wxruby64 2.0.1-x64-mingw32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (279) hide show
  1. checksums.yaml +7 -0
  2. data/INSTALL +254 -0
  3. data/LICENSE +53 -0
  4. data/README +198 -0
  5. data/art/wxruby-128x128.png +0 -0
  6. data/art/wxruby-256x256.png +0 -0
  7. data/art/wxruby-64x64.png +0 -0
  8. data/art/wxruby.png +0 -0
  9. data/lib/wx.rb +53 -0
  10. data/lib/wx/accessors.rb +68 -0
  11. data/lib/wx/classes/acceleratortable.rb +28 -0
  12. data/lib/wx/classes/animation.rb +18 -0
  13. data/lib/wx/classes/app.rb +51 -0
  14. data/lib/wx/classes/artprovider.rb +31 -0
  15. data/lib/wx/classes/auinotebook.rb +9 -0
  16. data/lib/wx/classes/bitmap.rb +59 -0
  17. data/lib/wx/classes/busycursor.rb +12 -0
  18. data/lib/wx/classes/checklistbox.rb +46 -0
  19. data/lib/wx/classes/choice.rb +4 -0
  20. data/lib/wx/classes/clientdc.rb +13 -0
  21. data/lib/wx/classes/clipboard.rb +56 -0
  22. data/lib/wx/classes/colour.rb +49 -0
  23. data/lib/wx/classes/combobox.rb +4 -0
  24. data/lib/wx/classes/commandevent.rb +7 -0
  25. data/lib/wx/classes/controlwithitems.rb +10 -0
  26. data/lib/wx/classes/data_object.rb +14 -0
  27. data/lib/wx/classes/data_object_simple.rb +6 -0
  28. data/lib/wx/classes/dataformat.rb +23 -0
  29. data/lib/wx/classes/dc.rb +57 -0
  30. data/lib/wx/classes/event.rb +5 -0
  31. data/lib/wx/classes/evthandler.rb +1039 -0
  32. data/lib/wx/classes/font.rb +118 -0
  33. data/lib/wx/classes/functions.rb +44 -0
  34. data/lib/wx/classes/gauge.rb +12 -0
  35. data/lib/wx/classes/genericdirctrl.rb +36 -0
  36. data/lib/wx/classes/grid.rb +146 -0
  37. data/lib/wx/classes/hboxsizer.rb +6 -0
  38. data/lib/wx/classes/helpcontroller.rb +5 -0
  39. data/lib/wx/classes/helpcontrollerhelpprovider.rb +23 -0
  40. data/lib/wx/classes/helpprovider.rb +15 -0
  41. data/lib/wx/classes/htmlhelpcontroller.rb +5 -0
  42. data/lib/wx/classes/htmlwindow.rb +14 -0
  43. data/lib/wx/classes/icon.rb +32 -0
  44. data/lib/wx/classes/iconbundle.rb +3 -0
  45. data/lib/wx/classes/image.rb +53 -0
  46. data/lib/wx/classes/imagelist.rb +3 -0
  47. data/lib/wx/classes/listbox.rb +4 -0
  48. data/lib/wx/classes/listctrl.rb +33 -0
  49. data/lib/wx/classes/locale.rb +28 -0
  50. data/lib/wx/classes/mediactrl.rb +48 -0
  51. data/lib/wx/classes/menu.rb +62 -0
  52. data/lib/wx/classes/menuitem.rb +7 -0
  53. data/lib/wx/classes/notebook.rb +9 -0
  54. data/lib/wx/classes/object.rb +14 -0
  55. data/lib/wx/classes/paintdc.rb +12 -0
  56. data/lib/wx/classes/point.rb +56 -0
  57. data/lib/wx/classes/previewframe.rb +13 -0
  58. data/lib/wx/classes/rect.rb +19 -0
  59. data/lib/wx/classes/richtextctrl.rb +63 -0
  60. data/lib/wx/classes/simplehelpprovider.rb +38 -0
  61. data/lib/wx/classes/size.rb +58 -0
  62. data/lib/wx/classes/sizer.rb +43 -0
  63. data/lib/wx/classes/sound.rb +23 -0
  64. data/lib/wx/classes/splitterwindow.rb +10 -0
  65. data/lib/wx/classes/standardpaths.rb +9 -0
  66. data/lib/wx/classes/styledtextctrl.rb +92 -0
  67. data/lib/wx/classes/textctrl.rb +14 -0
  68. data/lib/wx/classes/texturlevent.rb +18 -0
  69. data/lib/wx/classes/timer.rb +96 -0
  70. data/lib/wx/classes/toolbar.rb +36 -0
  71. data/lib/wx/classes/toolbartool.rb +4 -0
  72. data/lib/wx/classes/treectrl.rb +44 -0
  73. data/lib/wx/classes/validator.rb +7 -0
  74. data/lib/wx/classes/vboxsizer.rb +6 -0
  75. data/lib/wx/classes/window.rb +89 -0
  76. data/lib/wx/classes/xmlresource.rb +54 -0
  77. data/lib/wx/helpers.rb +54 -0
  78. data/lib/wx/keyword_ctors.rb +204 -0
  79. data/lib/wx/keyword_defs.rb +585 -0
  80. data/lib/wx/version.rb +3 -0
  81. data/lib/wxruby2.so +0 -0
  82. data/samples/SAMPLES-LICENSE.TXT +18 -0
  83. data/samples/aui/aui.rb +1356 -0
  84. data/samples/bigdemo/About.rbw +39 -0
  85. data/samples/bigdemo/ColorPanel.rbw +23 -0
  86. data/samples/bigdemo/GridSimple.rbw +78 -0
  87. data/samples/bigdemo/MDIDemo.rbw +57 -0
  88. data/samples/bigdemo/PopupMenu.rbw +149 -0
  89. data/samples/bigdemo/ShapedWindow.rbw +128 -0
  90. data/samples/bigdemo/Sizers.rbw +543 -0
  91. data/samples/bigdemo/bigdemo.rb +823 -0
  92. data/samples/bigdemo/demoTemplate.rbw +33 -0
  93. data/samples/bigdemo/helpfile.htb +0 -0
  94. data/samples/bigdemo/icons/Test 015.jpg +0 -0
  95. data/samples/bigdemo/icons/Test 015.png +0 -0
  96. data/samples/bigdemo/icons/choice.bmp +0 -0
  97. data/samples/bigdemo/icons/choice.xpm +27 -0
  98. data/samples/bigdemo/icons/combo.bmp +0 -0
  99. data/samples/bigdemo/icons/combo.xpm +27 -0
  100. data/samples/bigdemo/icons/copy.xpm +25 -0
  101. data/samples/bigdemo/icons/cut.xpm +24 -0
  102. data/samples/bigdemo/icons/gauge.bmp +0 -0
  103. data/samples/bigdemo/icons/gauge.xpm +27 -0
  104. data/samples/bigdemo/icons/help.xpm +25 -0
  105. data/samples/bigdemo/icons/list.bmp +0 -0
  106. data/samples/bigdemo/icons/list.xpm +27 -0
  107. data/samples/bigdemo/icons/mondrian.ico +0 -0
  108. data/samples/bigdemo/icons/mondrian.xpm +44 -0
  109. data/samples/bigdemo/icons/new.xpm +24 -0
  110. data/samples/bigdemo/icons/ogl.ico +0 -0
  111. data/samples/bigdemo/icons/ogl.xpm +45 -0
  112. data/samples/bigdemo/icons/open.xpm +26 -0
  113. data/samples/bigdemo/icons/paste.bmp +0 -0
  114. data/samples/bigdemo/icons/paste.xpm +38 -0
  115. data/samples/bigdemo/icons/pointy.png +0 -0
  116. data/samples/bigdemo/icons/preview.xpm +26 -0
  117. data/samples/bigdemo/icons/print.xpm +26 -0
  118. data/samples/bigdemo/icons/radio.bmp +0 -0
  119. data/samples/bigdemo/icons/radio.xpm +27 -0
  120. data/samples/bigdemo/icons/robert.xpm +415 -0
  121. data/samples/bigdemo/icons/sashtest.ico +0 -0
  122. data/samples/bigdemo/icons/save.xpm +25 -0
  123. data/samples/bigdemo/icons/smiles.bmp +0 -0
  124. data/samples/bigdemo/icons/smiles.xpm +39 -0
  125. data/samples/bigdemo/icons/smiley.ico +0 -0
  126. data/samples/bigdemo/icons/smiley.xpm +42 -0
  127. data/samples/bigdemo/icons/stattext.xpm +24 -0
  128. data/samples/bigdemo/icons/test2.bmp +0 -0
  129. data/samples/bigdemo/icons/test2.png +0 -0
  130. data/samples/bigdemo/icons/test2.xpm +79 -0
  131. data/samples/bigdemo/icons/text.bmp +0 -0
  132. data/samples/bigdemo/icons/text.xpm +27 -0
  133. data/samples/bigdemo/icons/tog1.bmp +0 -0
  134. data/samples/bigdemo/icons/tog1.xpm +38 -0
  135. data/samples/bigdemo/icons/tog2.bmp +0 -0
  136. data/samples/bigdemo/icons/tog2.xpm +38 -0
  137. data/samples/bigdemo/icons/wxruby-128x128.png +0 -0
  138. data/samples/bigdemo/icons/wxwin.ico +0 -0
  139. data/samples/bigdemo/icons/wxwin16x16.png +0 -0
  140. data/samples/bigdemo/icons/wxwin16x16.xpm +25 -0
  141. data/samples/bigdemo/icons/wxwin32x32.png +0 -0
  142. data/samples/bigdemo/icons/wxwin48x48.png +0 -0
  143. data/samples/bigdemo/run.rb +90 -0
  144. data/samples/bigdemo/tips.txt +7 -0
  145. data/samples/bigdemo/utils.rb +12 -0
  146. data/samples/bigdemo/wxArtProvider.rbw +281 -0
  147. data/samples/bigdemo/wxBitmapButton.rbw +65 -0
  148. data/samples/bigdemo/wxButton.rbw +64 -0
  149. data/samples/bigdemo/wxCalendarCtrl.rbw +60 -0
  150. data/samples/bigdemo/wxCheckBox.rbw +50 -0
  151. data/samples/bigdemo/wxCheckListBox.rbw +65 -0
  152. data/samples/bigdemo/wxChoice.rbw +47 -0
  153. data/samples/bigdemo/wxChoicebook.rbw +78 -0
  154. data/samples/bigdemo/wxColourDialog.rbw +31 -0
  155. data/samples/bigdemo/wxComboBox.rbw +77 -0
  156. data/samples/bigdemo/wxCursor.rbw +136 -0
  157. data/samples/bigdemo/wxDialog.rbw +74 -0
  158. data/samples/bigdemo/wxDirDialog.rbw +29 -0
  159. data/samples/bigdemo/wxDragImage.rbw +70 -0
  160. data/samples/bigdemo/wxFileDialog.rbw +37 -0
  161. data/samples/bigdemo/wxFileDialog_Save.rbw +35 -0
  162. data/samples/bigdemo/wxFindReplaceDialog.rbw +82 -0
  163. data/samples/bigdemo/wxFontDialog.rbw +173 -0
  164. data/samples/bigdemo/wxFrame.rbw +53 -0
  165. data/samples/bigdemo/wxGauge.rbw +71 -0
  166. data/samples/bigdemo/wxGenericDirCtrl.rbw +74 -0
  167. data/samples/bigdemo/wxGrid.rbw +66 -0
  168. data/samples/bigdemo/wxHtmlHelpController.rbw +52 -0
  169. data/samples/bigdemo/wxListBox.rbw +140 -0
  170. data/samples/bigdemo/wxListCtrl_virtual.rbw +112 -0
  171. data/samples/bigdemo/wxMDIWindows.rbw +50 -0
  172. data/samples/bigdemo/wxMenu.rbw +236 -0
  173. data/samples/bigdemo/wxMessageDialog.rbw +27 -0
  174. data/samples/bigdemo/wxMiniFrame.rbw +70 -0
  175. data/samples/bigdemo/wxMultipleChoiceDialog.rbw +32 -0
  176. data/samples/bigdemo/wxNotebook.rbw +136 -0
  177. data/samples/bigdemo/wxProgressDialog.rbw +43 -0
  178. data/samples/bigdemo/wxRadioBox.rbw +72 -0
  179. data/samples/bigdemo/wxRadioButton.rbw +125 -0
  180. data/samples/bigdemo/wxSashWindow.rbw +141 -0
  181. data/samples/bigdemo/wxScrolledMessageDialog.rbw +57 -0
  182. data/samples/bigdemo/wxScrolledWindow.rbw +199 -0
  183. data/samples/bigdemo/wxSingleChoiceDialog.rbw +33 -0
  184. data/samples/bigdemo/wxSlider.rbw +42 -0
  185. data/samples/bigdemo/wxSpinButton.rbw +50 -0
  186. data/samples/bigdemo/wxSpinCtrl.rbw +51 -0
  187. data/samples/bigdemo/wxSplitterWindow.rbw +63 -0
  188. data/samples/bigdemo/wxStaticBitmap.rbw +47 -0
  189. data/samples/bigdemo/wxStaticText.rbw +55 -0
  190. data/samples/bigdemo/wxStatusBar.rbw +126 -0
  191. data/samples/bigdemo/wxTextCtrl.rbw +149 -0
  192. data/samples/bigdemo/wxTextEntryDialog.rbw +31 -0
  193. data/samples/bigdemo/wxToggleButton.rbw +49 -0
  194. data/samples/bigdemo/wxToolBar.rbw +131 -0
  195. data/samples/bigdemo/wxTreeCtrl.rbw +191 -0
  196. data/samples/calendar/calendar.rb +348 -0
  197. data/samples/caret/caret.rb +282 -0
  198. data/samples/caret/mondrian.xpm +44 -0
  199. data/samples/controls/controls.rb +1136 -0
  200. data/samples/controls/get_item_sample.rb +87 -0
  201. data/samples/controls/icons/choice.xpm +27 -0
  202. data/samples/controls/icons/combo.xpm +27 -0
  203. data/samples/controls/icons/gauge.xpm +27 -0
  204. data/samples/controls/icons/list.xpm +27 -0
  205. data/samples/controls/icons/radio.xpm +27 -0
  206. data/samples/controls/icons/stattext.xpm +24 -0
  207. data/samples/controls/icons/text.xpm +27 -0
  208. data/samples/controls/mondrian.ico +0 -0
  209. data/samples/controls/mondrian.xpm +44 -0
  210. data/samples/controls/test2.bmp +0 -0
  211. data/samples/dialogs/dialogs.rb +797 -0
  212. data/samples/dialogs/tips.txt +18 -0
  213. data/samples/dragdrop/dragdrop.rb +177 -0
  214. data/samples/drawing/bitmap.rb +49 -0
  215. data/samples/drawing/bitmap_image.rb +92 -0
  216. data/samples/drawing/graphics_drawing.rb +235 -0
  217. data/samples/drawing/maths_images.rb +265 -0
  218. data/samples/drawing/rmagic_bitmap_image.rb +110 -0
  219. data/samples/drawing/ruby-logo.jpg +0 -0
  220. data/samples/etc/activation.rb +102 -0
  221. data/samples/etc/choice.rb +67 -0
  222. data/samples/etc/miniframe.rb +79 -0
  223. data/samples/etc/sash.rb +130 -0
  224. data/samples/etc/scrollwin.rb +110 -0
  225. data/samples/etc/system_settings.rb +252 -0
  226. data/samples/etc/threaded.rb +72 -0
  227. data/samples/etc/toolbar_sizer_additem.rb +55 -0
  228. data/samples/etc/wizard.rb +74 -0
  229. data/samples/event/event.rb +182 -0
  230. data/samples/event/update_ui_event.rb +70 -0
  231. data/samples/grid/grid.rb +198 -0
  232. data/samples/grid/gridtablebase.rb +148 -0
  233. data/samples/html/html.rb +262 -0
  234. data/samples/listbook/listbook.rb +174 -0
  235. data/samples/listbook/listbook.xrc +370 -0
  236. data/samples/mdi/mdi.rb +85 -0
  237. data/samples/media/mediactrl.rb +167 -0
  238. data/samples/minimal/minimal.rb +77 -0
  239. data/samples/minimal/mondrian.ico +0 -0
  240. data/samples/minimal/mondrian.png +0 -0
  241. data/samples/minimal/nothing.rb +16 -0
  242. data/samples/opengl/cube.rb +130 -0
  243. data/samples/opengl/cube_anim_lighting.rb +191 -0
  244. data/samples/printing/mondrian.ico +0 -0
  245. data/samples/printing/mondrian.xpm +44 -0
  246. data/samples/printing/printing.rb +487 -0
  247. data/samples/sockets/SocketPackets.rb +27 -0
  248. data/samples/sockets/res/message-new.png +0 -0
  249. data/samples/sockets/res/user.png +0 -0
  250. data/samples/sockets/wxClient.rb +395 -0
  251. data/samples/sockets/wxServer.rb +422 -0
  252. data/samples/sockets/wxSocketGUI.rb +97 -0
  253. data/samples/text/document-open.png +0 -0
  254. data/samples/text/document-save.png +0 -0
  255. data/samples/text/edit-copy.png +0 -0
  256. data/samples/text/edit-cut.png +0 -0
  257. data/samples/text/edit-paste.png +0 -0
  258. data/samples/text/edit-redo.png +0 -0
  259. data/samples/text/edit-undo.png +0 -0
  260. data/samples/text/format-text-bold.png +0 -0
  261. data/samples/text/format-text-italic.png +0 -0
  262. data/samples/text/format-text-underline.png +0 -0
  263. data/samples/text/mondrian.ico +0 -0
  264. data/samples/text/mondrian.xpm +44 -0
  265. data/samples/text/preferences-desktop-font.png +0 -0
  266. data/samples/text/rich_textctrl.rb +290 -0
  267. data/samples/text/scintilla.rb +169 -0
  268. data/samples/text/textctrl.rb +111 -0
  269. data/samples/text/unicode.rb +242 -0
  270. data/samples/text/utf8.txt +15 -0
  271. data/samples/treectrl/icon1.xpm +79 -0
  272. data/samples/treectrl/icon2.xpm +53 -0
  273. data/samples/treectrl/icon3.xpm +79 -0
  274. data/samples/treectrl/icon4.xpm +43 -0
  275. data/samples/treectrl/icon5.xpm +79 -0
  276. data/samples/treectrl/treectrl.rb +1166 -0
  277. data/samples/xrc/samples.xrc +46 -0
  278. data/samples/xrc/xrc_sample.rb +76 -0
  279. metadata +330 -0
