wxruby64 2.0.1-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.
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,38 @@
1
+ # Pure-ruby implementation of the corresponding Wx class. Simply shows
2
+ # the Window's help text in a tooltip.
3
+ class Wx::SimpleHelpProvider < Wx::HelpProvider
4
+ def initialize
5
+ super
6
+ # Store for mapping windows -> help strings
7
+ @help_wins = {}
8
+ # Store for mapping ids -> help strings
9
+ @help_ids = {}
10
+ end
11
+
12
+ # This is what is called by Wx::Window#set_help_text
13
+ def add_help(identifier, text)
14
+ if identifier.kind_of? Wx::Window
15
+ @help_wins[identifier.object_id] = text
16
+ else
17
+ @help_ids[identifier] = text
18
+ end
19
+ end
20
+
21
+ # Retrieve help text for the given window +win+
22
+ def get_help(win)
23
+ @help_wins[win.object_id] || @help_ids[win.wx_id] || ""
24
+ end
25
+
26
+ # Remove the help text for +win+
27
+ def remove_help(win)
28
+ @help_wins.delete(win.object_id)
29
+ end
30
+
31
+ # Show help for +win+
32
+ def show_help(win)
33
+ help_text = get_help(win)
34
+ return false if help_text.empty?
35
+ tip = Wx::TipWindow.new(win, help_text, 100)
36
+ true
37
+ end
38
+ end
@@ -0,0 +1,58 @@
1
+ class Wx::Size
2
+ # More informative output for inspect etc
3
+ def to_s
4
+ "#<Wx::Size: (#{get_width}, #{get_height})>"
5
+ end
6
+
7
+ # Compare with another size
8
+ def ==(other)
9
+ unless other.kind_of?(Wx::Size)
10
+ Kernel.raise TypeError, "Cannot compare Size to #{other}"
11
+ end
12
+ get_x == other.get_x and get_y == other.get_y
13
+ end
14
+
15
+ # Return a new Wx::Size with the width and height values both divided
16
+ # by parameter +div+, which should be a Numeric
17
+ def /(div)
18
+ self.class.new( (get_x / div).to_i, (get_y / div).to_i )
19
+ end
20
+
21
+ # Return a new Wx::Size with the width and height values both
22
+ # multiplied by parameter +mul+, which should be a Numeric
23
+ def *(mul)
24
+ self.class.new( (get_x * mul).to_i, (get_y * mul).to_i )
25
+ end
26
+
27
+ # Return a new Wx::Size with the width and height parameters both
28
+ # reduced by parameter +arg+. If +arg+ is another Wx::Size, reduce
29
+ # width by the other's width and height by the other's height; if
30
+ # +arg+ is a numeric value, reduce both width and height by that
31
+ # value.
32
+ def -(arg)
33
+ case arg
34
+ when self.class
35
+ self.class.new( get_x - arg.get_x, get_y - arg.get_y )
36
+ when Numeric
37
+ self.class.new( (get_x - arg).to_i, (get_y - arg).to_i )
38
+ else
39
+ Kernel.raise TypeError, "Cannot add #{arg} to #{self.inspect}"
40
+ end
41
+ end
42
+
43
+ # Return a new Wx::Size with the width and height parameters both
44
+ # increased by parameter +arg+. If +arg+ is another Wx::Size, increase
45
+ # width by the other's width and height by the other's height; if
46
+ # +arg+ is a numeric value, increase both width and height by that
47
+ # value.
48
+ def +(arg)
49
+ case arg
50
+ when self.class
51
+ self.class.new( get_x + arg.get_x, get_y + arg.get_y )
52
+ when Numeric
53
+ self.class.new( (get_x + arg).to_i, (get_y + arg).to_i )
54
+ else
55
+ Kernel.raise TypeError, "Cannot add #{arg} to #{self.inspect}"
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,43 @@
1
+ # Class for automatically managing layouts
2
+ class Wx::Sizer
3
+ # Generic method to add items, supporting positional and named
4
+ # arguments
5
+ ADD_ITEM_PARAMS = [ Wx::Parameter[ :index, -1 ],
6
+ Wx::Parameter[ :proportion, 0 ],
7
+ Wx::Parameter[ :flag, 0 ],
8
+ Wx::Parameter[ :border, 0 ],
9
+ Wx::Parameter[ :user_data, nil ] ]
10
+
11
+ def add_item(item, *mixed_args)
12
+
13
+ begin
14
+ args = Wx::args_as_list(ADD_ITEM_PARAMS, *mixed_args)
15
+ rescue => err
16
+ err.set_backtrace(caller)
17
+ Kernel.raise err
18
+ end
19
+
20
+ full_args = []
21
+
22
+ # extract the width and the height in the case of a spacer
23
+ # defined as an array
24
+ if item.kind_of?(Array)
25
+ Kernel.raise ArgumentError,
26
+ "Invalid Sizer specification : [width, height] expected" if item.size != 2
27
+ full_args << item[0] << item[1]
28
+ else
29
+ full_args << item
30
+ end
31
+
32
+ # update the full arguments list with the optional arguments (except index)
33
+ idx = args.shift
34
+ full_args.concat(args)
35
+
36
+ # Call add to append if default position
37
+ if idx == -1
38
+ add(*full_args)
39
+ else
40
+ insert(idx, *full_args)
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,23 @@
1
+ # Plays simple sounds from .wav files
2
+ class Wx::Sound
3
+ class << self
4
+ # Shortcut class method, as per the wxWidgets docs, but easier to do
5
+ # in Ruby
6
+ def play(file, flags = Wx::SOUND_ASYNC)
7
+ new(file).play(flags)
8
+ end
9
+ end
10
+
11
+ # Test if newly created Sound is valid; if not, raise an exception
12
+ # rather than failing silently.
13
+ wx_init = self.instance_method(:initialize)
14
+ define_method(:initialize) do | *args |
15
+ if not File.exist?( File.expand_path(args[0]) )
16
+ Kernel.raise(ArgumentError, "Sound file does not exist: #{args[0]}")
17
+ end
18
+ wx_init.bind(self).call(*args)
19
+ if not ok?
20
+ Kernel.raise(ArgumentError, "Error loading sound file #{args[0]}")
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,10 @@
1
+ # Class with movable sash to separate two windows
2
+ class Wx::SplitterWindow
3
+ # These were released in wxRuby 2.0 with names slightly out of kilter
4
+ # with the documentation. The correct ones have an underscore before
5
+ # the digit.
6
+ #
7
+ # FIXME - the old names :get_window1 should be deleted in future versions.
8
+ alias :get_window_1 :get_window1
9
+ alias :get_window_2 :get_window2
10
+ end
@@ -0,0 +1,9 @@
1
+ # Access OS-standard locations for user files, config files etc
2
+ class Wx::StandardPaths
3
+ class << self
4
+ # Expose instance methods as class methods in Ruby
5
+ Wx::StandardPaths.instance_methods(false).each do | meth |
6
+ define_method(meth) { get.send(meth) }
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,92 @@
1
+ # Functionality here must be loaded first to add custom events
2
+ require 'wx/classes/evthandler'
3
+
4
+ # These event type constants will only be available and meaningful if
5
+ # Wx::StyledTextCtrl has been compiled into the library. If so, they
6
+ # need the below definitions for mapping, otherwise all the rest should
7
+ # be skipped
8
+ if defined?(Wx::StyledTextCtrl)
9
+ EventType = Wx::EvtHandler::EventType
10
+
11
+ stc_event_types = [
12
+ EventType['evt_stc_calltip_click', 1,
13
+ Wx::EVT_STC_CALLTIP_CLICK,
14
+ Wx::StyledTextEvent],
15
+ EventType['evt_stc_change', 1,
16
+ Wx::EVT_STC_CHANGE,
17
+ Wx::StyledTextEvent],
18
+ EventType['evt_stc_charadded', 1,
19
+ Wx::EVT_STC_CHARADDED,
20
+ Wx::StyledTextEvent],
21
+ EventType['evt_stc_doubleclick', 1,
22
+ Wx::EVT_STC_DOUBLECLICK,
23
+ Wx::StyledTextEvent],
24
+ EventType['evt_stc_do_drop', 1,
25
+ Wx::EVT_STC_DO_DROP,
26
+ Wx::StyledTextEvent],
27
+ EventType['evt_stc_drag_over', 1,
28
+ Wx::EVT_STC_DRAG_OVER,
29
+ Wx::StyledTextEvent],
30
+ EventType['evt_stc_dwellend', 1,
31
+ Wx::EVT_STC_DWELLEND,
32
+ Wx::StyledTextEvent],
33
+ EventType['evt_stc_dwellstart', 1,
34
+ Wx::EVT_STC_DWELLSTART,
35
+ Wx::StyledTextEvent],
36
+ EventType['evt_stc_hotspot_click', 1,
37
+ Wx::EVT_STC_HOTSPOT_CLICK,
38
+ Wx::StyledTextEvent],
39
+ EventType['evt_stc_hotspot_dclick', 1,
40
+ Wx::EVT_STC_HOTSPOT_DCLICK,
41
+ Wx::StyledTextEvent],
42
+ EventType['evt_stc_key', 1,
43
+ Wx::EVT_STC_KEY,
44
+ Wx::StyledTextEvent],
45
+ EventType['evt_stc_macrorecord', 1,
46
+ Wx::EVT_STC_MACRORECORD,
47
+ Wx::StyledTextEvent],
48
+ EventType['evt_stc_marginclick', 1,
49
+ Wx::EVT_STC_MARGINCLICK,
50
+ Wx::StyledTextEvent],
51
+ EventType['evt_stc_modified', 1,
52
+ Wx::EVT_STC_MODIFIED,
53
+ Wx::StyledTextEvent],
54
+ EventType['evt_stc_needshown', 1,
55
+ Wx::EVT_STC_NEEDSHOWN,
56
+ Wx::StyledTextEvent],
57
+ EventType['evt_stc_painted', 1,
58
+ Wx::EVT_STC_PAINTED,
59
+ Wx::StyledTextEvent],
60
+ EventType['evt_stc_romodifyattempt', 1,
61
+ Wx::EVT_STC_ROMODIFYATTEMPT,
62
+ Wx::StyledTextEvent],
63
+ EventType['evt_stc_savepointleft', 1,
64
+ Wx::EVT_STC_SAVEPOINTLEFT,
65
+ Wx::StyledTextEvent],
66
+ EventType['evt_stc_savepointreached', 1,
67
+ Wx::EVT_STC_SAVEPOINTREACHED,
68
+ Wx::StyledTextEvent],
69
+ EventType['evt_stc_start_drag', 1,
70
+ Wx::EVT_STC_START_DRAG,
71
+ Wx::StyledTextEvent],
72
+ EventType['evt_stc_styleneeded', 1,
73
+ Wx::EVT_STC_STYLENEEDED,
74
+ Wx::StyledTextEvent],
75
+ EventType['evt_stc_updateui', 1,
76
+ Wx::EVT_STC_UPDATEUI,
77
+ Wx::StyledTextEvent],
78
+ EventType['evt_stc_uridropped', 1,
79
+ Wx::EVT_STC_URIDROPPED,
80
+ Wx::StyledTextEvent],
81
+ EventType['evt_stc_userlistselection', 1,
82
+ Wx::EVT_STC_USERLISTSELECTION,
83
+ Wx::StyledTextEvent],
84
+ EventType['evt_stc_zoom', 1,
85
+ Wx::EVT_STC_ZOOM,
86
+ Wx::StyledTextEvent]
87
+ ]
88
+
89
+ stc_event_types.each do | ev_type |
90
+ Wx::EvtHandler.register_event_type(ev_type)
91
+ end
92
+ end
@@ -0,0 +1,14 @@
1
+ class Wx::TextCtrl
2
+ # Fix position_to_xy so it returns a two-element array - the internal
3
+ # version returns a three-element array with a Boolean that doesn't
4
+ # really make sense in Ruby
5
+ wx_position_to_xy = instance_method(:position_to_xy)
6
+ define_method(:position_to_xy) do | pos |
7
+ retval, x, y = wx_position_to_xy.bind(self).call(pos)
8
+ if retval
9
+ return [x, y]
10
+ else
11
+ return nil
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,18 @@
1
+ # Event fired when a user clicks or hovers over a hyperlink in a TextCtrl
2
+ class Wx::TextUrlEvent
3
+ # Returns the string URL that is being interacted with in this event
4
+ def get_url
5
+ text_ctrl = event_object
6
+ # In the standard TextCtrl, the relevant URL is always the same as
7
+ # the text clicked on, because all it does is highlight text that
8
+ # look like a URL. In RichTextCtrl, however, the URL value can be
9
+ # applied to any text (more like HTML), and so the URL has be
10
+ # retrieved by getting the applied RichTextAttr style and inspecting
11
+ # its property.
12
+ if text_ctrl.kind_of?(Wx::RichTextCtrl)
13
+ return text_ctrl.get_style(url_start).url
14
+ else
15
+ return text_ctrl.value[url_start .. url_end]
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,96 @@
1
+ # Class allowing periodic or timed events to be fired
2
+ class Wx::Timer
3
+ # Convenience method to trigger a one-off action after +interval+
4
+ # milliseconds have passed. The action is specified by the passed
5
+ # block. The Timer is owned by the global App object, and is returned
6
+ # by the method.
7
+ def self.after(interval, &block)
8
+ timer = new(Wx::THE_APP, Wx::ID_ANY)
9
+ Wx::THE_APP.evt_timer(timer.get_id, block)
10
+ timer.start(interval, true)
11
+ timer
12
+ end
13
+
14
+ # Convenience method to trigger a repeating action every +interval+
15
+ # milliseconds. The action is specified by the passed block. The Timer
16
+ # is owned by the global App object, and is returned by the method.
17
+ def self.every(interval, &block)
18
+ timer = new(Wx::THE_APP, Wx::ID_ANY)
19
+ Wx::THE_APP.evt_timer(timer.get_id, block)
20
+ timer.start(interval)
21
+ timer
22
+ end
23
+
24
+ # In common with other classes, make the id method refer to the
25
+ # wxWidgets id, not ruby's deprecated name for object_id
26
+ alias :id :get_id
27
+ # In case a more explicit option is preferred.
28
+ alias :wx_id :get_id
29
+
30
+ # This class can be linked to an owner - an instance of a class
31
+ # derived from EvtHandler which will receive Timer events. However,
32
+ # event if a Wx::Timer is attached to a Wx::Window, it is (unlike most
33
+ # classes) NOT automatically deleted when the window is destroyed. If
34
+ # the Timer continues ticking, it will send events to the
35
+ # now-destroyed window, causing segfaults. So the little acrobatics
36
+ # below set up a hook when a Timer's owner is set, and then ensure the
37
+ # timer is stopped when the window is destroyed.
38
+
39
+ # Redefine initialize
40
+ wx_init = self.instance_method(:initialize)
41
+ define_method(:initialize) do | *args |
42
+ setup_owner_destruction_hook(args[0])
43
+ wx_init.bind(self).call(*args)
44
+ end
45
+
46
+ # Redefine set_owner
47
+ wx_set_owner = self.instance_method(:set_owner)
48
+ define_method(:set_owner) do | *args |
49
+ setup_owner_destruction_hook(args[0])
50
+ wx_set_owner.bind(self).call(*args)
51
+ end
52
+
53
+ private
54
+ # This method notes in Ruby the ownership of the timer, from both
55
+ # sides, and sets up an event hook if needed for the window's
56
+ # destruction.
57
+ def setup_owner_destruction_hook(new_owner)
58
+ this_timer = self
59
+
60
+ # Class-wide list of global (unowned) timers
61
+ @@__unowned_timers__ ||= []
62
+
63
+ # remove from list of previous owner
64
+ if defined?(@__owner__) and @__owner__
65
+ @__owner__.instance_eval { @__owned_timers__.delete(this_timer) }
66
+ end
67
+
68
+ # If becoming global unowned timer, add to list of those timers
69
+ if not new_owner
70
+ @__owner__ = nil
71
+ @@__unowned_timers__ << self
72
+ return
73
+ end
74
+
75
+ # Otherwise, if previously unowned, remove from global owned
76
+ @@__unowned_timers__.delete(self)
77
+ @__owner__ = new_owner
78
+
79
+ # Then add to list of new owner, setting destructor hook if required
80
+ new_owner.instance_eval do
81
+ if not defined?(@__owned_timers__)
82
+ @__owned_timers__ = []
83
+ unless self.kind_of?(Wx::App) # Don't set up hook on App
84
+ evt_window_destroy do | evt |
85
+ # If it's the owning window being destroyed...
86
+ if evt.get_event_object == self
87
+ @__owned_timers__.each { | timer | timer.stop }
88
+ end
89
+ evt.skip
90
+ end
91
+ end
92
+ end
93
+ @__owned_timers__ << this_timer
94
+ end
95
+ end
96
+ end
@@ -0,0 +1,36 @@
1
+ # A set of buttons and controls attached to one edge of a Wx::Frame
2
+ class Wx::ToolBar
3
+ # Generic method to add items, supporting positional and named
4
+ # arguments
5
+ ADD_ITEM_PARAMS = [
6
+ Wx::Parameter[ :bitmap2, Wx::NULL_BITMAP ],
7
+ Wx::Parameter[ :position, -1 ],
8
+ Wx::Parameter[ :id, -1 ],
9
+ Wx::Parameter[ :label, "" ],
10
+ Wx::Parameter[ :kind, Wx::ITEM_NORMAL ],
11
+ Wx::Parameter[ :short_help, "" ],
12
+ Wx::Parameter[ :long_help, "" ],
13
+ Wx::Parameter[ :client_data, nil ] ]
14
+
15
+ def add_item(bitmap1, *mixed_args)
16
+
17
+ begin
18
+ args = Wx::args_as_list(ADD_ITEM_PARAMS, *mixed_args)
19
+ rescue => err
20
+ err.set_backtrace(caller)
21
+ Kernel.raise err
22
+ end
23
+
24
+ bitmap2 = args.shift
25
+ pos = args.shift
26
+ args.insert(2, bitmap1)
27
+ args.insert(3, bitmap2)
28
+
29
+ # Call add_tool to append if default position
30
+ if pos == -1
31
+ add_tool(*args)
32
+ else
33
+ insert_tool(pos, *args)
34
+ end
35
+ end
36
+ end