wxruby 1.9.1-powerpc-darwin8.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (204) hide show
  1. data/lib/wx.rb +42 -0
  2. data/lib/wx/accessors.rb +52 -0
  3. data/lib/wx/classes/app.rb +25 -0
  4. data/lib/wx/classes/artprovider.rb +31 -0
  5. data/lib/wx/classes/bitmap.rb +23 -0
  6. data/lib/wx/classes/choice.rb +4 -0
  7. data/lib/wx/classes/clientdc.rb +13 -0
  8. data/lib/wx/classes/colour.rb +47 -0
  9. data/lib/wx/classes/combobox.rb +4 -0
  10. data/lib/wx/classes/evthandler.rb +828 -0
  11. data/lib/wx/classes/font.rb +118 -0
  12. data/lib/wx/classes/grid.rb +130 -0
  13. data/lib/wx/classes/helpcontroller.rb +5 -0
  14. data/lib/wx/classes/htmlhelpcontroller.rb +5 -0
  15. data/lib/wx/classes/htmlwindow.rb +6 -0
  16. data/lib/wx/classes/icon.rb +14 -0
  17. data/lib/wx/classes/image.rb +14 -0
  18. data/lib/wx/classes/listbox.rb +4 -0
  19. data/lib/wx/classes/locale.rb +28 -0
  20. data/lib/wx/classes/object.rb +7 -0
  21. data/lib/wx/classes/paintdc.rb +12 -0
  22. data/lib/wx/classes/point.rb +48 -0
  23. data/lib/wx/classes/previewframe.rb +13 -0
  24. data/lib/wx/classes/rect.rb +5 -0
  25. data/lib/wx/classes/size.rb +49 -0
  26. data/lib/wx/classes/styledtextctrl.rb +92 -0
  27. data/lib/wx/classes/textctrl.rb +14 -0
  28. data/lib/wx/classes/texturlevent.rb +6 -0
  29. data/lib/wx/classes/timer.rb +69 -0
  30. data/lib/wx/classes/window.rb +42 -0
  31. data/lib/wx/classes/xmlresource.rb +16 -0
  32. data/lib/wx/keyword_ctors.rb +219 -0
  33. data/lib/wx/keyword_defs.rb +455 -0
  34. data/lib/wx/version.rb +3 -0
  35. data/lib/wxruby2.bundle +0 -0
  36. data/samples/SAMPLES-LICENSE.TXT +18 -0
  37. data/samples/aui/aui.rb +1353 -0
  38. data/samples/bigdemo/About.rbw +39 -0
  39. data/samples/bigdemo/ColorPanel.rbw +25 -0
  40. data/samples/bigdemo/GridSimple.rbw +80 -0
  41. data/samples/bigdemo/MDIDemo.rbw +59 -0
  42. data/samples/bigdemo/PopupMenu.rbw +151 -0
  43. data/samples/bigdemo/ShapedWindow.rbw +135 -0
  44. data/samples/bigdemo/Sizers.rbw +545 -0
  45. data/samples/bigdemo/bigdemo.rb +826 -0
  46. data/samples/bigdemo/demoTemplate.rbw +37 -0
  47. data/samples/bigdemo/helpfile.htb +0 -0
  48. data/samples/bigdemo/icons/Test 015.jpg +0 -0
  49. data/samples/bigdemo/icons/Test 015.png +0 -0
  50. data/samples/bigdemo/icons/choice.bmp +0 -0
  51. data/samples/bigdemo/icons/choice.xpm +27 -0
  52. data/samples/bigdemo/icons/combo.bmp +0 -0
  53. data/samples/bigdemo/icons/combo.xpm +27 -0
  54. data/samples/bigdemo/icons/copy.xpm +25 -0
  55. data/samples/bigdemo/icons/cut.xpm +24 -0
  56. data/samples/bigdemo/icons/gauge.bmp +0 -0
  57. data/samples/bigdemo/icons/gauge.xpm +27 -0
  58. data/samples/bigdemo/icons/help.xpm +25 -0
  59. data/samples/bigdemo/icons/list.bmp +0 -0
  60. data/samples/bigdemo/icons/list.xpm +27 -0
  61. data/samples/bigdemo/icons/mondrian.ico +0 -0
  62. data/samples/bigdemo/icons/mondrian.xpm +44 -0
  63. data/samples/bigdemo/icons/new.xpm +24 -0
  64. data/samples/bigdemo/icons/ogl.ico +0 -0
  65. data/samples/bigdemo/icons/ogl.xpm +45 -0
  66. data/samples/bigdemo/icons/open.xpm +26 -0
  67. data/samples/bigdemo/icons/paste.bmp +0 -0
  68. data/samples/bigdemo/icons/paste.xpm +38 -0
  69. data/samples/bigdemo/icons/pointy.png +0 -0
  70. data/samples/bigdemo/icons/preview.xpm +26 -0
  71. data/samples/bigdemo/icons/print.xpm +26 -0
  72. data/samples/bigdemo/icons/radio.bmp +0 -0
  73. data/samples/bigdemo/icons/radio.xpm +27 -0
  74. data/samples/bigdemo/icons/robert.xpm +415 -0
  75. data/samples/bigdemo/icons/ruby.png +0 -0
  76. data/samples/bigdemo/icons/sashtest.ico +0 -0
  77. data/samples/bigdemo/icons/save.xpm +25 -0
  78. data/samples/bigdemo/icons/smiles.bmp +0 -0
  79. data/samples/bigdemo/icons/smiles.xpm +39 -0
  80. data/samples/bigdemo/icons/smiley.ico +0 -0
  81. data/samples/bigdemo/icons/smiley.xpm +42 -0
  82. data/samples/bigdemo/icons/stattext.xpm +24 -0
  83. data/samples/bigdemo/icons/test2.bmp +0 -0
  84. data/samples/bigdemo/icons/test2.png +0 -0
  85. data/samples/bigdemo/icons/test2.xpm +79 -0
  86. data/samples/bigdemo/icons/text.bmp +0 -0
  87. data/samples/bigdemo/icons/text.xpm +27 -0
  88. data/samples/bigdemo/icons/tog1.bmp +0 -0
  89. data/samples/bigdemo/icons/tog1.xpm +38 -0
  90. data/samples/bigdemo/icons/tog2.bmp +0 -0
  91. data/samples/bigdemo/icons/tog2.xpm +38 -0
  92. data/samples/bigdemo/icons/wxwin.ico +0 -0
  93. data/samples/bigdemo/icons/wxwin16x16.png +0 -0
  94. data/samples/bigdemo/icons/wxwin16x16.xpm +25 -0
  95. data/samples/bigdemo/icons/wxwin32x32.png +0 -0
  96. data/samples/bigdemo/icons/wxwin48x48.png +0 -0
  97. data/samples/bigdemo/run.rb +94 -0
  98. data/samples/bigdemo/tips.txt +7 -0
  99. data/samples/bigdemo/utils.rb +12 -0
  100. data/samples/bigdemo/wxArtProvider.rbw +285 -0
  101. data/samples/bigdemo/wxBitmapButton.rbw +64 -0
  102. data/samples/bigdemo/wxButton.rbw +66 -0
  103. data/samples/bigdemo/wxCalendarCtrl.rbw +72 -0
  104. data/samples/bigdemo/wxCheckBox.rbw +52 -0
  105. data/samples/bigdemo/wxCheckListBox.rbw +77 -0
  106. data/samples/bigdemo/wxChoice.rbw +49 -0
  107. data/samples/bigdemo/wxChoicebook.rbw +80 -0
  108. data/samples/bigdemo/wxColourDialog.rbw +34 -0
  109. data/samples/bigdemo/wxComboBox.rbw +79 -0
  110. data/samples/bigdemo/wxCursor.rbw +140 -0
  111. data/samples/bigdemo/wxDialog.rbw +92 -0
  112. data/samples/bigdemo/wxDirDialog.rbw +32 -0
  113. data/samples/bigdemo/wxDragImage.rbw +74 -0
  114. data/samples/bigdemo/wxFileDialog.rbw +39 -0
  115. data/samples/bigdemo/wxFileDialog_Save.rbw +38 -0
  116. data/samples/bigdemo/wxFindReplaceDialog.rbw +85 -0
  117. data/samples/bigdemo/wxFontDialog.rbw +176 -0
  118. data/samples/bigdemo/wxFrame.rbw +55 -0
  119. data/samples/bigdemo/wxGauge.rbw +73 -0
  120. data/samples/bigdemo/wxGenericDirCtrl.rbw +78 -0
  121. data/samples/bigdemo/wxGrid.rbw +68 -0
  122. data/samples/bigdemo/wxHtmlHelpController.rbw +57 -0
  123. data/samples/bigdemo/wxListBox.rbw +142 -0
  124. data/samples/bigdemo/wxListCtrl_virtual.rbw +109 -0
  125. data/samples/bigdemo/wxMDIWindows.rbw +52 -0
  126. data/samples/bigdemo/wxMenu.rbw +238 -0
  127. data/samples/bigdemo/wxMessageDialog.rbw +30 -0
  128. data/samples/bigdemo/wxMiniFrame.rbw +74 -0
  129. data/samples/bigdemo/wxMultipleChoiceDialog.rbw +34 -0
  130. data/samples/bigdemo/wxNotebook.rbw +138 -0
  131. data/samples/bigdemo/wxProgressDialog.rbw +45 -0
  132. data/samples/bigdemo/wxRadioBox.rbw +74 -0
  133. data/samples/bigdemo/wxRadioButton.rbw +127 -0
  134. data/samples/bigdemo/wxSashWindow.rbw +155 -0
  135. data/samples/bigdemo/wxScrolledMessageDialog.rbw +59 -0
  136. data/samples/bigdemo/wxScrolledWindow.rbw +196 -0
  137. data/samples/bigdemo/wxSingleChoiceDialog.rbw +35 -0
  138. data/samples/bigdemo/wxSlider.rbw +44 -0
  139. data/samples/bigdemo/wxSpinButton.rbw +52 -0
  140. data/samples/bigdemo/wxSpinCtrl.rbw +53 -0
  141. data/samples/bigdemo/wxSplitterWindow.rbw +65 -0
  142. data/samples/bigdemo/wxStaticBitmap.rbw +53 -0
  143. data/samples/bigdemo/wxStaticText.rbw +57 -0
  144. data/samples/bigdemo/wxStatusBar.rbw +128 -0
  145. data/samples/bigdemo/wxTextCtrl.rbw +151 -0
  146. data/samples/bigdemo/wxTextEntryDialog.rbw +34 -0
  147. data/samples/bigdemo/wxToggleButton.rbw +51 -0
  148. data/samples/bigdemo/wxToolBar.rbw +133 -0
  149. data/samples/bigdemo/wxTreeCtrl.rbw +192 -0
  150. data/samples/calendar/calendar.rb +275 -0
  151. data/samples/caret/caret.rb +296 -0
  152. data/samples/caret/mondrian.xpm +44 -0
  153. data/samples/controls/controls.rb +1140 -0
  154. data/samples/controls/get_item_sample.rb +87 -0
  155. data/samples/controls/icons/choice.xpm +27 -0
  156. data/samples/controls/icons/combo.xpm +27 -0
  157. data/samples/controls/icons/gauge.xpm +27 -0
  158. data/samples/controls/icons/list.xpm +27 -0
  159. data/samples/controls/icons/radio.xpm +27 -0
  160. data/samples/controls/icons/stattext.xpm +24 -0
  161. data/samples/controls/icons/text.xpm +27 -0
  162. data/samples/controls/mondrian.ico +0 -0
  163. data/samples/controls/mondrian.xpm +44 -0
  164. data/samples/controls/test2.bmp +0 -0
  165. data/samples/dialogs/dialogs.rb +724 -0
  166. data/samples/dialogs/tips.txt +18 -0
  167. data/samples/etc/activation.rb +108 -0
  168. data/samples/etc/choice.rb +72 -0
  169. data/samples/etc/miniframe.rb +84 -0
  170. data/samples/etc/sash.rb +135 -0
  171. data/samples/etc/scrollwin.rb +116 -0
  172. data/samples/etc/system_settings.rb +258 -0
  173. data/samples/etc/wizard.rb +81 -0
  174. data/samples/event/event.rb +184 -0
  175. data/samples/grid/grid.rb +201 -0
  176. data/samples/html/html.rb +251 -0
  177. data/samples/images/Thumbs.db +0 -0
  178. data/samples/images/images.rb +48 -0
  179. data/samples/images/paperclip.png +0 -0
  180. data/samples/listbook/listbook.rb +183 -0
  181. data/samples/listbook/listbook.xrc +370 -0
  182. data/samples/mdi/mdi.rb +87 -0
  183. data/samples/minimal/minimal.rb +83 -0
  184. data/samples/minimal/mondrian.png +0 -0
  185. data/samples/minimal/nothing.rb +46 -0
  186. data/samples/minimal/text.rb +35 -0
  187. data/samples/printing/mondrian.ico +0 -0
  188. data/samples/printing/mondrian.xpm +44 -0
  189. data/samples/printing/printing.rb +484 -0
  190. data/samples/text/mondrian.ico +0 -0
  191. data/samples/text/mondrian.xpm +44 -0
  192. data/samples/text/scintilla.rb +174 -0
  193. data/samples/text/textctrl.rb +124 -0
  194. data/samples/text/unicode.rb +238 -0
  195. data/samples/text/utf8.txt +15 -0
  196. data/samples/treectrl/icon1.xpm +79 -0
  197. data/samples/treectrl/icon2.xpm +53 -0
  198. data/samples/treectrl/icon3.xpm +79 -0
  199. data/samples/treectrl/icon4.xpm +43 -0
  200. data/samples/treectrl/icon5.xpm +79 -0
  201. data/samples/treectrl/treectrl.rb +1210 -0
  202. data/samples/xrc/samples.xrc +46 -0
  203. data/samples/xrc/xrc_sample.rb +107 -0
  204. metadata +263 -0
