fxruby 1.6.11 → 1.6.12

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.
data/lib/fox16/core.rb CHANGED
@@ -182,6 +182,25 @@ module Fox
182
182
  end
183
183
  end
184
184
  end
185
+
186
+ class FXHiliteStyle
187
+ #
188
+ # Construct a new FXHiliteStyle instance, with fields initialized from
189
+ # an FXText instance.
190
+ #
191
+ def FXHiliteStyle.from_text(textw)
192
+ hs = new
193
+ hs.activeBackColor = textw.activeBackColor
194
+ hs.hiliteBackColor = textw.hiliteBackColor
195
+ hs.hiliteForeColor = textw.hiliteTextColor
196
+ hs.normalBackColor = textw.backColor
197
+ hs.normalForeColor = textw.textColor
198
+ hs.selectBackColor = textw.selBackColor
199
+ hs.selectForeColor = textw.selTextColor
200
+ hs.style = 0
201
+ hs
202
+ end
203
+ end
185
204
 
186
205
  class FXScrollArea
187
206
  # Returns a reference to the scroll corner (an FXScrollCorner instance) for this window.
data/lib/fox16/input.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  module Fox
2
+
2
3
  class FXApp
3
4
 
4
5
  alias addInputOrig addInput # :nodoc:
@@ -31,24 +32,28 @@ module Fox
31
32
  #
32
33
 
33
34
  def addInput(fd, mode, *args, &block)
35
+ params = {}
36
+ params = args.pop if args.last.is_a? Hash
34
37
  tgt, sel = nil, 0
35
38
  if args.length > 0
36
39
  if args[0].respond_to? :call
37
40
  tgt = FXPseudoTarget.new
38
- tgt.pconnect(SEL_IO_READ, args[0], block)
39
- tgt.pconnect(SEL_IO_WRITE, args[0], block)
40
- tgt.pconnect(SEL_IO_EXCEPT, args[0], block)
41
+ tgt.pconnect(SEL_IO_READ, args[0], params)
42
+ tgt.pconnect(SEL_IO_WRITE, args[0], params)
43
+ tgt.pconnect(SEL_IO_EXCEPT, args[0], params)
41
44
  else # it's some other kind of object
42
45
  tgt = args[0]
43
46
  sel = args[1]
44
47
  end
45
48
  else
46
49
  tgt = FXPseudoTarget.new
47
- tgt.pconnect(SEL_IO_READ, nil, block)
48
- tgt.pconnect(SEL_IO_WRITE, nil, block)
49
- tgt.pconnect(SEL_IO_EXCEPT, nil, block)
50
+ tgt.pconnect(SEL_IO_READ, block, params)
51
+ tgt.pconnect(SEL_IO_WRITE, block, params)
52
+ tgt.pconnect(SEL_IO_EXCEPT, block, params)
50
53
  end
51
54
  addInputOrig(fd, mode, tgt, sel)
52
55
  end
53
- end
54
- end
56
+
57
+ end # class FXApp
58
+
59
+ end # module Fox
data/lib/fox16/kwargs.rb CHANGED
@@ -56,7 +56,9 @@ module Fox
56
56
  end
57
57
 
58
58
  class FXFont
59
+
59
60
  alias old_initialize initialize
61
+
60
62
  def initialize(a, arg1, *args, &blk)
61
63
  if args.length > 0
62
64
  face, size = arg1, args[0]
@@ -72,6 +74,22 @@ module Fox
72
74
  old_initialize(a, arg1, &blk)
73
75
  end
74
76
  end
77
+
78
+ class << self
79
+ alias old_listFonts listFonts
80
+ end
81
+
82
+ def FXFont.listFonts(face, *args)
83
+ argument_names = %w{weight slant setWidth encoding hints}
84
+ default_params = { :weight => 0, :slant => 0, :setWidth => 0, :encoding => 0, :hints => 0 }
85
+ params = {}
86
+ params = args.pop if args.last.is_a? Hash
87
+ args.each_with_index { |e, i| params[argument_names[i].intern] = e }
88
+ params.keys.each { |key| raise ArgumentError, "Unrecognized parameter #{key}" unless default_params.keys.include?(key) }
89
+ params = default_params.merge(params)
90
+ old_listFonts(face, params[:weight], params[:slant], params[:setWidth], params[:encoding], params[:hints])
91
+ end
92
+
75
93
  end
