wxruby-ruby19 1.9.8-x86-linux → 1.9.10-x86-linux
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +53 -0
- data/README +297 -0
- data/lib/wx/accessors.rb +58 -0
- data/lib/wx/classes/acceleratortable.rb +28 -0
- data/lib/wx/classes/animation.rb +18 -0
- data/lib/wx/classes/app.rb +51 -0
- data/lib/wx/classes/artprovider.rb +31 -0
- data/lib/wx/classes/auinotebook.rb +9 -0
- data/lib/wx/classes/bitmap.rb +56 -0
- data/lib/wx/classes/busycursor.rb +12 -0
- data/lib/wx/classes/checklistbox.rb +45 -0
- data/lib/wx/classes/choice.rb +4 -0
- data/lib/wx/classes/clientdc.rb +13 -0
- data/lib/wx/classes/clipboard.rb +32 -0
- data/lib/wx/classes/colour.rb +49 -0
- data/lib/wx/classes/combobox.rb +4 -0
- data/lib/wx/classes/commandevent.rb +7 -0
- data/lib/wx/classes/controlwithitems.rb +10 -0
- 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/dc.rb +57 -0
- data/lib/wx/classes/event.rb +5 -0
- data/lib/wx/classes/evthandler.rb +1039 -0
- data/lib/wx/classes/font.rb +118 -0
- data/lib/wx/classes/functions.rb +44 -0
- data/lib/wx/classes/gauge.rb +12 -0
- data/lib/wx/classes/genericdirctrl.rb +36 -0
- data/lib/wx/classes/grid.rb +146 -0
- data/lib/wx/classes/hboxsizer.rb +6 -0
- data/lib/wx/classes/helpcontroller.rb +5 -0
- data/lib/wx/classes/helpcontrollerhelpprovider.rb +23 -0
- data/lib/wx/classes/helpprovider.rb +15 -0
- data/lib/wx/classes/htmlhelpcontroller.rb +5 -0
- data/lib/wx/classes/htmlwindow.rb +14 -0
- data/lib/wx/classes/icon.rb +32 -0
- data/lib/wx/classes/iconbundle.rb +3 -0
- data/lib/wx/classes/image.rb +43 -0
- data/lib/wx/classes/imagelist.rb +3 -0
- data/lib/wx/classes/listbox.rb +4 -0
- data/lib/wx/classes/listctrl.rb +33 -0
- data/lib/wx/classes/locale.rb +28 -0
- data/lib/wx/classes/mediactrl.rb +48 -0
- data/lib/wx/classes/menu.rb +62 -0
- data/lib/wx/classes/menuitem.rb +7 -0
- data/lib/wx/classes/notebook.rb +9 -0
- data/lib/wx/classes/object.rb +14 -0
- data/lib/wx/classes/paintdc.rb +12 -0
- data/lib/wx/classes/point.rb +56 -0
- data/lib/wx/classes/previewframe.rb +13 -0
- data/lib/wx/classes/rect.rb +19 -0
- data/lib/wx/classes/richtextctrl.rb +63 -0
- data/lib/wx/classes/simplehelpprovider.rb +38 -0
- data/lib/wx/classes/size.rb +58 -0
- data/lib/wx/classes/sizer.rb +37 -0
- data/lib/wx/classes/sound.rb +23 -0
- data/lib/wx/classes/standardpaths.rb +9 -0
- data/lib/wx/classes/styledtextctrl.rb +92 -0
- data/lib/wx/classes/textctrl.rb +14 -0
- data/lib/wx/classes/texturlevent.rb +18 -0
- data/lib/wx/classes/timer.rb +94 -0
- data/lib/wx/classes/toolbar.rb +27 -0
- data/lib/wx/classes/toolbartool.rb +4 -0
- data/lib/wx/classes/treectrl.rb +44 -0
- data/lib/wx/classes/vboxsizer.rb +6 -0
- data/lib/wx/classes/window.rb +89 -0
- data/lib/wx/classes/xmlresource.rb +54 -0
- data/lib/wx/helpers.rb +45 -0
- data/lib/wx/keyword_ctors.rb +204 -0
- data/lib/wx/keyword_defs.rb +558 -0
- data/lib/wx/version.rb +3 -0
- data/lib/wx.rb +53 -0
- data/lib/wxruby2.so +0 -0
- data/samples/SAMPLES-LICENSE.TXT +18 -0
- data/samples/aui/aui.rb +1356 -0
- data/samples/bigdemo/About.rbw +39 -0
- data/samples/bigdemo/ColorPanel.rbw +23 -0
- data/samples/bigdemo/GridSimple.rbw +78 -0
- data/samples/bigdemo/MDIDemo.rbw +57 -0
- data/samples/bigdemo/PopupMenu.rbw +149 -0
- data/samples/bigdemo/ShapedWindow.rbw +131 -0
- data/samples/bigdemo/Sizers.rbw +543 -0
- data/samples/bigdemo/bigdemo.rb +823 -0
- data/samples/bigdemo/demoTemplate.rbw +33 -0
- data/samples/bigdemo/helpfile.htb +0 -0
- data/samples/bigdemo/icons/Test 015.jpg +0 -0
- data/samples/bigdemo/icons/Test 015.png +0 -0
- data/samples/bigdemo/icons/choice.bmp +0 -0
- data/samples/bigdemo/icons/choice.xpm +27 -0
- data/samples/bigdemo/icons/combo.bmp +0 -0
- data/samples/bigdemo/icons/combo.xpm +27 -0
- data/samples/bigdemo/icons/copy.xpm +25 -0
- data/samples/bigdemo/icons/cut.xpm +24 -0
- data/samples/bigdemo/icons/gauge.bmp +0 -0
- data/samples/bigdemo/icons/gauge.xpm +27 -0
- data/samples/bigdemo/icons/help.xpm +25 -0
- data/samples/bigdemo/icons/list.bmp +0 -0
- data/samples/bigdemo/icons/list.xpm +27 -0
- data/samples/bigdemo/icons/mondrian.ico +0 -0
- data/samples/bigdemo/icons/mondrian.xpm +44 -0
- data/samples/bigdemo/icons/new.xpm +24 -0
- data/samples/bigdemo/icons/ogl.ico +0 -0
- data/samples/bigdemo/icons/ogl.xpm +45 -0
- data/samples/bigdemo/icons/open.xpm +26 -0
- data/samples/bigdemo/icons/paste.bmp +0 -0
- data/samples/bigdemo/icons/paste.xpm +38 -0
- data/samples/bigdemo/icons/pointy.png +0 -0
- data/samples/bigdemo/icons/preview.xpm +26 -0
- data/samples/bigdemo/icons/print.xpm +26 -0
- data/samples/bigdemo/icons/radio.bmp +0 -0
- data/samples/bigdemo/icons/radio.xpm +27 -0
- data/samples/bigdemo/icons/robert.xpm +415 -0
- data/samples/bigdemo/icons/ruby.png +0 -0
- data/samples/bigdemo/icons/sashtest.ico +0 -0
- data/samples/bigdemo/icons/save.xpm +25 -0
- data/samples/bigdemo/icons/smiles.bmp +0 -0
- data/samples/bigdemo/icons/smiles.xpm +39 -0
- data/samples/bigdemo/icons/smiley.ico +0 -0
- data/samples/bigdemo/icons/smiley.xpm +42 -0
- data/samples/bigdemo/icons/stattext.xpm +24 -0
- data/samples/bigdemo/icons/test2.bmp +0 -0
- data/samples/bigdemo/icons/test2.png +0 -0
- data/samples/bigdemo/icons/test2.xpm +79 -0
- data/samples/bigdemo/icons/text.bmp +0 -0
- data/samples/bigdemo/icons/text.xpm +27 -0
- data/samples/bigdemo/icons/tog1.bmp +0 -0
- data/samples/bigdemo/icons/tog1.xpm +38 -0
- data/samples/bigdemo/icons/tog2.bmp +0 -0
- data/samples/bigdemo/icons/tog2.xpm +38 -0
- data/samples/bigdemo/icons/wxwin.ico +0 -0
- data/samples/bigdemo/icons/wxwin16x16.png +0 -0
- data/samples/bigdemo/icons/wxwin16x16.xpm +25 -0
- data/samples/bigdemo/icons/wxwin32x32.png +0 -0
- data/samples/bigdemo/icons/wxwin48x48.png +0 -0
- data/samples/bigdemo/run.rb +90 -0
- data/samples/bigdemo/tips.txt +7 -0
- data/samples/bigdemo/utils.rb +12 -0
- data/samples/bigdemo/wxArtProvider.rbw +281 -0
- data/samples/bigdemo/wxBitmapButton.rbw +65 -0
- data/samples/bigdemo/wxButton.rbw +64 -0
- data/samples/bigdemo/wxCalendarCtrl.rbw +60 -0
- data/samples/bigdemo/wxCheckBox.rbw +50 -0
- data/samples/bigdemo/wxCheckListBox.rbw +65 -0
- data/samples/bigdemo/wxChoice.rbw +47 -0
- data/samples/bigdemo/wxChoicebook.rbw +78 -0
- data/samples/bigdemo/wxColourDialog.rbw +31 -0
- data/samples/bigdemo/wxComboBox.rbw +77 -0
- data/samples/bigdemo/wxCursor.rbw +136 -0
- data/samples/bigdemo/wxDialog.rbw +74 -0
- data/samples/bigdemo/wxDirDialog.rbw +29 -0
- data/samples/bigdemo/wxDragImage.rbw +70 -0
- data/samples/bigdemo/wxFileDialog.rbw +37 -0
- data/samples/bigdemo/wxFileDialog_Save.rbw +35 -0
- data/samples/bigdemo/wxFindReplaceDialog.rbw +82 -0
- data/samples/bigdemo/wxFontDialog.rbw +173 -0
- data/samples/bigdemo/wxFrame.rbw +53 -0
- data/samples/bigdemo/wxGauge.rbw +71 -0
- data/samples/bigdemo/wxGenericDirCtrl.rbw +74 -0
- data/samples/bigdemo/wxGrid.rbw +66 -0
- data/samples/bigdemo/wxHtmlHelpController.rbw +52 -0
- data/samples/bigdemo/wxListBox.rbw +140 -0
- data/samples/bigdemo/wxListCtrl_virtual.rbw +112 -0
- data/samples/bigdemo/wxMDIWindows.rbw +50 -0
- data/samples/bigdemo/wxMenu.rbw +236 -0
- data/samples/bigdemo/wxMessageDialog.rbw +27 -0
- data/samples/bigdemo/wxMiniFrame.rbw +70 -0
- data/samples/bigdemo/wxMultipleChoiceDialog.rbw +32 -0
- data/samples/bigdemo/wxNotebook.rbw +136 -0
- data/samples/bigdemo/wxProgressDialog.rbw +43 -0
- data/samples/bigdemo/wxRadioBox.rbw +72 -0
- data/samples/bigdemo/wxRadioButton.rbw +125 -0
- data/samples/bigdemo/wxSashWindow.rbw +141 -0
- data/samples/bigdemo/wxScrolledMessageDialog.rbw +57 -0
- data/samples/bigdemo/wxScrolledWindow.rbw +199 -0
- data/samples/bigdemo/wxSingleChoiceDialog.rbw +33 -0
- data/samples/bigdemo/wxSlider.rbw +42 -0
- data/samples/bigdemo/wxSpinButton.rbw +50 -0
- data/samples/bigdemo/wxSpinCtrl.rbw +51 -0
- data/samples/bigdemo/wxSplitterWindow.rbw +63 -0
- data/samples/bigdemo/wxStaticBitmap.rbw +51 -0
- data/samples/bigdemo/wxStaticText.rbw +55 -0
- data/samples/bigdemo/wxStatusBar.rbw +126 -0
- data/samples/bigdemo/wxTextCtrl.rbw +149 -0
- data/samples/bigdemo/wxTextEntryDialog.rbw +31 -0
- data/samples/bigdemo/wxToggleButton.rbw +49 -0
- data/samples/bigdemo/wxToolBar.rbw +131 -0
- data/samples/bigdemo/wxTreeCtrl.rbw +191 -0
- data/samples/calendar/calendar.rb +256 -0
- data/samples/caret/caret.rb +282 -0
- data/samples/caret/mondrian.xpm +44 -0
- data/samples/controls/controls.rb +1136 -0
- data/samples/controls/get_item_sample.rb +87 -0
- data/samples/controls/icons/choice.xpm +27 -0
- data/samples/controls/icons/combo.xpm +27 -0
- data/samples/controls/icons/gauge.xpm +27 -0
- data/samples/controls/icons/list.xpm +27 -0
- data/samples/controls/icons/radio.xpm +27 -0
- data/samples/controls/icons/stattext.xpm +24 -0
- data/samples/controls/icons/text.xpm +27 -0
- data/samples/controls/mondrian.ico +0 -0
- data/samples/controls/mondrian.xpm +44 -0
- data/samples/controls/test2.bmp +0 -0
- data/samples/dialogs/dialogs.rb +797 -0
- data/samples/dialogs/tips.txt +18 -0
- data/samples/dragdrop/dragdrop.rb +177 -0
- data/samples/drawing/graphics_drawing.rb +235 -0
- data/samples/drawing/images.rb +37 -0
- data/samples/drawing/paperclip.png +0 -0
- data/samples/etc/activation.rb +102 -0
- data/samples/etc/choice.rb +67 -0
- data/samples/etc/miniframe.rb +79 -0
- data/samples/etc/sash.rb +130 -0
- data/samples/etc/scrollwin.rb +110 -0
- data/samples/etc/system_settings.rb +252 -0
- data/samples/etc/threaded.rb +72 -0
- data/samples/etc/toolbar_sizer_additem.rb +55 -0
- data/samples/etc/wizard.rb +74 -0
- data/samples/event/event.rb +182 -0
- data/samples/event/update_ui_event.rb +70 -0
- data/samples/grid/grid.rb +198 -0
- data/samples/grid/gridtablebase.rb +148 -0
- data/samples/html/html.rb +262 -0
- data/samples/listbook/listbook.rb +174 -0
- data/samples/listbook/listbook.xrc +370 -0
- data/samples/mdi/mdi.rb +85 -0
- data/samples/media/mediactrl.rb +167 -0
- data/samples/minimal/minimal.rb +77 -0
- data/samples/minimal/mondrian.ico +0 -0
- data/samples/minimal/mondrian.png +0 -0
- data/samples/minimal/nothing.rb +16 -0
- data/samples/opengl/cube.rb +117 -0
- data/samples/printing/mondrian.ico +0 -0
- data/samples/printing/mondrian.xpm +44 -0
- data/samples/printing/printing.rb +487 -0
- data/samples/sockets/SocketPackets.rb +27 -0
- data/samples/sockets/res/message-new.png +0 -0
- data/samples/sockets/res/user.png +0 -0
- data/samples/sockets/wxClient.rb +395 -0
- data/samples/sockets/wxServer.rb +422 -0
- data/samples/sockets/wxSocketGUI.rb +97 -0
- 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/mondrian.ico +0 -0
- data/samples/text/mondrian.xpm +44 -0
- data/samples/text/rich_textctrl.rb +98 -0
- data/samples/text/scintilla.rb +169 -0
- data/samples/text/textctrl.rb +111 -0
- data/samples/text/unicode.rb +242 -0
- data/samples/text/utf8.txt +15 -0
- data/samples/treectrl/icon1.xpm +79 -0
- data/samples/treectrl/icon2.xpm +53 -0
- data/samples/treectrl/icon3.xpm +79 -0
- data/samples/treectrl/icon4.xpm +43 -0
- data/samples/treectrl/icon5.xpm +79 -0
- data/samples/treectrl/treectrl.rb +1166 -0
- data/samples/xrc/samples.xrc +46 -0
- data/samples/xrc/xrc_sample.rb +76 -0
- metadata +234 -220
@@ -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 then old_meth.bind(self).call(*args)
|
27
|
+
when String then old_meth.bind(self).call(Wx::ID_ANY, *args)
|
28
|
+
when Wx::MenuItem then 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 then old_meth.bind(self).call(pos, *args)
|
50
|
+
when String then old_meth.bind(self).call(pos, Wx::ID_ANY, *args)
|
51
|
+
when Wx::MenuItem then 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
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# The root class for most (not all) WxRuby classes
|
2
|
+
class Wx::Object
|
3
|
+
# Massage the output of inspect to show the public module name (Wx),
|
4
|
+
# instead of the internal name (Wxruby2)
|
5
|
+
def to_s
|
6
|
+
super.sub('ruby2', '')
|
7
|
+
end
|
8
|
+
|
9
|
+
# Returns a string containing the C++ pointer address of this
|
10
|
+
# object. Only useful for debugging.
|
11
|
+
def ptr_addr
|
12
|
+
Wx::ptr_addr(self)
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# Device Context to paint within an on_paint handler
|
2
|
+
class Wx::PaintDC
|
3
|
+
# This class should not be instantiated directly in wxRuby; it should
|
4
|
+
# always be used via Window#paint, which takes a block receiving the
|
5
|
+
# DC. This ensures that the DC is cleaned up at the correct time,
|
6
|
+
# preventing serious errors on some platforms.
|
7
|
+
define_method(:initialize) do | *args |
|
8
|
+
Kernel.raise RuntimeError,
|
9
|
+
"Do not instantiate PaintDC directly; use Window#paint",
|
10
|
+
caller[1..-1]
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
class Wx::Point
|
2
|
+
# More informative output when converted to string
|
3
|
+
def to_s
|
4
|
+
"#<Wx::Point: (#{x}, #{y})>"
|
5
|
+
end
|
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
|
+
|
15
|
+
# Return a new Wx::Point with the x and y parameters both divided by
|
16
|
+
# parameter +div+, which should be a Numeric
|
17
|
+
def /(div)
|
18
|
+
self.class.new( (get_x / div).to_i, (get_y / div).to_i )
|
19
|
+
end
|
20
|
+
|
21
|
+
# Return a new Wx::Point with the x and y values both multiplied by
|
22
|
+
# parameter +mul+, which should be a Numeric
|
23
|
+
def *(mul)
|
24
|
+
self.class.new( (get_x * mul).to_i, (get_y * mul).to_i )
|
25
|
+
end
|
26
|
+
|
27
|
+
# Return a new Wx::Point with the x and y values both reduced by
|
28
|
+
# parameter +arg+. If +arg+ is another Wx::Point, reduce x by the
|
29
|
+
# other's x and y by the other's y; if +arg+ is a numeric value,
|
30
|
+
# reduce x and y both by that value.
|
31
|
+
def -(arg)
|
32
|
+
case arg
|
33
|
+
when self.class
|
34
|
+
self.class.new( get_x - arg.get_x, get_y - arg.get_y )
|
35
|
+
when Numeric
|
36
|
+
self.class.new( (get_x - arg).to_i, (get_y - arg).to_i )
|
37
|
+
else
|
38
|
+
Kernel.raise TypeError, "Cannot add #{arg} to #{self.inspect}"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
# Return a new Wx::Point with the x and y values both increased by
|
43
|
+
# parameter +arg+. If +arg+ is another Wx::Point, increase x by the
|
44
|
+
# other's x and y by the other's y; if +arg+ is a numeric value,
|
45
|
+
# increase both x and y by that value.
|
46
|
+
def +(arg)
|
47
|
+
case arg
|
48
|
+
when self.class
|
49
|
+
self.class.new( get_x + arg.get_x, get_y + arg.get_y )
|
50
|
+
when Numeric
|
51
|
+
self.class.new( (get_x + arg).to_i, (get_y + arg).to_i )
|
52
|
+
else
|
53
|
+
Kernel.raise TypeError, "Cannot add #{arg} to #{self.inspect}"
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# Frame that displays a print preview
|
2
|
+
class Wx::PreviewFrame
|
3
|
+
# a PreviewFrame has a preview associated with it that must be
|
4
|
+
# protected from Ruby's GC. However, there is no C++ method to access
|
5
|
+
# the Wx::PrintPreview (only a protected member), so instead we have
|
6
|
+
# to assign it to an instance variable so it is marked correctly when
|
7
|
+
# the frame displaying it is marked.
|
8
|
+
wx_init = self.instance_method(:initialize)
|
9
|
+
define_method(:initialize) do | *args |
|
10
|
+
wx_init.bind(self).call(*args)
|
11
|
+
@__preview = args[0]
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# Class representing a rectangular shape
|
2
|
+
class Wx::Rect
|
3
|
+
# Nicely readable inspect output for Rect
|
4
|
+
def to_s
|
5
|
+
"#<Wx::Rect: (#{get_left}, #{get_top}) (#{get_right}, #{get_bottom})>"
|
6
|
+
end
|
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
|
17
|
+
# More ruby-ish names
|
18
|
+
alias :contains? :contains
|
19
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# Text editor supporting various formatting, intended for editing
|
2
|
+
# natural language texts
|
3
|
+
class Wx::RichTextCtrl
|
4
|
+
# These three methods return the styles applicable at certain points
|
5
|
+
# in the document. However, the standard wx signature is to accept the
|
6
|
+
# value of some kind of TextAttr class that will hold the return as an
|
7
|
+
# argument. The return value is a boolean for success/failure. In
|
8
|
+
# Ruby, we only support returning the value as a RichTextAttr, and do
|
9
|
+
# so as a proper return value, having accepted a single argument
|
10
|
+
# specifying where to get the style from. If retrieval is not
|
11
|
+
# successful, raise an exception.
|
12
|
+
wx_get_style = self.instance_method(:get_style)
|
13
|
+
define_method(:get_style) do | pos |
|
14
|
+
style = Wx::RichTextAttr.new
|
15
|
+
if wx_get_style.bind(self).call(pos, style)
|
16
|
+
return style
|
17
|
+
else
|
18
|
+
Kernel.raise RuntimeError, "Could not retrieve style at position #{pos}"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
wx_get_style_for_range = self.instance_method(:get_style_for_range)
|
23
|
+
define_method(:get_style_for_range) do | rng |
|
24
|
+
style = Wx::RichTextAttr.new
|
25
|
+
if wx_get_style_for_range.bind(self).call(rng, style)
|
26
|
+
return style
|
27
|
+
else
|
28
|
+
Kernel.raise RuntimeError, "Could not retrieve style for range #{rng}"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
wx_get_uncombined_style = self.instance_method(:get_uncombined_style)
|
33
|
+
define_method(:get_uncombined_style) do | pos |
|
34
|
+
style = Wx::RichTextAttr.new
|
35
|
+
if wx_get_uncombined_style.bind(self).call(pos, style)
|
36
|
+
return style
|
37
|
+
else
|
38
|
+
Kernel.raise RuntimeError, "Could not retrieve style at position #{pos}"
|
39
|
+
end
|
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
|
63
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# Pure-ruby implementation of the corresponding Wx class. Simply shows
|
2
|
+
# the Window's help text in a tooltip.
|
3
|
+
class Wx::SimpleHelpProvider < Wx::HelpProvider
|
4
|
+
def initialize
|
5
|
+
super
|
6
|
+
# Store for mapping windows -> help strings
|
7
|
+
@help_wins = {}
|
8
|
+
# Store for mapping ids -> help strings
|
9
|
+
@help_ids = {}
|
10
|
+
end
|
11
|
+
|
12
|
+
# This is what is called by Wx::Window#set_help_text
|
13
|
+
def add_help(identifier, text)
|
14
|
+
if identifier.kind_of? Wx::Window
|
15
|
+
@help_wins[identifier.object_id] = text
|
16
|
+
else
|
17
|
+
@help_ids[identifier] = text
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# Retrieve help text for the given window +win+
|
22
|
+
def get_help(win)
|
23
|
+
@help_wins[win.object_id] || @help_ids[win.wx_id] || ""
|
24
|
+
end
|
25
|
+
|
26
|
+
# Remove the help text for +win+
|
27
|
+
def remove_help(win)
|
28
|
+
@help_wins.delete(win.object_id)
|
29
|
+
end
|
30
|
+
|
31
|
+
# Show help for +win+
|
32
|
+
def show_help(win)
|
33
|
+
help_text = get_help(win)
|
34
|
+
return false if help_text.empty?
|
35
|
+
tip = Wx::TipWindow.new(win, help_text, 100)
|
36
|
+
true
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
class Wx::Size
|
2
|
+
# More informative output for inspect etc
|
3
|
+
def to_s
|
4
|
+
"#<Wx::Size: (#{get_width}, #{get_height})>"
|
5
|
+
end
|
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
|
+
|
15
|
+
# Return a new Wx::Size with the width and height values both divided
|
16
|
+
# by parameter +div+, which should be a Numeric
|
17
|
+
def /(div)
|
18
|
+
self.class.new( (get_x / div).to_i, (get_y / div).to_i )
|
19
|
+
end
|
20
|
+
|
21
|
+
# Return a new Wx::Size with the width and height values both
|
22
|
+
# multiplied by parameter +mul+, which should be a Numeric
|
23
|
+
def *(mul)
|
24
|
+
self.class.new( (get_x * mul).to_i, (get_y * mul).to_i )
|
25
|
+
end
|
26
|
+
|
27
|
+
# Return a new Wx::Size with the width and height parameters both
|
28
|
+
# reduced by parameter +arg+. If +arg+ is another Wx::Size, reduce
|
29
|
+
# width by the other's width and height by the other's height; if
|
30
|
+
# +arg+ is a numeric value, reduce both width and height by that
|
31
|
+
# value.
|
32
|
+
def -(arg)
|
33
|
+
case arg
|
34
|
+
when self.class
|
35
|
+
self.class.new( get_x - arg.get_x, get_y - arg.get_y )
|
36
|
+
when Numeric
|
37
|
+
self.class.new( (get_x - arg).to_i, (get_y - arg).to_i )
|
38
|
+
else
|
39
|
+
Kernel.raise TypeError, "Cannot add #{arg} to #{self.inspect}"
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# Return a new Wx::Size with the width and height parameters both
|
44
|
+
# increased by parameter +arg+. If +arg+ is another Wx::Size, increase
|
45
|
+
# width by the other's width and height by the other's height; if
|
46
|
+
# +arg+ is a numeric value, increase both width and height by that
|
47
|
+
# value.
|
48
|
+
def +(arg)
|
49
|
+
case arg
|
50
|
+
when self.class
|
51
|
+
self.class.new( get_x + arg.get_x, get_y + arg.get_y )
|
52
|
+
when Numeric
|
53
|
+
self.class.new( (get_x + arg).to_i, (get_y + arg).to_i )
|
54
|
+
else
|
55
|
+
Kernel.raise TypeError, "Cannot add #{arg} to #{self.inspect}"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# Class for automatically managing layouts
|
2
|
+
class Wx::Sizer
|
3
|
+
# Generic method to add items, supporting positional and named
|
4
|
+
# arguments
|
5
|
+
ADD_ITEM_PARAMS = [ Wx::Parameter[ :index, -1 ],
|
6
|
+
Wx::Parameter[ :proportion, 0 ],
|
7
|
+
Wx::Parameter[ :flag, 0 ],
|
8
|
+
Wx::Parameter[ :border, 0 ],
|
9
|
+
Wx::Parameter[ :user_data, nil ] ]
|
10
|
+
|
11
|
+
def add_item(item, *mixed_args)
|
12
|
+
args = Wx::args_as_list(ADD_ITEM_PARAMS, *mixed_args)
|
13
|
+
|
14
|
+
full_args = []
|
15
|
+
|
16
|
+
# extract the width and the height in the case of a spacer
|
17
|
+
# defined as an array
|
18
|
+
if item.kind_of?(Array)
|
19
|
+
Kernel.raise ArgumentError,
|
20
|
+
"Invalid Sizer specification : [width, height] expected" if item.size != 2
|
21
|
+
full_args << item[0] << item[1]
|
22
|
+
else
|
23
|
+
full_args << item
|
24
|
+
end
|
25
|
+
|
26
|
+
# update the full arguments list with the optional arguments (except index)
|
27
|
+
idx = args.shift
|
28
|
+
full_args.concat(args)
|
29
|
+
|
30
|
+
# Call add to append if default position
|
31
|
+
if idx == -1
|
32
|
+
add(*full_args)
|
33
|
+
else
|
34
|
+
insert(idx, *full_args)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# Plays simple sounds from .wav files
|
2
|
+
class Wx::Sound
|
3
|
+
class << self
|
4
|
+
# Shortcut class method, as per the wxWidgets docs, but easier to do
|
5
|
+
# in Ruby
|
6
|
+
def play(file, flags = Wx::SOUND_ASYNC)
|
7
|
+
new(file).play(flags)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
# Test if newly created Sound is valid; if not, raise an exception
|
12
|
+
# rather than failing silently.
|
13
|
+
wx_init = self.instance_method(:initialize)
|
14
|
+
define_method(:initialize) do | *args |
|
15
|
+
if not File.exist?( File.expand_path(args[0]) )
|
16
|
+
Kernel.raise(ArgumentError, "Sound file does not exist: #{args[0]}")
|
17
|
+
end
|
18
|
+
wx_init.bind(self).call(*args)
|
19
|
+
if not ok?
|
20
|
+
Kernel.raise(ArgumentError, "Error loading sound file #{args[0]}")
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
# Access OS-standard locations for user files, config files etc
|
2
|
+
class Wx::StandardPaths
|
3
|
+
class << self
|
4
|
+
# Expose instance methods as class methods in Ruby
|
5
|
+
Wx::StandardPaths.instance_methods(false).each do | meth |
|
6
|
+
define_method(meth) { get.send(meth) }
|
7
|
+
end
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
# Functionality here must be loaded first to add custom events
|
2
|
+
require 'wx/classes/evthandler'
|
3
|
+
|
4
|
+
# These event type constants will only be available and meaningful if
|
5
|
+
# Wx::StyledTextCtrl has been compiled into the library. If so, they
|
6
|
+
# need the below definitions for mapping, otherwise all the rest should
|
7
|
+
# be skipped
|
8
|
+
if defined?(Wx::StyledTextCtrl)
|
9
|
+
EventType = Wx::EvtHandler::EventType
|
10
|
+
|
11
|
+
stc_event_types = [
|
12
|
+
EventType['evt_stc_calltip_click', 1,
|
13
|
+
Wx::EVT_STC_CALLTIP_CLICK,
|
14
|
+
Wx::StyledTextEvent],
|
15
|
+
EventType['evt_stc_change', 1,
|
16
|
+
Wx::EVT_STC_CHANGE,
|
17
|
+
Wx::StyledTextEvent],
|
18
|
+
EventType['evt_stc_charadded', 1,
|
19
|
+
Wx::EVT_STC_CHARADDED,
|
20
|
+
Wx::StyledTextEvent],
|
21
|
+
EventType['evt_stc_doubleclick', 1,
|
22
|
+
Wx::EVT_STC_DOUBLECLICK,
|
23
|
+
Wx::StyledTextEvent],
|
24
|
+
EventType['evt_stc_do_drop', 1,
|
25
|
+
Wx::EVT_STC_DO_DROP,
|
26
|
+
Wx::StyledTextEvent],
|
27
|
+
EventType['evt_stc_drag_over', 1,
|
28
|
+
Wx::EVT_STC_DRAG_OVER,
|
29
|
+
Wx::StyledTextEvent],
|
30
|
+
EventType['evt_stc_dwellend', 1,
|
31
|
+
Wx::EVT_STC_DWELLEND,
|
32
|
+
Wx::StyledTextEvent],
|
33
|
+
EventType['evt_stc_dwellstart', 1,
|
34
|
+
Wx::EVT_STC_DWELLSTART,
|
35
|
+
Wx::StyledTextEvent],
|
36
|
+
EventType['evt_stc_hotspot_click', 1,
|
37
|
+
Wx::EVT_STC_HOTSPOT_CLICK,
|
38
|
+
Wx::StyledTextEvent],
|
39
|
+
EventType['evt_stc_hotspot_dclick', 1,
|
40
|
+
Wx::EVT_STC_HOTSPOT_DCLICK,
|
41
|
+
Wx::StyledTextEvent],
|
42
|
+
EventType['evt_stc_key', 1,
|
43
|
+
Wx::EVT_STC_KEY,
|
44
|
+
Wx::StyledTextEvent],
|
45
|
+
EventType['evt_stc_macrorecord', 1,
|
46
|
+
Wx::EVT_STC_MACRORECORD,
|
47
|
+
Wx::StyledTextEvent],
|
48
|
+
EventType['evt_stc_marginclick', 1,
|
49
|
+
Wx::EVT_STC_MARGINCLICK,
|
50
|
+
Wx::StyledTextEvent],
|
51
|
+
EventType['evt_stc_modified', 1,
|
52
|
+
Wx::EVT_STC_MODIFIED,
|
53
|
+
Wx::StyledTextEvent],
|
54
|
+
EventType['evt_stc_needshown', 1,
|
55
|
+
Wx::EVT_STC_NEEDSHOWN,
|
56
|
+
Wx::StyledTextEvent],
|
57
|
+
EventType['evt_stc_painted', 1,
|
58
|
+
Wx::EVT_STC_PAINTED,
|
59
|
+
Wx::StyledTextEvent],
|
60
|
+
EventType['evt_stc_romodifyattempt', 1,
|
61
|
+
Wx::EVT_STC_ROMODIFYATTEMPT,
|
62
|
+
Wx::StyledTextEvent],
|
63
|
+
EventType['evt_stc_savepointleft', 1,
|
64
|
+
Wx::EVT_STC_SAVEPOINTLEFT,
|
65
|
+
Wx::StyledTextEvent],
|
66
|
+
EventType['evt_stc_savepointreached', 1,
|
67
|
+
Wx::EVT_STC_SAVEPOINTREACHED,
|
68
|
+
Wx::StyledTextEvent],
|
69
|
+
EventType['evt_stc_start_drag', 1,
|
70
|
+
Wx::EVT_STC_START_DRAG,
|
71
|
+
Wx::StyledTextEvent],
|
72
|
+
EventType['evt_stc_styleneeded', 1,
|
73
|
+
Wx::EVT_STC_STYLENEEDED,
|
74
|
+
Wx::StyledTextEvent],
|
75
|
+
EventType['evt_stc_updateui', 1,
|
76
|
+
Wx::EVT_STC_UPDATEUI,
|
77
|
+
Wx::StyledTextEvent],
|
78
|
+
EventType['evt_stc_uridropped', 1,
|
79
|
+
Wx::EVT_STC_URIDROPPED,
|
80
|
+
Wx::StyledTextEvent],
|
81
|
+
EventType['evt_stc_userlistselection', 1,
|
82
|
+
Wx::EVT_STC_USERLISTSELECTION,
|
83
|
+
Wx::StyledTextEvent],
|
84
|
+
EventType['evt_stc_zoom', 1,
|
85
|
+
Wx::EVT_STC_ZOOM,
|
86
|
+
Wx::StyledTextEvent]
|
87
|
+
]
|
88
|
+
|
89
|
+
stc_event_types.each do | ev_type |
|
90
|
+
Wx::EvtHandler.register_event_type(ev_type)
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
class Wx::TextCtrl
|
2
|
+
# Fix position_to_xy so it returns a two-element array - the internal
|
3
|
+
# version returns a three-element array with a Boolean that doesn't
|
4
|
+
# really make sense in Ruby
|
5
|
+
wx_position_to_xy = instance_method(:position_to_xy)
|
6
|
+
define_method(:position_to_xy) do | pos |
|
7
|
+
retval, x, y = wx_position_to_xy.bind(self).call(pos)
|
8
|
+
if retval
|
9
|
+
return [x, y]
|
10
|
+
else
|
11
|
+
return nil
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# Event fired when a user clicks or hovers over a hyperlink in a TextCtrl
|
2
|
+
class Wx::TextUrlEvent
|
3
|
+
# Returns the string URL that is being interacted with in this event
|
4
|
+
def get_url
|
5
|
+
text_ctrl = event_object
|
6
|
+
# In the standard TextCtrl, the relevant URL is always the same as
|
7
|
+
# the text clicked on, because all it does is highlight text that
|
8
|
+
# look like a URL. In RichTextCtrl, however, the URL value can be
|
9
|
+
# applied to any text (more like HTML), and so the URL has be
|
10
|
+
# retrieved by getting the applied RichTextAttr style and inspecting
|
11
|
+
# its property.
|
12
|
+
if text_ctrl.kind_of?(Wx::RichTextCtrl)
|
13
|
+
return text_ctrl.get_style(url_start).url
|
14
|
+
else
|
15
|
+
return text_ctrl.value[url_start .. url_end]
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
# Class allowing periodic or timed events to be fired
|
2
|
+
class Wx::Timer
|
3
|
+
# Convenience method to trigger a one-off action after +interval+
|
4
|
+
# milliseconds have passed. The action is specified by the passed
|
5
|
+
# block. The Timer is owned by the global App object, and is returned
|
6
|
+
# by the method.
|
7
|
+
def self.after(interval, &block)
|
8
|
+
timer = new(Wx::THE_APP, Wx::ID_ANY)
|
9
|
+
Wx::THE_APP.evt_timer(timer.get_id, block)
|
10
|
+
timer.start(interval, true)
|
11
|
+
timer
|
12
|
+
end
|
13
|
+
|
14
|
+
# Convenience method to trigger a repeating action every +interval+
|
15
|
+
# milliseconds. The action is specified by the passed block. The Timer
|
16
|
+
# is owned by the global App object, and is returned by the method.
|
17
|
+
def self.every(interval, &block)
|
18
|
+
timer = new(Wx::THE_APP, Wx::ID_ANY)
|
19
|
+
Wx::THE_APP.evt_timer(timer.get_id, block)
|
20
|
+
timer.start(interval)
|
21
|
+
timer
|
22
|
+
end
|
23
|
+
|
24
|
+
# In common with other classes, make the id method refer to the
|
25
|
+
# wxWidgets id, not ruby's deprecated name for object_id
|
26
|
+
alias :id :get_id
|
27
|
+
|
28
|
+
# This class can be linked to an owner - an instance of a class
|
29
|
+
# derived from EvtHandler which will receive Timer events. However,
|
30
|
+
# event if a Wx::Timer is attached to a Wx::Window, it is (unlike most
|
31
|
+
# classes) NOT automatically deleted when the window is destroyed. If
|
32
|
+
# the Timer continues ticking, it will send events to the
|
33
|
+
# now-destroyed window, causing segfaults. So the little acrobatics
|
34
|
+
# below set up a hook when a Timer's owner is set, and then ensure the
|
35
|
+
# timer is stopped when the window is destroyed.
|
36
|
+
|
37
|
+
# Redefine initialize
|
38
|
+
wx_init = self.instance_method(:initialize)
|
39
|
+
define_method(:initialize) do | *args |
|
40
|
+
setup_owner_destruction_hook(args[0])
|
41
|
+
wx_init.bind(self).call(*args)
|
42
|
+
end
|
43
|
+
|
44
|
+
# Redefine set_owner
|
45
|
+
wx_set_owner = self.instance_method(:set_owner)
|
46
|
+
define_method(:set_owner) do | *args |
|
47
|
+
setup_owner_destruction_hook(args[0])
|
48
|
+
wx_set_owner.bind(self).call(*args)
|
49
|
+
end
|
50
|
+
|
51
|
+
private
|
52
|
+
# This method notes in Ruby the ownership of the timer, from both
|
53
|
+
# sides, and sets up an event hook if needed for the window's
|
54
|
+
# destruction.
|
55
|
+
def setup_owner_destruction_hook(new_owner)
|
56
|
+
this_timer = self
|
57
|
+
|
58
|
+
# Class-wide list of global (unowned) timers
|
59
|
+
@@__unowned_timers__ ||= []
|
60
|
+
|
61
|
+
# remove from list of previous owner
|
62
|
+
if defined?(@__owner__) and @__owner__
|
63
|
+
@__owner__.instance_eval { @__owned_timers__.delete(this_timer) }
|
64
|
+
end
|
65
|
+
|
66
|
+
# If becoming global unowned timer, add to list of those timers
|
67
|
+
if not new_owner
|
68
|
+
@__owner__ = nil
|
69
|
+
@@__unowned_timers__ << self
|
70
|
+
return
|
71
|
+
end
|
72
|
+
|
73
|
+
# Otherwise, if previously unowned, remove from global owned
|
74
|
+
@@__unowned_timers__.delete(self)
|
75
|
+
@__owner__ = new_owner
|
76
|
+
|
77
|
+
# Then add to list of new owner, setting destructor hook if required
|
78
|
+
new_owner.instance_eval do
|
79
|
+
if not defined?(@__owned_timers__)
|
80
|
+
@__owned_timers__ = []
|
81
|
+
unless self.kind_of?(Wx::App) # Don't set up hook on App
|
82
|
+
evt_window_destroy do | evt |
|
83
|
+
# If it's the owning window being destroyed...
|
84
|
+
if evt.get_event_object == self
|
85
|
+
@__owned_timers__.each { | timer | timer.stop }
|
86
|
+
end
|
87
|
+
evt.skip
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
@__owned_timers__ << this_timer
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|