@@ -0,0 +1,42 @@
1
+ # Copyright 2004-2006 by Kevin Smith
2
+ # released under the MIT-style wxruby2 license
3
+
4
+ # This wrapper serves three functions:
5
+ # 1. It loads the binary library 'wxruby2.so' or 'wxruby.dll', while
6
+ # still allowing applications to just require 'wx'.
7
+ # 2. It sets up the version information
8
+ # 3. It loads in ruby extensions to the core Wx classes.
9
+
10
+
11
+ # load the binary library
12
+ require 'wxruby2'
13
+
14
+ # alias the module
15
+ Wx = Wxruby2
16
+
17
+ # Load the version information (should be bundled with all released versions)
18
+ begin
19
+ require 'wx/version'
20
+ rescue LoadError
21
+ Wx::WXRUBY_VERSION = '0.0.0'
22
+ end
23
+ # Convenience string for WxWidgets version info
24
+ Wx::WXWIDGETS_VERSION = '%i.%i.%i' % [ Wx::WXWIDGETS_MAJOR_VERSION,
25
+ Wx::WXWIDGETS_MINOR_VERSION,
26
+ Wx::WXWIDGETS_RELEASE_NUMBER ]
27
+
28
+
29
+ # Load in all the class extension methods written in ruby
30
+ # evthandler must be required first b/c it sets up methods modified elsewhere
31
+ require 'wx/classes/evthandler.rb'
32
+ class_files = File.join( File.dirname(__FILE__), 'wx', 'classes', '*.rb')
33
+ Dir.glob(class_files) do | class_file |
34
+ require 'wx/classes/' + class_file[/\w+\.rb$/]
35
+ end
36
+
37
+ # Load in syntax sweetner
38
+ require 'wx/accessors'
39
+ require 'wx/keyword_ctors'
40
+ require 'wx/keyword_defs'
41
+
42
+
@@ -0,0 +1,52 @@
1
+ # = WxSugar - Accessors
2
+ #
3
+ # The default WxRuby interface has lots and lots of methods like
4
+ #
5
+ # * get_position()
6
+ # * set_size(a_size)
7
+ # * is_checked()
8
+ #
9
+ # and so on. Methods that retrieve set, or query attributes of an object
10
+ # are more normally in Ruby called simply by the attribute name:
11
+ #
12
+ # * position()
13
+ # * size = a_size
14
+ # * checked?
15
+ #
16
+ # This extension creates an alias for every WxRuby instance method that
17
+ # begins with +get_+, +set_+ or +is_+. Note that if you are calling a
18
+ # 'setter' method on self, you must explicitly send the message to self:
19
+ #
20
+ # # set's self size to be 100px by 100px
21
+ # self.size = Wx::Size.new(100, 100)
22
+ # # only sets the value of a local variable 'size'
23
+ # size = Wx::Size.new
24
+
25
+ module WxRubyStyleAccessors
26
+ def method_missing(sym, *args)
27
+ case sym.to_s
28
+ when /^(.*)\=$/
29
+ meth = "set_#{$1}"
30
+ when /^(.*)\?$/
31
+ meth = "is_#{$1}"
32
+ else
33
+ meth = "get_#{sym}"
34
+ end
35
+ if respond_to?(meth)
36
+ send(meth, *args)
37
+ else
38
+ e = NoMethodError.new("undefined method '#{sym}' for #{self.inspect}")
39
+ e.set_backtrace(caller)
40
+ Kernel.raise e
41
+ end
42
+ end
43
+ end
44
+
45
+ all_classes = Wx::constants.collect { | c | Wx::const_get(c) }.grep(Class)
46
+
47
+ all_classes.each do | klass |
48
+ klass.class_eval do
49
+ include WxRubyStyleAccessors
50
+ extend WxRubyStyleAccessors
51
+ end
52
+ end
@@ -0,0 +1,25 @@
1
+ # Copyright 2004-2006 by Kevin Smith
2
+ # released under the MIT-style wxruby2 license
3
+
4
+ class Wx::App
5
+ # This method handles failed assertions from within the WxWidgets C++
6
+ # code. These messages are only generated by a DEBUG build of
7
+ # WxRuby. Such messages usually indicate that the API is being used
8
+ # incorrectly; the file/line reference points to the place in the
9
+ # WxWidgets source code where the assertion was made.
10
+ def on_assert_failure(file, line, condition, message)
11
+ warn "Wx WARNING: #{message} (#{file}:#{line})"
12
+ end
13
+
14
+ # For use in development only, of no practical use in production code.
15
+ # This method causes Ruby's garbage collection to run (roughly) at
16
+ # interval +interval+ (seconds) - the default is 1, i.e. every
17
+ # second. This should help ferret out bugs in memory management more
18
+ # quickly.
19
+ def gc_stress(interval = 1)
20
+ t = Wx::Timer.new(self, 9999)
21
+ evt_timer(9999) { Thread.pass }
22
+ Thread.new { loop { sleep interval; GC.start } }
23
+ t.start(100)
24
+ end
25
+ end
@@ -0,0 +1,31 @@
1
+ # Class which can supply icons and bitmaps
2
+ class Wx::ArtProvider
3
+ # Keep a note of supplied ArtProviders to prevent them being GC'd
4
+ @__art_provs = []
5
+
6
+ class << self
7
+ wx_insert = instance_method(:insert)
8
+ define_method(:insert) do | art_prov |
9
+ wx_insert.bind(self).call(art_prov)
10
+ @__art_provs.unshift(art_prov)
11
+ end
12
+
13
+ wx_pop = instance_method(:pop)
14
+ define_method(:pop) do
15
+ wx_pop.bind(self).call
16
+ @__art_provs.pop
17
+ end
18
+
19
+ wx_push = instance_method(:push)
20
+ define_method(:push) do | art_prov |
21
+ wx_push.bind(self).call(art_prov)
22
+ @__art_provs.push(art_prov)
23
+ end
24
+
25
+ wx_remove = instance_method(:remove)
26
+ define_method(:remove) do | art_prov |
27
+ wx_push.bind(self).call(art_prov)
28
+ @__art_provs.delete(art_prov)
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,23 @@
1
+ class Wx::Bitmap
2
+ # Redefine the initialize method so it raises an exception if a
3
+ # non-existent file is given to the constructor; otherwise, wx Widgets
4
+ # just carries on with an empty bitmap, which may cause faults later
5
+ wx_init = self.instance_method(:initialize)
6
+ define_method(:initialize) do | *args |
7
+ if args[0].kind_of? String
8
+ if not File.exist?( File.expand_path(args[0]) )
9
+ Kernel.raise(ArgumentError, "Bitmap file does not exist: #{args[0]}")
10
+ end
11
+ end
12
+ wx_init.bind(self).call(*args)
13
+ end
14
+
15
+ # Accepts a block, which will be passed a device context which can be
16
+ # used to draw upon the Bitmap
17
+ def draw
18
+ dc = MemoryDC.new
19
+ dc.select_object(self)
20
+ yield dc
21
+ dc.select_object( NULL_BITMAP )
22
+ end
23
+ end
@@ -0,0 +1,4 @@
1
+ class Wx::Choice
2
+ alias :get_item_data :get_client_data
3
+ alias :set_item_data :set_client_data
4
+ end
@@ -0,0 +1,13 @@
1
+ # Device Context to paint on a window outside an on_paint handler. It is
2
+ # recommended that PaintDC is used in preference to this class.
3
+ class Wx::ClientDC
4
+ # This class should not be instantiated directly in wxRuby; it should
5
+ # always be used via Window#paint, which takes a block receiving the
6
+ # DC. This ensures that the DC is cleaned up at the correct time,
7
+ # avoiding errors and segfaults on exit.
8
+ def initialize(*args)
9
+ Kernel.raise RuntimeError,
10
+ "Do not instantiate ClientDC directly; use Window#paint",
11
+ caller[1..-1]
12
+ end
13
+ end
@@ -0,0 +1,47 @@
1
+ class Wx::Colour
2
+ # Redefine the initialize method so it raises an exception if an
3
+ # invalid colour value is given. This might be an unknown colour
4
+ # string (eg 'dark blue') or out-of-bounds integer values (<0 or >255)
5
+ wx_init = self.instance_method(:initialize)
6
+ define_method(:initialize) do | *args |
7
+ begin
8
+ wx_init.bind(self).call(*args)
9
+ # Invalid integer values raise SWIG 'no matching func'
10
+ rescue ArgumentError
11
+ Kernel.raise ArgumentError, "Invalid colour values #{args.inspect}"
12
+ end
13
+
14
+ if not is_ok
15
+ Kernel.raise ArgumentError, "Invalid colour values #{args.inspect}"
16
+ end
17
+ end
18
+
19
+ # Standard colours, corresponding to WxWidgets stock colours.
20
+ Wx::WHITE = new(255, 255, 255)
21
+ Wx::BLACK = new(0, 0, 0)
22
+
23
+ Wx::RED = new(255, 0, 0)
24
+ Wx::GREEN = new(0, 255, 0)
25
+ Wx::BLUE = new(0, 0, 255)
26
+
27
+ Wx::YELLOW = new(255, 255, 0)
28
+ Wx::MAGENTA = new(255, 0, 255)
29
+ Wx::CYAN = new(0, 255, 255)
30
+
31
+ Wx::LIGHT_GREY = new(192, 192, 192)
32
+
33
+ # Colours are equal to one another if they have the same red, green
34
+ # and blue intensity, and the same alpha
35
+ def ==(other)
36
+ if not other.is_a?(self.class)
37
+ raise ArgumentError, "No comparison of #{self} to #{other}"
38
+ end
39
+ [ red, green, blue, alpha ] ==
40
+ [ other.red, other.green, other.blue, other.alpha ]
41
+ end
42
+
43
+ # More informative output for inspect etc
44
+ def to_s
45
+ "#<Wx::Colour: (#{red}, #{green}, #{blue} *#{alpha})>"
46
+ end
47
+ end
@@ -0,0 +1,4 @@
1
+ class Wx::ComboBox
2
+ alias :get_item_data :get_client_data
3
+ alias :set_item_data :set_client_data
4
+ end
@@ -0,0 +1,828 @@
1
+ # All classes which are capable of handling events inherit from
2
+ # EvtHandler. This includes all Wx::Window subclasses and Wx::App.
3
+
4
+ class Wx::EvtHandler
5
+ # EventType is an internal class that's used to set up event handlers
6
+ # and mappings.
7
+ # * 'name' is the name of the event handler method in ruby
8
+ # * 'arity' is the number of id arguments that method should accept
9
+ # * 'const' is the Wx EventType constant that identifies the event
10
+ # * 'evt_class' is the WxRuby event class which is passed to the event
11
+ # handler block
12
+ #
13
+ # NB: Some event types currently pass a Wx::Event into the event
14
+ # handler block; when the appropriate classes are added to wxRuby, the
15
+ # binding can be updated here.
16
+ EventType = Struct.new(:name, :arity, :const, :evt_class)
17
+
18
+ # Fast look-up hash to map event type ids to ruby event classes
19
+ EVENT_TYPE_CLASS_MAP = {}
20
+ # Hash to look up EVT constants from symbol names of evt handler
21
+ # methods; used internally by disconnect (see EvtHandler.i)
22
+ EVENT_NAME_TYPE_MAP = {}
23
+
24
+ # Given a Wx EventType id (eg Wx::EVT_MENU), returns a WxRuby Event
25
+ # class which should be passed to event handler blocks. The actual
26
+ # EVT_XXX constants themselves are in the compiled library, defined in
27
+ # swig/classes/Event.i
28
+ def self.event_class_for_type(id)
29
+ if evt_klass = EVENT_TYPE_CLASS_MAP[id]
30
+ return evt_klass
31
+ else
32
+ warn "No event class defined for event type #{id}"
33
+ return Wx::Event
34
+ end
35
+ end
36
+
37
+ # Given the symbol name of an evt_xxx handler method, returns the
38
+ # Integer Wx::EVT_XXX constant associated with that handler.
39
+ def self.event_type_for_name(name)
40
+ EVENT_NAME_TYPE_MAP[name]
41
+ end
42
+
43
+ # Given the Integer constant Wx::EVT_XXX, returns the convenience
44
+ # handler method name associated with that type of event.
45
+ def self.event_name_for_type(name)
46
+ EVENT_NAME_TYPE_MAP.index(name)
47
+ end
48
+
49
+ # Public method to register the mapping of a custom event type
50
+ # +konstant+ (which should be a unique integer; one will be created if
51
+ # not supplied) to a custom event class +klass+. If +meth+ and +arity+
52
+ # are given, a convenience evt_handler method called +meth+ will be
53
+ # created, which accepts +arity+ arguments.
54
+ def self.register_class( klass, konstant = nil,
55
+ meth = nil, arity = nil)
56
+ konstant ||= Wx::Event.new_event_type
57
+ unless klass < Wx::Event
58
+ Kernel.raise TypeError, "Event class should be a subclass of Wx::Event"
59
+ end
60
+ ev_type = EventType.new(meth, arity, konstant, klass)
61
+ register_event_type(ev_type)
62
+ return konstant
63
+ end
64
+
65
+ # Registers the event type +ev_type+, which should be an instance of
66
+ # the Struct class +Wx::EvtHandler::EventType+.
67
+ def self.register_event_type(ev_type)
68
+ EVENT_TYPE_CLASS_MAP[ev_type.const] = ev_type.evt_class
69
+ EVENT_NAME_TYPE_MAP[ev_type.name.intern] = ev_type.const
70
+
71
+ unless ev_type.arity and ev_type.name
72
+ return
73
+ end
74
+ case ev_type.arity
75
+ when 0 # events without an id
76
+ class_eval %Q|
77
+ def #{ev_type.name}(&block)
78
+ connect(Wx::ID_ANY, Wx::ID_ANY, #{ev_type.const}, &block)
79
+ end |
80
+ when 1 # events with an id
81
+ class_eval %Q|
82
+ def #{ev_type.name}(id, &block)
83
+ connect(id, Wx::ID_ANY, #{ev_type.const}, &block)
84
+ end |
85
+ when 2 # events with id range
86
+ class_eval %Q|
87
+ def #{ev_type.name}(first_id, last_id, &block)
88
+ connect(first_id, last_id, #{ev_type.const}, &block)
89
+ end |
90
+ end
91
+ end
92
+
93
+ # Definitions for all event types that are part by core wxRuby. Events
94
+ # that are mapped to class Wx::Event are TODO as they are not
95
+ # currently wrapped by the correct class. All StyledTextCtrl
96
+ # (Scintilla) events with prefix EVT_STC are dealt with in the
97
+ # separate styledtextctrl.rb file.
98
+ EVENT_DEFINITIONS = [
99
+ EventType['evt_activate', 0,
100
+ Wx::EVT_ACTIVATE,
101
+ Wx::ActivateEvent],
102
+ EventType['evt_activate_app', 0,
103
+ Wx::EVT_ACTIVATE_APP,
104
+ Wx::ActivateEvent],
105
+ EventType['evt_auinotebook_allow_dnd', 1,
106
+ Wx::EVT_COMMAND_AUINOTEBOOK_ALLOW_DND,
107
+ Wx::AuiNotebookEvent],
108
+ EventType['evt_auinotebook_begin_drag', 1,
109
+ Wx::EVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG,
110
+ Wx::AuiNotebookEvent],
111
+ EventType['evt_auinotebook_button', 1,
112
+ Wx::EVT_COMMAND_AUINOTEBOOK_BUTTON,
113
+ Wx::AuiNotebookEvent],
114
+ EventType['evt_auinotebook_drag_motion', 1,
115
+ Wx::EVT_COMMAND_AUINOTEBOOK_DRAG_MOTION,
116
+ Wx::AuiNotebookEvent],
117
+ EventType['evt_auinotebook_end_drag', 1,
118
+ Wx::EVT_COMMAND_AUINOTEBOOK_END_DRAG,
119
+ Wx::AuiNotebookEvent],
120
+ EventType['evt_auinotebook_page_changed', 1,
121
+ Wx::EVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED,
122
+ Wx::AuiNotebookEvent],
123
+ EventType['evt_auinotebook_page_changing', 1,
124
+ Wx::EVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING,
125
+ Wx::AuiNotebookEvent],
126
+ EventType['evt_auinotebook_page_close', 1,
127
+ Wx::EVT_COMMAND_AUINOTEBOOK_PAGE_CLOSE,
128
+ Wx::AuiNotebookEvent],
129
+ EventType['evt_aui_find_manager', 0,
130
+ Wx::EVT_AUI_FIND_MANAGER,
131
+ Wx::AuiManagerEvent],
132
+ EventType['evt_aui_pane_button', 0,
133
+ Wx::EVT_AUI_PANE_BUTTON,
134
+ Wx::AuiManagerEvent],
135
+ EventType['evt_aui_pane_close', 0,
136
+ Wx::EVT_AUI_PANE_CLOSE,
137
+ Wx::AuiManagerEvent],
138
+ EventType['evt_aui_pane_maximize', 0,
139
+ Wx::EVT_AUI_PANE_MAXIMIZE,
140
+ Wx::AuiManagerEvent],
141
+ EventType['evt_aui_pane_restore', 0,
142
+ Wx::EVT_AUI_PANE_RESTORE,
143
+ Wx::AuiManagerEvent],
144
+ EventType['evt_aui_render', 0,
145
+ Wx::EVT_AUI_RENDER,
146
+ Wx::AuiManagerEvent],
147
+ EventType['evt_button', 1,
148
+ Wx::EVT_COMMAND_BUTTON_CLICKED,
149
+ Wx::CommandEvent],
150
+ EventType['evt_calculate_layout', 0,
151
+ Wx::EVT_CALCULATE_LAYOUT,
152
+ Wx::Event],
153
+ EventType['evt_calendar', 1,
154
+ Wx::EVT_CALENDAR_DOUBLECLICKED,
155
+ Wx::CalendarEvent],
156
+ EventType['evt_calendar_day', 1,
157
+ Wx::EVT_CALENDAR_DAY_CHANGED,
158
+ Wx::CalendarEvent],
159
+ EventType['evt_calendar_month', 1,
160
+ Wx::EVT_CALENDAR_MONTH_CHANGED,
161
+ Wx::CalendarEvent],
162
+ EventType['evt_calendar_sel_changed', 1,
163
+ Wx::EVT_CALENDAR_SEL_CHANGED,
164
+ Wx::CalendarEvent],
165
+ EventType['evt_calendar_weekday_clicked', 1,
166
+ Wx::EVT_CALENDAR_WEEKDAY_CLICKED,
167
+ Wx::CalendarEvent],
168
+ EventType['evt_calendar_year', 1,
169
+ Wx::EVT_CALENDAR_YEAR_CHANGED,
170
+ Wx::CalendarEvent],
171
+ EventType['evt_char', 0,
172
+ Wx::EVT_CHAR,
173
+ Wx::KeyEvent],
174
+ EventType['evt_char_hook', 0,
175
+ Wx::EVT_CHAR_HOOK,
176
+ Wx::KeyEvent],
177
+ EventType['evt_checkbox', 1,
178
+ Wx::EVT_COMMAND_CHECKBOX_CLICKED,
179
+ Wx::CommandEvent],
180
+ EventType['evt_checklistbox', 1,
181
+ Wx::EVT_COMMAND_CHECKLISTBOX_TOGGLED,
182
+ Wx::CommandEvent],
183
+ EventType['evt_child_focus', 0,
184
+ Wx::EVT_CHILD_FOCUS,
185
+ Wx::ChildFocusEvent],
186
+ EventType['evt_choice', 1,
187
+ Wx::EVT_COMMAND_CHOICE_SELECTED,
188
+ Wx::CommandEvent],
189
+ EventType['evt_choicebook_page_changed', 1,
190
+ Wx::EVT_COMMAND_CHOICEBOOK_PAGE_CHANGED,
191
+ Wx::ChoicebookEvent],
192
+ EventType['evt_choicebook_page_changing', 1,
193
+ Wx::EVT_COMMAND_CHOICEBOOK_PAGE_CHANGING,
194
+ Wx::ChoicebookEvent],
195
+ EventType['evt_close', 0,
196
+ Wx::EVT_CLOSE_WINDOW,
197
+ Wx::CloseEvent],
198
+ EventType['evt_combobox', 1,
199
+ Wx::EVT_COMMAND_COMBOBOX_SELECTED,
200
+ Wx::CommandEvent],
201
+ EventType['evt_command', 0,
202
+ Wx::EVT_NULL,
203
+ Wx::Event],
204
+ EventType['evt_command_enter', 1,
205
+ Wx::EVT_COMMAND_ENTER,
206
+ Wx::Event],
207
+ EventType['evt_command_kill_focus', 1,
208
+ Wx::EVT_COMMAND_KILL_FOCUS,
209
+ Wx::Event],
210
+ EventType['evt_command_left_click', 1,
211
+ Wx::EVT_COMMAND_LEFT_CLICK,
212
+ Wx::Event],
213
+ EventType['evt_command_left_dclick', 1,
214
+ Wx::EVT_COMMAND_LEFT_DCLICK,
215
+ Wx::Event],
216
+ EventType['evt_command_range', 2,
217
+ Wx::EVT_NULL,
218
+ Wx::Event],
219
+ EventType['evt_command_right_click', 1,
220
+ Wx::EVT_COMMAND_RIGHT_CLICK,
221
+ Wx::Event],
222
+ EventType['evt_command_set_focus', 1,
223
+ Wx::EVT_COMMAND_SET_FOCUS,
224
+ Wx::Event],
225
+ EventType['evt_context_menu', 0,
226
+ Wx::EVT_CONTEXT_MENU,
227
+ Wx::ContextMenuEvent],
228
+ EventType['evt_drop_files', 0,
229
+ Wx::EVT_DROP_FILES,
230
+ Wx::Event],
231
+ EventType['evt_end_process', 1,
232
+ Wx::EVT_END_PROCESS,
233
+ Wx::Event],
234
+ EventType['evt_end_session', 0,
235
+ Wx::EVT_END_SESSION,
236
+ Wx::Event],
237
+ EventType['evt_enter_window', 0,
238
+ Wx::EVT_ENTER_WINDOW,
239
+ Wx::MouseEvent],
240
+ EventType['evt_erase_background', 0,
241
+ Wx::EVT_ERASE_BACKGROUND,
242
+ Wx::EraseEvent],
243
+ EventType['evt_find', 1,
244
+ Wx::EVT_COMMAND_FIND,
245
+ Wx::FindDialogEvent],
246
+ EventType['evt_find_close', 1,
247
+ Wx::EVT_COMMAND_FIND_CLOSE,
248
+ Wx::FindDialogEvent],
249
+ EventType['evt_find_next', 1,
250
+ Wx::EVT_COMMAND_FIND_NEXT,
251
+ Wx::FindDialogEvent],
252
+ EventType['evt_find_replace', 1,
253
+ Wx::EVT_COMMAND_FIND_REPLACE,
254
+ Wx::FindDialogEvent],
255
+ EventType['evt_find_replace_all', 1,
256
+ Wx::EVT_COMMAND_FIND_REPLACE_ALL,
257
+ Wx::FindDialogEvent],
258
+ EventType['evt_grid_cell_change', 0,
259
+ Wx::EVT_GRID_CELL_CHANGE,
260
+ Wx::GridEvent],
261
+ EventType['evt_grid_cell_left_click', 0,
262
+ Wx::EVT_GRID_CELL_LEFT_CLICK,
263
+ Wx::GridEvent],
264
+ EventType['evt_grid_cell_left_dclick', 0,
265
+ Wx::EVT_GRID_CELL_LEFT_DCLICK,
266
+ Wx::GridEvent],
267
+ EventType['evt_grid_cell_right_click', 0,
268
+ Wx::EVT_GRID_CELL_RIGHT_CLICK,
269
+ Wx::GridEvent],
270
+ EventType['evt_grid_cell_right_dclick', 0,
271
+ Wx::EVT_GRID_CELL_RIGHT_DCLICK,
272
+ Wx::GridEvent],
273
+ EventType['evt_grid_cmd_cell_change', 1,
274
+ Wx::EVT_GRID_CELL_CHANGE,
275
+ Wx::GridEvent],
276
+ EventType['evt_grid_cmd_cell_left_click', 1,
277
+ Wx::EVT_GRID_CELL_LEFT_CLICK,
278
+ Wx::GridEvent],
279
+ EventType['evt_grid_cmd_cell_left_dclick', 1,
280
+ Wx::EVT_GRID_CELL_LEFT_DCLICK,
281
+ Wx::GridEvent],
282
+ EventType['evt_grid_cmd_cell_right_click', 1,
283
+ Wx::EVT_GRID_CELL_RIGHT_CLICK,
284
+ Wx::GridEvent],
285
+ EventType['evt_grid_cmd_cell_right_dclick', 1,
286
+ Wx::EVT_GRID_CELL_RIGHT_DCLICK,
287
+ Wx::GridEvent],
288
+ EventType['evt_grid_cmd_col_size', 1,
289
+ Wx::EVT_GRID_COL_SIZE,
290
+ Wx::GridSizeEvent],
291
+ EventType['evt_grid_cmd_editor_created', 1,
292
+ Wx::EVT_GRID_EDITOR_CREATED,
293
+ Wx::GridEditorCreatedEvent],
294
+ EventType['evt_grid_cmd_editor_hidden', 1,
295
+ Wx::EVT_GRID_EDITOR_HIDDEN,
296
+ Wx::GridEvent],
297
+ EventType['evt_grid_cmd_editor_shown', 1,
298
+ Wx::EVT_GRID_EDITOR_SHOWN,
299
+ Wx::GridEvent],
300
+ EventType['evt_grid_cmd_label_left_click', 1,
301
+ Wx::EVT_GRID_LABEL_LEFT_CLICK,
302
+ Wx::GridEvent],
303
+ EventType['evt_grid_cmd_label_left_dclick', 1,
304
+ Wx::EVT_GRID_LABEL_LEFT_DCLICK,
305
+ Wx::GridEvent],
306
+ EventType['evt_grid_cmd_label_right_click', 1,
307
+ Wx::EVT_GRID_LABEL_RIGHT_CLICK,
308
+ Wx::GridEvent],
309
+ EventType['evt_grid_cmd_label_right_dclick', 1,
310
+ Wx::EVT_GRID_LABEL_RIGHT_DCLICK,
311
+ Wx::GridEvent],
312
+ EventType['evt_grid_cmd_range_select', 1,
313
+ Wx::EVT_GRID_RANGE_SELECT,
314
+ Wx::GridRangeSelectEvent],
315
+ EventType['evt_grid_cmd_row_size', 1,
316
+ Wx::EVT_GRID_ROW_SIZE,
317
+ Wx::GridSizeEvent],
318
+ EventType['evt_grid_cmd_select_cell', 1,
319
+ Wx::EVT_GRID_SELECT_CELL,
320
+ Wx::GridEvent],
321
+ EventType['evt_grid_col_size', 0,
322
+ Wx::EVT_GRID_COL_SIZE,
323
+ Wx::GridSizeEvent],
324
+ EventType['evt_grid_editor_created', 0,
325
+ Wx::EVT_GRID_EDITOR_CREATED,
326
+ Wx::GridEditorCreatedEvent],
327
+ EventType['evt_grid_editor_hidden', 0,
328
+ Wx::EVT_GRID_EDITOR_HIDDEN,
329
+ Wx::GridEvent],
330
+ EventType['evt_grid_editor_shown', 0,
331
+ Wx::EVT_GRID_EDITOR_SHOWN,
332
+ Wx::GridEvent],
333
+ EventType['evt_grid_label_left_click', 0,
334
+ Wx::EVT_GRID_LABEL_LEFT_CLICK,
335
+ Wx::GridEvent],
336
+ EventType['evt_grid_label_left_dclick', 0,
337
+ Wx::EVT_GRID_LABEL_LEFT_DCLICK,
338
+ Wx::GridEvent],
339
+ EventType['evt_grid_label_right_click', 0,
340
+ Wx::EVT_GRID_LABEL_RIGHT_CLICK,
341
+ Wx::GridEvent],
342
+ EventType['evt_grid_label_right_dclick', 0,
343
+ Wx::EVT_GRID_LABEL_RIGHT_DCLICK,
344
+ Wx::GridEvent],
345
+ EventType['evt_grid_range_select', 0,
346
+ Wx::EVT_GRID_RANGE_SELECT,
347
+ Wx::GridRangeSelectEvent],
348
+ EventType['evt_grid_row_size', 0,
349
+ Wx::EVT_GRID_ROW_SIZE,
350
+ Wx::GridSizeEvent],
351
+ EventType['evt_grid_select_cell', 0,
352
+ Wx::EVT_GRID_SELECT_CELL,
353
+ Wx::GridEvent],
354
+ EventType['evt_help', 1,
355
+ Wx::EVT_HELP,
356
+ Wx::Event],
357
+ EventType['evt_help_range', 2,
358
+ Wx::EVT_HELP,
359
+ Wx::Event],
360
+ EventType['evt_hyperlink', 1,
361
+ Wx::EVT_COMMAND_HYPERLINK,
362
+ Wx::HyperlinkEvent],
363
+ EventType['evt_iconize', 0,
364
+ Wx::EVT_ICONIZE,
365
+ Wx::IconizeEvent],
366
+ EventType['evt_idle', 0,
367
+ Wx::EVT_IDLE,
368
+ Wx::IdleEvent],
369
+ EventType['evt_init_dialog', 0,
370
+ Wx::EVT_INIT_DIALOG,
371
+ Wx::Event],
372
+ EventType['evt_joy_button_down', 0,
373
+ Wx::EVT_JOY_BUTTON_DOWN,
374
+ Wx::Event],
375
+ EventType['evt_joy_button_up', 0,
376
+ Wx::EVT_JOY_BUTTON_UP,
377
+ Wx::Event],
378
+ EventType['evt_joy_move', 0,
379
+ Wx::EVT_JOY_MOVE,
380
+ Wx::Event],
381
+ EventType['evt_joy_zmove', 0,
382
+ Wx::EVT_JOY_ZMOVE,
383
+ Wx::Event],
384
+ EventType['evt_key_down', 0,
385
+ Wx::EVT_KEY_DOWN,
386
+ Wx::KeyEvent],
387
+ EventType['evt_key_up', 0,
388
+ Wx::EVT_KEY_UP,
389
+ Wx::KeyEvent],
390
+ EventType['evt_kill_focus', 0,
391
+ Wx::EVT_KILL_FOCUS,
392
+ Wx::FocusEvent],
393
+ EventType['evt_leave_window', 0,
394
+ Wx::EVT_LEAVE_WINDOW,
395
+ Wx::MouseEvent],
396
+ EventType['evt_left_dclick', 0,
397
+ Wx::EVT_LEFT_DCLICK,
398
+ Wx::MouseEvent],
399
+ EventType['evt_left_down', 0,
400
+ Wx::EVT_LEFT_DOWN,
401
+ Wx::MouseEvent],
402
+ EventType['evt_left_up', 0,
403
+ Wx::EVT_LEFT_UP,
404
+ Wx::MouseEvent],
405
+ EventType['evt_listbook_page_changed', 1,
406
+ Wx::EVT_COMMAND_LISTBOOK_PAGE_CHANGED,
407
+ Wx::ListbookEvent],
408
+ EventType['evt_listbook_page_changing', 1,
409
+ Wx::EVT_COMMAND_LISTBOOK_PAGE_CHANGING,
410
+ Wx::ListbookEvent],
411
+ EventType['evt_listbox', 1,
412
+ Wx::EVT_COMMAND_LISTBOX_SELECTED,
413
+ Wx::CommandEvent],
414
+ EventType['evt_listbox_dclick', 1,
415
+ Wx::EVT_COMMAND_LISTBOX_DOUBLECLICKED,
416
+ Wx::CommandEvent],
417
+ EventType['evt_list_begin_drag', 1,
418
+ Wx::EVT_COMMAND_LIST_BEGIN_DRAG,
419
+ Wx::ListEvent],
420
+ EventType['evt_list_begin_label_edit', 1,
421
+ Wx::EVT_COMMAND_LIST_BEGIN_LABEL_EDIT,
422
+ Wx::ListEvent],
423
+ EventType['evt_list_begin_rdrag', 1,
424
+ Wx::EVT_COMMAND_LIST_BEGIN_RDRAG,
425
+ Wx::ListEvent],
426
+ EventType['evt_list_cache_hint', 1,
427
+ Wx::EVT_COMMAND_LIST_CACHE_HINT,
428
+ Wx::ListEvent],
429
+ EventType['evt_list_col_begin_drag', 1,
430
+ Wx::EVT_COMMAND_LIST_COL_BEGIN_DRAG,
431
+ Wx::ListEvent],
432
+ EventType['evt_list_col_click', 1,
433
+ Wx::EVT_COMMAND_LIST_COL_CLICK,
434
+ Wx::ListEvent],
435
+ EventType['evt_list_col_dragging', 1,
436
+ Wx::EVT_COMMAND_LIST_COL_DRAGGING,
437
+ Wx::ListEvent],
438
+ EventType['evt_list_col_end_drag', 1,
439
+ Wx::EVT_COMMAND_LIST_COL_END_DRAG,
440
+ Wx::ListEvent],
441
+ EventType['evt_list_col_right_click', 1,
442
+ Wx::EVT_COMMAND_LIST_COL_RIGHT_CLICK,
443
+ Wx::ListEvent],
444
+ EventType['evt_list_delete_all_items', 1,
445
+ Wx::EVT_COMMAND_LIST_DELETE_ALL_ITEMS,
446
+ Wx::ListEvent],
447
+ EventType['evt_list_delete_item', 1,
448
+ Wx::EVT_COMMAND_LIST_DELETE_ITEM,
449
+ Wx::ListEvent],
450
+ EventType['evt_list_end_label_edit', 1,
451
+ Wx::EVT_COMMAND_LIST_END_LABEL_EDIT,
452
+ Wx::ListEvent],
453
+ EventType['evt_list_insert_item', 1,
454
+ Wx::EVT_COMMAND_LIST_INSERT_ITEM,
455
+ Wx::ListEvent],
456
+ EventType['evt_list_item_activated', 1,
457
+ Wx::EVT_COMMAND_LIST_ITEM_ACTIVATED,
458
+ Wx::ListEvent],
459
+ EventType['evt_list_item_deselected', 1,
460
+ Wx::EVT_COMMAND_LIST_ITEM_DESELECTED,
461
+ Wx::ListEvent],
462
+ EventType['evt_list_item_focused', 1,
463
+ Wx::EVT_COMMAND_LIST_ITEM_FOCUSED,
464
+ Wx::ListEvent],
465
+ EventType['evt_list_item_middle_click', 1,
466
+ Wx::EVT_COMMAND_LIST_ITEM_MIDDLE_CLICK,
467
+ Wx::ListEvent],
468
+ EventType['evt_list_item_right_click', 1,
469
+ Wx::EVT_COMMAND_LIST_ITEM_RIGHT_CLICK,
470
+ Wx::ListEvent],
471
+ EventType['evt_list_item_selected', 1,
472
+ Wx::EVT_COMMAND_LIST_ITEM_SELECTED,
473
+ Wx::ListEvent],
474
+ EventType['evt_list_key_down', 1,
475
+ Wx::EVT_COMMAND_LIST_KEY_DOWN,
476
+ Wx::ListEvent],
477
+ EventType['evt_maximize', 0,
478
+ Wx::EVT_MAXIMIZE,
479
+ Wx::Event],
480
+ EventType['evt_menu', 1,
481
+ Wx::EVT_COMMAND_MENU_SELECTED,
482
+ Wx::CommandEvent],
483
+ EventType['evt_menu_close', 0,
484
+ Wx::EVT_MENU_CLOSE,
485
+ Wx::MenuEvent],
486
+ EventType['evt_menu_highlight', 1,
487
+ Wx::EVT_MENU_HIGHLIGHT,
488
+ Wx::MenuEvent],
489
+ EventType['evt_menu_highlight_all', 0,
490
+ Wx::EVT_MENU_HIGHLIGHT,
491
+ Wx::MenuEvent],
492
+ EventType['evt_menu_open', 0,
493
+ Wx::EVT_MENU_OPEN,
494
+ Wx::MenuEvent],
495
+ EventType['evt_menu_range', 2,
496
+ Wx::EVT_COMMAND_MENU_SELECTED,
497
+ Wx::CommandEvent],
498
+ EventType['evt_middle_dclick', 0,
499
+ Wx::EVT_MIDDLE_DCLICK,
500
+ Wx::MouseEvent],
501
+ EventType['evt_middle_down', 0,
502
+ Wx::EVT_MIDDLE_DOWN,
503
+ Wx::MouseEvent],
504
+ EventType['evt_middle_up', 0,
505
+ Wx::EVT_MIDDLE_UP,
506
+ Wx::MouseEvent],
507
+ EventType['evt_motion', 0,
508
+ Wx::EVT_MOTION,
509
+ Wx::MouseEvent],
510
+ EventType['evt_mousewheel', 0,
511
+ Wx::EVT_MOUSEWHEEL,
512
+ Wx::MouseEvent],
513
+ EventType['evt_mouse_capture_changed', 0,
514
+ Wx::EVT_MOUSE_CAPTURE_CHANGED,
515
+ Wx::Event],
516
+ EventType['evt_move', 0,
517
+ Wx::EVT_MOVE,
518
+ Wx::MoveEvent],
519
+ EventType['evt_nc_paint', 0,
520
+ Wx::EVT_NC_PAINT,
521
+ Wx::Event],
522
+ EventType['evt_notebook_page_changed', 1,
523
+ Wx::EVT_COMMAND_NOTEBOOK_PAGE_CHANGED,
524
+ Wx::NotebookEvent],
525
+ EventType['evt_notebook_page_changing', 1,
526
+ Wx::EVT_COMMAND_NOTEBOOK_PAGE_CHANGING,
527
+ Wx::NotebookEvent],
528
+ EventType['evt_paint', 0,
529
+ Wx::EVT_PAINT,
530
+ Wx::PaintEvent],
531
+ EventType['evt_query_end_session', 0,
532
+ Wx::EVT_QUERY_END_SESSION,
533
+ Wx::Event],
534
+ EventType['evt_query_layout_info', 0,
535
+ Wx::EVT_QUERY_LAYOUT_INFO,
536
+ Wx::Event],
537
+ EventType['evt_radiobox', 1,
538
+ Wx::EVT_COMMAND_RADIOBOX_SELECTED,
539
+ Wx::CommandEvent],
540
+ EventType['evt_radiobutton', 1,
541
+ Wx::EVT_COMMAND_RADIOBUTTON_SELECTED,
542
+ Wx::CommandEvent],
543
+ EventType['evt_right_dclick', 0,
544
+ Wx::EVT_RIGHT_DCLICK,
545
+ Wx::MouseEvent],
546
+ EventType['evt_right_down', 0,
547
+ Wx::EVT_RIGHT_DOWN,
548
+ Wx::MouseEvent],
549
+ EventType['evt_right_up', 0,
550
+ Wx::EVT_RIGHT_UP,
551
+ Wx::MouseEvent],
552
+ EventType['evt_sash_dragged', 1,
553
+ Wx::EVT_SASH_DRAGGED,
554
+ Wx::SashEvent],
555
+ EventType['evt_sash_dragged_range', 2,
556
+ Wx::EVT_SASH_DRAGGED,
557
+ Wx::SashEvent],
558
+ EventType['evt_scrollbar', 1,
559
+ Wx::EVT_COMMAND_SCROLLBAR_UPDATED,
560
+ Wx::CommandEvent],
561
+ EventType['evt_scrollwin_bottom', 0,
562
+ Wx::EVT_SCROLLWIN_TOP,
563
+ Wx::ScrollWinEvent],
564
+ EventType['evt_scrollwin_linedown', 0,
565
+ Wx::EVT_SCROLLWIN_LINEDOWN,
566
+ Wx::ScrollWinEvent],
567
+ EventType['evt_scrollwin_lineup', 0,
568
+ Wx::EVT_SCROLLWIN_LINEUP,
569
+ Wx::ScrollWinEvent],
570
+ EventType['evt_scrollwin_pagedown', 0,
571
+ Wx::EVT_SCROLLWIN_PAGEDOWN,
572
+ Wx::ScrollWinEvent],
573
+ EventType['evt_scrollwin_pageup', 0,
574
+ Wx::EVT_SCROLLWIN_PAGEUP,
575
+ Wx::ScrollWinEvent],
576
+ EventType['evt_scrollwin_thumbrelease', 0,
577
+ Wx::EVT_SCROLLWIN_THUMBRELEASE,
578
+ Wx::ScrollWinEvent],
579
+ EventType['evt_scrollwin_thumbtrack', 0,
580
+ Wx::EVT_SCROLLWIN_THUMBTRACK,
581
+ Wx::ScrollWinEvent],
582
+ EventType['evt_scrollwin_top', 0,
583
+ Wx::EVT_SCROLLWIN_TOP,
584
+ Wx::ScrollWinEvent],
585
+ EventType['evt_scroll_bottom', 0,
586
+ Wx::EVT_SCROLL_BOTTOM,
587
+ Wx::ScrollEvent],
588
+ EventType['evt_scroll_linedown', 0,
589
+ Wx::EVT_SCROLL_LINEDOWN,
590
+ Wx::ScrollEvent],
591
+ EventType['evt_scroll_lineup', 0,
592
+ Wx::EVT_SCROLL_LINEUP,
593
+ Wx::ScrollEvent],
594
+ EventType['evt_scroll_pagedown', 0,
595
+ Wx::EVT_SCROLL_PAGEDOWN,
596
+ Wx::ScrollEvent],
597
+ EventType['evt_scroll_pageup', 0,
598
+ Wx::EVT_SCROLL_PAGEUP,
599
+ Wx::ScrollEvent],
600
+ EventType['evt_scroll_thumbrelease', 0,
601
+ Wx::EVT_SCROLL_THUMBRELEASE,
602
+ Wx::ScrollEvent],
603
+ EventType['evt_scroll_thumbtrack', 0,
604
+ Wx::EVT_SCROLL_THUMBTRACK,
605
+ Wx::ScrollEvent],
606
+ EventType['evt_scroll_top', 0,
607
+ Wx::EVT_SCROLL_TOP,
608
+ Wx::ScrollEvent],
609
+ EventType['evt_set_cursor', 0,
610
+ Wx::EVT_SET_CURSOR,
611
+ Wx::SetCursorEvent],
612
+ EventType['evt_set_focus', 0,
613
+ Wx::EVT_SET_FOCUS,
614
+ Wx::FocusEvent],
615
+ EventType['evt_size', 0,
616
+ Wx::EVT_SIZE,
617
+ Wx::SizeEvent],
618
+ EventType['evt_sizing', 0,
619
+ Wx::EVT_SIZING,
620
+ Wx::SizeEvent],
621
+ EventType['evt_slider', 1,
622
+ Wx::EVT_COMMAND_SLIDER_UPDATED,
623
+ Wx::CommandEvent],
624
+ EventType['evt_socket', 1,
625
+ Wx::EVT_SOCKET,
626
+ Wx::Event],
627
+ EventType['evt_spin', 1,
628
+ Wx::EVT_SCROLL_THUMBTRACK,
629
+ Wx::ScrollEvent],
630
+ EventType['evt_spinctrl', 1,
631
+ Wx::EVT_COMMAND_SPINCTRL_UPDATED,
632
+ Wx::SpinEvent],
633
+ EventType['evt_spin_down', 1,
634
+ Wx::EVT_SCROLL_LINEDOWN,
635
+ Wx::ScrollEvent],
636
+ EventType['evt_spin_up', 1,
637
+ Wx::EVT_SCROLL_LINEUP,
638
+ Wx::ScrollEvent],
639
+ EventType['evt_splitter_dclick', 1,
640
+ Wx::EVT_COMMAND_SPLITTER_DOUBLECLICKED,
641
+ Wx::SplitterEvent],
642
+ EventType['evt_splitter_sash_pos_changed', 1,
643
+ Wx::EVT_COMMAND_SPLITTER_SASH_POS_CHANGED,
644
+ Wx::SplitterEvent],
645
+ EventType['evt_splitter_sash_pos_changing', 1,
646
+ Wx::EVT_COMMAND_SPLITTER_SASH_POS_CHANGING,
647
+ Wx::SplitterEvent],
648
+ EventType['evt_splitter_unsplit', 1,
649
+ Wx::EVT_COMMAND_SPLITTER_UNSPLIT,
650
+ Wx::SplitterEvent],
651
+ EventType['evt_sys_colour_changed', 0,
652
+ Wx::EVT_SYS_COLOUR_CHANGED,
653
+ Wx::Event],
654
+ EventType['evt_taskbar_left_dclick', 0,
655
+ Wx::EVT_TASKBAR_LEFT_DCLICK,
656
+ Wx::Event],
657
+ EventType['evt_taskbar_left_down', 0,
658
+ Wx::EVT_TASKBAR_LEFT_DOWN,
659
+ Wx::Event],
660
+ EventType['evt_taskbar_left_up', 0,
661
+ Wx::EVT_TASKBAR_LEFT_UP,
662
+ Wx::Event],
663
+ EventType['evt_taskbar_move', 0,
664
+ Wx::EVT_TASKBAR_MOVE,
665
+ Wx::Event],
666
+ EventType['evt_taskbar_right_dclick', 0,
667
+ Wx::EVT_TASKBAR_RIGHT_DCLICK,
668
+ Wx::Event],
669
+ EventType['evt_taskbar_right_down', 0,
670
+ Wx::EVT_TASKBAR_RIGHT_DOWN,
671
+ Wx::Event],
672
+ EventType['evt_taskbar_right_up', 0,
673
+ Wx::EVT_TASKBAR_RIGHT_UP,
674
+ Wx::Event],
675
+ EventType['evt_text', 1,
676
+ Wx::EVT_COMMAND_TEXT_UPDATED,
677
+ Wx::CommandEvent],
678
+ EventType['evt_text_enter', 1,
679
+ Wx::EVT_COMMAND_TEXT_ENTER,
680
+ Wx::CommandEvent],
681
+ EventType['evt_text_maxlen', 1,
682
+ Wx::EVT_COMMAND_TEXT_MAXLEN,
683
+ Wx::CommandEvent],
684
+ EventType['evt_text_url', 1,
685
+ Wx::EVT_COMMAND_TEXT_URL,
686
+ Wx::TextUrlEvent],
687
+ EventType['evt_timer', 1,
688
+ Wx::EVT_TIMER,
689
+ Wx::TimerEvent],
690
+ EventType['evt_togglebutton', 1,
691
+ Wx::EVT_COMMAND_TOGGLEBUTTON_CLICKED,
692
+ Wx::Event],
693
+ EventType['evt_tool', 1,
694
+ Wx::EVT_COMMAND_TOOL_CLICKED,
695
+ Wx::CommandEvent],
696
+ EventType['evt_tool_enter', 1,
697
+ Wx::EVT_COMMAND_TOOL_ENTER,
698
+ Wx::CommandEvent],
699
+ EventType['evt_tool_range', 2,
700
+ Wx::EVT_COMMAND_TOOL_CLICKED,
701
+ Wx::CommandEvent],
702
+ EventType['evt_tool_rclicked', 1,
703
+ Wx::EVT_COMMAND_TOOL_RCLICKED,
704
+ Wx::CommandEvent],
705
+ EventType['evt_tool_rclicked_range', 2,
706
+ Wx::EVT_COMMAND_TOOL_RCLICKED,
707
+ Wx::CommandEvent],
708
+ EventType['evt_tree_begin_drag', 1,
709
+ Wx::EVT_COMMAND_TREE_BEGIN_DRAG,
710
+ Wx::TreeEvent],
711
+ EventType['evt_tree_begin_label_edit', 1,
712
+ Wx::EVT_COMMAND_TREE_BEGIN_LABEL_EDIT,
713
+ Wx::TreeEvent],
714
+ EventType['evt_tree_begin_rdrag', 1,
715
+ Wx::EVT_COMMAND_TREE_BEGIN_RDRAG,
716
+ Wx::TreeEvent],
717
+ EventType['evt_tree_delete_item', 1,
718
+ Wx::EVT_COMMAND_TREE_DELETE_ITEM,
719
+ Wx::TreeEvent],
720
+ EventType['evt_tree_end_drag', 1,
721
+ Wx::EVT_COMMAND_TREE_END_DRAG,
722
+ Wx::TreeEvent],
723
+ EventType['evt_tree_end_label_edit', 1,
724
+ Wx::EVT_COMMAND_TREE_END_LABEL_EDIT,
725
+ Wx::TreeEvent],
726
+ EventType['evt_tree_get_info', 1,
727
+ Wx::EVT_COMMAND_TREE_GET_INFO,
728
+ Wx::TreeEvent],
729
+ EventType['evt_tree_item_activated', 1,
730
+ Wx::EVT_COMMAND_TREE_ITEM_ACTIVATED,
731
+ Wx::TreeEvent],
732
+ EventType['evt_tree_item_collapsed', 1,
733
+ Wx::EVT_COMMAND_TREE_ITEM_COLLAPSED,
734
+ Wx::TreeEvent],
735
+ EventType['evt_tree_item_collapsing', 1,
736
+ Wx::EVT_COMMAND_TREE_ITEM_COLLAPSING,
737
+ Wx::TreeEvent],
738
+ EventType['evt_tree_item_expanded', 1,
739
+ Wx::EVT_COMMAND_TREE_ITEM_EXPANDED,
740
+ Wx::TreeEvent],
741
+ EventType['evt_tree_item_expanding', 1,
742
+ Wx::EVT_COMMAND_TREE_ITEM_EXPANDING,
743
+ Wx::TreeEvent],
744
+ EventType['evt_tree_item_middle_click', 1,
745
+ Wx::EVT_COMMAND_TREE_ITEM_MIDDLE_CLICK,
746
+ Wx::TreeEvent],
747
+ EventType['evt_tree_item_right_click', 1,
748
+ Wx::EVT_COMMAND_TREE_ITEM_RIGHT_CLICK,
749
+ Wx::TreeEvent],
750
+ EventType['evt_tree_key_down', 1,
751
+ Wx::EVT_COMMAND_TREE_KEY_DOWN,
752
+ Wx::TreeEvent],
753
+ EventType['evt_tree_sel_changed', 1,
754
+ Wx::EVT_COMMAND_TREE_SEL_CHANGED,
755
+ Wx::TreeEvent],
756
+ EventType['evt_tree_sel_changing', 1,
757
+ Wx::EVT_COMMAND_TREE_SEL_CHANGING,
758
+ Wx::TreeEvent],
759
+ EventType['evt_tree_set_info', 1,
760
+ Wx::EVT_COMMAND_TREE_SET_INFO,
761
+ Wx::TreeEvent],
762
+ EventType['evt_update_ui', 1,
763
+ Wx::EVT_UPDATE_UI,
764
+ Wx::UpdateUIEvent],
765
+ EventType['evt_update_ui_range', 2,
766
+ Wx::EVT_UPDATE_UI,
767
+ Wx::UpdateUIEvent],
768
+ EventType['evt_window_create', 0,
769
+ Wx::EVT_CREATE,
770
+ Wx::WindowCreateEvent],
771
+ EventType['evt_window_destroy', 0,
772
+ Wx::EVT_DESTROY,
773
+ Wx::WindowDestroyEvent],
774
+ EventType['evt_wizard_cancel', 1,
775
+ Wx::EVT_WIZARD_CANCEL,
776
+ Wx::WizardEvent],
777
+ EventType['evt_wizard_finished', 1,
778
+ Wx::EVT_WIZARD_FINISHED,
779
+ Wx::WizardEvent],
780
+ EventType['evt_wizard_help', 1,
781
+ Wx::EVT_WIZARD_HELP,
782
+ Wx::WizardEvent],
783
+ EventType['evt_wizard_page_changed', 1,
784
+ Wx::EVT_WIZARD_PAGE_CHANGED,
785
+ Wx::WizardEvent],
786
+ EventType['evt_wizard_page_changing', 1,
787
+ Wx::EVT_WIZARD_PAGE_CHANGING,
788
+ Wx::WizardEvent]
789
+ ]
790
+
791
+ # Loop over the event definitions to set up two things:
792
+ # 1) A hash mapping Event Type ids to event classes, used when events
793
+ # are fired to quickly look up the right type to yield
794
+ # 2) EvtHandler instance methods like evt_xxx to conveniently set
795
+ # up event handlers
796
+ EVENT_DEFINITIONS.each { | ev_type | register_event_type(ev_type) }
797
+
798
+
799
+ # convenience evt_handler to listen to all mouse events
800
+ def evt_mouse_events(&block)
801
+ evt_left_down(&block)
802
+ evt_left_up(&block)
803
+ evt_middle_down(&block)
804
+ evt_middle_up(&block)
805
+ evt_right_down(&block)
806
+ evt_right_up(&block)
807
+ evt_motion(&block)
808
+ evt_left_dclick(&block)
809
+ evt_middle_dclick(&block)
810
+ evt_right_dclick(&block)
811
+ evt_leave_window(&block)
812
+ evt_enter_window(&block)
813
+ evt_mousewheel(&block)
814
+ end
815
+
816
+ # convenience evt handler to listen to all scrollwin events
817
+ def evt_scrollwin(&block)
818
+ evt_scrollwin_top(&block)
819
+ evt_scrollwin_bottom(&block)
820
+ evt_scrollwin_lineup(&block)
821
+ evt_scrollwin_linedown(&block)
822
+ evt_scrollwin_pageup(&block)
823
+ evt_scrollwin_pagedown(&block)
824
+ evt_scrollwin_thumbtrack(&block)
825
+ evt_scrollwin_thumbrelease(&block)
826
+ end
827
+ end
828
+