wxruby 1.9.3-x86-linux

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 (226) hide show
  1. data/LICENSE +53 -0
  2. data/README +299 -0
  3. data/lib/wx.rb +42 -0
  4. data/lib/wx/accessors.rb +52 -0
  5. data/lib/wx/classes/app.rb +45 -0
  6. data/lib/wx/classes/artprovider.rb +31 -0
  7. data/lib/wx/classes/bitmap.rb +23 -0
  8. data/lib/wx/classes/checklistbox.rb +45 -0
  9. data/lib/wx/classes/choice.rb +4 -0
  10. data/lib/wx/classes/clientdc.rb +13 -0
  11. data/lib/wx/classes/clipboard.rb +16 -0
  12. data/lib/wx/classes/colour.rb +47 -0
  13. data/lib/wx/classes/combobox.rb +4 -0
  14. data/lib/wx/classes/commandevent.rb +7 -0
  15. data/lib/wx/classes/controlwithitems.rb +10 -0
  16. data/lib/wx/classes/event.rb +5 -0
  17. data/lib/wx/classes/evthandler.rb +894 -0
  18. data/lib/wx/classes/font.rb +118 -0
  19. data/lib/wx/classes/grid.rb +129 -0
  20. data/lib/wx/classes/helpcontroller.rb +5 -0
  21. data/lib/wx/classes/htmlhelpcontroller.rb +5 -0
  22. data/lib/wx/classes/htmlwindow.rb +6 -0
  23. data/lib/wx/classes/icon.rb +14 -0
  24. data/lib/wx/classes/image.rb +14 -0
  25. data/lib/wx/classes/listbox.rb +4 -0
  26. data/lib/wx/classes/listctrl.rb +21 -0
  27. data/lib/wx/classes/locale.rb +28 -0
  28. data/lib/wx/classes/mediactrl.rb +22 -0
  29. data/lib/wx/classes/menu.rb +62 -0
  30. data/lib/wx/classes/menuitem.rb +7 -0
  31. data/lib/wx/classes/object.rb +7 -0
  32. data/lib/wx/classes/paintdc.rb +12 -0
  33. data/lib/wx/classes/point.rb +48 -0
  34. data/lib/wx/classes/previewframe.rb +13 -0
  35. data/lib/wx/classes/rect.rb +5 -0
  36. data/lib/wx/classes/size.rb +49 -0
  37. data/lib/wx/classes/sound.rb +23 -0
  38. data/lib/wx/classes/styledtextctrl.rb +92 -0
  39. data/lib/wx/classes/textctrl.rb +14 -0
  40. data/lib/wx/classes/texturlevent.rb +6 -0
  41. data/lib/wx/classes/timer.rb +69 -0
  42. data/lib/wx/classes/treectrl.rb +44 -0
  43. data/lib/wx/classes/window.rb +49 -0
  44. data/lib/wx/classes/xmlresource.rb +16 -0
  45. data/lib/wx/keyword_ctors.rb +219 -0
  46. data/lib/wx/keyword_defs.rb +485 -0
  47. data/lib/wx/version.rb +3 -0
  48. data/lib/wxruby2.so +0 -0
  49. data/samples/SAMPLES-LICENSE.TXT +18 -0
  50. data/samples/aui/aui.rb +1360 -0
  51. data/samples/bigdemo/About.rbw +39 -0
  52. data/samples/bigdemo/ColorPanel.rbw +25 -0
  53. data/samples/bigdemo/GridSimple.rbw +80 -0
  54. data/samples/bigdemo/MDIDemo.rbw +59 -0
  55. data/samples/bigdemo/PopupMenu.rbw +151 -0
  56. data/samples/bigdemo/ShapedWindow.rbw +135 -0
  57. data/samples/bigdemo/Sizers.rbw +545 -0
  58. data/samples/bigdemo/bigdemo.rb +826 -0
  59. data/samples/bigdemo/demoTemplate.rbw +37 -0
  60. data/samples/bigdemo/helpfile.htb +0 -0
  61. data/samples/bigdemo/icons/Test 015.jpg +0 -0
  62. data/samples/bigdemo/icons/Test 015.png +0 -0
  63. data/samples/bigdemo/icons/choice.bmp +0 -0
  64. data/samples/bigdemo/icons/choice.xpm +27 -0
  65. data/samples/bigdemo/icons/combo.bmp +0 -0
  66. data/samples/bigdemo/icons/combo.xpm +27 -0
  67. data/samples/bigdemo/icons/copy.xpm +25 -0
  68. data/samples/bigdemo/icons/cut.xpm +24 -0
  69. data/samples/bigdemo/icons/gauge.bmp +0 -0
  70. data/samples/bigdemo/icons/gauge.xpm +27 -0
  71. data/samples/bigdemo/icons/help.xpm +25 -0
  72. data/samples/bigdemo/icons/list.bmp +0 -0
  73. data/samples/bigdemo/icons/list.xpm +27 -0
  74. data/samples/bigdemo/icons/mondrian.ico +0 -0
  75. data/samples/bigdemo/icons/mondrian.xpm +44 -0
  76. data/samples/bigdemo/icons/new.xpm +24 -0
  77. data/samples/bigdemo/icons/ogl.ico +0 -0
  78. data/samples/bigdemo/icons/ogl.xpm +45 -0
  79. data/samples/bigdemo/icons/open.xpm +26 -0
  80. data/samples/bigdemo/icons/paste.bmp +0 -0
  81. data/samples/bigdemo/icons/paste.xpm +38 -0
  82. data/samples/bigdemo/icons/pointy.png +0 -0
  83. data/samples/bigdemo/icons/preview.xpm +26 -0
  84. data/samples/bigdemo/icons/print.xpm +26 -0
  85. data/samples/bigdemo/icons/radio.bmp +0 -0
  86. data/samples/bigdemo/icons/radio.xpm +27 -0
  87. data/samples/bigdemo/icons/robert.xpm +415 -0
  88. data/samples/bigdemo/icons/ruby.png +0 -0
  89. data/samples/bigdemo/icons/sashtest.ico +0 -0
  90. data/samples/bigdemo/icons/save.xpm +25 -0
  91. data/samples/bigdemo/icons/smiles.bmp +0 -0
  92. data/samples/bigdemo/icons/smiles.xpm +39 -0
  93. data/samples/bigdemo/icons/smiley.ico +0 -0
  94. data/samples/bigdemo/icons/smiley.xpm +42 -0
  95. data/samples/bigdemo/icons/stattext.xpm +24 -0
  96. data/samples/bigdemo/icons/test2.bmp +0 -0
  97. data/samples/bigdemo/icons/test2.png +0 -0
  98. data/samples/bigdemo/icons/test2.xpm +79 -0
  99. data/samples/bigdemo/icons/text.bmp +0 -0
  100. data/samples/bigdemo/icons/text.xpm +27 -0
  101. data/samples/bigdemo/icons/tog1.bmp +0 -0
  102. data/samples/bigdemo/icons/tog1.xpm +38 -0
  103. data/samples/bigdemo/icons/tog2.bmp +0 -0
  104. data/samples/bigdemo/icons/tog2.xpm +38 -0
  105. data/samples/bigdemo/icons/wxwin.ico +0 -0
  106. data/samples/bigdemo/icons/wxwin16x16.png +0 -0
  107. data/samples/bigdemo/icons/wxwin16x16.xpm +25 -0
  108. data/samples/bigdemo/icons/wxwin32x32.png +0 -0
  109. data/samples/bigdemo/icons/wxwin48x48.png +0 -0
  110. data/samples/bigdemo/run.rb +94 -0
  111. data/samples/bigdemo/tips.txt +7 -0
  112. data/samples/bigdemo/utils.rb +12 -0
  113. data/samples/bigdemo/wxArtProvider.rbw +285 -0
  114. data/samples/bigdemo/wxBitmapButton.rbw +64 -0
  115. data/samples/bigdemo/wxButton.rbw +66 -0
  116. data/samples/bigdemo/wxCalendarCtrl.rbw +72 -0
  117. data/samples/bigdemo/wxCheckBox.rbw +52 -0
  118. data/samples/bigdemo/wxCheckListBox.rbw +77 -0
  119. data/samples/bigdemo/wxChoice.rbw +49 -0
  120. data/samples/bigdemo/wxChoicebook.rbw +80 -0
  121. data/samples/bigdemo/wxColourDialog.rbw +34 -0
  122. data/samples/bigdemo/wxComboBox.rbw +79 -0
  123. data/samples/bigdemo/wxCursor.rbw +140 -0
  124. data/samples/bigdemo/wxDialog.rbw +92 -0
  125. data/samples/bigdemo/wxDirDialog.rbw +32 -0
  126. data/samples/bigdemo/wxDragImage.rbw +74 -0
  127. data/samples/bigdemo/wxFileDialog.rbw +39 -0
  128. data/samples/bigdemo/wxFileDialog_Save.rbw +38 -0
  129. data/samples/bigdemo/wxFindReplaceDialog.rbw +85 -0
  130. data/samples/bigdemo/wxFontDialog.rbw +176 -0
  131. data/samples/bigdemo/wxFrame.rbw +55 -0
  132. data/samples/bigdemo/wxGauge.rbw +73 -0
  133. data/samples/bigdemo/wxGenericDirCtrl.rbw +78 -0
  134. data/samples/bigdemo/wxGrid.rbw +68 -0
  135. data/samples/bigdemo/wxHtmlHelpController.rbw +57 -0
  136. data/samples/bigdemo/wxListBox.rbw +142 -0
  137. data/samples/bigdemo/wxListCtrl_virtual.rbw +109 -0
  138. data/samples/bigdemo/wxMDIWindows.rbw +52 -0
  139. data/samples/bigdemo/wxMenu.rbw +238 -0
  140. data/samples/bigdemo/wxMessageDialog.rbw +30 -0
  141. data/samples/bigdemo/wxMiniFrame.rbw +74 -0
  142. data/samples/bigdemo/wxMultipleChoiceDialog.rbw +34 -0
  143. data/samples/bigdemo/wxNotebook.rbw +138 -0
  144. data/samples/bigdemo/wxProgressDialog.rbw +45 -0
  145. data/samples/bigdemo/wxRadioBox.rbw +74 -0
  146. data/samples/bigdemo/wxRadioButton.rbw +127 -0
  147. data/samples/bigdemo/wxSashWindow.rbw +145 -0
  148. data/samples/bigdemo/wxScrolledMessageDialog.rbw +59 -0
  149. data/samples/bigdemo/wxScrolledWindow.rbw +201 -0
  150. data/samples/bigdemo/wxSingleChoiceDialog.rbw +35 -0
  151. data/samples/bigdemo/wxSlider.rbw +44 -0
  152. data/samples/bigdemo/wxSpinButton.rbw +52 -0
  153. data/samples/bigdemo/wxSpinCtrl.rbw +53 -0
  154. data/samples/bigdemo/wxSplitterWindow.rbw +65 -0
  155. data/samples/bigdemo/wxStaticBitmap.rbw +53 -0
  156. data/samples/bigdemo/wxStaticText.rbw +57 -0
  157. data/samples/bigdemo/wxStatusBar.rbw +128 -0
  158. data/samples/bigdemo/wxTextCtrl.rbw +151 -0
  159. data/samples/bigdemo/wxTextEntryDialog.rbw +34 -0
  160. data/samples/bigdemo/wxToggleButton.rbw +51 -0
  161. data/samples/bigdemo/wxToolBar.rbw +133 -0
  162. data/samples/bigdemo/wxTreeCtrl.rbw +192 -0
  163. data/samples/calendar/calendar.rb +275 -0
  164. data/samples/caret/caret.rb +286 -0
  165. data/samples/caret/mondrian.xpm +44 -0
  166. data/samples/controls/controls.rb +1140 -0
  167. data/samples/controls/get_item_sample.rb +87 -0
  168. data/samples/controls/icons/choice.xpm +27 -0
  169. data/samples/controls/icons/combo.xpm +27 -0
  170. data/samples/controls/icons/gauge.xpm +27 -0
  171. data/samples/controls/icons/list.xpm +27 -0
  172. data/samples/controls/icons/radio.xpm +27 -0
  173. data/samples/controls/icons/stattext.xpm +24 -0
  174. data/samples/controls/icons/text.xpm +27 -0
  175. data/samples/controls/mondrian.ico +0 -0
  176. data/samples/controls/mondrian.xpm +44 -0
  177. data/samples/controls/test2.bmp +0 -0
  178. data/samples/dialogs/dialogs.rb +724 -0
  179. data/samples/dialogs/tips.txt +18 -0
  180. data/samples/drawing/graphics_drawing.rb +232 -0
  181. data/samples/drawing/images.rb +48 -0
  182. data/samples/drawing/paperclip.png +0 -0
  183. data/samples/etc/activation.rb +108 -0
  184. data/samples/etc/choice.rb +72 -0
  185. data/samples/etc/miniframe.rb +84 -0
  186. data/samples/etc/sash.rb +135 -0
  187. data/samples/etc/scrollwin.rb +116 -0
  188. data/samples/etc/system_settings.rb +258 -0
  189. data/samples/etc/threaded.rb +81 -0
  190. data/samples/etc/wizard.rb +79 -0
  191. data/samples/event/event.rb +184 -0
  192. data/samples/grid/grid.rb +202 -0
  193. data/samples/html/html.rb +264 -0
  194. data/samples/listbook/listbook.rb +181 -0
  195. data/samples/listbook/listbook.xrc +370 -0
  196. data/samples/mdi/mdi.rb +87 -0
  197. data/samples/media/mediactrl.rb +173 -0
  198. data/samples/minimal/minimal.rb +85 -0
  199. data/samples/minimal/mondrian.ico +0 -0
  200. data/samples/minimal/mondrian.png +0 -0
  201. data/samples/minimal/nothing.rb +21 -0
  202. data/samples/opengl/cube.rb +123 -0
  203. data/samples/printing/mondrian.ico +0 -0
  204. data/samples/printing/mondrian.xpm +44 -0
  205. data/samples/printing/printing.rb +484 -0
  206. data/samples/sockets/SocketPackets.rb +27 -0
  207. data/samples/sockets/res/message-new.png +0 -0
  208. data/samples/sockets/res/user.png +0 -0
  209. data/samples/sockets/wxClient.rb +395 -0
  210. data/samples/sockets/wxServer.rb +422 -0
  211. data/samples/sockets/wxSocketGUI.rb +97 -0
  212. data/samples/text/mondrian.ico +0 -0
  213. data/samples/text/mondrian.xpm +44 -0
  214. data/samples/text/scintilla.rb +174 -0
  215. data/samples/text/textctrl.rb +124 -0
  216. data/samples/text/unicode.rb +238 -0
  217. data/samples/text/utf8.txt +15 -0
  218. data/samples/treectrl/icon1.xpm +79 -0
  219. data/samples/treectrl/icon2.xpm +53 -0
  220. data/samples/treectrl/icon3.xpm +79 -0
  221. data/samples/treectrl/icon4.xpm +43 -0
  222. data/samples/treectrl/icon5.xpm +79 -0
  223. data/samples/treectrl/treectrl.rb +1180 -0
  224. data/samples/xrc/samples.xrc +46 -0
  225. data/samples/xrc/xrc_sample.rb +107 -0
  226. metadata +303 -0
