wx_sugar 0.1.2 → 0.1.13

Sign up to get free protection for your applications and to get access to all the features.
data/lib/wx_sugar/all.rb CHANGED
@@ -16,10 +16,13 @@
16
16
  #
17
17
  # == Using WxSugar
18
18
  #
19
- # The extensions can currently be used with either WxRuby (0.6.0) or
20
- # WxRuby2 (the SWIG version). To use all of the extensions, simple write
19
+ # The extensions can currently be used with WxRuby2 or the old WxRuby
20
+ # (0.6.0). WxRuby2 is strongly recommended, and support for the old
21
+ # series may be dropped in the future.
22
+ #
23
+ # The simplest way to use WxSugar is to load all the behaviours. You
24
+ # should load the wx library first:
21
25
  #
22
- # # EITHER ... New development
23
26
  # require 'wx'
24
27
  # # OR ... old non-SWIG beta veresion
25
28
  # require 'wxruby'
@@ -27,31 +30,43 @@
27
30
  # require 'wx_sugar/all'
28
31
  # ...
29
32
  #
30
- # If you only want to load specific behaviours, just +require+ the
31
- # desired extensions only
33
+ # If you only want to load specific WxSugar behaviours, just +require+
34
+ # the desired extensions only
32
35
  #
33
36
  # require 'wx_sugar/keyword_constructors'
34
37
  # require 'wx_sugar/acccessors'
35
38
  #
36
39
  # == Overview of extensions
40
+ #
41
+ # The following are the WxSugar behaviours that are available. In
42
+ # general you require one of these extensions, it modifies the behaviour
43
+ # of all relevant Wx classes, and affects all new instances.
37
44
  #
38
- # [accessors.rb]
45
+ # [accessors]
39
46
  # Provide ruby-style getters, setters and question-mark methods
40
- # [delayed_constructors.rb]
41
- # For use with +layout+, limited independent interest
42
- # [event_connector.rb]
47
+ # [delayed_constructors]
48
+ # Required by +layout+, of limited independent interest
49
+ # [event_connector]
43
50
  # Neater syntax for connecting event listeners
44
- # [itemdata.rb]
45
- # Associate ruby objects with items in controls *NEEDS UPDATE*
46
- # [keyword_constructors.rb]
51
+ # [keyword_constructors]
47
52
  # Use keyword-style hash arguments to construct widgets
48
- # [layout.rb]
49
- # Easy interface to using WxWidgets Sizers
50
- # [menu.rb]
53
+ # [layout]
54
+ # Easy interface to using WxWidgets Sizers to arrange controls
55
+ # [menu]
51
56
  # Create and update menus without a mess of system ids
57
+ # [wx_classes]
58
+ # Useful ruby methods added to individual Wx classes.
59
+ #
60
+ # === Deprecated extensions
61
+ #
62
+ # This module is deprecated and will soon be removed.
63
+ #
64
+ # [itemdata.rb]
65
+ # Linking ruby objects with wx controls; use the
66
+ # get/set_item_data methods in core wxruby2 instead.
52
67
 
53
68
 
