wxruby 1.9.2-i386-mswin32 → 1.9.3-i386-mswin32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/LICENSE +53 -53
- data/README +299 -299
- data/lib/wx/classes/app.rb +6 -0
- data/lib/wx/classes/checklistbox.rb +45 -30
- data/lib/wx/classes/clipboard.rb +16 -0
- data/lib/wx/classes/event.rb +5 -0
- data/lib/wx/classes/evthandler.rb +20 -10
- data/lib/wx/classes/grid.rb +38 -39
- data/lib/wx/classes/listctrl.rb +12 -0
- data/lib/wx/classes/mediactrl.rb +22 -0
- data/lib/wx/classes/menu.rb +6 -6
- data/lib/wx/classes/sound.rb +23 -0
- data/lib/wx/classes/styledtextctrl.rb +2 -2
- data/lib/wx/classes/treectrl.rb +26 -0
- data/lib/wx/keyword_ctors.rb +19 -5
- data/lib/wx/keyword_defs.rb +20 -0
- data/lib/wx/version.rb +1 -1
- data/lib/wx.rb +42 -42
- data/lib/wxruby2.exp +0 -0
- data/lib/wxruby2.lib +0 -0
- data/lib/wxruby2.so +0 -0
- data/samples/SAMPLES-LICENSE.TXT +17 -17
- data/samples/aui/aui.rb +8 -1
- data/samples/bigdemo/About.rbw +39 -39
- data/samples/bigdemo/ColorPanel.rbw +25 -25
- data/samples/bigdemo/GridSimple.rbw +80 -80
- data/samples/bigdemo/MDIDemo.rbw +59 -59
- data/samples/bigdemo/PopupMenu.rbw +151 -151
- data/samples/bigdemo/Sizers.rbw +545 -545
- data/samples/bigdemo/bigdemo.rb +826 -826
- data/samples/bigdemo/demoTemplate.rbw +37 -37
- 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 +66 -66
- data/samples/bigdemo/wxCalendarCtrl.rbw +72 -72
- data/samples/bigdemo/wxCheckBox.rbw +52 -52
- data/samples/bigdemo/wxCheckListBox.rbw +77 -77
- data/samples/bigdemo/wxChoice.rbw +49 -49
- data/samples/bigdemo/wxColourDialog.rbw +34 -34
- data/samples/bigdemo/wxComboBox.rbw +79 -79
- data/samples/bigdemo/wxDialog.rbw +92 -92
- data/samples/bigdemo/wxDirDialog.rbw +32 -32
- data/samples/bigdemo/wxFileDialog.rbw +39 -39
- data/samples/bigdemo/wxFileDialog_Save.rbw +38 -38
- data/samples/bigdemo/wxFindReplaceDialog.rbw +85 -85
- data/samples/bigdemo/wxFontDialog.rbw +176 -176
- data/samples/bigdemo/wxFrame.rbw +55 -55
- data/samples/bigdemo/wxGauge.rbw +73 -73
- data/samples/bigdemo/wxGrid.rbw +68 -68
- data/samples/bigdemo/wxListBox.rbw +142 -142
- data/samples/bigdemo/wxListCtrl_virtual.rbw +109 -109
- data/samples/bigdemo/wxMDIWindows.rbw +52 -52
- data/samples/bigdemo/wxMenu.rbw +238 -238
- data/samples/bigdemo/wxMessageDialog.rbw +30 -30
- data/samples/bigdemo/wxMultipleChoiceDialog.rbw +34 -34
- data/samples/bigdemo/wxNotebook.rbw +138 -138
- data/samples/bigdemo/wxProgressDialog.rbw +45 -45
- data/samples/bigdemo/wxRadioBox.rbw +74 -74
- data/samples/bigdemo/wxRadioButton.rbw +127 -127
- data/samples/bigdemo/wxSashWindow.rbw +94 -104
- data/samples/bigdemo/wxScrolledMessageDialog.rbw +59 -59
- data/samples/bigdemo/wxScrolledWindow.rbw +201 -201
- data/samples/bigdemo/wxSingleChoiceDialog.rbw +35 -35
- data/samples/bigdemo/wxSlider.rbw +44 -44
- data/samples/bigdemo/wxSpinButton.rbw +52 -52
- data/samples/bigdemo/wxSpinCtrl.rbw +53 -53
- data/samples/bigdemo/wxSplitterWindow.rbw +65 -65
- data/samples/bigdemo/wxStaticBitmap.rbw +53 -53
- data/samples/bigdemo/wxStaticText.rbw +57 -57
- data/samples/bigdemo/wxStatusBar.rbw +128 -128
- data/samples/bigdemo/wxTextCtrl.rbw +151 -151
- data/samples/bigdemo/wxTextEntryDialog.rbw +34 -34
- data/samples/bigdemo/wxToggleButton.rbw +51 -51
- data/samples/bigdemo/wxToolBar.rbw +133 -133
- data/samples/bigdemo/wxTreeCtrl.rbw +192 -192
- data/samples/calendar/calendar.rb +275 -275
- data/samples/caret/caret.rb +286 -286
- data/samples/caret/mondrian.xpm +44 -44
- data/samples/controls/controls.rb +1140 -1140
- 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 +724 -724
- data/samples/dialogs/tips.txt +18 -18
- data/samples/drawing/graphics_drawing.rb +232 -0
- data/samples/{images → drawing}/images.rb +48 -48
- data/samples/{images → drawing}/paperclip.png +0 -0
- data/samples/etc/activation.rb +108 -108
- data/samples/etc/choice.rb +72 -72
- data/samples/etc/miniframe.rb +84 -84
- data/samples/etc/sash.rb +135 -135
- data/samples/etc/scrollwin.rb +116 -116
- data/samples/etc/system_settings.rb +258 -258
- data/samples/etc/wizard.rb +79 -79
- data/samples/grid/grid.rb +1 -0
- data/samples/listbook/listbook.rb +181 -181
- data/samples/listbook/listbook.xrc +370 -370
- data/samples/mdi/mdi.rb +87 -87
- data/samples/media/mediactrl.rb +173 -0
- data/samples/minimal/minimal.rb +85 -85
- data/samples/minimal/nothing.rb +21 -21
- data/samples/opengl/cube.rb +123 -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/textctrl.rb +124 -124
- data/samples/text/unicode.rb +238 -238
- data/samples/text/utf8.txt +14 -14
- data/samples/treectrl/treectrl.rb +1180 -1181
- data/samples/xrc/samples.xrc +46 -46
- data/samples/xrc/xrc_sample.rb +107 -107
- metadata +26 -9
- data/samples/images/Thumbs.db +0 -0
data/samples/etc/wizard.rb
CHANGED
@@ -1,79 +1,79 @@
|
|
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
|
-
|
16
|
-
class MyFrame < Wx::Frame
|
17
|
-
def initialize(title, pos, size)
|
18
|
-
super(nil, :title => title, :position => pos, :size => size)
|
19
|
-
|
20
|
-
menuFile = Wx::Menu.new
|
21
|
-
helpMenu = Wx::Menu.new
|
22
|
-
helpMenu.append(Wx::ID_ABOUT, "&About...\tF1", "Show about dialog")
|
23
|
-
menuFile.append(Wx::ID_EXIT, "E&xit\tAlt-X", "Quit this program")
|
24
|
-
menuBar = Wx::MenuBar.new
|
25
|
-
menuBar.append(menuFile, "&File")
|
26
|
-
menuBar.append(helpMenu, "&Help")
|
27
|
-
self.menu_bar = menuBar
|
28
|
-
|
29
|
-
create_status_bar(1)
|
30
|
-
self.status_text = "Welcome to wxRuby!"
|
31
|
-
s = Wx::StaticText.new(self, :label => 'The Wizard has completed')
|
32
|
-
evt_menu Wx::ID_EXIT, :on_quit
|
33
|
-
evt_menu Wx::ID_ABOUT, :on_about
|
34
|
-
|
35
|
-
w = Wx::Wizard.new(self, :title => 'The WxRuby Wizard')
|
36
|
-
p1 = Wx::WizardPageSimple.new(w)
|
37
|
-
s = Wx::StaticText.new(p1, :label => 'This is the first page')
|
38
|
-
|
39
|
-
p2 = Wx::WizardPageSimple.new(w, p1)
|
40
|
-
p1.set_next(p2)
|
41
|
-
s = Wx::StaticText.new(p2, :label => 'This is the second page')
|
42
|
-
|
43
|
-
p3 = Wx::WizardPageSimple.new(w, p2)
|
44
|
-
p2.set_next(p3)
|
45
|
-
s = Wx::StaticText.new(p3, :label => 'This is the final page')
|
46
|
-
|
47
|
-
evt_wizard_page_changed(w) { p "page changed" }
|
48
|
-
evt_wizard_page_changing(w) { p "page changing" }
|
49
|
-
evt_wizard_help(w) { p "wizard help" }
|
50
|
-
evt_wizard_cancel(w) { p "wizard cancelled" }
|
51
|
-
evt_wizard_finished(w) { p "wizard finished" }
|
52
|
-
|
53
|
-
w.run_wizard(p1)
|
54
|
-
end
|
55
|
-
|
56
|
-
def on_quit
|
57
|
-
close(true)
|
58
|
-
end
|
59
|
-
|
60
|
-
def on_about
|
61
|
-
msg = sprintf("This is the About dialog of the wizard sample.\n" \
|
62
|
-
"Welcome to %s", Wx::VERSION_STRING)
|
63
|
-
Wx::message_box(msg, "About Wizard", Wx::OK|Wx::ICON_INFORMATION, self)
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
class RbApp < Wx::App
|
68
|
-
def on_init
|
69
|
-
frame = MyFrame.new("Wizard wxRuby App",
|
70
|
-
Wx::Point.new(50, 50),
|
71
|
-
Wx::Size.new(450, 340))
|
72
|
-
frame.show(true)
|
73
|
-
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
app = RbApp.new
|
78
|
-
app.main_loop()
|
79
|
-
|
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
|
+
|
16
|
+
class MyFrame < Wx::Frame
|
17
|
+
def initialize(title, pos, size)
|
18
|
+
super(nil, :title => title, :position => pos, :size => size)
|
19
|
+
|
20
|
+
menuFile = Wx::Menu.new
|
21
|
+
helpMenu = Wx::Menu.new
|
22
|
+
helpMenu.append(Wx::ID_ABOUT, "&About...\tF1", "Show about dialog")
|
23
|
+
menuFile.append(Wx::ID_EXIT, "E&xit\tAlt-X", "Quit this program")
|
24
|
+
menuBar = Wx::MenuBar.new
|
25
|
+
menuBar.append(menuFile, "&File")
|
26
|
+
menuBar.append(helpMenu, "&Help")
|
27
|
+
self.menu_bar = menuBar
|
28
|
+
|
29
|
+
create_status_bar(1)
|
30
|
+
self.status_text = "Welcome to wxRuby!"
|
31
|
+
s = Wx::StaticText.new(self, :label => 'The Wizard has completed')
|
32
|
+
evt_menu Wx::ID_EXIT, :on_quit
|
33
|
+
evt_menu Wx::ID_ABOUT, :on_about
|
34
|
+
|
35
|
+
w = Wx::Wizard.new(self, :title => 'The WxRuby Wizard')
|
36
|
+
p1 = Wx::WizardPageSimple.new(w)
|
37
|
+
s = Wx::StaticText.new(p1, :label => 'This is the first page')
|
38
|
+
|
39
|
+
p2 = Wx::WizardPageSimple.new(w, p1)
|
40
|
+
p1.set_next(p2)
|
41
|
+
s = Wx::StaticText.new(p2, :label => 'This is the second page')
|
42
|
+
|
43
|
+
p3 = Wx::WizardPageSimple.new(w, p2)
|
44
|
+
p2.set_next(p3)
|
45
|
+
s = Wx::StaticText.new(p3, :label => 'This is the final page')
|
46
|
+
|
47
|
+
evt_wizard_page_changed(w) { p "page changed" }
|
48
|
+
evt_wizard_page_changing(w) { p "page changing" }
|
49
|
+
evt_wizard_help(w) { p "wizard help" }
|
50
|
+
evt_wizard_cancel(w) { p "wizard cancelled" }
|
51
|
+
evt_wizard_finished(w) { p "wizard finished" }
|
52
|
+
|
53
|
+
w.run_wizard(p1)
|
54
|
+
end
|
55
|
+
|
56
|
+
def on_quit
|
57
|
+
close(true)
|
58
|
+
end
|
59
|
+
|
60
|
+
def on_about
|
61
|
+
msg = sprintf("This is the About dialog of the wizard sample.\n" \
|
62
|
+
"Welcome to %s", Wx::VERSION_STRING)
|
63
|
+
Wx::message_box(msg, "About Wizard", Wx::OK|Wx::ICON_INFORMATION, self)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
class RbApp < Wx::App
|
68
|
+
def on_init
|
69
|
+
frame = MyFrame.new("Wizard wxRuby App",
|
70
|
+
Wx::Point.new(50, 50),
|
71
|
+
Wx::Size.new(450, 340))
|
72
|
+
frame.show(true)
|
73
|
+
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
app = RbApp.new
|
78
|
+
app.main_loop()
|
79
|
+
|
data/samples/grid/grid.rb
CHANGED
@@ -181,6 +181,7 @@ class GridFrame < Wx::Frame
|
|
181
181
|
@grid.auto_size_row(3, true)
|
182
182
|
|
183
183
|
# Display of cells can be customised
|
184
|
+
@grid.set_cell_editor(6, 0, Wx::GridCellBoolEditor.new)
|
184
185
|
@grid.set_cell_renderer(6, 0, Wx::GridCellBoolRenderer.new)
|
185
186
|
@grid.set_cell_value(6, 1, 'Cell to the left displayed as boolean')
|
186
187
|
end
|
@@ -1,181 +1,181 @@
|
|
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
|
-
|
16
|
-
#
|
17
|
-
# Basic Frame Class. This creates the dialog window
|
18
|
-
#
|
19
|
-
class SimpleFrame < Wx::Frame
|
20
|
-
|
21
|
-
FILE_DIALOG, FILE_ABOUT, FILE_QUIT = [0,Wx::ID_ABOUT,Wx::ID_EXIT]
|
22
|
-
|
23
|
-
def initialize(parent)
|
24
|
-
# To load a layout defined in XRC into a Ruby subclass of Frame,
|
25
|
-
# first call the empty constructor. All the details of size,
|
26
|
-
# title, position and so on are loaded from the XRC by the call to
|
27
|
-
# load_frame_subclass. Using a non-empty constructor will cause
|
28
|
-
# errors on GTK.
|
29
|
-
super()
|
30
|
-
$xml.load_frame_subclass(self,nil,'ID_FRAME')
|
31
|
-
|
32
|
-
# Create a new menu
|
33
|
-
bar = Wx::MenuBar.new
|
34
|
-
menu = Wx::Menu.new
|
35
|
-
menu.append(FILE_ABOUT,"About...")
|
36
|
-
menu.append_separator
|
37
|
-
menu.append(FILE_QUIT,"Quit")
|
38
|
-
bar.append(menu,"File")
|
39
|
-
|
40
|
-
set_menu_bar(bar)
|
41
|
-
|
42
|
-
# Assign the menu events
|
43
|
-
evt_menu(FILE_ABOUT) do
|
44
|
-
Wx::message_box("wxRuby Listbook sample\nby Sean Long", "About Listbook", Wx::OK | Wx::ICON_INFORMATION, self)
|
45
|
-
end
|
46
|
-
evt_menu(FILE_QUIT) do
|
47
|
-
Wx::get_app.exit_main_loop()
|
48
|
-
end
|
49
|
-
evt_close() do
|
50
|
-
Wx::get_app.exit_main_loop()
|
51
|
-
end
|
52
|
-
|
53
|
-
# Variables not in tabs
|
54
|
-
@listbook = xrcid_to_window('ID_LISTBOOK')
|
55
|
-
@text_output = xrcid_to_window('ID_ORDER_TEXTCTRL')
|
56
|
-
|
57
|
-
# Variables for widgets in Pizza tab
|
58
|
-
@pizza_size = xrcid_to_window('ID_PIZZA_SIZE_CHOICE')
|
59
|
-
@pizza_crust = xrcid_to_window('ID_PIZZA_CRUST_CHOICE')
|
60
|
-
@pizza_sauce = xrcid_to_window('ID_PIZZA_SAUCE_CHOICE')
|
61
|
-
@pizza_cheese = xrcid_to_window('ID_PIZZA_CHEESE_CHOICE')
|
62
|
-
@pizza_toppings = []
|
63
|
-
3.times do |i|
|
64
|
-
@pizza_toppings << xrcid_to_window("ID_PIZZA_TOPPING_#{i+1}_CHOICE")
|
65
|
-
end
|
66
|
-
|
67
|
-
# fill in toppings
|
68
|
-
toppings = ['pepperoni','sausage','italian sausage','olives',
|
69
|
-
'mushrooms','artichoke','extra cheese','']
|
70
|
-
toppings.each do |top_name|
|
71
|
-
@pizza_toppings.each do |top_obj|
|
72
|
-
top_obj.append(top_name)
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
index = 0
|
77
|
-
@pizza_toppings.each do |obj|
|
78
|
-
obj.set_selection(index)
|
79
|
-
index += 1
|
80
|
-
end
|
81
|
-
|
82
|
-
# Events for pizza tab
|
83
|
-
evt_button( Wx::xrcid('ID_PIZZA_BUTTON') ) do |event|
|
84
|
-
#get selections and add to order
|
85
|
-
order_string = @text_output.get_value
|
86
|
-
if order_string != "" then order_string << "\n" end
|
87
|
-
order_string << "One #{@pizza_size.get_string_selection} pizza with:\n"
|
88
|
-
order_string << @pizza_crust.get_string_selection + " crust" + "\n"
|
89
|
-
order_string << @pizza_sauce.get_string_selection + " sauce" +"\n"
|
90
|
-
order_string << @pizza_cheese.get_string_selection + " and" + "\n"
|
91
|
-
@pizza_toppings.each { |obj| order_string << obj.get_string_selection + "\n" }
|
92
|
-
|
93
|
-
@text_output.set_value(order_string)
|
94
|
-
end
|
95
|
-
|
96
|
-
|
97
|
-
# Variables for widgets in Drink tab
|
98
|
-
@drink_size = xrcid_to_window('ID_DRINK_SIZE_CHOICE')
|
99
|
-
@drink_type = xrcid_to_window('ID_DRINK_TYPE_CHOICE')
|
100
|
-
|
101
|
-
# Events for drink tab
|
102
|
-
evt_button(Wx::xrcid('ID_DRINK_BUTTON')) do |event|
|
103
|
-
#get selections and add to order
|
104
|
-
order_string = @text_output.get_value
|
105
|
-
if order_string != "" then order_string << "\n" end
|
106
|
-
|
107
|
-
order_string << "One #{@drink_size.get_string_selection} #{@drink_type.get_string_selection }.\n"
|
108
|
-
|
109
|
-
@text_output.set_value(order_string)
|
110
|
-
end
|
111
|
-
|
112
|
-
# Variables for widgets in Ice Cream tab
|
113
|
-
@ice_cream_size = xrcid_to_window('ID_ICE_CREAM_SIZE_CHOICE')
|
114
|
-
@ice_cream_type = xrcid_to_window('ID_ICE_CREAM_TYPE_CHOICE')
|
115
|
-
@ice_cream_toppings = []
|
116
|
-
4.times do |i|
|
117
|
-
@ice_cream_toppings <<
|
118
|
-
xrcid_to_window("ID_ICE_CREAM_TOPPING_#{i+1}_CHOICE")
|
119
|
-
end
|
120
|
-
|
121
|
-
toppings = ['','m&m\'s','chocolate chips','fudge','nuts','cherry','whip cream']
|
122
|
-
toppings.each do |top_name|
|
123
|
-
@ice_cream_toppings.each do |top_obj|
|
124
|
-
top_obj.append(top_name)
|
125
|
-
end
|
126
|
-
end
|
127
|
-
@ice_cream_toppings.each { |obj| obj.set_selection(0) }
|
128
|
-
|
129
|
-
# Events for ice cream tab
|
130
|
-
evt_button(Wx::xrcid('ID_ICE_CREAM_BUTTON')) do |event|
|
131
|
-
#get selections and add to order
|
132
|
-
order_string = @text_output.get_value
|
133
|
-
if order_string != "" then order_string << "\n" end
|
134
|
-
|
135
|
-
order_string << "One #{@ice_cream_size.get_string_selection} #{@ice_cream_type.get_string_selection} ice cream:\n"
|
136
|
-
@ice_cream_toppings.each { |obj| order_string << obj.get_string_selection + "\n" }
|
137
|
-
|
138
|
-
@text_output.set_value(order_string)
|
139
|
-
end
|
140
|
-
|
141
|
-
evt_listbook_page_changed(Wx::xrcid('ID_LISTBOOK')) do |event|
|
142
|
-
tab_number = event.get_selection
|
143
|
-
order_string = @text_output.get_value
|
144
|
-
order_string << "moved to tab = #{@listbook.get_page_text(tab_number)} \n"
|
145
|
-
@text_output.set_value(order_string)
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
# Converts a XRCID id - as used in wxWidget's XML format - into the
|
150
|
-
# correct ruby window
|
151
|
-
def xrcid_to_window(xrc_id)
|
152
|
-
Wx::Window.find_window_by_id(Wx::xrcid(xrc_id), self)
|
153
|
-
end
|
154
|
-
|
155
|
-
end
|
156
|
-
|
157
|
-
#
|
158
|
-
# Application class.
|
159
|
-
#
|
160
|
-
class XrcApp < Wx::App
|
161
|
-
|
162
|
-
def on_init
|
163
|
-
# Create a resource handler
|
164
|
-
$xml = Wx::XmlResource.get();
|
165
|
-
$xml.init_all_handlers();
|
166
|
-
|
167
|
-
# Load a resource file from the script's directory
|
168
|
-
xrc_file = File.join( File.dirname( __FILE__ ), 'listbook.xrc' )
|
169
|
-
|
170
|
-
$xml.load(xrc_file)
|
171
|
-
|
172
|
-
|
173
|
-
# Show the main frame.
|
174
|
-
$main = SimpleFrame.new(self)
|
175
|
-
$main.show(true)
|
176
|
-
|
177
|
-
end
|
178
|
-
end
|
179
|
-
|
180
|
-
|
181
|
-
XrcApp.new().main_loop()
|
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
|
+
|
16
|
+
#
|
17
|
+
# Basic Frame Class. This creates the dialog window
|
18
|
+
#
|
19
|
+
class SimpleFrame < Wx::Frame
|
20
|
+
|
21
|
+
FILE_DIALOG, FILE_ABOUT, FILE_QUIT = [0,Wx::ID_ABOUT,Wx::ID_EXIT]
|
22
|
+
|
23
|
+
def initialize(parent)
|
24
|
+
# To load a layout defined in XRC into a Ruby subclass of Frame,
|
25
|
+
# first call the empty constructor. All the details of size,
|
26
|
+
# title, position and so on are loaded from the XRC by the call to
|
27
|
+
# load_frame_subclass. Using a non-empty constructor will cause
|
28
|
+
# errors on GTK.
|
29
|
+
super()
|
30
|
+
$xml.load_frame_subclass(self,nil,'ID_FRAME')
|
31
|
+
|
32
|
+
# Create a new menu
|
33
|
+
bar = Wx::MenuBar.new
|
34
|
+
menu = Wx::Menu.new
|
35
|
+
menu.append(FILE_ABOUT,"About...")
|
36
|
+
menu.append_separator
|
37
|
+
menu.append(FILE_QUIT,"Quit")
|
38
|
+
bar.append(menu,"File")
|
39
|
+
|
40
|
+
set_menu_bar(bar)
|
41
|
+
|
42
|
+
# Assign the menu events
|
43
|
+
evt_menu(FILE_ABOUT) do
|
44
|
+
Wx::message_box("wxRuby Listbook sample\nby Sean Long", "About Listbook", Wx::OK | Wx::ICON_INFORMATION, self)
|
45
|
+
end
|
46
|
+
evt_menu(FILE_QUIT) do
|
47
|
+
Wx::get_app.exit_main_loop()
|
48
|
+
end
|
49
|
+
evt_close() do
|
50
|
+
Wx::get_app.exit_main_loop()
|
51
|
+
end
|
52
|
+
|
53
|
+
# Variables not in tabs
|
54
|
+
@listbook = xrcid_to_window('ID_LISTBOOK')
|
55
|
+
@text_output = xrcid_to_window('ID_ORDER_TEXTCTRL')
|
56
|
+
|
57
|
+
# Variables for widgets in Pizza tab
|
58
|
+
@pizza_size = xrcid_to_window('ID_PIZZA_SIZE_CHOICE')
|
59
|
+
@pizza_crust = xrcid_to_window('ID_PIZZA_CRUST_CHOICE')
|
60
|
+
@pizza_sauce = xrcid_to_window('ID_PIZZA_SAUCE_CHOICE')
|
61
|
+
@pizza_cheese = xrcid_to_window('ID_PIZZA_CHEESE_CHOICE')
|
62
|
+
@pizza_toppings = []
|
63
|
+
3.times do |i|
|
64
|
+
@pizza_toppings << xrcid_to_window("ID_PIZZA_TOPPING_#{i+1}_CHOICE")
|
65
|
+
end
|
66
|
+
|
67
|
+
# fill in toppings
|
68
|
+
toppings = ['pepperoni','sausage','italian sausage','olives',
|
69
|
+
'mushrooms','artichoke','extra cheese','']
|
70
|
+
toppings.each do |top_name|
|
71
|
+
@pizza_toppings.each do |top_obj|
|
72
|
+
top_obj.append(top_name)
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
index = 0
|
77
|
+
@pizza_toppings.each do |obj|
|
78
|
+
obj.set_selection(index)
|
79
|
+
index += 1
|
80
|
+
end
|
81
|
+
|
82
|
+
# Events for pizza tab
|
83
|
+
evt_button( Wx::xrcid('ID_PIZZA_BUTTON') ) do |event|
|
84
|
+
#get selections and add to order
|
85
|
+
order_string = @text_output.get_value
|
86
|
+
if order_string != "" then order_string << "\n" end
|
87
|
+
order_string << "One #{@pizza_size.get_string_selection} pizza with:\n"
|
88
|
+
order_string << @pizza_crust.get_string_selection + " crust" + "\n"
|
89
|
+
order_string << @pizza_sauce.get_string_selection + " sauce" +"\n"
|
90
|
+
order_string << @pizza_cheese.get_string_selection + " and" + "\n"
|
91
|
+
@pizza_toppings.each { |obj| order_string << obj.get_string_selection + "\n" }
|
92
|
+
|
93
|
+
@text_output.set_value(order_string)
|
94
|
+
end
|
95
|
+
|
96
|
+
|
97
|
+
# Variables for widgets in Drink tab
|
98
|
+
@drink_size = xrcid_to_window('ID_DRINK_SIZE_CHOICE')
|
99
|
+
@drink_type = xrcid_to_window('ID_DRINK_TYPE_CHOICE')
|
100
|
+
|
101
|
+
# Events for drink tab
|
102
|
+
evt_button(Wx::xrcid('ID_DRINK_BUTTON')) do |event|
|
103
|
+
#get selections and add to order
|
104
|
+
order_string = @text_output.get_value
|
105
|
+
if order_string != "" then order_string << "\n" end
|
106
|
+
|
107
|
+
order_string << "One #{@drink_size.get_string_selection} #{@drink_type.get_string_selection }.\n"
|
108
|
+
|
109
|
+
@text_output.set_value(order_string)
|
110
|
+
end
|
111
|
+
|
112
|
+
# Variables for widgets in Ice Cream tab
|
113
|
+
@ice_cream_size = xrcid_to_window('ID_ICE_CREAM_SIZE_CHOICE')
|
114
|
+
@ice_cream_type = xrcid_to_window('ID_ICE_CREAM_TYPE_CHOICE')
|
115
|
+
@ice_cream_toppings = []
|
116
|
+
4.times do |i|
|
117
|
+
@ice_cream_toppings <<
|
118
|
+
xrcid_to_window("ID_ICE_CREAM_TOPPING_#{i+1}_CHOICE")
|
119
|
+
end
|
120
|
+
|
121
|
+
toppings = ['','m&m\'s','chocolate chips','fudge','nuts','cherry','whip cream']
|
122
|
+
toppings.each do |top_name|
|
123
|
+
@ice_cream_toppings.each do |top_obj|
|
124
|
+
top_obj.append(top_name)
|
125
|
+
end
|
126
|
+
end
|
127
|
+
@ice_cream_toppings.each { |obj| obj.set_selection(0) }
|
128
|
+
|
129
|
+
# Events for ice cream tab
|
130
|
+
evt_button(Wx::xrcid('ID_ICE_CREAM_BUTTON')) do |event|
|
131
|
+
#get selections and add to order
|
132
|
+
order_string = @text_output.get_value
|
133
|
+
if order_string != "" then order_string << "\n" end
|
134
|
+
|
135
|
+
order_string << "One #{@ice_cream_size.get_string_selection} #{@ice_cream_type.get_string_selection} ice cream:\n"
|
136
|
+
@ice_cream_toppings.each { |obj| order_string << obj.get_string_selection + "\n" }
|
137
|
+
|
138
|
+
@text_output.set_value(order_string)
|
139
|
+
end
|
140
|
+
|
141
|
+
evt_listbook_page_changed(Wx::xrcid('ID_LISTBOOK')) do |event|
|
142
|
+
tab_number = event.get_selection
|
143
|
+
order_string = @text_output.get_value
|
144
|
+
order_string << "moved to tab = #{@listbook.get_page_text(tab_number)} \n"
|
145
|
+
@text_output.set_value(order_string)
|
146
|
+
end
|
147
|
+
end
|
148
|
+
|
149
|
+
# Converts a XRCID id - as used in wxWidget's XML format - into the
|
150
|
+
# correct ruby window
|
151
|
+
def xrcid_to_window(xrc_id)
|
152
|
+
Wx::Window.find_window_by_id(Wx::xrcid(xrc_id), self)
|
153
|
+
end
|
154
|
+
|
155
|
+
end
|
156
|
+
|
157
|
+
#
|
158
|
+
# Application class.
|
159
|
+
#
|
160
|
+
class XrcApp < Wx::App
|
161
|
+
|
162
|
+
def on_init
|
163
|
+
# Create a resource handler
|
164
|
+
$xml = Wx::XmlResource.get();
|
165
|
+
$xml.init_all_handlers();
|
166
|
+
|
167
|
+
# Load a resource file from the script's directory
|
168
|
+
xrc_file = File.join( File.dirname( __FILE__ ), 'listbook.xrc' )
|
169
|
+
|
170
|
+
$xml.load(xrc_file)
|
171
|
+
|
172
|
+
|
173
|
+
# Show the main frame.
|
174
|
+
$main = SimpleFrame.new(self)
|
175
|
+
$main.show(true)
|
176
|
+
|
177
|
+
end
|
178
|
+
end
|
179
|
+
|
180
|
+
|
181
|
+
XrcApp.new().main_loop()
|