@@ -0,0 +1,72 @@
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
+ # This simple sample demonstrates how to use Ruby 1.8's lightweight
11
+ # (green) threads to execute non-GUI code in parallel with a wxRuby
12
+ # GUI. This strategy is useful in a number of situations:
13
+ #
14
+ # * To keep the GUI responsive whilst computationally intensive
15
+ # operations are carried out in the background
16
+ # * To keep the GUI responsive while waiting for networking operations
17
+ # to complete
18
+ #
19
+ # The basic problem is that, as with other Ruby GUI toolkits, non-GUI
20
+ # threads will not, by default, get allocated time to run while Ruby is
21
+ # busy in Wx code - the main wxRuby event loop. Strategies to deal with
22
+ # this include using non-blocking IO, and, more generically, using
23
+ # wxRuby's Timer class to explicitly allocate time for non-GUI threads
24
+ # to run. The latter technique is shown here.
25
+
26
+ # This frame shows a set of progress bars which monitor progress of
27
+ # long-running tasks. In this example, this long-running task is
28
+ # emulated by simply sleep-ing for random periods, but could equally be
29
+ # downloading from a socket or parsing a file.
30
+ class ProgressFrame < Wx::Frame
31
+ STEPS = 20
32
+ def initialize
33
+ super(nil, :title => 'Threading demo')
34
+ @gauges = []
35
+ panel = Wx::Panel.new(self)
36
+ sizer = Wx::BoxSizer.new(Wx::VERTICAL)
37
+ # show ten gauges
38
+ 10.times do
39
+ gauge = Wx::Gauge.new(panel, :range => STEPS)
40
+ # For each gauge, start a new thread in which the task runs
41
+ Thread.new do
42
+ # The long-running task
43
+ STEPS.times do | i |
44
+ sleep rand(100) / 50.0
45
+ # Update the main GUI
46
+ gauge.value = i + 1
47
+ end
48
+ end
49
+ @gauges << gauge
50
+ sizer.add(gauge, 0, Wx::GROW|Wx::ALL, 2)
51
+ end
52
+ panel.sizer = sizer
53
+ sizer.fit(panel)
54
+ end
55
+ end
56
+
57
+ # This app class creates a frame, and, importantly, a timer to allow
58
+ class GaugeApp < Wx::App
59
+ # Get a guaranteed-unique id
60
+ THREAD_TIMER_ID = Wx::ID_HIGHEST + 1
61
+ def on_init
62
+ # Create a global application timer that passes control to other
63
+ # ruby threads. The timer will run every 1/40 second (25ms). Higher
64
+ # values will make the other threads run more often, but will
65
+ # eventually degrade the responsiveness of the GUI.
66
+ Wx::Timer.every(25) { Thread.pass }
67
+ prog = ProgressFrame.new
68
+ prog.show
69
+ end
70
+ end
71
+
72
+ GaugeApp.new.main_loop
@@ -0,0 +1,55 @@
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
+
5
+ require 'rubygems' rescue LoadError
6
+
7
+ require 'wx'
8
+
9
+ # Simple test application for keyword arguments to Sizer#add_item and
10
+ # ToolBar#add_item. Originally contributed by Chauk-Mean P
11
+
12
+ Wx::App.run do
13
+ frame = Wx::Frame.new( nil,
14
+ :title => 'ToolBar and Sizer API enhancements') do
15
+
16
+ sizer = Wx::BoxSizer.new(Wx::VERTICAL)
17
+
18
+ button1 = Wx::Button.new(self, :label => 'Button 1')
19
+ button2 = Wx::Button.new(self, :label => 'Button 2')
20
+ button3 = Wx::Button.new(self, :label => 'Button 3')
21
+
22
+ # Sizer#add_item usage
23
+ # use of positional arguments
24
+ sizer.add_item(button1, -1, 1, Wx::EXPAND)
25
+ # use of a spacer
26
+ sizer.add_item([20, 15])
27
+ # use of keyword arguments without index
28
+ sizer.add_item(button3, :proportion => 1, :flag => Wx::EXPAND)
29
+ # use of keyword arguments with index specified
30
+ sizer.add_item(button2, :index => 1, :proportion => 1, :flag => Wx::EXPAND)
31
+ self.sizer = sizer
32
+
33
+ # ToolBar#add_item usage
34
+ toolbar = create_tool_bar( Wx::TB_HORIZONTAL|Wx::TB_FLAT )
35
+ # provide only a bitmap
36
+ new_item_id = toolbar.add_item( Wx::ArtProvider.bitmap(Wx::ART_NEW) )
37
+ # use of keyword arguments without pos
38
+ save_item_id = toolbar.add_item( Wx::ArtProvider.bitmap(Wx::ART_FILE_SAVE),
39
+ :short_help => "Save")
40
+ # use of keyword arguments with pos
41
+ open_item_id = toolbar.add_item( Wx::ArtProvider.bitmap(Wx::ART_FILE_OPEN),
42
+ :position => 1,
43
+ :short_help => "Open")
44
+ toolbar.realize
45
+
46
+ # tool item event handling
47
+ evt_tool new_item_id do
48
+ Wx::message_box "New clicked"
49
+ end
50
+
51
+ end
52
+
53
+ frame.show
54
+ end
55
+
@@ -0,0 +1,74 @@
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
+ class MyFrame < Wx::Frame
12
+ def initialize(title, pos, size)
13
+ super(nil, :title => title, :position => pos, :size => size)
14
+
15
+ menuFile = Wx::Menu.new
16
+ helpMenu = Wx::Menu.new
17
+ helpMenu.append(Wx::ID_ABOUT, "&About...\tF1", "Show about dialog")
18
+ menuFile.append(Wx::ID_EXIT, "E&xit\tAlt-X", "Quit this program")
19
+ menuBar = Wx::MenuBar.new
20
+ menuBar.append(menuFile, "&File")
21
+ menuBar.append(helpMenu, "&Help")
22
+ self.menu_bar = menuBar
23
+
24
+ create_status_bar(1)
25
+ self.status_text = "Welcome to wxRuby!"
26
+ s = Wx::StaticText.new(self, :label => 'The Wizard has completed')
27
+ evt_menu Wx::ID_EXIT, :on_quit
28
+ evt_menu Wx::ID_ABOUT, :on_about
29
+
30
+ w = Wx::Wizard.new(self, :title => 'The WxRuby Wizard')
31
+ p1 = Wx::WizardPageSimple.new(w)
32
+ s = Wx::StaticText.new(p1, :label => 'This is the first page')
33
+
34
+ p2 = Wx::WizardPageSimple.new(w, p1)
35
+ p1.set_next(p2)
36
+ s = Wx::StaticText.new(p2, :label => 'This is the second page')
37
+
38
+ p3 = Wx::WizardPageSimple.new(w, p2)
39
+ p2.set_next(p3)
40
+ s = Wx::StaticText.new(p3, :label => 'This is the final page')
41
+
42
+ evt_wizard_page_changed(w) { p "page changed" }
43
+ evt_wizard_page_changing(w) { p "page changing" }
44
+ evt_wizard_help(w) { p "wizard help" }
45
+ evt_wizard_cancel(w) { p "wizard cancelled" }
46
+ evt_wizard_finished(w) { p "wizard finished" }
47
+
48
+ w.run_wizard(p1)
49
+ end
50
+
51
+ def on_quit
52
+ close(true)
53
+ end
54
+
55
+ def on_about
56
+ msg = sprintf("This is the About dialog of the wizard sample.\n" \
57
+ "Welcome to %s", Wx::VERSION_STRING)
58
+ Wx::message_box(msg, "About Wizard", Wx::OK|Wx::ICON_INFORMATION, self)
59
+ end
60
+ end
61
+
62
+ class RbApp < Wx::App
63
+ def on_init
64
+ frame = MyFrame.new("Wizard wxRuby App",
65
+ Wx::Point.new(50, 50),
66
+ Wx::Size.new(450, 340))
67
+ frame.show(true)
68
+
69
+ end
70
+ end
71
+
72
+ app = RbApp.new
73
+ app.main_loop()
74
+
@@ -0,0 +1,182 @@
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
+ # This sample demonstrates how to dynamically connect and disconnect
11
+ # event handlers, and how to create custom event types and listeners
12
+ # associated with user-defined control classes.
13
+
14
+ # A custom type of event associated with a target control. Note that for
15
+ # user-defined controls, the associated event should inherit from
16
+ # Wx::CommandEvent rather than Wx::Event.
17
+ class TargetHitEvent < Wx::CommandEvent
18
+ # Create a new unique constant identifier, associate this class
19
+ # with events of that identifier, and create a shortcut 'evt_target'
20
+ # method for setting up this handler.
21
+ EVT_HIT_TARGET = Wx::EvtHandler.register_class(self, nil, 'evt_target', 1)
22
+
23
+ def initialize(target, score, distance)
24
+ # The constant id is the arg to super
25
+ super(EVT_HIT_TARGET)
26
+ # client_data should be used to store any information associated
27
+ # with the event.
28
+ self.client_data = { :score => score, :distance => distance }
29
+ self.id = target.get_id
30
+ end
31
+
32
+ # Returns the points score associated with this event
33
+ def score
34
+ client_data[:score]
35
+ end
36
+
37
+ # Returns the distance (in pixels) from the centre of the target
38
+ def distance
39
+ client_data[:distance]
40
+ end
41
+ end
42
+
43
+ # An example of a simple user-written control, which displays a
44
+ # "bulls-eye" like target, and sends events with a score and distance
45
+ class TargetControl < Wx::Window
46
+ TargetCircle = Struct.new(:radius, :score, :brush)
47
+
48
+ def initialize(parent, *args)
49
+ super(parent, *args)
50
+
51
+ # Set up the scores and sizes of the rings
52
+ @radii = [
53
+ TargetCircle[ 0.1, 20, Wx::RED_BRUSH ],
54
+ TargetCircle[ 0.25, 10, Wx::BLUE_BRUSH ],
55
+ TargetCircle[ 0.4, 5, Wx::GREEN_BRUSH ] ]
56
+ evt_paint { | e | on_paint(e) }
57
+ evt_left_down { | e | on_left_down(e) }
58
+ end
59
+
60
+ # What point is at the centre (assuming this control is always square)
61
+ def centre_point
62
+ size.width / 2
63
+ end
64
+
65
+ # Called whenever the target is repainted, draws a series of
66
+ # concentric circles
67
+ def on_paint(evt)
68
+ paint do | dc |
69
+ dc.clear
70
+ @radii.reverse_each do | circ |
71
+ dc.brush = circ.brush
72
+ dc.draw_circle(centre_point, centre_point,
73
+ ( size.width * circ.radius).to_i )
74
+ end
75
+ end
76
+ end
77
+
78
+ # Test if the target was hit, and generate a TargetHitEvent if so
79
+ def on_left_down(evt)
80
+ # quick bit of pythagoras...
81
+ distance = Math.sqrt( ( evt.x - centre_point ) ** 2 +
82
+ ( evt.y - centre_point ) ** 2 )
83
+ # See which target ring, if any, was hit by the event
84
+ @radii.each do | circ |
85
+ if distance < ( size.width * circ.radius)
86
+ # Create an instance of the event
87
+ evt = TargetHitEvent.new(self, circ.score, distance)
88
+ # This sends the event for processing by listeners
89
+ event_handler.process_event(evt)
90
+ break
91
+ end
92
+ end
93
+ end
94
+ end
95
+
96
+ # Container frame for the target control
97
+ class TargetFrame < Wx::Frame
98
+ def initialize(title)
99
+ super(nil, :title => title, :size => [300, 300])
100
+ @tgt = TargetControl.new(self)
101
+ # This user-defined event handling method was set up by
102
+ # EvtHandler.register_class, above
103
+ evt_target(@tgt.get_id) { | e | on_target(e) }
104
+ @listening = true
105
+ evt_size { | e | on_size(e) }
106
+ setup_menus
107
+ create_status_bar
108
+ end
109
+
110
+ # What's done when the target is hit
111
+ def on_target(evt)
112
+ msg = "Target hit for score %i, %.2f pixels from centre" %
113
+ [ evt.score, evt.distance ]
114
+ self.status_text = msg
115
+ end
116
+
117
+ # Keep the target centred and square
118
+ def on_size(evt)
119
+ smaller = [ evt.size.width, evt.size.height ].min
120
+ @tgt.centre
121
+ @tgt.size = Wx::Size.new(smaller, smaller)
122
+ @tgt.refresh
123
+ end
124
+
125
+ # Toggle whether or not we are listening for events from the bulls-eye
126
+ # target
127
+ def on_toggle_connect
128
+ if @listening
129
+ # Remove :evt_target event handler for the @tgt
130
+ disconnect(@tgt.get_id, Wx::ID_ANY, :evt_target)
131
+ menu_bar.check(TOGGLE_LISTEN, false)
132
+ self.status_text = "Ignoring target events"
133
+ @listening = false
134
+ else
135
+ # Restore evt_target event handler for the @tgt
136
+ evt_target(@tgt.get_id) { | e | on_target(e) }
137
+ menu_bar.check(TOGGLE_LISTEN, true)
138
+ self.status_text = ''
139
+ @listening = true
140
+ end
141
+ end
142
+
143
+ def on_about
144
+ msg = sprintf("This is the About dialog of the event handling sample.\n" \
145
+ "Welcome to wxRuby, version %s", Wx::WXRUBY_VERSION)
146
+
147
+ about_dlg = Wx::MessageDialog.new( self, msg, 'About Event Handling',
148
+ Wx::OK|Wx::ICON_INFORMATION )
149
+ about_dlg.show_modal
150
+
151
+ end
152
+
153
+ TOGGLE_LISTEN = 1001
154
+ def setup_menus
155
+ menu_file = Wx::Menu.new
156
+ menu_help = Wx::Menu.new
157
+ menu_help.append(Wx::ID_ABOUT, "&About...\tF1", "Show about dialog")
158
+ evt_menu(Wx::ID_ABOUT) { on_about }
159
+ menu_file.append(Wx::ID_EXIT, "E&xit\tAlt-X", "Quit this program")
160
+ evt_menu(Wx::ID_EXIT) { self.close }
161
+ menu_file.append_check_item(TOGGLE_LISTEN, "L&isten for events",
162
+ "Toggle listening for target events")
163
+ evt_menu(TOGGLE_LISTEN) { on_toggle_connect }
164
+
165
+ menu_bar = Wx::MenuBar.new
166
+ menu_bar.append(menu_file, "&File")
167
+ menu_bar.append(menu_help, "&Help")
168
+
169
+ self.menu_bar = menu_bar
170
+ menu_bar.check(TOGGLE_LISTEN, true)
171
+ end
172
+ end
173
+
174
+ class TargetApp < Wx::App
175
+ def on_init
176
+ TargetFrame.new("Event Handling Sample").show
177
+ return true
178
+ end
179
+ end
180
+
181
+ a = TargetApp.new
182
+ a.main_loop()
@@ -0,0 +1,70 @@
1
+ #!/usr/bin/env ruby
2
+ begin
3
+ require 'rubygems'
4
+ rescue LoadError
5
+ end
6
+ require 'wx'
7
+
8
+ # Demonstrating the use of evt_update_ui to keep menu items and controls
9
+ # in sync in being enabled/disabled, checked/unchecked.
10
+ #
11
+ # evt_update_ui is called repeatedly whenever the item is (or is about
12
+ # to become) visible; by calling methods on the passed event object, the
13
+ # state of the control is updated. For complex applications, this can be
14
+ # a lot simpler (less code, more reliable) than having to remember to
15
+ # update all the relevant controls and items whenever the state changes.
16
+ #
17
+ # In the example below, the application is globally in edit mode. This
18
+ # mode can be changed either from a menu item, or via a
19
+ # checkbox. Whichever is used to change, the state of the other should
20
+ # be kept in sync
21
+ class UpdateUIFrame < Wx::Frame
22
+ def initialize
23
+ super(nil, :title => 'Update UI example', :size => [ 400, 300 ])
24
+ @edit_mode = false
25
+
26
+ # First, set up the menus
27
+ self.menu_bar = Wx::MenuBar.new
28
+ menu_edit = Wx::Menu.new
29
+
30
+ # Toggle case-change menu item
31
+ menu_edit.append_check_item(Wx::ID_EDIT, 'Allow case change')
32
+ # When the item is called, toggle edit mode
33
+ evt_menu(Wx::ID_EDIT) { @edit_mode = ! @edit_mode }
34
+ # Give the menu item a check or not, depending on mode
35
+ evt_update_ui(Wx::ID_EDIT) { | evt | evt.check(@edit_mode) }
36
+
37
+ # Upcase menu item
38
+ up_case = menu_edit.append('Upper case')
39
+ evt_menu(up_case) { @txt.value = @txt.value.upcase }
40
+ evt_update_ui(up_case) { | evt | evt.enable(@edit_mode) }
41
+
42
+ # Lowercase menu item
43
+ up_case = menu_edit.append('Lower case')
44
+ evt_menu(up_case) { @txt.value = @txt.value.downcase }
45
+ evt_update_ui(up_case) { | evt | evt.enable(@edit_mode) }
46
+
47
+ menu_bar.append(menu_edit, "&Edit")
48
+
49
+ # Second, the frame contents
50
+ self.sizer = Wx::BoxSizer.new(Wx::VERTICAL)
51
+
52
+ # A text control
53
+ @txt = Wx::TextCtrl.new( self,
54
+ :value => 'Welcome to wxRuby',
55
+ :style => Wx::TE_MULTILINE )
56
+ sizer.add(@txt, 1, Wx::GROW|Wx::ALL, 5)
57
+
58
+ # A checkbox, use the Wx::ID_EDIT id to share evt code with the
59
+ # corresponding menu item
60
+ @cbx = Wx::CheckBox.new( self,
61
+ :id => Wx::ID_EDIT,
62
+ :label => 'Allow case change')
63
+ evt_checkbox(@cbx) { @edit_mode = ! @edit_mode }
64
+
65
+ sizer.add(@cbx, 0, Wx::RIGHT|Wx::ALL, 5)
66
+ sizer.layout
67
+ end
68
+ end
69
+
70
+ Wx::App.run { UpdateUIFrame.new.show }