wxruby 1.9.0-powerpc-darwin8.10.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/wx.rb +35 -0
- data/lib/wx/classes/app.rb +25 -0
- data/lib/wx/classes/artprovider.rb +31 -0
- data/lib/wx/classes/bitmap.rb +23 -0
- data/lib/wx/classes/choice.rb +4 -0
- data/lib/wx/classes/clientdc.rb +13 -0
- data/lib/wx/classes/colour.rb +47 -0
- data/lib/wx/classes/combobox.rb +4 -0
- data/lib/wx/classes/evthandler.rb +824 -0
- data/lib/wx/classes/font.rb +118 -0
- data/lib/wx/classes/grid.rb +130 -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/locale.rb +28 -0
- data/lib/wx/classes/object.rb +7 -0
- data/lib/wx/classes/paintdc.rb +12 -0
- data/lib/wx/classes/point.rb +5 -0
- data/lib/wx/classes/previewframe.rb +13 -0
- data/lib/wx/classes/rect.rb +5 -0
- data/lib/wx/classes/size.rb +5 -0
- data/lib/wx/classes/texturlevent.rb +6 -0
- data/lib/wx/classes/timer.rb +69 -0
- data/lib/wx/classes/window.rb +38 -0
- data/lib/wx/classes/xmlresource.rb +16 -0
- data/lib/wx/version.rb +3 -0
- data/lib/wxruby2.bundle +0 -0
- data/samples/SAMPLES-LICENSE.TXT +18 -0
- data/samples/aui/aui.rb +1352 -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 +155 -0
- data/samples/bigdemo/wxScrolledMessageDialog.rbw +59 -0
- data/samples/bigdemo/wxScrolledWindow.rbw +196 -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 +296 -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/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/wizard.rb +81 -0
- data/samples/grid/grid.rb +201 -0
- data/samples/html/html.rb +251 -0
- data/samples/images/Thumbs.db +0 -0
- data/samples/images/images.rb +48 -0
- data/samples/images/paperclip.png +0 -0
- data/samples/listbook/listbook.rb +183 -0
- data/samples/listbook/listbook.xrc +370 -0
- data/samples/mdi/mdi.rb +87 -0
- data/samples/minimal/minimal.rb +95 -0
- data/samples/minimal/mondrian.ico +0 -0
- data/samples/minimal/mondrian.xpm +44 -0
- data/samples/minimal/nothing.rb +46 -0
- data/samples/minimal/text.rb +35 -0
- data/samples/printing/mondrian.ico +0 -0
- data/samples/printing/mondrian.xpm +44 -0
- data/samples/printing/printing.rb +484 -0
- data/samples/text/mondrian.ico +0 -0
- data/samples/text/mondrian.xpm +44 -0
- data/samples/text/scintilla.rb +180 -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 +1210 -0
- data/samples/xrc/samples.xrc +46 -0
- data/samples/xrc/xrc_sample.rb +107 -0
- metadata +264 -0
@@ -0,0 +1,109 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
begin
|
4
|
+
require 'wx'
|
5
|
+
rescue LoadError => no_wx_err
|
6
|
+
begin
|
7
|
+
require 'rubygems'
|
8
|
+
require 'wx'
|
9
|
+
rescue LoadError
|
10
|
+
raise no_wx_err
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class TestVirtualList < Wx::ListCtrl
|
15
|
+
def initialize(parent, log)
|
16
|
+
super(parent, -1, Wx::DEFAULT_POSITION, Wx::DEFAULT_SIZE, Wx::LC_REPORT | Wx::LC_VIRTUAL | Wx::LC_HRULES | Wx::LC_VRULES)
|
17
|
+
@log = log
|
18
|
+
|
19
|
+
@il = Wx::ImageList.new(16,16)
|
20
|
+
bmp_file = File.join(File.dirname(__FILE__), "icons/wxwin16x16.xpm")
|
21
|
+
|
22
|
+
@idx1 = @il.add(Wx::Bitmap.new(bmp_file))
|
23
|
+
set_image_list(@il, Wx::IMAGE_LIST_SMALL)
|
24
|
+
|
25
|
+
insert_column(0,"First")
|
26
|
+
insert_column(1,"Second")
|
27
|
+
insert_column(2,"Third")
|
28
|
+
set_column_width(0,175)
|
29
|
+
set_column_width(1,175)
|
30
|
+
set_column_width(2,175)
|
31
|
+
|
32
|
+
set_item_count(1000000)
|
33
|
+
|
34
|
+
@attr1 = Wx::ListItemAttr.new()
|
35
|
+
@attr1.set_background_colour(Wx::Colour.new("YELLOW"))
|
36
|
+
|
37
|
+
@attr2 = Wx::ListItemAttr.new()
|
38
|
+
@attr2.set_background_colour(Wx::Colour.new("LIGHT BLUE"))
|
39
|
+
|
40
|
+
evt_list_item_selected(get_id()) {|event| on_item_selected(event)}
|
41
|
+
evt_list_item_activated(get_id()) {|event| on_item_activated(event)}
|
42
|
+
evt_list_item_deselected(get_id()) {|event| on_item_deselected(event)}
|
43
|
+
end
|
44
|
+
|
45
|
+
def on_item_selected(event)
|
46
|
+
@currentItem = event.get_index()
|
47
|
+
@item = event.get_item()
|
48
|
+
get_column(1,@item)
|
49
|
+
|
50
|
+
@log.write_text('on_item_selected: "%s", "%s", "%s", "%s"' % [@currentItem, get_item_text(@currentItem),
|
51
|
+
@item.get_text(), get_column(2,@item) ? @item.get_text() : nil])
|
52
|
+
end
|
53
|
+
|
54
|
+
def on_item_activated(event)
|
55
|
+
@currentItem = event.get_index()
|
56
|
+
@log.write_text("on_item_activated: %s\nTopItem: %s" % [get_item_text(@currentItem), get_top_item()])
|
57
|
+
end
|
58
|
+
|
59
|
+
def on_item_deselected(event)
|
60
|
+
@log.write_text("on_item_deselected: %s" % event.get_index())
|
61
|
+
end
|
62
|
+
|
63
|
+
#---------------------------------------------------
|
64
|
+
# These methods are callbacks for implementing the
|
65
|
+
# "virtualness" of the list... Normally you would
|
66
|
+
# determine the text, attributes and/or image based
|
67
|
+
# on values from some external data source, but for
|
68
|
+
# this demo we'll just calculate them
|
69
|
+
|
70
|
+
def on_get_item_text(item, col)
|
71
|
+
return "Item %d, column %d" % [item,col]
|
72
|
+
end
|
73
|
+
|
74
|
+
def on_get_item_image(item)
|
75
|
+
if item % 3 == 0
|
76
|
+
return @idx1
|
77
|
+
else
|
78
|
+
return -1
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def on_get_item_attr(item)
|
83
|
+
if item % 3 == 1
|
84
|
+
return @attr1
|
85
|
+
elsif item % 3 == 2
|
86
|
+
return @attr2
|
87
|
+
else
|
88
|
+
return nil
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
|
93
|
+
module Demo
|
94
|
+
def Demo.run(frame, nb, log)
|
95
|
+
win = TestVirtualList.new(nb,log)
|
96
|
+
return win
|
97
|
+
end
|
98
|
+
|
99
|
+
def Demo.overview
|
100
|
+
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."
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
|
105
|
+
if __FILE__ == $0
|
106
|
+
run_solo_lib = File.join( File.dirname(__FILE__), 'run.rb')
|
107
|
+
load run_solo_lib
|
108
|
+
run File.basename($0)
|
109
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
begin
|
4
|
+
require 'wx'
|
5
|
+
rescue LoadError => no_wx_err
|
6
|
+
begin
|
7
|
+
require 'rubygems'
|
8
|
+
require 'wx'
|
9
|
+
rescue LoadError
|
10
|
+
raise no_wx_err
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class TestPanel < Wx::Panel
|
15
|
+
def initialize(parent, log)
|
16
|
+
@log = log
|
17
|
+
super(parent, -1)
|
18
|
+
|
19
|
+
b1 = Wx::Button.new(self, -1, "MDI demo")
|
20
|
+
evt_button(b1.get_id()) {|event| show_mdi_demo(event)}
|
21
|
+
|
22
|
+
box = Wx::BoxSizer.new(Wx::VERTICAL)
|
23
|
+
box.add(20,30)
|
24
|
+
box.add(b1, 0, Wx::ALIGN_CENTER | Wx::ALL, 15)
|
25
|
+
set_sizer(box)
|
26
|
+
end
|
27
|
+
|
28
|
+
def show_mdi_demo(event)
|
29
|
+
mdi_demo_file = File.join( File.dirname(__FILE__), "MDIDemo.rbw")
|
30
|
+
load mdi_demo_file
|
31
|
+
frame = Demo::MyParentFrame.new()
|
32
|
+
frame.show()
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
module Demo
|
37
|
+
def Demo.run(frame,nb,log)
|
38
|
+
win = TestPanel.new(nb, log)
|
39
|
+
return win
|
40
|
+
end
|
41
|
+
|
42
|
+
def Demo.overview
|
43
|
+
"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)."
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
if __FILE__ == $0
|
49
|
+
run_solo_lib = File.join( File.dirname(__FILE__), 'run.rb')
|
50
|
+
load run_solo_lib
|
51
|
+
run File.basename($0)
|
52
|
+
end
|
@@ -0,0 +1,238 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
begin
|
4
|
+
require 'wx'
|
5
|
+
rescue LoadError => no_wx_err
|
6
|
+
begin
|
7
|
+
require 'rubygems'
|
8
|
+
require 'wx'
|
9
|
+
rescue LoadError
|
10
|
+
raise no_wx_err
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class MyFrame < Wx::Frame
|
15
|
+
def initialize(parent, id, log)
|
16
|
+
super(parent, id, "Playing with menus", Wx::DEFAULT_POSITION, Wx::Size.new(400,200))
|
17
|
+
@log = log
|
18
|
+
center_on_screen(Wx::BOTH)
|
19
|
+
|
20
|
+
create_status_bar()
|
21
|
+
set_status_text("This is the statusbar")
|
22
|
+
|
23
|
+
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."
|
24
|
+
tc = Wx::TextCtrl.new(self, -1, text, Wx::DEFAULT_POSITION,
|
25
|
+
Wx::DEFAULT_SIZE, Wx::TE_READONLY | Wx::TE_MULTILINE)
|
26
|
+
|
27
|
+
# Prepare the menu bar
|
28
|
+
menuBar = Wx::MenuBar.new()
|
29
|
+
|
30
|
+
# 1st menu from the left
|
31
|
+
menu1 = Wx::Menu.new()
|
32
|
+
menu1.append(101, "&Mercury", "This the text in the Statusbar")
|
33
|
+
menu1.append(102, "&Venus", "")
|
34
|
+
menu1.append(103, "&Earth", "You may select Earth too")
|
35
|
+
menu1.append_separator()
|
36
|
+
menu1.append(104, "&Close", "Close this frame")
|
37
|
+
# Add menu to the menu bar
|
38
|
+
menuBar.append(menu1, "&Planets")
|
39
|
+
|
40
|
+
# 2nd menu from left
|
41
|
+
menu2 = Wx::Menu.new()
|
42
|
+
menu2.append(201, "Hydrogen")
|
43
|
+
menu2.append(202, "Helium")
|
44
|
+
# a submenu in the 2nd menu
|
45
|
+
submenu = Wx::Menu.new()
|
46
|
+
submenu.append(2031,"Lanthanium")
|
47
|
+
submenu.append(2032,"Cerium")
|
48
|
+
submenu.append(2033,"Praseodymium")
|
49
|
+
item = Wx::MenuItem.new(menu2, 203, "Lanthanides", "", Wx::ITEM_NORMAL, submenu)
|
50
|
+
menu2.append_item(item)
|
51
|
+
# append 2nd menu
|
52
|
+
menuBar.append(menu2, "&Elements")
|
53
|
+
|
54
|
+
menu3 = Wx::Menu.new()
|
55
|
+
menu3.append_item(Wx::MenuItem.new(menu3, 301, "IRB", "a Python shell using tcl/tk as GUI", Wx::ITEM_RADIO))
|
56
|
+
menu3.append_item(Wx::MenuItem.new(menu3, 302, "PyCrust", "a Python shell using wxPython as GUI", Wx::ITEM_RADIO))
|
57
|
+
menu3.append_item(Wx::MenuItem.new(menu3, 303, "psi", "a simple Python shell using wxPython as GUI", Wx::ITEM_RADIO))
|
58
|
+
menu3.append_separator()
|
59
|
+
menu3.append_item(Wx::MenuItem.new(menu3, 304, "project1", "", Wx::ITEM_NORMAL))
|
60
|
+
menu3.append_item(Wx::MenuItem.new(menu3, 305, "project2", "", Wx::ITEM_NORMAL))
|
61
|
+
menuBar.append(menu3, "&Shells")
|
62
|
+
|
63
|
+
menu4 = Wx::Menu.new()
|
64
|
+
menu4.append_item(Wx::MenuItem.new(menu4, 401, "letters", "abcde...", Wx::ITEM_CHECK))
|
65
|
+
menu4.append_item(Wx::MenuItem.new(menu4, 402, "digits", "123...", Wx::ITEM_CHECK))
|
66
|
+
menu4.append_item(Wx::MenuItem.new(menu4, 403, "letters and digits", "abcd... + 123...", Wx::ITEM_CHECK))
|
67
|
+
menuBar.append(menu4, "Chec&k")
|
68
|
+
|
69
|
+
menu5 = Wx::Menu.new()
|
70
|
+
# Show how to put an icon in the menu
|
71
|
+
item = Wx::MenuItem.new(menu5, 500, "&Smile!\tCtrl+S",
|
72
|
+
"This one has an icon")
|
73
|
+
|
74
|
+
# set_bitmap is only available on Windows and GTK
|
75
|
+
if item.respond_to?(:set_bitmap)
|
76
|
+
bmp_file = File.join( File.dirname(__FILE__),
|
77
|
+
'icons', 'wxwin16x16.xpm')
|
78
|
+
item.set_bitmap( Wx::Bitmap.new(bmp_file) )
|
79
|
+
end
|
80
|
+
menu5.append_item(item)
|
81
|
+
|
82
|
+
menu5.append(501, "Interesting thing\tCtrl+A", "Note the shortcut!")
|
83
|
+
menu5.append_separator()
|
84
|
+
menu5.append(502, "Hello\tShift+H")
|
85
|
+
menu5.append_separator()
|
86
|
+
menu5.append(503, "remove the submenu")
|
87
|
+
menu6 = Wx::Menu.new()
|
88
|
+
menu6.append(601, "Submenu Item")
|
89
|
+
item = Wx::MenuItem.new(menu5, 504, "submenu", "", Wx::ITEM_NORMAL, menu6)
|
90
|
+
menu5.append_item(item)
|
91
|
+
menu5.append(505, "remove this menu")
|
92
|
+
menu5.append(506, "this is updated")
|
93
|
+
menu5.append(507, "insert after this...")
|
94
|
+
menu5.append(508, "...and before this")
|
95
|
+
menuBar.append(menu5, "&Fun")
|
96
|
+
|
97
|
+
set_menu_bar(menuBar)
|
98
|
+
|
99
|
+
# Menu events
|
100
|
+
evt_menu_highlight_all {|event| on_menu_highlight(event)}
|
101
|
+
|
102
|
+
evt_menu(101) {|event| menu_101(event)}
|
103
|
+
evt_menu(102) {|event| menu_102(event)}
|
104
|
+
evt_menu(103) {|event| menu_103(event)}
|
105
|
+
evt_menu(104) {|event| close_window(event)}
|
106
|
+
|
107
|
+
evt_menu(201) {|event| menu_201(event)}
|
108
|
+
evt_menu(202) {|event| menu_202(event)}
|
109
|
+
evt_menu(2031) {|event| menu_2031(event)}
|
110
|
+
evt_menu(2032) {|event| menu_2032(event)}
|
111
|
+
evt_menu(2033) {|event| menu_2033(event)}
|
112
|
+
|
113
|
+
evt_menu(301) {|event| menu_301_to_303(event)}
|
114
|
+
evt_menu(302) {|event| menu_301_to_303(event)}
|
115
|
+
evt_menu(303) {|event| menu_301_to_303(event)}
|
116
|
+
evt_menu(304) {|event| menu_304(event)}
|
117
|
+
evt_menu(305) {|event| menu_305(event)}
|
118
|
+
|
119
|
+
evt_menu_range(401,403) {|event| menu_401_to_403(event)}
|
120
|
+
|
121
|
+
evt_menu(500) {|event| menu_500(event)}
|
122
|
+
evt_menu(501) {|event| menu_501(event)}
|
123
|
+
evt_menu(502) {|event| menu_502(event)}
|
124
|
+
evt_menu(503) {|event| test_remove(event)}
|
125
|
+
evt_menu(505) {|event| test_remove2(event)}
|
126
|
+
evt_menu(507) {|event| test_insert(event)}
|
127
|
+
evt_menu(508) {|event| test_insert(event)}
|
128
|
+
|
129
|
+
evt_update_ui(506) {|event| test_update_ui(event)}
|
130
|
+
end
|
131
|
+
|
132
|
+
# Methods
|
133
|
+
|
134
|
+
def on_menu_highlight(event)
|
135
|
+
event.skip()
|
136
|
+
end
|
137
|
+
|
138
|
+
def menu_101(event)
|
139
|
+
@log.write_text("Welcome to Mercury")
|
140
|
+
end
|
141
|
+
|
142
|
+
def menu_102(event)
|
143
|
+
@log.write_text("Welcome to Venus")
|
144
|
+
end
|
145
|
+
|
146
|
+
def menu_103(event)
|
147
|
+
@log.write_text("Welcome to Earth")
|
148
|
+
end
|
149
|
+
|
150
|
+
def close_window(event)
|
151
|
+
event.skip()
|
152
|
+
end
|
153
|
+
|
154
|
+
def menu_201(event)
|
155
|
+
@log.write_text("Chemical element number 1")
|
156
|
+
end
|
157
|
+
|
158
|
+
def menu_202(event)
|
159
|
+
@log.write_text("Chemical element number 2")
|
160
|
+
end
|
161
|
+
|
162
|
+
def menu_2031(event)
|
163
|
+
@log.write_text("Element number 57")
|
164
|
+
end
|
165
|
+
|
166
|
+
def menu_2032(event)
|
167
|
+
@log.write_text("Element number 58")
|
168
|
+
end
|
169
|
+
|
170
|
+
def menu_2033(event)
|
171
|
+
@log.write_text("Element number 59")
|
172
|
+
end
|
173
|
+
|
174
|
+
def menu_301_to_303(event)
|
175
|
+
id = event.get_id()
|
176
|
+
@log.write_text("Event id: %d" % id)
|
177
|
+
end
|
178
|
+
|
179
|
+
def menu_304(event)
|
180
|
+
@log.write_text("Not yet available")
|
181
|
+
end
|
182
|
+
|
183
|
+
def menu_305(event)
|
184
|
+
@log.write_text("Still vapor")
|
185
|
+
end
|
186
|
+
|
187
|
+
def menu_401_to_403(event)
|
188
|
+
@log.write_text("From an evt_menu_range event")
|
189
|
+
end
|
190
|
+
|
191
|
+
def menu_500(event)
|
192
|
+
@log.write_text("Have a happy day!")
|
193
|
+
end
|
194
|
+
|
195
|
+
def menu_501(event)
|
196
|
+
@log.write_text("Look in the code to see how the shortcut has been realized")
|
197
|
+
end
|
198
|
+
|
199
|
+
def menu_502(event)
|
200
|
+
@log.write_text("Hello from Robert Carlin!")
|
201
|
+
end
|
202
|
+
|
203
|
+
# These methods haven't been implemented yet....Waiting for Wx::MenuBar.get_menu_bar() to be implemented
|
204
|
+
def test_remove(event)
|
205
|
+
|
206
|
+
end
|
207
|
+
|
208
|
+
def test_remove2(event)
|
209
|
+
|
210
|
+
end
|
211
|
+
|
212
|
+
def test_insert(event)
|
213
|
+
|
214
|
+
end
|
215
|
+
|
216
|
+
def test_update_ui(event)
|
217
|
+
event.skip()
|
218
|
+
end
|
219
|
+
end
|
220
|
+
|
221
|
+
module Demo
|
222
|
+
def Demo.run(frame, nb, log)
|
223
|
+
win = MyFrame.new(frame, -1, log)
|
224
|
+
frame.otherWin = win
|
225
|
+
win.show()
|
226
|
+
end
|
227
|
+
|
228
|
+
def Demo.overview
|
229
|
+
return "A demo of using Wx::MenuBar and Wx::Menu in various ways."
|
230
|
+
end
|
231
|
+
end
|
232
|
+
|
233
|
+
|
234
|
+
if __FILE__ == $0
|
235
|
+
run_solo_lib = File.join( File.dirname(__FILE__), 'run.rb')
|
236
|
+
load run_solo_lib
|
237
|
+
run File.basename($0)
|
238
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
begin
|
4
|
+
require 'wx'
|
5
|
+
rescue LoadError => no_wx_err
|
6
|
+
begin
|
7
|
+
require 'rubygems'
|
8
|
+
require 'wx'
|
9
|
+
rescue LoadError
|
10
|
+
raise no_wx_err
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
module Demo
|
15
|
+
def Demo.run(frame, nb, log)
|
16
|
+
dlg = Wx::MessageDialog.new(frame, "Hello from Ruby and wxRuby!", "A Message Box", Wx::OK | Wx::ICON_INFORMATION)
|
17
|
+
dlg.show_modal()
|
18
|
+
dlg.destroy()
|
19
|
+
end
|
20
|
+
|
21
|
+
def Demo.overview
|
22
|
+
return "Show a message to the user in a dialog"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
if __FILE__ == $0
|
27
|
+
run_solo_lib = File.join( File.dirname(__FILE__), 'run.rb')
|
28
|
+
load run_solo_lib
|
29
|
+
run File.basename($0)
|
30
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# wxRuby2 Sample Code. Copyright (c) 2004-2006 Kevin B. Smith
|
3
|
+
# Freely reusable code: see SAMPLES-LICENSE.TXT for details
|
4
|
+
|
5
|
+
begin
|
6
|
+
require 'wx'
|
7
|
+
rescue LoadError => no_wx_err
|
8
|
+
begin
|
9
|
+
require 'rubygems'
|
10
|
+
require 'wx'
|
11
|
+
rescue LoadError
|
12
|
+
raise no_wx_err
|
13
|
+
end
|
14
|
+
end
|
15
|
+
include Wx
|
16
|
+
|
17
|
+
class MyMiniFrame < MiniFrame
|
18
|
+
def initialize(parent, log)
|
19
|
+
@log = log
|
20
|
+
super(parent, -1, "Wx::MiniFrame demonstration",
|
21
|
+
DEFAULT_POSITION, Size.new(350,200), DEFAULT_FRAME_STYLE)
|
22
|
+
panel = Panel.new(self, -1)
|
23
|
+
|
24
|
+
button = Button.new(panel, -1, "Close me", Point.new(15,15))
|
25
|
+
evt_button( button.get_id ) { on_close_me }
|
26
|
+
# evt_close { | e | on_close_window(e) }
|
27
|
+
end
|
28
|
+
|
29
|
+
def on_close_me
|
30
|
+
close(true)
|
31
|
+
end
|
32
|
+
|
33
|
+
def on_close_window(event)
|
34
|
+
@log.write_text("MiniFrame closed.")
|
35
|
+
event.skip
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
class TestPanel < Wx::Panel
|
41
|
+
def initialize(parent, log)
|
42
|
+
super(parent, -1, Wx::DEFAULT_POSITION, Wx::DEFAULT_SIZE, Wx::NO_FULL_REPAINT_ON_RESIZE)
|
43
|
+
@log = log
|
44
|
+
|
45
|
+
b = Button.new(self, -1, 'Create and Show a MiniFrame', Wx::Point.new(50,50))
|
46
|
+
evt_button(b.get_id) { on_button }
|
47
|
+
end
|
48
|
+
|
49
|
+
def on_button
|
50
|
+
win = MyMiniFrame.new(self, @log)
|
51
|
+
win.set_size(Wx::Size.new(200, 200))
|
52
|
+
win.center_on_parent(Wx::BOTH)
|
53
|
+
win.show(true)
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
module Demo
|
58
|
+
def Demo.run(frame, nb, log)
|
59
|
+
TestPanel.new(nb, log)
|
60
|
+
end
|
61
|
+
|
62
|
+
def Demo.overview
|
63
|
+
return "A MiniFrame is a Frame with a small title bar. It is suitable for floating\n" +
|
64
|
+
"toolbars that must not take up too much screen area. In other respects, it's the\n" +
|
65
|
+
"same as a Wx::Frame."
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
|
70
|
+
if __FILE__ == $0
|
71
|
+
run_solo_lib = File.join( File.dirname(__FILE__), 'run.rb')
|
72
|
+
load run_solo_lib
|
73
|
+
run File.basename($0)
|
74
|
+
end
|