wxruby 1.9.3-universal-darwin

Sign up to get free protection for your applications and to get access to all the features.
Files changed (226) hide show
  1. data/LICENSE +53 -0
  2. data/README +299 -0
  3. data/lib/wx.rb +42 -0
  4. data/lib/wx/accessors.rb +52 -0
  5. data/lib/wx/classes/app.rb +45 -0
  6. data/lib/wx/classes/artprovider.rb +31 -0
  7. data/lib/wx/classes/bitmap.rb +23 -0
  8. data/lib/wx/classes/checklistbox.rb +45 -0
  9. data/lib/wx/classes/choice.rb +4 -0
  10. data/lib/wx/classes/clientdc.rb +13 -0
  11. data/lib/wx/classes/clipboard.rb +16 -0
  12. data/lib/wx/classes/colour.rb +47 -0
  13. data/lib/wx/classes/combobox.rb +4 -0
  14. data/lib/wx/classes/commandevent.rb +7 -0
  15. data/lib/wx/classes/controlwithitems.rb +10 -0
  16. data/lib/wx/classes/event.rb +5 -0
  17. data/lib/wx/classes/evthandler.rb +894 -0
  18. data/lib/wx/classes/font.rb +118 -0
  19. data/lib/wx/classes/grid.rb +129 -0
  20. data/lib/wx/classes/helpcontroller.rb +5 -0
  21. data/lib/wx/classes/htmlhelpcontroller.rb +5 -0
  22. data/lib/wx/classes/htmlwindow.rb +6 -0
  23. data/lib/wx/classes/icon.rb +14 -0
  24. data/lib/wx/classes/image.rb +14 -0
  25. data/lib/wx/classes/listbox.rb +4 -0
  26. data/lib/wx/classes/listctrl.rb +21 -0
  27. data/lib/wx/classes/locale.rb +28 -0
  28. data/lib/wx/classes/mediactrl.rb +22 -0
  29. data/lib/wx/classes/menu.rb +62 -0
  30. data/lib/wx/classes/menuitem.rb +7 -0
  31. data/lib/wx/classes/object.rb +7 -0
  32. data/lib/wx/classes/paintdc.rb +12 -0
  33. data/lib/wx/classes/point.rb +48 -0
  34. data/lib/wx/classes/previewframe.rb +13 -0
  35. data/lib/wx/classes/rect.rb +5 -0
  36. data/lib/wx/classes/size.rb +49 -0
  37. data/lib/wx/classes/sound.rb +23 -0
  38. data/lib/wx/classes/styledtextctrl.rb +92 -0
  39. data/lib/wx/classes/textctrl.rb +14 -0
  40. data/lib/wx/classes/texturlevent.rb +6 -0
  41. data/lib/wx/classes/timer.rb +69 -0
  42. data/lib/wx/classes/treectrl.rb +44 -0
  43. data/lib/wx/classes/window.rb +49 -0
  44. data/lib/wx/classes/xmlresource.rb +16 -0
  45. data/lib/wx/keyword_ctors.rb +219 -0
  46. data/lib/wx/keyword_defs.rb +485 -0
  47. data/lib/wx/version.rb +3 -0
  48. data/lib/wxruby2.bundle +0 -0
  49. data/samples/SAMPLES-LICENSE.TXT +18 -0
  50. data/samples/aui/aui.rb +1360 -0
  51. data/samples/bigdemo/About.rbw +39 -0
  52. data/samples/bigdemo/ColorPanel.rbw +25 -0
  53. data/samples/bigdemo/GridSimple.rbw +80 -0
  54. data/samples/bigdemo/MDIDemo.rbw +59 -0
  55. data/samples/bigdemo/PopupMenu.rbw +151 -0
  56. data/samples/bigdemo/ShapedWindow.rbw +135 -0
  57. data/samples/bigdemo/Sizers.rbw +545 -0
  58. data/samples/bigdemo/bigdemo.rb +826 -0
  59. data/samples/bigdemo/demoTemplate.rbw +37 -0
  60. data/samples/bigdemo/helpfile.htb +0 -0
  61. data/samples/bigdemo/icons/Test 015.jpg +0 -0
  62. data/samples/bigdemo/icons/Test 015.png +0 -0
  63. data/samples/bigdemo/icons/choice.bmp +0 -0
  64. data/samples/bigdemo/icons/choice.xpm +27 -0
  65. data/samples/bigdemo/icons/combo.bmp +0 -0
  66. data/samples/bigdemo/icons/combo.xpm +27 -0
  67. data/samples/bigdemo/icons/copy.xpm +25 -0
  68. data/samples/bigdemo/icons/cut.xpm +24 -0
  69. data/samples/bigdemo/icons/gauge.bmp +0 -0
  70. data/samples/bigdemo/icons/gauge.xpm +27 -0
  71. data/samples/bigdemo/icons/help.xpm +25 -0
  72. data/samples/bigdemo/icons/list.bmp +0 -0
  73. data/samples/bigdemo/icons/list.xpm +27 -0
  74. data/samples/bigdemo/icons/mondrian.ico +0 -0
  75. data/samples/bigdemo/icons/mondrian.xpm +44 -0
  76. data/samples/bigdemo/icons/new.xpm +24 -0
  77. data/samples/bigdemo/icons/ogl.ico +0 -0
  78. data/samples/bigdemo/icons/ogl.xpm +45 -0
  79. data/samples/bigdemo/icons/open.xpm +26 -0
  80. data/samples/bigdemo/icons/paste.bmp +0 -0
  81. data/samples/bigdemo/icons/paste.xpm +38 -0
  82. data/samples/bigdemo/icons/pointy.png +0 -0
  83. data/samples/bigdemo/icons/preview.xpm +26 -0
  84. data/samples/bigdemo/icons/print.xpm +26 -0
  85. data/samples/bigdemo/icons/radio.bmp +0 -0
  86. data/samples/bigdemo/icons/radio.xpm +27 -0
  87. data/samples/bigdemo/icons/robert.xpm +415 -0
  88. data/samples/bigdemo/icons/ruby.png +0 -0
  89. data/samples/bigdemo/icons/sashtest.ico +0 -0
  90. data/samples/bigdemo/icons/save.xpm +25 -0
  91. data/samples/bigdemo/icons/smiles.bmp +0 -0
  92. data/samples/bigdemo/icons/smiles.xpm +39 -0
  93. data/samples/bigdemo/icons/smiley.ico +0 -0
  94. data/samples/bigdemo/icons/smiley.xpm +42 -0
  95. data/samples/bigdemo/icons/stattext.xpm +24 -0
  96. data/samples/bigdemo/icons/test2.bmp +0 -0
  97. data/samples/bigdemo/icons/test2.png +0 -0
  98. data/samples/bigdemo/icons/test2.xpm +79 -0
  99. data/samples/bigdemo/icons/text.bmp +0 -0
  100. data/samples/bigdemo/icons/text.xpm +27 -0
  101. data/samples/bigdemo/icons/tog1.bmp +0 -0
  102. data/samples/bigdemo/icons/tog1.xpm +38 -0
  103. data/samples/bigdemo/icons/tog2.bmp +0 -0
  104. data/samples/bigdemo/icons/tog2.xpm +38 -0
  105. data/samples/bigdemo/icons/wxwin.ico +0 -0
  106. data/samples/bigdemo/icons/wxwin16x16.png +0 -0
  107. data/samples/bigdemo/icons/wxwin16x16.xpm +25 -0
  108. data/samples/bigdemo/icons/wxwin32x32.png +0 -0
  109. data/samples/bigdemo/icons/wxwin48x48.png +0 -0
  110. data/samples/bigdemo/run.rb +94 -0
  111. data/samples/bigdemo/tips.txt +7 -0
  112. data/samples/bigdemo/utils.rb +12 -0
  113. data/samples/bigdemo/wxArtProvider.rbw +285 -0
  114. data/samples/bigdemo/wxBitmapButton.rbw +64 -0
  115. data/samples/bigdemo/wxButton.rbw +66 -0
  116. data/samples/bigdemo/wxCalendarCtrl.rbw +72 -0
  117. data/samples/bigdemo/wxCheckBox.rbw +52 -0
  118. data/samples/bigdemo/wxCheckListBox.rbw +77 -0
  119. data/samples/bigdemo/wxChoice.rbw +49 -0
  120. data/samples/bigdemo/wxChoicebook.rbw +80 -0
  121. data/samples/bigdemo/wxColourDialog.rbw +34 -0
  122. data/samples/bigdemo/wxComboBox.rbw +79 -0
  123. data/samples/bigdemo/wxCursor.rbw +140 -0
  124. data/samples/bigdemo/wxDialog.rbw +92 -0
  125. data/samples/bigdemo/wxDirDialog.rbw +32 -0
  126. data/samples/bigdemo/wxDragImage.rbw +74 -0
  127. data/samples/bigdemo/wxFileDialog.rbw +39 -0
  128. data/samples/bigdemo/wxFileDialog_Save.rbw +38 -0
  129. data/samples/bigdemo/wxFindReplaceDialog.rbw +85 -0
  130. data/samples/bigdemo/wxFontDialog.rbw +176 -0
  131. data/samples/bigdemo/wxFrame.rbw +55 -0
  132. data/samples/bigdemo/wxGauge.rbw +73 -0
  133. data/samples/bigdemo/wxGenericDirCtrl.rbw +78 -0
  134. data/samples/bigdemo/wxGrid.rbw +68 -0
  135. data/samples/bigdemo/wxHtmlHelpController.rbw +57 -0
  136. data/samples/bigdemo/wxListBox.rbw +142 -0
  137. data/samples/bigdemo/wxListCtrl_virtual.rbw +109 -0
  138. data/samples/bigdemo/wxMDIWindows.rbw +52 -0
  139. data/samples/bigdemo/wxMenu.rbw +238 -0
  140. data/samples/bigdemo/wxMessageDialog.rbw +30 -0
  141. data/samples/bigdemo/wxMiniFrame.rbw +74 -0
  142. data/samples/bigdemo/wxMultipleChoiceDialog.rbw +34 -0
  143. data/samples/bigdemo/wxNotebook.rbw +138 -0
  144. data/samples/bigdemo/wxProgressDialog.rbw +45 -0
  145. data/samples/bigdemo/wxRadioBox.rbw +74 -0
  146. data/samples/bigdemo/wxRadioButton.rbw +127 -0
  147. data/samples/bigdemo/wxSashWindow.rbw +145 -0
  148. data/samples/bigdemo/wxScrolledMessageDialog.rbw +59 -0
  149. data/samples/bigdemo/wxScrolledWindow.rbw +201 -0
  150. data/samples/bigdemo/wxSingleChoiceDialog.rbw +35 -0
  151. data/samples/bigdemo/wxSlider.rbw +44 -0
  152. data/samples/bigdemo/wxSpinButton.rbw +52 -0
  153. data/samples/bigdemo/wxSpinCtrl.rbw +53 -0
  154. data/samples/bigdemo/wxSplitterWindow.rbw +65 -0
  155. data/samples/bigdemo/wxStaticBitmap.rbw +53 -0
  156. data/samples/bigdemo/wxStaticText.rbw +57 -0
  157. data/samples/bigdemo/wxStatusBar.rbw +128 -0
  158. data/samples/bigdemo/wxTextCtrl.rbw +151 -0
  159. data/samples/bigdemo/wxTextEntryDialog.rbw +34 -0
  160. data/samples/bigdemo/wxToggleButton.rbw +51 -0
  161. data/samples/bigdemo/wxToolBar.rbw +133 -0
  162. data/samples/bigdemo/wxTreeCtrl.rbw +192 -0
  163. data/samples/calendar/calendar.rb +275 -0
  164. data/samples/caret/caret.rb +286 -0
  165. data/samples/caret/mondrian.xpm +44 -0
  166. data/samples/controls/controls.rb +1140 -0
  167. data/samples/controls/get_item_sample.rb +87 -0
  168. data/samples/controls/icons/choice.xpm +27 -0
  169. data/samples/controls/icons/combo.xpm +27 -0
  170. data/samples/controls/icons/gauge.xpm +27 -0
  171. data/samples/controls/icons/list.xpm +27 -0
  172. data/samples/controls/icons/radio.xpm +27 -0
  173. data/samples/controls/icons/stattext.xpm +24 -0
  174. data/samples/controls/icons/text.xpm +27 -0
  175. data/samples/controls/mondrian.ico +0 -0
  176. data/samples/controls/mondrian.xpm +44 -0
  177. data/samples/controls/test2.bmp +0 -0
  178. data/samples/dialogs/dialogs.rb +724 -0
  179. data/samples/dialogs/tips.txt +18 -0
  180. data/samples/drawing/graphics_drawing.rb +232 -0
  181. data/samples/drawing/images.rb +48 -0
  182. data/samples/drawing/paperclip.png +0 -0
  183. data/samples/etc/activation.rb +108 -0
  184. data/samples/etc/choice.rb +72 -0
  185. data/samples/etc/miniframe.rb +84 -0
  186. data/samples/etc/sash.rb +135 -0
  187. data/samples/etc/scrollwin.rb +116 -0
  188. data/samples/etc/system_settings.rb +258 -0
  189. data/samples/etc/threaded.rb +81 -0
  190. data/samples/etc/wizard.rb +79 -0
  191. data/samples/event/event.rb +184 -0
  192. data/samples/grid/grid.rb +202 -0
  193. data/samples/html/html.rb +264 -0
  194. data/samples/listbook/listbook.rb +181 -0
  195. data/samples/listbook/listbook.xrc +370 -0
  196. data/samples/mdi/mdi.rb +87 -0
  197. data/samples/media/mediactrl.rb +173 -0
  198. data/samples/minimal/minimal.rb +85 -0
  199. data/samples/minimal/mondrian.ico +0 -0
  200. data/samples/minimal/mondrian.png +0 -0
  201. data/samples/minimal/nothing.rb +21 -0
  202. data/samples/opengl/cube.rb +123 -0
  203. data/samples/printing/mondrian.ico +0 -0
  204. data/samples/printing/mondrian.xpm +44 -0
  205. data/samples/printing/printing.rb +484 -0
  206. data/samples/sockets/SocketPackets.rb +27 -0
  207. data/samples/sockets/res/message-new.png +0 -0
  208. data/samples/sockets/res/user.png +0 -0
  209. data/samples/sockets/wxClient.rb +395 -0
  210. data/samples/sockets/wxServer.rb +422 -0
  211. data/samples/sockets/wxSocketGUI.rb +97 -0
  212. data/samples/text/mondrian.ico +0 -0
  213. data/samples/text/mondrian.xpm +44 -0
  214. data/samples/text/scintilla.rb +174 -0
  215. data/samples/text/textctrl.rb +124 -0
  216. data/samples/text/unicode.rb +238 -0
  217. data/samples/text/utf8.txt +15 -0
  218. data/samples/treectrl/icon1.xpm +79 -0
  219. data/samples/treectrl/icon2.xpm +53 -0
  220. data/samples/treectrl/icon3.xpm +79 -0
  221. data/samples/treectrl/icon4.xpm +43 -0
  222. data/samples/treectrl/icon5.xpm +79 -0
  223. data/samples/treectrl/treectrl.rb +1180 -0
  224. data/samples/xrc/samples.xrc +46 -0
  225. data/samples/xrc/xrc_sample.rb +107 -0
  226. metadata +296 -0