@@ -0,0 +1,16 @@
1
+ class Wx::XmlResource
2
+ # The standard .load method returns a boolean indicating success or
3
+ # failure. Failure might result from bad XML, or a non-existent
4
+ # file. In ruby, in these circumstances, it's more natural to raise an
5
+ # Exception than expect the user to test the return value.
6
+ wx_load = self.instance_method(:load)
7
+ define_method(:load) do | fname |
8
+ result = wx_load.bind(self).call(fname)
9
+ if not result
10
+ Kernel.raise( RuntimeError,
11
+ "Failed to load XRC from '#{fname}'; " +
12
+ "check the file exists and is valid XML")
13
+ end
14
+ fname
15
+ end
16
+ end
@@ -0,0 +1,219 @@
1
+ # = WxRuby Extensions - Keyword Constructors
2
+ #
3
+ # The *Keyword Constructors* extension allows the use of Ruby hash-style
4
+ # keyword arguments in constructors of common WxWidgets Windows, Frame,
5
+ # Dialog and Control classes.
6
+ #
7
+ # == Introduction
8
+ #
9
+ # Building a GUI in WxWidgets involves lots of calls to +new+, but
10
+ # these methods often have long parameter lists. Often the default
11
+ # values for many of these parameters are correct. For example, if
12
+ # you're using a sizer-based layout, you usually don't want to specify a
13
+ # size for widgets, but you still have to type
14
+ #
15
+ # Wx::TreeCtrl.new( parent, -1, Wx::DEFAULT_POSITION, Wx::DEFAULT_SIZE,
16
+ # Wx::NO_BUTTONS )
17
+ #
18
+ # just to create a standard TreeCtrl with the 'no buttons' style. If you
19
+ # want to specify the 'NO BUTTONS' style, you can't avoid all the typing
20
+ # of DEFAULT_POSITION etc.
21
+ #
22
+ # == Basic Keyword Constructors
23
+ #
24
+ # With keyword_constructors, you could write the above as
25
+ #
26
+ # TreeCtrl.new(parent, :style => Wx::NO_BUTTONS)
27
+ #
28
+ # And it will assume you want the default id (-1), and the default size
29
+ # and position. If you want to specify an explicit size, you can do so:
30
+ #
31
+ # TreeCtrl.new(parent, :size => Wx::Size.new(100, 300))
32
+ #
33
+ # For brevity, this module also allows you to specify positions and
34
+ # sizes using a a two-element array:
35
+ #
36
+ # TreeCtrl.new(parent, :size => [100, 300])
37
+ #
38
+ # Similarly with position:
39
+ #
40
+ # TreeCtrl.new(parent, :pos => Wx::Point.new(5, 25))
41
+ #
42
+ # TreeCtrl.new(parent, :pos => [5, 25])
43
+ #
44
+ # You can have multiple keyword arguments:
45
+ #
46
+ # TreeCtrl.new(parent, :pos => [5, 25], :size => [100, 300] )
47
+ #
48
+ # == No ID required
49
+ #
50
+ # As with position and size, you usually don't want to deal with
51
+ # assigning unique ids to every widget and frame you create - it's a C++
52
+ # hangover that often seems clunky in Ruby. The *Event Connectors*
53
+ # extension allows you to set up event handling without having to use
54
+ # ids, and if no :id argument is supplied to a constructor, the default
55
+ # (-1) will be passed.
56
+ #
57
+ # There are occasions when a specific ID does need to be used - for
58
+ # example, to tell WxWidgets that a button is a 'stock' item, so that it
59
+ # can be displayed using platform-standard text and icon. To do this,
60
+ # simply pass an :id argument to the constructor - here, the system's
61
+ # standard 'preview' button
62
+ #
63
+ # Wx::Button.new(parent, :id => Wx::ID_PREVIEW)
64
+ #
65
+ # == Class-specific arguments
66
+ #
67
+ # The arguments :size, :pos and :style are common to many WxWidgets
68
+ # window classes. The +new+ methods of these classes also have
69
+ # parameters that are specific to those classes; for example, the text
70
+ # label on a button, or the initial value of a text control.
71
+ #
72
+ # Wx::Button.new(parent, :label => 'press me')
73
+ # Wx::TextCtrl.new(parent, :value => 'type some text here')
74
+ #
75
+ # The keyword names of these arguments can be found by looking at the
76
+ # WxRuby documentation, in the relevant class's +new+ method. You can
77
+ # also get a string description of the class's +new+ method parameters
78
+ # within Ruby by doing:
79
+ #
80
+ # puts Wx::TextCtrl.describe_constructor()
81
+ #
82
+ # This will print a list of the argument names expected by the class's
83
+ # +new+ method, and the correct type for them.
84
+ #
85
+ # == Mixing positional and keyword arguments
86
+ #
87
+ # To support existing code, and to avoid forcing the use of more verbose
88
+ # keyword-style arguments where they're not desired, you can mix
89
+ # positional and keyword arguments, omitting or including +id+s as
90
+ # desired.
91
+ #
92
+ # Wx::Button.new(parent, 'press me', :style => Wx::BU_RIGHT)
93
+
94
+ module Wx
95
+ module KeywordConstructor
96
+ module ClassMethods
97
+
98
+ # Common Wx constructor argument keywords, with their default values.
99
+ STANDARD_DEFAULTS = {
100
+ :id => -1,
101
+ :size => Wx::DEFAULT_SIZE,
102
+ :pos => Wx::DEFAULT_POSITION,
103
+ :style => 0,
104
+ :title => '',
105
+ :validator => Wx::DEFAULT_VALIDATOR,
106
+ :choices => [] # for Choice, ComboBox etc
107
+ }
108
+
109
+
110
+ # A named parameter in a Wx constructor parameter list
111
+ Parameter = Struct.new( :name, :default )
112
+
113
+ attr_writer :param_spec
114
+ def param_spec
115
+ @param_spec ||= []
116
+ end
117
+
118
+ # Adds a list of named parameters *params* to the parameter
119
+ # specification for this Wx class's constructor. Each parameter
120
+ # should be specified as a either a common known symbol, such as
121
+ # +:size+ or +:pos:+ or +:style:+ (corresponding to the common
122
+ # constructor arguments in WxWidgets API), or a single-key with the
123
+ # key the name of the argument, and the value a default value.
124
+ #
125
+ # Parameters should be specified in the order they occur in the Wx
126
+ # API constructor
127
+ def wx_ctor_params(*params)
128
+ self.param_spec += params.map do | param |
129
+ param.kind_of?(Hash) ? Parameter[*param.to_a.flatten] :
130
+ Parameter[param, STANDARD_DEFAULTS[param] ]
131
+ end
132
+ end
133
+
134
+ def args_as_list(*mixed_args)
135
+ # get keyword arguments from mixed args if supplied, else empty
136
+ kwa = mixed_args.last.kind_of?(Hash) ? mixed_args.pop : {}
137
+ out_args = []
138
+ param_spec.each_with_index do | param, i |
139
+ if arg = mixed_args[i] # use the supplied list arg
140
+ out_args << arg
141
+ elsif kwa.key?(param.name) # use the keyword arg
142
+ out_args << kwa[param.name]
143
+ else # use the default argument
144
+ out_args << param.default
145
+ end
146
+ end
147
+ out_args
148
+ rescue
149
+ Kernel.raise ArgumentError,
150
+ "Bad arg composition of #{mixed_args.inspect}"
151
+ end
152
+
153
+ def args_as_hash(*mixed_args)
154
+ kwa = mixed_args.last.kind_of?(Hash) ? mixed_args.pop : {}
155
+ param_spec.zip(mixed_args) do | param, arg |
156
+ kwa[param.name] = arg if arg
157
+ end
158
+ kwa
159
+ end
160
+
161
+ def describe_constructor()
162
+ param_spec.inject("") do | desc, param |
163
+ desc << "#{param.name} (#{param.default.class.name})\n"
164
+ end
165
+ end
166
+ end
167
+
168
+ def self.included(klass)
169
+ klass.extend ClassMethods
170
+ klass.module_eval do
171
+
172
+ alias :pre_wx_kwctor_init :initialize
173
+
174
+ # The new definition of initialize; accepts a parent arg
175
+ # mixed_args, which may zero or more position args, optionally
176
+ # terminated with hash keyword args, and an optional block
177
+ def initialize(parent = :default_ctor, *mixed_args, &block)
178
+ # allow zero-args ctor for use with XRC
179
+ if parent == :default_ctor
180
+ pre_wx_kwctor_init()
181
+ return
182
+ end
183
+
184
+ real_args = [ parent ] + self.class.args_as_list(*mixed_args)
185
+ begin
186
+ pre_wx_kwctor_init(*real_args)
187
+ rescue
188
+ msg = "Error initializing #{self.inspect} \n" +
189
+ "Sent parameters: #{real_args.inspect}\n" +
190
+ "Correct parameters are:\n" +
191
+ self.class.describe_constructor()
192
+ Kernel.raise ArgumentError, msg
193
+ end
194
+
195
+ # If a block was given, pass the newly created Window instance
196
+ # into it; use block
197
+ if block
198
+ if block.arity == -1 or block.arity == 0
199
+ self.instance_eval(&block)
200
+ elsif block.arity == 1
201
+ block.call(self)
202
+ else
203
+ Kernel.raise ArgumentError,
204
+ "Block to initialize accepts zero or one arg"
205
+ end
206
+ end
207
+ end
208
+ end
209
+
210
+ # Any class inheriting from a class including this module must have
211
+ # its own copy of the param_spec
212
+ def klass.inherited(sub_klass)
213
+ sub_klass.instance_variable_set(:@param_spec,
214
+ instance_variable_get(:@param_spec) )
215
+ end
216
+ end
217
+ end
218
+ end
219
+
@@ -0,0 +1,485 @@
1
+ # = WxSugar - Keyword Constructors Classes
2
+ #
3
+ # This extension defines the keyword parameters for +new+ methods for
4
+ # widgets, windows and frames. It's for use with *Keyword Constructors*
5
+ # and is no use on its own - except if you are looking for a bug or want
6
+ # to add a missing class.
7
+ #
8
+ # For each class, the parameters *must* be declared in the order that
9
+ # they are supplied to wxRuby. A parameter is specified by a symbol
10
+ # name, and, optionally, a default argument which will of whatever type
11
+ # the wxRuby core library accepts. Because hashes are unordered in Ruby
12
+ # 1.8, if a default argument is specified, this must be the last in a
13
+ # list of parameters.
14
+ #
15
+ # Some common parameters to constructors such as size, position, title,
16
+ # id and so forth always have a standard default argumnet, which is
17
+ # defined in keyword_ctors. In these cases, it is not necessary to
18
+ # supply the default argument in the definition.
19
+ module Wx
20
+ @defined_kw_classes = {}
21
+
22
+ # accepts a string unadorned name of a WxWidgets class, and block, which
23
+ # defines the constructor parameters and style flags for that class.
24
+ # If the named class exists in the available WxRuby, the block is run and
25
+ # the class may use keyword constructors. If the class is not available, the
26
+ # block is ignored.
27
+ def self.define_keyword_ctors(klass_name, &block)
28
+ # check this class hasn't already been defined
29
+ if @defined_kw_classes[klass_name]
30
+ raise ArgumentError, "Keyword ctor for #{klass_name} already defined"
31
+ else
32
+ @defined_kw_classes[klass_name] = true
33
+ end
34
+
35
+ begin
36
+ klass = Wx::const_get(klass_name)
37
+ rescue NameError
38
+ return nil
39
+ end
40
+ klass.module_eval { include Wx::KeywordConstructor }
41
+ klass.instance_eval(&block)
42
+ end
43
+ end
44
+
45
+ # Window : base class for all widgets and frames
46
+ Wx::define_keyword_ctors('Window') do
47
+ wx_ctor_params :id, :pos, :size, :style
48
+ wx_ctor_params :name => 'window'
49
+ end
50
+
51
+
52
+ ### FRAMES
53
+
54
+ # wxTopLevelWindow ABSTRACT: Any top level window, dialog or frame
55
+
56
+ # Normal frame
57
+ Wx::define_keyword_ctors('Frame') do
58
+ wx_ctor_params :id, :title, :pos, :size, :style => Wx::DEFAULT_FRAME_STYLE
59
+ wx_ctor_params :name => 'frame'
60
+ end
61
+
62
+ # MDI child frame
63
+ Wx::define_keyword_ctors('MDIChildFrame') do
64
+ wx_ctor_params :id, :title, :pos, :size, :style => Wx::DEFAULT_FRAME_STYLE
65
+ wx_ctor_params :name => 'frame'
66
+ end
67
+
68
+ # MDI parent frame
69
+ Wx::define_keyword_ctors('MDIParentFrame') do
70
+ wx_ctor_params :id, :title, :pos, :size
71
+ wx_ctor_params :style => Wx::DEFAULT_FRAME_STYLE|Wx::VSCROLL|Wx::HSCROLL
72
+ wx_ctor_params :name => 'frame'
73
+ end
74
+
75
+ # wxMiniFrame A frame with a small title bar
76
+ Wx::define_keyword_ctors('MiniFrame') do
77
+ wx_ctor_params :id, :title, :pos, :size
78
+ wx_ctor_params :style => Wx::DEFAULT_FRAME_STYLE
79
+ wx_ctor_params :name => 'frame'
80
+ end
81
+
82
+ # wxSplashScreen Splash screen class
83
+ # FIXME - this probably won't work at present because the 'parent' arg
84
+ # comes in a funny place in this class's ctor
85
+ #
86
+ # Wx::define_keyword_ctors('SplashScreen') do
87
+ # wx_ctor_params :bitmap => Wx::NULL_BITMAP
88
+ # wx_ctor_params :splashstyle, :milliseconds, :id => 1
89
+ # wx_ctor_params :parent => nil
90
+ # wx_ctor_params :title => ''
91
+ # wx_ctor_params :pos, :size
92
+ # wx_ctor_params :style => Wx::SIMPLE_BORDER|Wx::FRAME_NO_TASKBAR|Wx::STAY_ON_TOP
93
+ # end
94
+
95
+ # wxPropertySheetDialog Property sheet dialog
96
+ # wxTipWindow Shows text in a small window
97
+
98
+ # wxWizard A wizard dialog
99
+ Wx::define_keyword_ctors('Wizard') do
100
+ wx_ctor_params :id, :title, :bitmap => Wx::NULL_BITMAP
101
+ wx_ctor_params :pos # NB - no size argument for this class
102
+ wx_ctor_params :style => Wx::DEFAULT_DIALOG_STYLE
103
+ end
104
+
105
+
106
+ # MISCELLANEOUS WINDOWS
107
+
108
+ # A window whose colour changes according to current user settings
109
+ Wx::define_keyword_ctors('Panel') do
110
+ wx_ctor_params :id, :pos, :size, :style => Wx::TAB_TRAVERSAL
111
+ wx_ctor_params :name => 'panel'
112
+ end
113
+
114
+ # wxScrolledWindow Window with automatically managed scrollbars
115
+ Wx::define_keyword_ctors('ScrolledWindow') do
116
+ wx_ctor_params :id, :pos, :size, :style => Wx::VSCROLL|Wx::HSCROLL
117
+ wx_ctor_params :name => 'scrolledWindow'
118
+ end
119
+
120
+ # wxGrid A grid (table) window
121
+ Wx::define_keyword_ctors('Grid') do
122
+ wx_ctor_params :id, :pos, :size, :style => Wx::WANTS_CHARS
123
+ wx_ctor_params :name => 'grid'
124
+ end
125
+
126
+ # Window which can be split vertically or horizontally
127
+ Wx::define_keyword_ctors('SplitterWindow') do
128
+ wx_ctor_params :id, :pos, :size, :style => Wx::SP_3D
129
+ wx_ctor_params :name => 'splitterWindow'
130
+ end
131
+
132
+ # Implements the status bar on a frame
133
+ Wx::define_keyword_ctors('StatusBar') do
134
+ wx_ctor_params :id, :style => Wx::ST_SIZEGRIP
135
+ wx_ctor_params :name => 'statusBar'
136
+ end
137
+
138
+ # Toolbar class
139
+ Wx::define_keyword_ctors('ToolBar') do
140
+ wx_ctor_params :id, :pos, :size, :style => Wx::TB_HORIZONTAL|Wx::NO_BORDER
141
+ wx_ctor_params :name => 'toolBar' # not as documented in Wx 2.6.3
142
+ end
143
+
144
+ # Notebook class
145
+ Wx::define_keyword_ctors('Notebook') do
146
+ wx_ctor_params :id, :pos, :size, :style, :name => 'noteBook'
147
+ end
148
+
149
+ # Similar to notebook but using list control - undocumented
150
+ Wx::define_keyword_ctors('Listbook') do
151
+ wx_ctor_params :id, :pos, :size, :style, :name => 'listBook'
152
+ end
153
+
154
+ # Similar to notebook but using choice control
155
+ Wx::define_keyword_ctors('Choicebook') do
156
+ wx_ctor_params :id, :pos, :size, :style, :name => 'choiceBook'
157
+ end
158
+
159
+ # wxSashWindow: Window with four optional sashes that can be dragged
160
+ Wx::define_keyword_ctors('SashWindow') do
161
+ wx_ctor_params :id, :pos, :size
162
+ wx_ctor_params :style => Wx::CLIP_CHILDREN|Wx::SW_3D
163
+ wx_ctor_params :name => 'sashWindow'
164
+ end
165
+
166
+ # wxSashLayoutWindow: Window that can be involved in an IDE-like layout
167
+ # arrangement
168
+ Wx::define_keyword_ctors('SashLayoutWindow') do
169
+ wx_ctor_params :id, :pos, :size
170
+ wx_ctor_params :style => Wx::CLIP_CHILDREN|Wx::SW_3D
171
+ wx_ctor_params :name => 'layoutWindow'
172
+ end
173
+
174
+ # wxVScrolledWindow: As wxScrolledWindow but supports lines of variable height
175
+
176
+ # wxWizardPage: A base class for the page in wizard dialog.
177
+ Wx::define_keyword_ctors('WizardPage') do
178
+ wx_ctor_params :bitmap => Wx::NULL_BITMAP
179
+ end
180
+
181
+ # wxWizardPageSimple: A page in wizard dialog.
182
+ Wx::define_keyword_ctors('WizardPageSimple') do
183
+ wx_ctor_params :prev => nil
184
+ wx_ctor_params :next => nil
185
+ wx_ctor_params :bitmap => Wx::NULL_BITMAP
186
+ end
187
+
188
+ ### DIALOGS
189
+ # wxDialog Base class for common dialogs
190
+ Wx::define_keyword_ctors('Dialog') do
191
+ wx_ctor_params :id, :title => ''
192
+ wx_ctor_params :pos, :size, :style => Wx::DEFAULT_DIALOG_STYLE
193
+ wx_ctor_params :name => 'dialogBox'
194
+ end
195
+
196
+ # wxColourDialog Colour chooser dialog
197
+ Wx::define_keyword_ctors('ColourDialog') do
198
+ wx_ctor_params :colour_data => nil
199
+ end
200
+
201
+ # wxDirDialog Directory selector dialog
202
+ Wx::define_keyword_ctors('DirDialog') do
203
+ wx_ctor_params :message => 'Choose a directory'
204
+ wx_ctor_params :default_path => ''
205
+ wx_ctor_params :style, :pos, :size, :name => 'wxDirCtrl'
206
+ end
207
+
208
+ # wxFileDialog File selector dialog
209
+ Wx::define_keyword_ctors('FileDialog') do
210
+ wx_ctor_params :message => 'Choose a file'
211
+ wx_ctor_params :default_dir => ''
212
+ wx_ctor_params :default_file => ''
213
+ wx_ctor_params :wildcard => '*.*'
214
+ wx_ctor_params :style, :pos
215
+ end
216
+
217
+ # wxFindReplaceDialog Text search/replace dialog
218
+ Wx::define_keyword_ctors('FindReplaceDialog') do
219
+ wx_ctor_params :find_replace_data => Wx::FindReplaceData.new()
220
+ wx_ctor_params :title => 'findReplaceDialog'
221
+ wx_ctor_params :style
222
+ end
223
+
224
+ # wxMultiChoiceDialog Dialog to get one or more selections from a list
225
+ # wxSingleChoiceDialog Dialog to get a single selection from a list and return the string
226
+
227
+ # Dialog to get a single line of text from the user
228
+ Wx::define_keyword_ctors('TextEntryDialog') do
229
+ wx_ctor_params :message => ''
230
+ wx_ctor_params :caption => 'Please enter text'
231
+ wx_ctor_params :default_value => ''
232
+ wx_ctor_params :style => Wx::OK|Wx::CANCEL|Wx::CENTRE
233
+ wx_ctor_params :pos
234
+ end
235
+
236
+ # wxPasswordEntryDialog Dialog to get a password from the user
237
+ # Wx::define_keyword_ctors('PasswordEntryDialog') do
238
+ # wx_ctor_params :message => ''
239
+ # wx_ctor_params :caption => 'Enter password'
240
+ # wx_ctor_params :default_value => ''
241
+ # wx_ctor_params :style => Wx::OK|Wx::CANCEL|Wx::CENTRE
242
+ # wx_ctor_params :pos
243
+ # end
244
+
245
+ # wxFontDialog Font chooser dialog
246
+ # wxPageSetupDialog Standard page setup dialog
247
+ Wx::define_keyword_ctors('PageSetupDialog') do
248
+ wx_ctor_params :data
249
+ end
250
+
251
+ # wxPrintDialog Standard print dialog
252
+ Wx::define_keyword_ctors('PrintDialog') do
253
+ wx_ctor_params :data
254
+ end
255
+
256
+
257
+ # Simple message box dialog
258
+ Wx::define_keyword_ctors('MessageDialog') do
259
+ wx_ctor_params :message => ''
260
+ wx_ctor_params :caption => 'Message box'
261
+ wx_ctor_params :style => Wx::OK|Wx::CANCEL
262
+ wx_ctor_params :pos
263
+ end
264
+
265
+ ### CONTROLS
266
+
267
+ # Push button control, displaying text
268
+ Wx::define_keyword_ctors('Button') do
269
+ wx_ctor_params :id, :label => ''
270
+ wx_ctor_params :pos, :size, :style
271
+ wx_ctor_params :validator, :name => 'button'
272
+ end
273
+
274
+ # Push button control, displaying a bitmap
275
+ Wx::define_keyword_ctors('BitmapButton') do
276
+ wx_ctor_params :id, :bitmap, :pos, :size, :style => Wx::BU_AUTODRAW
277
+ wx_ctor_params :validator, :name => 'button'
278
+ end
279
+
280
+ # A button which stays pressed when clicked by user.
281
+ Wx::define_keyword_ctors('ToggleButton') do
282
+ wx_ctor_params :id, :label, :pos, :size, :style
283
+ wx_ctor_params :validator, :name => 'checkBox'
284
+ end
285
+
286
+ # Control showing an entire calendar month
287
+ Wx::define_keyword_ctors('CalendarCtrl') do
288
+ wx_ctor_params :id, :date => Time.now()
289
+ wx_ctor_params :pos, :size, :style => Wx::CAL_SHOW_HOLIDAYS
290
+ wx_ctor_params :name => 'calendar'
291
+ end
292
+
293
+ # Checkbox control
294
+ Wx::define_keyword_ctors('CheckBox') do
295
+ wx_ctor_params :id, :label => ''
296
+ wx_ctor_params :pos, :size, :style
297
+ wx_ctor_params :validator, :name => 'checkBox'
298
+ end
299
+
300
+ # A listbox with a checkbox to the left of each item
301
+ Wx::define_keyword_ctors('CheckListBox') do
302
+ wx_ctor_params :id, :pos, :size, :choices, :style
303
+ wx_ctor_params :validator, :name => 'listBox'
304
+ end
305
+
306
+ # wxChoice Choice control (a combobox without the editable area)
307
+ Wx::define_keyword_ctors('Choice') do
308
+ wx_ctor_params :id, :pos, :size, :choices, :style
309
+ wx_ctor_params :validator, :name => 'choice'
310
+ end
311
+
312
+ # wxComboBox A choice with an editable area
313
+ Wx::define_keyword_ctors('ComboBox') do
314
+ wx_ctor_params :id, :value => ''
315
+ wx_ctor_params :pos, :size, :choices => []
316
+ wx_ctor_params :style
317
+ wx_ctor_params :validator, :name => 'comboBox'
318
+ end
319
+
320
+ # wxBitmapComboBox A choice with an editable area
321
+ Wx::define_keyword_ctors('BitmapComboBox') do
322
+ wx_ctor_params :id, :value => ''
323
+ wx_ctor_params :pos, :size, :choices => []
324
+ wx_ctor_params :style
325
+ wx_ctor_params :validator, :name => 'comboBox'
326
+ end
327
+
328
+ # wxDatePickerCtrl Small date picker control
329
+
330
+ # wxGauge A control to represent a varying quantity, such as time
331
+ # remaining
332
+ Wx::define_keyword_ctors('Gauge') do
333
+ wx_ctor_params :id, :range, :pos, :size, :style => Wx::GA_HORIZONTAL
334
+ wx_ctor_params :validator, :name => 'gauge'
335
+ end
336
+
337
+ # wxGenericDirCtrl A control for displaying a directory tree
338
+ Wx::define_keyword_ctors('GenericDirCtrl') do
339
+ # TODO :dir => Wx::DIR_DIALOG_DEFAULT_FOLDER_STR
340
+ wx_ctor_params :id, :dir => ''
341
+ wx_ctor_params :pos, :size,
342
+ :style => Wx::DIRCTRL_3D_INTERNAL|Wx::SUNKEN_BORDER
343
+ wx_ctor_params :filter => ''
344
+ wx_ctor_params :default_filter => 0
345
+ wx_ctor_params :name => 'genericDirCtrl'
346
+ end
347
+
348
+
349
+ # wxHtmlListBox A listbox showing HTML content
350
+ # wxListBox A list of strings for single or multiple selection
351
+ Wx::define_keyword_ctors('ListBox') do
352
+ wx_ctor_params :id, :pos, :size, :choices => []
353
+ wx_ctor_params :style
354
+ wx_ctor_params :validator, :name => 'listBox'
355
+ end
356
+
357
+ # wxListCtrl A control for displaying lists of strings and/or icons, plus a multicolumn report view
358
+ Wx::define_keyword_ctors('ListCtrl') do
359
+ wx_ctor_params :id, :pos, :size, :style => Wx::LC_ICON
360
+ wx_ctor_params :validator, :name => 'listCtrl'
361
+ end
362
+
363
+ # wxListView A simpler interface (facade for wxListCtrl in report mode
364
+
365
+ # wxTreeCtrl Tree (hierarchy) control
366
+ Wx::define_keyword_ctors('TreeCtrl') do
367
+ wx_ctor_params :id, :pos, :size, :style => Wx::TR_HAS_BUTTONS
368
+ wx_ctor_params :validator, :name => 'treeCtrl'
369
+ end
370
+
371
+ # wxSpinCtrl A spin control - i.e. spin button and text control
372
+ Wx::define_keyword_ctors('SpinCtrl') do
373
+ wx_ctor_params :id, :value => ''
374
+ wx_ctor_params :pos, :size, :style => Wx::SP_ARROW_KEYS
375
+ wx_ctor_params :min => 0
376
+ wx_ctor_params :max => 100
377
+ wx_ctor_params :initial => 0
378
+ wx_ctor_params :name => 'spinCtrl'
379
+ end
380
+
381
+ # One or more lines of non-editable text
382
+ Wx::define_keyword_ctors('StaticText') do
383
+ wx_ctor_params :id, :label, :pos, :size, :style, :name => 'staticText'
384
+ end
385
+
386
+ Wx::define_keyword_ctors('StaticBox') do
387
+ wx_ctor_params :id, :label, :pos, :size, :style, :name => 'staticBox'
388
+ end
389
+
390
+ Wx::define_keyword_ctors('StaticLine') do
391
+ wx_ctor_params :id, :pos, :size, :style => Wx::LI_HORIZONTAL
392
+ wx_ctor_params :name => 'staticBox'
393
+ end
394
+
395
+ # wxStaticBitmap A control to display a bitmap
396
+ Wx::define_keyword_ctors('StaticBitmap') do
397
+ wx_ctor_params :id, :label, :pos, :size, :style
398
+ end
399
+
400
+
401
+ # wxRadioBox A group of radio buttons
402
+ Wx::define_keyword_ctors('RadioBox') do
403
+ wx_ctor_params :id, :label => ''
404
+ wx_ctor_params :pos, :size, :choices => []
405
+ wx_ctor_params :major_dimension => 0
406
+ wx_ctor_params :style => Wx::RA_SPECIFY_COLS
407
+ wx_ctor_params :validator, :name => 'radioBox'
408
+ end
409
+
410
+ # wxRadioButton: A round button used with others in a mutually exclusive way
411
+ Wx::define_keyword_ctors('RadioButton') do
412
+ wx_ctor_params :id, :label => ''
413
+ wx_ctor_params :pos, :size, :style => 0
414
+ wx_ctor_params :validator, :name => 'radioButton'
415
+ end
416
+
417
+ # wxSlider A slider that can be dragged by the user
418
+ Wx::define_keyword_ctors('Slider') do
419
+ wx_ctor_params :id, :value => 0
420
+ wx_ctor_params :min_value, :max_value
421
+ wx_ctor_params :pos, :size, :style => Wx::SL_HORIZONTAL
422
+ wx_ctor_params :validator, :name => 'slider'
423
+ end
424
+
425
+ # wxSpinButton - Has two small up and down (or left and right) arrow buttons
426
+ Wx::define_keyword_ctors('SpinButton') do
427
+ wx_ctor_params :id, :pos, :size, :style => Wx::SP_HORIZONTAL
428
+ wx_ctor_params :name => 'spinButton'
429
+ end
430
+
431
+ # wxScrollBar - standalone scrollbar with arrows and thumb
432
+ Wx::define_keyword_ctors('ScrollBar') do
433
+ wx_ctor_params :id, :pos, :size, :style => Wx::SB_HORIZONTAL
434
+ wx_ctor_params :validator, :name => 'scrollBar'
435
+ end
436
+
437
+
438
+ # wxVListBox A listbox supporting variable height rows
439
+
440
+ # wxTextCtrl Single or multiline text editing control
441
+ Wx::define_keyword_ctors('TextCtrl') do
442
+ wx_ctor_params :id, :value => ''
443
+ wx_ctor_params :pos, :size, :style
444
+ wx_ctor_params :validator, :name => 'textCtrl'
445
+ end
446
+
447
+ # wxHtmlWindow - Control for displaying HTML
448
+ Wx::define_keyword_ctors('HtmlWindow') do
449
+ wx_ctor_params :id, :pos, :size, :style => Wx::HW_DEFAULT_STYLE
450
+ wx_ctor_params :name => 'htmlWindow'
451
+ end
452
+
453
+ # wxHyperTextCtrl - display a clickable URL
454
+ Wx::define_keyword_ctors('HyperlinkCtrl') do
455
+ wx_ctor_params :id, :label => ''
456
+ wx_ctor_params :url => ''
457
+ wx_ctor_params :pos, :size, :style => 0
458
+ wx_ctor_params :name => 'hyperlink'
459
+ end
460
+
461
+ Wx::define_keyword_ctors('StyledTextCtrl') do
462
+ wx_ctor_params :id, :pos, :size, :style => 0
463
+ wx_ctor_params :name => 'styledTextCtrl'
464
+ end
465
+
466
+
467
+ Wx::define_keyword_ctors('CollapsiblePane') do
468
+ wx_ctor_params :id, :label => ''
469
+ wx_ctor_params :pos, :size, :style => 0
470
+ wx_ctor_params :validator, :name => 'collapsiblePane'
471
+ end
472
+
473
+ Wx::define_keyword_ctors('MediaCtrl') do
474
+ wx_ctor_params :id, :filename => ''
475
+ wx_ctor_params :pos, :size, :style => 0
476
+ wx_ctor_params :backend => ''
477
+ wx_ctor_params :validator, :name => 'mediaCtrl'
478
+ end
479
+
480
+ Wx::define_keyword_ctors('SearchCtrl') do
481
+ wx_ctor_params :id, :value => ''
482
+ wx_ctor_params :pos, :size, :style => 0
483
+ wx_ctor_params :validator, :name => 'searchCtrl'
484
+ end
485
+