wx_sugar 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -39,6 +39,28 @@ module NiceRubyMethodNames
39
39
  end
40
40
  end
41
41
 
42
+ module MethMissingNiceRubyNames
43
+ def method_missing(sym, *args)
44
+ case sym.to_s
45
+ when /^(.*)\=$/
46
+ meth = "set_#{$1}"
47
+ when /^(.*)\?$/
48
+ meth = "is_#{$1}"
49
+ else
50
+ meth = "get_#{sym}"
51
+ end
52
+ if respond_to?(meth)
53
+ send(meth, *args)
54
+ else
55
+ e = NoMethodError.new("undefined method '#{sym}' for #{self.inspect}")
56
+ e.set_backtrace(caller)
57
+ Kernel.raise e
58
+ end
59
+ end
60
+ end
61
+
62
+
42
63
  WxSugar::ALL_CLASSES.each do | klass |
43
- klass.class_eval { include NiceRubyMethodNames }
64
+ # klass.class_eval { include NiceRubyMethodNames }
65
+ klass.class_eval { include MethMissingNiceRubyNames }
44
66
  end
data/lib/wx_sugar/all.rb CHANGED
@@ -50,7 +50,7 @@
50
50
  # [menu.rb]
51
51
  # Create and update menus without a mess of system ids
52
52
 
53
- %w[ accessors delayed_constructors event_connector
54
- itemdata keyword_constructors layout menu ].each do | ext_feature |
53
+ %w[ accessors delayed_constructors event_connector itemdata
54
+ keyword_constructors layout menu wx_classes ].each do | ext_feature |
55
55
  require 'wx_sugar/' + ext_feature
56
56
  end
@@ -89,7 +89,8 @@ module EventConnector
89
89
  # end
90
90
  # end
91
91
  #
92
- def listen(evt, source = nil, handler = nil, &block)
92
+ def listen(evt, source = self, handler = nil, &block)
93
+
93
94
  # get the WxWidget evt_xxx method that will be called for binding
94
95
  event = "evt_#{evt}"
95
96
  if self.respond_to?(event)
@@ -125,7 +126,12 @@ module EventConnector
125
126
  end
126
127
 
127
128
 
128
- source_id = source ? source.get_id : Wx::ID_ANY
129
+ if source
130
+ source_id = source.get_id
131
+ else
132
+ source_id = -1
133
+ end
134
+
129
135
  begin
130
136
  # Some WxWidgest event connector methods expect the ID of the
131
137
  # triggering widget, others don't. So we try both ways to hide
@@ -6,7 +6,11 @@
6
6
  # to add a missing class.
7
7
 
8
8
  # This is a dummy, this variable is not loaded until Wx init
9
+ # hush warnings if it has already been loaded when we get here
10
+ v = $VERBOSE
11
+ $VERBOSE = nil
9
12
  Wx::NULL_BITMAP = nil
13
+ $VERBOSE = v
10
14
 
11
15
  module WxSugar
12
16
  # accepts a string unadorned name of a WxWidgets class, and block, which
@@ -35,13 +39,6 @@ end
35
39
 
36
40
  # wxTopLevelWindow ABSTRACT: Any top level window, dialog or frame
37
41
 
38
- # Dialog box
39
- WxSugar.define_keyword_ctors('Dialog') do
40
- wx_ctor_params :title => ''
41
- wx_ctor_params :pos, :size, :style => Wx::DEFAULT_DIALOG_STYLE
42
- wx_ctor_params :name => 'dialogBox'
43
- end
44
-
45
42
  # Normal frame
46
43
  WxSugar.define_keyword_ctors('Frame') do
47
44
  wx_ctor_params :title => ''
@@ -255,7 +255,6 @@ module KeywordConstructor
255
255
  # Any class inheriting from a class including this module must have
256
256
  # its own copy of the param_spec
257
257
  def klass.inherited(sub_klass)
258
- # sub_klass.module_eval { include KeywordConstructor }
259
258
  sub_klass.instance_variable_set(:@param_spec,
260
259
  self.instance_variable_get(:@param_spec) )
261
260
  sub_klass.instance_variable_set(:@param_flags,
@@ -87,14 +87,25 @@ module Arranger
87
87
  def arrange(a_sizer, layout = {})
88
88
  # run as a subordinate block
89
89
  if block_given? and @current_sizer
90
+ if layout[:padding]
91
+ old_padding = @padding
92
+ @padding = layout[:padding]
93
+ end
94
+
90
95
  superior_sizer, @current_sizer = @current_sizer, a_sizer
91
96
  yield(self)
92
97
  @current_sizer = superior_sizer
93
98
  proportion = layout[:proportion] || 0
94
99
  superior_sizer.add( a_sizer, proportion,
95
- Wx::EXPAND|Wx::ALL|Wx::ADJUST_MINSIZE, padding)
100
+ Wx::EXPAND|Wx::ALL|Wx::ADJUST_MINSIZE,
101
+ padding)
102
+
103
+ if layout[:padding]
104
+ @padding = old_padding
105
+ end
96
106
  # set as main sizer
97
107
  else
108
+ @padding = layout[:padding] if layout[:padding]
98
109
  @current_sizer = a_sizer
99
110
  yield(self) if block_given?
100
111
  self.set_sizer(a_sizer)
@@ -130,7 +141,6 @@ module Arranger
130
141
  end
131
142
 
132
143
  def arrange_linear( layout = { }, &block)
133
- @padding = layout[:padding] if layout[:padding]
134
144
  if layout[:direction].to_s.downcase == 'horizontal'
135
145
  direction = Wx::HORIZONTAL
136
146
  elsif layout[:direction].to_s.downcase == 'vertical'
@@ -202,7 +212,7 @@ module Arranger
202
212
  if layout_hints[:minsize]
203
213
  layout = layout | Wx::ADJUST_MINSIZE|Wx::EXPAND
204
214
  end
205
- if layout_hints[:expand] || layout_hints[:proportion]
215
+ if layout_hints[:proportion]
206
216
  layout = layout | Wx::EXPAND
207
217
  end
208
218
 
@@ -0,0 +1,4 @@
1
+ # Automatic loader for all the extensions to core Wx classes
2
+ Dir.glob( __FILE__.sub(/\.rb$/, File::SEPARATOR + '*.rb' ) ).each do | f |
3
+ require 'wx_sugar/wx_classes/' + File.basename(f)
4
+ end
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.0
7
- date: 2006-09-07
6
+ version: 0.1.1
7
+ date: 2006-09-15
8
8
  summary: Syntax extensions for WxRuby.
9
9
  require_paths:
10
10
  - lib
@@ -37,6 +37,7 @@ files:
37
37
  - lib/wx_sugar/keyword_constructors.rb
38
38
  - lib/wx_sugar/layout.rb
39
39
  - lib/wx_sugar/menu.rb
40
+ - lib/wx_sugar/wx_classes.rb
40
41
  test_files: []
41
42
  rdoc_options: []
42
43
  extra_rdoc_files: []