Class: Fox::FXCalendar
- Inherits:
-
FXVerticalFrame
- Object
- FXObject
- FXId
- FXDrawable
- FXWindow
- FXComposite
- FXPacker
- FXVerticalFrame
- Fox::FXCalendar
- Defined in:
- lib/fox16/calendar.rb
Overview
Calendar widget
Events
The following messages are sent by FXCalendar to its target:
SEL_COMMAND
:: sent when a day button is clicked; the message data is a Time object indicating the selected date
Calendar options
CALENDAR_NORMAL
:: normal display mode CALENDAR_READONLY
:: read-only mode
Constant Summary collapse
- DAYS =
['SUN', 'MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT']
Instance Attribute Summary collapse
-
#dayLabelFont ⇒ Object
Font used for days [FXFont].
-
#selected ⇒ Object
readonly
Currently selected date [Time].
Attributes inherited from FXPacker
#baseColor, #borderColor, #borderWidth, #frameStyle, #hSpacing, #hiliteColor, #packingHints, #padBottom, #padLeft, #padRight, #padTop, #shadowColor, #vSpacing
Attributes inherited from FXWindow
#accelTable, #backColor, #defaultCursor, #dragCursor, #first, #focus, #key, #last, #layoutHints, #next, #numChildren, #owner, #parent, #prev, #root, #selector, #shell, #target, #x, #y
Attributes inherited from FXDrawable
Attributes inherited from FXId
Instance Method Summary collapse
-
#headerBackColor ⇒ Object
Return the current header background color.
-
#headerBackColor=(clr) ⇒ Object
Set the header background color.
-
#headerTextColor ⇒ Object
Return the current header text color.
-
#headerTextColor=(clr) ⇒ Object
Set the header text color.
-
#initialize(parent, initial_date = Time.now, tgt = nil, sel = 0, opts = 0, x = 0, y = 0, w = 0, h = 0, pl = DEFAULT_PAD, pr = DEFAULT_PAD, pt = DEFAULT_PAD, pb = DEFAULT_PAD) ⇒ FXCalendar
constructor
Returns an initialized calendar widget.
Methods inherited from FXComposite
#maxChildHeight, #maxChildWidth
Methods inherited from FXWindow
#acceptDrop, #acquireClipboard, #acquireSelection, #active?, #addHotKey, after?, #after?, before?, #before?, #beginDrag, #canFocus?, #changeFocus, #childAtIndex, #childOf?, #children, #clearDragRectangle, #clearShape, colorType, colorTypeName, commonAncestor, #composeContext, #composite?, #contains?, #containsChild?, #create, #createComposeContext, #cursorPosition, #default?, #defaultHeight, #defaultWidth, deleteType, deleteTypeName, #destroy, #destroyComposeContext, #detach, #didAccept, #disable, #doesSaveUnder?, #dragging?, #dropDisable, #dropEnable, #dropEnabled?, #dropFinished, #dropTarget?, #each_child, #each_child_recursive, #enable, #enabled?, #endDrag, #forceRefresh, #getChildAt, #getDNDData, #getHeightForWidth, #getWidthForHeight, #grab, #grabKeyboard, #grabbed?, #grabbedKeyboard?, #handleDrag, #hasClipboard?, #hasFocus?, #hasSelection?, #height, #height=, #hide, imageType, #inFocusChain?, #indexOfChild, #initial?, #inquireDNDAction, #inquireDNDTypes, #killFocus, #layout, #linkAfter, #linkBefore, #lower, #move, octetType, octetTypeName, #offeredDNDType?, #position, #raiseWindow, #recalc, #releaseClipboard, #releaseSelection, #remHotKey, #removeChild, #repaint, #reparent, #resize, #scroll, #setCursorPosition, #setDNDData, #setDefault, #setDragRectangle, #setFocus, #setInitial, #setShape, #shell?, #show, #shown?, stringType, textType, textTypeName, #tr, #translateCoordinatesFrom, #translateCoordinatesTo, #underCursor?, #ungrab, #ungrabKeyboard, #update, urilistType, urilistTypeName, utf16Type, utf16TypeName, utf8Type, utf8TypeName, #visible=, #width, #width=
Methods included from Responder2
Methods inherited from FXDrawable
Methods inherited from FXId
#create, #created?, #destroy, #detach, #runOnUiThread
Methods inherited from FXObject
#bind, #handle, #load, #save, subclasses
Constructor Details
#initialize(parent, initial_date = Time.now, tgt = nil, sel = 0, opts = 0, x = 0, y = 0, w = 0, h = 0, pl = DEFAULT_PAD, pr = DEFAULT_PAD, pt = DEFAULT_PAD, pb = DEFAULT_PAD) ⇒ FXCalendar
Returns an initialized calendar widget
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/fox16/calendar.rb', line 54 def initialize(parent, initial_date=Time.now, tgt=nil, sel=0, opts=0, x=0, y=0, w=0, h=0, pl=DEFAULT_PAD, pr=DEFAULT_PAD, pt=DEFAULT_PAD, pb=DEFAULT_PAD) # Initialize the base class first super(parent, opts, x, y, w, h, pl, pr, pt, pb) # Save target and selector self.target = tgt self.selector = sel @headerBGColor = FXColor::Black @headerFGColor = FXColor::White @dayLabelFont = FXFont.new(getApp, "helvetica", 7) @date_showing = initial_date # Header row @header = FXHorizontalFrame.new(self, LAYOUT_FILL_X) @header.backColor = @headerBGColor @backBtn = FXArrowButton.new(@header, nil, 0, FRAME_RAISED|FRAME_THICK|ARROW_LEFT|ARROW_REPEAT) @backBtn.connect(SEL_COMMAND) do |send, sel, ev| @date_showing = _last_month _build_date_matrix @current_month.text = _header_date end @current_month = FXLabel.new(@header, _header_date, nil, LAYOUT_FILL_X|JUSTIFY_CENTER_X|LAYOUT_FILL_Y) @current_month.backColor = @headerBGColor @current_month.textColor = @headerFGColor @foreBtn = FXArrowButton.new(@header, nil, 0, FRAME_RAISED|FRAME_THICK|ARROW_RIGHT|ARROW_REPEAT) @foreBtn.connect(SEL_COMMAND) do |send, sel, ev| @date_showing = _next_month _build_date_matrix @current_month.text = _header_date end @matrix = FXMatrix.new(self, 7, MATRIX_BY_COLUMNS|LAYOUT_FILL_X|LAYOUT_FILL_Y|PACK_UNIFORM_WIDTH|FRAME_RAISED, 0, 0, 0, 0, 0, 0, 0, 0) DAYS.each { |day| _add_matrix_label(day) } (7*6 - 1).times do s = FXSwitcher.new(@matrix, LAYOUT_FILL_X|LAYOUT_FILL_Y|LAYOUT_FILL_ROW|LAYOUT_FILL_COLUMN, 0,0,0,0,0,0,0,0) FXFrame.new(s, LAYOUT_FILL_X|LAYOUT_FILL_Y, 0,0,0,0,0,0,0,0) btn = FXButton.new(s, '99', nil, nil, 0, LAYOUT_FILL_X|LAYOUT_FILL_Y|FRAME_RAISED|FRAME_THICK, 0,0,0,0,0,0,0,0) btn.connect(SEL_COMMAND) do |send, sel, ev| @selected = Time.local(@date_showing.year, @date_showing.month, send.text.to_i) target.handle(self, Fox.MKUINT(selector, SEL_COMMAND), @selected) if target end end _build_date_matrix() end |
Instance Attribute Details
#dayLabelFont ⇒ Object
Font used for days [FXFont]
49 50 51 |
# File 'lib/fox16/calendar.rb', line 49 def dayLabelFont @dayLabelFont end |
#selected ⇒ Object (readonly)
Currently selected date [Time]
46 47 48 |
# File 'lib/fox16/calendar.rb', line 46 def selected @selected end |
Instance Method Details
#headerBackColor ⇒ Object
Return the current header background color
109 110 111 |
# File 'lib/fox16/calendar.rb', line 109 def headerBackColor @headerBGColor end |
#headerBackColor=(clr) ⇒ Object
Set the header background color
114 115 116 117 118 119 |
# File 'lib/fox16/calendar.rb', line 114 def headerBackColor=(clr) @headerBGColor = clr @header.backColor = clr @current_month.backColor = clr DAYS.each_index { |i| @matrix.childAtIndex(i).backColor = clr } end |
#headerTextColor ⇒ Object
Return the current header text color
122 123 124 |
# File 'lib/fox16/calendar.rb', line 122 def headerTextColor @headerFGColor end |
#headerTextColor=(clr) ⇒ Object
Set the header text color
127 128 129 130 131 |
# File 'lib/fox16/calendar.rb', line 127 def headerTextColor=(clr) @headerFGColor = clr @current_month.textColor = clr DAYS.each_index { |i| @matrix.childAtIndex(i).textColor = clr } end |