wxruby 1.9.3-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 +299 -0
- data/lib/wx.rb +42 -0
- data/lib/wx/accessors.rb +52 -0
- data/lib/wx/classes/app.rb +45 -0
- data/lib/wx/classes/artprovider.rb +31 -0
- data/lib/wx/classes/bitmap.rb +23 -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 +16 -0
- data/lib/wx/classes/colour.rb +47 -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/event.rb +5 -0
- data/lib/wx/classes/evthandler.rb +894 -0
- data/lib/wx/classes/font.rb +118 -0
- data/lib/wx/classes/grid.rb +129 -0
- data/lib/wx/classes/helpcontroller.rb +5 -0
- data/lib/wx/classes/htmlhelpcontroller.rb +5 -0
- data/lib/wx/classes/htmlwindow.rb +6 -0
- data/lib/wx/classes/icon.rb +14 -0
- data/lib/wx/classes/image.rb +14 -0
- data/lib/wx/classes/listbox.rb +4 -0
- data/lib/wx/classes/listctrl.rb +21 -0
- data/lib/wx/classes/locale.rb +28 -0
- data/lib/wx/classes/mediactrl.rb +22 -0
- data/lib/wx/classes/menu.rb +62 -0
- data/lib/wx/classes/menuitem.rb +7 -0
- data/lib/wx/classes/object.rb +7 -0
- data/lib/wx/classes/paintdc.rb +12 -0
- data/lib/wx/classes/point.rb +48 -0
- data/lib/wx/classes/previewframe.rb +13 -0
- data/lib/wx/classes/rect.rb +5 -0
- data/lib/wx/classes/size.rb +49 -0
- data/lib/wx/classes/sound.rb +23 -0
- data/lib/wx/classes/styledtextctrl.rb +92 -0
- data/lib/wx/classes/textctrl.rb +14 -0
- data/lib/wx/classes/texturlevent.rb +6 -0
- data/lib/wx/classes/timer.rb +69 -0
- data/lib/wx/classes/treectrl.rb +44 -0
- data/lib/wx/classes/window.rb +49 -0
- data/lib/wx/classes/xmlresource.rb +16 -0
- data/lib/wx/keyword_ctors.rb +219 -0
- data/lib/wx/keyword_defs.rb +485 -0
- data/lib/wx/version.rb +3 -0
- data/lib/wxruby2.so +0 -0
- data/samples/SAMPLES-LICENSE.TXT +18 -0
- data/samples/aui/aui.rb +1360 -0
- data/samples/bigdemo/About.rbw +39 -0
- data/samples/bigdemo/ColorPanel.rbw +25 -0
- data/samples/bigdemo/GridSimple.rbw +80 -0
- data/samples/bigdemo/MDIDemo.rbw +59 -0
- data/samples/bigdemo/PopupMenu.rbw +151 -0
- data/samples/bigdemo/ShapedWindow.rbw +135 -0
- data/samples/bigdemo/Sizers.rbw +545 -0
- data/samples/bigdemo/bigdemo.rb +826 -0
- data/samples/bigdemo/demoTemplate.rbw +37 -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 +94 -0
- data/samples/bigdemo/tips.txt +7 -0
- data/samples/bigdemo/utils.rb +12 -0
- data/samples/bigdemo/wxArtProvider.rbw +285 -0
- data/samples/bigdemo/wxBitmapButton.rbw +64 -0
- data/samples/bigdemo/wxButton.rbw +66 -0
- data/samples/bigdemo/wxCalendarCtrl.rbw +72 -0
- data/samples/bigdemo/wxCheckBox.rbw +52 -0
- data/samples/bigdemo/wxCheckListBox.rbw +77 -0
- data/samples/bigdemo/wxChoice.rbw +49 -0
- data/samples/bigdemo/wxChoicebook.rbw +80 -0
- data/samples/bigdemo/wxColourDialog.rbw +34 -0
- data/samples/bigdemo/wxComboBox.rbw +79 -0
- data/samples/bigdemo/wxCursor.rbw +140 -0
- data/samples/bigdemo/wxDialog.rbw +92 -0
- data/samples/bigdemo/wxDirDialog.rbw +32 -0
- data/samples/bigdemo/wxDragImage.rbw +74 -0
- data/samples/bigdemo/wxFileDialog.rbw +39 -0
- data/samples/bigdemo/wxFileDialog_Save.rbw +38 -0
- data/samples/bigdemo/wxFindReplaceDialog.rbw +85 -0
- data/samples/bigdemo/wxFontDialog.rbw +176 -0
- data/samples/bigdemo/wxFrame.rbw +55 -0
- data/samples/bigdemo/wxGauge.rbw +73 -0
- data/samples/bigdemo/wxGenericDirCtrl.rbw +78 -0
- data/samples/bigdemo/wxGrid.rbw +68 -0
- data/samples/bigdemo/wxHtmlHelpController.rbw +57 -0
- data/samples/bigdemo/wxListBox.rbw +142 -0
- data/samples/bigdemo/wxListCtrl_virtual.rbw +109 -0
- data/samples/bigdemo/wxMDIWindows.rbw +52 -0
- data/samples/bigdemo/wxMenu.rbw +238 -0
- data/samples/bigdemo/wxMessageDialog.rbw +30 -0
- data/samples/bigdemo/wxMiniFrame.rbw +74 -0
- data/samples/bigdemo/wxMultipleChoiceDialog.rbw +34 -0
- data/samples/bigdemo/wxNotebook.rbw +138 -0
- data/samples/bigdemo/wxProgressDialog.rbw +45 -0
- data/samples/bigdemo/wxRadioBox.rbw +74 -0
- data/samples/bigdemo/wxRadioButton.rbw +127 -0
- data/samples/bigdemo/wxSashWindow.rbw +145 -0
- data/samples/bigdemo/wxScrolledMessageDialog.rbw +59 -0
- data/samples/bigdemo/wxScrolledWindow.rbw +201 -0
- data/samples/bigdemo/wxSingleChoiceDialog.rbw +35 -0
- data/samples/bigdemo/wxSlider.rbw +44 -0
- data/samples/bigdemo/wxSpinButton.rbw +52 -0
- data/samples/bigdemo/wxSpinCtrl.rbw +53 -0
- data/samples/bigdemo/wxSplitterWindow.rbw +65 -0
- data/samples/bigdemo/wxStaticBitmap.rbw +53 -0
- data/samples/bigdemo/wxStaticText.rbw +57 -0
- data/samples/bigdemo/wxStatusBar.rbw +128 -0
- data/samples/bigdemo/wxTextCtrl.rbw +151 -0
- data/samples/bigdemo/wxTextEntryDialog.rbw +34 -0
- data/samples/bigdemo/wxToggleButton.rbw +51 -0
- data/samples/bigdemo/wxToolBar.rbw +133 -0
- data/samples/bigdemo/wxTreeCtrl.rbw +192 -0
- data/samples/calendar/calendar.rb +275 -0
- data/samples/caret/caret.rb +286 -0
- data/samples/caret/mondrian.xpm +44 -0
- data/samples/controls/controls.rb +1140 -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 +724 -0
- data/samples/dialogs/tips.txt +18 -0
- data/samples/drawing/graphics_drawing.rb +232 -0
- data/samples/drawing/images.rb +48 -0
- data/samples/drawing/paperclip.png +0 -0
- data/samples/etc/activation.rb +108 -0
- data/samples/etc/choice.rb +72 -0
- data/samples/etc/miniframe.rb +84 -0
- data/samples/etc/sash.rb +135 -0
- data/samples/etc/scrollwin.rb +116 -0
- data/samples/etc/system_settings.rb +258 -0
- data/samples/etc/threaded.rb +81 -0
- data/samples/etc/wizard.rb +79 -0
- data/samples/event/event.rb +184 -0
- data/samples/grid/grid.rb +202 -0
- data/samples/html/html.rb +264 -0
- data/samples/listbook/listbook.rb +181 -0
- data/samples/listbook/listbook.xrc +370 -0
- data/samples/mdi/mdi.rb +87 -0
- data/samples/media/mediactrl.rb +173 -0
- data/samples/minimal/minimal.rb +85 -0
- data/samples/minimal/mondrian.ico +0 -0
- data/samples/minimal/mondrian.png +0 -0
- data/samples/minimal/nothing.rb +21 -0
- data/samples/opengl/cube.rb +123 -0
- data/samples/printing/mondrian.ico +0 -0
- data/samples/printing/mondrian.xpm +44 -0
- data/samples/printing/printing.rb +484 -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/mondrian.ico +0 -0
- data/samples/text/mondrian.xpm +44 -0
- data/samples/text/scintilla.rb +174 -0
- data/samples/text/textctrl.rb +124 -0
- data/samples/text/unicode.rb +238 -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 +1180 -0
- data/samples/xrc/samples.xrc +46 -0
- data/samples/xrc/xrc_sample.rb +107 -0
- metadata +303 -0
@@ -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,48 @@
|
|
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
|
+
# 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
|
48
|
+
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,49 @@
|
|
1
|
+
class Wx::Size
|
2
|
+
def to_s
|
3
|
+
"#<Wx::Size: (#{get_width}, #{get_height})>"
|
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
|
49
|
+
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,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,69 @@
|
|
1
|
+
# Class allowing periodic or timed events to be fired
|
2
|
+
class Wx::Timer
|
3
|
+
# This class can be linked to an owner - an instance of a class
|
4
|
+
# derived from EvtHandler which will receive Timer events. However,
|
5
|
+
# event if a Wx::Timer is attached to a Wx::Window, it is (unlike most
|
6
|
+
# classes) NOT automatically deleted when the window is destroyed. If
|
7
|
+
# the Timer continues ticking, it will send events to the
|
8
|
+
# now-destroyed window, causing segfaults. So the little acrobatics
|
9
|
+
# below set up a hook when a Timer's owner is set, and then ensure the
|
10
|
+
# timer is stopped when the window is destroyed.
|
11
|
+
|
12
|
+
# Redefine initialize
|
13
|
+
wx_init = self.instance_method(:initialize)
|
14
|
+
define_method(:initialize) do | *args |
|
15
|
+
setup_owner_destruction_hook(args[0])
|
16
|
+
wx_init.bind(self).call(*args)
|
17
|
+
end
|
18
|
+
|
19
|
+
# Redefine set_owner
|
20
|
+
wx_set_owner = self.instance_method(:set_owner)
|
21
|
+
define_method(:set_owner) do | *args |
|
22
|
+
setup_owner_destruction_hook(args[0])
|
23
|
+
wx_set_owner.bind(self).call(*args)
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
# This method notes in Ruby the ownership of the timer, from both
|
28
|
+
# sides, and sets up an event hook if needed for the window's
|
29
|
+
# destruction.
|
30
|
+
def setup_owner_destruction_hook(new_owner)
|
31
|
+
this_timer = self
|
32
|
+
|
33
|
+
# Class-wide list of global (unowned) timers
|
34
|
+
@@__unowned_timers__ ||= []
|
35
|
+
|
36
|
+
# remove from list of previous owner
|
37
|
+
if defined?(@__owner__) and @__owner__
|
38
|
+
@__owner__.instance_eval { @__owned_timers__.delete(this_timer) }
|
39
|
+
end
|
40
|
+
|
41
|
+
# If becoming global unowned timer, add to list of those timers
|
42
|
+
if not new_owner
|
43
|
+
@__owner__ = nil
|
44
|
+
@@__unowned_timers__ << self
|
45
|
+
return
|
46
|
+
end
|
47
|
+
|
48
|
+
# Otherwise, if previously unowned, remove from global owned
|
49
|
+
@@__unowned_timers__.delete(self)
|
50
|
+
@__owner__ = new_owner
|
51
|
+
|
52
|
+
# Then add to list of new owner, setting destructor hook if required
|
53
|
+
new_owner.instance_eval do
|
54
|
+
if not defined?(@__owned_timers__)
|
55
|
+
@__owned_timers__ = []
|
56
|
+
unless self.kind_of?(Wx::App) # Don't set up hook on App
|
57
|
+
evt_window_destroy do | evt |
|
58
|
+
# If it's the owning window being destroyed...
|
59
|
+
if evt.get_event_object == self
|
60
|
+
@__owned_timers__.each { | timer | timer.stop }
|
61
|
+
end
|
62
|
+
evt.skip
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
@__owned_timers__ << this_timer
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# Hierarchical control with items
|
2
|
+
class Wx::TreeCtrl
|
3
|
+
# Make these ruby enumerables so find, find_all, map etc are available
|
4
|
+
include Enumerable
|
5
|
+
# Iterate over all items
|
6
|
+
alias :each :traverse
|
7
|
+
|
8
|
+
# Return the children of +parent+ as an array of TreeItemIDs.
|
9
|
+
def get_children(parent)
|
10
|
+
kids = [ get_first_child(parent) ]
|
11
|
+
return [] if kids[0].zero?
|
12
|
+
|
13
|
+
while kid = get_next_sibling(kids.last) and not kid.zero?
|
14
|
+
kids << kid
|
15
|
+
end
|
16
|
+
kids
|
17
|
+
end
|
18
|
+
|
19
|
+
# Returns a Wx::Rect corresponding to the edges of an individual tree
|
20
|
+
# item, including the button, identified by id. The standard wxWidgets
|
21
|
+
# API for getting the pixel location of an item is unrubyish, using an
|
22
|
+
# input/output parameter. But since the underlying get_bounding_rect
|
23
|
+
# method works, it's easier to fix the API in Ruby than adding more to
|
24
|
+
# the already-toxic swig interface TreeCtrl.i file.
|
25
|
+
def get_item_rect(tree_item_id)
|
26
|
+
rect = Wx::Rect.new
|
27
|
+
if get_bounding_rect(tree_item_id, rect, false)
|
28
|
+
return rect
|
29
|
+
else
|
30
|
+
return nil
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
# Returns a Wx::Rect corresponding to the edges of an individual tree
|
35
|
+
# item's text label. See above.
|
36
|
+
def get_label_rect(tree_item_id)
|
37
|
+
rect = Wx::Rect.new
|
38
|
+
if get_bounding_rect(tree_item_id, rect, true)
|
39
|
+
return rect
|
40
|
+
else
|
41
|
+
nil
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# Copyright 2004-2007 by Kevin Smith
|
2
|
+
# released under the MIT-style wxruby2 license
|
3
|
+
|
4
|
+
# The base class for all things displayed on screen
|
5
|
+
class Wx::Window
|
6
|
+
|
7
|
+
# Ruby's Object#id is deprecated and will be removed in 1.9; therefore
|
8
|
+
# for classes inheriting from Wx::Window, the id method returns the
|
9
|
+
# wxRuby Window id
|
10
|
+
alias :id :get_id
|
11
|
+
# In case a more explicit option is preferred.
|
12
|
+
alias :wx_id :get_id
|
13
|
+
|
14
|
+
|
15
|
+
# Recursively searches all windows below +self+ and returns the first
|
16
|
+
# window which has the id +an_id+. This corresponds to the find_window
|
17
|
+
# method method in WxWidgets when called with an integer.
|
18
|
+
def find_window_by_id(an_id)
|
19
|
+
Wx::Window.find_window_by_id(an_id, self)
|
20
|
+
end
|
21
|
+
|
22
|
+
# Searches all windows below +self+ and returns the first window which
|
23
|
+
# has the name +a_name+ This corresponds to the find_window method method
|
24
|
+
# in WxWidgets when called with an string.
|
25
|
+
def find_window_by_name(a_name)
|
26
|
+
Wx::Window.find_window_by_name(a_name, self)
|
27
|
+
end
|
28
|
+
|
29
|
+
# Searches all windows below +self+ and returns the first window which
|
30
|
+
# has the label +a_label+.
|
31
|
+
def find_window_by_label(a_label)
|
32
|
+
Wx:Window.find_window_by_label(a_label, self)
|
33
|
+
end
|
34
|
+
|
35
|
+
alias :__old_evt_paint :evt_paint
|
36
|
+
# This modified version of evt_paint sets a variable indicating that a
|
37
|
+
# paint event is being handled just before running the event
|
38
|
+
# handler. This ensures that any call to Window#paint within the
|
39
|
+
# handler will supply a Wx::PaintDC (see swig/Window.i).
|
40
|
+
def evt_paint(meth = nil, &block)
|
41
|
+
paint_proc = acquire_handler(meth, block)
|
42
|
+
wrapped_block = proc do | event |
|
43
|
+
instance_variable_set("@__painting__", true)
|
44
|
+
paint_proc.call(event)
|
45
|
+
remove_instance_variable("@__painting__")
|
46
|
+
end
|
47
|
+
__old_evt_paint(&wrapped_block)
|
48
|
+
end
|
49
|
+
end
|