wxruby 1.9.6-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (236) hide show
  1. data/LICENSE +53 -0
  2. data/README +297 -0
  3. data/lib/wx/accessors.rb +52 -0
  4. data/lib/wx/classes/acceleratortable.rb +28 -0
  5. data/lib/wx/classes/animation.rb +18 -0
  6. data/lib/wx/classes/app.rb +45 -0
  7. data/lib/wx/classes/artprovider.rb +31 -0
  8. data/lib/wx/classes/bitmap.rb +28 -0
  9. data/lib/wx/classes/busycursor.rb +12 -0
  10. data/lib/wx/classes/checklistbox.rb +45 -0
  11. data/lib/wx/classes/choice.rb +4 -0
  12. data/lib/wx/classes/clientdc.rb +13 -0
  13. data/lib/wx/classes/clipboard.rb +16 -0
  14. data/lib/wx/classes/colour.rb +47 -0
  15. data/lib/wx/classes/combobox.rb +4 -0
  16. data/lib/wx/classes/commandevent.rb +7 -0
  17. data/lib/wx/classes/controlwithitems.rb +10 -0
  18. data/lib/wx/classes/dc.rb +57 -0
  19. data/lib/wx/classes/event.rb +5 -0
  20. data/lib/wx/classes/evthandler.rb +921 -0
  21. data/lib/wx/classes/font.rb +118 -0
  22. data/lib/wx/classes/functions.rb +44 -0
  23. data/lib/wx/classes/gauge.rb +12 -0
  24. data/lib/wx/classes/grid.rb +138 -0
  25. data/lib/wx/classes/helpcontroller.rb +5 -0
  26. data/lib/wx/classes/htmlhelpcontroller.rb +5 -0
  27. data/lib/wx/classes/htmlwindow.rb +14 -0
  28. data/lib/wx/classes/icon.rb +21 -0
  29. data/lib/wx/classes/iconbundle.rb +3 -0
  30. data/lib/wx/classes/image.rb +31 -0
  31. data/lib/wx/classes/imagelist.rb +3 -0
  32. data/lib/wx/classes/listbox.rb +4 -0
  33. data/lib/wx/classes/listctrl.rb +21 -0
  34. data/lib/wx/classes/locale.rb +28 -0
  35. data/lib/wx/classes/mediactrl.rb +22 -0
  36. data/lib/wx/classes/menu.rb +62 -0
  37. data/lib/wx/classes/menuitem.rb +7 -0
  38. data/lib/wx/classes/object.rb +7 -0
  39. data/lib/wx/classes/paintdc.rb +12 -0
  40. data/lib/wx/classes/point.rb +48 -0
  41. data/lib/wx/classes/previewframe.rb +13 -0
  42. data/lib/wx/classes/rect.rb +10 -0
  43. data/lib/wx/classes/size.rb +49 -0
  44. data/lib/wx/classes/sound.rb +23 -0
  45. data/lib/wx/classes/styledtextctrl.rb +92 -0
  46. data/lib/wx/classes/textctrl.rb +14 -0
  47. data/lib/wx/classes/texturlevent.rb +6 -0
  48. data/lib/wx/classes/timer.rb +94 -0
  49. data/lib/wx/classes/toolbartool.rb +4 -0
  50. data/lib/wx/classes/treectrl.rb +44 -0
  51. data/lib/wx/classes/window.rb +82 -0
  52. data/lib/wx/classes/xmlresource.rb +37 -0
  53. data/lib/wx/keyword_ctors.rb +222 -0
  54. data/lib/wx/keyword_defs.rb +492 -0
  55. data/lib/wx/version.rb +3 -0
  56. data/lib/wx.rb +42 -0
  57. data/lib/wxruby2.so +0 -0
  58. data/samples/SAMPLES-LICENSE.TXT +18 -0
  59. data/samples/aui/aui.rb +1356 -0
  60. data/samples/bigdemo/About.rbw +39 -0
  61. data/samples/bigdemo/ColorPanel.rbw +23 -0
  62. data/samples/bigdemo/GridSimple.rbw +78 -0
  63. data/samples/bigdemo/MDIDemo.rbw +57 -0
  64. data/samples/bigdemo/PopupMenu.rbw +149 -0
  65. data/samples/bigdemo/ShapedWindow.rbw +131 -0
  66. data/samples/bigdemo/Sizers.rbw +543 -0
  67. data/samples/bigdemo/bigdemo.rb +823 -0
  68. data/samples/bigdemo/demoTemplate.rbw +33 -0
  69. data/samples/bigdemo/helpfile.htb +0 -0
  70. data/samples/bigdemo/icons/Test 015.jpg +0 -0
  71. data/samples/bigdemo/icons/Test 015.png +0 -0
  72. data/samples/bigdemo/icons/choice.bmp +0 -0
  73. data/samples/bigdemo/icons/choice.xpm +27 -0
  74. data/samples/bigdemo/icons/combo.bmp +0 -0
  75. data/samples/bigdemo/icons/combo.xpm +27 -0
  76. data/samples/bigdemo/icons/copy.xpm +25 -0
  77. data/samples/bigdemo/icons/cut.xpm +24 -0
  78. data/samples/bigdemo/icons/gauge.bmp +0 -0
  79. data/samples/bigdemo/icons/gauge.xpm +27 -0
  80. data/samples/bigdemo/icons/help.xpm +25 -0
  81. data/samples/bigdemo/icons/list.bmp +0 -0
  82. data/samples/bigdemo/icons/list.xpm +27 -0
  83. data/samples/bigdemo/icons/mondrian.ico +0 -0
  84. data/samples/bigdemo/icons/mondrian.xpm +44 -0
  85. data/samples/bigdemo/icons/new.xpm +24 -0
  86. data/samples/bigdemo/icons/ogl.ico +0 -0
  87. data/samples/bigdemo/icons/ogl.xpm +45 -0
  88. data/samples/bigdemo/icons/open.xpm +26 -0
  89. data/samples/bigdemo/icons/paste.bmp +0 -0
  90. data/samples/bigdemo/icons/paste.xpm +38 -0
  91. data/samples/bigdemo/icons/pointy.png +0 -0
  92. data/samples/bigdemo/icons/preview.xpm +26 -0
  93. data/samples/bigdemo/icons/print.xpm +26 -0
  94. data/samples/bigdemo/icons/radio.bmp +0 -0
  95. data/samples/bigdemo/icons/radio.xpm +27 -0
  96. data/samples/bigdemo/icons/robert.xpm +415 -0
  97. data/samples/bigdemo/icons/ruby.png +0 -0
  98. data/samples/bigdemo/icons/sashtest.ico +0 -0
  99. data/samples/bigdemo/icons/save.xpm +25 -0
  100. data/samples/bigdemo/icons/smiles.bmp +0 -0
  101. data/samples/bigdemo/icons/smiles.xpm +39 -0
  102. data/samples/bigdemo/icons/smiley.ico +0 -0
  103. data/samples/bigdemo/icons/smiley.xpm +42 -0
  104. data/samples/bigdemo/icons/stattext.xpm +24 -0
  105. data/samples/bigdemo/icons/test2.bmp +0 -0
  106. data/samples/bigdemo/icons/test2.png +0 -0
  107. data/samples/bigdemo/icons/test2.xpm +79 -0
  108. data/samples/bigdemo/icons/text.bmp +0 -0
  109. data/samples/bigdemo/icons/text.xpm +27 -0
  110. data/samples/bigdemo/icons/tog1.bmp +0 -0
  111. data/samples/bigdemo/icons/tog1.xpm +38 -0
  112. data/samples/bigdemo/icons/tog2.bmp +0 -0
  113. data/samples/bigdemo/icons/tog2.xpm +38 -0
  114. data/samples/bigdemo/icons/wxwin.ico +0 -0
  115. data/samples/bigdemo/icons/wxwin16x16.png +0 -0
  116. data/samples/bigdemo/icons/wxwin16x16.xpm +25 -0
  117. data/samples/bigdemo/icons/wxwin32x32.png +0 -0
  118. data/samples/bigdemo/icons/wxwin48x48.png +0 -0
  119. data/samples/bigdemo/run.rb +90 -0
  120. data/samples/bigdemo/tips.txt +7 -0
  121. data/samples/bigdemo/utils.rb +12 -0
  122. data/samples/bigdemo/wxArtProvider.rbw +281 -0
  123. data/samples/bigdemo/wxBitmapButton.rbw +65 -0
  124. data/samples/bigdemo/wxButton.rbw +64 -0
  125. data/samples/bigdemo/wxCalendarCtrl.rbw +60 -0
  126. data/samples/bigdemo/wxCheckBox.rbw +50 -0
  127. data/samples/bigdemo/wxCheckListBox.rbw +75 -0
  128. data/samples/bigdemo/wxChoice.rbw +47 -0
  129. data/samples/bigdemo/wxChoicebook.rbw +78 -0
  130. data/samples/bigdemo/wxColourDialog.rbw +31 -0
  131. data/samples/bigdemo/wxComboBox.rbw +77 -0
  132. data/samples/bigdemo/wxCursor.rbw +136 -0
  133. data/samples/bigdemo/wxDialog.rbw +74 -0
  134. data/samples/bigdemo/wxDirDialog.rbw +29 -0
  135. data/samples/bigdemo/wxDragImage.rbw +70 -0
  136. data/samples/bigdemo/wxFileDialog.rbw +37 -0
  137. data/samples/bigdemo/wxFileDialog_Save.rbw +35 -0
  138. data/samples/bigdemo/wxFindReplaceDialog.rbw +82 -0
  139. data/samples/bigdemo/wxFontDialog.rbw +173 -0
  140. data/samples/bigdemo/wxFrame.rbw +53 -0
  141. data/samples/bigdemo/wxGauge.rbw +71 -0
  142. data/samples/bigdemo/wxGenericDirCtrl.rbw +74 -0
  143. data/samples/bigdemo/wxGrid.rbw +66 -0
  144. data/samples/bigdemo/wxHtmlHelpController.rbw +52 -0
  145. data/samples/bigdemo/wxListBox.rbw +140 -0
  146. data/samples/bigdemo/wxListCtrl_virtual.rbw +107 -0
  147. data/samples/bigdemo/wxMDIWindows.rbw +50 -0
  148. data/samples/bigdemo/wxMenu.rbw +236 -0
  149. data/samples/bigdemo/wxMessageDialog.rbw +27 -0
  150. data/samples/bigdemo/wxMiniFrame.rbw +70 -0
  151. data/samples/bigdemo/wxMultipleChoiceDialog.rbw +32 -0
  152. data/samples/bigdemo/wxNotebook.rbw +136 -0
  153. data/samples/bigdemo/wxProgressDialog.rbw +43 -0
  154. data/samples/bigdemo/wxRadioBox.rbw +72 -0
  155. data/samples/bigdemo/wxRadioButton.rbw +125 -0
  156. data/samples/bigdemo/wxSashWindow.rbw +141 -0
  157. data/samples/bigdemo/wxScrolledMessageDialog.rbw +57 -0
  158. data/samples/bigdemo/wxScrolledWindow.rbw +199 -0
  159. data/samples/bigdemo/wxSingleChoiceDialog.rbw +33 -0
  160. data/samples/bigdemo/wxSlider.rbw +42 -0
  161. data/samples/bigdemo/wxSpinButton.rbw +50 -0
  162. data/samples/bigdemo/wxSpinCtrl.rbw +51 -0
  163. data/samples/bigdemo/wxSplitterWindow.rbw +63 -0
  164. data/samples/bigdemo/wxStaticBitmap.rbw +51 -0
  165. data/samples/bigdemo/wxStaticText.rbw +55 -0
  166. data/samples/bigdemo/wxStatusBar.rbw +126 -0
  167. data/samples/bigdemo/wxTextCtrl.rbw +149 -0
  168. data/samples/bigdemo/wxTextEntryDialog.rbw +31 -0
  169. data/samples/bigdemo/wxToggleButton.rbw +49 -0
  170. data/samples/bigdemo/wxToolBar.rbw +131 -0
  171. data/samples/bigdemo/wxTreeCtrl.rbw +190 -0
  172. data/samples/calendar/calendar.rb +271 -0
  173. data/samples/caret/caret.rb +282 -0
  174. data/samples/caret/mondrian.xpm +44 -0
  175. data/samples/controls/controls.rb +1136 -0
  176. data/samples/controls/get_item_sample.rb +87 -0
  177. data/samples/controls/icons/choice.xpm +27 -0
  178. data/samples/controls/icons/combo.xpm +27 -0
  179. data/samples/controls/icons/gauge.xpm +27 -0
  180. data/samples/controls/icons/list.xpm +27 -0
  181. data/samples/controls/icons/radio.xpm +27 -0
  182. data/samples/controls/icons/stattext.xpm +24 -0
  183. data/samples/controls/icons/text.xpm +27 -0
  184. data/samples/controls/mondrian.ico +0 -0
  185. data/samples/controls/mondrian.xpm +44 -0
  186. data/samples/controls/test2.bmp +0 -0
  187. data/samples/dialogs/dialogs.rb +723 -0
  188. data/samples/dialogs/tips.txt +18 -0
  189. data/samples/drawing/graphics_drawing.rb +235 -0
  190. data/samples/drawing/images.rb +37 -0
  191. data/samples/drawing/paperclip.png +0 -0
  192. data/samples/etc/activation.rb +102 -0
  193. data/samples/etc/choice.rb +67 -0
  194. data/samples/etc/miniframe.rb +79 -0
  195. data/samples/etc/sash.rb +130 -0
  196. data/samples/etc/scrollwin.rb +110 -0
  197. data/samples/etc/system_settings.rb +252 -0
  198. data/samples/etc/threaded.rb +72 -0
  199. data/samples/etc/wizard.rb +74 -0
  200. data/samples/event/event.rb +182 -0
  201. data/samples/grid/grid.rb +198 -0
  202. data/samples/grid/gridtablebase.rb +134 -0
  203. data/samples/html/html.rb +262 -0
  204. data/samples/listbook/listbook.rb +174 -0
  205. data/samples/listbook/listbook.xrc +370 -0
  206. data/samples/mdi/mdi.rb +82 -0
  207. data/samples/media/mediactrl.rb +167 -0
  208. data/samples/minimal/minimal.rb +77 -0
  209. data/samples/minimal/mondrian.ico +0 -0
  210. data/samples/minimal/mondrian.png +0 -0
  211. data/samples/minimal/nothing.rb +16 -0
  212. data/samples/opengl/cube.rb +117 -0
  213. data/samples/printing/mondrian.ico +0 -0
  214. data/samples/printing/mondrian.xpm +44 -0
  215. data/samples/printing/printing.rb +310 -0
  216. data/samples/sockets/SocketPackets.rb +27 -0
  217. data/samples/sockets/res/message-new.png +0 -0
  218. data/samples/sockets/res/user.png +0 -0
  219. data/samples/sockets/wxClient.rb +395 -0
  220. data/samples/sockets/wxServer.rb +422 -0
  221. data/samples/sockets/wxSocketGUI.rb +97 -0
  222. data/samples/text/mondrian.ico +0 -0
  223. data/samples/text/mondrian.xpm +44 -0
  224. data/samples/text/scintilla.rb +169 -0
  225. data/samples/text/textctrl.rb +113 -0
  226. data/samples/text/unicode.rb +242 -0
  227. data/samples/text/utf8.txt +15 -0
  228. data/samples/treectrl/icon1.xpm +79 -0
  229. data/samples/treectrl/icon2.xpm +53 -0
  230. data/samples/treectrl/icon3.xpm +79 -0
  231. data/samples/treectrl/icon4.xpm +43 -0
  232. data/samples/treectrl/icon5.xpm +79 -0
  233. data/samples/treectrl/treectrl.rb +1174 -0
  234. data/samples/xrc/samples.xrc +46 -0
  235. data/samples/xrc/xrc_sample.rb +96 -0
  236. metadata +313 -0
