wxruby 1.9.2-i686-darwin8.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (214) 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 +39 -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 +30 -0
  9. data/lib/wx/classes/choice.rb +4 -0
  10. data/lib/wx/classes/clientdc.rb +13 -0
  11. data/lib/wx/classes/colour.rb +47 -0
  12. data/lib/wx/classes/combobox.rb +4 -0
  13. data/lib/wx/classes/commandevent.rb +7 -0
  14. data/lib/wx/classes/controlwithitems.rb +10 -0
  15. data/lib/wx/classes/evthandler.rb +884 -0
  16. data/lib/wx/classes/font.rb +118 -0
  17. data/lib/wx/classes/grid.rb +130 -0
  18. data/lib/wx/classes/helpcontroller.rb +5 -0
  19. data/lib/wx/classes/htmlhelpcontroller.rb +5 -0
  20. data/lib/wx/classes/htmlwindow.rb +6 -0
  21. data/lib/wx/classes/icon.rb +14 -0
  22. data/lib/wx/classes/image.rb +14 -0
  23. data/lib/wx/classes/listbox.rb +4 -0
  24. data/lib/wx/classes/listctrl.rb +9 -0
  25. data/lib/wx/classes/locale.rb +28 -0
  26. data/lib/wx/classes/menu.rb +62 -0
  27. data/lib/wx/classes/menuitem.rb +7 -0
  28. data/lib/wx/classes/object.rb +7 -0
  29. data/lib/wx/classes/paintdc.rb +12 -0
  30. data/lib/wx/classes/point.rb +48 -0
  31. data/lib/wx/classes/previewframe.rb +13 -0
  32. data/lib/wx/classes/rect.rb +5 -0
  33. data/lib/wx/classes/size.rb +49 -0
  34. data/lib/wx/classes/styledtextctrl.rb +92 -0
  35. data/lib/wx/classes/textctrl.rb +14 -0
  36. data/lib/wx/classes/texturlevent.rb +6 -0
  37. data/lib/wx/classes/timer.rb +69 -0
  38. data/lib/wx/classes/treectrl.rb +18 -0
  39. data/lib/wx/classes/window.rb +49 -0
  40. data/lib/wx/classes/xmlresource.rb +16 -0
  41. data/lib/wx/keyword_ctors.rb +205 -0
  42. data/lib/wx/keyword_defs.rb +465 -0
  43. data/lib/wx/version.rb +3 -0
  44. data/lib/wxruby2.bundle +0 -0
  45. data/samples/SAMPLES-LICENSE.TXT +18 -0
  46. data/samples/aui/aui.rb +1353 -0
  47. data/samples/bigdemo/About.rbw +39 -0
  48. data/samples/bigdemo/ColorPanel.rbw +25 -0
  49. data/samples/bigdemo/GridSimple.rbw +80 -0
  50. data/samples/bigdemo/MDIDemo.rbw +59 -0
  51. data/samples/bigdemo/PopupMenu.rbw +151 -0
  52. data/samples/bigdemo/ShapedWindow.rbw +135 -0
  53. data/samples/bigdemo/Sizers.rbw +545 -0
  54. data/samples/bigdemo/bigdemo.rb +826 -0
  55. data/samples/bigdemo/demoTemplate.rbw +37 -0
  56. data/samples/bigdemo/helpfile.htb +0 -0
  57. data/samples/bigdemo/icons/Test 015.jpg +0 -0
  58. data/samples/bigdemo/icons/Test 015.png +0 -0
  59. data/samples/bigdemo/icons/choice.bmp +0 -0
  60. data/samples/bigdemo/icons/choice.xpm +27 -0
  61. data/samples/bigdemo/icons/combo.bmp +0 -0
  62. data/samples/bigdemo/icons/combo.xpm +27 -0
  63. data/samples/bigdemo/icons/copy.xpm +25 -0
  64. data/samples/bigdemo/icons/cut.xpm +24 -0
  65. data/samples/bigdemo/icons/gauge.bmp +0 -0
  66. data/samples/bigdemo/icons/gauge.xpm +27 -0
  67. data/samples/bigdemo/icons/help.xpm +25 -0
  68. data/samples/bigdemo/icons/list.bmp +0 -0
  69. data/samples/bigdemo/icons/list.xpm +27 -0
  70. data/samples/bigdemo/icons/mondrian.ico +0 -0
  71. data/samples/bigdemo/icons/mondrian.xpm +44 -0
  72. data/samples/bigdemo/icons/new.xpm +24 -0
  73. data/samples/bigdemo/icons/ogl.ico +0 -0
  74. data/samples/bigdemo/icons/ogl.xpm +45 -0
  75. data/samples/bigdemo/icons/open.xpm +26 -0
  76. data/samples/bigdemo/icons/paste.bmp +0 -0
  77. data/samples/bigdemo/icons/paste.xpm +38 -0
  78. data/samples/bigdemo/icons/pointy.png +0 -0
  79. data/samples/bigdemo/icons/preview.xpm +26 -0
  80. data/samples/bigdemo/icons/print.xpm +26 -0
  81. data/samples/bigdemo/icons/radio.bmp +0 -0
  82. data/samples/bigdemo/icons/radio.xpm +27 -0
  83. data/samples/bigdemo/icons/robert.xpm +415 -0
  84. data/samples/bigdemo/icons/ruby.png +0 -0
  85. data/samples/bigdemo/icons/sashtest.ico +0 -0
  86. data/samples/bigdemo/icons/save.xpm +25 -0
  87. data/samples/bigdemo/icons/smiles.bmp +0 -0
  88. data/samples/bigdemo/icons/smiles.xpm +39 -0
  89. data/samples/bigdemo/icons/smiley.ico +0 -0
  90. data/samples/bigdemo/icons/smiley.xpm +42 -0
  91. data/samples/bigdemo/icons/stattext.xpm +24 -0
  92. data/samples/bigdemo/icons/test2.bmp +0 -0
  93. data/samples/bigdemo/icons/test2.png +0 -0
  94. data/samples/bigdemo/icons/test2.xpm +79 -0
  95. data/samples/bigdemo/icons/text.bmp +0 -0
  96. data/samples/bigdemo/icons/text.xpm +27 -0
  97. data/samples/bigdemo/icons/tog1.bmp +0 -0
  98. data/samples/bigdemo/icons/tog1.xpm +38 -0
  99. data/samples/bigdemo/icons/tog2.bmp +0 -0
  100. data/samples/bigdemo/icons/tog2.xpm +38 -0
  101. data/samples/bigdemo/icons/wxwin.ico +0 -0
  102. data/samples/bigdemo/icons/wxwin16x16.png +0 -0
  103. data/samples/bigdemo/icons/wxwin16x16.xpm +25 -0
  104. data/samples/bigdemo/icons/wxwin32x32.png +0 -0
  105. data/samples/bigdemo/icons/wxwin48x48.png +0 -0
  106. data/samples/bigdemo/run.rb +94 -0
  107. data/samples/bigdemo/tips.txt +7 -0
  108. data/samples/bigdemo/utils.rb +12 -0
  109. data/samples/bigdemo/wxArtProvider.rbw +285 -0
  110. data/samples/bigdemo/wxBitmapButton.rbw +64 -0
  111. data/samples/bigdemo/wxButton.rbw +66 -0
  112. data/samples/bigdemo/wxCalendarCtrl.rbw +72 -0
  113. data/samples/bigdemo/wxCheckBox.rbw +52 -0
  114. data/samples/bigdemo/wxCheckListBox.rbw +77 -0
  115. data/samples/bigdemo/wxChoice.rbw +49 -0
  116. data/samples/bigdemo/wxChoicebook.rbw +80 -0
  117. data/samples/bigdemo/wxColourDialog.rbw +34 -0
  118. data/samples/bigdemo/wxComboBox.rbw +79 -0
  119. data/samples/bigdemo/wxCursor.rbw +140 -0
  120. data/samples/bigdemo/wxDialog.rbw +92 -0
  121. data/samples/bigdemo/wxDirDialog.rbw +32 -0
  122. data/samples/bigdemo/wxDragImage.rbw +74 -0
  123. data/samples/bigdemo/wxFileDialog.rbw +39 -0
  124. data/samples/bigdemo/wxFileDialog_Save.rbw +38 -0
  125. data/samples/bigdemo/wxFindReplaceDialog.rbw +85 -0
  126. data/samples/bigdemo/wxFontDialog.rbw +176 -0
  127. data/samples/bigdemo/wxFrame.rbw +55 -0
  128. data/samples/bigdemo/wxGauge.rbw +73 -0
  129. data/samples/bigdemo/wxGenericDirCtrl.rbw +78 -0
  130. data/samples/bigdemo/wxGrid.rbw +68 -0
  131. data/samples/bigdemo/wxHtmlHelpController.rbw +57 -0
  132. data/samples/bigdemo/wxListBox.rbw +142 -0
  133. data/samples/bigdemo/wxListCtrl_virtual.rbw +109 -0
  134. data/samples/bigdemo/wxMDIWindows.rbw +52 -0
  135. data/samples/bigdemo/wxMenu.rbw +238 -0
  136. data/samples/bigdemo/wxMessageDialog.rbw +30 -0
  137. data/samples/bigdemo/wxMiniFrame.rbw +74 -0
  138. data/samples/bigdemo/wxMultipleChoiceDialog.rbw +34 -0
  139. data/samples/bigdemo/wxNotebook.rbw +138 -0
  140. data/samples/bigdemo/wxProgressDialog.rbw +45 -0
  141. data/samples/bigdemo/wxRadioBox.rbw +74 -0
  142. data/samples/bigdemo/wxRadioButton.rbw +127 -0
  143. data/samples/bigdemo/wxSashWindow.rbw +155 -0
  144. data/samples/bigdemo/wxScrolledMessageDialog.rbw +59 -0
  145. data/samples/bigdemo/wxScrolledWindow.rbw +201 -0
  146. data/samples/bigdemo/wxSingleChoiceDialog.rbw +35 -0
  147. data/samples/bigdemo/wxSlider.rbw +44 -0
  148. data/samples/bigdemo/wxSpinButton.rbw +52 -0
  149. data/samples/bigdemo/wxSpinCtrl.rbw +53 -0
  150. data/samples/bigdemo/wxSplitterWindow.rbw +65 -0
  151. data/samples/bigdemo/wxStaticBitmap.rbw +53 -0
  152. data/samples/bigdemo/wxStaticText.rbw +57 -0
  153. data/samples/bigdemo/wxStatusBar.rbw +128 -0
  154. data/samples/bigdemo/wxTextCtrl.rbw +151 -0
  155. data/samples/bigdemo/wxTextEntryDialog.rbw +34 -0
  156. data/samples/bigdemo/wxToggleButton.rbw +51 -0
  157. data/samples/bigdemo/wxToolBar.rbw +133 -0
  158. data/samples/bigdemo/wxTreeCtrl.rbw +192 -0
  159. data/samples/calendar/calendar.rb +275 -0
  160. data/samples/caret/caret.rb +286 -0
  161. data/samples/caret/mondrian.xpm +44 -0
  162. data/samples/controls/controls.rb +1140 -0
  163. data/samples/controls/get_item_sample.rb +87 -0
  164. data/samples/controls/icons/choice.xpm +27 -0
  165. data/samples/controls/icons/combo.xpm +27 -0
  166. data/samples/controls/icons/gauge.xpm +27 -0
  167. data/samples/controls/icons/list.xpm +27 -0
  168. data/samples/controls/icons/radio.xpm +27 -0
  169. data/samples/controls/icons/stattext.xpm +24 -0
  170. data/samples/controls/icons/text.xpm +27 -0
  171. data/samples/controls/mondrian.ico +0 -0
  172. data/samples/controls/mondrian.xpm +44 -0
  173. data/samples/controls/test2.bmp +0 -0
  174. data/samples/dialogs/dialogs.rb +724 -0
  175. data/samples/dialogs/tips.txt +18 -0
  176. data/samples/etc/activation.rb +108 -0
  177. data/samples/etc/choice.rb +72 -0
  178. data/samples/etc/miniframe.rb +84 -0
  179. data/samples/etc/sash.rb +135 -0
  180. data/samples/etc/scrollwin.rb +116 -0
  181. data/samples/etc/system_settings.rb +258 -0
  182. data/samples/etc/threaded.rb +81 -0
  183. data/samples/etc/wizard.rb +79 -0
  184. data/samples/event/event.rb +184 -0
  185. data/samples/grid/grid.rb +201 -0
  186. data/samples/html/html.rb +264 -0
  187. data/samples/images/Thumbs.db +0 -0
  188. data/samples/images/images.rb +48 -0
  189. data/samples/images/paperclip.png +0 -0
  190. data/samples/listbook/listbook.rb +181 -0
  191. data/samples/listbook/listbook.xrc +370 -0
  192. data/samples/mdi/mdi.rb +87 -0
  193. data/samples/minimal/minimal.rb +85 -0
  194. data/samples/minimal/mondrian.ico +0 -0
  195. data/samples/minimal/mondrian.png +0 -0
  196. data/samples/minimal/nothing.rb +21 -0
  197. data/samples/printing/mondrian.ico +0 -0
  198. data/samples/printing/mondrian.xpm +44 -0
  199. data/samples/printing/printing.rb +484 -0
  200. data/samples/text/mondrian.ico +0 -0
  201. data/samples/text/mondrian.xpm +44 -0
  202. data/samples/text/scintilla.rb +174 -0
  203. data/samples/text/textctrl.rb +124 -0
  204. data/samples/text/unicode.rb +238 -0
  205. data/samples/text/utf8.txt +15 -0
  206. data/samples/treectrl/icon1.xpm +79 -0
  207. data/samples/treectrl/icon2.xpm +53 -0
  208. data/samples/treectrl/icon3.xpm +79 -0
  209. data/samples/treectrl/icon4.xpm +43 -0
  210. data/samples/treectrl/icon5.xpm +79 -0
  211. data/samples/treectrl/treectrl.rb +1181 -0
  212. data/samples/xrc/samples.xrc +46 -0
  213. data/samples/xrc/xrc_sample.rb +107 -0
  214. metadata +280 -0
