wxruby-ruby19 1.9.8-x86-linux → 1.9.10-x86-linux

Sign up to get free protection for your applications and to get access to all the features.
Files changed (259) hide show
  1. data/LICENSE +53 -0
  2. data/README +297 -0
  3. data/lib/wx/accessors.rb +58 -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 +51 -0
  7. data/lib/wx/classes/artprovider.rb +31 -0
  8. data/lib/wx/classes/auinotebook.rb +9 -0
  9. data/lib/wx/classes/bitmap.rb +56 -0
  10. data/lib/wx/classes/busycursor.rb +12 -0
  11. data/lib/wx/classes/checklistbox.rb +45 -0
  12. data/lib/wx/classes/choice.rb +4 -0
  13. data/lib/wx/classes/clientdc.rb +13 -0
  14. data/lib/wx/classes/clipboard.rb +32 -0
  15. data/lib/wx/classes/colour.rb +49 -0
  16. data/lib/wx/classes/combobox.rb +4 -0
  17. data/lib/wx/classes/commandevent.rb +7 -0
  18. data/lib/wx/classes/controlwithitems.rb +10 -0
  19. data/lib/wx/classes/data_object.rb +14 -0
  20. data/lib/wx/classes/data_object_simple.rb +6 -0
  21. data/lib/wx/classes/dataformat.rb +23 -0
  22. data/lib/wx/classes/dc.rb +57 -0
  23. data/lib/wx/classes/event.rb +5 -0
  24. data/lib/wx/classes/evthandler.rb +1039 -0
  25. data/lib/wx/classes/font.rb +118 -0
  26. data/lib/wx/classes/functions.rb +44 -0
  27. data/lib/wx/classes/gauge.rb +12 -0
  28. data/lib/wx/classes/genericdirctrl.rb +36 -0
  29. data/lib/wx/classes/grid.rb +146 -0
  30. data/lib/wx/classes/hboxsizer.rb +6 -0
  31. data/lib/wx/classes/helpcontroller.rb +5 -0
  32. data/lib/wx/classes/helpcontrollerhelpprovider.rb +23 -0
  33. data/lib/wx/classes/helpprovider.rb +15 -0
  34. data/lib/wx/classes/htmlhelpcontroller.rb +5 -0
  35. data/lib/wx/classes/htmlwindow.rb +14 -0
  36. data/lib/wx/classes/icon.rb +32 -0
  37. data/lib/wx/classes/iconbundle.rb +3 -0
  38. data/lib/wx/classes/image.rb +43 -0
  39. data/lib/wx/classes/imagelist.rb +3 -0
  40. data/lib/wx/classes/listbox.rb +4 -0
  41. data/lib/wx/classes/listctrl.rb +33 -0
  42. data/lib/wx/classes/locale.rb +28 -0
  43. data/lib/wx/classes/mediactrl.rb +48 -0
  44. data/lib/wx/classes/menu.rb +62 -0
  45. data/lib/wx/classes/menuitem.rb +7 -0
  46. data/lib/wx/classes/notebook.rb +9 -0
  47. data/lib/wx/classes/object.rb +14 -0
  48. data/lib/wx/classes/paintdc.rb +12 -0
  49. data/lib/wx/classes/point.rb +56 -0
  50. data/lib/wx/classes/previewframe.rb +13 -0
  51. data/lib/wx/classes/rect.rb +19 -0
  52. data/lib/wx/classes/richtextctrl.rb +63 -0
  53. data/lib/wx/classes/simplehelpprovider.rb +38 -0
  54. data/lib/wx/classes/size.rb +58 -0
  55. data/lib/wx/classes/sizer.rb +37 -0
  56. data/lib/wx/classes/sound.rb +23 -0
  57. data/lib/wx/classes/standardpaths.rb +9 -0
  58. data/lib/wx/classes/styledtextctrl.rb +92 -0
  59. data/lib/wx/classes/textctrl.rb +14 -0
  60. data/lib/wx/classes/texturlevent.rb +18 -0
  61. data/lib/wx/classes/timer.rb +94 -0
  62. data/lib/wx/classes/toolbar.rb +27 -0
  63. data/lib/wx/classes/toolbartool.rb +4 -0
  64. data/lib/wx/classes/treectrl.rb +44 -0
  65. data/lib/wx/classes/vboxsizer.rb +6 -0
  66. data/lib/wx/classes/window.rb +89 -0
  67. data/lib/wx/classes/xmlresource.rb +54 -0
  68. data/lib/wx/helpers.rb +45 -0
  69. data/lib/wx/keyword_ctors.rb +204 -0
  70. data/lib/wx/keyword_defs.rb +558 -0
  71. data/lib/wx/version.rb +3 -0
  72. data/lib/wx.rb +53 -0
  73. data/lib/wxruby2.so +0 -0
  74. data/samples/SAMPLES-LICENSE.TXT +18 -0
  75. data/samples/aui/aui.rb +1356 -0
  76. data/samples/bigdemo/About.rbw +39 -0
  77. data/samples/bigdemo/ColorPanel.rbw +23 -0
  78. data/samples/bigdemo/GridSimple.rbw +78 -0
  79. data/samples/bigdemo/MDIDemo.rbw +57 -0
  80. data/samples/bigdemo/PopupMenu.rbw +149 -0
  81. data/samples/bigdemo/ShapedWindow.rbw +131 -0
  82. data/samples/bigdemo/Sizers.rbw +543 -0
  83. data/samples/bigdemo/bigdemo.rb +823 -0
  84. data/samples/bigdemo/demoTemplate.rbw +33 -0
  85. data/samples/bigdemo/helpfile.htb +0 -0
  86. data/samples/bigdemo/icons/Test 015.jpg +0 -0
  87. data/samples/bigdemo/icons/Test 015.png +0 -0
  88. data/samples/bigdemo/icons/choice.bmp +0 -0
  89. data/samples/bigdemo/icons/choice.xpm +27 -0
  90. data/samples/bigdemo/icons/combo.bmp +0 -0
  91. data/samples/bigdemo/icons/combo.xpm +27 -0
  92. data/samples/bigdemo/icons/copy.xpm +25 -0
  93. data/samples/bigdemo/icons/cut.xpm +24 -0
  94. data/samples/bigdemo/icons/gauge.bmp +0 -0
  95. data/samples/bigdemo/icons/gauge.xpm +27 -0
  96. data/samples/bigdemo/icons/help.xpm +25 -0
  97. data/samples/bigdemo/icons/list.bmp +0 -0
  98. data/samples/bigdemo/icons/list.xpm +27 -0
  99. data/samples/bigdemo/icons/mondrian.ico +0 -0
  100. data/samples/bigdemo/icons/mondrian.xpm +44 -0
  101. data/samples/bigdemo/icons/new.xpm +24 -0
  102. data/samples/bigdemo/icons/ogl.ico +0 -0
  103. data/samples/bigdemo/icons/ogl.xpm +45 -0
  104. data/samples/bigdemo/icons/open.xpm +26 -0
  105. data/samples/bigdemo/icons/paste.bmp +0 -0
  106. data/samples/bigdemo/icons/paste.xpm +38 -0
  107. data/samples/bigdemo/icons/pointy.png +0 -0
  108. data/samples/bigdemo/icons/preview.xpm +26 -0
  109. data/samples/bigdemo/icons/print.xpm +26 -0
  110. data/samples/bigdemo/icons/radio.bmp +0 -0
  111. data/samples/bigdemo/icons/radio.xpm +27 -0
  112. data/samples/bigdemo/icons/robert.xpm +415 -0
  113. data/samples/bigdemo/icons/ruby.png +0 -0
  114. data/samples/bigdemo/icons/sashtest.ico +0 -0
  115. data/samples/bigdemo/icons/save.xpm +25 -0
  116. data/samples/bigdemo/icons/smiles.bmp +0 -0
  117. data/samples/bigdemo/icons/smiles.xpm +39 -0
  118. data/samples/bigdemo/icons/smiley.ico +0 -0
  119. data/samples/bigdemo/icons/smiley.xpm +42 -0
  120. data/samples/bigdemo/icons/stattext.xpm +24 -0
  121. data/samples/bigdemo/icons/test2.bmp +0 -0
  122. data/samples/bigdemo/icons/test2.png +0 -0
  123. data/samples/bigdemo/icons/test2.xpm +79 -0
  124. data/samples/bigdemo/icons/text.bmp +0 -0
  125. data/samples/bigdemo/icons/text.xpm +27 -0
  126. data/samples/bigdemo/icons/tog1.bmp +0 -0
  127. data/samples/bigdemo/icons/tog1.xpm +38 -0
  128. data/samples/bigdemo/icons/tog2.bmp +0 -0
  129. data/samples/bigdemo/icons/tog2.xpm +38 -0
  130. data/samples/bigdemo/icons/wxwin.ico +0 -0
  131. data/samples/bigdemo/icons/wxwin16x16.png +0 -0
  132. data/samples/bigdemo/icons/wxwin16x16.xpm +25 -0
  133. data/samples/bigdemo/icons/wxwin32x32.png +0 -0
  134. data/samples/bigdemo/icons/wxwin48x48.png +0 -0
  135. data/samples/bigdemo/run.rb +90 -0
  136. data/samples/bigdemo/tips.txt +7 -0
  137. data/samples/bigdemo/utils.rb +12 -0
  138. data/samples/bigdemo/wxArtProvider.rbw +281 -0
  139. data/samples/bigdemo/wxBitmapButton.rbw +65 -0
  140. data/samples/bigdemo/wxButton.rbw +64 -0
  141. data/samples/bigdemo/wxCalendarCtrl.rbw +60 -0
  142. data/samples/bigdemo/wxCheckBox.rbw +50 -0
  143. data/samples/bigdemo/wxCheckListBox.rbw +65 -0
  144. data/samples/bigdemo/wxChoice.rbw +47 -0
  145. data/samples/bigdemo/wxChoicebook.rbw +78 -0
  146. data/samples/bigdemo/wxColourDialog.rbw +31 -0
  147. data/samples/bigdemo/wxComboBox.rbw +77 -0
  148. data/samples/bigdemo/wxCursor.rbw +136 -0
  149. data/samples/bigdemo/wxDialog.rbw +74 -0
  150. data/samples/bigdemo/wxDirDialog.rbw +29 -0
  151. data/samples/bigdemo/wxDragImage.rbw +70 -0
  152. data/samples/bigdemo/wxFileDialog.rbw +37 -0
  153. data/samples/bigdemo/wxFileDialog_Save.rbw +35 -0
  154. data/samples/bigdemo/wxFindReplaceDialog.rbw +82 -0
  155. data/samples/bigdemo/wxFontDialog.rbw +173 -0
  156. data/samples/bigdemo/wxFrame.rbw +53 -0
  157. data/samples/bigdemo/wxGauge.rbw +71 -0
  158. data/samples/bigdemo/wxGenericDirCtrl.rbw +74 -0
  159. data/samples/bigdemo/wxGrid.rbw +66 -0
  160. data/samples/bigdemo/wxHtmlHelpController.rbw +52 -0
  161. data/samples/bigdemo/wxListBox.rbw +140 -0
  162. data/samples/bigdemo/wxListCtrl_virtual.rbw +112 -0
  163. data/samples/bigdemo/wxMDIWindows.rbw +50 -0
  164. data/samples/bigdemo/wxMenu.rbw +236 -0
  165. data/samples/bigdemo/wxMessageDialog.rbw +27 -0
  166. data/samples/bigdemo/wxMiniFrame.rbw +70 -0
  167. data/samples/bigdemo/wxMultipleChoiceDialog.rbw +32 -0
  168. data/samples/bigdemo/wxNotebook.rbw +136 -0
  169. data/samples/bigdemo/wxProgressDialog.rbw +43 -0
  170. data/samples/bigdemo/wxRadioBox.rbw +72 -0
  171. data/samples/bigdemo/wxRadioButton.rbw +125 -0
  172. data/samples/bigdemo/wxSashWindow.rbw +141 -0
  173. data/samples/bigdemo/wxScrolledMessageDialog.rbw +57 -0
  174. data/samples/bigdemo/wxScrolledWindow.rbw +199 -0
  175. data/samples/bigdemo/wxSingleChoiceDialog.rbw +33 -0
  176. data/samples/bigdemo/wxSlider.rbw +42 -0
  177. data/samples/bigdemo/wxSpinButton.rbw +50 -0
  178. data/samples/bigdemo/wxSpinCtrl.rbw +51 -0
  179. data/samples/bigdemo/wxSplitterWindow.rbw +63 -0
  180. data/samples/bigdemo/wxStaticBitmap.rbw +51 -0
  181. data/samples/bigdemo/wxStaticText.rbw +55 -0
  182. data/samples/bigdemo/wxStatusBar.rbw +126 -0
  183. data/samples/bigdemo/wxTextCtrl.rbw +149 -0
  184. data/samples/bigdemo/wxTextEntryDialog.rbw +31 -0
  185. data/samples/bigdemo/wxToggleButton.rbw +49 -0
  186. data/samples/bigdemo/wxToolBar.rbw +131 -0
  187. data/samples/bigdemo/wxTreeCtrl.rbw +191 -0
  188. data/samples/calendar/calendar.rb +256 -0
  189. data/samples/caret/caret.rb +282 -0
  190. data/samples/caret/mondrian.xpm +44 -0
  191. data/samples/controls/controls.rb +1136 -0
  192. data/samples/controls/get_item_sample.rb +87 -0
  193. data/samples/controls/icons/choice.xpm +27 -0
  194. data/samples/controls/icons/combo.xpm +27 -0
  195. data/samples/controls/icons/gauge.xpm +27 -0
  196. data/samples/controls/icons/list.xpm +27 -0
  197. data/samples/controls/icons/radio.xpm +27 -0
  198. data/samples/controls/icons/stattext.xpm +24 -0
  199. data/samples/controls/icons/text.xpm +27 -0
  200. data/samples/controls/mondrian.ico +0 -0
  201. data/samples/controls/mondrian.xpm +44 -0
  202. data/samples/controls/test2.bmp +0 -0
  203. data/samples/dialogs/dialogs.rb +797 -0
  204. data/samples/dialogs/tips.txt +18 -0
  205. data/samples/dragdrop/dragdrop.rb +177 -0
  206. data/samples/drawing/graphics_drawing.rb +235 -0
  207. data/samples/drawing/images.rb +37 -0
  208. data/samples/drawing/paperclip.png +0 -0
  209. data/samples/etc/activation.rb +102 -0
  210. data/samples/etc/choice.rb +67 -0
  211. data/samples/etc/miniframe.rb +79 -0
  212. data/samples/etc/sash.rb +130 -0
  213. data/samples/etc/scrollwin.rb +110 -0
  214. data/samples/etc/system_settings.rb +252 -0
  215. data/samples/etc/threaded.rb +72 -0
  216. data/samples/etc/toolbar_sizer_additem.rb +55 -0
  217. data/samples/etc/wizard.rb +74 -0
  218. data/samples/event/event.rb +182 -0
  219. data/samples/event/update_ui_event.rb +70 -0
  220. data/samples/grid/grid.rb +198 -0
  221. data/samples/grid/gridtablebase.rb +148 -0
  222. data/samples/html/html.rb +262 -0
  223. data/samples/listbook/listbook.rb +174 -0
  224. data/samples/listbook/listbook.xrc +370 -0
  225. data/samples/mdi/mdi.rb +85 -0
  226. data/samples/media/mediactrl.rb +167 -0
  227. data/samples/minimal/minimal.rb +77 -0
  228. data/samples/minimal/mondrian.ico +0 -0
  229. data/samples/minimal/mondrian.png +0 -0
  230. data/samples/minimal/nothing.rb +16 -0
  231. data/samples/opengl/cube.rb +117 -0
  232. data/samples/printing/mondrian.ico +0 -0
  233. data/samples/printing/mondrian.xpm +44 -0
  234. data/samples/printing/printing.rb +487 -0
  235. data/samples/sockets/SocketPackets.rb +27 -0
  236. data/samples/sockets/res/message-new.png +0 -0
  237. data/samples/sockets/res/user.png +0 -0
  238. data/samples/sockets/wxClient.rb +395 -0
  239. data/samples/sockets/wxServer.rb +422 -0
  240. data/samples/sockets/wxSocketGUI.rb +97 -0
  241. data/samples/text/format-text-bold.png +0 -0
  242. data/samples/text/format-text-italic.png +0 -0
  243. data/samples/text/format-text-underline.png +0 -0
  244. data/samples/text/mondrian.ico +0 -0
  245. data/samples/text/mondrian.xpm +44 -0
  246. data/samples/text/rich_textctrl.rb +98 -0
  247. data/samples/text/scintilla.rb +169 -0
  248. data/samples/text/textctrl.rb +111 -0
  249. data/samples/text/unicode.rb +242 -0
  250. data/samples/text/utf8.txt +15 -0
  251. data/samples/treectrl/icon1.xpm +79 -0
  252. data/samples/treectrl/icon2.xpm +53 -0
  253. data/samples/treectrl/icon3.xpm +79 -0
  254. data/samples/treectrl/icon4.xpm +43 -0
  255. data/samples/treectrl/icon5.xpm +79 -0
  256. data/samples/treectrl/treectrl.rb +1166 -0
  257. data/samples/xrc/samples.xrc +46 -0
  258. data/samples/xrc/xrc_sample.rb +76 -0
  259. metadata +234 -220
