wxruby 1.9.0-powerpc-darwin8.10.0 → 1.9.2-powerpc-darwin8.10.0
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/LICENSE +53 -0
- data/README +299 -0
- data/lib/wx.rb +7 -0
- data/lib/wx/accessors.rb +52 -0
- data/lib/wx/classes/app.rb +15 -1
- data/lib/wx/classes/bitmap.rb +2 -2
- data/lib/wx/classes/checklistbox.rb +30 -0
- data/lib/wx/classes/clientdc.rb +1 -1
- data/lib/wx/classes/commandevent.rb +7 -0
- data/lib/wx/classes/controlwithitems.rb +10 -0
- data/lib/wx/classes/evthandler.rb +99 -39
- data/lib/wx/classes/grid.rb +13 -13
- data/lib/wx/classes/listctrl.rb +9 -0
- data/lib/wx/classes/menu.rb +62 -0
- data/lib/wx/classes/menuitem.rb +7 -0
- data/lib/wx/classes/paintdc.rb +1 -1
- data/lib/wx/classes/point.rb +43 -0
- data/lib/wx/classes/size.rb +44 -0
- data/lib/wx/classes/styledtextctrl.rb +92 -0
- data/lib/wx/classes/textctrl.rb +14 -0
- data/lib/wx/classes/timer.rb +2 -2
- data/lib/wx/classes/treectrl.rb +18 -0
- data/lib/wx/classes/window.rb +13 -2
- data/lib/wx/keyword_ctors.rb +205 -0
- data/lib/wx/keyword_defs.rb +465 -0
- data/lib/wx/version.rb +1 -1
- data/lib/wxruby2.bundle +0 -0
- data/samples/aui/aui.rb +6 -5
- data/samples/bigdemo/wxListCtrl_virtual.rbw +21 -21
- data/samples/bigdemo/wxScrolledWindow.rbw +8 -3
- data/samples/calendar/calendar.rb +1 -1
- data/samples/caret/caret.rb +29 -39
- data/samples/etc/threaded.rb +81 -0
- data/samples/etc/wizard.rb +22 -24
- data/samples/event/event.rb +184 -0
- data/samples/html/html.rb +25 -12
- data/samples/listbook/listbook.rb +65 -67
- data/samples/minimal/minimal.rb +40 -50
- data/samples/minimal/mondrian.png +0 -0
- data/samples/minimal/nothing.rb +5 -30
- data/samples/text/scintilla.rb +22 -28
- data/samples/text/unicode.rb +1 -1
- data/samples/treectrl/treectrl.rb +197 -226
- metadata +20 -4
- data/samples/minimal/mondrian.xpm +0 -44
- data/samples/minimal/text.rb +0 -35
@@ -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
|
data/lib/wx/classes/clientdc.rb
CHANGED
@@ -5,7 +5,7 @@ class Wx::ClientDC
|
|
5
5
|
# always be used via Window#paint, which takes a block receiving the
|
6
6
|
# DC. This ensures that the DC is cleaned up at the correct time,
|
7
7
|
# avoiding errors and segfaults on exit.
|
8
|
-
|
8
|
+
define_method(:initialize) do | *args |
|
9
9
|
Kernel.raise RuntimeError,
|
10
10
|
"Do not instantiate ClientDC directly; use Window#paint",
|
11
11
|
caller[1..-1]
|
@@ -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
|
@@ -16,14 +16,17 @@ class Wx::EvtHandler
|
|
16
16
|
EventType = Struct.new(:name, :arity, :const, :evt_class)
|
17
17
|
|
18
18
|
# Fast look-up hash to map event type ids to ruby event classes
|
19
|
-
|
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 = {}
|
20
23
|
|
21
24
|
# Given a Wx EventType id (eg Wx::EVT_MENU), returns a WxRuby Event
|
22
25
|
# class which should be passed to event handler blocks. The actual
|
23
26
|
# EVT_XXX constants themselves are in the compiled library, defined in
|
24
27
|
# swig/classes/Event.i
|
25
28
|
def self.event_class_for_type(id)
|
26
|
-
if evt_klass =
|
29
|
+
if evt_klass = EVENT_TYPE_CLASS_MAP[id]
|
27
30
|
return evt_klass
|
28
31
|
else
|
29
32
|
warn "No event class defined for event type #{id}"
|
@@ -31,6 +34,19 @@ class Wx::EvtHandler
|
|
31
34
|
end
|
32
35
|
end
|
33
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
|
+
|
34
50
|
# Public method to register the mapping of a custom event type
|
35
51
|
# +konstant+ (which should be a unique integer; one will be created if
|
36
52
|
# not supplied) to a custom event class +klass+. If +meth+ and +arity+
|
@@ -48,31 +64,90 @@ class Wx::EvtHandler
|
|
48
64
|
end
|
49
65
|
|
50
66
|
# Registers the event type +ev_type+, which should be an instance of
|
51
|
-
# the Struct class +Wx::EvtHandler::EventType+.
|
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.
|
52
71
|
def self.register_event_type(ev_type)
|
53
|
-
|
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
|
+
|
54
76
|
unless ev_type.arity and ev_type.name
|
55
77
|
return
|
56
78
|
end
|
79
|
+
|
80
|
+
# set up the evt_xxx method
|
57
81
|
case ev_type.arity
|
58
82
|
when 0 # events without an id
|
59
83
|
class_eval %Q|
|
60
|
-
def #{ev_type.name}(&block)
|
61
|
-
|
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)
|
62
87
|
end |
|
63
88
|
when 1 # events with an id
|
64
89
|
class_eval %Q|
|
65
|
-
def #{ev_type.name}(id, &block)
|
66
|
-
|
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)
|
67
94
|
end |
|
68
95
|
when 2 # events with id range
|
69
96
|
class_eval %Q|
|
70
|
-
def #{ev_type.name}(first_id, last_id, &block)
|
71
|
-
|
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)
|
72
102
|
end |
|
73
103
|
end
|
74
104
|
end
|
75
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.
|
76
151
|
EVENT_DEFINITIONS = [
|
77
152
|
EventType['evt_activate', 0,
|
78
153
|
Wx::EVT_ACTIVATE,
|
@@ -173,6 +248,9 @@ class Wx::EvtHandler
|
|
173
248
|
EventType['evt_close', 0,
|
174
249
|
Wx::EVT_CLOSE_WINDOW,
|
175
250
|
Wx::CloseEvent],
|
251
|
+
EventType['evt_collapsiblepane_changed', 1,
|
252
|
+
Wx::EVT_COMMAND_COLLPANE_CHANGED,
|
253
|
+
Wx::CollapsiblePaneEvent],
|
176
254
|
EventType['evt_combobox', 1,
|
177
255
|
Wx::EVT_COMMAND_COMBOBOX_SELECTED,
|
178
256
|
Wx::CommandEvent],
|
@@ -791,34 +869,16 @@ class Wx::EvtHandler
|
|
791
869
|
evt_mousewheel(&block)
|
792
870
|
end
|
793
871
|
|
794
|
-
#
|
795
|
-
|
796
|
-
|
797
|
-
|
798
|
-
|
799
|
-
|
800
|
-
|
801
|
-
|
802
|
-
|
803
|
-
|
804
|
-
|
805
|
-
# Wx::EVT_SCI_UPDATEUI => Wx::ScintillaEvent,
|
806
|
-
# Wx::EVT_SCI_MODIFIED => Wx::ScintillaEvent,
|
807
|
-
# Wx::EVT_SCI_MACRORECORD => Wx::ScintillaEvent,
|
808
|
-
# Wx::EVT_SCI_MARGINCLICK => Wx::ScintillaEvent,
|
809
|
-
# Wx::EVT_SCI_NEEDSHOWN => Wx::ScintillaEvent,
|
810
|
-
# Wx::EVT_SCI_PAINTED => Wx::ScintillaEvent,
|
811
|
-
# Wx::EVT_SCI_USERLISTSELECTION => Wx::ScintillaEvent,
|
812
|
-
# Wx::EVT_SCI_URIDROPPED => Wx::ScintillaEvent,
|
813
|
-
# Wx::EVT_SCI_DWELLSTART => Wx::ScintillaEvent,
|
814
|
-
# Wx::EVT_SCI_DWELLEND => Wx::ScintillaEvent,
|
815
|
-
# Wx::EVT_SCI_START_DRAG => Wx::ScintillaEvent,
|
816
|
-
# Wx::EVT_SCI_DRAG_OVER => Wx::ScintillaEvent,
|
817
|
-
# Wx::EVT_SCI_DO_DROP => Wx::ScintillaEvent,
|
818
|
-
# Wx::EVT_SCI_ZOOM => Wx::ScintillaEvent,
|
819
|
-
# Wx::EVT_SCI_HOTSPOT_CLICK => Wx::ScintillaEvent,
|
820
|
-
# Wx::EVT_SCI_HOTSPOT_DCLICK => Wx::ScintillaEvent,
|
821
|
-
# Wx::EVT_SCI_CALLTIP_CLICK => Wx::ScintillaEvent )
|
822
|
-
# end
|
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
|
823
883
|
end
|
824
884
|
|
data/lib/wx/classes/grid.rb
CHANGED
@@ -84,18 +84,18 @@ class Wx::Grid
|
|
84
84
|
# This and the following methods do a bit of book-keeping - as rows
|
85
85
|
# and columns are deleted and inserted, the position of the columns
|
86
86
|
# and rows with stored editors and renderers may move.
|
87
|
-
|
88
|
-
|
89
|
-
|
87
|
+
alias :__insert_rows :insert_rows
|
88
|
+
def insert_rows(pos = 0, num = 1, update_labels = true)
|
89
|
+
__insert_rows(pos, num, update_labels)
|
90
90
|
num.times { @__row_editors.insert(pos, nil) }
|
91
91
|
num.times { @__row_renderers.insert(pos, nil) }
|
92
92
|
num.times { @__cell_editors.insert(pos, []) }
|
93
93
|
num.times { @__cell_renderers.insert(pos, []) }
|
94
94
|
end
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
95
|
+
|
96
|
+
alias :__insert_cols :insert_cols
|
97
|
+
def insert_cols(pos = 0, num = 1, update_labels = true)
|
98
|
+
__insert_cols(pos, num, update_labels)
|
99
99
|
num.times { @__col_editors.insert(pos, nil) }
|
100
100
|
num.times { @__col_renderers.insert(pos, nil) }
|
101
101
|
num.times do
|
@@ -106,18 +106,18 @@ class Wx::Grid
|
|
106
106
|
end
|
107
107
|
end
|
108
108
|
|
109
|
-
|
110
|
-
|
111
|
-
|
109
|
+
alias :__delete_rows :delete_rows
|
110
|
+
def delete_rows(pos = 0, num = 1, update_labels = true)
|
111
|
+
__delete_rows(pos, num, update_labels)
|
112
112
|
@__row_editors.slice!(pos, num)
|
113
113
|
@__row_renderers.slice!(pos, num)
|
114
114
|
@__cell_editors.slice!(pos, num)
|
115
115
|
@__cell_renderers.slice!(pos, num)
|
116
116
|
end
|
117
117
|
|
118
|
-
|
119
|
-
|
120
|
-
|
118
|
+
alias :__delete_cols :delete_cols
|
119
|
+
def delete_cols(pos = 0, num = 1, update_labels = true)
|
120
|
+
__delete_cols(pos, num, update_labels)
|
121
121
|
@__col_editors.slice!(pos, num)
|
122
122
|
@__col_renderers.slice!(pos, num)
|
123
123
|
num.times do
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# Multi-item control with numerous possible view styles
|
2
|
+
class Wx::ListCtrl
|
3
|
+
# Make these ruby enumerables so find, find_all, map are available
|
4
|
+
include Enumerable
|
5
|
+
# Passes each valid item index into the passed block
|
6
|
+
def each
|
7
|
+
0.upto(item_count - 1) { | i | yield i }
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,62 @@
|
|
1
|
+
# A single labelled list within a drop-down menu, or a popup menu
|
2
|
+
class Wx::Menu
|
3
|
+
|
4
|
+
# In the standard WxWidgets API, the methods append, prepend, insert
|
5
|
+
# (and their variants) require a constant integer id as the identifier
|
6
|
+
# of the menu item. This is then used in event handling.
|
7
|
+
#
|
8
|
+
# In WxRuby the use of explicit ids can be avoided in most cases,
|
9
|
+
# being a most unruby-ish practice. So, by analogy with the general
|
10
|
+
# use of Wx::Window classes and event handlers, where the id is
|
11
|
+
# implicit in the constructor, and the window can be passed direct to
|
12
|
+
# the event handler setup method, the below sets up a similar facility
|
13
|
+
# for adding items to Wx::Menu.
|
14
|
+
#
|
15
|
+
# For all these methods, the only required argument is the string name
|
16
|
+
# of the menu item; a system-default id will be supplied if no
|
17
|
+
# explicit one is given. The return value of these methods in all
|
18
|
+
# cases is a Wx::MenuItem object, which can be passed directly as the
|
19
|
+
# first argument to an evt_menu handler.
|
20
|
+
def self.methods_with_optional_ids(*meth_names)
|
21
|
+
class_eval do
|
22
|
+
meth_names.each do | meth |
|
23
|
+
old_meth = instance_method(meth)
|
24
|
+
define_method(meth) do | *args |
|
25
|
+
case args.first
|
26
|
+
when Fixnum : old_meth.bind(self).call(*args)
|
27
|
+
when String : old_meth.bind(self).call(Wx::ID_ANY, *args)
|
28
|
+
when Wx::MenuItem : old_meth.bind(self).call(args.first)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# Create the optional-id methods
|
36
|
+
methods_with_optional_ids :append, :prepend,
|
37
|
+
:append_check_item, :prepend_check_item,
|
38
|
+
:append_radio_item, :prepend_radio_item
|
39
|
+
|
40
|
+
# This is much the same as above, except for insert and variants,
|
41
|
+
# which take an additional first argument, the position at which to
|
42
|
+
# insert the new item.
|
43
|
+
def self.methods_with_optional_ids_and_pos(*meth_names)
|
44
|
+
class_eval do
|
45
|
+
meth_names.each do | meth |
|
46
|
+
old_meth = instance_method(meth)
|
47
|
+
define_method(meth) do | pos, *args |
|
48
|
+
case args.first
|
49
|
+
when Fixnum : old_meth.bind(self).call(pos, *args)
|
50
|
+
when String : old_meth.bind(self).call(pos, Wx::ID_ANY, *args)
|
51
|
+
when Wx::MenuItem : old_meth.bind(self).call(pos, args.first)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
# Create the optional-id methods
|
59
|
+
methods_with_optional_ids_and_pos :insert,
|
60
|
+
:insert_check_item,
|
61
|
+
:insert_radio_item
|
62
|
+
end
|
data/lib/wx/classes/paintdc.rb
CHANGED
@@ -4,7 +4,7 @@ class Wx::PaintDC
|
|
4
4
|
# always be used via Window#paint, which takes a block receiving the
|
5
5
|
# DC. This ensures that the DC is cleaned up at the correct time,
|
6
6
|
# preventing serious errors on some platforms.
|
7
|
-
|
7
|
+
define_method(:initialize) do | *args |
|
8
8
|
Kernel.raise RuntimeError,
|
9
9
|
"Do not instantiate PaintDC directly; use Window#paint",
|
10
10
|
caller[1..-1]
|
data/lib/wx/classes/point.rb
CHANGED
@@ -1,5 +1,48 @@
|
|
1
1
|
class Wx::Point
|
2
|
+
# More informative output when converted to string
|
2
3
|
def to_s
|
3
4
|
"#<Wx::Point: (#{x}, #{y})>"
|
4
5
|
end
|
6
|
+
|
7
|
+
# Return a new Wx::Point with the x and y parameters both divided by
|
8
|
+
# parameter +div+, which should be a Numeric
|
9
|
+
def /(div)
|
10
|
+
self.class.new( (get_x / div).to_i, (get_y / div).to_i )
|
11
|
+
end
|
12
|
+
|
13
|
+
# Return a new Wx::Point with the x and y values both multiplied by
|
14
|
+
# parameter +mul+, which should be a Numeric
|
15
|
+
def *(mul)
|
16
|
+
self.class.new( (get_x * mul).to_i, (get_y * mul).to_i )
|
17
|
+
end
|
18
|
+
|
19
|
+
# Return a new Wx::Point with the x and y values both reduced by
|
20
|
+
# parameter +arg+. If +arg+ is another Wx::Point, reduce x by the
|
21
|
+
# other's x and y by the other's y; if +arg+ is a numeric value,
|
22
|
+
# reduce x and y both by that value.
|
23
|
+
def -(arg)
|
24
|
+
case arg
|
25
|
+
when self.class
|
26
|
+
self.class.new( get_x - arg.get_x, get_y - arg.get_y )
|
27
|
+
when Numeric
|
28
|
+
self.class.new( (get_x - arg).to_i, (get_y - arg).to_i )
|
29
|
+
else
|
30
|
+
Kernel.raise TypeError, "Cannot add #{arg} to #{self.inspect}"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# Return a new Wx::Point with the x and y values both increased by
|
35
|
+
# parameter +arg+. If +arg+ is another Wx::Point, increase x by the
|
36
|
+
# other's x and y by the other's y; if +arg+ is a numeric value,
|
37
|
+
# increase both x and y by that value.
|
38
|
+
def +(arg)
|
39
|
+
case arg
|
40
|
+
when self.class
|
41
|
+
self.class.new( get_x + arg.get_x, get_y + arg.get_y )
|
42
|
+
when Numeric
|
43
|
+
self.class.new( (get_x + arg).to_i, (get_y + arg).to_i )
|
44
|
+
else
|
45
|
+
Kernel.raise TypeError, "Cannot add #{arg} to #{self.inspect}"
|
46
|
+
end
|
47
|
+
end
|
5
48
|
end
|
data/lib/wx/classes/size.rb
CHANGED
@@ -2,4 +2,48 @@ class Wx::Size
|
|
2
2
|
def to_s
|
3
3
|
"#<Wx::Size: (#{get_width}, #{get_height})>"
|
4
4
|
end
|
5
|
+
|
6
|
+
# Return a new Wx::Size with the width and height values both divided
|
7
|
+
# by parameter +div+, which should be a Numeric
|
8
|
+
def /(div)
|
9
|
+
self.class.new( (get_x / div).to_i, (get_y / div).to_i )
|
10
|
+
end
|
11
|
+
|
12
|
+
# Return a new Wx::Size with the width and height values both
|
13
|
+
# multiplied by parameter +mul+, which should be a Numeric
|
14
|
+
def *(mul)
|
15
|
+
self.class.new( (get_x * mul).to_i, (get_y * mul).to_i )
|
16
|
+
end
|
17
|
+
|
18
|
+
# Return a new Wx::Size with the width and height parameters both
|
19
|
+
# reduced by parameter +arg+. If +arg+ is another Wx::Size, reduce
|
20
|
+
# width by the other's width and height by the other's height; if
|
21
|
+
# +arg+ is a numeric value, reduce both width and height by that
|
22
|
+
# value.
|
23
|
+
def -(arg)
|
24
|
+
case arg
|
25
|
+
when self.class
|
26
|
+
self.class.new( get_x - arg.get_x, get_y - arg.get_y )
|
27
|
+
when Numeric
|
28
|
+
self.class.new( (get_x - arg).to_i, (get_y - arg).to_i )
|
29
|
+
else
|
30
|
+
Kernel.raise TypeError, "Cannot add #{arg} to #{self.inspect}"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# Return a new Wx::Size with the width and height parameters both
|
35
|
+
# increased by parameter +arg+. If +arg+ is another Wx::Size, increase
|
36
|
+
# width by the other's width and height by the other's height; if
|
37
|
+
# +arg+ is a numeric value, increase both width and height by that
|
38
|
+
# value.
|
39
|
+
def +(arg)
|
40
|
+
case arg
|
41
|
+
when self.class
|
42
|
+
self.class.new( get_x + arg.get_x, get_y + arg.get_y )
|
43
|
+
when Numeric
|
44
|
+
self.class.new( (get_x + arg).to_i, (get_y + arg).to_i )
|
45
|
+
else
|
46
|
+
Kernel.raise TypeError, "Cannot add #{arg} to #{self.inspect}"
|
47
|
+
end
|
48
|
+
end
|
5
49
|
end
|