54
- %w[ accessors delayed_constructors event_connector itemdata
69
+ %w[ accessors delayed_constructors event_connector
55
70
  keyword_constructors layout menu wx_classes ].each do | ext_feature |
56
71
  require 'wx_sugar/' + ext_feature
57
72
  end
@@ -52,7 +52,8 @@ WxSugar.define_class_group('MISC_WINDOW_CLASSES',
52
52
  'SashLayoutWindow',
53
53
  'VScrolledWindow',
54
54
  'WizardPage',
55
- 'WizardPageSimple'
55
+ 'WizardPageSimple',
56
+ 'HtmlWindow'
56
57
  )
57
58
 
58
59
  WxSugar.define_class_group('CONTROL_CLASSES',
@@ -13,12 +13,21 @@ Wx::NULL_BITMAP = nil
13
13
  $VERBOSE = v
14
14
 
15
15
  module WxSugar
16
+ @defined_classes = {}
17
+
16
18
  # accepts a string unadorned name of a WxWidgets class, and block, which
17
19
  # defines the constructor parameters and style flags for that class.
18
20
  # If the named class exists in the available WxRuby, the block is run and
19
21
  # the class may use keyword constructors. If the class is not available, the
20
22
  # block is ignored.
21
23
  def self.define_keyword_ctors(klass_name, &block)
24
+ # check this class hasn't already been defined
25
+ if @defined_classes[klass_name]
26
+ raise ArgumentError, "Keyword ctor for #{klass_name} already defined"
27
+ else
28
+ @defined_classes[klass_name] = true
29
+ end
30
+
22
31
  begin
23
32
  klass = Wx::const_get(klass_name)
24
33
  rescue NameError
@@ -34,8 +43,14 @@ module WxSugar
34
43
  end
35
44
  end
36
45
 
46
+ # Window : base class for all widgets and frames
47
+ WxSugar.define_keyword_ctors('Window') do
48
+ wx_ctor_params :pos, :size, :style
49
+ wx_ctor_params :name => 'window'
50
+ end
51
+
52
+
37
53
  ### FRAMES
38
- # Normal frame
39
54
 
40
55
  # wxTopLevelWindow ABSTRACT: Any top level window, dialog or frame
41
56
 
@@ -146,7 +161,7 @@ end
146
161
 
147
162
  # wxSashLayoutWindow: Window that can be involved in an IDE-like layout
148
163
  # arrangement
149
- WxSugar.define_keyword_ctors('SashWindow') do
164
+ WxSugar.define_keyword_ctors('SashLayoutWindow') do
150
165
  wx_ctor_params :pos, :size
151
166
  wx_ctor_params :style => Wx::CLIP_CHILDREN|Wx::SW_3D
152
167
  wx_ctor_params :name => 'layoutWindow'
@@ -223,7 +238,15 @@ end
223
238
 
224
239
  # wxFontDialog Font chooser dialog
225
240
  # wxPageSetupDialog Standard page setup dialog
241
+ WxSugar.define_keyword_ctors('PageSetupDialog') do
242
+ wx_ctor_params :data
243
+ end
244
+
226
245
  # wxPrintDialog Standard print dialog
246
+ WxSugar.define_keyword_ctors('PrintDialog') do
247
+ wx_ctor_params :data
248
+ end
249
+
227
250
 
228
251
  # Simple message box dialog
229
252
  WxSugar.define_keyword_ctors('MessageDialog') do
@@ -297,6 +320,17 @@ WxSugar.define_keyword_ctors('Gauge') do
297
320
  end
298
321
 
299
322
  # wxGenericDirCtrl A control for displaying a directory tree
323
+ WxSugar.define_keyword_ctors('GenericDirCtrl') do
324
+ # TODO :dir => Wx::DIR_DIALOG_DEFAULT_FOLDER_STR
325
+ wx_ctor_params :dir => ''
326
+ wx_ctor_params :pos, :size,
327
+ :style => Wx::DIRCTRL_3D_INTERNAL|Wx::SUNKEN_BORDER
328
+ wx_ctor_params :filter => ''
329
+ wx_ctor_params :default_filter => 0
330
+ wx_ctor_params :name => 'genericDirCtrl'
331
+ end
332
+
333
+
300
334
  # wxHtmlListBox A listbox showing HTML content
301
335
  # wxListBox A list of strings for single or multiple selection
302
336
  WxSugar.define_keyword_ctors('ListBox') do
@@ -318,20 +352,14 @@ WxSugar.define_keyword_ctors('TreeCtrl') do
318
352
  # wx_ctor_params :validator, :name => 'treeCtrl'
319
353
  end
320
354
 
321
- # wxScrollBar Scrollbar control
322
- # wxSpinButton A spin or 'up-down' control
323
- WxSugar.define_keyword_ctors('SpinCtrl') do
324
- wx_ctor_params :pos, :size, :style => Wx::SP_HORIZONTAL
325
- # wx_ctor_params :validator, :name => 'treeCtrl'
326
- end
327
-
328
355
  # wxSpinCtrl A spin control - i.e. spin button and text control
329
356
  WxSugar.define_keyword_ctors('SpinCtrl') do
357
+ wx_ctor_params :value => ''
330
358
  wx_ctor_params :pos, :size, :style => Wx::SP_ARROW_KEYS
331
359
  wx_ctor_params :min => 0
332
360
  wx_ctor_params :max => 100
333
361
  wx_ctor_params :initial => 0
334
- # wx_ctor_params :validator, :name => 'treeCtrl'
362
+ wx_ctor_params :name => 'spinCtrl'
335
363
  end
336
364
 
337
365
  # One or more lines of non-editable text
@@ -360,13 +388,11 @@ WxSugar.define_keyword_ctors('RadioBox') do
360
388
  wx_ctor_params :pos, :size, :choices => []
361
389
  wx_ctor_params :major_dimension => 0
362
390
  wx_ctor_params :style => Wx::RA_SPECIFY_COLS
363
-
364
- # wx_ctor_params :validator, :name => 'radioBox'
391
+ # wx_ctor_params :validator, :name => 'radioBox'
365
392
  end
366
393
 
367
-
368
394
  # wxRadioButton A round button to be used with others in a mutually exclusive way
369
- WxSugar.define_keyword_ctors('RadioBox') do
395
+ WxSugar.define_keyword_ctors('RadioButton') do
370
396
  wx_ctor_params :label => ''
371
397
  wx_ctor_params :pos, :size, :style => 0
372
398
  # wx_ctor_params :validator, :name => 'radioButton'
@@ -374,16 +400,30 @@ end
374
400
 
375
401
  # wxSlider A slider that can be dragged by the user
376
402
  WxSugar.define_keyword_ctors('Slider') do
403
+ wx_ctor_params :value => 0
377
404
  wx_ctor_params :min_value, :max_value
378
405
  wx_ctor_params :pos, :size, :style => Wx::SL_HORIZONTAL
379
406
  # wx_ctor_params :validator, :name => 'radioButton'
380
407
  end
381
408
 
409
+
410
+ # wxSpinButton - Has two small up and down (or left and right) arrow buttons
411
+ WxSugar.define_keyword_ctors('SpinButton') do
412
+ wx_ctor_params :pos, :size, :style => Wx::SP_HORIZONTAL
413
+ wx_ctor_params :name => 'spinButton'
414
+ end
415
+
382
416
  # wxVListBox A listbox supporting variable height rows
383
417
 
384
418
  # wxTextCtrl Single or multiline text editing control
385
419
  WxSugar.define_keyword_ctors('TextCtrl') do
386
420
  wx_ctor_params :value => ''
387
421
  wx_ctor_params :pos, :size, :style
422
+ # wx_ctor_params validator, :name => 'textCtrl'
388
423
  end
389
424
 
425
+ # wxHtmlWindow - Control for displaying HTML
426
+ WxSugar.define_keyword_ctors('HtmlWindow') do
427
+ wx_ctor_params :pos, :size, :style => Wx::HW_DEFAULT_STYLE
428
+ wx_ctor_params :name => 'htmlWindow'
429
+ end
@@ -244,7 +244,7 @@ module KeywordConstructor
244
244
  pre_wx_kwctor_init(*real_args)
245
245
  rescue
246
246
  Kernel.raise ArgumentError, "Error initializing #{self.inspect} \n" +
247
- "Sent paramters: #{real_args.inspect}\n" +
247
+ "Sent parameters: #{real_args.inspect}\n" +
248
248
  "correct parameters are:\n" +
249
249
  self.class.describe_constructor()
250
250
  end
@@ -1,3 +1,3 @@
1
1
  module WxSugar
2
- VERSION = '0.1.2'
2
+ VERSION = '0.1.13'
3
3
  end
data/lib/wx_sugar.rb ADDED
@@ -0,0 +1 @@
1
+ require 'wx_sugar/all'
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.8.10
3
3
  specification_version: 1
4
4
  name: wx_sugar
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.1.2
7
- date: 2006-10-19
6
+ version: 0.1.13
7
+ date: 2006-12-03
8
8
  summary: Syntax extensions for WxRuby.
9
9
  require_paths:
10
10
  - lib
@@ -28,6 +28,7 @@ authors:
28
28
  - Alex Fenton
29
29
  files:
30
30
  - lib/wx_sugar
31
+ - lib/wx_sugar.rb
31
32
  - lib/wx_sugar/accessors.rb
32
33
  - lib/wx_sugar/all.rb
33
34
  - lib/wx_sugar/class_definitions.rb