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,107 +1,112 @@
|
|
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
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
@currentItem
|
54
|
-
|
55
|
-
end
|
56
|
-
|
57
|
-
def
|
58
|
-
@
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
#
|
67
|
-
#
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
def Demo.
|
98
|
-
|
99
|
-
|
100
|
-
end
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
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
|
+
# A virtual ListCtrl loads its items as needed from a virtual store. So
|
12
|
+
# it's useful for linking to existing data sources, or for displaying
|
13
|
+
# very large lists. It's subclassed in ruby, and the item_count is set;
|
14
|
+
# the get_item_text methods should return how to display a given line.
|
15
|
+
class TestVirtualList < Wx::ListCtrl
|
16
|
+
def initialize(parent, log)
|
17
|
+
super parent, :style => Wx::LC_REPORT|Wx::LC_VIRTUAL|
|
18
|
+
Wx::LC_HRULES| Wx::LC_VRULES
|
19
|
+
@log = log
|
20
|
+
|
21
|
+
@il = Wx::ImageList.new(16,16)
|
22
|
+
bmp_file = File.join(File.dirname(__FILE__), "icons/wxwin16x16.xpm")
|
23
|
+
|
24
|
+
@idx1 = @il.add(Wx::Bitmap.new(bmp_file))
|
25
|
+
set_image_list(@il, Wx::IMAGE_LIST_SMALL)
|
26
|
+
|
27
|
+
insert_column(0,"First")
|
28
|
+
insert_column(1,"Second")
|
29
|
+
insert_column(2,"Third")
|
30
|
+
set_column_width(0,175)
|
31
|
+
set_column_width(1,175)
|
32
|
+
set_column_width(2,175)
|
33
|
+
|
34
|
+
# Important - call this
|
35
|
+
self.item_count = 10_000
|
36
|
+
|
37
|
+
@attr1 = Wx::ListItemAttr.new()
|
38
|
+
@attr1.set_background_colour(Wx::Colour.new("YELLOW"))
|
39
|
+
|
40
|
+
@attr2 = Wx::ListItemAttr.new()
|
41
|
+
@attr2.set_background_colour(Wx::Colour.new("LIGHT BLUE"))
|
42
|
+
|
43
|
+
evt_list_item_selected(get_id()) {|event| on_item_selected(event)}
|
44
|
+
evt_list_item_activated(get_id()) {|event| on_item_activated(event)}
|
45
|
+
evt_list_item_deselected(get_id()) {|event| on_item_deselected(event)}
|
46
|
+
end
|
47
|
+
|
48
|
+
def on_item_selected(event)
|
49
|
+
@currentItem = event.get_index()
|
50
|
+
@item = event.get_item()
|
51
|
+
get_column(1,@item)
|
52
|
+
|
53
|
+
@log.write_text('on_item_selected: "%s", "%s", "%s", "%s"' % [@currentItem, get_item_text(@currentItem),
|
54
|
+
@item.get_text(), get_column(2,@item) ? @item.get_text() : nil])
|
55
|
+
end
|
56
|
+
|
57
|
+
def on_item_activated(event)
|
58
|
+
@currentItem = event.get_index()
|
59
|
+
@log.write_text("on_item_activated: %s\nTopItem: %s" % [get_item_text(@currentItem), get_top_item()])
|
60
|
+
end
|
61
|
+
|
62
|
+
def on_item_deselected(event)
|
63
|
+
@log.write_text("on_item_deselected: %s" % event.get_index())
|
64
|
+
end
|
65
|
+
|
66
|
+
# These three following methods are callbacks for implementing the
|
67
|
+
# "virtualness" of the list; they *must* be defined by any ListCtrl
|
68
|
+
# object with the style LC_VIRTUAL.
|
69
|
+
|
70
|
+
# Normally you would determine the text, attributes and/or image
|
71
|
+
# based on values from some external data source, but for this demo
|
72
|
+
# we'll just calculate them based on order.
|
73
|
+
def on_get_item_text(item, col)
|
74
|
+
return "Item %d, column %d" % [item,col]
|
75
|
+
end
|
76
|
+
|
77
|
+
def on_get_item_column_image(item, col)
|
78
|
+
if item % 4 == 0
|
79
|
+
return @idx1
|
80
|
+
else
|
81
|
+
return -1
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def on_get_item_attr(item)
|
86
|
+
if item % 3 == 1
|
87
|
+
return @attr1
|
88
|
+
elsif item % 3 == 2
|
89
|
+
return @attr2
|
90
|
+
else
|
91
|
+
return nil
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
module Demo
|
97
|
+
def Demo.run(frame, nb, log)
|
98
|
+
win = TestVirtualList.new(nb,log)
|
99
|
+
return win
|
100
|
+
end
|
101
|
+
|
102
|
+
def Demo.overview
|
103
|
+
return "A special case of report view quite different from the other modes of the list control is a virtual control in which the items data (including text, images and attributes) is managed by the main program and is requested by the control itself only when needed which allows to have controls with millions of items without consuming much memory. To use virtual list control you must use SetItemCount first and overload at least OnGetItemText (and optionally OnGetItemImage and OnGetItemAttr) to return the information about the items when the control requests it."
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
|
108
|
+
if __FILE__ == $0
|
109
|
+
run_solo_lib = File.join( File.dirname(__FILE__), 'run.rb')
|
110
|
+
load run_solo_lib
|
111
|
+
run File.basename($0)
|
112
|
+
end
|
@@ -1,50 +1,50 @@
|
|
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
|
-
@log = log
|
15
|
-
super(parent, -1)
|
16
|
-
|
17
|
-
b1 = Wx::Button.new(self, -1, "MDI demo")
|
18
|
-
evt_button(b1.get_id()) {|event| show_mdi_demo(event)}
|
19
|
-
|
20
|
-
box = Wx::BoxSizer.new(Wx::VERTICAL)
|
21
|
-
box.add(20,30)
|
22
|
-
box.add(b1, 0, Wx::ALIGN_CENTER | Wx::ALL, 15)
|
23
|
-
set_sizer(box)
|
24
|
-
end
|
25
|
-
|
26
|
-
def show_mdi_demo(event)
|
27
|
-
mdi_demo_file = File.join( File.dirname(__FILE__), "MDIDemo.rbw")
|
28
|
-
load mdi_demo_file
|
29
|
-
frame = Demo::MyParentFrame.new()
|
30
|
-
frame.show()
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
module Demo
|
35
|
-
def Demo.run(frame,nb,log)
|
36
|
-
win = TestPanel.new(nb, log)
|
37
|
-
return win
|
38
|
-
end
|
39
|
-
|
40
|
-
def Demo.overview
|
41
|
-
"An MDI (Multiple Document Interface) parent frame is a window which can contain MDI child frames in its own 'desktop'. It is a convenient way to avoid window clutter, and is used in many popular Windows applications, such as Microsoft Word(TM)."
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
|
46
|
-
if __FILE__ == $0
|
47
|
-
run_solo_lib = File.join( File.dirname(__FILE__), 'run.rb')
|
48
|
-
load run_solo_lib
|
49
|
-
run File.basename($0)
|
50
|
-
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
|
+
@log = log
|
15
|
+
super(parent, -1)
|
16
|
+
|
17
|
+
b1 = Wx::Button.new(self, -1, "MDI demo")
|
18
|
+
evt_button(b1.get_id()) {|event| show_mdi_demo(event)}
|
19
|
+
|
20
|
+
box = Wx::BoxSizer.new(Wx::VERTICAL)
|
21
|
+
box.add(20,30)
|
22
|
+
box.add(b1, 0, Wx::ALIGN_CENTER | Wx::ALL, 15)
|
23
|
+
set_sizer(box)
|
24
|
+
end
|
25
|
+
|
26
|
+
def show_mdi_demo(event)
|
27
|
+
mdi_demo_file = File.join( File.dirname(__FILE__), "MDIDemo.rbw")
|
28
|
+
load mdi_demo_file
|
29
|
+
frame = Demo::MyParentFrame.new()
|
30
|
+
frame.show()
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
module Demo
|
35
|
+
def Demo.run(frame,nb,log)
|
36
|
+
win = TestPanel.new(nb, log)
|
37
|
+
return win
|
38
|
+
end
|
39
|
+
|
40
|
+
def Demo.overview
|
41
|
+
"An MDI (Multiple Document Interface) parent frame is a window which can contain MDI child frames in its own 'desktop'. It is a convenient way to avoid window clutter, and is used in many popular Windows applications, such as Microsoft Word(TM)."
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
if __FILE__ == $0
|
47
|
+
run_solo_lib = File.join( File.dirname(__FILE__), 'run.rb')
|
48
|
+
load run_solo_lib
|
49
|
+
run File.basename($0)
|
50
|
+
end
|
data/samples/bigdemo/wxMenu.rbw
CHANGED
@@ -1,236 +1,236 @@
|
|
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 MyFrame < Wx::Frame
|
13
|
-
def initialize(parent, id, log)
|
14
|
-
super(parent, id, "Playing with menus", Wx::DEFAULT_POSITION, Wx::Size.new(400,200))
|
15
|
-
@log = log
|
16
|
-
center_on_screen(Wx::BOTH)
|
17
|
-
|
18
|
-
create_status_bar()
|
19
|
-
set_status_text("This is the statusbar")
|
20
|
-
|
21
|
-
text = "A bunch of bogus menus have been created for this frame. You can play around with them to see how they behave and then check the source for this sample to see how to implement them."
|
22
|
-
tc = Wx::TextCtrl.new(self, -1, text, Wx::DEFAULT_POSITION,
|
23
|
-
Wx::DEFAULT_SIZE, Wx::TE_READONLY | Wx::TE_MULTILINE)
|
24
|
-
|
25
|
-
# Prepare the menu bar
|
26
|
-
menuBar = Wx::MenuBar.new()
|
27
|
-
|
28
|
-
# 1st menu from the left
|
29
|
-
menu1 = Wx::Menu.new()
|
30
|
-
menu1.append(101, "&Mercury", "This the text in the Statusbar")
|
31
|
-
menu1.append(102, "&Venus", "")
|
32
|
-
menu1.append(103, "&Earth", "You may select Earth too")
|
33
|
-
menu1.append_separator()
|
34
|
-
menu1.append(104, "&Close", "Close this frame")
|
35
|
-
# Add menu to the menu bar
|
36
|
-
menuBar.append(menu1, "&Planets")
|
37
|
-
|
38
|
-
# 2nd menu from left
|
39
|
-
menu2 = Wx::Menu.new()
|
40
|
-
menu2.append(201, "Hydrogen")
|
41
|
-
menu2.append(202, "Helium")
|
42
|
-
# a submenu in the 2nd menu
|
43
|
-
submenu = Wx::Menu.new()
|
44
|
-
submenu.append(2031,"Lanthanium")
|
45
|
-
submenu.append(2032,"Cerium")
|
46
|
-
submenu.append(2033,"Praseodymium")
|
47
|
-
item = Wx::MenuItem.new(menu2, 203, "Lanthanides", "", Wx::ITEM_NORMAL, submenu)
|
48
|
-
menu2.append_item(item)
|
49
|
-
# append 2nd menu
|
50
|
-
menuBar.append(menu2, "&Elements")
|
51
|
-
|
52
|
-
menu3 = Wx::Menu.new()
|
53
|
-
menu3.append_item(Wx::MenuItem.new(menu3, 301, "IRB", "a Python shell using tcl/tk as GUI", Wx::ITEM_RADIO))
|
54
|
-
menu3.append_item(Wx::MenuItem.new(menu3, 302, "PyCrust", "a Python shell using wxPython as GUI", Wx::ITEM_RADIO))
|
55
|
-
menu3.append_item(Wx::MenuItem.new(menu3, 303, "psi", "a simple Python shell using wxPython as GUI", Wx::ITEM_RADIO))
|
56
|
-
menu3.append_separator()
|
57
|
-
menu3.append_item(Wx::MenuItem.new(menu3, 304, "project1", "", Wx::ITEM_NORMAL))
|
58
|
-
menu3.append_item(Wx::MenuItem.new(menu3, 305, "project2", "", Wx::ITEM_NORMAL))
|
59
|
-
menuBar.append(menu3, "&Shells")
|
60
|
-
|
61
|
-
menu4 = Wx::Menu.new()
|
62
|
-
menu4.append_item(Wx::MenuItem.new(menu4, 401, "letters", "abcde...", Wx::ITEM_CHECK))
|
63
|
-
menu4.append_item(Wx::MenuItem.new(menu4, 402, "digits", "123...", Wx::ITEM_CHECK))
|
64
|
-
menu4.append_item(Wx::MenuItem.new(menu4, 403, "letters and digits", "abcd... + 123...", Wx::ITEM_CHECK))
|
65
|
-
menuBar.append(menu4, "Chec&k")
|
66
|
-
|
67
|
-
menu5 = Wx::Menu.new()
|
68
|
-
# Show how to put an icon in the menu
|
69
|
-
item = Wx::MenuItem.new(menu5, 500, "&Smile!\tCtrl+S",
|
70
|
-
"This one has an icon")
|
71
|
-
|
72
|
-
# set_bitmap is only available on Windows and GTK
|
73
|
-
if item.respond_to?(:set_bitmap)
|
74
|
-
bmp_file = File.join( File.dirname(__FILE__),
|
75
|
-
'icons', 'wxwin16x16.xpm')
|
76
|
-
item.set_bitmap( Wx::Bitmap.new(bmp_file) )
|
77
|
-
end
|
78
|
-
menu5.append_item(item)
|
79
|
-
|
80
|
-
menu5.append(501, "Interesting thing\tCtrl+A", "Note the shortcut!")
|
81
|
-
menu5.append_separator()
|
82
|
-
menu5.append(502, "Hello\tShift+H")
|
83
|
-
menu5.append_separator()
|
84
|
-
menu5.append(503, "remove the submenu")
|
85
|
-
menu6 = Wx::Menu.new()
|
86
|
-
menu6.append(601, "Submenu Item")
|
87
|
-
item = Wx::MenuItem.new(menu5, 504, "submenu", "", Wx::ITEM_NORMAL, menu6)
|
88
|
-
menu5.append_item(item)
|
89
|
-
menu5.append(505, "remove this menu")
|
90
|
-
menu5.append(506, "this is updated")
|
91
|
-
menu5.append(507, "insert after this...")
|
92
|
-
menu5.append(508, "...and before this")
|
93
|
-
menuBar.append(menu5, "&Fun")
|
94
|
-
|
95
|
-
set_menu_bar(menuBar)
|
96
|
-
|
97
|
-
# Menu events
|
98
|
-
evt_menu_highlight_all {|event| on_menu_highlight(event)}
|
99
|
-
|
100
|
-
evt_menu(101) {|event| menu_101(event)}
|
101
|
-
evt_menu(102) {|event| menu_102(event)}
|
102
|
-
evt_menu(103) {|event| menu_103(event)}
|
103
|
-
evt_menu(104) {|event| close_window(event)}
|
104
|
-
|
105
|
-
evt_menu(201) {|event| menu_201(event)}
|
106
|
-
evt_menu(202) {|event| menu_202(event)}
|
107
|
-
evt_menu(2031) {|event| menu_2031(event)}
|
108
|
-
evt_menu(2032) {|event| menu_2032(event)}
|
109
|
-
evt_menu(2033) {|event| menu_2033(event)}
|
110
|
-
|
111
|
-
evt_menu(301) {|event| menu_301_to_303(event)}
|
112
|
-
evt_menu(302) {|event| menu_301_to_303(event)}
|
113
|
-
evt_menu(303) {|event| menu_301_to_303(event)}
|
114
|
-
evt_menu(304) {|event| menu_304(event)}
|
115
|
-
evt_menu(305) {|event| menu_305(event)}
|
116
|
-
|
117
|
-
evt_menu_range(401,403) {|event| menu_401_to_403(event)}
|
118
|
-
|
119
|
-
evt_menu(500) {|event| menu_500(event)}
|
120
|
-
evt_menu(501) {|event| menu_501(event)}
|
121
|
-
evt_menu(502) {|event| menu_502(event)}
|
122
|
-
evt_menu(503) {|event| test_remove(event)}
|
123
|
-
evt_menu(505) {|event| test_remove2(event)}
|
124
|
-
evt_menu(507) {|event| test_insert(event)}
|
125
|
-
evt_menu(508) {|event| test_insert(event)}
|
126
|
-
|
127
|
-
evt_update_ui(506) {|event| test_update_ui(event)}
|
128
|
-
end
|
129
|
-
|
130
|
-
# Methods
|
131
|
-
|
132
|
-
def on_menu_highlight(event)
|
133
|
-
event.skip()
|
134
|
-
end
|
135
|
-
|
136
|
-
def menu_101(event)
|
137
|
-
@log.write_text("Welcome to Mercury")
|
138
|
-
end
|
139
|
-
|
140
|
-
def menu_102(event)
|
141
|
-
@log.write_text("Welcome to Venus")
|
142
|
-
end
|
143
|
-
|
144
|
-
def menu_103(event)
|
145
|
-
@log.write_text("Welcome to Earth")
|
146
|
-
end
|
147
|
-
|
148
|
-
def close_window(event)
|
149
|
-
event.skip()
|
150
|
-
end
|
151
|
-
|
152
|
-
def menu_201(event)
|
153
|
-
@log.write_text("Chemical element number 1")
|
154
|
-
end
|
155
|
-
|
156
|
-
def menu_202(event)
|
157
|
-
@log.write_text("Chemical element number 2")
|
158
|
-
end
|
159
|
-
|
160
|
-
def menu_2031(event)
|
161
|
-
@log.write_text("Element number 57")
|
162
|
-
end
|
163
|
-
|
164
|
-
def menu_2032(event)
|
165
|
-
@log.write_text("Element number 58")
|
166
|
-
end
|
167
|
-
|
168
|
-
def menu_2033(event)
|
169
|
-
@log.write_text("Element number 59")
|
170
|
-
end
|
171
|
-
|
172
|
-
def menu_301_to_303(event)
|
173
|
-
id = event.get_id()
|
174
|
-
@log.write_text("Event id: %d" % id)
|
175
|
-
end
|
176
|
-
|
177
|
-
def menu_304(event)
|
178
|
-
@log.write_text("Not yet available")
|
179
|
-
end
|
180
|
-
|
181
|
-
def menu_305(event)
|
182
|
-
@log.write_text("Still vapor")
|
183
|
-
end
|
184
|
-
|
185
|
-
def menu_401_to_403(event)
|
186
|
-
@log.write_text("From an evt_menu_range event")
|
187
|
-
end
|
188
|
-
|
189
|
-
def menu_500(event)
|
190
|
-
@log.write_text("Have a happy day!")
|
191
|
-
end
|
192
|
-
|
193
|
-
def menu_501(event)
|
194
|
-
@log.write_text("Look in the code to see how the shortcut has been realized")
|
195
|
-
end
|
196
|
-
|
197
|
-
def menu_502(event)
|
198
|
-
@log.write_text("Hello from Robert Carlin!")
|
199
|
-
end
|
200
|
-
|
201
|
-
# These methods haven't been implemented yet....Waiting for Wx::MenuBar.get_menu_bar() to be implemented
|
202
|
-
def test_remove(event)
|
203
|
-
|
204
|
-
end
|
205
|
-
|
206
|
-
def test_remove2(event)
|
207
|
-
|
208
|
-
end
|
209
|
-
|
210
|
-
def test_insert(event)
|
211
|
-
|
212
|
-
end
|
213
|
-
|
214
|
-
def test_update_ui(event)
|
215
|
-
event.skip()
|
216
|
-
end
|
217
|
-
end
|
218
|
-
|
219
|
-
module Demo
|
220
|
-
def Demo.run(frame, nb, log)
|
221
|
-
win = MyFrame.new(frame, -1, log)
|
222
|
-
frame.otherWin = win
|
223
|
-
win.show()
|
224
|
-
end
|
225
|
-
|
226
|
-
def Demo.overview
|
227
|
-
return "A demo of using Wx::MenuBar and Wx::Menu in various ways."
|
228
|
-
end
|
229
|
-
end
|
230
|
-
|
231
|
-
|
232
|
-
if __FILE__ == $0
|
233
|
-
run_solo_lib = File.join( File.dirname(__FILE__), 'run.rb')
|
234
|
-
load run_solo_lib
|
235
|
-
run File.basename($0)
|
236
|
-
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 MyFrame < Wx::Frame
|
13
|
+
def initialize(parent, id, log)
|
14
|
+
super(parent, id, "Playing with menus", Wx::DEFAULT_POSITION, Wx::Size.new(400,200))
|
15
|
+
@log = log
|
16
|
+
center_on_screen(Wx::BOTH)
|
17
|
+
|
18
|
+
create_status_bar()
|
19
|
+
set_status_text("This is the statusbar")
|
20
|
+
|
21
|
+
text = "A bunch of bogus menus have been created for this frame. You can play around with them to see how they behave and then check the source for this sample to see how to implement them."
|
22
|
+
tc = Wx::TextCtrl.new(self, -1, text, Wx::DEFAULT_POSITION,
|
23
|
+
Wx::DEFAULT_SIZE, Wx::TE_READONLY | Wx::TE_MULTILINE)
|
24
|
+
|
25
|
+
# Prepare the menu bar
|
26
|
+
menuBar = Wx::MenuBar.new()
|
27
|
+
|
28
|
+
# 1st menu from the left
|
29
|
+
menu1 = Wx::Menu.new()
|
30
|
+
menu1.append(101, "&Mercury", "This the text in the Statusbar")
|
31
|
+
menu1.append(102, "&Venus", "")
|
32
|
+
menu1.append(103, "&Earth", "You may select Earth too")
|
33
|
+
menu1.append_separator()
|
34
|
+
menu1.append(104, "&Close", "Close this frame")
|
35
|
+
# Add menu to the menu bar
|
36
|
+
menuBar.append(menu1, "&Planets")
|
37
|
+
|
38
|
+
# 2nd menu from left
|
39
|
+
menu2 = Wx::Menu.new()
|
40
|
+
menu2.append(201, "Hydrogen")
|
41
|
+
menu2.append(202, "Helium")
|
42
|
+
# a submenu in the 2nd menu
|
43
|
+
submenu = Wx::Menu.new()
|
44
|
+
submenu.append(2031,"Lanthanium")
|
45
|
+
submenu.append(2032,"Cerium")
|
46
|
+
submenu.append(2033,"Praseodymium")
|
47
|
+
item = Wx::MenuItem.new(menu2, 203, "Lanthanides", "", Wx::ITEM_NORMAL, submenu)
|
48
|
+
menu2.append_item(item)
|
49
|
+
# append 2nd menu
|
50
|
+
menuBar.append(menu2, "&Elements")
|
51
|
+
|
52
|
+
menu3 = Wx::Menu.new()
|
53
|
+
menu3.append_item(Wx::MenuItem.new(menu3, 301, "IRB", "a Python shell using tcl/tk as GUI", Wx::ITEM_RADIO))
|
54
|
+
menu3.append_item(Wx::MenuItem.new(menu3, 302, "PyCrust", "a Python shell using wxPython as GUI", Wx::ITEM_RADIO))
|
55
|
+
menu3.append_item(Wx::MenuItem.new(menu3, 303, "psi", "a simple Python shell using wxPython as GUI", Wx::ITEM_RADIO))
|
56
|
+
menu3.append_separator()
|
57
|
+
menu3.append_item(Wx::MenuItem.new(menu3, 304, "project1", "", Wx::ITEM_NORMAL))
|
58
|
+
menu3.append_item(Wx::MenuItem.new(menu3, 305, "project2", "", Wx::ITEM_NORMAL))
|
59
|
+
menuBar.append(menu3, "&Shells")
|
60
|
+
|
61
|
+
menu4 = Wx::Menu.new()
|
62
|
+
menu4.append_item(Wx::MenuItem.new(menu4, 401, "letters", "abcde...", Wx::ITEM_CHECK))
|
63
|
+
menu4.append_item(Wx::MenuItem.new(menu4, 402, "digits", "123...", Wx::ITEM_CHECK))
|
64
|
+
menu4.append_item(Wx::MenuItem.new(menu4, 403, "letters and digits", "abcd... + 123...", Wx::ITEM_CHECK))
|
65
|
+
menuBar.append(menu4, "Chec&k")
|
66
|
+
|
67
|
+
menu5 = Wx::Menu.new()
|
68
|
+
# Show how to put an icon in the menu
|
69
|
+
item = Wx::MenuItem.new(menu5, 500, "&Smile!\tCtrl+S",
|
70
|
+
"This one has an icon")
|
71
|
+
|
72
|
+
# set_bitmap is only available on Windows and GTK
|
73
|
+
if item.respond_to?(:set_bitmap)
|
74
|
+
bmp_file = File.join( File.dirname(__FILE__),
|
75
|
+
'icons', 'wxwin16x16.xpm')
|
76
|
+
item.set_bitmap( Wx::Bitmap.new(bmp_file) )
|
77
|
+
end
|
78
|
+
menu5.append_item(item)
|
79
|
+
|
80
|
+
menu5.append(501, "Interesting thing\tCtrl+A", "Note the shortcut!")
|
81
|
+
menu5.append_separator()
|
82
|
+
menu5.append(502, "Hello\tShift+H")
|
83
|
+
menu5.append_separator()
|
84
|
+
menu5.append(503, "remove the submenu")
|
85
|
+
menu6 = Wx::Menu.new()
|
86
|
+
menu6.append(601, "Submenu Item")
|
87
|
+
item = Wx::MenuItem.new(menu5, 504, "submenu", "", Wx::ITEM_NORMAL, menu6)
|
88
|
+
menu5.append_item(item)
|
89
|
+
menu5.append(505, "remove this menu")
|
90
|
+
menu5.append(506, "this is updated")
|
91
|
+
menu5.append(507, "insert after this...")
|
92
|
+
menu5.append(508, "...and before this")
|
93
|
+
menuBar.append(menu5, "&Fun")
|
94
|
+
|
95
|
+
set_menu_bar(menuBar)
|
96
|
+
|
97
|
+
# Menu events
|
98
|
+
evt_menu_highlight_all {|event| on_menu_highlight(event)}
|
99
|
+
|
100
|
+
evt_menu(101) {|event| menu_101(event)}
|
101
|
+
evt_menu(102) {|event| menu_102(event)}
|
102
|
+
evt_menu(103) {|event| menu_103(event)}
|
103
|
+
evt_menu(104) {|event| close_window(event)}
|
104
|
+
|
105
|
+
evt_menu(201) {|event| menu_201(event)}
|
106
|
+
evt_menu(202) {|event| menu_202(event)}
|
107
|
+
evt_menu(2031) {|event| menu_2031(event)}
|
108
|
+
evt_menu(2032) {|event| menu_2032(event)}
|
109
|
+
evt_menu(2033) {|event| menu_2033(event)}
|
110
|
+
|
111
|
+
evt_menu(301) {|event| menu_301_to_303(event)}
|
112
|
+
evt_menu(302) {|event| menu_301_to_303(event)}
|
113
|
+
evt_menu(303) {|event| menu_301_to_303(event)}
|
114
|
+
evt_menu(304) {|event| menu_304(event)}
|
115
|
+
evt_menu(305) {|event| menu_305(event)}
|
116
|
+
|
117
|
+
evt_menu_range(401,403) {|event| menu_401_to_403(event)}
|
118
|
+
|
119
|
+
evt_menu(500) {|event| menu_500(event)}
|
120
|
+
evt_menu(501) {|event| menu_501(event)}
|
121
|
+
evt_menu(502) {|event| menu_502(event)}
|
122
|
+
evt_menu(503) {|event| test_remove(event)}
|
123
|
+
evt_menu(505) {|event| test_remove2(event)}
|
124
|
+
evt_menu(507) {|event| test_insert(event)}
|
125
|
+
evt_menu(508) {|event| test_insert(event)}
|
126
|
+
|
127
|
+
evt_update_ui(506) {|event| test_update_ui(event)}
|
128
|
+
end
|
129
|
+
|
130
|
+
# Methods
|
131
|
+
|
132
|
+
def on_menu_highlight(event)
|
133
|
+
event.skip()
|
134
|
+
end
|
135
|
+
|
136
|
+
def menu_101(event)
|
137
|
+
@log.write_text("Welcome to Mercury")
|
138
|
+
end
|
139
|
+
|
140
|
+
def menu_102(event)
|
141
|
+
@log.write_text("Welcome to Venus")
|
142
|
+
end
|
143
|
+
|
144
|
+
def menu_103(event)
|
145
|
+
@log.write_text("Welcome to Earth")
|
146
|
+
end
|
147
|
+
|
148
|
+
def close_window(event)
|
149
|
+
event.skip()
|
150
|
+
end
|
151
|
+
|
152
|
+
def menu_201(event)
|
153
|
+
@log.write_text("Chemical element number 1")
|
154
|
+
end
|
155
|
+
|
156
|
+
def menu_202(event)
|
157
|
+
@log.write_text("Chemical element number 2")
|
158
|
+
end
|
159
|
+
|
160
|
+
def menu_2031(event)
|
161
|
+
@log.write_text("Element number 57")
|
162
|
+
end
|
163
|
+
|
164
|
+
def menu_2032(event)
|
165
|
+
@log.write_text("Element number 58")
|
166
|
+
end
|
167
|
+
|
168
|
+
def menu_2033(event)
|
169
|
+
@log.write_text("Element number 59")
|
170
|
+
end
|
171
|
+
|
172
|
+
def menu_301_to_303(event)
|
173
|
+
id = event.get_id()
|
174
|
+
@log.write_text("Event id: %d" % id)
|
175
|
+
end
|
176
|
+
|
177
|
+
def menu_304(event)
|
178
|
+
@log.write_text("Not yet available")
|
179
|
+
end
|
180
|
+
|
181
|
+
def menu_305(event)
|
182
|
+
@log.write_text("Still vapor")
|
183
|
+
end
|
184
|
+
|
185
|
+
def menu_401_to_403(event)
|
186
|
+
@log.write_text("From an evt_menu_range event")
|
187
|
+
end
|
188
|
+
|
189
|
+
def menu_500(event)
|
190
|
+
@log.write_text("Have a happy day!")
|
191
|
+
end
|
192
|
+
|
193
|
+
def menu_501(event)
|
194
|
+
@log.write_text("Look in the code to see how the shortcut has been realized")
|
195
|
+
end
|
196
|
+
|
197
|
+
def menu_502(event)
|
198
|
+
@log.write_text("Hello from Robert Carlin!")
|
199
|
+
end
|
200
|
+
|
201
|
+
# These methods haven't been implemented yet....Waiting for Wx::MenuBar.get_menu_bar() to be implemented
|
202
|
+
def test_remove(event)
|
203
|
+
|
204
|
+
end
|
205
|
+
|
206
|
+
def test_remove2(event)
|
207
|
+
|
208
|
+
end
|
209
|
+
|
210
|
+
def test_insert(event)
|
211
|
+
|
212
|
+
end
|
213
|
+
|
214
|
+
def test_update_ui(event)
|
215
|
+
event.skip()
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
module Demo
|
220
|
+
def Demo.run(frame, nb, log)
|
221
|
+
win = MyFrame.new(frame, -1, log)
|
222
|
+
frame.otherWin = win
|
223
|
+
win.show()
|
224
|
+
end
|
225
|
+
|
226
|
+
def Demo.overview
|
227
|
+
return "A demo of using Wx::MenuBar and Wx::Menu in various ways."
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
|
232
|
+
if __FILE__ == $0
|
233
|
+
run_solo_lib = File.join( File.dirname(__FILE__), 'run.rb')
|
234
|
+
load run_solo_lib
|
235
|
+
run File.basename($0)
|
236
|
+
end
|