![](http://www.gnu-darwin.org/hexley-gd-sm.png)
|
# File ../lib/fox/calendar.rb, line 49
def initialize(parent, initial_date=Time.now, target=nil, selector=0, opts=0, x=0, y=0, width=0, height=0, padLeft=DEFAULT_PAD, padRight=DEFAULT_PAD, padTop=DEFAULT_PAD, padBottom=DEFAULT_PAD)
# Initialize the base class first
super(parent, opts, x, y, width, height, padLeft, padRight, padTop, padBottom)
# Save target and selector
self.target = target
self.selector = selector
@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, MKUINT(selector, SEL_COMMAND), nil) if target
end
end
_build_date_matrix()
end
|