@@ -0,0 +1,109 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ begin
4
+ require 'wx'
5
+ rescue LoadError => no_wx_err
6
+ begin
7
+ require 'rubygems'
8
+ require 'wx'
9
+ rescue LoadError
10
+ raise no_wx_err
11
+ end
12
+ end
13
+
14
+ class TestVirtualList < Wx::ListCtrl
15
+ def initialize(parent, log)
16
+ super(parent, -1, Wx::DEFAULT_POSITION, Wx::DEFAULT_SIZE, Wx::LC_REPORT | Wx::LC_VIRTUAL | Wx::LC_HRULES | Wx::LC_VRULES)
17
+ @log = log
18
+
19
+ @il = Wx::ImageList.new(16,16)
20
+ bmp_file = File.join(File.dirname(__FILE__), "icons/wxwin16x16.xpm")
21
+
22
+ @idx1 = @il.add(Wx::Bitmap.new(bmp_file))
23
+ set_image_list(@il, Wx::IMAGE_LIST_SMALL)
24
+
25
+ insert_column(0,"First")
26
+ insert_column(1,"Second")
27
+ insert_column(2,"Third")
28
+ set_column_width(0,175)
29
+ set_column_width(1,175)
30
+ set_column_width(2,175)
31
+
32
+ set_item_count(1000000)
33
+
34
+ @attr1 = Wx::ListItemAttr.new()
35
+ @attr1.set_background_colour(Wx::Colour.new("YELLOW"))
36
+
37
+ @attr2 = Wx::ListItemAttr.new()
38
+ @attr2.set_background_colour(Wx::Colour.new("LIGHT BLUE"))
39
+
40
+ evt_list_item_selected(get_id()) {|event| on_item_selected(event)}
41
+ evt_list_item_activated(get_id()) {|event| on_item_activated(event)}
42
+ evt_list_item_deselected(get_id()) {|event| on_item_deselected(event)}
43
+ end
44
+
45
+ def on_item_selected(event)
46
+ @currentItem = event.get_index()
47
+ @item = event.get_item()
48
+ get_column(1,@item)
49
+
50
+ @log.write_text('on_item_selected: "%s", "%s", "%s", "%s"' % [@currentItem, get_item_text(@currentItem),
51
+ @item.get_text(), get_column(2,@item) ? @item.get_text() : nil])
52
+ end
53
+
54
+ def on_item_activated(event)
55
+ @currentItem = event.get_index()
56
+ @log.write_text("on_item_activated: %s\nTopItem: %s" % [get_item_text(@currentItem), get_top_item()])
57
+ end
58
+
59
+ def on_item_deselected(event)
60
+ @log.write_text("on_item_deselected: %s" % event.get_index())
61
+ end
62
+
63
+ # These three following methods are callbacks for implementing the
64
+ # "virtualness" of the list; they *must* be defined by any ListCtrl
65
+ # object with the style LC_VIRTUAL.
66
+
67
+ # Normally you would determine the text, attributes and/or image
68
+ # based on values from some external data source, but for this demo
69
+ # we'll just calculate them based on order.
70
+ def on_get_item_text(item, col)
71
+ return "Item %d, column %d" % [item,col]
72
+ end
73
+
74
+ def on_get_item_column_image(item, col)
75
+ if item % 4 == 0
76
+ return @idx1
77
+ else
78
+ return -1
79
+ end
80
+ end
81
+
82
+ def on_get_item_attr(item)
83
+ if item % 3 == 1
84
+ return @attr1
85
+ elsif item % 3 == 2
86
+ return @attr2
87
+ else
88
+ return nil
89
+ end
90
+ end
91
+ end
92
+
93
+ module Demo
94
+ def Demo.run(frame, nb, log)
95
+ win = TestVirtualList.new(nb,log)
96
+ return win
97
+ end
98
+
99
+ def Demo.overview
100
+ return "A special case of report view quite different from the other modes of the list control is a virtual control in which the items data (including text, images and attributes) is managed by the main program and is requested by the control itself only when needed which allows to have controls with millions of items without consuming much memory. To use virtual list control you must use SetItemCount first and overload at least OnGetItemText (and optionally OnGetItemImage and OnGetItemAttr) to return the information about the items when the control requests it."
101
+ end
102
+ end
103
+
104
+
105
+ if __FILE__ == $0
106
+ run_solo_lib = File.join( File.dirname(__FILE__), 'run.rb')
107
+ load run_solo_lib
108
+ run File.basename($0)
109
+ end
@@ -0,0 +1,52 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ begin
4
+ require 'wx'
5
+ rescue LoadError => no_wx_err
6
+ begin
7
+ require 'rubygems'
8
+ require 'wx'
9
+ rescue LoadError
10
+ raise no_wx_err
11
+ end
12
+ end
13
+
14
+ class TestPanel < Wx::Panel
15
+ def initialize(parent, log)
16
+ @log = log
17
+ super(parent, -1)
18
+
19
+ b1 = Wx::Button.new(self, -1, "MDI demo")
20
+ evt_button(b1.get_id()) {|event| show_mdi_demo(event)}
21
+
22
+ box = Wx::BoxSizer.new(Wx::VERTICAL)
23
+ box.add(20,30)
24
+ box.add(b1, 0, Wx::ALIGN_CENTER | Wx::ALL, 15)
25
+ set_sizer(box)
26
+ end
27
+
28
+ def show_mdi_demo(event)
29
+ mdi_demo_file = File.join( File.dirname(__FILE__), "MDIDemo.rbw")
30
+ load mdi_demo_file
31
+ frame = Demo::MyParentFrame.new()
32
+ frame.show()
33
+ end
34
+ end
35
+
36
+ module Demo
37
+ def Demo.run(frame,nb,log)
38
+ win = TestPanel.new(nb, log)
39
+ return win
40
+ end
41
+
42
+ def Demo.overview
43
+ "An MDI (Multiple Document Interface) parent frame is a window which can contain MDI child frames in its own 'desktop'. It is a convenient way to avoid window clutter, and is used in many popular Windows applications, such as Microsoft Word(TM)."
44
+ end
45
+ end
46
+
47
+
48
+ if __FILE__ == $0
49
+ run_solo_lib = File.join( File.dirname(__FILE__), 'run.rb')
50
+ load run_solo_lib
51
+ run File.basename($0)
52
+ end
@@ -0,0 +1,238 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ begin
4
+ require 'wx'
5
+ rescue LoadError => no_wx_err
6
+ begin
7
+ require 'rubygems'
8
+ require 'wx'
9
+ rescue LoadError
10
+ raise no_wx_err
11
+ end
12
+ end
13
+
14
+ class MyFrame < Wx::Frame
15
+ def initialize(parent, id, log)
16
+ super(parent, id, "Playing with menus", Wx::DEFAULT_POSITION, Wx::Size.new(400,200))
17
+ @log = log
18
+ center_on_screen(Wx::BOTH)
19
+
20
+ create_status_bar()
21
+ set_status_text("This is the statusbar")
22
+
23
+ text = "A bunch of bogus menus have been created for this frame. You can play around with them to see how they behave and then check the source for this sample to see how to implement them."
24
+ tc = Wx::TextCtrl.new(self, -1, text, Wx::DEFAULT_POSITION,
25
+ Wx::DEFAULT_SIZE, Wx::TE_READONLY | Wx::TE_MULTILINE)
26
+
27
+ # Prepare the menu bar
28
+ menuBar = Wx::MenuBar.new()
29
+
30
+ # 1st menu from the left
31
+ menu1 = Wx::Menu.new()
32
+ menu1.append(101, "&Mercury", "This the text in the Statusbar")
33
+ menu1.append(102, "&Venus", "")
34
+ menu1.append(103, "&Earth", "You may select Earth too")
35
+ menu1.append_separator()
36
+ menu1.append(104, "&Close", "Close this frame")
37
+ # Add menu to the menu bar
38
+ menuBar.append(menu1, "&Planets")
39
+
40
+ # 2nd menu from left
41
+ menu2 = Wx::Menu.new()
42
+ menu2.append(201, "Hydrogen")
43
+ menu2.append(202, "Helium")
44
+ # a submenu in the 2nd menu
45
+ submenu = Wx::Menu.new()
46
+ submenu.append(2031,"Lanthanium")
47
+ submenu.append(2032,"Cerium")
48
+ submenu.append(2033,"Praseodymium")
49
+ item = Wx::MenuItem.new(menu2, 203, "Lanthanides", "", Wx::ITEM_NORMAL, submenu)
50
+ menu2.append_item(item)
51
+ # append 2nd menu
52
+ menuBar.append(menu2, "&Elements")
53
+
54
+ menu3 = Wx::Menu.new()
55
+ menu3.append_item(Wx::MenuItem.new(menu3, 301, "IRB", "a Python shell using tcl/tk as GUI", Wx::ITEM_RADIO))
56
+ menu3.append_item(Wx::MenuItem.new(menu3, 302, "PyCrust", "a Python shell using wxPython as GUI", Wx::ITEM_RADIO))
57
+ menu3.append_item(Wx::MenuItem.new(menu3, 303, "psi", "a simple Python shell using wxPython as GUI", Wx::ITEM_RADIO))
58
+ menu3.append_separator()
59
+ menu3.append_item(Wx::MenuItem.new(menu3, 304, "project1", "", Wx::ITEM_NORMAL))
60
+ menu3.append_item(Wx::MenuItem.new(menu3, 305, "project2", "", Wx::ITEM_NORMAL))
61
+ menuBar.append(menu3, "&Shells")
62
+
63
+ menu4 = Wx::Menu.new()
64
+ menu4.append_item(Wx::MenuItem.new(menu4, 401, "letters", "abcde...", Wx::ITEM_CHECK))
65
+ menu4.append_item(Wx::MenuItem.new(menu4, 402, "digits", "123...", Wx::ITEM_CHECK))
66
+ menu4.append_item(Wx::MenuItem.new(menu4, 403, "letters and digits", "abcd... + 123...", Wx::ITEM_CHECK))
67
+ menuBar.append(menu4, "Chec&k")
68
+
69
+ menu5 = Wx::Menu.new()
70
+ # Show how to put an icon in the menu
71
+ item = Wx::MenuItem.new(menu5, 500, "&Smile!\tCtrl+S",
72
+ "This one has an icon")
73
+
74
+ # set_bitmap is only available on Windows and GTK
75
+ if item.respond_to?(:set_bitmap)
76
+ bmp_file = File.join( File.dirname(__FILE__),
77
+ 'icons', 'wxwin16x16.xpm')
78
+ item.set_bitmap( Wx::Bitmap.new(bmp_file) )
79
+ end
80
+ menu5.append_item(item)
81
+
82
+ menu5.append(501, "Interesting thing\tCtrl+A", "Note the shortcut!")
83
+ menu5.append_separator()
84
+ menu5.append(502, "Hello\tShift+H")
85
+ menu5.append_separator()
86
+ menu5.append(503, "remove the submenu")
87
+ menu6 = Wx::Menu.new()
88
+ menu6.append(601, "Submenu Item")
89
+ item = Wx::MenuItem.new(menu5, 504, "submenu", "", Wx::ITEM_NORMAL, menu6)
90
+ menu5.append_item(item)
91
+ menu5.append(505, "remove this menu")
92
+ menu5.append(506, "this is updated")
93
+ menu5.append(507, "insert after this...")
94
+ menu5.append(508, "...and before this")
95
+ menuBar.append(menu5, "&Fun")
96
+
97
+ set_menu_bar(menuBar)
98
+
99
+ # Menu events
100
+ evt_menu_highlight_all {|event| on_menu_highlight(event)}
101
+
102
+ evt_menu(101) {|event| menu_101(event)}
103
+ evt_menu(102) {|event| menu_102(event)}
104
+ evt_menu(103) {|event| menu_103(event)}
105
+ evt_menu(104) {|event| close_window(event)}
106
+
107
+ evt_menu(201) {|event| menu_201(event)}
108
+ evt_menu(202) {|event| menu_202(event)}
109
+ evt_menu(2031) {|event| menu_2031(event)}
110
+ evt_menu(2032) {|event| menu_2032(event)}
111
+ evt_menu(2033) {|event| menu_2033(event)}
112
+
113
+ evt_menu(301) {|event| menu_301_to_303(event)}
114
+ evt_menu(302) {|event| menu_301_to_303(event)}
115
+ evt_menu(303) {|event| menu_301_to_303(event)}
116
+ evt_menu(304) {|event| menu_304(event)}
117
+ evt_menu(305) {|event| menu_305(event)}
118
+
119
+ evt_menu_range(401,403) {|event| menu_401_to_403(event)}
120
+
121
+ evt_menu(500) {|event| menu_500(event)}
122
+ evt_menu(501) {|event| menu_501(event)}
123
+ evt_menu(502) {|event| menu_502(event)}
124
+ evt_menu(503) {|event| test_remove(event)}
125
+ evt_menu(505) {|event| test_remove2(event)}
126
+ evt_menu(507) {|event| test_insert(event)}
127
+ evt_menu(508) {|event| test_insert(event)}
128
+
129
+ evt_update_ui(506) {|event| test_update_ui(event)}
130
+ end
131
+
132
+ # Methods
133
+
134
+ def on_menu_highlight(event)
135
+ event.skip()
136
+ end
137
+
138
+ def menu_101(event)
139
+ @log.write_text("Welcome to Mercury")
140
+ end
141
+
142
+ def menu_102(event)
143
+ @log.write_text("Welcome to Venus")
144
+ end
145
+
146
+ def menu_103(event)
147
+ @log.write_text("Welcome to Earth")
148
+ end
149
+
150
+ def close_window(event)
151
+ event.skip()
152
+ end
153
+
154
+ def menu_201(event)
155
+ @log.write_text("Chemical element number 1")
156
+ end
157
+
158
+ def menu_202(event)
159
+ @log.write_text("Chemical element number 2")
160
+ end
161
+
162
+ def menu_2031(event)
163
+ @log.write_text("Element number 57")
164
+ end
165
+
166
+ def menu_2032(event)
167
+ @log.write_text("Element number 58")
168
+ end
169
+
170
+ def menu_2033(event)
171
+ @log.write_text("Element number 59")
172
+ end
173
+
174
+ def menu_301_to_303(event)
175
+ id = event.get_id()
176
+ @log.write_text("Event id: %d" % id)
177
+ end
178
+
179
+ def menu_304(event)
180
+ @log.write_text("Not yet available")
181
+ end
182
+
183
+ def menu_305(event)
184
+ @log.write_text("Still vapor")
185
+ end
186
+
187
+ def menu_401_to_403(event)
188
+ @log.write_text("From an evt_menu_range event")
189
+ end
190
+
191
+ def menu_500(event)
192
+ @log.write_text("Have a happy day!")
193
+ end
194
+
195
+ def menu_501(event)
196
+ @log.write_text("Look in the code to see how the shortcut has been realized")
197
+ end
198
+
199
+ def menu_502(event)
200
+ @log.write_text("Hello from Robert Carlin!")
201
+ end
202
+
203
+ # These methods haven't been implemented yet....Waiting for Wx::MenuBar.get_menu_bar() to be implemented
204
+ def test_remove(event)
205
+
206
+ end
207
+
208
+ def test_remove2(event)
209
+
210
+ end
211
+
212
+ def test_insert(event)
213
+
214
+ end
215
+
216
+ def test_update_ui(event)
217
+ event.skip()
218
+ end
219
+ end
220
+
221
+ module Demo
222
+ def Demo.run(frame, nb, log)
223
+ win = MyFrame.new(frame, -1, log)
224
+ frame.otherWin = win
225
+ win.show()
226
+ end
227
+
228
+ def Demo.overview
229
+ return "A demo of using Wx::MenuBar and Wx::Menu in various ways."
230
+ end
231
+ end
232
+
233
+
234
+ if __FILE__ == $0
235
+ run_solo_lib = File.join( File.dirname(__FILE__), 'run.rb')
236
+ load run_solo_lib
237
+ run File.basename($0)
238
+ end
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ begin
4
+ require 'wx'
5
+ rescue LoadError => no_wx_err
6
+ begin
7
+ require 'rubygems'
8
+ require 'wx'
9
+ rescue LoadError
10
+ raise no_wx_err
11
+ end
12
+ end
13
+
14
+ module Demo
15
+ def Demo.run(frame, nb, log)
16
+ dlg = Wx::MessageDialog.new(frame, "Hello from Ruby and wxRuby!", "A Message Box", Wx::OK | Wx::ICON_INFORMATION)
17
+ dlg.show_modal()
18
+ dlg.destroy()
19
+ end
20
+
21
+ def Demo.overview
22
+ return "Show a message to the user in a dialog"
23
+ end
24
+ end
25
+
26
+ if __FILE__ == $0
27
+ run_solo_lib = File.join( File.dirname(__FILE__), 'run.rb')
28
+ load run_solo_lib
29
+ run File.basename($0)
30
+ end
@@ -0,0 +1,74 @@
1
+ #!/usr/bin/env ruby
2
+ # wxRuby2 Sample Code. Copyright (c) 2004-2006 Kevin B. Smith
3
+ # Freely reusable code: see SAMPLES-LICENSE.TXT for details
4
+
5
+ begin
6
+ require 'wx'
7
+ rescue LoadError => no_wx_err
8
+ begin
9
+ require 'rubygems'
10
+ require 'wx'
11
+ rescue LoadError
12
+ raise no_wx_err
13
+ end
14
+ end
15
+ include Wx
16
+
17
+ class MyMiniFrame < MiniFrame
18
+ def initialize(parent, log)
19
+ @log = log
20
+ super(parent, -1, "Wx::MiniFrame demonstration",
21
+ DEFAULT_POSITION, Size.new(350,200), DEFAULT_FRAME_STYLE)
22
+ panel = Panel.new(self, -1)
23
+
24
+ button = Button.new(panel, -1, "Close me", Point.new(15,15))
25
+ evt_button( button.get_id ) { on_close_me }
26
+ # evt_close { | e | on_close_window(e) }
27
+ end
28
+
29
+ def on_close_me
30
+ close(true)
31
+ end
32
+
33
+ def on_close_window(event)
34
+ @log.write_text("MiniFrame closed.")
35
+ event.skip
36
+ end
37
+
38
+ end
39
+
40
+ class TestPanel < Wx::Panel
41
+ def initialize(parent, log)
42
+ super(parent, -1, Wx::DEFAULT_POSITION, Wx::DEFAULT_SIZE, Wx::NO_FULL_REPAINT_ON_RESIZE)
43
+ @log = log
44
+
45
+ b = Button.new(self, -1, 'Create and Show a MiniFrame', Wx::Point.new(50,50))
46
+ evt_button(b.get_id) { on_button }
47
+ end
48
+
49
+ def on_button
50
+ win = MyMiniFrame.new(self, @log)
51
+ win.set_size(Wx::Size.new(200, 200))
52
+ win.center_on_parent(Wx::BOTH)
53
+ win.show(true)
54
+ end
55
+ end
56
+
57
+ module Demo
58
+ def Demo.run(frame, nb, log)
59
+ TestPanel.new(nb, log)
60
+ end
61
+
62
+ def Demo.overview
63
+ return "A MiniFrame is a Frame with a small title bar. It is suitable for floating\n" +
64
+ "toolbars that must not take up too much screen area. In other respects, it's the\n" +
65
+ "same as a Wx::Frame."
66
+ end
67
+ end
68
+
69
+
70
+ if __FILE__ == $0
71
+ run_solo_lib = File.join( File.dirname(__FILE__), 'run.rb')
72
+ load run_solo_lib
73
+ run File.basename($0)
74
+ end