76
94
 
77
95
  class FXGLCanvas
@@ -1654,6 +1672,24 @@ module Fox
1654
1672
  end
1655
1673
  end
1656
1674
 
1675
+ class FXPacker
1676
+ alias old_initialize initialize
1677
+ def initialize(parent, *args, &blk)
1678
+ argument_names = %w{opts x y width height padLeft padRight padTop padBottom hSpacing vSpacing}
1679
+ default_params = { :opts => 0, :x => 0, :y => 0, :width => 0, :height => 0, :padLeft => DEFAULT_SPACING, :padRight => DEFAULT_SPACING, :padTop => DEFAULT_SPACING, :padBottom => DEFAULT_SPACING, :hSpacing => DEFAULT_SPACING, :vSpacing => DEFAULT_SPACING }
1680
+ params = {}
1681
+ params = args.pop if args.last.is_a? Hash
1682
+ args.each_with_index { |e, i| params[argument_names[i].intern] = e }
1683
+ if params.key? :padding
1684
+ value = params.delete(:padding)
1685
+ [:padLeft, :padRight, :padTop, :padBottom].each { |s| params[s] ||= value }
1686
+ end
1687
+ params.keys.each { |key| raise ArgumentError, "Unrecognized parameter #{key}" unless default_params.keys.include?(key) }
1688
+ params = default_params.merge(params)
1689
+ old_initialize(parent, params[:opts], params[:x], params[:y], params[:width], params[:height], params[:padLeft], params[:padRight], params[:padTop], params[:padBottom], params[:hSpacing], params[:vSpacing], &blk)
1690
+ end
1691
+ end
1692
+
1657
1693
  class FXPCXIcon
1658
1694
  alias old_initialize initialize
1659
1695
  def initialize(a, *args, &blk)
@@ -21,30 +21,25 @@ module Fox
21
21
  #
22
22
  def initialize
23
23
  super
24
- @blocks = {}
24
+ @context = {}
25
25
  end
26
26
 
27
27
  #
28
28
  # Store an association between a message of type
29
- # _messageType_ with a callable object or a block.
29
+ # _message_type_ with a callable object.
30
30
  #
31
- def pconnect(messageType, callableObject, block)
32
- if callableObject.nil?
33
- @blocks[messageType] = block
34
- else
35
- @blocks[messageType] = callableObject
36
- end
37
- FXMAPTYPE(messageType, :onHandleMsg)
38
-
39
- case messageType
40
- when SEL_TIMEOUT
41
- @@targets_of_pending_timers[self] = self
42
- when SEL_CHORE
43
- @@targets_of_pending_chores[self] = self
44
- when SEL_SIGNAL
45
- @@targets_of_pending_signals[self] = self
46
- when SEL_IO_READ, SEL_IO_WRITE, SEL_IO_EXCEPT
47
- @@targets_of_pending_inputs[self] = self
31
+ def pconnect(message_type, callable_object, params={})
32
+ @context[message_type] = { :callable => callable_object, :params => params }
33
+ FXMAPTYPE(message_type, :onHandleMsg)
34
+ case message_type
35
+ when SEL_TIMEOUT
36
+ @@targets_of_pending_timers[self] = self
37
+ when SEL_CHORE
38
+ @@targets_of_pending_chores[self] = self
39
+ when SEL_SIGNAL
40
+ @@targets_of_pending_signals[self] = self
41
+ when SEL_IO_READ, SEL_IO_WRITE, SEL_IO_EXCEPT
42
+ @@targets_of_pending_inputs[self] = self
48
43
  end
49
44
  end
50
45
 
@@ -53,18 +48,31 @@ module Fox
53
48
  # message data _ptr_.
54
49
  #
55
50
  def onHandleMsg(sender, sel, ptr)