@@ -0,0 +1,823 @@
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
+ # Demo created by Robert Carlin, based on the wxPython demo by Robin Dunn
11
+ # Modified by Kevin Smith, Roy Sutton, Alex Fenton
12
+
13
+
14
+ # TODO:
15
+ # Finish Scintilla integration
16
+ # Fix 'Find Next'
17
+ # Refactor editor pane
18
+ # More samples
19
+ # Finish 'rubification' of source
20
+ # Fix non-scintilla code viewer
21
+
22
+ OVR_TEXT = "This is the WxRuby Demo. It was ported from the wxPython Demo, created by Robin Dunn. Many thanks to him for all his hard work - this demo is what it is because of him. Click on any of the items in the tree control to start the demo. Don't forget to check out the Demo Code tab - you can see the source code for each demo!\nHope you like it!"
23
+
24
+ $tree_list = [
25
+ #new stuff
26
+ #['Recent Additions', [
27
+ # 'wxMaskedNumCtrl',
28
+ # 'FloatCanvas',
29
+ # ]],
30
+
31
+ # managed windows == things with a [optional] caption you can close
32
+ ['Base Frames and Dialogs', [
33
+ 'wxDialog',
34
+ 'wxFrame',
35
+ 'wxMDIWindows',
36
+ 'wxMiniFrame',
37
+ #'wxWizard',
38
+ ]],
39
+
40
+ # the common dialogs
41
+ ['Common Dialogs', [
42
+ 'wxColourDialog',
43
+ 'wxDirDialog',
44
+ 'wxFileDialog',
45
+ 'wxFileDialog_Save',
46
+ 'wxFindReplaceDialog',
47
+ 'wxFontDialog',
48
+ 'wxMessageDialog',
49
+ #'wxPageSetupDialog',
50
+ #'wxPrintDialog',
51
+ 'wxProgressDialog',
52
+ 'wxSingleChoiceDialog',
53
+ 'wxTextEntryDialog',
54
+ ]],
55
+
56
+ # dialogs from libraries
57
+ ['More Dialogs', [
58
+ # 'ErrorDialogs',
59
+ # 'ImageBrowser',
60
+ 'wxMultipleChoiceDialog',
61
+ 'wxScrolledMessageDialog'
62
+ ]],
63
+
64
+ # core controls
65
+ ['Core Windows/Controls', [
66
+ 'PopupMenu',
67
+ 'wxBitmapButton',
68
+ 'wxButton',
69
+ 'wxCheckBox',
70
+ 'wxCheckListBox',
71
+ 'wxChoice',
72
+ 'wxChoicebook',
73
+ 'wxComboBox',
74
+ 'wxGauge',
75
+ 'wxGenericDirCtrl',
76
+ 'wxGrid',
77
+ #'wxGrid_MegaExample',
78
+ 'wxListBox',
79
+ #'wxListCtrl',
80
+ 'wxListCtrl_virtual',
81
+ 'wxMenu',
82
+ 'wxNotebook',
83
+ #'wxPopupWindow',
84
+ 'wxRadioBox',
85
+ 'wxRadioButton',
86
+ 'wxSashWindow',
87
+ 'wxScrolledWindow',
88
+ 'wxSlider',
89
+ 'wxSpinButton',
90
+ 'wxSpinCtrl',
91
+ 'wxSplitterWindow',
92
+ 'wxStaticBitmap',
93
+ 'wxStaticText',
94
+ 'wxStatusBar',
95
+ 'wxTextCtrl',
96
+ 'wxToggleButton',
97
+ 'wxToolBar',
98
+ 'wxTreeCtrl',
99
+ #'wxValidator',
100
+ ]],
101
+
102
+ # controls coming from other libraries
103
+ ['More Windows/Controls', [
104
+ #'wxFloatBar', deprecated
105
+ #'wxMVCTree', deprecated
106
+ #'wxRightTextCtrl', deprecated as we have wxTE_RIGHT now.
107
+ #'AnalogClockWindow',
108
+ #'ColourSelect',
109
+ #'ContextHelp',
110
+ #'FancyText',
111
+ #'FloatCanvas',
112
+ #'FileBrowseButton',
113
+ #'GenericButtons',
114
+ #'MaskedEditControls',
115
+ #'SplitTree',
116
+ #'TablePrint',
117
+ #'Throbber',
118
+ #'wxCalendar',
119
+ 'wxCalendarCtrl',
120
+ #'wxDynamicSashWindow',
121
+ #'wxEditableListBox',
122
+ #'wxEditor',
123
+ #'wxHtmlWindow',
124
+ #'wxIEHtmlWin',
125
+ #'wxIntCtrl',
126
+ #'wxLEDNumberCtrl',
127
+ #'wxMimeTypesManager',
128
+ #'wxMaskedNumCtrl',
129
+ #'wxMultiSash',
130
+ #'wxPopupControl',
131
+ #'wxStyledTextCtrl_1',
132
+ #'wxStyledTextCtrl_2',
133
+ #'wxTimeCtrl',
134
+ #'wxTreeListCtrl',
135
+ ]],
136
+
137
+ # How to lay out the controls in a frame/dialog
138
+ ['Window Layout', [
139
+ # 'LayoutAnchors',
140
+ # 'Layoutf',
141
+ # 'RowColSizer',
142
+ 'Sizers',
143
+ # 'wxScrolledPanel',
144
+ # 'wxXmlResource',
145
+ # 'wxXmlResourceHandler',
146
+ ]],
147
+
148
+ # ditto
149
+ #['Process and Events', [
150
+ # 'EventManager',
151
+ # 'infoframe',
152
+ # 'OOR',
153
+ # 'PythonEvents',
154
+ # 'Threads',
155
+ # 'wxKeyEvents',
156
+ # 'wxProcess',
157
+ # 'wxTimer',
158
+ # ]],
159
+
160
+ #~ # Clipboard and DnD
161
+ #~ ['Clipboard and DnD', [
162
+ #~ #'CustomDragAndDrop',
163
+ #~ 'DragAndDrop',
164
+ #~ 'URLDragAndDrop',
165
+ #~ ]],
166
+
167
+ # Images
168
+ ['Using Images', [
169
+ # 'Throbber',
170
+ 'wxArtProvider',
171
+ 'wxCursor',
172
+ 'wxDragImage',
173
+ # 'wxImage',
174
+ # 'wxImageFromStream',
175
+ # 'wxMask',
176
+ ]],
177
+
178
+ # Other stuff
179
+ ['Miscellaneous', [
180
+ # 'ColourDB',
181
+ # 'DialogUnits',
182
+ # 'DrawXXXList',
183
+ # 'FontEnumerator',
184
+ # 'PrintFramework',
185
+ 'ShapedWindow',
186
+ # 'Throbber',
187
+ # 'Unicode',
188
+ # 'wxFileHistory',
189
+ # 'wxJoystick',
190
+ # 'wxOGL',
191
+ # 'wxWave',
192
+ ]],
193
+
194
+ # need libs not coming with the demo
195
+ #['Objects using an external library', [
196
+ # 'ActiveXWrapper_Acrobat',
197
+ # 'ActiveXWrapper_IE',
198
+ # 'wxGLCanvas',
199
+ # 'wxPlotCanvas',
200
+ # ]],
201
+
202
+
203
+ ['Check out the samples dir too', [
204
+ ]],
205
+
206
+ ]
207
+
208
+ class DemoCodeViewer < Wx::TextCtrl
209
+ def intialize(parent, id)
210
+ super(parent, id, OVR_TEXT, Wx::DEFAULT_POSITION, Wx::Size.new(400, 400),
211
+ Wx::TE_MULTILINE|Wx::TE_READONLY|Wx::HSCROLL|
212
+ Wx::TE_RICH|Wx::TE_NOHIDESEL)
213
+ end
214
+ end
215
+
216
+ class WxRubyDemo < Wx::Frame
217
+ attr_accessor :otherWin
218
+
219
+ def initialize(title, pos, size, style=Wx::DEFAULT_FRAME_STYLE)
220
+ super(nil,-1,title,pos,size,style)
221
+ @demoID = 6000
222
+ @otherWin = nil
223
+
224
+ icon_file = File.join(File.dirname(__FILE__), 'icons', 'mondrian.xpm')
225
+ icon = Wx::Icon.new(icon_file, Wx::BITMAP_TYPE_XPM)
226
+ set_icon(icon)
227
+
228
+ @tbicon = DemoTaskBarIcon.new(self)
229
+
230
+ evt_idle {|event| on_idle(event)}
231
+ evt_close {|event| on_close(event)}
232
+ evt_iconize {|event| on_iconize(event)}
233
+ evt_maximize {|event| on_maximize(event)}
234
+
235
+ centre(Wx::BOTH)
236
+ create_status_bar(1, Wx::ST_SIZEGRIP)
237
+ set_status_text("Welcome to the WxRuby Demo!")
238
+
239
+ splitter = Wx::SplitterWindow.new(self, -1)
240
+ splitter2 = Wx::SplitterWindow.new(splitter, -1)
241
+
242
+ # Make a File menu
243
+
244
+ @mainmenu = Wx::MenuBar.new
245
+ menu = Wx::Menu.new
246
+ menu.append(Wx::ID_EXIT, "E&xit\tALT-X", "Get the heck outta here!")
247
+ evt_menu(Wx::ID_EXIT) {exit}
248
+ @mainmenu.append(menu, "&File")
249
+
250
+ # Make a Demo menu - thanks to Kevin Smith for figuring the submenus out!
251
+ menu = Wx::Menu.new
252
+ $tree_list.each do |item|
253
+ @submenu = Wx::Menu.new
254
+ item[1].each do |childItem|
255
+ mID = @demoID += 1
256
+ @submenu.append(mID, childItem)
257
+ evt_menu(mID) {|event| on_demo_menu(childItem)}
258
+ end
259
+ menuItem = Wx::MenuItem.new(menu, 500000, item[0], "", Wx::ITEM_NORMAL, @submenu)
260
+ menu.append_item(menuItem)
261
+ end
262
+ @mainmenu.append(menu, "&Demo")
263
+
264
+ # Make a Help menu
265
+ helpID = Wx::ID_ABOUT
266
+ findID = @demoID += 1
267
+ findnextID = @demoID += 1
268
+ clearID = @demoID += 1
269
+ menu = Wx::Menu.new
270
+ menu.append(findID, "&Find\tCtrl-F", "Find in the Demo Code")
271
+ menu.append(findnextID, "Find &Next\tF3", "Find Next")
272
+ menu.append_separator
273
+ menu.append(helpID, "&About\tCtrl-H", "wxRuby RULES!!!")
274
+ evt_menu(helpID) {|event| on_help_about(event)}
275
+ evt_menu(findID) {|event| on_help_find(event)}
276
+ evt_menu(findnextID) {|event| on_find_next(event)}
277
+ evt_find(-1) {|event| on_find(event)}
278
+ evt_find_next(-1) {|event| on_find(event)}
279
+ evt_find_close(-1) {|event| on_find_close(event)}
280
+ @mainmenu.append(menu, "&Help")
281
+ set_menu_bar(@mainmenu)
282
+
283
+ @finddata = Wx::FindReplaceData.new()
284
+
285
+ @treeMap = {}
286
+ @tree = Wx::TreeCtrl.new(splitter)
287
+ root = @tree.add_root("wxRuby Overview")
288
+ firstChild = nil
289
+
290
+ $tree_list.each do |item|
291
+ child = @tree.append_item(root, item[0])
292
+ if not firstChild then firstChild = child end
293
+ item[1].each do |childItem|
294
+ theDemo = @tree.append_item(child, childItem)
295
+ @treeMap[childItem] = theDemo
296
+ end
297
+ end
298
+ @tree.expand(root)
299
+ @tree.expand(firstChild)
300
+
301
+ evt_tree_item_expanded @tree, :on_item_expanded
302
+ evt_tree_item_collapsed @tree, :on_item_collapsed
303
+ evt_tree_sel_changed @tree, :on_tree_sel_changed
304
+ evt_tree_item_activated @tree, :on_tree_sel_changed
305
+ @tree.evt_left_down method(:on_tree_left_down)
306
+
307
+
308
+
309
+ # Create a Notebook
310
+ @nb = Wx::Notebook.new(splitter2, :style => Wx::CLIP_CHILDREN)
311
+
312
+ @ovr = Wx::TextCtrl.new(@nb, :value => OVR_TEXT, :style =>
313
+ Wx::TE_MULTILINE|Wx::TE_READONLY|
314
+ Wx::TE_RICH|Wx::TE_NOHIDESEL)
315
+ @nb.add_page(@ovr, "Overview")
316
+
317
+ if Wx.const_defined?(:Scintilla)
318
+ panel, @txt = setup_editor(@nb)
319
+ @nb.add_page(panel, "Demo Code")
320
+ else
321
+ # FIXME: Should use DemoCodeViewer, but when we do (on Windows) it
322
+ # puts all text on one line! Can remove instance_eval
323
+ # once that's resolved
324
+ @txt = Wx::TextCtrl.new(@nb, :value => OVR_TEXT, :style =>
325
+ Wx::TE_MULTILINE|Wx::TE_READONLY|
326
+ Wx::HSCROLL|Wx::TE_RICH|Wx::TE_RICH2|
327
+ Wx::TE_NOHIDESEL)
328
+ @txt.instance_eval { alias clear_all clear }
329
+ @txt.set_max_length(0)
330
+ @nb.add_page(@txt, "Demo Code")
331
+ end
332
+
333
+ get_demo_file(__FILE__)
334
+
335
+ @log = Wx::TextCtrl.new(splitter2, -1, "", Wx::DEFAULT_POSITION,
336
+ Wx::DEFAULT_SIZE,
337
+ Wx::TE_MULTILINE|Wx::TE_READONLY|Wx::HSCROLL)
338
+ # For some reason when the number of characters entered is
339
+ # greater than about 10,700, the text control freezes. I know
340
+ # someone mentioned this on the list a while ago...calling
341
+ # set_max_length(0) with zero as the argument tells the text
342
+ # control to default limit that the underlying native text
343
+ # control can handle.
344
+ @log.set_max_length(0)
345
+ Wx::Log::set_active_target(Wx::LogTextCtrl.new(@log))
346
+
347
+ splitter.split_vertically(@tree, splitter2, 220)
348
+ splitter2.split_horizontally(@nb, @log, 300)
349
+
350
+
351
+ splitter.set_minimum_pane_size(20)
352
+ splitter2.set_minimum_pane_size(100)
353
+
354
+ @nb.set_selection(0)
355
+ @tree.select_item(root)
356
+ show_tip()
357
+ end
358
+
359
+ def write_text(text)
360
+ Wx::log_message(text)
361
+ end
362
+
363
+ def on_idle(event)
364
+ if @otherWin != nil
365
+ @otherWin.raise()
366
+ @window = @otherWin
367
+ @otherWin = nil
368
+ end
369
+ end
370
+
371
+ def on_close(event)
372
+ @tbicon.remove_icon
373
+ destroy()
374
+ exit()
375
+ end
376
+
377
+ def on_item_expanded(event)
378
+ item = event.get_item()
379
+ Wx::log_message("on_item_expanded: %s" % @tree.get_item_text(item))
380
+ end
381
+
382
+ def on_item_collapsed(event)
383
+ item = event.get_item()
384
+ Wx::log_message("on_item_collapsed: %s" % @tree.get_item_text(item))
385
+ end
386
+
387
+ def on_tree_sel_changed(event)
388
+
389
+ item = event.get_item()
390
+
391
+ if item.nonzero?
392
+ itemText = @tree.get_item_text(item)
393
+ run_demo(itemText)
394
+ end
395
+ end
396
+
397
+ def on_tree_left_down(event)
398
+ pt = Wx::Point.new(event.get_x, event.get_y)
399
+ item = @tree.hit_test(pt)
400
+ if item == @tree.get_selection()
401
+ set_overview(@tree.get_item_text(item) + " Overview", @curOverview)
402
+ Wx::log_message(@tree.get_item_text(item) + " Overview")
403
+
404
+ end
405
+
406
+ event.skip()
407
+ end
408
+
409
+ def run_demo(itemText)
410
+ if @nb.get_page_count() == 3
411
+ if @nb.get_selection() == 2
412
+ @nb.set_selection(0)
413
+ end
414
+ if @window != nil
415
+ @window = nil
416
+ end
417
+ @nb.delete_page(2)
418
+ end
419
+
420
+ if itemText == "wxRuby Overview"
421
+ get_demo_file(__FILE__)
422
+ set_overview("wxRuby Overview", OVR_TEXT)
423
+ @nb.refresh()
424
+ @window = nil
425
+ else
426
+ demo_file = File.join( File.dirname(__FILE__), itemText + '.rbw')
427
+ if File.exist?(demo_file)
428
+ Wx::log_message("Running Demo: " + itemText + ".rbw")
429
+ get_demo_file(demo_file)
430
+ # I use load() here because it allows the user to modify
431
+ # the underlying file for each sample, so that each time
432
+ # They run it any changes made will be reflected without
433
+ # having to restart the demo.
434
+ begin
435
+ load demo_file
436
+ set_overview(itemText + " Overview", Demo::overview)
437
+ @tree.refresh()
438
+ @nb.refresh()
439
+ @window = Demo.run(self, @nb, self)
440
+ if @window.class.ancestors.include?(Wx::Window)
441
+ # Check to see if the demo returned a Wx::Window, Wx::Panel or a new class inheriting from them
442
+ # if so, create a new tab in the notebook for them
443
+ @nb.add_page(@window, "Demo")
444
+ @nb.set_selection(2)
445
+ @nb.refresh()
446
+ end
447
+ rescue Exception => problem
448
+ dlg = Wx::MessageDialog.new(self, "A problem occurred with the %s demo:\n%s\n%s" % [itemText, problem, problem.backtrace().join("\n").to_s()],
449
+ "Error!!!", Wx::OK | Wx::ICON_ERROR)
450
+ dlg.show_modal()
451
+ dlg.destroy()
452
+ end
453
+ else
454
+ @ovr.set_value("")
455
+ @txt.clear_all
456
+ @window = nil
457
+ end
458
+ end
459
+ @tree.set_focus()
460
+ end
461
+
462
+ def get_demo_file(fileName)
463
+ @filename = fileName
464
+ @txt.clear()
465
+ @txt.load_file(fileName)
466
+ if @txt.is_a?(Wx::TextCtrl)
467
+ @txt.set_insertion_point(0)
468
+ @txt.show_position(0)
469
+ end
470
+ end
471
+
472
+ def set_overview(name, text)
473
+ text ||= ''
474
+ @curOverview = text
475
+ @ovr.set_value(text)
476
+ @ovr.set_style(0,text.length,Wx::TextAttr.new(Wx::BLUE, Wx::Colour.new("White"), Wx::Font.new(12, Wx::FONTFAMILY_SWISS, Wx::FONTSTYLE_NORMAL, Wx::FONTWEIGHT_BOLD)))
477
+ @nb.set_page_text(0, name)
478
+ end
479
+
480
+ # Menu Methods
481
+
482
+ def on_file_exit(event)
483
+ close()
484
+ end
485
+
486
+ def on_help_about(event)
487
+ load File.join(File.dirname(__FILE__), "About.rbw")
488
+ about = About::MyAboutBox.new(self)
489
+ about.show_modal()
490
+ about.destroy()
491
+ end
492
+
493
+ def on_help_find(event)
494
+ @nb.set_selection(1)
495
+ @finddlg = Wx::FindReplaceDialog.new(self, @finddata, "Find", Wx::FR_NOUPDOWN | Wx::FR_NOMATCHCASE | Wx::FR_NOWHOLEWORD)
496
+ @finddlg.show()
497
+ end
498
+
499
+ def on_find(event)
500
+ # FIXME: These problems are probably resolved now
501
+ # Problems
502
+ # 1) For some reason, the control is not properly counting EOL characters - it almost seems to be skipping them
503
+ # causing the control to incorrectly set the initial insertion point for the the "found" text
504
+ # 2) This also is causing problems with the amount of text that is highlighted - the length of the highlighted string
505
+ # is less than it should be
506
+ # 3) After doing an initial "find" operation, using the "find next" operation causes the program to crash - again, I
507
+ # don't know why this is :(
508
+ # Example - When I try to find "menu", the text that gets highlighted is the newline on the second line and the "ME" of
509
+ # MENU_EXIT - a total of only 3 characters, when it should highlight all of "menu". I don't fully understand
510
+ # this problem, but it doesn't appear until after you attempt to find text beyond the first line :(
511
+ if @txt.is_a?(Wx::TextCtrl)
512
+ @nb.set_selection(1)
513
+ myEnd = @txt.get_last_position()
514
+ write_text("Last position = %d" % myEnd)
515
+ textstring = @txt.get_range(0,myEnd).downcase()
516
+ if Wx::PLATFORM == "WXMSW"
517
+ textstring.sub!(/\n/, "\r\n")
518
+ end
519
+ #write_text("textstring - %s" % textstring)
520
+ start = @txt.get_insertion_point()
521
+ write_text("insertion point = " + start.to_s())
522
+ findstring = @finddata.get_find_string().downcase()
523
+ write_text("finddata = " + findstring)
524
+ loc = textstring.index(findstring, start)
525
+ write_text("location = " + loc.to_s())
526
+ write_text("findstring.length() = " + findstring.length().to_s())
527
+ if loc == nil and start != 0
528
+ # string not found, start at beginning
529
+ start = 0
530
+ loc = textstring.index(findstring, start)
531
+ end
532
+
533
+ if loc == nil
534
+ dlg = Wx::MessageDialog.new(self, 'Find String Not Found', 'Find String Not Found in Demo File',
535
+ Wx::OK | Wx::ICON_INFORMATION)
536
+ dlg.show_modal()
537
+ dlg.destroy()
538
+ end
539
+
540
+ if @finddlg
541
+ if loc == nil
542
+ @finddlg.set_focus()
543
+ return
544
+ else
545
+ @finddlg.hide()
546
+ end
547
+ end
548
+ @txt.show_position(loc)
549
+ @txt.set_selection(loc, loc + findstring.length())
550
+ else # Scintilla
551
+ # FIXME: Take into account search direction
552
+ @txt.set_target_start(@txt.get_target_end)
553
+ @txt.set_target_end(@txt.get_length - 1)
554
+ # FIXME: get flags from find dialog
555
+ @txt.set_search_flags(0)
556
+ loc = @txt.search_in_target(event.get_find_string)
557
+ if loc == -1
558
+ dlg = Wx::MessageDialog.new(self, 'Find String Not Found', 'Find String Not Found in Demo File',
559
+ Wx::OK | Wx::ICON_INFORMATION)
560
+ dlg.show_modal()
561
+ dlg.destroy()
562
+ end
563
+
564
+ if @finddlg
565
+ if loc == -1
566
+ @finddlg.set_focus()
567
+ return
568
+ end
569
+ end
570
+ @txt.ensure_caret_visible
571
+ @txt.set_selection(loc, loc + event.get_find_string.length)
572
+ end
573
+ end
574
+
575
+ def on_find_next(event)
576
+ # FIXME: Saving an event is probably a bad idea
577
+ if @finddata.get_find_string() != ""
578
+ on_find(event)
579
+ else
580
+ on_help_find(event)
581
+ end
582
+ end
583
+
584
+ def on_find_close(event)
585
+ event.get_dialog().destroy()
586
+ end
587
+
588
+ def show_tip()
589
+ tips_file = File.join(File.dirname(__FILE__), 'tips.txt')
590
+ tp = Wx::create_file_tip_provider( tips_file, rand(6) )
591
+ Wx::show_tip(self, tp)
592
+ end
593
+
594
+ def on_demo_menu(childItem)
595
+ # Also, for some reason I haven't figured out yet either, the demo executes two times
596
+ selectedDemo = @treeMap[childItem]
597
+ if selectedDemo
598
+ @tree.select_item(selectedDemo)
599
+ @tree.ensure_visible(selectedDemo)
600
+ end
601
+ end
602
+
603
+ def on_iconize(event)
604
+ Wx::log_message("on_iconify")
605
+ event.skip
606
+ end
607
+
608
+ def on_maximize(event)
609
+ Wx::log_message("on_maximize")
610
+ event.skip
611
+ end
612
+
613
+ # FIXME: Refactor into a class
614
+ def setup_editor(parent)
615
+ panel = Wx::Panel.new(parent)
616
+ panel.hide
617
+ sci = setup_scintilla(panel)
618
+ @save_button = Wx::Button.new(panel, -1, 'Save Changes')
619
+ @delete_button = Wx::Button.new(panel, -1, 'Delete Modified')
620
+ @save_button.enable(false);
621
+ panel.evt_button(@save_button.get_id) { on_save }
622
+ panel.evt_button(@delete_button.get_id) { on_delete }
623
+ panel.evt_sci_modified { on_modified }
624
+
625
+ radio_buttons = {:original => Wx::RadioButton.new(panel, -1, "Original", Wx::DEFAULT_POSITION, Wx::DEFAULT_SIZE, Wx::RB_GROUP),
626
+ :modified => Wx::RadioButton.new(panel, -1, "Modified")}
627
+
628
+ @control_box = Wx::BoxSizer.new(Wx::HORIZONTAL)
629
+ @control_box.add(Wx::StaticText.new(panel, -1, 'Active Version:'), 0, Wx::RIGHT | Wx::LEFT | Wx::ALIGN_CENTER_VERTICAL, 5)
630
+ radio_buttons.each_pair { |id, button|
631
+ @control_box.add(button, 0, Wx::EXPAND | Wx::RIGHT, 5)
632
+ evt_radiobutton(button.get_id) { |event| on_radio_button(event) }
633
+ }
634
+ @control_box.add(@save_button, 0, Wx::RIGHT, 5)
635
+ @control_box.add(@delete_button, 0)
636
+
637
+ @box = Wx::BoxSizer.new(Wx::VERTICAL)
638
+ @box.add(@control_box, 0, Wx::EXPAND)
639
+ @box.add(Wx::StaticLine.new(panel), 0, Wx::EXPAND)
640
+
641
+ @box.add(sci, 1, Wx::EXPAND)
642
+ @box.fit(panel)
643
+ panel.set_sizer(@box)
644
+ [panel, sci]
645
+ end
646
+
647
+ def setup_scintilla(parent)
648
+ sci = Wx::Scintilla.new(parent)
649
+ font = Wx::Font.new(10, Wx::TELETYPE, Wx::NORMAL, Wx::NORMAL)
650
+ sci.style_set_font(Wx::SCI_STYLE_DEFAULT, font);
651
+ sci.set_edge_mode(Wx::SCI_EDGE_LINE)
652
+ line_num_margin = sci.text_width(Wx::SCI_STYLE_LINENUMBER, "_99999")
653
+ sci.set_margin_width(0, line_num_margin)
654
+
655
+ sci.style_set_foreground(Wx::SCI_STYLE_DEFAULT, Wx::BLACK);
656
+ sci.style_set_background(Wx::SCI_STYLE_DEFAULT, Wx::WHITE);
657
+ sci.style_set_foreground(Wx::SCI_STYLE_LINENUMBER, Wx::LIGHT_GREY);
658
+ sci.style_set_background(Wx::SCI_STYLE_LINENUMBER, Wx::WHITE);
659
+ sci.style_set_foreground(Wx::SCI_STYLE_INDENTGUIDE, Wx::LIGHT_GREY);
660
+
661
+ sci.set_tab_width(2)
662
+ sci.set_use_tabs(false)
663
+ sci.set_tab_indents(true)
664
+ sci.set_back_space_un_indents(true)
665
+ sci.set_indent(2)
666
+ sci.set_edge_column(80)
667
+
668
+ sci.set_lexer(Wx::SCI_LEX_RUBY)
669
+ sci.style_clear_all
670
+ sci.style_set_foreground(2, Wx::RED)
671
+ sci.style_set_foreground(3, Wx::GREEN)
672
+ sci.style_set_foreground(5, Wx::BLUE)
673
+ sci.style_set_foreground(6, Wx::BLUE)
674
+ sci.style_set_foreground(7, Wx::BLUE)
675
+ sci.set_key_words(0, "begin break elsif module retry unless end case next return until class ensure nil self when def false not super while alias defined? for or then yield and do if redo true else in rescue undef")
676
+
677
+ sci.set_property("fold","1")
678
+ sci.set_property("fold.compact", "0")
679
+ sci.set_property("fold.comment", "1")
680
+ sci.set_property("fold.preprocessor", "1")
681
+
682
+ sci.set_margin_width(1, 0)
683
+ sci.set_margin_type(1, Wx::SCI_MARGIN_SYMBOL)
684
+ sci.set_margin_mask(1, Wx::SCI_MASK_FOLDERS)
685
+ sci.set_margin_width(1, 20)
686
+
687
+ sci.marker_define(Wx::SCI_MARKNUM_FOLDER, Wx::SCI_MARK_PLUS)
688
+ sci.marker_define(Wx::SCI_MARKNUM_FOLDEROPEN, Wx::SCI_MARK_MINUS)
689
+ sci.marker_define(Wx::SCI_MARKNUM_FOLDEREND, Wx::SCI_MARK_EMPTY)
690
+ sci.marker_define(Wx::SCI_MARKNUM_FOLDERMIDTAIL, Wx::SCI_MARK_EMPTY)
691
+ sci.marker_define(Wx::SCI_MARKNUM_FOLDEROPENMID, Wx::SCI_MARK_EMPTY)
692
+ sci.marker_define(Wx::SCI_MARKNUM_FOLDERSUB, Wx::SCI_MARK_EMPTY)
693
+ sci.marker_define(Wx::SCI_MARKNUM_FOLDERTAIL, Wx::SCI_MARK_EMPTY)
694
+ sci.set_fold_flags(16)
695
+
696
+ sci.set_margin_sensitive(1,1)
697
+ sci
698
+ end
699
+
700
+ def on_save
701
+ if not FileTest.directory?(File.dirname(modified_filename))
702
+ if not Dir.mkdir(File.dirname(modified_filename))
703
+ Wx::log_message("Unable to create directory 'modified'")
704
+ return
705
+ end
706
+ end
707
+ File.open(modified_filename, "w") { |file|
708
+ file.write(@txt.get_text)
709
+ }
710
+ # FIXME: Reload module we just saved
711
+ end
712
+
713
+ def on_delete
714
+ if File.exists?(modified_filename)
715
+ File.unlink(modified_filename)
716
+ end
717
+ # FIXME: Update state
718
+ end
719
+
720
+ def on_modified
721
+ @save_button.enable(@txt.get_modify)
722
+ end
723
+
724
+ def on_radio_button(event)
725
+ # FIXME: Can't do anything here yet
726
+ end
727
+
728
+ def modified_filename
729
+ File.join(File.dirname(@filename), "modified", File.basename(@filename))
730
+ end
731
+ end
732
+
733
+ class DemoTaskBarIcon < Wx::TaskBarIcon
734
+ # TODO: Need a new_id function like wxPython has
735
+ TBMENU_RESTORE = 6000
736
+ TBMENU_CLOSE = 6001
737
+ TBMENU_CHANGE = 6002
738
+ TBMENU_REMOVE = 6003
739
+
740
+ def initialize(frame)
741
+ super()
742
+
743
+ @frame = frame
744
+
745
+ # starting image
746
+ icon = make_icon('ruby.png')
747
+ set_icon(icon, 'wxRuby Demo')
748
+ @image_index = 1
749
+
750
+ # events
751
+ evt_taskbar_left_dclick {|evt| on_taskbar_activate(evt) }
752
+
753
+ evt_menu(TBMENU_RESTORE) {|evt| on_taskbar_activate(evt) }
754
+ evt_menu(TBMENU_CLOSE) { @frame.close }
755
+ evt_menu(TBMENU_CHANGE) {|evt| on_taskbar_change(evt) }
756
+ evt_menu(TBMENU_REMOVE) { remove_icon }
757
+ end
758
+
759
+ def create_popup_menu
760
+ # Called by the base class when it needs to popup the menu
761
+ # (the default evt_right_down event). Create and return
762
+ # the menu to display.
763
+ menu = Wx::Menu.new
764
+ menu.append(TBMENU_RESTORE, "Restore wxRuby Demo")
765
+ menu.append(TBMENU_CLOSE, "Close wxRuby Demo")
766
+ menu.append_separator
767
+ menu.append(TBMENU_CHANGE, "Change the TB Icon")
768
+ menu.append(TBMENU_REMOVE, "Remove the TB Icon")
769
+ return menu
770
+ end
771
+
772
+ def make_icon(imgname)
773
+ # Different platforms have different requirements for the
774
+ # taskbar icon size
775
+ filename = File.join( File.dirname(__FILE__), 'icons', imgname )
776
+ img = Wx::Image.new(filename)
777
+ if Wx::PLATFORM == "WXMSW"
778
+ img = img.scale(16, 16)
779
+ elsif Wx::PLATFORM == "WXGTK"
780
+ img = img.scale(22, 22)
781
+ end
782
+ # WXMAC can be any size up to 128x128, so don't scale
783
+ icon = Wx::Icon.new
784
+ icon.copy_from_bitmap(Wx::Bitmap.new(img))
785
+ return icon
786
+ end
787
+
788
+ def on_taskbar_activate(evt)
789
+ if @frame.is_iconized
790
+ @frame.iconize(false)
791
+ end
792
+ if not @frame.is_shown
793
+ @frame.show(true)
794
+ end
795
+ @frame.raise
796
+ end
797
+
798
+ def on_taskbar_change(evt)
799
+ names = [ "ruby.png", "wxwin16x16.xpm", "smiles.xpm", "mondrian.xpm" ]
800
+ name = names[@image_index]
801
+ @image_index += 1
802
+ if @image_index >= names.length
803
+ @image_index = 0
804
+ end
805
+
806
+ icon = make_icon(name)
807
+ set_icon(icon, 'This is a new icon: ' + name)
808
+ end
809
+
810
+ end
811
+
812
+ class DemoApp < Wx::App
813
+ def on_init
814
+ frame = WxRubyDemo.new("WxRuby BIG combined demo",
815
+ Wx::DEFAULT_POSITION,
816
+ Wx::Size.new(750, 550))
817
+
818
+ frame.show(true)
819
+ end
820
+ end
821
+
822
+ demo = DemoApp.new
823
+ demo.main_loop