wxruby 1.9.9-universal-darwin-9 → 1.9.10-universal-darwin-9
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/wx/classes/bitmap.rb +29 -1
- data/lib/wx/classes/clipboard.rb +19 -3
- data/lib/wx/classes/colour.rb +6 -4
- data/lib/wx/classes/data_object.rb +14 -0
- data/lib/wx/classes/data_object_simple.rb +6 -0
- data/lib/wx/classes/dataformat.rb +23 -0
- data/lib/wx/classes/evthandler.rb +31 -4
- data/lib/wx/classes/genericdirctrl.rb +36 -0
- data/lib/wx/classes/grid.rb +8 -0
- data/lib/wx/classes/hboxsizer.rb +6 -0
- data/lib/wx/classes/icon.rb +12 -1
- data/lib/wx/classes/image.rb +13 -1
- data/lib/wx/classes/listctrl.rb +12 -0
- data/lib/wx/classes/point.rb +8 -0
- data/lib/wx/classes/rect.rb +10 -1
- data/lib/wx/classes/richtextctrl.rb +22 -0
- data/lib/wx/classes/size.rb +9 -0
- data/lib/wx/classes/sizer.rb +18 -3
- data/lib/wx/classes/toolbar.rb +4 -6
- data/lib/wx/classes/vboxsizer.rb +6 -0
- data/lib/wx/classes/window.rb +7 -0
- data/lib/wx/classes/xmlresource.rb +17 -0
- data/lib/wx/helpers.rb +16 -1
- data/lib/wx/keyword_ctors.rb +3 -2
- data/lib/wx/keyword_defs.rb +27 -5
- data/lib/wx/version.rb +1 -1
- data/lib/wxruby2.bundle +0 -0
- data/samples/bigdemo/About.rbw +1 -1
- data/samples/bigdemo/wxCheckListBox.rbw +40 -50
- data/samples/bigdemo/wxListCtrl_virtual.rbw +8 -3
- data/samples/bigdemo/wxSashWindow.rbw +2 -2
- data/samples/bigdemo/wxTreeCtrl.rbw +4 -3
- data/samples/calendar/calendar.rb +143 -158
- data/samples/dialogs/dialogs.rb +74 -0
- data/samples/etc/toolbar_sizer_additem.rb +55 -0
- data/samples/event/update_ui_event.rb +70 -0
- data/samples/grid/gridtablebase.rb +43 -29
- data/samples/mdi/mdi.rb +22 -14
- data/samples/minimal/minimal.rb +3 -3
- data/samples/text/format-text-bold.png +0 -0
- data/samples/text/format-text-italic.png +0 -0
- data/samples/text/format-text-underline.png +0 -0
- data/samples/text/rich_textctrl.rb +98 -0
- data/samples/text/textctrl.rb +0 -2
- data/samples/treectrl/treectrl.rb +10 -18
- data/samples/xrc/xrc_sample.rb +48 -68
- metadata +15 -3
data/lib/wx/classes/bitmap.rb
CHANGED
@@ -1,4 +1,25 @@
|
|
1
|
+
# A platform-dependent image that can be drawn on the screen
|
1
2
|
class Wx::Bitmap
|
3
|
+
# Allow wxRuby to guess the type of an image file from its extension.
|
4
|
+
BITMAP_TYPE_GUESS = {
|
5
|
+
'bmp' => Wx::BITMAP_TYPE_BMP,
|
6
|
+
'gif' => Wx::BITMAP_TYPE_GIF,
|
7
|
+
'ico' => Wx::BITMAP_TYPE_ICO,
|
8
|
+
'jpeg' => Wx::BITMAP_TYPE_JPEG,
|
9
|
+
'jpg' => Wx::BITMAP_TYPE_JPEG,
|
10
|
+
'pbm' => Wx::BITMAP_TYPE_PNM,
|
11
|
+
'pcx' => Wx::BITMAP_TYPE_PCX,
|
12
|
+
'pgm' => Wx::BITMAP_TYPE_PNM,
|
13
|
+
'png' => Wx::BITMAP_TYPE_PNG,
|
14
|
+
'pnm' => Wx::BITMAP_TYPE_PNM,
|
15
|
+
'ppm' => Wx::BITMAP_TYPE_PNM,
|
16
|
+
'tga' => Wx::BITMAP_TYPE_TGA,
|
17
|
+
'tif' => Wx::BITMAP_TYPE_TIF,
|
18
|
+
'tiff' => Wx::BITMAP_TYPE_TIF,
|
19
|
+
'xbm' => Wx::BITMAP_TYPE_XBM,
|
20
|
+
'xpm' => Wx::BITMAP_TYPE_XPM
|
21
|
+
}
|
22
|
+
|
2
23
|
# Constructor copying data from an image
|
3
24
|
def self.from_image(img, depth = -1)
|
4
25
|
new(img, depth)
|
@@ -6,13 +27,20 @@ class Wx::Bitmap
|
|
6
27
|
|
7
28
|
# Redefine the initialize method so it raises an exception if a
|
8
29
|
# non-existent file is given to the constructor; otherwise, wx Widgets
|
9
|
-
# just carries on with an empty bitmap, which may cause faults
|
30
|
+
# just carries on with an empty bitmap, which may cause faults
|
31
|
+
# later. Also, be helpful and try to guess the bitmap type from the
|
32
|
+
# filename if it's not specified
|
10
33
|
wx_init = self.instance_method(:initialize)
|
11
34
|
define_method(:initialize) do | *args |
|
35
|
+
# If creating from a file, check it exists
|
12
36
|
if args[0].kind_of? String
|
13
37
|
if not File.exist?( File.expand_path(args[0]) )
|
14
38
|
Kernel.raise(ArgumentError, "Bitmap file does not exist: #{args[0]}")
|
15
39
|
end
|
40
|
+
# If type not specified, try to guess it from the file extension
|
41
|
+
if not args[1] and file_ext = args[0][/\w+$/]
|
42
|
+
args[1] = BITMAP_TYPE_GUESS[file_ext.downcase]
|
43
|
+
end
|
16
44
|
end
|
17
45
|
wx_init.bind(self).call(*args)
|
18
46
|
end
|
data/lib/wx/classes/clipboard.rb
CHANGED
@@ -1,16 +1,32 @@
|
|
1
1
|
class Wx::Clipboard
|
2
|
+
# See if we like these better
|
3
|
+
alias :place :set_data
|
4
|
+
alias :fetch :get_data
|
5
|
+
|
2
6
|
class << self
|
7
|
+
# This is provided internally by the SWIG interface file, but all
|
8
|
+
# public access should be via Clipboard.open; see below
|
9
|
+
private :get_global_clipboard
|
10
|
+
|
3
11
|
# Class method to provide access to the clipboard within a ruby
|
4
12
|
# block. Tests that the clipboard could be accessed, and ensures
|
5
13
|
# that it is closed when the block is finished.
|
6
14
|
def open
|
7
|
-
clip =
|
15
|
+
clip = nil
|
16
|
+
# Trying to access the segfault outside main_loop will segfault on
|
17
|
+
# some platforms (eg, GTK)
|
18
|
+
unless Wx::const_defined?(:THE_APP)
|
19
|
+
raise RuntimeError,
|
20
|
+
"The clipboard can only be accessed when the App is running"
|
21
|
+
end
|
22
|
+
|
23
|
+
clip = get_global_clipboard
|
8
24
|
unless clip.open
|
9
25
|
Kernel.raise "Could not open clipboard"
|
10
26
|
end
|
11
27
|
yield clip
|
12
|
-
|
13
|
-
|
28
|
+
ensure
|
29
|
+
clip.close if clip
|
14
30
|
end
|
15
31
|
end
|
16
32
|
end
|
data/lib/wx/classes/colour.rb
CHANGED
@@ -33,11 +33,13 @@ class Wx::Colour
|
|
33
33
|
# Colours are equal to one another if they have the same red, green
|
34
34
|
# and blue intensity, and the same alpha
|
35
35
|
def ==(other)
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
[ red, green, blue, alpha ] ==
|
36
|
+
case other
|
37
|
+
when Wx::Colour
|
38
|
+
[ self.red, self.green, self.blue, self.alpha ] ==
|
40
39
|
[ other.red, other.green, other.blue, other.alpha ]
|
40
|
+
else
|
41
|
+
false
|
42
|
+
end
|
41
43
|
end
|
42
44
|
|
43
45
|
# More informative output for inspect etc
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# Provide some default implementations of these to make life easier
|
2
|
+
class Wx::DataObject
|
3
|
+
def get_preferred_format(direction)
|
4
|
+
get_all_formats(direction).first
|
5
|
+
end
|
6
|
+
|
7
|
+
def get_format_count(direction)
|
8
|
+
get_all_formats(direction).length
|
9
|
+
end
|
10
|
+
|
11
|
+
def get_data_size(format)
|
12
|
+
get_data_here(format).size
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# Make this easier to use for multi-typed data objects. Comparison
|
2
|
+
# doesn't work correctly in the SWIG binding
|
3
|
+
class Wx::DataFormat
|
4
|
+
def ==(other)
|
5
|
+
if self.get_type > Wx::DATA_FORMAT_ID_INVALID
|
6
|
+
self.get_type == other.get_type
|
7
|
+
else
|
8
|
+
self.id == other.id
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
# Provide pre-cooked data formats for the standard types
|
14
|
+
module Wx
|
15
|
+
DF_TEXT = DataFormat.new( DATA_FORMAT_ID_TEXT )
|
16
|
+
DF_BITMAP = DataFormat.new( DATA_FORMAT_ID_BITMAP )
|
17
|
+
if Wx::PLATFORM != 'WXGTK'
|
18
|
+
DF_METAFILE = DataFormat.new( DATA_FORMAT_ID_METAFILE )
|
19
|
+
end
|
20
|
+
DF_FILENAME = DataFormat.new( DATA_FORMAT_ID_FILENAME )
|
21
|
+
DF_UNICODETEXT = DataFormat.new( DATA_FORMAT_ID_UNICODETEXT )
|
22
|
+
# DF_HTML is only supported on Windows + MSVC, so don't offer it
|
23
|
+
end
|
@@ -235,6 +235,12 @@ class Wx::EvtHandler
|
|
235
235
|
EventType['evt_aui_render', 0,
|
236
236
|
Wx::EVT_AUI_RENDER,
|
237
237
|
Wx::AuiManagerEvent],
|
238
|
+
EventType['evt_bookctrl_page_changed', 1,
|
239
|
+
Wx::EVT_COMMAND_BOOKCTRL_PAGE_CHANGED,
|
240
|
+
Wx::BookCtrlBaseEvent],
|
241
|
+
EventType['evt_bookctrl_page_changing', 1,
|
242
|
+
Wx::EVT_COMMAND_BOOKCTRL_PAGE_CHANGING,
|
243
|
+
Wx::BookCtrlBaseEvent],
|
238
244
|
EventType['evt_button', 1,
|
239
245
|
Wx::EVT_COMMAND_BUTTON_CLICKED,
|
240
246
|
Wx::CommandEvent],
|
@@ -313,15 +319,18 @@ class Wx::EvtHandler
|
|
313
319
|
EventType['evt_context_menu', 0,
|
314
320
|
Wx::EVT_CONTEXT_MENU,
|
315
321
|
Wx::ContextMenuEvent],
|
316
|
-
EventType['
|
317
|
-
Wx::
|
318
|
-
Wx::
|
322
|
+
EventType['evt_date_changed', 1,
|
323
|
+
Wx::EVT_DATE_CHANGED,
|
324
|
+
Wx::DateEvent],
|
319
325
|
EventType['evt_detailed_help', 1,
|
320
326
|
Wx::EVT_DETAILED_HELP,
|
321
327
|
Wx::HelpEvent],
|
322
328
|
EventType['evt_detailed_help_range', 2,
|
323
329
|
Wx::EVT_DETAILED_HELP,
|
324
330
|
Wx::HelpEvent],
|
331
|
+
EventType['evt_drop_files', 0,
|
332
|
+
Wx::EVT_DROP_FILES,
|
333
|
+
Wx::Event],
|
325
334
|
EventType['evt_end_process', 1,
|
326
335
|
Wx::EVT_END_PROCESS,
|
327
336
|
Wx::Event],
|
@@ -864,10 +873,16 @@ class Wx::EvtHandler
|
|
864
873
|
Wx::TimerEvent],
|
865
874
|
EventType['evt_togglebutton', 1,
|
866
875
|
Wx::EVT_COMMAND_TOGGLEBUTTON_CLICKED,
|
867
|
-
Wx::
|
876
|
+
Wx::CommandEvent],
|
868
877
|
EventType['evt_tool', 1,
|
869
878
|
Wx::EVT_COMMAND_TOOL_CLICKED,
|
870
879
|
Wx::CommandEvent],
|
880
|
+
EventType['evt_toolbook_page_changed', 1,
|
881
|
+
Wx::EVT_COMMAND_TOOLBOOK_PAGE_CHANGED,
|
882
|
+
Wx::ToolbookEvent],
|
883
|
+
EventType['evt_toolbook_page_changing', 1,
|
884
|
+
Wx::EVT_COMMAND_TOOLBOOK_PAGE_CHANGING,
|
885
|
+
Wx::ToolbookEvent],
|
871
886
|
EventType['evt_tool_enter', 1,
|
872
887
|
Wx::EVT_COMMAND_TOOL_ENTER,
|
873
888
|
Wx::CommandEvent],
|
@@ -943,6 +958,18 @@ class Wx::EvtHandler
|
|
943
958
|
EventType['evt_tree_state_image_click', 1,
|
944
959
|
Wx::EVT_COMMAND_TREE_STATE_IMAGE_CLICK,
|
945
960
|
Wx::TreeEvent],
|
961
|
+
EventType['evt_treebook_node_collapsed', 1,
|
962
|
+
Wx::EVT_COMMAND_TREEBOOK_NODE_COLLAPSED,
|
963
|
+
Wx::TreebookEvent],
|
964
|
+
EventType['evt_treebook_node_expanded', 1,
|
965
|
+
Wx::EVT_COMMAND_TREEBOOK_NODE_EXPANDED,
|
966
|
+
Wx::TreebookEvent],
|
967
|
+
EventType['evt_treebook_page_changed', 1,
|
968
|
+
Wx::EVT_COMMAND_TREEBOOK_PAGE_CHANGED,
|
969
|
+
Wx::TreebookEvent],
|
970
|
+
EventType['evt_treebook_page_changing', 1,
|
971
|
+
Wx::EVT_COMMAND_TREEBOOK_PAGE_CHANGING,
|
972
|
+
Wx::TreebookEvent],
|
946
973
|
EventType['evt_update_ui', 1,
|
947
974
|
Wx::EVT_UPDATE_UI,
|
948
975
|
Wx::UpdateUIEvent],
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# Bottom-up implementation of a Directory lister
|
2
|
+
class Wx::GenericDirCtrl
|
3
|
+
module DirCtrlTree
|
4
|
+
# The TreeCtrl contained in a GenericDirCtrl already has C++ data
|
5
|
+
# associated with the items. If these are returned to Ruby crashes
|
6
|
+
# will result. So this module sets the TreeCtrl to return the path
|
7
|
+
# string.
|
8
|
+
def get_item_data(tree_id)
|
9
|
+
root_id = get_root_item
|
10
|
+
return "" if tree_id == root_id
|
11
|
+
|
12
|
+
path = item_text(tree_id)
|
13
|
+
while tree_id = item_parent(tree_id) and tree_id != root_id
|
14
|
+
path = item_text(tree_id) + "/#{path}"
|
15
|
+
end
|
16
|
+
unless Wx::PLATFORM == 'WXMSW'
|
17
|
+
path = "/" + path
|
18
|
+
end
|
19
|
+
path
|
20
|
+
end
|
21
|
+
|
22
|
+
alias :get_item_path :get_item_data
|
23
|
+
|
24
|
+
# Not allowed
|
25
|
+
def set_item_data(tree_id, data)
|
26
|
+
Kernel.raise "Item data cannot be set for a GenericDirCtrl's Tree"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
wx_get_tree_ctrl = instance_method(:get_tree_ctrl)
|
31
|
+
define_method(:get_tree_ctrl) do
|
32
|
+
tree = wx_get_tree_ctrl.bind(self).call
|
33
|
+
tree.extend(DirCtrlTree)
|
34
|
+
tree
|
35
|
+
end
|
36
|
+
end
|
data/lib/wx/classes/grid.rb
CHANGED
@@ -35,6 +35,14 @@ class Wx::Grid
|
|
35
35
|
@__grid_table = table
|
36
36
|
end
|
37
37
|
|
38
|
+
# Store the renderers / editors associated with types, if used
|
39
|
+
alias :__register_data_type :register_data_type
|
40
|
+
def register_data_type(type_name, renderer, editor)
|
41
|
+
__register_data_type(type_name, renderer, editor)
|
42
|
+
@__named_type_info ||= {}
|
43
|
+
@__named_type_info[type_name] = [ renderer, editor ]
|
44
|
+
end
|
45
|
+
|
38
46
|
# store default editor
|
39
47
|
wx_set_default_editor = self.instance_method(:set_default_editor)
|
40
48
|
define_method(:set_default_editor) do | editr |
|
data/lib/wx/classes/icon.rb
CHANGED
@@ -1,4 +1,10 @@
|
|
1
|
+
# Specific type of platform-dependent image used for frames on Windows and
|
2
|
+
# Linux. Normally Bitmap is used
|
1
3
|
class Wx::Icon
|
4
|
+
# Load the type-guessing hash from Wx::Bitmap
|
5
|
+
require 'wx/classes/bitmap'
|
6
|
+
BITMAP_TYPE_GUESS = Wx::Bitmap::BITMAP_TYPE_GUESS
|
7
|
+
|
2
8
|
# Analogous to Image.from_bitmap
|
3
9
|
def self.from_bitmap(bmp)
|
4
10
|
ico = new
|
@@ -8,13 +14,18 @@ class Wx::Icon
|
|
8
14
|
|
9
15
|
# Redefine the initialize method so it raises an exception if a
|
10
16
|
# non-existent file is given to the constructor; otherwise, wx Widgets
|
11
|
-
# just carries on with an empty icon, which may cause faults
|
17
|
+
# just carries on with an empty icon, which may cause faults
|
18
|
+
# later. Also guess icon type from filename, if not specified.
|
12
19
|
wx_init = self.instance_method(:initialize)
|
13
20
|
define_method(:initialize) do | *args |
|
14
21
|
if args[0].kind_of? String
|
15
22
|
if not File.exist?( File.expand_path(args[0]) )
|
16
23
|
Kernel.raise(ArgumentError, "Icon file does not exist: #{args[0]}")
|
17
24
|
end
|
25
|
+
# If type not specified, try to guess it from the file extension
|
26
|
+
if not args[1] and ( file_ext = args[0][/\w+$/] )
|
27
|
+
args[1] = BITMAP_TYPE_GUESS[file_ext.downcase]
|
28
|
+
end
|
18
29
|
end
|
19
30
|
wx_init.bind(self).call(*args)
|
20
31
|
end
|
data/lib/wx/classes/image.rb
CHANGED
@@ -1,4 +1,10 @@
|
|
1
|
+
# A platform-independent image; can be manipulated more extensively than
|
2
|
+
# Bitmap, but must be converted to a Bitmap for drawing.
|
1
3
|
class Wx::Image
|
4
|
+
# Load the type-guessing hash from Wx::Bitmap
|
5
|
+
require 'wx/classes/bitmap'
|
6
|
+
BITMAP_TYPE_GUESS = Wx::Bitmap::BITMAP_TYPE_GUESS
|
7
|
+
|
2
8
|
# Load a new image from an IO-like object that supports "read"
|
3
9
|
def self.read(an_io, type_or_mime, index = -1)
|
4
10
|
img = new
|
@@ -13,13 +19,19 @@ class Wx::Image
|
|
13
19
|
|
14
20
|
# Redefine the initialize method so it raises an exception if a
|
15
21
|
# non-existent file is given to the constructor; otherwise, wx Widgets
|
16
|
-
# just carries on with an invalid image, which may cause faults
|
22
|
+
# just carries on with an invalid image, which may cause faults
|
23
|
+
# later. Also, if loading from a file, and the type is not specified,
|
24
|
+
# try to guess it from the filename extension
|
17
25
|
wx_init = self.instance_method(:initialize)
|
18
26
|
define_method(:initialize) do | *args |
|
19
27
|
if args[0].kind_of? String
|
20
28
|
if not File.exist?( File.expand_path(args[0]) )
|
21
29
|
Kernel.raise(ArgumentError, "Image file does not exist: #{args[0]}")
|
22
30
|
end
|
31
|
+
# If type not specified, try to guess it from the file extension
|
32
|
+
if not args[1] and file_ext = args[0][/\w+$/]
|
33
|
+
args[1] = BITMAP_TYPE_GUESS[file_ext.downcase]
|
34
|
+
end
|
23
35
|
end
|
24
36
|
wx_init.bind(self).call(*args)
|
25
37
|
end
|
data/lib/wx/classes/listctrl.rb
CHANGED
@@ -7,6 +7,18 @@ class Wx::ListCtrl
|
|
7
7
|
0.upto(item_count - 1) { | i | yield i }
|
8
8
|
end
|
9
9
|
|
10
|
+
# Returns an Array containing the indexes of the currently selected
|
11
|
+
# items
|
12
|
+
def get_selections
|
13
|
+
selections = []
|
14
|
+
item = get_next_item(-1, Wx::LIST_NEXT_BELOW, Wx::LIST_STATE_SELECTED)
|
15
|
+
while item >= 0
|
16
|
+
selections << item
|
17
|
+
item = get_next_item(item, Wx::LIST_NEXT_BELOW, Wx::LIST_STATE_SELECTED)
|
18
|
+
end
|
19
|
+
selections
|
20
|
+
end
|
21
|
+
|
10
22
|
# Stub version for LC_VIRTUAL controls that does nothing; may be
|
11
23
|
# overridden in subclasses.
|
12
24
|
def on_get_item_attr(i)
|
data/lib/wx/classes/point.rb
CHANGED
@@ -4,6 +4,14 @@ class Wx::Point
|
|
4
4
|
"#<Wx::Point: (#{x}, #{y})>"
|
5
5
|
end
|
6
6
|
|
7
|
+
# Correct comparison for Points - same if same x and y
|
8
|
+
def ==(other)
|
9
|
+
unless other.kind_of?(Wx::Point)
|
10
|
+
Kernel.raise TypeError, "Cannot compare Point to #{other}"
|
11
|
+
end
|
12
|
+
x == other.x and y == other.y
|
13
|
+
end
|
14
|
+
|
7
15
|
# Return a new Wx::Point with the x and y parameters both divided by
|
8
16
|
# parameter +div+, which should be a Numeric
|
9
17
|
def /(div)
|
data/lib/wx/classes/rect.rb
CHANGED
@@ -4,7 +4,16 @@ class Wx::Rect
|
|
4
4
|
def to_s
|
5
5
|
"#<Wx::Rect: (#{get_left}, #{get_top}) (#{get_right}, #{get_bottom})>"
|
6
6
|
end
|
7
|
-
|
7
|
+
|
8
|
+
# Correct comparison for Wx::Rect, are the same if have the same
|
9
|
+
# position and the same size
|
10
|
+
def ==(other)
|
11
|
+
unless other.kind_of?(Wx::Rect)
|
12
|
+
Kernel.raise TypeError, "Cannot compare Rect to #{other}"
|
13
|
+
end
|
14
|
+
get_left == other.get_left and get_top == other.get_top and
|
15
|
+
get_right = other.get_right and get_bottom == other.get_bottom
|
16
|
+
end
|
8
17
|
# More ruby-ish names
|
9
18
|
alias :contains? :contains
|
10
19
|
end
|
@@ -38,4 +38,26 @@ class Wx::RichTextCtrl
|
|
38
38
|
Kernel.raise RuntimeError, "Could not retrieve style at position #{pos}"
|
39
39
|
end
|
40
40
|
end
|
41
|
+
|
42
|
+
# Fix to accept a single +pos+ argument and return a Wx::Rect
|
43
|
+
wx_car_pos_for_index = self.instance_method(:get_caret_position_for_index)
|
44
|
+
define_method(:get_caret_position_for_index) do | pos |
|
45
|
+
rect = Wx::Rect.new
|
46
|
+
if wx_car_pos_for_index.bind(self).call(pos, rect)
|
47
|
+
return rect
|
48
|
+
else
|
49
|
+
Kernel.raise RuntimeError, "Could not rect for position #{pos}"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
# Fix to return a pair of col, row values
|
54
|
+
wx_pos_to_xy = self.instance_method(:position_to_xy)
|
55
|
+
define_method(:position_to_xy) do | pos |
|
56
|
+
success, x, y = wx_pos_to_xy.bind(self).call(pos)
|
57
|
+
if success
|
58
|
+
return x, y
|
59
|
+
else
|
60
|
+
Kernel.raise RuntimeError, "Could not convert position #{pos} to x, y"
|
61
|
+
end
|
62
|
+
end
|
41
63
|
end
|
data/lib/wx/classes/size.rb
CHANGED
@@ -1,8 +1,17 @@
|
|
1
1
|
class Wx::Size
|
2
|
+
# More informative output for inspect etc
|
2
3
|
def to_s
|
3
4
|
"#<Wx::Size: (#{get_width}, #{get_height})>"
|
4
5
|
end
|
5
6
|
|
7
|
+
# Compare with another size
|
8
|
+
def ==(other)
|
9
|
+
unless other.kind_of?(Wx::Size)
|
10
|
+
Kernel.raise TypeError, "Cannot compare Size to #{other}"
|
11
|
+
end
|
12
|
+
get_x == other.get_x and get_y == other.get_y
|
13
|
+
end
|
14
|
+
|
6
15
|
# Return a new Wx::Size with the width and height values both divided
|
7
16
|
# by parameter +div+, which should be a Numeric
|
8
17
|
def /(div)
|