56
- messageType = Fox.FXSELTYPE(sel)
57
- result = @blocks[messageType].call(sender, sel, ptr)
58
- case messageType
59
- when SEL_TIMEOUT
60
- @@targets_of_pending_timers.delete(self)
61
- when SEL_CHORE
62
- @@targets_of_pending_chores.delete(self)
51
+ message_type = Fox.FXSELTYPE(sel)
52
+ ctx = @context[message_type]
53
+ callable_object = ctx[:callable]
54
+ params = ctx[:params]
55
+ result = callable_object.call(sender, sel, ptr)
56
+ case message_type
57
+ when SEL_TIMEOUT
58
+ if params[:repeat]
59
+ FXApp.instance.addTimeout(params[:delay], callable_object, params)
60
+ else
61
+ @@targets_of_pending_timers.delete(self)
62
+ end
63
+ when SEL_CHORE
64
+ if params[:repeat]
65
+ FXApp.instance.addChore(callable_object, params)
66
+ else
67
+ @@targets_of_pending_chores.delete(self)
68
+ end
63
69
  end
64
70
  result
65
71
  end
66
- end
67
- end
72
+
73
+ end # class FXPseudoTarget
74
+
75
+ end # module Fox
68
76
 
69
77
  #
70
78
  # The Responder2 module provides the #connect method,
@@ -95,13 +103,14 @@ module Responder2
95
103
  # will be "called" with three arguments (the sender, selector and
96
104
  # message data).
97
105
  #
98
- def connect(messageType, callableObject=nil, &block)
106
+ def connect(message_type, callable_object=nil, &block)
99
107
  unless instance_variables.include?('@pseudoTarget')
100
108
  @pseudoTarget = Fox::FXPseudoTarget.new
101
109
  self.target = @pseudoTarget
102
110
  end
103
- @pseudoTarget.pconnect(messageType, callableObject, block)
111
+ @pseudoTarget.pconnect(message_type, callable_object ? callable_object : block)
104
112
  end
113
+
105
114
  end
106
115
 
107
116
  module Fox
data/lib/fox16/signal.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  module Fox
2
+
2
3
  class FXApp
3
4
 
4
5
  alias addSignalOrig addSignal # :nodoc:
@@ -18,7 +19,7 @@ module Fox
18
19
  # the message to be sent when this signal is raised.
19
20
  # If _sendImmediately_ is +true+, the message will be sent to the target right away;
20
21
  # this should be used with extreme care as the application is interrupted
21
- # at an unknown point it its execution.
22
+ # at an unknown point in its execution.
22
23
  # The _flags_ are to be set as per POSIX definitions.
23
24
  #
24
25
  # A second form of #addSignal takes a Method instance as its second argument:
@@ -38,16 +39,18 @@ module Fox
38
39
  #
39
40
 
40
41
  def addSignal(sig, *args, &block)
42
+ params = {}
43
+ params = args.pop if args.last.is_a? Hash
41
44
  tgt, sel, immediate, flags = nil, 0, false, 0
42
45
  if args.length > 0
43
46
  if args[0].respond_to? :call
44
47
  tgt = FXPseudoTarget.new
45
- tgt.pconnect(SEL_SIGNAL, args[0], block)
48
+ tgt.pconnect(SEL_SIGNAL, args[0], params)
46
49
  immediate = (args.length > 1) ? args[1] : false
47
50
  flags = (args.length > 2) ? args[2] : 0
48
51
  elsif (args[0].kind_of? TrueClass) || (args[0].kind_of? FalseClass)
49
52
  tgt = FXPseudoTarget.new
50
- tgt.pconnect(SEL_SIGNAL, nil, block)
53
+ tgt.pconnect(SEL_SIGNAL, block, params)
51
54
  immediate = args[0]
52
55
  flags = (args.length > 1) ? args[1] : 0
53
56
  else # it's some other kind of object
@@ -58,9 +61,11 @@ module Fox
58
61
  end
59
62
  else
60
63
  tgt = FXPseudoTarget.new
61
- tgt.pconnect(SEL_SIGNAL, nil, block)
64
+ tgt.pconnect(SEL_SIGNAL, block, params)
62
65
  end
63
66
  addSignalOrig(sig, tgt, sel, immediate, flags)
64
67
  end
65
- end
66
- end
68
+
69
+ end # class FXApp
70
+
71
+ end # module Fox
data/lib/fox16/timeout.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  module Fox
2
+
2
3
  class FXApp
