wxruby 1.9.9-x86-mingw32 → 1.9.10-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (152) hide show
  1. data/LICENSE +53 -53
  2. data/README +297 -297
  3. data/lib/wx.rb +53 -53
  4. data/lib/wx/classes/bitmap.rb +29 -1
  5. data/lib/wx/classes/clipboard.rb +19 -3
  6. data/lib/wx/classes/colour.rb +6 -4
  7. data/lib/wx/classes/data_object.rb +14 -0
  8. data/lib/wx/classes/data_object_simple.rb +6 -0
  9. data/lib/wx/classes/dataformat.rb +23 -0
  10. data/lib/wx/classes/evthandler.rb +31 -4
  11. data/lib/wx/classes/genericdirctrl.rb +36 -0
  12. data/lib/wx/classes/grid.rb +8 -0
  13. data/lib/wx/classes/hboxsizer.rb +6 -0
  14. data/lib/wx/classes/icon.rb +12 -1
  15. data/lib/wx/classes/image.rb +13 -1
  16. data/lib/wx/classes/listctrl.rb +12 -0
  17. data/lib/wx/classes/point.rb +8 -0
  18. data/lib/wx/classes/rect.rb +10 -1
  19. data/lib/wx/classes/richtextctrl.rb +22 -0
  20. data/lib/wx/classes/size.rb +9 -0
  21. data/lib/wx/classes/sizer.rb +18 -3
  22. data/lib/wx/classes/toolbar.rb +4 -6
  23. data/lib/wx/classes/vboxsizer.rb +6 -0
  24. data/lib/wx/classes/window.rb +7 -0
  25. data/lib/wx/classes/xmlresource.rb +17 -0
  26. data/lib/wx/helpers.rb +16 -1
  27. data/lib/wx/keyword_ctors.rb +3 -2
  28. data/lib/wx/keyword_defs.rb +27 -5
  29. data/lib/wx/version.rb +1 -1
  30. data/lib/wxruby2.so +0 -0
  31. data/samples/SAMPLES-LICENSE.TXT +17 -17
  32. data/samples/bigdemo/About.rbw +39 -39
  33. data/samples/bigdemo/ColorPanel.rbw +23 -23
  34. data/samples/bigdemo/GridSimple.rbw +78 -78
  35. data/samples/bigdemo/MDIDemo.rbw +57 -57
  36. data/samples/bigdemo/PopupMenu.rbw +149 -149
  37. data/samples/bigdemo/Sizers.rbw +543 -543
  38. data/samples/bigdemo/bigdemo.rb +823 -823
  39. data/samples/bigdemo/demoTemplate.rbw +33 -33
  40. data/samples/bigdemo/icons/choice.xpm +27 -27
  41. data/samples/bigdemo/icons/combo.xpm +27 -27
  42. data/samples/bigdemo/icons/copy.xpm +25 -25
  43. data/samples/bigdemo/icons/cut.xpm +24 -24
  44. data/samples/bigdemo/icons/gauge.xpm +27 -27
  45. data/samples/bigdemo/icons/help.xpm +25 -25
  46. data/samples/bigdemo/icons/list.xpm +27 -27
  47. data/samples/bigdemo/icons/mondrian.xpm +44 -44
  48. data/samples/bigdemo/icons/new.xpm +24 -24
  49. data/samples/bigdemo/icons/ogl.ico +0 -0
  50. data/samples/bigdemo/icons/ogl.xpm +45 -45
  51. data/samples/bigdemo/icons/open.xpm +26 -26
  52. data/samples/bigdemo/icons/paste.xpm +38 -38
  53. data/samples/bigdemo/icons/preview.xpm +26 -26
  54. data/samples/bigdemo/icons/print.xpm +26 -26
  55. data/samples/bigdemo/icons/radio.xpm +27 -27
  56. data/samples/bigdemo/icons/robert.xpm +415 -415
  57. data/samples/bigdemo/icons/save.xpm +25 -25
  58. data/samples/bigdemo/icons/smiles.xpm +39 -39
  59. data/samples/bigdemo/icons/smiley.xpm +42 -42
  60. data/samples/bigdemo/icons/stattext.xpm +24 -24
  61. data/samples/bigdemo/icons/test2.bmp +0 -0
  62. data/samples/bigdemo/icons/test2.xpm +79 -79
  63. data/samples/bigdemo/icons/text.xpm +27 -27
  64. data/samples/bigdemo/icons/tog1.xpm +38 -38
  65. data/samples/bigdemo/icons/tog2.xpm +38 -38
  66. data/samples/bigdemo/icons/wxwin16x16.xpm +25 -25
  67. data/samples/bigdemo/tips.txt +7 -7
  68. data/samples/bigdemo/utils.rb +11 -11
  69. data/samples/bigdemo/wxButton.rbw +64 -64
  70. data/samples/bigdemo/wxCalendarCtrl.rbw +60 -60
  71. data/samples/bigdemo/wxCheckBox.rbw +50 -50
  72. data/samples/bigdemo/wxCheckListBox.rbw +65 -75
  73. data/samples/bigdemo/wxChoice.rbw +47 -47
  74. data/samples/bigdemo/wxColourDialog.rbw +31 -31
  75. data/samples/bigdemo/wxComboBox.rbw +77 -77
  76. data/samples/bigdemo/wxDialog.rbw +74 -74
  77. data/samples/bigdemo/wxDirDialog.rbw +29 -29
  78. data/samples/bigdemo/wxFileDialog.rbw +37 -37
  79. data/samples/bigdemo/wxFileDialog_Save.rbw +35 -35
  80. data/samples/bigdemo/wxFindReplaceDialog.rbw +82 -82
  81. data/samples/bigdemo/wxFontDialog.rbw +173 -173
  82. data/samples/bigdemo/wxFrame.rbw +53 -53
  83. data/samples/bigdemo/wxGauge.rbw +71 -71
  84. data/samples/bigdemo/wxGrid.rbw +66 -66
  85. data/samples/bigdemo/wxListBox.rbw +140 -140
  86. data/samples/bigdemo/wxListCtrl_virtual.rbw +112 -107
  87. data/samples/bigdemo/wxMDIWindows.rbw +50 -50
  88. data/samples/bigdemo/wxMenu.rbw +236 -236
  89. data/samples/bigdemo/wxMessageDialog.rbw +27 -27
  90. data/samples/bigdemo/wxMultipleChoiceDialog.rbw +32 -32
  91. data/samples/bigdemo/wxNotebook.rbw +136 -136
  92. data/samples/bigdemo/wxProgressDialog.rbw +43 -43
  93. data/samples/bigdemo/wxRadioBox.rbw +72 -72
  94. data/samples/bigdemo/wxRadioButton.rbw +125 -125
  95. data/samples/bigdemo/wxSashWindow.rbw +2 -2
  96. data/samples/bigdemo/wxScrolledMessageDialog.rbw +57 -57
  97. data/samples/bigdemo/wxScrolledWindow.rbw +199 -199
  98. data/samples/bigdemo/wxSingleChoiceDialog.rbw +33 -33
  99. data/samples/bigdemo/wxSlider.rbw +42 -42
  100. data/samples/bigdemo/wxSpinButton.rbw +50 -50
  101. data/samples/bigdemo/wxSpinCtrl.rbw +51 -51
  102. data/samples/bigdemo/wxSplitterWindow.rbw +63 -63
  103. data/samples/bigdemo/wxStaticBitmap.rbw +51 -51
  104. data/samples/bigdemo/wxStaticText.rbw +55 -55
  105. data/samples/bigdemo/wxStatusBar.rbw +126 -126
  106. data/samples/bigdemo/wxTextCtrl.rbw +149 -149
  107. data/samples/bigdemo/wxTextEntryDialog.rbw +31 -31
  108. data/samples/bigdemo/wxToggleButton.rbw +49 -49
  109. data/samples/bigdemo/wxToolBar.rbw +131 -131
  110. data/samples/bigdemo/wxTreeCtrl.rbw +191 -190
  111. data/samples/calendar/calendar.rb +256 -271
  112. data/samples/caret/caret.rb +282 -282
  113. data/samples/caret/mondrian.xpm +44 -44
  114. data/samples/controls/controls.rb +1136 -1136
  115. data/samples/controls/get_item_sample.rb +87 -87
  116. data/samples/controls/icons/choice.xpm +27 -27
  117. data/samples/controls/icons/combo.xpm +27 -27
  118. data/samples/controls/icons/gauge.xpm +27 -27
  119. data/samples/controls/icons/list.xpm +27 -27
  120. data/samples/controls/icons/radio.xpm +27 -27
  121. data/samples/controls/icons/stattext.xpm +24 -24
  122. data/samples/controls/icons/text.xpm +27 -27
  123. data/samples/controls/mondrian.xpm +44 -44
  124. data/samples/dialogs/dialogs.rb +797 -723
  125. data/samples/dialogs/tips.txt +18 -18
  126. data/samples/drawing/images.rb +37 -37
  127. data/samples/etc/activation.rb +102 -102
  128. data/samples/etc/choice.rb +67 -67
  129. data/samples/etc/miniframe.rb +79 -79
  130. data/samples/etc/sash.rb +130 -130
  131. data/samples/etc/scrollwin.rb +110 -110
  132. data/samples/etc/system_settings.rb +252 -252
  133. data/samples/etc/toolbar_sizer_additem.rb +55 -0
  134. data/samples/etc/wizard.rb +74 -74
  135. data/samples/event/update_ui_event.rb +70 -0
  136. data/samples/grid/gridtablebase.rb +43 -29
  137. data/samples/listbook/listbook.rb +174 -174
  138. data/samples/listbook/listbook.xrc +370 -370
  139. data/samples/mdi/mdi.rb +85 -77
  140. data/samples/minimal/minimal.rb +77 -77
  141. data/samples/minimal/nothing.rb +16 -16
  142. data/samples/text/format-text-bold.png +0 -0
  143. data/samples/text/format-text-italic.png +0 -0
  144. data/samples/text/format-text-underline.png +0 -0
  145. data/samples/text/rich_textctrl.rb +98 -0
  146. data/samples/text/textctrl.rb +111 -113
  147. data/samples/text/unicode.rb +242 -242
  148. data/samples/text/utf8.txt +14 -14
  149. data/samples/treectrl/treectrl.rb +1166 -1174
  150. data/samples/xrc/samples.xrc +46 -46
  151. data/samples/xrc/xrc_sample.rb +76 -96
  152. metadata +15 -3
