wxruby 1.9.9-x86-mingw32 → 1.9.10-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +53 -53
- data/README +297 -297
- data/lib/wx.rb +53 -53
- 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.so +0 -0
- data/samples/SAMPLES-LICENSE.TXT +17 -17
- data/samples/bigdemo/About.rbw +39 -39
- data/samples/bigdemo/ColorPanel.rbw +23 -23
- data/samples/bigdemo/GridSimple.rbw +78 -78
- data/samples/bigdemo/MDIDemo.rbw +57 -57
- data/samples/bigdemo/PopupMenu.rbw +149 -149
- data/samples/bigdemo/Sizers.rbw +543 -543
- data/samples/bigdemo/bigdemo.rb +823 -823
- data/samples/bigdemo/demoTemplate.rbw +33 -33
- data/samples/bigdemo/icons/choice.xpm +27 -27
- data/samples/bigdemo/icons/combo.xpm +27 -27
- data/samples/bigdemo/icons/copy.xpm +25 -25
- data/samples/bigdemo/icons/cut.xpm +24 -24
- data/samples/bigdemo/icons/gauge.xpm +27 -27
- data/samples/bigdemo/icons/help.xpm +25 -25
- data/samples/bigdemo/icons/list.xpm +27 -27
- data/samples/bigdemo/icons/mondrian.xpm +44 -44
- data/samples/bigdemo/icons/new.xpm +24 -24
- data/samples/bigdemo/icons/ogl.ico +0 -0
- data/samples/bigdemo/icons/ogl.xpm +45 -45
- data/samples/bigdemo/icons/open.xpm +26 -26
- data/samples/bigdemo/icons/paste.xpm +38 -38
- data/samples/bigdemo/icons/preview.xpm +26 -26
- data/samples/bigdemo/icons/print.xpm +26 -26
- data/samples/bigdemo/icons/radio.xpm +27 -27
- data/samples/bigdemo/icons/robert.xpm +415 -415
- data/samples/bigdemo/icons/save.xpm +25 -25
- data/samples/bigdemo/icons/smiles.xpm +39 -39
- data/samples/bigdemo/icons/smiley.xpm +42 -42
- data/samples/bigdemo/icons/stattext.xpm +24 -24
- data/samples/bigdemo/icons/test2.bmp +0 -0
- data/samples/bigdemo/icons/test2.xpm +79 -79
- data/samples/bigdemo/icons/text.xpm +27 -27
- data/samples/bigdemo/icons/tog1.xpm +38 -38
- data/samples/bigdemo/icons/tog2.xpm +38 -38
- data/samples/bigdemo/icons/wxwin16x16.xpm +25 -25
- data/samples/bigdemo/tips.txt +7 -7
- data/samples/bigdemo/utils.rb +11 -11
- data/samples/bigdemo/wxButton.rbw +64 -64
- data/samples/bigdemo/wxCalendarCtrl.rbw +60 -60
- data/samples/bigdemo/wxCheckBox.rbw +50 -50
- data/samples/bigdemo/wxCheckListBox.rbw +65 -75
- data/samples/bigdemo/wxChoice.rbw +47 -47
- data/samples/bigdemo/wxColourDialog.rbw +31 -31
- data/samples/bigdemo/wxComboBox.rbw +77 -77
- data/samples/bigdemo/wxDialog.rbw +74 -74
- data/samples/bigdemo/wxDirDialog.rbw +29 -29
- data/samples/bigdemo/wxFileDialog.rbw +37 -37
- data/samples/bigdemo/wxFileDialog_Save.rbw +35 -35
- data/samples/bigdemo/wxFindReplaceDialog.rbw +82 -82
- data/samples/bigdemo/wxFontDialog.rbw +173 -173
- data/samples/bigdemo/wxFrame.rbw +53 -53
- data/samples/bigdemo/wxGauge.rbw +71 -71
- data/samples/bigdemo/wxGrid.rbw +66 -66
- data/samples/bigdemo/wxListBox.rbw +140 -140
- data/samples/bigdemo/wxListCtrl_virtual.rbw +112 -107
- data/samples/bigdemo/wxMDIWindows.rbw +50 -50
- data/samples/bigdemo/wxMenu.rbw +236 -236
- data/samples/bigdemo/wxMessageDialog.rbw +27 -27
- data/samples/bigdemo/wxMultipleChoiceDialog.rbw +32 -32
- data/samples/bigdemo/wxNotebook.rbw +136 -136
- data/samples/bigdemo/wxProgressDialog.rbw +43 -43
- data/samples/bigdemo/wxRadioBox.rbw +72 -72
- data/samples/bigdemo/wxRadioButton.rbw +125 -125
- data/samples/bigdemo/wxSashWindow.rbw +2 -2
- data/samples/bigdemo/wxScrolledMessageDialog.rbw +57 -57
- data/samples/bigdemo/wxScrolledWindow.rbw +199 -199
- data/samples/bigdemo/wxSingleChoiceDialog.rbw +33 -33
- data/samples/bigdemo/wxSlider.rbw +42 -42
- data/samples/bigdemo/wxSpinButton.rbw +50 -50
- data/samples/bigdemo/wxSpinCtrl.rbw +51 -51
- data/samples/bigdemo/wxSplitterWindow.rbw +63 -63
- data/samples/bigdemo/wxStaticBitmap.rbw +51 -51
- data/samples/bigdemo/wxStaticText.rbw +55 -55
- data/samples/bigdemo/wxStatusBar.rbw +126 -126
- data/samples/bigdemo/wxTextCtrl.rbw +149 -149
- data/samples/bigdemo/wxTextEntryDialog.rbw +31 -31
- data/samples/bigdemo/wxToggleButton.rbw +49 -49
- data/samples/bigdemo/wxToolBar.rbw +131 -131
- data/samples/bigdemo/wxTreeCtrl.rbw +191 -190
- data/samples/calendar/calendar.rb +256 -271
- data/samples/caret/caret.rb +282 -282
- data/samples/caret/mondrian.xpm +44 -44
- data/samples/controls/controls.rb +1136 -1136
- data/samples/controls/get_item_sample.rb +87 -87
- data/samples/controls/icons/choice.xpm +27 -27
- data/samples/controls/icons/combo.xpm +27 -27
- data/samples/controls/icons/gauge.xpm +27 -27
- data/samples/controls/icons/list.xpm +27 -27
- data/samples/controls/icons/radio.xpm +27 -27
- data/samples/controls/icons/stattext.xpm +24 -24
- data/samples/controls/icons/text.xpm +27 -27
- data/samples/controls/mondrian.xpm +44 -44
- data/samples/dialogs/dialogs.rb +797 -723
- data/samples/dialogs/tips.txt +18 -18
- data/samples/drawing/images.rb +37 -37
- data/samples/etc/activation.rb +102 -102
- data/samples/etc/choice.rb +67 -67
- data/samples/etc/miniframe.rb +79 -79
- data/samples/etc/sash.rb +130 -130
- data/samples/etc/scrollwin.rb +110 -110
- data/samples/etc/system_settings.rb +252 -252
- data/samples/etc/toolbar_sizer_additem.rb +55 -0
- data/samples/etc/wizard.rb +74 -74
- data/samples/event/update_ui_event.rb +70 -0
- data/samples/grid/gridtablebase.rb +43 -29
- data/samples/listbook/listbook.rb +174 -174
- data/samples/listbook/listbook.xrc +370 -370
- data/samples/mdi/mdi.rb +85 -77
- data/samples/minimal/minimal.rb +77 -77
- data/samples/minimal/nothing.rb +16 -16
- 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 +111 -113
- data/samples/text/unicode.rb +242 -242
- data/samples/text/utf8.txt +14 -14
- data/samples/treectrl/treectrl.rb +1166 -1174
- data/samples/xrc/samples.xrc +46 -46
- data/samples/xrc/xrc_sample.rb +76 -96
- metadata +15 -3
@@ -1,31 +1,31 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# wxRuby2 Sample Code. Copyright (c) 2004-2008 wxRuby development team
|
3
|
-
# Freely reusable code: see SAMPLES-LICENSE.TXT for details
|
4
|
-
begin
|
5
|
-
require 'rubygems'
|
6
|
-
rescue LoadError
|
7
|
-
end
|
8
|
-
require 'wx'
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
module Demo
|
13
|
-
def Demo.run(frame, nb, log)
|
14
|
-
dlg = Wx::TextEntryDialog.new(frame, "What is your favorite programming language?", "Duh??", "Ruby")
|
15
|
-
dlg.set_value("Ruby is the best!")
|
16
|
-
if dlg.show_modal() == Wx::ID_OK
|
17
|
-
log.write_text("You entered: " + dlg.get_value().to_s + "\n")
|
18
|
-
end
|
19
|
-
return nil
|
20
|
-
end
|
21
|
-
|
22
|
-
def Demo.overview
|
23
|
-
return "This dialog allows the user to input text"
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
if __FILE__ == $0
|
28
|
-
run_solo_lib = File.join( File.dirname(__FILE__), 'run.rb')
|
29
|
-
load run_solo_lib
|
30
|
-
run File.basename($0)
|
31
|
-
end
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# wxRuby2 Sample Code. Copyright (c) 2004-2008 wxRuby development team
|
3
|
+
# Freely reusable code: see SAMPLES-LICENSE.TXT for details
|
4
|
+
begin
|
5
|
+
require 'rubygems'
|
6
|
+
rescue LoadError
|
7
|
+
end
|
8
|
+
require 'wx'
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
module Demo
|
13
|
+
def Demo.run(frame, nb, log)
|
14
|
+
dlg = Wx::TextEntryDialog.new(frame, "What is your favorite programming language?", "Duh??", "Ruby")
|
15
|
+
dlg.set_value("Ruby is the best!")
|
16
|
+
if dlg.show_modal() == Wx::ID_OK
|
17
|
+
log.write_text("You entered: " + dlg.get_value().to_s + "\n")
|
18
|
+
end
|
19
|
+
return nil
|
20
|
+
end
|
21
|
+
|
22
|
+
def Demo.overview
|
23
|
+
return "This dialog allows the user to input text"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
if __FILE__ == $0
|
28
|
+
run_solo_lib = File.join( File.dirname(__FILE__), 'run.rb')
|
29
|
+
load run_solo_lib
|
30
|
+
run File.basename($0)
|
31
|
+
end
|
@@ -1,49 +1,49 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# wxRuby2 Sample Code. Copyright (c) 2004-2008 wxRuby development team
|
3
|
-
# Freely reusable code: see SAMPLES-LICENSE.TXT for details
|
4
|
-
begin
|
5
|
-
require 'rubygems'
|
6
|
-
rescue LoadError
|
7
|
-
end
|
8
|
-
require 'wx'
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
class TestPanel < Wx::Panel
|
13
|
-
def initialize(parent, log)
|
14
|
-
super(parent, -1)
|
15
|
-
@log = log
|
16
|
-
panel = Wx::Panel.new(self, -1)
|
17
|
-
buttons = Wx::BoxSizer.new(Wx::HORIZONTAL)
|
18
|
-
"These are toggle buttons".split().each do |word|
|
19
|
-
b = Wx::ToggleButton.new(panel, -1, word)
|
20
|
-
evt_togglebutton(b.get_id()) {|event| on_toggle(event)}
|
21
|
-
buttons.add(b, 0, Wx::ALL, 5)
|
22
|
-
end
|
23
|
-
panel.set_sizer(buttons)
|
24
|
-
buttons.fit(panel)
|
25
|
-
panel.move(Wx::Point.new(50,50))
|
26
|
-
end
|
27
|
-
|
28
|
-
def on_toggle(event)
|
29
|
-
@log.write_text("Button " + event.get_id().to_s() + " toggled")
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
module Demo
|
34
|
-
def Demo.run(frame,nb,log)
|
35
|
-
win = TestPanel.new(nb, log)
|
36
|
-
return win
|
37
|
-
end
|
38
|
-
|
39
|
-
def Demo.overview
|
40
|
-
"Wx::ToggleButton is a button that stays pressed when clicked by the user. In other words, it is similar to Wx::CheckBox in functionality but looks like a Wx::Button."
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
|
45
|
-
if __FILE__ == $0
|
46
|
-
run_solo_lib = File.join( File.dirname(__FILE__), 'run.rb')
|
47
|
-
load run_solo_lib
|
48
|
-
run File.basename($0)
|
49
|
-
end
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# wxRuby2 Sample Code. Copyright (c) 2004-2008 wxRuby development team
|
3
|
+
# Freely reusable code: see SAMPLES-LICENSE.TXT for details
|
4
|
+
begin
|
5
|
+
require 'rubygems'
|
6
|
+
rescue LoadError
|
7
|
+
end
|
8
|
+
require 'wx'
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
class TestPanel < Wx::Panel
|
13
|
+
def initialize(parent, log)
|
14
|
+
super(parent, -1)
|
15
|
+
@log = log
|
16
|
+
panel = Wx::Panel.new(self, -1)
|
17
|
+
buttons = Wx::BoxSizer.new(Wx::HORIZONTAL)
|
18
|
+
"These are toggle buttons".split().each do |word|
|
19
|
+
b = Wx::ToggleButton.new(panel, -1, word)
|
20
|
+
evt_togglebutton(b.get_id()) {|event| on_toggle(event)}
|
21
|
+
buttons.add(b, 0, Wx::ALL, 5)
|
22
|
+
end
|
23
|
+
panel.set_sizer(buttons)
|
24
|
+
buttons.fit(panel)
|
25
|
+
panel.move(Wx::Point.new(50,50))
|
26
|
+
end
|
27
|
+
|
28
|
+
def on_toggle(event)
|
29
|
+
@log.write_text("Button " + event.get_id().to_s() + " toggled")
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
module Demo
|
34
|
+
def Demo.run(frame,nb,log)
|
35
|
+
win = TestPanel.new(nb, log)
|
36
|
+
return win
|
37
|
+
end
|
38
|
+
|
39
|
+
def Demo.overview
|
40
|
+
"Wx::ToggleButton is a button that stays pressed when clicked by the user. In other words, it is similar to Wx::CheckBox in functionality but looks like a Wx::Button."
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
|
45
|
+
if __FILE__ == $0
|
46
|
+
run_solo_lib = File.join( File.dirname(__FILE__), 'run.rb')
|
47
|
+
load run_solo_lib
|
48
|
+
run File.basename($0)
|
49
|
+
end
|
@@ -1,131 +1,131 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# wxRuby2 Sample Code. Copyright (c) 2004-2008 wxRuby development team
|
3
|
-
# Freely reusable code: see SAMPLES-LICENSE.TXT for details
|
4
|
-
begin
|
5
|
-
require 'rubygems'
|
6
|
-
rescue LoadError
|
7
|
-
end
|
8
|
-
require 'wx'
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
class TestToolBar < Wx::Frame
|
13
|
-
# returns a Bitmap icon object
|
14
|
-
def xpm_bitmap(base_name)
|
15
|
-
|
16
|
-
xpm_file = File.join( File.dirname(__FILE__), 'icons', base_name )
|
17
|
-
Wx::Bitmap.new(xpm_file, Wx::BITMAP_TYPE_XPM)
|
18
|
-
end
|
19
|
-
|
20
|
-
def initialize(parent, log)
|
21
|
-
super(parent, -1, "Test ToolBar", Wx::DEFAULT_POSITION, Wx::Size.new(500,300))
|
22
|
-
@log = log
|
23
|
-
@timer = nil
|
24
|
-
evt_close {|event| on_close_window(event)}
|
25
|
-
|
26
|
-
Wx::Window.new(self, -1).set_background_colour(Wx::WHITE)
|
27
|
-
|
28
|
-
tb = create_tool_bar(Wx::TB_HORIZONTAL | Wx::NO_BORDER | Wx::TB_FLAT | Wx::TB_TEXT)
|
29
|
-
|
30
|
-
create_status_bar()
|
31
|
-
tb.add_tool(10, "New", xpm_bitmap('new.xpm'), "Long help for New")
|
32
|
-
evt_tool(10) {|event| on_tool_click(event)}
|
33
|
-
evt_tool_rclicked(10) {|event| on_tool_rclick(event)}
|
34
|
-
|
35
|
-
tb.add_tool(20, "Open", xpm_bitmap('open.xpm'), "Long help for Open")
|
36
|
-
evt_tool(20) {|event| on_tool_click(event)}
|
37
|
-
evt_tool_rclicked(20) {|event| on_tool_rclick(event)}
|
38
|
-
|
39
|
-
tb.add_separator()
|
40
|
-
|
41
|
-
tb.add_tool(30, "Copy", xpm_bitmap('copy.xpm'), "Long help for Copy")
|
42
|
-
evt_tool(30) {|event| on_tool_click(event)}
|
43
|
-
evt_tool_rclicked(30) {|event| on_tool_rclick(event)}
|
44
|
-
|
45
|
-
tb.add_tool(40, "Paste", xpm_bitmap('paste.xpm'), "Long help for Paste")
|
46
|
-
evt_tool(40) {|event| on_tool_click(event)}
|
47
|
-
evt_tool_rclicked(40) {|event| on_tool_rclick(event)}
|
48
|
-
|
49
|
-
tb.add_separator()
|
50
|
-
|
51
|
-
tb.add_check_tool(50, "", xpm_bitmap('tog1.xpm'),
|
52
|
-
Wx::NULL_BITMAP, "Toggle this")
|
53
|
-
evt_tool(50) {|event| on_tool_click(event)}
|
54
|
-
|
55
|
-
evt_tool_enter(-1) {|event| on_tool_enter(event)}
|
56
|
-
evt_tool_rclicked(-1) {|event| on_tool_rclick(event)}
|
57
|
-
evt_timer(5000) {|event| on_clear_sb(event)}
|
58
|
-
|
59
|
-
tb.add_separator()
|
60
|
-
cbID = 5000
|
61
|
-
choices = ["", "This", "is a", "wxComboBox"]
|
62
|
-
|
63
|
-
tb.add_control(Wx::ComboBox.new(tb, cbID, "", Wx::DEFAULT_POSITION, Wx::Size.new(150,-1), choices,
|
64
|
-
Wx::CB_DROPDOWN))
|
65
|
-
evt_combobox(cbID) {|event| on_combo(event)}
|
66
|
-
tb.add_control(Wx::TextCtrl.new(tb, -1, "ToolBar controls!!", Wx::DEFAULT_POSITION, Wx::Size.new(150,-1)))
|
67
|
-
|
68
|
-
tb.realize()
|
69
|
-
end
|
70
|
-
|
71
|
-
def on_tool_click(event)
|
72
|
-
@log.write_text("tool " + event.get_id().to_s() + " clicked")
|
73
|
-
tb = get_tool_bar()
|
74
|
-
tb.enable_tool(10, tb.get_tool_enabled(10) ? false : true)
|
75
|
-
end
|
76
|
-
|
77
|
-
def on_tool_rclick(event)
|
78
|
-
@log.write_text("tool " + event.get_id().to_s() + " right-clicked")
|
79
|
-
end
|
80
|
-
|
81
|
-
def on_combo(event)
|
82
|
-
@log.write_text("combobox item selected " + event.get_string())
|
83
|
-
end
|
84
|
-
|
85
|
-
def on_tool_enter(event)
|
86
|
-
@log.write_text("on_tool_enter: " + event.get_id().to_s + ", " + event.get_int().to_s())
|
87
|
-
if @timer == nil
|
88
|
-
@timer = Wx::Timer.new(self, 5000)
|
89
|
-
end
|
90
|
-
if @timer != nil
|
91
|
-
@timer.stop()
|
92
|
-
end
|
93
|
-
@timer.start(2000)
|
94
|
-
@timer.stop()
|
95
|
-
@timer.start(2000)
|
96
|
-
event.skip()
|
97
|
-
end
|
98
|
-
|
99
|
-
def on_clear_sb(event) # called for the timer event handler
|
100
|
-
set_status_text("")
|
101
|
-
@timer.stop()
|
102
|
-
@timer = nil
|
103
|
-
end
|
104
|
-
|
105
|
-
def on_close_window(event)
|
106
|
-
if @timer != nil
|
107
|
-
@timer.stop()
|
108
|
-
@timer = nil
|
109
|
-
end
|
110
|
-
destroy()
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
module Demo
|
115
|
-
def Demo.run(frame,nb,log)
|
116
|
-
win = TestToolBar.new(frame, log)
|
117
|
-
frame.otherWin = win
|
118
|
-
win.show()
|
119
|
-
end
|
120
|
-
|
121
|
-
def Demo.overview
|
122
|
-
"A toolbar is that familiar little rectangular strip below the menubar that hosts various 'buttons', which are usually shortcuts to menu commands."
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
|
-
|
127
|
-
if __FILE__ == $0
|
128
|
-
run_solo_lib = File.join( File.dirname(__FILE__), 'run.rb')
|
129
|
-
load run_solo_lib
|
130
|
-
run File.basename($0)
|
131
|
-
end
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# wxRuby2 Sample Code. Copyright (c) 2004-2008 wxRuby development team
|
3
|
+
# Freely reusable code: see SAMPLES-LICENSE.TXT for details
|
4
|
+
begin
|
5
|
+
require 'rubygems'
|
6
|
+
rescue LoadError
|
7
|
+
end
|
8
|
+
require 'wx'
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
class TestToolBar < Wx::Frame
|
13
|
+
# returns a Bitmap icon object
|
14
|
+
def xpm_bitmap(base_name)
|
15
|
+
|
16
|
+
xpm_file = File.join( File.dirname(__FILE__), 'icons', base_name )
|
17
|
+
Wx::Bitmap.new(xpm_file, Wx::BITMAP_TYPE_XPM)
|
18
|
+
end
|
19
|
+
|
20
|
+
def initialize(parent, log)
|
21
|
+
super(parent, -1, "Test ToolBar", Wx::DEFAULT_POSITION, Wx::Size.new(500,300))
|
22
|
+
@log = log
|
23
|
+
@timer = nil
|
24
|
+
evt_close {|event| on_close_window(event)}
|
25
|
+
|
26
|
+
Wx::Window.new(self, -1).set_background_colour(Wx::WHITE)
|
27
|
+
|
28
|
+
tb = create_tool_bar(Wx::TB_HORIZONTAL | Wx::NO_BORDER | Wx::TB_FLAT | Wx::TB_TEXT)
|
29
|
+
|
30
|
+
create_status_bar()
|
31
|
+
tb.add_tool(10, "New", xpm_bitmap('new.xpm'), "Long help for New")
|
32
|
+
evt_tool(10) {|event| on_tool_click(event)}
|
33
|
+
evt_tool_rclicked(10) {|event| on_tool_rclick(event)}
|
34
|
+
|
35
|
+
tb.add_tool(20, "Open", xpm_bitmap('open.xpm'), "Long help for Open")
|
36
|
+
evt_tool(20) {|event| on_tool_click(event)}
|
37
|
+
evt_tool_rclicked(20) {|event| on_tool_rclick(event)}
|
38
|
+
|
39
|
+
tb.add_separator()
|
40
|
+
|
41
|
+
tb.add_tool(30, "Copy", xpm_bitmap('copy.xpm'), "Long help for Copy")
|
42
|
+
evt_tool(30) {|event| on_tool_click(event)}
|
43
|
+
evt_tool_rclicked(30) {|event| on_tool_rclick(event)}
|
44
|
+
|
45
|
+
tb.add_tool(40, "Paste", xpm_bitmap('paste.xpm'), "Long help for Paste")
|
46
|
+
evt_tool(40) {|event| on_tool_click(event)}
|
47
|
+
evt_tool_rclicked(40) {|event| on_tool_rclick(event)}
|
48
|
+
|
49
|
+
tb.add_separator()
|
50
|
+
|
51
|
+
tb.add_check_tool(50, "", xpm_bitmap('tog1.xpm'),
|
52
|
+
Wx::NULL_BITMAP, "Toggle this")
|
53
|
+
evt_tool(50) {|event| on_tool_click(event)}
|
54
|
+
|
55
|
+
evt_tool_enter(-1) {|event| on_tool_enter(event)}
|
56
|
+
evt_tool_rclicked(-1) {|event| on_tool_rclick(event)}
|
57
|
+
evt_timer(5000) {|event| on_clear_sb(event)}
|
58
|
+
|
59
|
+
tb.add_separator()
|
60
|
+
cbID = 5000
|
61
|
+
choices = ["", "This", "is a", "wxComboBox"]
|
62
|
+
|
63
|
+
tb.add_control(Wx::ComboBox.new(tb, cbID, "", Wx::DEFAULT_POSITION, Wx::Size.new(150,-1), choices,
|
64
|
+
Wx::CB_DROPDOWN))
|
65
|
+
evt_combobox(cbID) {|event| on_combo(event)}
|
66
|
+
tb.add_control(Wx::TextCtrl.new(tb, -1, "ToolBar controls!!", Wx::DEFAULT_POSITION, Wx::Size.new(150,-1)))
|
67
|
+
|
68
|
+
tb.realize()
|
69
|
+
end
|
70
|
+
|
71
|
+
def on_tool_click(event)
|
72
|
+
@log.write_text("tool " + event.get_id().to_s() + " clicked")
|
73
|
+
tb = get_tool_bar()
|
74
|
+
tb.enable_tool(10, tb.get_tool_enabled(10) ? false : true)
|
75
|
+
end
|
76
|
+
|
77
|
+
def on_tool_rclick(event)
|
78
|
+
@log.write_text("tool " + event.get_id().to_s() + " right-clicked")
|
79
|
+
end
|
80
|
+
|
81
|
+
def on_combo(event)
|
82
|
+
@log.write_text("combobox item selected " + event.get_string())
|
83
|
+
end
|
84
|
+
|
85
|
+
def on_tool_enter(event)
|
86
|
+
@log.write_text("on_tool_enter: " + event.get_id().to_s + ", " + event.get_int().to_s())
|
87
|
+
if @timer == nil
|
88
|
+
@timer = Wx::Timer.new(self, 5000)
|
89
|
+
end
|
90
|
+
if @timer != nil
|
91
|
+
@timer.stop()
|
92
|
+
end
|
93
|
+
@timer.start(2000)
|
94
|
+
@timer.stop()
|
95
|
+
@timer.start(2000)
|
96
|
+
event.skip()
|
97
|
+
end
|
98
|
+
|
99
|
+
def on_clear_sb(event) # called for the timer event handler
|
100
|
+
set_status_text("")
|
101
|
+
@timer.stop()
|
102
|
+
@timer = nil
|
103
|
+
end
|
104
|
+
|
105
|
+
def on_close_window(event)
|
106
|
+
if @timer != nil
|
107
|
+
@timer.stop()
|
108
|
+
@timer = nil
|
109
|
+
end
|
110
|
+
destroy()
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
module Demo
|
115
|
+
def Demo.run(frame,nb,log)
|
116
|
+
win = TestToolBar.new(frame, log)
|
117
|
+
frame.otherWin = win
|
118
|
+
win.show()
|
119
|
+
end
|
120
|
+
|
121
|
+
def Demo.overview
|
122
|
+
"A toolbar is that familiar little rectangular strip below the menubar that hosts various 'buttons', which are usually shortcuts to menu commands."
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
|
127
|
+
if __FILE__ == $0
|
128
|
+
run_solo_lib = File.join( File.dirname(__FILE__), 'run.rb')
|
129
|
+
load run_solo_lib
|
130
|
+
run File.basename($0)
|
131
|
+
end
|
@@ -1,190 +1,191 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
# wxRuby2 Sample Code. Copyright (c) 2004-2008 wxRuby development team
|
3
|
-
# Freely reusable code: see SAMPLES-LICENSE.TXT for details
|
4
|
-
begin
|
5
|
-
require 'rubygems'
|
6
|
-
rescue LoadError
|
7
|
-
end
|
8
|
-
require 'wx'
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
class MyTreeCtrl < Wx::TreeCtrl
|
13
|
-
def initialize(parent, id, pos, size, style, log)
|
14
|
-
super(parent,id,pos,size,style)
|
15
|
-
@log = log
|
16
|
-
|
17
|
-
evt_left_dclick {|event| on_left_dclick(event)}
|
18
|
-
evt_right_down {|event| on_right_click(event)}
|
19
|
-
evt_right_up {|event| on_right_up(event)}
|
20
|
-
end
|
21
|
-
|
22
|
-
def on_left_dclick(event)
|
23
|
-
pt = Wx::Point.new(event.get_x(), event.get_y())
|
24
|
-
|
25
|
-
end
|
26
|
-
|
27
|
-
def on_right_click(event)
|
28
|
-
pt = Wx::Point.new(event.get_x(), event.get_y())
|
29
|
-
id = hit_test(pt)
|
30
|
-
if id
|
31
|
-
@log.write_text("on_right_click: ")# + @tree.get_item_text(id))
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
def on_right_up(event)
|
36
|
-
pt = Wx::Point.new(event.get_x(), event.get_y())
|
37
|
-
id = hit_test(pt)
|
38
|
-
if id
|
39
|
-
@log.write_text("on_right_up: ")#+ @tree.get_item_text(id) + " (manually starting label edit)")
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
def on_compare_items(item1, item2)
|
44
|
-
t1 = get_item_text(item1)
|
45
|
-
t2 = get_item_text(item2)
|
46
|
-
@log.write_text('compare: ' + t1 + ' <> ' + t2)
|
47
|
-
if t1 < t2 then return -1 end
|
48
|
-
if t1 == t2 then return 0 end
|
49
|
-
return 1
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
class TestTreeCtrlPanel < Wx::Panel
|
54
|
-
def initialize(parent, log)
|
55
|
-
# Use the WANTS_CHARS style so the panel doesn't eat the Return key
|
56
|
-
super(parent, -1, Wx::DEFAULT_POSITION, Wx::DEFAULT_SIZE, Wx::WANTS_CHARS)
|
57
|
-
evt_size {|event| on_size(event)}
|
58
|
-
|
59
|
-
@log = log
|
60
|
-
tID = 5000
|
61
|
-
|
62
|
-
@tree = MyTreeCtrl.new(self, tID, Wx::DEFAULT_POSITION, Wx::DEFAULT_SIZE, Wx::TR_HAS_BUTTONS | Wx::TR_EDIT_LABELS, @log)
|
63
|
-
|
64
|
-
isz = Wx::Size.new(16,16)
|
65
|
-
il = Wx::ImageList.new(16,16)
|
66
|
-
bm = Wx::Bitmap.new
|
67
|
-
bm.copy_from_icon(Wx::ArtProvider::get_icon(Wx::ART_FOLDER, Wx::ART_OTHER, isz))
|
68
|
-
fldridx = il.add(bm)
|
69
|
-
bm.copy_from_icon(Wx::ArtProvider::get_icon(Wx::ART_FILE_OPEN, Wx::ART_OTHER, isz))
|
70
|
-
fldropenidx = il.add(bm)
|
71
|
-
bm.copy_from_icon(Wx::ArtProvider::get_icon(Wx::ART_FILE_OPEN, Wx::ART_OTHER, isz))
|
72
|
-
fileidx = il.add(bm)
|
73
|
-
bmp_file = File.join(File.dirname(__FILE__), 'icons', 'wxwin16x16.xpm')
|
74
|
-
smileidx = il.add(Wx::Bitmap.new(bmp_file))
|
75
|
-
|
76
|
-
@tree.set_image_list(il)
|
77
|
-
@il = il
|
78
|
-
|
79
|
-
@root = @tree.add_root("The Root Item")
|
80
|
-
@tree.set_item_image(@root, fldridx, Wx::TREE_ITEM_ICON_NORMAL)
|
81
|
-
@tree.set_item_image(@root, fldropenidx, Wx::TREE_ITEM_ICON_EXPANDED)
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
@tree.set_item_image(child,
|
86
|
-
|
87
|
-
0.upto(4) do |y|
|
88
|
-
last = @tree.append_item(child, "item " + x.to_s() + "-" +
|
89
|
-
@tree.set_item_image(last, fldridx, Wx::TREE_ITEM_ICON_NORMAL)
|
90
|
-
@tree.set_item_image(last, fldropenidx, Wx::TREE_ITEM_ICON_EXPANDED)
|
91
|
-
0.upto(4) do |z|
|
92
|
-
item = @tree.append_item(last, "item " + x.to_s() + "-" +
|
93
|
-
@tree.set_item_image(item, fileidx, Wx::TREE_ITEM_ICON_NORMAL)
|
94
|
-
@tree.set_item_image(item, smileidx, Wx::TREE_ITEM_ICON_SELECTED)
|
95
|
-
end
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
child
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
x
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
end
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
end
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# wxRuby2 Sample Code. Copyright (c) 2004-2008 wxRuby development team
|
3
|
+
# Freely reusable code: see SAMPLES-LICENSE.TXT for details
|
4
|
+
begin
|
5
|
+
require 'rubygems'
|
6
|
+
rescue LoadError
|
7
|
+
end
|
8
|
+
require 'wx'
|
9
|
+
|
10
|
+
|
11
|
+
|
12
|
+
class MyTreeCtrl < Wx::TreeCtrl
|
13
|
+
def initialize(parent, id, pos, size, style, log)
|
14
|
+
super(parent,id,pos,size,style)
|
15
|
+
@log = log
|
16
|
+
|
17
|
+
evt_left_dclick {|event| on_left_dclick(event)}
|
18
|
+
evt_right_down {|event| on_right_click(event)}
|
19
|
+
evt_right_up {|event| on_right_up(event)}
|
20
|
+
end
|
21
|
+
|
22
|
+
def on_left_dclick(event)
|
23
|
+
pt = Wx::Point.new(event.get_x(), event.get_y())
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
def on_right_click(event)
|
28
|
+
pt = Wx::Point.new(event.get_x(), event.get_y())
|
29
|
+
id = hit_test(pt)
|
30
|
+
if id
|
31
|
+
@log.write_text("on_right_click: ")# + @tree.get_item_text(id))
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def on_right_up(event)
|
36
|
+
pt = Wx::Point.new(event.get_x(), event.get_y())
|
37
|
+
id = hit_test(pt)
|
38
|
+
if id
|
39
|
+
@log.write_text("on_right_up: ")#+ @tree.get_item_text(id) + " (manually starting label edit)")
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def on_compare_items(item1, item2)
|
44
|
+
t1 = get_item_text(item1)
|
45
|
+
t2 = get_item_text(item2)
|
46
|
+
@log.write_text('compare: ' + t1 + ' <> ' + t2)
|
47
|
+
if t1 < t2 then return -1 end
|
48
|
+
if t1 == t2 then return 0 end
|
49
|
+
return 1
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
class TestTreeCtrlPanel < Wx::Panel
|
54
|
+
def initialize(parent, log)
|
55
|
+
# Use the WANTS_CHARS style so the panel doesn't eat the Return key
|
56
|
+
super(parent, -1, Wx::DEFAULT_POSITION, Wx::DEFAULT_SIZE, Wx::WANTS_CHARS)
|
57
|
+
evt_size {|event| on_size(event)}
|
58
|
+
|
59
|
+
@log = log
|
60
|
+
tID = 5000
|
61
|
+
|
62
|
+
@tree = MyTreeCtrl.new(self, tID, Wx::DEFAULT_POSITION, Wx::DEFAULT_SIZE, Wx::TR_HAS_BUTTONS | Wx::TR_EDIT_LABELS, @log)
|
63
|
+
|
64
|
+
isz = Wx::Size.new(16,16)
|
65
|
+
il = Wx::ImageList.new(16,16)
|
66
|
+
bm = Wx::Bitmap.new
|
67
|
+
bm.copy_from_icon(Wx::ArtProvider::get_icon(Wx::ART_FOLDER, Wx::ART_OTHER, isz))
|
68
|
+
fldridx = il.add(bm)
|
69
|
+
bm.copy_from_icon(Wx::ArtProvider::get_icon(Wx::ART_FILE_OPEN, Wx::ART_OTHER, isz))
|
70
|
+
fldropenidx = il.add(bm)
|
71
|
+
bm.copy_from_icon(Wx::ArtProvider::get_icon(Wx::ART_FILE_OPEN, Wx::ART_OTHER, isz))
|
72
|
+
fileidx = il.add(bm)
|
73
|
+
bmp_file = File.join(File.dirname(__FILE__), 'icons', 'wxwin16x16.xpm')
|
74
|
+
smileidx = il.add(Wx::Bitmap.new(bmp_file))
|
75
|
+
|
76
|
+
@tree.set_image_list(il)
|
77
|
+
@il = il
|
78
|
+
|
79
|
+
@root = @tree.add_root("The Root Item")
|
80
|
+
@tree.set_item_image(@root, fldridx, Wx::TREE_ITEM_ICON_NORMAL)
|
81
|
+
@tree.set_item_image(@root, fldropenidx, Wx::TREE_ITEM_ICON_EXPANDED)
|
82
|
+
0.upto(15) do |x|
|
83
|
+
child = @tree.append_item(@root, "Item " + x.to_s())
|
84
|
+
@tree.set_item_image(child, fldridx, Wx::TREE_ITEM_ICON_NORMAL)
|
85
|
+
@tree.set_item_image(child, fldropenidx, Wx::TREE_ITEM_ICON_EXPANDED)
|
86
|
+
character = "a"
|
87
|
+
0.upto(4) do |y|
|
88
|
+
last = @tree.append_item(child, "item " + x.to_s() + "-" + character)
|
89
|
+
@tree.set_item_image(last, fldridx, Wx::TREE_ITEM_ICON_NORMAL)
|
90
|
+
@tree.set_item_image(last, fldropenidx, Wx::TREE_ITEM_ICON_EXPANDED)
|
91
|
+
0.upto(4) do |z|
|
92
|
+
item = @tree.append_item(last, "item " + x.to_s() + "-" + character + "-" + z.to_s())
|
93
|
+
@tree.set_item_image(item, fileidx, Wx::TREE_ITEM_ICON_NORMAL)
|
94
|
+
@tree.set_item_image(item, smileidx, Wx::TREE_ITEM_ICON_SELECTED)
|
95
|
+
end
|
96
|
+
character.succ!
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
@tree.expand(@root)
|
101
|
+
evt_tree_item_expanded(tID) {|event| on_item_expanded(event)}
|
102
|
+
evt_tree_item_collapsed(tID) {|event| on_item_collapsed(event)}
|
103
|
+
evt_tree_sel_changed(tID) {|event| on_sel_changed(event)}
|
104
|
+
evt_tree_begin_label_edit(tID) {|event| on_begin_edit(event)}
|
105
|
+
evt_tree_end_label_edit(tID) {|event| on_end_edit(event)}
|
106
|
+
evt_tree_item_activated(tID) {|event| on_activate(event)}
|
107
|
+
|
108
|
+
|
109
|
+
end
|
110
|
+
|
111
|
+
|
112
|
+
def on_begin_edit(event)
|
113
|
+
@log.write_text("on_begin_edit")
|
114
|
+
# show how to prevent edit
|
115
|
+
if @tree.get_item_text(event.get_item()) == "The Root Item"
|
116
|
+
@log.write_text("You can't edit this one...")
|
117
|
+
|
118
|
+
# Let's just see what's visible of its children
|
119
|
+
cookie = 0
|
120
|
+
root = event.get_item()
|
121
|
+
child, cookie = @tree.get_first_child(root)
|
122
|
+
while child != nil
|
123
|
+
@log.write_text("Child [" + @tree.get_item_text(child) + "] visible = " + @tree.is_visible(child).to_s())
|
124
|
+
child,cookie = @tree.get_next_child(root, cookie)
|
125
|
+
end
|
126
|
+
event.veto()
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
def on_end_edit(event)
|
131
|
+
@log.write_text("on_end_edit")
|
132
|
+
#show how to reject edit, we'll not allow any digits
|
133
|
+
nums = ("0".."9").to_a()
|
134
|
+
x = event.get_label()
|
135
|
+
x.each_byte do |byte|
|
136
|
+
if nums.include?(byte.chr())
|
137
|
+
@log.write_text("You can't enter digits...")
|
138
|
+
event.veto()
|
139
|
+
return
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
def on_size(event)
|
145
|
+
size = get_client_size()
|
146
|
+
@tree.set_dimensions(0,0,size.x, size.y)
|
147
|
+
end
|
148
|
+
|
149
|
+
def on_item_expanded(event)
|
150
|
+
item = event.get_item()
|
151
|
+
@log.write_text("on_item_expanded: " + @tree.get_item_text(item))
|
152
|
+
end
|
153
|
+
|
154
|
+
def on_item_collapsed(event)
|
155
|
+
item = event.get_item()
|
156
|
+
@log.write_text("on_item_collapsed: " + @tree.get_item_text(item))
|
157
|
+
end
|
158
|
+
|
159
|
+
def on_sel_changed(event)
|
160
|
+
@item = event.get_item()
|
161
|
+
if @item.nonzero?
|
162
|
+
@log.write_text("on_sel_changed: " + @tree.get_item_text(@item))
|
163
|
+
# if Wx::PLATFORM == "WXMSW"
|
164
|
+
#@log.write_text("BoundingRect: " + @tree.get_bounding_rect(@item))
|
165
|
+
#end
|
166
|
+
end
|
167
|
+
event.skip()
|
168
|
+
end
|
169
|
+
|
170
|
+
def on_activate(event)
|
171
|
+
@log.write_text("on_activate: " + @tree.get_item_text(@item))
|
172
|
+
end
|
173
|
+
end
|
174
|
+
|
175
|
+
module Demo
|
176
|
+
def Demo.run(frame, nb, log)
|
177
|
+
win = TestTreeCtrlPanel.new(nb, log)
|
178
|
+
return win
|
179
|
+
end
|
180
|
+
|
181
|
+
def Demo.overview
|
182
|
+
return ""
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
|
187
|
+
if __FILE__ == $0
|
188
|
+
run_solo_lib = File.join( File.dirname(__FILE__), 'run.rb')
|
189
|
+
load run_solo_lib
|
190
|
+
run File.basename($0)
|
191
|
+
end
|