3
4
 
4
5
  alias addTimeoutOrig addTimeout # :nodoc:
@@ -7,8 +8,8 @@ module Fox
7
8
  alias remainingTimeoutOrig remainingTimeout # :nodoc:
8
9
 
9
10
  #
10
- # Add a timeout message to be sent to target object in _ms_ milliseconds;
11
- # the timer fires only once after the interval expires. The last argument
11
+ # Add a timeout message to be sent to target object in _ms_ milliseconds.
12
+ # By default, the timer fires only once after the interval expires. The last argument
12
13
  # is optional user data which will be passed along as the _ptr_ argument of
13
14
  # the message handler. If a timer with the same target and message already exists,
14
15
  # it will be rescheduled.
@@ -34,30 +35,43 @@ module Fox
34
35
  #
35
36
  # The last form of #addTimeout takes a block:
36
37
  #
37
- # timeout = app.addTimeout(delay) { |sender, sel, data|
38
+ # timeout = app.addTimeout(delay) do |sender, sel, data|
38
39
  # ... handle the timeout ...
39
- # }
40
+ # end
40
41
  #
41
42
  # All of these return a reference to an opaque object (actually, a hash) that
42
43
  # can be passed to #removeTimeout if it is necessary to remove the timeout
43
44
  # before it fires.
44
45
  #
46
+ # For the last two forms, you can pass in the optional +:repeat+ parameter to
47
+ # cause the timeout to be re-registered after it fires, e.g.
48
+ #
49
+ # timeout = app.addTimeout(delay, :repeat => true) do |sender, sel, data|
50
+ # ... handle the timeout ...
51
+ # ... re-add the timeout with the same delay ...
52
+ # end
53
+ #
45
54
  def addTimeout(ms, *args, &block)
55
+ params = {}
56
+ params = args.pop if args.last.is_a? Hash
57
+ params[:delay] = ms
46
58
  tgt, sel = nil, 0
47
59
  if args.length > 0
48
60
  if args[0].respond_to? :call
49
- tgt = FXPseudoTarget.new
50
- tgt.pconnect(SEL_TIMEOUT, args[0], nil)
61
+ tgt = params[:target] || FXPseudoTarget.new
62
+ tgt.pconnect(SEL_TIMEOUT, args[0], params)
51
63
  else # it's some other kind of object
52
64
  tgt = args[0]
53
65
  sel = args[1]
54
66
  end
55
67
  else
56
- tgt = FXPseudoTarget.new
57
- tgt.pconnect(SEL_TIMEOUT, nil, block)
68
+ tgt = params[:target] || FXPseudoTarget.new
69
+ tgt.pconnect(SEL_TIMEOUT, block, params)
58
70
  end
59
71
  addTimeoutOrig(tgt, sel, ms)
60
- return { :target => tgt, :selector => sel }
72
+ params[:target] = tgt
73
+ params[:selector] = sel
74
+ params
61
75
  end
62
76
 
63
77
  #
@@ -69,8 +83,8 @@ module Fox
69
83
  if args.length == 2
70
84
  removeTimeoutOrig(args[0], args[1])
71
85
  else
72
- hsh = args[0]
73
- removeTimeoutOrig(hsh[:target], hsh[:selector])
86
+ params = args[0]
87
+ removeTimeoutOrig(params[:target], params[:selector])
74
88
  end
75
89
  end
76
90
 
@@ -116,5 +130,7 @@ module Fox
116
130
  remainingTimeoutOrig(hsh[:target], hsh[:selector])
117
131
  end
118
132
  end
119
- end
120
- end
133
+
134
+ end # class FXApp
135
+
136
+ end # module Fox
data/lib/fox16/version.rb CHANGED
@@ -3,7 +3,7 @@ module Fox
3
3
  # Returns the FXRuby version number as a string, e.g. "1.0.19".
4
4
  #
5
5
  def Fox.fxrubyversion
6
- "1.6.11"
6
+ "1.6.12"
7
7
  end
8
8
  end
9
9
 
@@ -14,7 +14,7 @@ module Fox
14
14
  # The option <tt>BUTTON_AUTOGRAY</tt> (<tt>BUTTON_AUTOHIDE</tt>) causes the button to be grayed