@@ -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 = Wx::MemoryDC.new
19
+ dc.select_object(self)
20
+ yield dc
21
+ dc.select_object( Wx::NULL_BITMAP )
22
+ end
23
+ end
@@ -0,0 +1,30 @@
1
+ # Display a listbox with a checkbox for each item
2
+ class Wx::CheckListBox < Wx::ListBox
3
+
4
+ # According to the wxWidgets documentation: "wxCheckListBox uses
5
+ # client data in its implementation, and therefore this is not
6
+ # available to the application."
7
+ #
8
+ # So, rather than crashing, raise an Exception if this is attempted
9
+ def append(*args)
10
+ if args.length == 2
11
+ Kernel.raise "Cannot use item data with Wx::CheckListBox"
12
+ else
13
+ super
14
+ end
15
+ end
16
+
17
+ # As above
18
+ def insert(*args)
19
+ if args.length == 3
20
+ Kernel.raise "Cannot use item data with Wx::CheckListBox"
21
+ else
22
+ super
23
+ end
24
+ end
25
+
26
+ # As above
27
+ def set_item_data(index, data)
28
+ Kernel.raise "Cannot use item data with Wx::CheckListBox"
29
+ end
30
+ 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
+ define_method(:initialize) do | *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,7 @@
1
+ # Class representing interactions with controls such as ListBox
2
+ class Wx::CommandEvent
3
+ # get_int and get_selection are already synonyms, but neither name
4
+ # accurately describes what the method does as the event may be a
5
+ # (de)selection or a check in a CheckListBox
6
+ alias :get_index :get_int
7
+ end
@@ -0,0 +1,10 @@
1
+ # Superclass of a variety of controls that display lists of items (eg
2
+ # Choice, ListBox, CheckListBox)
3
+ class Wx::ControlWithItems
4
+ # Make these ruby enumerables so find, find_all, map etc are available
5
+ include Enumerable
6
+ # Passes each valid item index into the passed block
7
+ def each
8
+ 0.upto(count - 1) { | i | yield i }
9
+ end
10
+ end
@@ -0,0 +1,884 @@
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
+
46
+ def self.event_name_for_type(name)
47
+ EVENT_NAME_TYPE_MAP.index(name)
48
+ end
49
+
50
+ # Public method to register the mapping of a custom event type
51
+ # +konstant+ (which should be a unique integer; one will be created if
52
+ # not supplied) to a custom event class +klass+. If +meth+ and +arity+
53
+ # are given, a convenience evt_handler method called +meth+ will be
54
+ # created, which accepts +arity+ arguments.
55
+ def self.register_class( klass, konstant = nil,
56
+ meth = nil, arity = nil)
57
+ konstant ||= Wx::Event.new_event_type
58
+ unless klass < Wx::Event
59
+ Kernel.raise TypeError, "Event class should be a subclass of Wx::Event"
60
+ end
61
+ ev_type = EventType.new(meth, arity, konstant, klass)
62
+ register_event_type(ev_type)
63
+ return konstant
64
+ end
65
+
66
+ # Registers the event type +ev_type+, which should be an instance of
67
+ # the Struct class +Wx::EvtHandler::EventType+. This sets up the
68
+ # mapping of events of that type (identified by integer id) to the
69
+ # appropriate ruby event class, and defines a convenience evt_xxx
70
+ # instance method in the class EvtHandler.
71
+ def self.register_event_type(ev_type)
72
+ # set up the event type mapping
73
+ EVENT_TYPE_CLASS_MAP[ev_type.const] = ev_type.evt_class
74
+ EVENT_NAME_TYPE_MAP[ev_type.name.intern] = ev_type.const
75
+
76
+ unless ev_type.arity and ev_type.name
77
+ return
78
+ end
79
+
80
+ # set up the evt_xxx method
81
+ case ev_type.arity
82
+ when 0 # events without an id
83
+ class_eval %Q|
84
+ def #{ev_type.name}(meth = nil, &block)
85
+ handler = acquire_handler(meth, block)
86
+ connect(Wx::ID_ANY, Wx::ID_ANY, #{ev_type.const}, &handler)
87
+ end |
88
+ when 1 # events with an id
89
+ class_eval %Q|
90
+ def #{ev_type.name}(id, meth = nil, &block)
91
+ handler = acquire_handler(meth, block)
92
+ id = acquire_id(id)
93
+ connect(id, Wx::ID_ANY, #{ev_type.const}, &handler)
94
+ end |
95
+ when 2 # events with id range
96
+ class_eval %Q|
97
+ def #{ev_type.name}(first_id, last_id, meth = nil, &block)
98
+ handler = acquire_handler(meth, block)
99
+ first_id = acquire_id(first_id)
100
+ last_id = acquire_id(last_id)
101
+ connect( first_id, last_id, #{ev_type.const}, &handler)
102
+ end |
103
+ end
104
+ end
105
+
106
+ # Not for external use; determines whether to use a block or call a
107
+ # method in self to handle an event, passed to connect. Makes evt_xxx
108
+ # liberal about what it accepts - aside from a block, it can be a
109
+ # method name (as Symbol or String), a (bound) method object, or a
110
+ # Proc object
111
+ def acquire_handler(meth, block)
112
+ if block and not meth
113
+ return block
114
+ elsif meth and not block
115
+ h_meth = case meth
116
+ when Symbol, String : self.method(meth)
117
+ when Proc : meth
118
+ when Method : meth.to_proc
119
+ end
120
+ if h_meth.arity == 1
121
+ return lambda { | evt | h_meth.call(evt) }
122
+ else
123
+ return lambda { h_meth.call }
124
+ end
125
+ else
126
+ Kernel.raise ArgumentError,
127
+ "Specify event handler with a method, name, proc OR block"
128
+ caller
129
+ end
130
+ end
131
+
132
+ # Not for external use; acquires an id either from an explicit Fixnum
133
+ # parameter or by calling the wx_id method of a passed Window.
134
+ def acquire_id(window_or_id)
135
+ case window_or_id
136
+ when Fixnum : window_or_id
137
+ when Wx::Window, Wx::MenuItem : window_or_id.wx_id
138
+ else Kernel.raise ArgumentError,
139
+ "Must specify Wx::Window event source or its Wx id, " +
140
+ "not '#{window_or_id.inspect}'",
141
+ caller
142
+ end
143
+ end
144
+ private :acquire_id, :acquire_handler
145
+
146
+ # Definitions for all event types that are part by core wxRuby. Events
147
+ # that are mapped to class Wx::Event are TODO as they are not
148
+ # currently wrapped by the correct class. All StyledTextCtrl
149
+ # (Scintilla) events with prefix EVT_STC are dealt with in the
150
+ # separate styledtextctrl.rb file.
151
+ EVENT_DEFINITIONS = [
152
+ EventType['evt_activate', 0,
153
+ Wx::EVT_ACTIVATE,
154
+ Wx::ActivateEvent],
155
+ EventType['evt_activate_app', 0,
156
+ Wx::EVT_ACTIVATE_APP,
157
+ Wx::ActivateEvent],
158
+ EventType['evt_auinotebook_allow_dnd', 1,
159
+ Wx::EVT_COMMAND_AUINOTEBOOK_ALLOW_DND,
160
+ Wx::AuiNotebookEvent],
161
+ EventType['evt_auinotebook_begin_drag', 1,
162
+ Wx::EVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG,
163
+ Wx::AuiNotebookEvent],
164
+ EventType['evt_auinotebook_button', 1,
165
+ Wx::EVT_COMMAND_AUINOTEBOOK_BUTTON,
166
+ Wx::AuiNotebookEvent],
167
+ EventType['evt_auinotebook_drag_motion', 1,
168
+ Wx::EVT_COMMAND_AUINOTEBOOK_DRAG_MOTION,
169
+ Wx::AuiNotebookEvent],
170
+ EventType['evt_auinotebook_end_drag', 1,
171
+ Wx::EVT_COMMAND_AUINOTEBOOK_END_DRAG,
172
+ Wx::AuiNotebookEvent],
173
+ EventType['evt_auinotebook_page_changed', 1,
174
+ Wx::EVT_COMMAND_AUINOTEBOOK_PAGE_CHANGED,
175
+ Wx::AuiNotebookEvent],
176
+ EventType['evt_auinotebook_page_changing', 1,
177
+ Wx::EVT_COMMAND_AUINOTEBOOK_PAGE_CHANGING,
178
+ Wx::AuiNotebookEvent],
179
+ EventType['evt_auinotebook_page_close', 1,
180
+ Wx::EVT_COMMAND_AUINOTEBOOK_PAGE_CLOSE,
181
+ Wx::AuiNotebookEvent],
182
+ EventType['evt_aui_find_manager', 0,
183
+ Wx::EVT_AUI_FIND_MANAGER,
184
+ Wx::AuiManagerEvent],
185
+ EventType['evt_aui_pane_button', 0,
186
+ Wx::EVT_AUI_PANE_BUTTON,
187
+ Wx::AuiManagerEvent],
188
+ EventType['evt_aui_pane_close', 0,
189
+ Wx::EVT_AUI_PANE_CLOSE,
190
+ Wx::AuiManagerEvent],
191
+ EventType['evt_aui_pane_maximize', 0,
192
+ Wx::EVT_AUI_PANE_MAXIMIZE,
193
+ Wx::AuiManagerEvent],
194
+ EventType['evt_aui_pane_restore', 0,
195
+ Wx::EVT_AUI_PANE_RESTORE,
196
+ Wx::AuiManagerEvent],
197
+ EventType['evt_aui_render', 0,
198
+ Wx::EVT_AUI_RENDER,
199
+ Wx::AuiManagerEvent],
200
+ EventType['evt_button', 1,
201
+ Wx::EVT_COMMAND_BUTTON_CLICKED,
202
+ Wx::CommandEvent],
203
+ EventType['evt_calculate_layout', 0,
204
+ Wx::EVT_CALCULATE_LAYOUT,
205
+ Wx::Event],
206
+ EventType['evt_calendar', 1,
207
+ Wx::EVT_CALENDAR_DOUBLECLICKED,
208
+ Wx::CalendarEvent],
209
+ EventType['evt_calendar_day', 1,
210
+ Wx::EVT_CALENDAR_DAY_CHANGED,
211
+ Wx::CalendarEvent],
212
+ EventType['evt_calendar_month', 1,
213
+ Wx::EVT_CALENDAR_MONTH_CHANGED,
214
+ Wx::CalendarEvent],
215
+ EventType['evt_calendar_sel_changed', 1,
216
+ Wx::EVT_CALENDAR_SEL_CHANGED,
217
+ Wx::CalendarEvent],
218
+ EventType['evt_calendar_weekday_clicked', 1,
219
+ Wx::EVT_CALENDAR_WEEKDAY_CLICKED,
220
+ Wx::CalendarEvent],
221
+ EventType['evt_calendar_year', 1,
222
+ Wx::EVT_CALENDAR_YEAR_CHANGED,
223
+ Wx::CalendarEvent],
224
+ EventType['evt_char', 0,
225
+ Wx::EVT_CHAR,
226
+ Wx::KeyEvent],
227
+ EventType['evt_char_hook', 0,
228
+ Wx::EVT_CHAR_HOOK,
229
+ Wx::KeyEvent],
230
+ EventType['evt_checkbox', 1,
231
+ Wx::EVT_COMMAND_CHECKBOX_CLICKED,
232
+ Wx::CommandEvent],
233
+ EventType['evt_checklistbox', 1,
234
+ Wx::EVT_COMMAND_CHECKLISTBOX_TOGGLED,
235
+ Wx::CommandEvent],
236
+ EventType['evt_child_focus', 0,
237
+ Wx::EVT_CHILD_FOCUS,
238
+ Wx::ChildFocusEvent],
239
+ EventType['evt_choice', 1,
240
+ Wx::EVT_COMMAND_CHOICE_SELECTED,
241
+ Wx::CommandEvent],
242
+ EventType['evt_choicebook_page_changed', 1,
243
+ Wx::EVT_COMMAND_CHOICEBOOK_PAGE_CHANGED,
244
+ Wx::ChoicebookEvent],
245
+ EventType['evt_choicebook_page_changing', 1,
246
+ Wx::EVT_COMMAND_CHOICEBOOK_PAGE_CHANGING,
247
+ Wx::ChoicebookEvent],
248
+ EventType['evt_close', 0,
249
+ Wx::EVT_CLOSE_WINDOW,
250
+ Wx::CloseEvent],
251
+ EventType['evt_collapsiblepane_changed', 1,
252
+ Wx::EVT_COMMAND_COLLPANE_CHANGED,
253
+ Wx::CollapsiblePaneEvent],
254
+ EventType['evt_combobox', 1,
255
+ Wx::EVT_COMMAND_COMBOBOX_SELECTED,
256
+ Wx::CommandEvent],
257
+ EventType['evt_command', 0,
258
+ Wx::EVT_NULL,
259
+ Wx::Event],
260
+ EventType['evt_command_enter', 1,
261
+ Wx::EVT_COMMAND_ENTER,
262
+ Wx::Event],
263
+ EventType['evt_command_kill_focus', 1,
264
+ Wx::EVT_COMMAND_KILL_FOCUS,
265
+ Wx::Event],
266
+ EventType['evt_command_left_click', 1,
267
+ Wx::EVT_COMMAND_LEFT_CLICK,
268
+ Wx::Event],
269
+ EventType['evt_command_left_dclick', 1,
270
+ Wx::EVT_COMMAND_LEFT_DCLICK,
271
+ Wx::Event],
272
+ EventType['evt_command_range', 2,
273
+ Wx::EVT_NULL,
274
+ Wx::Event],
275
+ EventType['evt_command_right_click', 1,
276
+ Wx::EVT_COMMAND_RIGHT_CLICK,
277
+ Wx::Event],
278
+ EventType['evt_command_set_focus', 1,
279
+ Wx::EVT_COMMAND_SET_FOCUS,
280
+ Wx::Event],
281
+ EventType['evt_context_menu', 0,
282
+ Wx::EVT_CONTEXT_MENU,
283
+ Wx::ContextMenuEvent],
284
+ EventType['evt_drop_files', 0,
285
+ Wx::EVT_DROP_FILES,
286
+ Wx::Event],
287
+ EventType['evt_end_process', 1,
288
+ Wx::EVT_END_PROCESS,
289
+ Wx::Event],
290
+ EventType['evt_end_session', 0,
291
+ Wx::EVT_END_SESSION,
292
+ Wx::Event],
293
+ EventType['evt_enter_window', 0,
294
+ Wx::EVT_ENTER_WINDOW,
295
+ Wx::MouseEvent],
296
+ EventType['evt_erase_background', 0,
297
+ Wx::EVT_ERASE_BACKGROUND,
298
+ Wx::EraseEvent],
299
+ EventType['evt_find', 1,
300
+ Wx::EVT_COMMAND_FIND,
301
+ Wx::FindDialogEvent],
302
+ EventType['evt_find_close', 1,
303
+ Wx::EVT_COMMAND_FIND_CLOSE,
304
+ Wx::FindDialogEvent],
305
+ EventType['evt_find_next', 1,
306
+ Wx::EVT_COMMAND_FIND_NEXT,
307
+ Wx::FindDialogEvent],
308
+ EventType['evt_find_replace', 1,
309
+ Wx::EVT_COMMAND_FIND_REPLACE,
310
+ Wx::FindDialogEvent],
311
+ EventType['evt_find_replace_all', 1,
312
+ Wx::EVT_COMMAND_FIND_REPLACE_ALL,
313
+ Wx::FindDialogEvent],
314
+ EventType['evt_grid_cell_change', 0,
315
+ Wx::EVT_GRID_CELL_CHANGE,
316
+ Wx::GridEvent],
317
+ EventType['evt_grid_cell_left_click', 0,
318
+ Wx::EVT_GRID_CELL_LEFT_CLICK,
319
+ Wx::GridEvent],
320
+ EventType['evt_grid_cell_left_dclick', 0,
321
+ Wx::EVT_GRID_CELL_LEFT_DCLICK,
322
+ Wx::GridEvent],
323
+ EventType['evt_grid_cell_right_click', 0,
324
+ Wx::EVT_GRID_CELL_RIGHT_CLICK,
325
+ Wx::GridEvent],
326
+ EventType['evt_grid_cell_right_dclick', 0,
327
+ Wx::EVT_GRID_CELL_RIGHT_DCLICK,
328
+ Wx::GridEvent],
329
+ EventType['evt_grid_cmd_cell_change', 1,
330
+ Wx::EVT_GRID_CELL_CHANGE,
331
+ Wx::GridEvent],
332
+ EventType['evt_grid_cmd_cell_left_click', 1,
333
+ Wx::EVT_GRID_CELL_LEFT_CLICK,
334
+ Wx::GridEvent],
335
+ EventType['evt_grid_cmd_cell_left_dclick', 1,
336
+ Wx::EVT_GRID_CELL_LEFT_DCLICK,
337
+ Wx::GridEvent],
338
+ EventType['evt_grid_cmd_cell_right_click', 1,
339
+ Wx::EVT_GRID_CELL_RIGHT_CLICK,
340
+ Wx::GridEvent],
341
+ EventType['evt_grid_cmd_cell_right_dclick', 1,
342
+ Wx::EVT_GRID_CELL_RIGHT_DCLICK,
343
+ Wx::GridEvent],
344
+ EventType['evt_grid_cmd_col_size', 1,
345
+ Wx::EVT_GRID_COL_SIZE,
346
+ Wx::GridSizeEvent],
347
+ EventType['evt_grid_cmd_editor_created', 1,
348
+ Wx::EVT_GRID_EDITOR_CREATED,
349
+ Wx::GridEditorCreatedEvent],
350
+ EventType['evt_grid_cmd_editor_hidden', 1,
351
+ Wx::EVT_GRID_EDITOR_HIDDEN,
352
+ Wx::GridEvent],
353
+ EventType['evt_grid_cmd_editor_shown', 1,
354
+ Wx::EVT_GRID_EDITOR_SHOWN,
355
+ Wx::GridEvent],
356
+ EventType['evt_grid_cmd_label_left_click', 1,
357
+ Wx::EVT_GRID_LABEL_LEFT_CLICK,
358
+ Wx::GridEvent],
359
+ EventType['evt_grid_cmd_label_left_dclick', 1,
360
+ Wx::EVT_GRID_LABEL_LEFT_DCLICK,
361
+ Wx::GridEvent],
362
+ EventType['evt_grid_cmd_label_right_click', 1,
363
+ Wx::EVT_GRID_LABEL_RIGHT_CLICK,
364
+ Wx::GridEvent],
365
+ EventType['evt_grid_cmd_label_right_dclick', 1,
366
+ Wx::EVT_GRID_LABEL_RIGHT_DCLICK,
367
+ Wx::GridEvent],
368
+ EventType['evt_grid_cmd_range_select', 1,
369
+ Wx::EVT_GRID_RANGE_SELECT,
370
+ Wx::GridRangeSelectEvent],
371
+ EventType['evt_grid_cmd_row_size', 1,
372
+ Wx::EVT_GRID_ROW_SIZE,
373
+ Wx::GridSizeEvent],
374
+ EventType['evt_grid_cmd_select_cell', 1,
375
+ Wx::EVT_GRID_SELECT_CELL,
376
+ Wx::GridEvent],
377
+ EventType['evt_grid_col_size', 0,
378
+ Wx::EVT_GRID_COL_SIZE,
379
+ Wx::GridSizeEvent],
380
+ EventType['evt_grid_editor_created', 0,
381
+ Wx::EVT_GRID_EDITOR_CREATED,
382
+ Wx::GridEditorCreatedEvent],
383
+ EventType['evt_grid_editor_hidden', 0,
384
+ Wx::EVT_GRID_EDITOR_HIDDEN,
385
+ Wx::GridEvent],
386
+ EventType['evt_grid_editor_shown', 0,
387
+ Wx::EVT_GRID_EDITOR_SHOWN,
388
+ Wx::GridEvent],
389
+ EventType['evt_grid_label_left_click', 0,
390
+ Wx::EVT_GRID_LABEL_LEFT_CLICK,
391
+ Wx::GridEvent],
392
+ EventType['evt_grid_label_left_dclick', 0,
393
+ Wx::EVT_GRID_LABEL_LEFT_DCLICK,
394
+ Wx::GridEvent],
395
+ EventType['evt_grid_label_right_click', 0,
396
+ Wx::EVT_GRID_LABEL_RIGHT_CLICK,
397
+ Wx::GridEvent],
398
+ EventType['evt_grid_label_right_dclick', 0,
399
+ Wx::EVT_GRID_LABEL_RIGHT_DCLICK,
400
+ Wx::GridEvent],
401
+ EventType['evt_grid_range_select', 0,
402
+ Wx::EVT_GRID_RANGE_SELECT,
403
+ Wx::GridRangeSelectEvent],
404
+ EventType['evt_grid_row_size', 0,
405
+ Wx::EVT_GRID_ROW_SIZE,
406
+ Wx::GridSizeEvent],
407
+ EventType['evt_grid_select_cell', 0,
408
+ Wx::EVT_GRID_SELECT_CELL,
409
+ Wx::GridEvent],
410
+ EventType['evt_help', 1,
411
+ Wx::EVT_HELP,
412
+ Wx::Event],
413
+ EventType['evt_help_range', 2,
414
+ Wx::EVT_HELP,
415
+ Wx::Event],
416
+ EventType['evt_hyperlink', 1,
417
+ Wx::EVT_COMMAND_HYPERLINK,
418
+ Wx::HyperlinkEvent],
419
+ EventType['evt_iconize', 0,
420
+ Wx::EVT_ICONIZE,
421
+ Wx::IconizeEvent],
422
+ EventType['evt_idle', 0,
423
+ Wx::EVT_IDLE,
424
+ Wx::IdleEvent],
425
+ EventType['evt_init_dialog', 0,
426
+ Wx::EVT_INIT_DIALOG,
427
+ Wx::Event],
428
+ EventType['evt_joy_button_down', 0,
429
+ Wx::EVT_JOY_BUTTON_DOWN,
430
+ Wx::Event],
431
+ EventType['evt_joy_button_up', 0,
432
+ Wx::EVT_JOY_BUTTON_UP,
433
+ Wx::Event],
434
+ EventType['evt_joy_move', 0,
435
+ Wx::EVT_JOY_MOVE,
436
+ Wx::Event],
437
+ EventType['evt_joy_zmove', 0,
438
+ Wx::EVT_JOY_ZMOVE,
439
+ Wx::Event],
440
+ EventType['evt_key_down', 0,
441
+ Wx::EVT_KEY_DOWN,
442
+ Wx::KeyEvent],
443
+ EventType['evt_key_up', 0,
444
+ Wx::EVT_KEY_UP,
445
+ Wx::KeyEvent],
446
+ EventType['evt_kill_focus', 0,
447
+ Wx::EVT_KILL_FOCUS,
448
+ Wx::FocusEvent],
449
+ EventType['evt_leave_window', 0,
450
+ Wx::EVT_LEAVE_WINDOW,
451
+ Wx::MouseEvent],
452
+ EventType['evt_left_dclick', 0,
453
+ Wx::EVT_LEFT_DCLICK,
454
+ Wx::MouseEvent],
455
+ EventType['evt_left_down', 0,
456
+ Wx::EVT_LEFT_DOWN,
457
+ Wx::MouseEvent],
458
+ EventType['evt_left_up', 0,
459
+ Wx::EVT_LEFT_UP,
460
+ Wx::MouseEvent],
461
+ EventType['evt_listbook_page_changed', 1,
462
+ Wx::EVT_COMMAND_LISTBOOK_PAGE_CHANGED,
463
+ Wx::ListbookEvent],
464
+ EventType['evt_listbook_page_changing', 1,
465
+ Wx::EVT_COMMAND_LISTBOOK_PAGE_CHANGING,
466
+ Wx::ListbookEvent],
467
+ EventType['evt_listbox', 1,
468
+ Wx::EVT_COMMAND_LISTBOX_SELECTED,
469
+ Wx::CommandEvent],
470
+ EventType['evt_listbox_dclick', 1,
471
+ Wx::EVT_COMMAND_LISTBOX_DOUBLECLICKED,
472
+ Wx::CommandEvent],
473
+ EventType['evt_list_begin_drag', 1,
474
+ Wx::EVT_COMMAND_LIST_BEGIN_DRAG,
475
+ Wx::ListEvent],
476
+ EventType['evt_list_begin_label_edit', 1,
477
+ Wx::EVT_COMMAND_LIST_BEGIN_LABEL_EDIT,
478
+ Wx::ListEvent],
479
+ EventType['evt_list_begin_rdrag', 1,
480
+ Wx::EVT_COMMAND_LIST_BEGIN_RDRAG,
481
+ Wx::ListEvent],
482
+ EventType['evt_list_cache_hint', 1,
483
+ Wx::EVT_COMMAND_LIST_CACHE_HINT,
484
+ Wx::ListEvent],
485
+ EventType['evt_list_col_begin_drag', 1,
486
+ Wx::EVT_COMMAND_LIST_COL_BEGIN_DRAG,
487
+ Wx::ListEvent],
488
+ EventType['evt_list_col_click', 1,
489
+ Wx::EVT_COMMAND_LIST_COL_CLICK,
490
+ Wx::ListEvent],
491
+ EventType['evt_list_col_dragging', 1,
492
+ Wx::EVT_COMMAND_LIST_COL_DRAGGING,
493
+ Wx::ListEvent],
494
+ EventType['evt_list_col_end_drag', 1,
495
+ Wx::EVT_COMMAND_LIST_COL_END_DRAG,
496
+ Wx::ListEvent],
497
+ EventType['evt_list_col_right_click', 1,
498
+ Wx::EVT_COMMAND_LIST_COL_RIGHT_CLICK,
499
+ Wx::ListEvent],
500
+ EventType['evt_list_delete_all_items', 1,
501
+ Wx::EVT_COMMAND_LIST_DELETE_ALL_ITEMS,
502
+ Wx::ListEvent],
503
+ EventType['evt_list_delete_item', 1,
504
+ Wx::EVT_COMMAND_LIST_DELETE_ITEM,
505
+ Wx::ListEvent],
506
+ EventType['evt_list_end_label_edit', 1,
507
+ Wx::EVT_COMMAND_LIST_END_LABEL_EDIT,
508
+ Wx::ListEvent],
509
+ EventType['evt_list_insert_item', 1,
510
+ Wx::EVT_COMMAND_LIST_INSERT_ITEM,
511
+ Wx::ListEvent],
512
+ EventType['evt_list_item_activated', 1,
513
+ Wx::EVT_COMMAND_LIST_ITEM_ACTIVATED,
514
+ Wx::ListEvent],
515
+ EventType['evt_list_item_deselected', 1,
516
+ Wx::EVT_COMMAND_LIST_ITEM_DESELECTED,
517
+ Wx::ListEvent],
518
+ EventType['evt_list_item_focused', 1,
519
+ Wx::EVT_COMMAND_LIST_ITEM_FOCUSED,
520
+ Wx::ListEvent],
521
+ EventType['evt_list_item_middle_click', 1,
522
+ Wx::EVT_COMMAND_LIST_ITEM_MIDDLE_CLICK,
523
+ Wx::ListEvent],
524
+ EventType['evt_list_item_right_click', 1,
525
+ Wx::EVT_COMMAND_LIST_ITEM_RIGHT_CLICK,
526
+ Wx::ListEvent],
527
+ EventType['evt_list_item_selected', 1,
528
+ Wx::EVT_COMMAND_LIST_ITEM_SELECTED,
529
+ Wx::ListEvent],
530
+ EventType['evt_list_key_down', 1,
531
+ Wx::EVT_COMMAND_LIST_KEY_DOWN,
532
+ Wx::ListEvent],
533
+ EventType['evt_maximize', 0,
534
+ Wx::EVT_MAXIMIZE,
535
+ Wx::Event],
536
+ EventType['evt_menu', 1,
537
+ Wx::EVT_COMMAND_MENU_SELECTED,
538
+ Wx::CommandEvent],
539
+ EventType['evt_menu_close', 0,
540
+ Wx::EVT_MENU_CLOSE,
541
+ Wx::MenuEvent],
542
+ EventType['evt_menu_highlight', 1,
543
+ Wx::EVT_MENU_HIGHLIGHT,
544
+ Wx::MenuEvent],
545
+ EventType['evt_menu_highlight_all', 0,
546
+ Wx::EVT_MENU_HIGHLIGHT,
547
+ Wx::MenuEvent],
548
+ EventType['evt_menu_open', 0,
549
+ Wx::EVT_MENU_OPEN,
550
+ Wx::MenuEvent],
551
+ EventType['evt_menu_range', 2,
552
+ Wx::EVT_COMMAND_MENU_SELECTED,
553
+ Wx::CommandEvent],
554
+ EventType['evt_middle_dclick', 0,
555
+ Wx::EVT_MIDDLE_DCLICK,
556
+ Wx::MouseEvent],
557
+ EventType['evt_middle_down', 0,
558
+ Wx::EVT_MIDDLE_DOWN,
559
+ Wx::MouseEvent],
560
+ EventType['evt_middle_up', 0,
561
+ Wx::EVT_MIDDLE_UP,
562
+ Wx::MouseEvent],
563
+ EventType['evt_motion', 0,
564
+ Wx::EVT_MOTION,
565
+ Wx::MouseEvent],
566
+ EventType['evt_mousewheel', 0,
567
+ Wx::EVT_MOUSEWHEEL,
568
+ Wx::MouseEvent],
569
+ EventType['evt_mouse_capture_changed', 0,
570
+ Wx::EVT_MOUSE_CAPTURE_CHANGED,
571
+ Wx::Event],
572
+ EventType['evt_move', 0,
573
+ Wx::EVT_MOVE,
574
+ Wx::MoveEvent],
575
+ EventType['evt_nc_paint', 0,
576
+ Wx::EVT_NC_PAINT,
577
+ Wx::Event],
578
+ EventType['evt_notebook_page_changed', 1,
579
+ Wx::EVT_COMMAND_NOTEBOOK_PAGE_CHANGED,
580
+ Wx::NotebookEvent],
581
+ EventType['evt_notebook_page_changing', 1,
582
+ Wx::EVT_COMMAND_NOTEBOOK_PAGE_CHANGING,
583
+ Wx::NotebookEvent],
584
+ EventType['evt_paint', 0,
585
+ Wx::EVT_PAINT,
586
+ Wx::PaintEvent],
587
+ EventType['evt_query_end_session', 0,
588
+ Wx::EVT_QUERY_END_SESSION,
589
+ Wx::Event],
590
+ EventType['evt_query_layout_info', 0,
591
+ Wx::EVT_QUERY_LAYOUT_INFO,
592
+ Wx::Event],
593
+ EventType['evt_radiobox', 1,
594
+ Wx::EVT_COMMAND_RADIOBOX_SELECTED,
595
+ Wx::CommandEvent],
596
+ EventType['evt_radiobutton', 1,
597
+ Wx::EVT_COMMAND_RADIOBUTTON_SELECTED,
598
+ Wx::CommandEvent],
599
+ EventType['evt_right_dclick', 0,
600
+ Wx::EVT_RIGHT_DCLICK,
601
+ Wx::MouseEvent],
602
+ EventType['evt_right_down', 0,
603
+ Wx::EVT_RIGHT_DOWN,
604
+ Wx::MouseEvent],
605
+ EventType['evt_right_up', 0,
606
+ Wx::EVT_RIGHT_UP,
607
+ Wx::MouseEvent],
608
+ EventType['evt_sash_dragged', 1,
609
+ Wx::EVT_SASH_DRAGGED,
610
+ Wx::SashEvent],
611
+ EventType['evt_sash_dragged_range', 2,
612
+ Wx::EVT_SASH_DRAGGED,
613
+ Wx::SashEvent],
614
+ EventType['evt_scrollbar', 1,
615
+ Wx::EVT_COMMAND_SCROLLBAR_UPDATED,
616
+ Wx::CommandEvent],
617
+ EventType['evt_scrollwin_bottom', 0,
618
+ Wx::EVT_SCROLLWIN_TOP,
619
+ Wx::ScrollWinEvent],
620
+ EventType['evt_scrollwin_linedown', 0,
621
+ Wx::EVT_SCROLLWIN_LINEDOWN,
622
+ Wx::ScrollWinEvent],
623
+ EventType['evt_scrollwin_lineup', 0,
624
+ Wx::EVT_SCROLLWIN_LINEUP,
625
+ Wx::ScrollWinEvent],
626
+ EventType['evt_scrollwin_pagedown', 0,
627
+ Wx::EVT_SCROLLWIN_PAGEDOWN,
628
+ Wx::ScrollWinEvent],
629
+ EventType['evt_scrollwin_pageup', 0,
630
+ Wx::EVT_SCROLLWIN_PAGEUP,
631
+ Wx::ScrollWinEvent],
632
+ EventType['evt_scrollwin_thumbrelease', 0,
633
+ Wx::EVT_SCROLLWIN_THUMBRELEASE,
634
+ Wx::ScrollWinEvent],
635
+ EventType['evt_scrollwin_thumbtrack', 0,
636
+ Wx::EVT_SCROLLWIN_THUMBTRACK,
637
+ Wx::ScrollWinEvent],
638
+ EventType['evt_scrollwin_top', 0,
639
+ Wx::EVT_SCROLLWIN_TOP,
640
+ Wx::ScrollWinEvent],
641
+ EventType['evt_scroll_bottom', 0,
642
+ Wx::EVT_SCROLL_BOTTOM,
643
+ Wx::ScrollEvent],
644
+ EventType['evt_scroll_linedown', 0,
645
+ Wx::EVT_SCROLL_LINEDOWN,
646
+ Wx::ScrollEvent],
647
+ EventType['evt_scroll_lineup', 0,
648
+ Wx::EVT_SCROLL_LINEUP,
649
+ Wx::ScrollEvent],
650
+ EventType['evt_scroll_pagedown', 0,
651
+ Wx::EVT_SCROLL_PAGEDOWN,
652
+ Wx::ScrollEvent],
653
+ EventType['evt_scroll_pageup', 0,
654
+ Wx::EVT_SCROLL_PAGEUP,
655
+ Wx::ScrollEvent],
656
+ EventType['evt_scroll_thumbrelease', 0,
657
+ Wx::EVT_SCROLL_THUMBRELEASE,
658
+ Wx::ScrollEvent],
659
+ EventType['evt_scroll_thumbtrack', 0,
660
+ Wx::EVT_SCROLL_THUMBTRACK,
661
+ Wx::ScrollEvent],
662
+ EventType['evt_scroll_top', 0,
663
+ Wx::EVT_SCROLL_TOP,
664
+ Wx::ScrollEvent],
665
+ EventType['evt_set_cursor', 0,
666
+ Wx::EVT_SET_CURSOR,
667
+ Wx::SetCursorEvent],
668
+ EventType['evt_set_focus', 0,
669
+ Wx::EVT_SET_FOCUS,
670
+ Wx::FocusEvent],
671
+ EventType['evt_size', 0,
672
+ Wx::EVT_SIZE,
673
+ Wx::SizeEvent],
674
+ EventType['evt_sizing', 0,
675
+ Wx::EVT_SIZING,
676
+ Wx::SizeEvent],
677
+ EventType['evt_slider', 1,
678
+ Wx::EVT_COMMAND_SLIDER_UPDATED,
679
+ Wx::CommandEvent],
680
+ EventType['evt_socket', 1,
681
+ Wx::EVT_SOCKET,
682
+ Wx::Event],
683
+ EventType['evt_spin', 1,
684
+ Wx::EVT_SCROLL_THUMBTRACK,
685
+ Wx::ScrollEvent],
686
+ EventType['evt_spinctrl', 1,
687
+ Wx::EVT_COMMAND_SPINCTRL_UPDATED,
688
+ Wx::SpinEvent],
689
+ EventType['evt_spin_down', 1,
690
+ Wx::EVT_SCROLL_LINEDOWN,
691
+ Wx::ScrollEvent],
692
+ EventType['evt_spin_up', 1,
693
+ Wx::EVT_SCROLL_LINEUP,
694
+ Wx::ScrollEvent],
695
+ EventType['evt_splitter_dclick', 1,
696
+ Wx::EVT_COMMAND_SPLITTER_DOUBLECLICKED,
697
+ Wx::SplitterEvent],
698
+ EventType['evt_splitter_sash_pos_changed', 1,
699
+ Wx::EVT_COMMAND_SPLITTER_SASH_POS_CHANGED,
700
+ Wx::SplitterEvent],
701
+ EventType['evt_splitter_sash_pos_changing', 1,
702
+ Wx::EVT_COMMAND_SPLITTER_SASH_POS_CHANGING,
703
+ Wx::SplitterEvent],
704
+ EventType['evt_splitter_unsplit', 1,
705
+ Wx::EVT_COMMAND_SPLITTER_UNSPLIT,
706
+ Wx::SplitterEvent],
707
+ EventType['evt_sys_colour_changed', 0,
708
+ Wx::EVT_SYS_COLOUR_CHANGED,
709
+ Wx::Event],
710
+ EventType['evt_taskbar_left_dclick', 0,
711
+ Wx::EVT_TASKBAR_LEFT_DCLICK,
712
+ Wx::Event],
713
+ EventType['evt_taskbar_left_down', 0,
714
+ Wx::EVT_TASKBAR_LEFT_DOWN,
715
+ Wx::Event],
716
+ EventType['evt_taskbar_left_up', 0,
717
+ Wx::EVT_TASKBAR_LEFT_UP,
718
+ Wx::Event],
719
+ EventType['evt_taskbar_move', 0,
720
+ Wx::EVT_TASKBAR_MOVE,
721
+ Wx::Event],
722
+ EventType['evt_taskbar_right_dclick', 0,
723
+ Wx::EVT_TASKBAR_RIGHT_DCLICK,
724
+ Wx::Event],
725
+ EventType['evt_taskbar_right_down', 0,
726
+ Wx::EVT_TASKBAR_RIGHT_DOWN,
727
+ Wx::Event],
728
+ EventType['evt_taskbar_right_up', 0,
729
+ Wx::EVT_TASKBAR_RIGHT_UP,
730
+ Wx::Event],
731
+ EventType['evt_text', 1,
732
+ Wx::EVT_COMMAND_TEXT_UPDATED,
733
+ Wx::CommandEvent],
734
+ EventType['evt_text_enter', 1,
735
+ Wx::EVT_COMMAND_TEXT_ENTER,
736
+ Wx::CommandEvent],
737
+ EventType['evt_text_maxlen', 1,
738
+ Wx::EVT_COMMAND_TEXT_MAXLEN,
739
+ Wx::CommandEvent],
740
+ EventType['evt_text_url', 1,
741
+ Wx::EVT_COMMAND_TEXT_URL,
742
+ Wx::TextUrlEvent],
743
+ EventType['evt_timer', 1,
744
+ Wx::EVT_TIMER,
745
+ Wx::TimerEvent],
746
+ EventType['evt_togglebutton', 1,
747
+ Wx::EVT_COMMAND_TOGGLEBUTTON_CLICKED,
748
+ Wx::Event],
749
+ EventType['evt_tool', 1,
750
+ Wx::EVT_COMMAND_TOOL_CLICKED,
751
+ Wx::CommandEvent],
752
+ EventType['evt_tool_enter', 1,
753
+ Wx::EVT_COMMAND_TOOL_ENTER,
754
+ Wx::CommandEvent],
755
+ EventType['evt_tool_range', 2,
756
+ Wx::EVT_COMMAND_TOOL_CLICKED,
757
+ Wx::CommandEvent],
758
+ EventType['evt_tool_rclicked', 1,
759
+ Wx::EVT_COMMAND_TOOL_RCLICKED,
760
+ Wx::CommandEvent],
761
+ EventType['evt_tool_rclicked_range', 2,
762
+ Wx::EVT_COMMAND_TOOL_RCLICKED,
763
+ Wx::CommandEvent],
764
+ EventType['evt_tree_begin_drag', 1,
765
+ Wx::EVT_COMMAND_TREE_BEGIN_DRAG,
766
+ Wx::TreeEvent],
767
+ EventType['evt_tree_begin_label_edit', 1,
768
+ Wx::EVT_COMMAND_TREE_BEGIN_LABEL_EDIT,
769
+ Wx::TreeEvent],
770
+ EventType['evt_tree_begin_rdrag', 1,
771
+ Wx::EVT_COMMAND_TREE_BEGIN_RDRAG,
772
+ Wx::TreeEvent],
773
+ EventType['evt_tree_delete_item', 1,
774
+ Wx::EVT_COMMAND_TREE_DELETE_ITEM,
775
+ Wx::TreeEvent],
776
+ EventType['evt_tree_end_drag', 1,
777
+ Wx::EVT_COMMAND_TREE_END_DRAG,
778
+ Wx::TreeEvent],
779
+ EventType['evt_tree_end_label_edit', 1,
780
+ Wx::EVT_COMMAND_TREE_END_LABEL_EDIT,
781
+ Wx::TreeEvent],
782
+ EventType['evt_tree_get_info', 1,
783
+ Wx::EVT_COMMAND_TREE_GET_INFO,
784
+ Wx::TreeEvent],
785
+ EventType['evt_tree_item_activated', 1,
786
+ Wx::EVT_COMMAND_TREE_ITEM_ACTIVATED,
787
+ Wx::TreeEvent],
788
+ EventType['evt_tree_item_collapsed', 1,
789
+ Wx::EVT_COMMAND_TREE_ITEM_COLLAPSED,
790
+ Wx::TreeEvent],
791
+ EventType['evt_tree_item_collapsing', 1,
792
+ Wx::EVT_COMMAND_TREE_ITEM_COLLAPSING,
793
+ Wx::TreeEvent],
794
+ EventType['evt_tree_item_expanded', 1,
795
+ Wx::EVT_COMMAND_TREE_ITEM_EXPANDED,
796
+ Wx::TreeEvent],
797
+ EventType['evt_tree_item_expanding', 1,
798
+ Wx::EVT_COMMAND_TREE_ITEM_EXPANDING,
799
+ Wx::TreeEvent],
800
+ EventType['evt_tree_item_middle_click', 1,
801
+ Wx::EVT_COMMAND_TREE_ITEM_MIDDLE_CLICK,
802
+ Wx::TreeEvent],
803
+ EventType['evt_tree_item_right_click', 1,
804
+ Wx::EVT_COMMAND_TREE_ITEM_RIGHT_CLICK,
805
+ Wx::TreeEvent],
806
+ EventType['evt_tree_key_down', 1,
807
+ Wx::EVT_COMMAND_TREE_KEY_DOWN,
808
+ Wx::TreeEvent],
809
+ EventType['evt_tree_sel_changed', 1,
810
+ Wx::EVT_COMMAND_TREE_SEL_CHANGED,
811
+ Wx::TreeEvent],
812
+ EventType['evt_tree_sel_changing', 1,
813
+ Wx::EVT_COMMAND_TREE_SEL_CHANGING,
814
+ Wx::TreeEvent],
815
+ EventType['evt_tree_set_info', 1,
816
+ Wx::EVT_COMMAND_TREE_SET_INFO,
817
+ Wx::TreeEvent],
818
+ EventType['evt_update_ui', 1,
819
+ Wx::EVT_UPDATE_UI,
820
+ Wx::UpdateUIEvent],
821
+ EventType['evt_update_ui_range', 2,
822
+ Wx::EVT_UPDATE_UI,
823
+ Wx::UpdateUIEvent],
824
+ EventType['evt_window_create', 0,
825
+ Wx::EVT_CREATE,
826
+ Wx::WindowCreateEvent],
827
+ EventType['evt_window_destroy', 0,
828
+ Wx::EVT_DESTROY,
829
+ Wx::WindowDestroyEvent],
830
+ EventType['evt_wizard_cancel', 1,
831
+ Wx::EVT_WIZARD_CANCEL,
832
+ Wx::WizardEvent],
833
+ EventType['evt_wizard_finished', 1,
834
+ Wx::EVT_WIZARD_FINISHED,
835
+ Wx::WizardEvent],
836
+ EventType['evt_wizard_help', 1,
837
+ Wx::EVT_WIZARD_HELP,
838
+ Wx::WizardEvent],
839
+ EventType['evt_wizard_page_changed', 1,
840
+ Wx::EVT_WIZARD_PAGE_CHANGED,
841
+ Wx::WizardEvent],
842
+ EventType['evt_wizard_page_changing', 1,
843
+ Wx::EVT_WIZARD_PAGE_CHANGING,
844
+ Wx::WizardEvent]
845
+ ]
846
+
847
+ # Loop over the event definitions to set up two things:
848
+ # 1) A hash mapping Event Type ids to event classes, used when events
849
+ # are fired to quickly look up the right type to yield
850
+ # 2) EvtHandler instance methods like evt_xxx to conveniently set
851
+ # up event handlers
852
+ EVENT_DEFINITIONS.each { | ev_type | register_event_type(ev_type) }
853
+
854
+
855
+ # convenience evt_handler to listen to all mouse events
856
+ def evt_mouse_events(&block)
857
+ evt_left_down(&block)
858
+ evt_left_up(&block)
859
+ evt_middle_down(&block)
860
+ evt_middle_up(&block)
861
+ evt_right_down(&block)
862
+ evt_right_up(&block)
863
+ evt_motion(&block)
864
+ evt_left_dclick(&block)
865
+ evt_middle_dclick(&block)
866
+ evt_right_dclick(&block)
867
+ evt_leave_window(&block)
868
+ evt_enter_window(&block)
869
+ evt_mousewheel(&block)
870
+ end
871
+
872
+ # convenience evt handler to listen to all scrollwin events
873
+ def evt_scrollwin(&block)
874
+ evt_scrollwin_top(&block)
875
+ evt_scrollwin_bottom(&block)
876
+ evt_scrollwin_lineup(&block)
877
+ evt_scrollwin_linedown(&block)
878
+ evt_scrollwin_pageup(&block)
879
+ evt_scrollwin_pagedown(&block)
880
+ evt_scrollwin_thumbtrack(&block)
881
+ evt_scrollwin_thumbrelease(&block)
882
+ end
883
+ end
884
+