@@ -0,0 +1,1136 @@
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
+ CONTROLS_QUIT = ID_EXIT
14
+ CONTROLS_TEXT = 101
15
+ CONTROLS_ABOUT = ID_ABOUT
16
+ CONTROLS_CLEAR_LOG = 103
17
+ # tooltip menu
18
+ CONTROLS_SET_TOOLTIP_DELAY = 200
19
+ CONTROLS_ENABLE_TOOLTIPS = 201
20
+ # panel menu
21
+ CONTROLS_ENABLE_ALL = 202
22
+
23
+
24
+ ID_NOTEBOOK = 1000
25
+
26
+ ID_LISTBOX = 130
27
+ ID_LISTBOX_SEL_NUM = 131
28
+ ID_LISTBOX_SEL_STR = 132
29
+ ID_LISTBOX_CLEAR = 133
30
+ ID_LISTBOX_APPEND = 134
31
+ ID_LISTBOX_DELETE = 135
32
+ ID_LISTBOX_FONT = 136
33
+ ID_LISTBOX_ENABLE = 137
34
+ ID_LISTBOX_SORTED = 138
35
+
36
+ ID_CHOICE = 120
37
+ ID_CHOICE_SEL_NUM = 121
38
+ ID_CHOICE_SEL_STR = 122
39
+ ID_CHOICE_CLEAR = 123
40
+ ID_CHOICE_APPEND = 124
41
+ ID_CHOICE_DELETE = 125
42
+ ID_CHOICE_FONT = 126
43
+ ID_CHOICE_ENABLE = 127
44
+ ID_CHOICE_SORTED = 128
45
+
46
+ ID_COMBO = 140
47
+ ID_COMBO_SEL_NUM = 141
48
+ ID_COMBO_SEL_STR = 142
49
+ ID_COMBO_CLEAR = 143
50
+ ID_COMBO_APPEND = 144
51
+ ID_COMBO_DELETE = 145
52
+ ID_COMBO_FONT = 146
53
+ ID_COMBO_ENABLE = 147
54
+
55
+ ID_RADIOBOX = 160
56
+ ID_RADIOBOX_SEL_NUM = 161
57
+ ID_RADIOBOX_SEL_STR = 162
58
+ ID_RADIOBOX_FONT = 163
59
+ ID_RADIOBOX_ENABLE = 164
60
+
61
+ ID_RADIOBUTTON_1 = 166
62
+ ID_RADIOBUTTON_2 = 167
63
+
64
+ ID_SET_FONT = 170
65
+
66
+ ID_GAUGE = 180
67
+ ID_SLIDER = 181
68
+
69
+ ID_SPIN = 182
70
+ ID_BTNPROGRESS = 183
71
+ ID_BUTTON_LABEL = 184
72
+ ID_SPINCTRL = 185
73
+
74
+ ID_BUTTON_TEST1 = 190
75
+ ID_BUTTON_TEST2 = 191
76
+ ID_BITMAP_BTN = 192
77
+
78
+ ID_CHANGE_COLOUR = 200
79
+
80
+ ID_SIZER_CHECK1 = 201
81
+ ID_SIZER_CHECK2 = 202
82
+ ID_SIZER_CHECK3 = 203
83
+ ID_SIZER_CHECK4 = 204
84
+ ID_SIZER_CHECK14 = 205
85
+ ID_SIZER_CHECKBIG = 206
86
+
87
+ Image_List, Image_Choice, Image_Combo, Image_Text, Image_Radio, Image_Gauge, Image_Max = (0..6).to_a
88
+
89
+
90
+ # a button which intercepts double clicks (for testing...)
91
+ class MyButton < Button
92
+ def initialize(parent,id,label = EmptyString,pos = DEFAULT_POSITION,size = DEFAULT_SIZE)
93
+ super(parent,id,label,pos,size)
94
+
95
+ evt_left_dclick {|event| onDClick(event)}
96
+ end
97
+
98
+ def onDClick(event)
99
+ log_message("MyButton::OnDClick")
100
+ event.skip()
101
+ end
102
+
103
+ end
104
+
105
+ # a combo which intercepts chars (to test Windows behaviour)
106
+ class MyComboBox < ComboBox
107
+ def initialize(parent,id,value = EmptyString,
108
+ pos = DEFAULT_POSITION,
109
+ size = DEFAULT_SIZE,
110
+ choices = [],
111
+ style = 0)
112
+ super(parent, id, value, pos, size, choices)#, style)
113
+
114
+ evt_char {|event| onChar(event)}
115
+ evt_key_down {|event| onKeyDown(event)}
116
+ evt_key_up {|event| onKeyUp(event)}
117
+
118
+ evt_set_focus {|event| onFocusGot(event)}
119
+ end
120
+
121
+ def onChar(event)
122
+ log_message("MyComboBox::OnChar")
123
+ if event.key_code() == ?w
124
+ log_message("MyComboBox: 'w' will be ignored.")
125
+ else
126
+ event.skip()
127
+ end
128
+ end
129
+
130
+ def onKeyDown(event)
131
+ log_message("MyComboBox::OnKeyDown")
132
+ if event.key_code() == ?w
133
+ log_message("MyComboBox: 'w' will be ignored.")
134
+ else
135
+ event.skip()
136
+ end
137
+ end
138
+
139
+ def onKeyUp(event)
140
+ #log_message("MyComboBox::OnKeyUp")
141
+ event.skip()
142
+ end
143
+
144
+ def onFocusGot(event)
145
+ #log_message("MyComboBox::OnFocusGot")
146
+ event.skip()
147
+ end
148
+
149
+ end
150
+
151
+ # a radiobox which handles focus set/kill (for testing)
152
+ class MyRadioBox < RadioBox
153
+ def initialize(parent,
154
+ id,title = EmptyString,
155
+ pos = DEFAULT_POSITION,
156
+ size = DEFAULT_SIZE,
157
+ choices = [],
158
+ majorDim = 1,
159
+ style = RA_HORIZONTAL)
160
+ super(parent, id, title, pos, size, choices, majorDim,style)
161
+ set_foreground_colour(RED)
162
+
163
+ evt_set_focus {|event| onFocusGot(event)}
164
+ evt_kill_focus {|event| onFocusLost(event)}
165
+
166
+ end
167
+
168
+ def onFocusGot(event)
169
+ log_message("MyRadioBox::OnFocusGot")
170
+ event.skip()
171
+ end
172
+
173
+ def onFocusLost(event)
174
+ log_message("MyRadioBox::OnFocusLost")
175
+ event.skip()
176
+ end
177
+
178
+ end
179
+
180
+
181
+ class MyPanel < Panel
182
+
183
+ # delete Log::set_active_target(@m_logTargetOld)
184
+ # delete @m_notebook.GetImageList()
185
+ attr_reader :m_text,:m_logTargetOld
186
+
187
+ def initialize(frame,x,y,w,h)
188
+ super( frame, -1, Point.new(x, y), Size.new(w, h) )
189
+
190
+ @s_colOld = NULL_COLOUR
191
+
192
+ @m_text = TextCtrl.new(self, -1, "This is the log window.\n",
193
+ Point.new(0, 250), Size.new(100, 50), TE_MULTILINE)
194
+ @m_text.set_background_colour(Colour.new("wheat"))
195
+
196
+ #@m_logTargetOld = Log::set_active_target(LogTextCtrl.new(@m_text))
197
+
198
+ @m_notebook = Wx::Notebook.new(self, ID_NOTEBOOK)
199
+
200
+ choices = [
201
+ "This",
202
+ "is one of my",
203
+ "really",
204
+ "wonderful",
205
+ "examples."
206
+ ]
207
+
208
+ # fill the image list
209
+
210
+ imagelist = ImageList.new(16, 16)
211
+
212
+ imagelist.add( Bitmap.new( local_icon_file("list.xpm"),
213
+ Wx::BITMAP_TYPE_XPM))
214
+ imagelist.add( Bitmap.new( local_icon_file("choice.xpm"),
215
+ Wx::BITMAP_TYPE_XPM))
216
+ imagelist.add( Bitmap.new( local_icon_file("combo.xpm"),
217
+ Wx::BITMAP_TYPE_XPM))
218
+ imagelist.add( Bitmap.new( local_icon_file("text.xpm"),
219
+ Wx::BITMAP_TYPE_XPM))
220
+ imagelist.add( Bitmap.new( local_icon_file("radio.xpm"),
221
+ Wx::BITMAP_TYPE_XPM))
222
+ imagelist.add( Bitmap.new( local_icon_file("gauge.xpm"),
223
+ Wx::BITMAP_TYPE_XPM))
224
+
225
+ @m_notebook.set_image_list(imagelist)
226
+
227
+ panel = Panel.new(@m_notebook)
228
+ @m_listbox = ListBox.new( panel, ID_LISTBOX,
229
+ Point.new(10,10), Size.new(120,70),
230
+ choices, LB_ALWAYS_SB )
231
+
232
+ @m_listboxSorted = ListBox.new( panel, ID_LISTBOX_SORTED,
233
+ Point.new(10,90), Size.new(120,70),
234
+ choices, LB_SORT )
235
+
236
+
237
+ @m_listbox.set_cursor(CROSS_CURSOR)
238
+
239
+ @m_listbox.set_tool_tip( "This is a list box" )
240
+
241
+
242
+ @m_lbSelectNum = Button.new( panel, ID_LISTBOX_SEL_NUM, "Select #&2", Point.new(180,30), Size.new(140,30) )
243
+ @m_lbSelectThis = Button.new( panel, ID_LISTBOX_SEL_STR, "&Select 'This'", Point.new(340,30), Size.new(140,30) )
244
+ Button.new( panel, ID_LISTBOX_CLEAR, "&clear", Point.new(180,80), Size.new(140,30) )
245
+ MyButton.new( panel, ID_LISTBOX_APPEND, "&append 'Hi!'", Point.new(340,80), Size.new(140,30) )
246
+ Button.new( panel, ID_LISTBOX_DELETE, "D&elete selected item", Point.new(180,130), Size.new(140,30) )
247
+ button = MyButton.new( panel, ID_LISTBOX_FONT, "Set &Italic font", Point.new(340,130), Size.new(140,30) )
248
+
249
+ button.set_default()
250
+
251
+ button.set_foreground_colour(BLUE)
252
+
253
+ button.set_tool_tip( "Press here to set italic font" )
254
+
255
+ @m_checkbox = CheckBox.new( panel, ID_LISTBOX_ENABLE, "&Disable", Point.new(20,170) )
256
+ @m_checkbox.set_value(FALSE)
257
+ @m_checkbox.set_tool_tip( "Click here to disable the listbox" )
258
+ @m_toggle_color = CheckBox.new( panel, ID_CHANGE_COLOUR, "&Toggle colour",
259
+ Point.new(110,170) )
260
+ panel.set_cursor(Cursor.new(CURSOR_HAND))
261
+ @m_notebook.add_page(panel, "ListBox", TRUE, Image_List)
262
+
263
+ panel = Panel.new(@m_notebook)
264
+ @m_choice = Choice.new( panel, ID_CHOICE, Point.new(10,10), Size.new(120,-1), choices )
265
+ @m_choiceSorted = Choice.new( panel, ID_CHOICE_SORTED, Point.new(10,70), Size.new(120,-1),
266
+ choices, CB_SORT )
267
+
268
+ @m_choice.set_selection(2)
269
+ @m_choice.set_background_colour(Colour.new("red"))
270
+ Button.new( panel, ID_CHOICE_SEL_NUM, "Select #&2", Point.new(180,30), Size.new(140,30) )
271
+ Button.new( panel, ID_CHOICE_SEL_STR, "&Select 'This'", Point.new(340,30), Size.new(140,30) )
272
+ Button.new( panel, ID_CHOICE_CLEAR, "&clear", Point.new(180,80), Size.new(140,30) )
273
+ Button.new( panel, ID_CHOICE_APPEND, "&append 'Hi!'", Point.new(340,80), Size.new(140,30) )
274
+ Button.new( panel, ID_CHOICE_DELETE, "D&elete selected item", Point.new(180,130), Size.new(140,30) )
275
+ Button.new( panel, ID_CHOICE_FONT, "Set &Italic font", Point.new(340,130), Size.new(140,30) )
276
+ CheckBox.new( panel, ID_CHOICE_ENABLE, "&Disable", Point.new(20,130), Size.new(140,30) )
277
+
278
+ @m_notebook.add_page(panel, "Choice", FALSE, Image_Choice)
279
+
280
+ panel = Panel.new(@m_notebook)
281
+ StaticBox.new( panel, -1, "&Box around combobox",
282
+ Point.new(5, 5), Size.new(150, 100))
283
+ @m_combo = MyComboBox.new( panel, ID_COMBO, "This",
284
+ Point.new(20,25), Size.new(120, -1),
285
+ choices,PROCESS_ENTER)
286
+ # CB_READONLY | PROCESS_ENTER)
287
+
288
+ @m_combo.set_tool_tip("This is a natural\ncombobox - can you believe me?")
289
+
290
+ Button.new( panel, ID_COMBO_SEL_NUM, "Select #&2", Point.new(180,30), Size.new(140,30) )
291
+ Button.new( panel, ID_COMBO_SEL_STR, "&Select 'This'", Point.new(340,30), Size.new(140,30) )
292
+ Button.new( panel, ID_COMBO_CLEAR, "&clear", Point.new(180,80), Size.new(140,30) )
293
+ Button.new( panel, ID_COMBO_APPEND, "&append 'Hi!'", Point.new(340,80), Size.new(140,30) )
294
+ Button.new( panel, ID_COMBO_DELETE, "D&elete selected item", Point.new(180,130), Size.new(140,30) )
295
+ Button.new( panel, ID_COMBO_FONT, "Set &Italic font", Point.new(340,130), Size.new(140,30) )
296
+ CheckBox.new( panel, ID_COMBO_ENABLE, "&Disable", Point.new(20,130), Size.new(140,30) )
297
+ @m_notebook.add_page(panel, "ComboBox", FALSE, Image_Combo)
298
+
299
+ choices2 = ["First", "Second"]
300
+ # "Third",
301
+ #"Fourth", "Fifth", "Sixth",
302
+ #"Seventh", "Eighth", "Nineth", "Tenth" */
303
+
304
+ panel = Panel.new(@m_notebook)
305
+ MyRadioBox.new( panel, ID_RADIOBOX, "&That", Point.new(10,160), Size.new(-1,-1), choices2, 1, RA_SPECIFY_ROWS )
306
+ @m_radio = RadioBox.new( panel, ID_RADIOBOX, "T&his", Point.new(10,10), Size.new(-1,-1), choices, 1, RA_SPECIFY_COLS )
307
+ @m_radio.set_foreground_colour(RED)
308
+
309
+ @m_radio.set_tool_tip("Ever seen a radiobox?")
310
+
311
+ Button.new( panel, ID_RADIOBOX_SEL_NUM, "Select #&2", Point.new(180,30), Size.new(140,30) )
312
+ Button.new( panel, ID_RADIOBOX_SEL_STR, "&Select 'This'", Point.new(180,80), Size.new(140,30) )
313
+ @m_fontButton = Button.new( panel, ID_SET_FONT, "Set &more Italic font", Point.new(340,30), Size.new(140,30) )
314
+ Button.new( panel, ID_RADIOBOX_FONT, "Set &Italic font", Point.new(340,80), Size.new(140,30) )
315
+ CheckBox.new( panel, ID_RADIOBOX_ENABLE, "&Disable", Point.new(340,130), DEFAULT_SIZE )
316
+ rb = RadioButton.new( panel, ID_RADIOBUTTON_1, "Radiobutton1", Point.new(210,170), DEFAULT_SIZE, RB_GROUP )
317
+ rb.set_value( FALSE )
318
+ RadioButton.new( panel, ID_RADIOBUTTON_2, "&Radiobutton2", Point.new(340,170), DEFAULT_SIZE )
319
+ @m_notebook.add_page(panel, "RadioBox", FALSE, Image_Radio)
320
+
321
+ panel = Panel.new(@m_notebook)
322
+ StaticBox.new( panel, -1, "&Gauge and Slider", Point.new(10,10), Size.new(222,130) )
323
+ @m_gauge = Gauge.new( panel, -1, 200, Point.new(18,50), Size.new(155, 30), GA_HORIZONTAL|NO_BORDER )
324
+ @m_gauge.set_background_colour(GREEN)
325
+ @m_gauge.set_foreground_colour(RED)
326
+ @m_gaugeVert = Gauge.new( panel, -1, 100,
327
+ Point.new(195,35), Size.new(30, 90),
328
+ GA_VERTICAL | GA_SMOOTH | NO_BORDER )
329
+ @m_slider = Slider.new( panel, ID_SLIDER, 0, 0, 200, Point.new(18,90), Size.new(155,-1),
330
+ SL_AUTOTICKS | SL_LABELS )
331
+ @m_slider.set_tick_freq(40, 0)
332
+ @m_slider.set_tool_tip("This is a sliding slider")
333
+
334
+ StaticBox.new( panel, -1, "&Explanation",
335
+ Point.new(230,10), Size.new(270,130),
336
+ ALIGN_CENTER )
337
+
338
+ StaticText.new( panel, -1,
339
+ "In order see the gauge (aka progress bar)\n"+
340
+ "control do something you have to drag the\n"+
341
+ "handle of the slider to the right.\n"+
342
+ "\n"+
343
+ "This is also supposed to demonstrate how\n"+
344
+ "to use static controls.\n",
345
+ Point.new(250,25),
346
+ Size.new(240, 110))
347
+ initialSpinValue = -5
348
+ s = initialSpinValue.to_s
349
+ @m_spintext = TextCtrl.new( panel, -1, s, Point.new(20,160), Size.new(80,-1) )
350
+ @m_spinbutton = SpinButton.new( panel, ID_SPIN, Point.new(103,160), Size.new(80, -1) )
351
+ @m_spinbutton.set_range(-40,30)
352
+ @m_spinbutton.set_value(initialSpinValue)
353
+
354
+ @m_btnProgress = Button.new( panel, ID_BTNPROGRESS, "&Show progress dialog",
355
+ Point.new(300, 160) )
356
+
357
+ @m_spinctrl = SpinCtrl.new( panel, ID_SPINCTRL, "", Point.new(200, 160), Size.new(80, -1) )
358
+ @m_spinctrl.set_range(10,30)
359
+ @m_spinctrl.set_value(15)
360
+
361
+ @m_notebook.add_page(panel, "Gauge", FALSE, Image_Gauge)
362
+
363
+ panel = Panel.new(@m_notebook)
364
+
365
+ icon = ArtProvider::get_icon(ART_INFORMATION)
366
+ StaticBitmap.new( panel, -1, icon, Point.new(10, 10) )
367
+
368
+ bitmap = Bitmap.new( 100, 100 )
369
+ bitmap.draw do | dc |
370
+ dc.clear()
371
+ dc.set_pen(GREEN_PEN)
372
+ dc.draw_ellipse(5, 5, 90, 90)
373
+ dc.draw_text("Bitmap", 30, 40)
374
+ end
375
+
376
+ BitmapButton.new(panel, ID_BITMAP_BTN, bitmap, Point.new(100, 20))
377
+
378
+ # test for masked bitmap display
379
+ bitmap = Bitmap.new( File.join(File.dirname(__FILE__), "test2.bmp"),
380
+ BITMAP_TYPE_BMP)
381
+ if bitmap.is_ok()
382
+ bitmap.set_mask(Mask.new(bitmap, BLUE))
383
+ StaticBitmap.new(panel, -1, bitmap, Point.new(300, 120))
384
+ end
385
+ # bmp1 = ArtProvider::get_bitmap(ART_INFORMATION)
386
+ # bmp2 = ArtProvider::get_bitmap(ART_WARNING)
387
+ # bmp3 = ArtProvider::get_bitmap(ART_QUESTION)
388
+ # bmpBtn = BitmapButton.new(panel, -1,
389
+ # bmp1,
390
+ # Point.new(30, 70))
391
+
392
+ # bmpBtn.set_bitmap_selected(bmp2)
393
+ # bmpBtn.set_bitmap_focus(bmp3)
394
+ ToggleButton.new(panel, ID_BUTTON_LABEL,
395
+ "&Toggle label", Point.new(250, 20))
396
+ @m_label = StaticText.new(panel, -1, "Label with some long text",
397
+ Point.new(250, 60), DEFAULT_SIZE,
398
+ ALIGN_RIGHT)
399
+ @m_label.set_foreground_colour(BLUE )
400
+
401
+ @m_notebook.add_page(panel, "BitmapXXX")
402
+
403
+ # sizer
404
+
405
+ panel = Panel.new(@m_notebook)
406
+ panel.set_auto_layout( TRUE )
407
+
408
+ sizer = BoxSizer.new( VERTICAL )
409
+
410
+ csizer =
411
+ StaticBoxSizer.new(StaticBox.new(panel, -1, "Show Buttons"),
412
+ HORIZONTAL )
413
+
414
+ check1 = CheckBox.new(panel, ID_SIZER_CHECK1, "1")
415
+ check1.set_value(TRUE)
416
+ csizer.add(check1)
417
+ check2 = CheckBox.new(panel, ID_SIZER_CHECK2, "2")
418
+ check2.set_value(TRUE)
419
+ csizer.add(check2)
420
+ check3 = CheckBox.new(panel, ID_SIZER_CHECK3, "3")
421
+ check3.set_value(TRUE)
422
+ csizer.add(check3)
423
+ check4 = CheckBox.new(panel, ID_SIZER_CHECK4, "4")
424
+ check4.set_value(TRUE)
425
+ csizer.add(check4)
426
+ check14 = CheckBox.new(panel, ID_SIZER_CHECK14, "1-4")
427
+ check14.set_value(TRUE)
428
+ csizer.add(check14)
429
+ checkBig = CheckBox.new(panel, ID_SIZER_CHECKBIG, "Big")
430
+ checkBig.set_value(TRUE)
431
+ csizer.add(checkBig)
432
+
433
+ sizer.add(csizer)
434
+
435
+ @m_hsizer = BoxSizer.new( HORIZONTAL )
436
+
437
+ @m_buttonSizer = BoxSizer.new(VERTICAL)
438
+
439
+ @m_sizerBtn1 = Button.new(panel, -1, "Test Button &1" )
440
+ @m_buttonSizer.add( @m_sizerBtn1, 0, ALL, 10 )
441
+ @m_sizerBtn2 = Button.new(panel, -1, "Test Button &2" )
442
+ @m_buttonSizer.add( @m_sizerBtn2, 0, ALL, 10 )
443
+ @m_sizerBtn3 = Button.new(panel, -1, "Test Button &3" )
444
+ @m_buttonSizer.add( @m_sizerBtn3, 0, ALL, 10 )
445
+ @m_sizerBtn4 = Button.new(panel, -1, "Test Button &4" )
446
+ @m_buttonSizer.add( @m_sizerBtn4, 0, ALL, 10 )
447
+
448
+ @m_hsizer.add(@m_buttonSizer)
449
+ @m_hsizer.add( 20,20, 1 )
450
+ @m_bigBtn = Button.new(panel, -1, "Multiline\nbutton" )
451
+ @m_hsizer.add( @m_bigBtn , 3, GROW|ALL, 10 )
452
+
453
+ sizer.add(@m_hsizer, 1, GROW)
454
+
455
+ panel.set_sizer( sizer )
456
+
457
+ @m_notebook.add_page(panel, "Sizer")
458
+
459
+ evt_size {|event| onSize(event) }
460
+ evt_notebook_page_changing(ID_NOTEBOOK) {|event| onPageChanging(event) }
461
+ evt_notebook_page_changed(ID_NOTEBOOK) {|event| onPageChanged(event) }
462
+ evt_listbox(ID_LISTBOX) {|event| onListBox(event) }
463
+ evt_listbox(ID_LISTBOX_SORTED) {|event| onListBox(event) }
464
+ evt_listbox_dclick(ID_LISTBOX) {|event| onListBoxDoubleClick(event) }
465
+ evt_button(ID_LISTBOX_SEL_NUM) {|event| onListBoxButtons(event) }
466
+ evt_button(ID_LISTBOX_SEL_STR) {|event| onListBoxButtons(event) }
467
+ evt_button(ID_LISTBOX_CLEAR) {|event| onListBoxButtons(event) }
468
+ evt_button(ID_LISTBOX_APPEND) {|event| onListBoxButtons(event) }
469
+ evt_button(ID_LISTBOX_DELETE) {|event| onListBoxButtons(event) }
470
+ evt_button(ID_LISTBOX_FONT) {|event| onListBoxButtons(event) }
471
+ evt_checkbox(ID_LISTBOX_ENABLE) {|event| onListBoxButtons(event) }
472
+ evt_choice(ID_CHOICE) {|event| onChoice(event) }
473
+ evt_choice(ID_CHOICE_SORTED) {|event| onChoice(event) }
474
+ evt_button(ID_CHOICE_SEL_NUM) {|event| onChoiceButtons(event) }
475
+ evt_button(ID_CHOICE_SEL_STR) {|event| onChoiceButtons(event) }
476
+ evt_button(ID_CHOICE_CLEAR) {|event| onChoiceButtons(event) }
477
+ evt_button(ID_CHOICE_APPEND) {|event| onChoiceButtons(event) }
478
+ evt_button(ID_CHOICE_DELETE) {|event| onChoiceButtons(event) }
479
+ evt_button(ID_CHOICE_FONT) {|event| onChoiceButtons(event) }
480
+ evt_checkbox(ID_CHOICE_ENABLE) {|event| onChoiceButtons(event) }
481
+ evt_combobox(ID_COMBO) {|event| onCombo(event) }
482
+ evt_text(ID_COMBO) {|event| onComboTextChanged(event) }
483
+ evt_text_enter(ID_COMBO) {|event| onComboTextEnter(event) }
484
+ evt_button(ID_COMBO_SEL_NUM) {|event| onComboButtons(event) }
485
+ evt_button(ID_COMBO_SEL_STR) {|event| onComboButtons(event) }
486
+ evt_button(ID_COMBO_CLEAR) {|event| onComboButtons(event) }
487
+ evt_button(ID_COMBO_APPEND) {|event| onComboButtons(event) }
488
+ evt_button(ID_COMBO_DELETE) {|event| onComboButtons(event) }
489
+ evt_button(ID_COMBO_FONT) {|event| onComboButtons(event) }
490
+ evt_checkbox(ID_COMBO_ENABLE) {|event| onComboButtons(event) }
491
+ evt_radiobox(ID_RADIOBOX) {|event| onRadio(event) }
492
+ evt_button(ID_RADIOBOX_SEL_NUM) {|event| onRadioButtons(event) }
493
+ evt_button(ID_RADIOBOX_SEL_STR) {|event| onRadioButtons(event) }
494
+ evt_button(ID_RADIOBOX_FONT) {|event| onRadioButtons(event) }
495
+ evt_checkbox(ID_RADIOBOX_ENABLE) {|event| onRadioButtons(event) }
496
+ evt_button(ID_SET_FONT) {|event| onSetFont(event) }
497
+ evt_slider(ID_SLIDER) {|event| onSliderupdate(event) }
498
+ evt_spin(ID_SPIN) {|event| onSpinupdate(event) }
499
+ evt_spin_up(ID_SPIN) {|event| onSpinUp(event) }
500
+ evt_spin_down(ID_SPIN) {|event| onSpinDown(event) }
501
+ evt_update_ui(ID_BTNPROGRESS) {|event| onupdateShowProgress(event) }
502
+ evt_button(ID_BTNPROGRESS) {|event| onShowProgress(event) }
503
+ evt_spinctrl(ID_SPINCTRL) {|event| onSpinCtrl(event) }
504
+ evt_spin_up(ID_SPINCTRL) {|event| onSpinCtrlUp(event) }
505
+ evt_spin_down(ID_SPINCTRL) {|event| onSpinCtrlDown(event) }
506
+ evt_text(ID_SPINCTRL) {|event| onSpinCtrlText(event) }
507
+ if (RUBY_PLATFORM =~ /mswin/)
508
+ evt_togglebutton(ID_BUTTON_LABEL) {|event| onupdateLabel(event) }
509
+ end
510
+ evt_checkbox(ID_CHANGE_COLOUR) {|event| onChangeColour(event) }
511
+ evt_button(ID_BUTTON_TEST1) {|event| onTestButton(event) }
512
+ evt_button(ID_BUTTON_TEST2) {|event| onTestButton(event) }
513
+ evt_button(ID_BITMAP_BTN) {|event| onBmpButton(event) }
514
+
515
+ evt_checkbox(ID_SIZER_CHECK1) {|event| onSizerCheck(event) }
516
+ evt_checkbox(ID_SIZER_CHECK2) {|event| onSizerCheck(event) }
517
+ evt_checkbox(ID_SIZER_CHECK3) {|event| onSizerCheck(event) }
518
+ evt_checkbox(ID_SIZER_CHECK4) {|event| onSizerCheck(event) }
519
+ evt_checkbox(ID_SIZER_CHECK14) {|event| onSizerCheck(event) }
520
+ evt_checkbox(ID_SIZER_CHECKBIG) {|event| onSizerCheck(event) }
521
+
522
+ end
523
+
524
+ # utility function to find an icon relative to this ruby script
525
+ def local_icon_file(icon_name)
526
+ File.join( File.dirname(__FILE__), 'icons', icon_name)
527
+ end
528
+
529
+
530
+ def onSize(event)
531
+ size = get_client_size()
532
+ x = size.get_width
533
+ y = size.get_height
534
+ if @m_notebook
535
+ @m_notebook.set_dimensions( 2, 2, x-4, y*2/3-4 )
536
+ end
537
+ if @m_text
538
+ @m_text.set_dimensions( 2, y*2/3+2, x-4, y/3-4 )
539
+ end
540
+ end
541
+
542
+ def onPageChanging(event)
543
+
544
+ selOld = event.get_old_selection()
545
+ if selOld == 2
546
+ if message_box("This demonstrates how a program may prevent the\n"+
547
+ "page change from taking place - if you select\n"+
548
+ "[No] the current page will stay the third one\n",
549
+ "Control sample",
550
+ ICON_QUESTION | YES_NO, self) != YES
551
+ event.veto()
552
+ return nil
553
+ end
554
+ end
555
+ @m_text << "Notebook selection is being changed from " << selOld \
556
+ << " to " << event.get_selection() \
557
+ << " (current page from notebook is " \
558
+ << @m_notebook.get_selection() << ")\n"
559
+ end
560
+
561
+ def onPageChanged(event)
562
+ @m_text << "Notebook selection is now " << event.get_selection() \
563
+ << " (from notebook: " << @m_notebook.get_selection() \
564
+ << ")\n"
565
+ end
566
+
567
+ def onTestButton(event)
568
+ log_message("Button %s clicked.",
569
+ event.get_id() == ID_BUTTON_TEST1 ? '1' : '2')
570
+ end
571
+
572
+ def onBmpButton(event)
573
+ log_message("Bitmap button clicked.")
574
+ end
575
+
576
+ def onChangeColour(event)
577
+ # test panel colour changing and propagation to the subcontrols
578
+ if @s_colOld.is_ok()
579
+
580
+ set_background_colour(@s_colOld)
581
+ @s_colOld = NULL_COLOUR
582
+
583
+ @m_lbSelectThis.set_foreground_colour(Colour.new("red"))
584
+ @m_lbSelectThis.set_background_colour(Colour.new("white"))
585
+ else
586
+ @s_colOld = Colour.new("red")
587
+ set_background_colour(Colour.new("white"))
588
+
589
+ @m_lbSelectThis.set_foreground_colour(Colour.new("white"))
590
+ @m_lbSelectThis.set_background_colour(Colour.new("red"))
591
+ end
592
+
593
+ @m_lbSelectThis.refresh()
594
+ refresh()
595
+ end
596
+
597
+ def onListBox(event)
598
+ # GetParent().Move(100, 100)
599
+ if event.get_int() == -1
600
+ @m_text.append_text( "ListBox has no selections anymore\n" )
601
+ return Qnil
602
+ end
603
+
604
+ listbox = (event.get_id() == ID_LISTBOX) ? @m_listbox : @m_listboxSorted
605
+
606
+ @m_text.append_text( "ListBox event selection string is: '" )
607
+ @m_text.append_text( event.get_string() )
608
+ @m_text.append_text( "'\n" )
609
+ @m_text.append_text( "ListBox control selection string is: '" )
610
+ @m_text.append_text( listbox.get_string_selection() )
611
+ @m_text.append_text( "'\n" )
612
+
613
+ # NOTE: get_client_data and set_client_data have been removed from wxRuby 0.4
614
+ # because they could cause crashes
615
+ # obj = event.get_client_data()
616
+ # @m_text.append_text( "ListBox event client data string is: '" )
617
+ # if obj
618
+ # @m_text.append_text( obj )
619
+ # else
620
+ # @m_text.append_text( "none" )
621
+ # end
622
+
623
+ # @m_text.append_text( "'\n" )
624
+ # @m_text.append_text( "ListBox control client data string is: '" )
625
+ # obj = listbox.get_client_data(listbox.get_selection())
626
+ # if obj
627
+ # @m_text.append_text( obj )
628
+ # else
629
+ # @m_text.append_text( "none" )
630
+ # end
631
+ # @m_text.append_text( "'\n" )
632
+ end
633
+
634
+ def onListBoxDoubleClick(event)
635
+ @m_text.append_text( "ListBox double click string is: " )
636
+ @m_text.append_text( event.get_string() )
637
+ @m_text.append_text( "\n" )
638
+ end
639
+
640
+ def onListBoxButtons(event)
641
+ case event.get_id()
642
+ when ID_LISTBOX_ENABLE
643
+ @m_text.append_text("Checkbox clicked.\n")
644
+ if event.get_int() != 0
645
+ @m_checkbox.set_tool_tip( "Click to enable listbox" )
646
+ @m_toggle_color.enable(false)
647
+ else
648
+ @m_checkbox.set_tool_tip( "Click to disable listbox" )
649
+ @m_toggle_color.enable(true)
650
+ end
651
+ @m_listbox.enable( event.get_int() == 0 )
652
+ @m_lbSelectThis.enable( event.get_int() == 0 )
653
+ @m_lbSelectNum.enable( event.get_int() == 0 )
654
+ @m_listboxSorted.enable( event.get_int() == 0 )
655
+ #w = Window::find_window_by_id(ID_CHANGE_COLOUR)
656
+ #if(w)
657
+ # w.enable( event.get_int() == 0 )
658
+ #else
659
+ # puts("Window ID_CHANGE_COLOR not found")
660
+ #end
661
+ when ID_LISTBOX_SEL_NUM
662
+ @m_listbox.set_selection( 2 )
663
+ @m_listboxSorted.set_selection( 2 )
664
+ @m_lbSelectThis.warp_pointer( 40, 14 )
665
+ when ID_LISTBOX_SEL_STR
666
+ @m_listbox.set_string_selection( "This" )
667
+ @m_listboxSorted.set_string_selection( "This" )
668
+ @m_lbSelectNum.warp_pointer( 40, 14 )
669
+ when ID_LISTBOX_CLEAR
670
+ @m_listbox.clear()
671
+ @m_listboxSorted.clear()
672
+ when ID_LISTBOX_APPEND
673
+ @m_listbox.append( "Hi!" )
674
+ @m_listboxSorted.append( "Hi!" )
675
+ when ID_LISTBOX_DELETE
676
+ idx = @m_listbox.get_selection()
677
+ if idx != NOT_FOUND
678
+ @m_listbox.delete( idx )
679
+ end
680
+ idx = @m_listboxSorted.get_selection()
681
+ if idx != NOT_FOUND
682
+ @m_listboxSorted.delete( idx )
683
+ end
684
+ when ID_LISTBOX_FONT
685
+ @m_listbox.set_font( ITALIC_FONT )
686
+ @m_listboxSorted.set_font( ITALIC_FONT )
687
+ @m_checkbox.set_font( ITALIC_FONT )
688
+ end
689
+ end
690
+
691
+
692
+ def onChoice(event)
693
+
694
+ choice = (event.get_id() == ID_CHOICE) ? @m_choice : @m_choiceSorted
695
+
696
+ @m_text.append_text( "Choice event selection string is: '" )
697
+ @m_text.append_text( event.get_string() )
698
+ @m_text.append_text( "'\n" )
699
+ @m_text.append_text( "Choice control selection string is: '" )
700
+ @m_text.append_text( choice.get_string_selection() )
701
+ @m_text.append_text( "'\n" )
702
+
703
+ # NOTE: get_client_data and set_client_data have been removed from wxRuby 0.4
704
+ # because they could cause crashes
705
+ # obj = event.get_client_data()
706
+ # @m_text.append_text( "Choice event client data string is: '" )
707
+
708
+ # if obj
709
+ # @m_text.append_text( obj )
710
+ # else
711
+ # @m_text.append_text( "none" )
712
+ # end
713
+
714
+ # @m_text.append_text( "'\n" )
715
+ # @m_text.append_text( "Choice control client data string is: '" )
716
+
717
+ # obj = choice.get_client_data(choice.get_selection())
718
+ # if obj
719
+ # @m_text.append_text( obj )
720
+ # else
721
+ # @m_text.append_text( "none" )
722
+ # end
723
+ # @m_text.append_text( "'\n" )
724
+ end
725
+
726
+ def onChoiceButtons(event)
727
+ case event.get_id()
728
+ when ID_CHOICE_ENABLE
729
+ @m_choice.enable( event.get_int() == 0 )
730
+ @m_choiceSorted.enable( event.get_int() == 0 )
731
+ when ID_CHOICE_SEL_NUM
732
+ @m_choice.set_selection( 2 )
733
+ @m_choiceSorted.set_selection( 2 )
734
+ when ID_CHOICE_SEL_STR
735
+ @m_choice.set_string_selection( "This" )
736
+ @m_choiceSorted.set_string_selection( "This" )
737
+ when ID_CHOICE_CLEAR
738
+ @m_choice.clear()
739
+ @m_choiceSorted.clear()
740
+ when ID_CHOICE_APPEND
741
+ @m_choice.append( "Hi!" )
742
+ @m_choiceSorted.append( "Hi!" )
743
+ when ID_CHOICE_DELETE
744
+ idx = @m_choice.get_selection()
745
+ if idx != NOT_FOUND
746
+ @m_choice.delete( idx )
747
+ end
748
+ idx = @m_choiceSorted.get_selection()
749
+ if idx != NOT_FOUND
750
+ @m_choiceSorted.delete( idx )
751
+ end
752
+ when ID_CHOICE_FONT
753
+ @m_choice.set_font( ITALIC_FONT )
754
+ @m_choiceSorted.set_font( ITALIC_FONT )
755
+ end
756
+ end
757
+
758
+ def onCombo(event)
759
+ @m_text.append_text( "ComboBox event selection string is: " )
760
+ @m_text.append_text( event.get_string() )
761
+ @m_text.append_text( "\n" )
762
+ @m_text.append_text( "ComboBox control selection string is: " )
763
+ @m_text.append_text( @m_combo.get_string_selection() )
764
+ @m_text.append_text( "\n" )
765
+ end
766
+
767
+ def onComboTextChanged(event)
768
+ str = sprintf( "Text in the combobox changed: now is '%s'.",
769
+ event.get_string())
770
+ log_message( str )
771
+ end
772
+
773
+ def onComboTextEnter(event)
774
+ log_message("Enter pressed in the combobox: value is '%s'.",
775
+ @m_combo.get_value())
776
+ end
777
+
778
+ def onComboButtons(event)
779
+ case event.get_id()
780
+ when ID_COMBO_ENABLE
781
+ @m_combo.enable( event.get_int() == 0 )
782
+ when ID_COMBO_SEL_NUM
783
+ @m_combo.set_selection( 2 )
784
+ when ID_COMBO_SEL_STR
785
+ @m_combo.set_string_selection( "This" )
786
+ when ID_COMBO_CLEAR
787
+ @m_combo.clear()
788
+ when ID_COMBO_APPEND
789
+ @m_combo.append( "Hi!" )
790
+ when ID_COMBO_DELETE
791
+ idx = @m_combo.get_selection()
792
+ @m_combo.delete( idx )
793
+ when ID_COMBO_FONT
794
+ @m_combo.set_font( ITALIC_FONT )
795
+ end
796
+ end
797
+
798
+ def onRadio(event)
799
+ @m_text.append_text( "RadioBox selection string is: " )
800
+ @m_text.append_text( event.get_string() )
801
+ @m_text.append_text( "\n" )
802
+ end
803
+
804
+ def onRadioButtons(event)
805
+ case event.get_id()
806
+ when ID_RADIOBOX_ENABLE
807
+ @m_radio.enable( event.get_int() == 0 )
808
+ when ID_RADIOBOX_SEL_NUM
809
+ @m_radio.set_selection( 2 )
810
+ when ID_RADIOBOX_SEL_STR
811
+ @m_radio.set_string_selection( "This" )
812
+ when ID_RADIOBOX_FONT
813
+ @m_radio.set_foreground_colour(GREEN)
814
+ @m_radio.set_font( ITALIC_FONT )
815
+ end
816
+ end
817
+
818
+ def onSetFont(event)
819
+ @m_fontButton.set_font( ITALIC_FONT )
820
+ @m_text.set_font( ITALIC_FONT )
821
+ end
822
+
823
+ def onupdateLabel(event)
824
+ @m_label.set_label(event.get_int() != 0 ? "Very very very very very long text." : "Shorter text.")
825
+ end
826
+
827
+ def onSliderupdate(event)
828
+ @m_gauge.set_value( @m_slider.get_value() )
829
+ @m_gaugeVert.set_value( @m_slider.get_value() / 2 )
830
+ end
831
+
832
+
833
+ def onSpinCtrlText(event)
834
+ if @m_spinctrl
835
+ s = sprintf( "Spin ctrl text changed: now %d (from event: %s)\n",
836
+ @m_spinctrl.get_value(), event.get_string() )
837
+ @m_text.append_text(s)
838
+ end
839
+ end
840
+
841
+ def onSpinCtrl(event)
842
+ if @m_spinctrl
843
+ s = sprintf( "Spin ctrl changed: now %d (from event: %d)\n",
844
+ @m_spinctrl.get_value(), event.get_int() )
845
+ @m_text.append_text(s)
846
+ end
847
+ end
848
+
849
+ def onSpinCtrlUp(event)
850
+ if @m_spinctrl
851
+ @m_text.append_text( sprintf(
852
+ "Spin up: %d (from event: %d)\n",
853
+ @m_spinctrl.get_value(), event.get_int() ) )
854
+ end
855
+ end
856
+
857
+ def onSpinCtrlDown(event)
858
+ if @m_spinctrl
859
+ @m_text.append_text( sprintf(
860
+ "Spin down: %d (from event: %d)\n",
861
+ @m_spinctrl.get_value(), event.get_int() ) )
862
+ end
863
+ end
864
+
865
+
866
+ def onSpinUp(event)
867
+ value = sprintf( "Spin control up: current = %d\n",
868
+ @m_spinbutton.get_value())
869
+
870
+ if event.get_position() > 17
871
+ value += "Preventing the spin button from going above 17.\n"
872
+ event.veto()
873
+ end
874
+
875
+ @m_text.append_text(value)
876
+ end
877
+
878
+ def onSpinDown(event)
879
+ value = sprintf( "Spin control down: current = %d\n",
880
+ @m_spinbutton.get_value())
881
+
882
+ if event.get_position() < -17
883
+ value += "Preventing the spin button from going below -17.\n"
884
+ event.veto()
885
+ end
886
+
887
+ @m_text.append_text(value)
888
+ end
889
+
890
+ def onSpinupdate(event)
891
+ value = sprintf( "%d", event.get_position() )
892
+ @m_spintext.set_value( value )
893
+
894
+ value = sprintf( "Spin control range: (%d, %d), current = %d\n",
895
+ @m_spinbutton.get_min(), @m_spinbutton.get_max(),
896
+ @m_spinbutton.get_value())
897
+
898
+ @m_text.append_text(value)
899
+ end
900
+
901
+ def onupdateShowProgress(event)
902
+ event.enable( @m_spinbutton.get_value() > 0 )
903
+ end
904
+
905
+ def onShowProgress(event)
906
+ max = @m_spinbutton.get_value()
907
+ if max <= 0
908
+ log_error("You must set positive range!")
909
+ return nil
910
+ end
911
+
912
+ dialog = ProgressDialog.new("Progress dialog example",
913
+ "An informative message",
914
+ max, # range
915
+ self, # parent
916
+ PD_CAN_ABORT |
917
+ PD_AUTO_HIDE |
918
+ PD_APP_MODAL |
919
+ PD_ELAPSED_TIME |
920
+ PD_ESTIMATED_TIME |
921
+ PD_REMAINING_TIME)
922
+
923
+ cont = TRUE
924
+ 0.upto(max) {|i|
925
+ break if !cont
926
+ sleep(1)
927
+ if i == max
928
+ cont = dialog.update(i, "That's all, folks!")
929
+ elsif i == max / 2
930
+ cont = dialog.update(i, "Only a half left (very long message)!")
931
+ else
932
+ cont = dialog.update(i)
933
+ end
934
+ }
935
+ dialog.destroy()
936
+ if !cont
937
+ @m_text << "Progress dialog aborted!\n"
938
+ else
939
+ @m_text << "Countdown from " << max << " finished.\n"
940
+ end
941
+ end
942
+
943
+ def onSizerCheck(event)
944
+ case event.get_id()
945
+ when ID_SIZER_CHECK1
946
+ @m_buttonSizer.show(@m_sizerBtn1, event.is_checked())
947
+ @m_buttonSizer.layout()
948
+ when ID_SIZER_CHECK2
949
+ @m_buttonSizer.show(@m_sizerBtn2, event.is_checked())
950
+ @m_buttonSizer.layout()
951
+ when ID_SIZER_CHECK3
952
+ @m_buttonSizer.show(@m_sizerBtn3, event.is_checked())
953
+ @m_buttonSizer.layout()
954
+ when ID_SIZER_CHECK4
955
+ @m_buttonSizer.show(@m_sizerBtn4, event.is_checked())
956
+ @m_buttonSizer.layout()
957
+ when ID_SIZER_CHECK14
958
+ @m_hsizer.show(@m_buttonSizer, event.is_checked())
959
+ @m_hsizer.layout()
960
+ when ID_SIZER_CHECKBIG
961
+ @m_hsizer.show(@m_bigBtn, event.is_checked())
962
+ @m_hsizer.layout()
963
+ end
964
+ end
965
+ end
966
+
967
+
968
+ class MyFrame < Frame
969
+ def initialize(title,x,y)
970
+ super(nil, -1, title, Point.new(x, y), Size.new(500, 430))
971
+
972
+ @s_delay = 5000
973
+ @s_enabled = TRUE
974
+ @s_enable2 = TRUE
975
+ @s_windowFocus = nil
976
+ mondrian_icon =
977
+ case Wx::PLATFORM
978
+ when "WXMSW"
979
+ Icon.new( File.join( File.dirname(__FILE__), "mondrian.ico"),
980
+ Wx::BITMAP_TYPE_ICO )
981
+ else
982
+ Icon.new( File.join( File.dirname(__FILE__), "mondrian.xpm"),
983
+ Wx::BITMAP_TYPE_XPM )
984
+ end
985
+
986
+ set_icon(mondrian_icon)
987
+
988
+ file_menu = Menu.new
989
+
990
+ file_menu.append(CONTROLS_CLEAR_LOG, "&clear log\tCtrl-L")
991
+ file_menu.append_separator()
992
+ file_menu.append(CONTROLS_ABOUT, "&About\tF1")
993
+ file_menu.append_separator()
994
+ file_menu.append(CONTROLS_QUIT, "E&xit\tAlt-X", "Quit controls sample")
995
+
996
+ menu_bar = MenuBar.new
997
+ menu_bar.append(file_menu, "&File")
998
+
999
+ tooltip_menu = Menu.new
1000
+ tooltip_menu.append(CONTROLS_SET_TOOLTIP_DELAY, "Set &delay\tCtrl-D")
1001
+ tooltip_menu.append_separator()
1002
+ tooltip_menu.append(CONTROLS_ENABLE_TOOLTIPS, "&Toggle tooltips\tCtrl-T",
1003
+ "enable/disable tooltips", ITEM_CHECK)
1004
+ tooltip_menu.check(CONTROLS_ENABLE_TOOLTIPS, TRUE)
1005
+ menu_bar.append(tooltip_menu, "&Tooltips")
1006
+
1007
+ panel_menu = Menu.new
1008
+ panel_menu.append(CONTROLS_ENABLE_ALL, "&Disable all\tCtrl-E",
1009
+ "enable/disable all panel controls", ITEM_CHECK)
1010
+ menu_bar.append(panel_menu, "&Panel")
1011
+
1012
+ set_menu_bar(menu_bar)
1013
+
1014
+ create_status_bar(2)
1015
+
1016
+ @m_panel = MyPanel.new( self, 10, 10, 300, 100 )
1017
+
1018
+ set_size_hints( 500, 425 )
1019
+
1020
+ evt_menu(CONTROLS_QUIT) {|event| onQuit(event) }
1021
+ evt_menu(CONTROLS_ABOUT) {|event| onAbout(event) }
1022
+ evt_menu(CONTROLS_CLEAR_LOG) {|event| onClearLog(event) }
1023
+ evt_menu(CONTROLS_SET_TOOLTIP_DELAY) {|event| onSetTooltipDelay(event) }
1024
+ evt_menu(CONTROLS_ENABLE_TOOLTIPS) {|event| onToggleTooltips(event) }
1025
+ evt_menu(CONTROLS_ENABLE_ALL) {|event| onenableAll(event) }
1026
+
1027
+ evt_size() {|event| onSize(event) }
1028
+ evt_move() {|event| onMove(event) }
1029
+ evt_idle() {|event| onIdle(event) }
1030
+ evt_close() {|event| onClose(event) }
1031
+ end
1032
+
1033
+ def onClose(event)
1034
+ Log::set_active_target(@m_panel.m_logTargetOld)
1035
+ destroy()
1036
+ end
1037
+
1038
+ def onQuit(event)
1039
+ close(TRUE)
1040
+ end
1041
+
1042
+ def onAbout(event)
1043
+ BusyCursor.busy do
1044
+ dialog = MessageDialog.new(self, "This is a control sample", "About Controls", OK)
1045
+ dialog.show_modal()
1046
+ end
1047
+ end
1048
+
1049
+ def onClearLog(event)
1050
+ @m_panel.m_text.clear()
1051
+ end
1052
+
1053
+ def onSetTooltipDelay(event)
1054
+ delay = @s_delay.to_s
1055
+
1056
+ delay = get_text_from_user("Enter delay (in milliseconds)",
1057
+ "Set tooltip delay",
1058
+ delay,
1059
+ self)
1060
+ if !delay
1061
+ return Qnil # cancelled
1062
+ end
1063
+
1064
+ @s_delay = delay.to_i
1065
+
1066
+ ToolTip::set_delay(@s_delay)
1067
+
1068
+ log_status(self, "Tooltip delay set to %d milliseconds", @s_delay)
1069
+ end
1070
+
1071
+ def onToggleTooltips(event)
1072
+ @s_enabled = ! @s_enabled
1073
+ ToolTip::enable(@s_enabled)
1074
+ log_status(self, "Tooltips %sabled", @s_enabled ? "en" : "dis" )
1075
+ end
1076
+
1077
+ def onenableAll(event)
1078
+ @s_enable2 = ! @s_enable2
1079
+ @m_panel.enable(@s_enable2)
1080
+ end
1081
+
1082
+ def onMove(event)
1083
+ update_status_bar(event.get_position(), get_size())
1084
+ event.skip()
1085
+ end
1086
+
1087
+ def onSize(event)
1088
+ update_status_bar(get_position(), event.get_size())
1089
+ event.skip()
1090
+ end
1091
+
1092
+ def onIdle(event)
1093
+
1094
+ # track the window which has the focus in the status bar
1095
+ focus = Window::find_focus()
1096
+ if focus && (focus != @s_windowFocus)
1097
+ @s_windowFocus = focus
1098
+ msg = sprintf( "Focus: %s, HWND = %08x",
1099
+ @s_windowFocus.wx_class,
1100
+ @s_windowFocus.get_handle )
1101
+ set_status_text(msg)
1102
+ end
1103
+ end
1104
+
1105
+ def GetPanel()
1106
+ @m_panel
1107
+ end
1108
+
1109
+ def update_status_bar(pos,size)
1110
+ if get_status_bar()
1111
+ sizeAll = get_size()
1112
+ sizeCl = get_client_size()
1113
+ msg = sprintf("pos=(%d, %d), size=%dx%d or %dx%d (client=%dx%d)",
1114
+ pos.x, pos.y,
1115
+ size.x, size.y,
1116
+ sizeAll.x, sizeAll.y,
1117
+ sizeCl.x, sizeCl.y)
1118
+ set_status_text(msg, 1)
1119
+ end
1120
+ end
1121
+
1122
+ end
1123
+
1124
+ class MyApp < App
1125
+ def on_init()
1126
+ # parse the cmd line
1127
+ x = 50
1128
+ y = 50
1129
+ # Create the main frame window
1130
+ frame = MyFrame.new("Controls Windows App", x, y)
1131
+ frame.show(TRUE)
1132
+ end
1133
+ end
1134
+
1135
+ a = MyApp.new
1136
+ a.main_loop