@@ -1,271 +1,256 @@
1
- #!/usr/bin/env ruby
2
- # wxRuby2 Sample Code. Copyright (c) 2004-2008 wxRuby development team
3
- # Freely reusable code: see SAMPLES-LICENSE.TXT for details
4
- begin
5
- require 'rubygems'
6
- rescue LoadError
7
- end
8
- require 'wx'
9
-
10
-
11
- include Wx
12
-
13
- require 'date'
14
-
15
-
16
- Calendar_File_About = ID_ABOUT
17
- Calendar_File_Quit = ID_EXIT
18
- Calendar_Cal_Monday = 200
19
- Calendar_Cal_Holidays = 201
20
- Calendar_Cal_Special = 202
21
- Calendar_Cal_Month = 203
22
- Calendar_Cal_Year = 204
23
- Calendar_Cal_SeqMonth = 205
24
- Calendar_Cal_SurroundWeeks = 206
25
-
26
-
27
- def format_date(d)
28
- return "#{d.year}-#{d.mon}-#{d.day}"
29
- end
30
-
31
- class MyCalendar < CalendarCtrl
32
- def initialize(parent, display_frame, initial_date, calendar_flags)
33
- super(parent, -1,
34
- initial_date,
35
- DEFAULT_POSITION,
36
- DEFAULT_SIZE,
37
- calendar_flags | RAISED_BORDER)
38
-
39
- @display = display_frame
40
- @date = initial_date
41
- @weekday_names = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']
42
-
43
- id = get_id
44
- evt_calendar(id) {|event| on_calendar(event)}
45
- evt_calendar_month(id) {on_cal_month_change}
46
- evt_calendar_year(id) {on_cal_year_change}
47
- evt_calendar_sel_changed(id) {|event| on_calendar_change(event)}
48
- evt_calendar_weekday_clicked(id) {|event| on_calendar_weekday_click(event)}
49
- end
50
-
51
- def on_calendar(event)
52
- @date = event.get_date
53
- @display.set_date(@date)
54
- end
55
-
56
- def on_calendar_change(event)
57
- @date = event.get_date
58
- log_status("Selected date: #{format_date(@date)}")
59
- end
60
-
61
- def on_cal_month_change
62
- log_status("Calendar month changed")
63
- end
64
-
65
- def on_cal_year_change
66
- log_status("Calendar year changed")
67
- end
68
-
69
- def on_calendar_weekday_click(event)
70
- wday = event.get_week_day
71
- log_status("Clicked on #{@weekday_names[wday]}")
72
- end
73
-
74
- attr_reader :date
75
- end
76
-
77
- class MyFrame < Frame
78
- def initialize(title)
79
- super(nil, -1, title)
80
- @panel = Wx::Panel.new(self)
81
- add_menu_bar
82
- add_status_bar
83
-
84
- @calendar_flags = CAL_MONDAY_FIRST | CAL_SHOW_HOLIDAYS
85
-
86
- now = DateTime.now
87
- @calendar = MyCalendar.new(@panel, self, now, @calendar_flags)
88
-
89
- @sizer = BoxSizer.new(VERTICAL)
90
- configure_window
91
-
92
- evt_menu(Calendar_File_Quit) {on_quit}
93
- evt_menu(Calendar_File_About) {on_about}
94
-
95
- evt_menu(Calendar_Cal_Monday) {|event| on_cal_monday(event)}
96
- evt_menu(Calendar_Cal_Holidays) {|event| on_cal_holidays(event)}
97
- evt_menu(Calendar_Cal_Special) {|event| on_cal_special(event)}
98
-
99
- evt_menu(Calendar_Cal_Month) {|event| on_cal_allow_month(event)}
100
- evt_menu(Calendar_Cal_Year) {|event| on_cal_allow_year(event)}
101
-
102
- evt_menu(Calendar_Cal_SeqMonth) {|event| on_cal_seq_month(event)}
103
- evt_menu(Calendar_Cal_SurroundWeeks) {|event| on_cal_show_surrounding_weeks(event)}
104
-
105
- evt_update_ui(Calendar_Cal_Year) {|event| on_allow_year_update(event)}
106
- end
107
-
108
- def add_menu_bar
109
- # create a menu bar
110
- menu_file = Menu.new
111
-
112
- menu_file.append(Calendar_File_About, "&About...\tCtrl-A", "Show about dialog")
113
- menu_file.append_separator()
114
- menu_file.append(Calendar_File_Quit, "E&xit\tAlt-X", "Quit self program")
115
-
116
- menu_cal = Menu.new
117
- menu_cal.append(Calendar_Cal_Monday,
118
- "Monday &first weekday\tCtrl-F",
119
- "Toggle between Mon and Sun as the first week day",
120
- ITEM_CHECK)
121
- menu_cal.append(Calendar_Cal_Holidays, "Show &holidays\tCtrl-H",
122
- "Toggle highlighting the holidays",
123
- ITEM_CHECK)
124
- menu_cal.append(Calendar_Cal_Special, "Highlight &special dates\tCtrl-S",
125
- "Test custom highlighting",
126
- ITEM_CHECK)
127
- menu_cal.append(Calendar_Cal_SurroundWeeks,
128
- "Show s&urrounding weeks\tCtrl-W",
129
- "Show the neighbouring weeks in the prev/next month",
130
- ITEM_CHECK)
131
- menu_cal.append_separator()
132
- menu_cal.append(Calendar_Cal_SeqMonth,
133
- "To&ggle month selector style\tCtrl-G",
134
- "Use another style for the calendar controls",
135
- ITEM_CHECK)
136
- menu_cal.append(Calendar_Cal_Month, "&Month can be changed\tCtrl-M",
137
- "Allow changing the month in the calendar",
138
- ITEM_CHECK)
139
- menu_cal.append(Calendar_Cal_Year, "&Year can be changed\tCtrl-Y",
140
- "Allow changing the year in the calendar",
141
- ITEM_CHECK)
142
-
143
- # now append the freshly created menu to the menu bar...
144
- menu_bar = MenuBar.new
145
- menu_bar.append(menu_file, "&File")
146
- menu_bar.append(menu_cal, "&Calendar")
147
-
148
- menu_bar.check(Calendar_Cal_Monday, TRUE)
149
- menu_bar.check(Calendar_Cal_Holidays, TRUE)
150
- menu_bar.check(Calendar_Cal_Month, TRUE)
151
- menu_bar.check(Calendar_Cal_Year, TRUE)
152
-
153
- # ... and attach self menu bar to the frame
154
- set_menu_bar(menu_bar)
155
- end
156
-
157
- def add_status_bar
158
- # create a status bar just for fun (by default with 1 pane only)
159
- create_status_bar
160
- set_status_text("Welcome to Windows!")
161
- end
162
-
163
- def configure_window
164
- @sizer.add(@calendar, 0, Wx::ALIGN_CENTRE|Wx::ALL, 5)
165
- @sizer.set_size_hints(@panel)
166
- layout
167
- @panel.set_sizer(@sizer)
168
- end
169
-
170
- def on_quit
171
- # true is to force the frame to close
172
- close(true)
173
- end
174
-
175
- def on_about
176
- message_box("wxRuby CalendarCtrl sample\nby Kevin Smith\n" +
177
- "based on the wxWidgets version by Vadim Zeitlin",
178
- "About Calendar", OK | ICON_INFORMATION, self)
179
- end
180
-
181
- def on_cal_monday(event)
182
- enable = get_menu_bar().is_checked(event.get_id())
183
- toggle_cal_style(enable, CAL_MONDAY_FIRST)
184
- end
185
-
186
- def on_cal_holidays(event)
187
- enable = get_menu_bar().is_checked(event.get_id())
188
- @calendar.enable_holiday_display(enable)
189
- end
190
-
191
- def on_cal_special(event)
192
- highlight_special(get_menu_bar().is_checked(event.get_id()))
193
- end
194
-
195
- def on_cal_allow_month(event)
196
- allow = get_menu_bar().is_checked(event.get_id())
197
- @calendar.enable_month_change(allow)
198
- end
199
-
200
- def on_cal_allow_year(event)
201
- allow = get_menu_bar().is_checked(event.get_id())
202
- @calendar.enable_year_change(allow)
203
- end
204
-
205
- def on_cal_seq_month(event)
206
- allow = get_menu_bar().is_checked(event.get_id())
207
- toggle_cal_style(allow, CAL_SEQUENTIAL_MONTH_SELECTION)
208
- end
209
-
210
- def on_cal_show_surrounding_weeks(event)
211
- allow = get_menu_bar().is_checked(event.get_id())
212
- toggle_cal_style(allow, CAL_SHOW_SURROUNDING_WEEKS)
213
- end
214
-
215
- def on_allow_year_update(event)
216
- event.enable( get_menu_bar().is_checked(Calendar_Cal_Month))
217
- end
218
-
219
- def toggle_cal_style(on,flag)
220
- style = @calendar.get_window_style_flag
221
- date = @calendar.date
222
- @sizer.detach(@calendar)
223
- @calendar.destroy
224
- if on
225
- style |= flag
226
- else
227
- style &= ~flag
228
- end
229
- @calendar = MyCalendar.new(@panel, self, date, style)
230
- @sizer.add(@calendar, 0, Wx::ALIGN_CENTRE|Wx::ALL, 5)
231
- @panel.layout
232
- end
233
-
234
- def highlight_special(on)
235
- if on
236
- attr_red_circle = CalendarDateAttr.new(CAL_BORDER_ROUND, RED)
237
- attr_green_square = CalendarDateAttr.new(CAL_BORDER_SQUARE, GREEN)
238
- # This wraps correctly, but causes problems because the colour is freed
239
- # when the attribute is reset.
240
- #
241
- # attr_header_like = CalendarDateAttr.new(BLUE, LIGHT_GREY)
242
-
243
- @calendar.set_attr(17, attr_red_circle)
244
- @calendar.set_attr(29, attr_green_square)
245
- # @calendar.set_attr(13, attr_header_like)
246
- else
247
- @calendar.reset_attr(17)
248
- @calendar.reset_attr(29)
249
- # @calendar.reset_attr(13)
250
- end
251
- @calendar.refresh()
252
- end
253
-
254
- def set_date(d)
255
- str = "%s-%s-%s" % [ d.year, d.mon, d.day ]
256
- Wx::MessageDialog.new( self, "The selected date is #{str}",
257
- "Date chosen" ).show_modal
258
- end
259
-
260
- end
261
-
262
-
263
- class RbApp < App
264
- def on_init()
265
- frame = MyFrame.new("Calendar Windows sample")
266
- frame.show(true)
267
- end
268
- end
269
-
270
- a = RbApp.new
271
- a.main_loop()
1
+ #!/usr/bin/env ruby
2
+ # wxRuby2 Sample Code. Copyright (c) 2004-2008 wxRuby development team
3
+ # Freely reusable code: see SAMPLES-LICENSE.TXT for details
4
+ begin
5
+ require 'rubygems'
6
+ rescue LoadError
7
+ end
8
+ require 'wx'
9
+
10
+ include Wx
11
+
12
+ Calendar_Cal_Monday = 200
13
+ Calendar_Cal_Holidays = 201
14
+ Calendar_Cal_Special = 202
15
+ Calendar_Cal_Month = 203
16
+ Calendar_Cal_Year = 204
17
+ Calendar_Cal_SeqMonth = 205
18
+ Calendar_Cal_SurroundWeeks = 206
19
+
20
+
21
+ class MyCalendar < CalendarCtrl
22
+ def initialize(parent, display_frame, initial_date, calendar_flags)
23
+ super( parent,
24
+ :date => initial_date,
25
+ :style => calendar_flags | RAISED_BORDER)
26
+
27
+ @display = display_frame
28
+ @date = initial_date
29
+ @weekday_names = %w|Sun Mon Tue Wed Thu Fri Sat|
30
+
31
+ evt_calendar self, :on_calendar
32
+ evt_calendar_month self, :on_cal_month_change
33
+ evt_calendar_year self, :on_cal_year_change
34
+ evt_calendar_sel_changed self, :on_calendar_change
35
+ evt_calendar_weekday_clicked self, :on_calendar_weekday_click
36
+ end
37
+
38
+ def on_calendar(event)
39
+ @display.date = event.date
40
+ end
41
+
42
+ def on_calendar_change(event)
43
+ @date = event.date
44
+ log_status("Selected date: #{@date.strftime('%Y-%M-%D')}")
45
+ end
46
+
47
+ def on_cal_month_change
48
+ log_status("Calendar month changed")
49
+ end
50
+
51
+ def on_cal_year_change
52
+ log_status("Calendar year changed")
53
+ end
54
+
55
+ def on_calendar_weekday_click(event)
56
+ wday = event.week_day
57
+ log_status("Clicked on #{@weekday_names[wday]}")
58
+ end
59
+
60
+ attr_reader :date
61
+ end
62
+
63
+ class MyFrame < Frame
64
+ def initialize(title)
65
+ super(nil, -1, title)
66
+ @panel = Wx::Panel.new(self)
67
+ add_menu_bar
68
+ add_status_bar
69
+
70
+ @calendar_flags = CAL_MONDAY_FIRST | CAL_SHOW_HOLIDAYS
71
+
72
+ @calendar = MyCalendar.new(@panel, self, Time.now, @calendar_flags)
73
+
74
+ @sizer = BoxSizer.new(VERTICAL)
75
+ configure_window
76
+
77
+ evt_menu Wx::ID_EXIT, :on_quit
78
+ evt_menu Wx::ID_ABOUT, :on_about
79
+
80
+ evt_menu Calendar_Cal_Monday, :on_cal_monday
81
+ evt_menu Calendar_Cal_Holidays, :on_cal_holidays
82
+ evt_menu Calendar_Cal_Special, :on_cal_special
83
+
84
+ evt_menu Calendar_Cal_Month, :on_cal_allow_month
85
+ evt_menu Calendar_Cal_Year, :on_cal_allow_year
86
+
87
+ evt_menu Calendar_Cal_SeqMonth, :on_cal_seq_month
88
+ evt_menu Calendar_Cal_SurroundWeeks, :on_cal_show_surrounding_weeks
89
+
90
+ evt_update_ui Calendar_Cal_Year, :on_allow_year_update
91
+ end
92
+
93
+ def add_menu_bar
94
+ # create a menu bar
95
+ menu_file = Menu.new
96
+
97
+ menu_file.append(Wx::ID_ABOUT, "&About...\tCtrl-A", "Show about dialog")
98
+ menu_file.append_separator
99
+ menu_file.append(Wx::ID_EXIT, "E&xit\tAlt-X", "Quit self program")
100
+
101
+ menu_cal = Menu.new
102
+ menu_cal.append(Calendar_Cal_Monday,
103
+ "Monday &first weekday\tCtrl-F",
104
+ "Toggle between Mon and Sun as the first week day",
105
+ ITEM_CHECK)
106
+ menu_cal.append(Calendar_Cal_Holidays, "Show &holidays\tCtrl-H",
107
+ "Toggle highlighting the holidays",
108
+ ITEM_CHECK)
109
+ menu_cal.append(Calendar_Cal_Special, "Highlight &special dates\tCtrl-S",
110
+ "Test custom highlighting",
111
+ ITEM_CHECK)
112
+ menu_cal.append(Calendar_Cal_SurroundWeeks,
113
+ "Show s&urrounding weeks\tCtrl-W",
114
+ "Show the neighbouring weeks in the prev/next month",
115
+ ITEM_CHECK)
116
+ menu_cal.append_separator
117
+ menu_cal.append(Calendar_Cal_SeqMonth,
118
+ "To&ggle month selector style\tCtrl-G",
119
+ "Use another style for the calendar controls",
120
+ ITEM_CHECK)
121
+ menu_cal.append(Calendar_Cal_Month, "&Month can be changed\tCtrl-M",
122
+ "Allow changing the month in the calendar",
123
+ ITEM_CHECK)
124
+ menu_cal.append(Calendar_Cal_Year, "&Year can be changed\tCtrl-Y",
125
+ "Allow changing the year in the calendar",
126
+ ITEM_CHECK)
127
+
128
+ # now append the freshly created menu to the menu bar...
129
+ menu_bar = MenuBar.new
130
+ menu_bar.append(menu_file, "&File")
131
+ menu_bar.append(menu_cal, "&Calendar")
132
+
133
+ menu_bar.check(Calendar_Cal_Monday, TRUE)
134
+ menu_bar.check(Calendar_Cal_Holidays, TRUE)
135
+ menu_bar.check(Calendar_Cal_Month, TRUE)
136
+ menu_bar.check(Calendar_Cal_Year, TRUE)
137
+
138
+ # ... and attach self menu bar to the frame
139
+ self.menu_bar = menu_bar
140
+ end
141
+
142
+ def add_status_bar
143
+ # create a status bar just for fun (by default with 1 pane only)
144
+ create_status_bar
145
+ set_status_text("Welcome to Windows!")
146
+ end
147
+
148
+ def configure_window
149
+ @sizer.add(@calendar, 0, Wx::ALIGN_CENTRE|Wx::ALL, 5)
150
+ @sizer.size_hints = @panel
151
+ layout
152
+ @panel.sizer = @sizer
153
+ end
154
+
155
+ def on_quit
156
+ # true is to force the frame to close
157
+ close(true)
158
+ end
159
+
160
+ def on_about
161
+ message_box("wxRuby CalendarCtrl sample\nby Kevin Smith\n" +
162
+ "based on the wxWidgets version by Vadim Zeitlin",
163
+ "About Calendar", OK | ICON_INFORMATION, self)
164
+ end
165
+
166
+ def on_cal_monday(event)
167
+ enable = get_menu_bar().is_checked(event.get_id())
168
+ toggle_cal_style(enable, CAL_MONDAY_FIRST)
169
+ end
170
+
171
+ def on_cal_holidays(event)
172
+ enable = get_menu_bar().is_checked(event.get_id())
173
+ @calendar.enable_holiday_display(enable)
174
+ end
175
+
176
+ def on_cal_special(event)
177
+ highlight_special(get_menu_bar().is_checked(event.get_id()))
178
+ end
179
+
180
+ def on_cal_allow_month(event)
181
+ allow = get_menu_bar().is_checked(event.get_id())
182
+ @calendar.enable_month_change(allow)
183
+ end
184
+
185
+ def on_cal_allow_year(event)
186
+ allow = get_menu_bar().is_checked(event.get_id())
187
+ @calendar.enable_year_change(allow)
188
+ end
189
+
190
+ def on_cal_seq_month(event)
191
+ allow = get_menu_bar().is_checked(event.get_id())
192
+ toggle_cal_style(allow, CAL_SEQUENTIAL_MONTH_SELECTION)
193
+ end
194
+
195
+ def on_cal_show_surrounding_weeks(event)
196
+ allow = get_menu_bar().is_checked(event.get_id())
197
+ toggle_cal_style(allow, CAL_SHOW_SURROUNDING_WEEKS)
198
+ end
199
+
200
+ def on_allow_year_update(event)
201
+ event.enable( get_menu_bar().is_checked(Calendar_Cal_Month))
202
+ end
203
+
204
+ def toggle_cal_style(on,flag)
205
+ style = @calendar.get_window_style_flag
206
+ date = @calendar.date
207
+ @sizer.detach(@calendar)
208
+ @calendar.destroy
209
+ if on
210
+ style |= flag
211
+ else
212
+ style &= ~flag
213
+ end
214
+ @calendar = MyCalendar.new(@panel, self, date, style)
215
+ @sizer.add(@calendar, 0, Wx::ALIGN_CENTRE|Wx::ALL, 5)
216
+ @panel.layout
217
+ end
218
+
219
+ def highlight_special(on)
220
+ if on
221
+ attr_red_circle = CalendarDateAttr.new(CAL_BORDER_ROUND, RED)
222
+ attr_green_square = CalendarDateAttr.new(CAL_BORDER_SQUARE, GREEN)
223
+ # This wraps correctly, but causes problems because the colour is freed
224
+ # when the attribute is reset.
225
+ #
226
+ # attr_header_like = CalendarDateAttr.new(BLUE, LIGHT_GREY)
227
+
228
+ @calendar.set_attr(17, attr_red_circle)
229
+ @calendar.set_attr(29, attr_green_square)
230
+ # @calendar.set_attr(13, attr_header_like)
231
+ else
232
+ @calendar.reset_attr(17)
233
+ @calendar.reset_attr(29)
234
+ # @calendar.reset_attr(13)
235
+ end
236
+ @calendar.refresh()
237
+ end
238
+
239
+ def set_date(d)
240
+ str = "%s-%s-%s" % [ d.year, d.mon, d.day ]
241
+ Wx::MessageDialog.new( self, "The selected date is #{str}",
242
+ "Date chosen" ).show_modal
243
+ end
244
+
245
+ end
246
+
247
+
248
+ class RbApp < App
249
+ def on_init()
250
+ frame = MyFrame.new("Calendar Windows sample")
251
+ frame.show(true)
252
+ end
253
+ end
254
+
255
+ a = RbApp.new
256
+ a.main_loop()