15
15
  # out (hidden) if its handler does not respond to the <tt>SEL_UPDATE</tt> message.
16
16
  # This is useful when messages are delegated, for example when using a
17
- # multiple document interface, where the ultimaye destination of a message
17
+ # multiple document interface, where the ultimate destination of a message
18
18
  # can be changed.
19
19
  #
20
20
  # === Events
@@ -48,7 +48,7 @@ module Fox
48
48
  #
49
49
  # Make cursor from FXColor pixels; cursor size should be 32x32 for portability!
50
50
  #
51
- def initialize(a, src, msk, width=32, height=32, hotX=-1, hotY=-1) # :yields: theCursor
51
+ def initialize(a, pixels, width=32, height=32, hotX=-1, hotY=-1) # :yields: theCursor
52
52
  end
53
53
 
54
54
  #
@@ -165,6 +165,86 @@ module Fox
165
165
  # +color+:: fill color for blank areas after crop [FXColor]
166
166
  #
167
167
  def crop(x, y, w, h, color=0) ; end
168
+
169
+ # Fill image with uniform color.
170
+ def fill(color); end
171
+
172
+ #
173
+ # Fade an image to a certain color by a certain factor. The _factor_ is
174
+ # some integer value between 0 and 255 inclusive, where a factor of 255 indicates no fading and a factor
175
+ # of zero indicates that the image is completely faded to the fade _color_.
176
+ #
177
+ # ==== Parameters:
178
+ #
179
+ # +color+:: the fade color [FXColor]
180
+ # +factor+:: fading factor [Integer]
181
+ #
182
+ def fade(color, factor=255); end
183
+
184
+ #
185
+ # Shear image horizontally; the number of pixels is equal to the
186
+ # _shear_ parameter times 256. The area outside the image is filled
187
+ # with transparent black, unless another _color_ is specified.
188
+ #
189
+ # ==== Parameters:
190
+ #
191
+ # +shear+:: how far to shear [Integer]
192
+ # +color+:: fill color for areas outside the sheared image [FXColor]
193
+ #
194
+ def xshear(shear, color=0); end
195
+
196
+ #
197
+ # Shear image vertically; the number of pixels is equal to the
198
+ # _shear_ parameter times 256. The area outside the image is filled
199
+ # with transparent black, unless another _color_ is specified.
200
+ #
201
+ # ==== Parameters:
202
+ #
203
+ # +shear+:: how far to shear [Integer]
204
+ # +color+:: fill color for areas outside the sheared image [FXColor]
205
+ #
206
+ def yshear(shear, color=0); end
207
+
208
+ #
209
+ # Fill image using a horizontal gradient.
210
+ #
211
+ # ==== Parameters:
212
+ #
213
+ # +left+:: starting color, for leftmost pixels [FXColor]
214
+ # +right+:: ending color, for rightmost pixels [FXColor]
215
+ #
216
+ def hgradient(left, right); end
217
+
218
+ #
219
+ # Fill image using a vertical gradient.
220
+ #
221
+ # ==== Parameters:
222
+ #
223
+ # +top+:: starting color, for topmost pixels [FXColor]
224
+ # +bottom+:: ending color, for bottommost pixels [FXColor]
225
+ #
226
+ def vgradient(top, bottom); end
227
+
228
+ #
229
+ # Fill image using a bilinear gradient.
230
+ #
231
+ # ==== Parameters:
232
+ #
233
+ # +topleft+:: pixel color for top-left corner [FXColor]
234
+ # +topright+:: pixel color for top-right corner [FXColor]
235
+ # +bottomleft+:: pixel color for bottom-left corner [FXColor]
236
+ # +bottomright+:: pixel color for bottom-right corner [FXColor]
237
+ #
238
+ def gradient(topleft, topright, bottomleft, bottomright); end
239
+
240
+ #
241
+ # Blend image over uniform color.
242
+ #
243
+ # ==== Parameters:
244
+ #
245
+ # +color+:: the blended color [FXColor]
246
+ #
247
+ def blend(color); end
168
248
 
169
249
  #
170
250
  # Save pixel data to a stream.