wxruby-ruby19 1.9.8-x86-darwin-9 → 1.9.10-x86-darwin-9
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +53 -0
- data/README +297 -0
- data/lib/wx.rb +2 -2
- data/lib/wx/accessors.rb +7 -1
- data/lib/wx/classes/app.rb +10 -4
- 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 +79 -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 +63 -0
- data/lib/wx/classes/size.rb +9 -0
- data/lib/wx/classes/sizer.rb +18 -3
- data/lib/wx/classes/standardpaths.rb +9 -0
- data/lib/wx/classes/texturlevent.rb +14 -2
- 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 +56 -5
- data/lib/wx/version.rb +1 -1
- data/lib/wxruby2.bundle +0 -0
- data/samples/SAMPLES-LICENSE.TXT +18 -0
- data/samples/aui/aui.rb +1356 -0
- data/samples/bigdemo/About.rbw +39 -0
- data/samples/bigdemo/ColorPanel.rbw +23 -0
- data/samples/bigdemo/GridSimple.rbw +78 -0
- data/samples/bigdemo/MDIDemo.rbw +57 -0
- data/samples/bigdemo/PopupMenu.rbw +149 -0
- data/samples/bigdemo/ShapedWindow.rbw +131 -0
- data/samples/bigdemo/Sizers.rbw +543 -0
- data/samples/bigdemo/bigdemo.rb +823 -0
- data/samples/bigdemo/demoTemplate.rbw +33 -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 +90 -0
- data/samples/bigdemo/tips.txt +7 -0
- data/samples/bigdemo/utils.rb +12 -0
- data/samples/bigdemo/wxArtProvider.rbw +281 -0
- data/samples/bigdemo/wxBitmapButton.rbw +65 -0
- data/samples/bigdemo/wxButton.rbw +64 -0
- data/samples/bigdemo/wxCalendarCtrl.rbw +60 -0
- data/samples/bigdemo/wxCheckBox.rbw +50 -0
- data/samples/bigdemo/wxCheckListBox.rbw +65 -0
- data/samples/bigdemo/wxChoice.rbw +47 -0
- data/samples/bigdemo/wxChoicebook.rbw +78 -0
- data/samples/bigdemo/wxColourDialog.rbw +31 -0
- data/samples/bigdemo/wxComboBox.rbw +77 -0
- data/samples/bigdemo/wxCursor.rbw +136 -0
- data/samples/bigdemo/wxDialog.rbw +74 -0
- data/samples/bigdemo/wxDirDialog.rbw +29 -0
- data/samples/bigdemo/wxDragImage.rbw +70 -0
- data/samples/bigdemo/wxFileDialog.rbw +37 -0
- data/samples/bigdemo/wxFileDialog_Save.rbw +35 -0
- data/samples/bigdemo/wxFindReplaceDialog.rbw +82 -0
- data/samples/bigdemo/wxFontDialog.rbw +173 -0
- data/samples/bigdemo/wxFrame.rbw +53 -0
- data/samples/bigdemo/wxGauge.rbw +71 -0
- data/samples/bigdemo/wxGenericDirCtrl.rbw +74 -0
- data/samples/bigdemo/wxGrid.rbw +66 -0
- data/samples/bigdemo/wxHtmlHelpController.rbw +52 -0
- data/samples/bigdemo/wxListBox.rbw +140 -0
- data/samples/bigdemo/wxListCtrl_virtual.rbw +112 -0
- data/samples/bigdemo/wxMDIWindows.rbw +50 -0
- data/samples/bigdemo/wxMenu.rbw +236 -0
- data/samples/bigdemo/wxMessageDialog.rbw +27 -0
- data/samples/bigdemo/wxMiniFrame.rbw +70 -0
- data/samples/bigdemo/wxMultipleChoiceDialog.rbw +32 -0
- data/samples/bigdemo/wxNotebook.rbw +136 -0
- data/samples/bigdemo/wxProgressDialog.rbw +43 -0
- data/samples/bigdemo/wxRadioBox.rbw +72 -0
- data/samples/bigdemo/wxRadioButton.rbw +125 -0
- data/samples/bigdemo/wxSashWindow.rbw +141 -0
- data/samples/bigdemo/wxScrolledMessageDialog.rbw +57 -0
- data/samples/bigdemo/wxScrolledWindow.rbw +199 -0
- data/samples/bigdemo/wxSingleChoiceDialog.rbw +33 -0
- data/samples/bigdemo/wxSlider.rbw +42 -0
- data/samples/bigdemo/wxSpinButton.rbw +50 -0
- data/samples/bigdemo/wxSpinCtrl.rbw +51 -0
- data/samples/bigdemo/wxSplitterWindow.rbw +63 -0
- data/samples/bigdemo/wxStaticBitmap.rbw +51 -0
- data/samples/bigdemo/wxStaticText.rbw +55 -0
- data/samples/bigdemo/wxStatusBar.rbw +126 -0
- data/samples/bigdemo/wxTextCtrl.rbw +149 -0
- data/samples/bigdemo/wxTextEntryDialog.rbw +31 -0
- data/samples/bigdemo/wxToggleButton.rbw +49 -0
- data/samples/bigdemo/wxToolBar.rbw +131 -0
- data/samples/bigdemo/wxTreeCtrl.rbw +191 -0
- data/samples/calendar/calendar.rb +256 -0
- data/samples/caret/caret.rb +282 -0
- data/samples/caret/mondrian.xpm +44 -0
- data/samples/controls/controls.rb +1136 -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 +797 -0
- data/samples/dialogs/tips.txt +18 -0
- data/samples/dragdrop/dragdrop.rb +177 -0
- data/samples/drawing/graphics_drawing.rb +235 -0
- data/samples/drawing/images.rb +37 -0
- data/samples/drawing/paperclip.png +0 -0
- data/samples/etc/activation.rb +102 -0
- data/samples/etc/choice.rb +67 -0
- data/samples/etc/miniframe.rb +79 -0
- data/samples/etc/sash.rb +130 -0
- data/samples/etc/scrollwin.rb +110 -0
- data/samples/etc/system_settings.rb +252 -0
- data/samples/etc/threaded.rb +72 -0
- data/samples/etc/toolbar_sizer_additem.rb +55 -0
- data/samples/etc/wizard.rb +74 -0
- data/samples/event/event.rb +182 -0
- data/samples/event/update_ui_event.rb +70 -0
- data/samples/grid/grid.rb +198 -0
- data/samples/grid/gridtablebase.rb +148 -0
- data/samples/html/html.rb +262 -0
- data/samples/listbook/listbook.rb +174 -0
- data/samples/listbook/listbook.xrc +370 -0
- data/samples/mdi/mdi.rb +85 -0
- data/samples/media/mediactrl.rb +167 -0
- data/samples/minimal/minimal.rb +77 -0
- data/samples/minimal/mondrian.ico +0 -0
- data/samples/minimal/mondrian.png +0 -0
- data/samples/minimal/nothing.rb +16 -0
- data/samples/opengl/cube.rb +117 -0
- data/samples/printing/mondrian.ico +0 -0
- data/samples/printing/mondrian.xpm +44 -0
- data/samples/printing/printing.rb +487 -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/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/mondrian.ico +0 -0
- data/samples/text/mondrian.xpm +44 -0
- data/samples/text/rich_textctrl.rb +98 -0
- data/samples/text/scintilla.rb +169 -0
- data/samples/text/textctrl.rb +111 -0
- data/samples/text/unicode.rb +242 -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 +1166 -0
- data/samples/xrc/samples.xrc +46 -0
- data/samples/xrc/xrc_sample.rb +76 -0
- metadata +17 -3
@@ -0,0 +1,282 @@
|
|
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
|
+
include Wx
|
12
|
+
|
13
|
+
# menu items
|
14
|
+
Caret_set_blink_time = 3
|
15
|
+
Caret_Move = 4
|
16
|
+
|
17
|
+
# controls start here (the numbers are, of course, arbitrary)
|
18
|
+
Caret_Text = 1000
|
19
|
+
|
20
|
+
|
21
|
+
# MyCanvas is a canvas on which you can type
|
22
|
+
class MyCanvas < ScrolledWindow
|
23
|
+
def initialize(parent)
|
24
|
+
super(parent, :style => SUNKEN_BORDER)
|
25
|
+
|
26
|
+
self.background_colour = WHITE
|
27
|
+
|
28
|
+
@font = Font.new(12, FONTFAMILY_TELETYPE,
|
29
|
+
FONTSTYLE_NORMAL, FONTWEIGHT_NORMAL)
|
30
|
+
|
31
|
+
@x_caret = @y_caret = @x_chars = @y_chars = 0
|
32
|
+
@x_margin = @y_margin = 5
|
33
|
+
@text = nil
|
34
|
+
|
35
|
+
create_caret
|
36
|
+
|
37
|
+
evt_paint :on_paint
|
38
|
+
evt_size :on_size
|
39
|
+
evt_char :on_char
|
40
|
+
end
|
41
|
+
|
42
|
+
def [](x,y)
|
43
|
+
@text[x + @x_chars * y,1]
|
44
|
+
end
|
45
|
+
|
46
|
+
def []=(x,y,z)
|
47
|
+
@text[x + @x_chars * y,1] = z
|
48
|
+
end
|
49
|
+
|
50
|
+
# caret movement
|
51
|
+
def home_pos
|
52
|
+
@x_caret = 0
|
53
|
+
end
|
54
|
+
|
55
|
+
def end_pos
|
56
|
+
@x_caret = @x_chars - 1
|
57
|
+
end
|
58
|
+
|
59
|
+
def first_line
|
60
|
+
@y_caret = 0
|
61
|
+
end
|
62
|
+
|
63
|
+
def last_line
|
64
|
+
@y_caret = @y_chars - 1
|
65
|
+
end
|
66
|
+
|
67
|
+
def prev_char
|
68
|
+
if @x_caret == 0
|
69
|
+
end_pos
|
70
|
+
prev_line
|
71
|
+
else
|
72
|
+
@x_caret -= 1
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def next_char
|
77
|
+
@x_caret += 1
|
78
|
+
if @x_caret == @x_chars
|
79
|
+
home_pos
|
80
|
+
next_line
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def prev_line
|
85
|
+
if @y_caret == 0
|
86
|
+
last_line
|
87
|
+
else
|
88
|
+
@y_caret -= 1
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
def next_line
|
93
|
+
@y_caret += 1
|
94
|
+
if @y_caret == @y_chars
|
95
|
+
first_line
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
def create_caret
|
100
|
+
paint do | dc |
|
101
|
+
dc.font = @font
|
102
|
+
@height_char = dc.char_height
|
103
|
+
@width_char = dc.char_width
|
104
|
+
|
105
|
+
my_caret = Caret.new(self, Size.new(@width_char, @height_char))
|
106
|
+
self.caret = my_caret
|
107
|
+
|
108
|
+
caret.move [ @x_margin, @y_margin ]
|
109
|
+
caret.show
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
def move_caret(x,y)
|
114
|
+
@x_caret = x
|
115
|
+
@y_caret = y
|
116
|
+
|
117
|
+
do_move_caret
|
118
|
+
end
|
119
|
+
|
120
|
+
def do_move_caret
|
121
|
+
log_status("Caret is at (%d, %d)", @x_caret, @y_caret)
|
122
|
+
|
123
|
+
caret.move_xy( @x_margin + @x_caret * @width_char,
|
124
|
+
@y_margin + @y_caret * @height_char)
|
125
|
+
end
|
126
|
+
|
127
|
+
def on_size(event)
|
128
|
+
@x_chars = (event.size.x - 2 * @x_margin) / @width_char
|
129
|
+
@y_chars = (event.size.y - 2 * @y_margin) / @height_char
|
130
|
+
if @x_chars <= 0
|
131
|
+
@x_chars = 1
|
132
|
+
end
|
133
|
+
if @y_chars <= 0
|
134
|
+
@y_chars = 1
|
135
|
+
end
|
136
|
+
if @x_caret >= @x_chars
|
137
|
+
@x_caret = @x_chars-1
|
138
|
+
end
|
139
|
+
if @y_caret >= @y_chars
|
140
|
+
@y_caret = @y_chars-1
|
141
|
+
end
|
142
|
+
|
143
|
+
@text = " " * @x_chars * @y_chars
|
144
|
+
|
145
|
+
if parent && parent.status_bar
|
146
|
+
msg = sprintf("Panel size is (%d, %d)", @x_chars, @y_chars)
|
147
|
+
parent.set_status_text(msg, 1)
|
148
|
+
parent.refresh
|
149
|
+
end
|
150
|
+
event.skip
|
151
|
+
end
|
152
|
+
|
153
|
+
def on_paint
|
154
|
+
if caret
|
155
|
+
caret.hide
|
156
|
+
end
|
157
|
+
|
158
|
+
paint do | dc |
|
159
|
+
dc.clear
|
160
|
+
dc.set_font(@font)
|
161
|
+
|
162
|
+
for y in 0 ... @y_chars
|
163
|
+
line = @text[@x_chars * y,@x_chars]
|
164
|
+
dc.draw_text( line, @x_margin, @y_margin + y * @height_char )
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
if caret
|
169
|
+
caret.show
|
170
|
+
end
|
171
|
+
end
|
172
|
+
|
173
|
+
def on_char(event)
|
174
|
+
case event.key_code
|
175
|
+
when K_LEFT, K_BACK
|
176
|
+
prev_char
|
177
|
+
when K_RIGHT
|
178
|
+
next_char
|
179
|
+
when K_UP
|
180
|
+
prev_line
|
181
|
+
when K_DOWN
|
182
|
+
next_line
|
183
|
+
when K_HOME
|
184
|
+
home_pos
|
185
|
+
when K_END
|
186
|
+
end_pos
|
187
|
+
when K_RETURN
|
188
|
+
home_pos
|
189
|
+
next_line
|
190
|
+
else
|
191
|
+
ch = event.key_code
|
192
|
+
if !event.alt_down and (ch >= K_SPACE) and (ch < K_DELETE)
|
193
|
+
self[@x_caret, @y_caret] = ch.chr
|
194
|
+
refresh
|
195
|
+
next_char
|
196
|
+
else
|
197
|
+
event.skip
|
198
|
+
end
|
199
|
+
end
|
200
|
+
do_move_caret
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
class MyFrame < Frame
|
205
|
+
def initialize(title, pos, size)
|
206
|
+
super(nil, -1, title, pos, size)
|
207
|
+
# set the frame icon
|
208
|
+
icon_file = File.join(File.dirname(__FILE__), 'mondrian.xpm')
|
209
|
+
self.icon = Icon.new(icon_file, BITMAP_TYPE_XPM)
|
210
|
+
|
211
|
+
# create a menu bar
|
212
|
+
menu_file = Menu.new
|
213
|
+
|
214
|
+
menu_file.append(Caret_set_blink_time, "&Blink time...\tCtrl-B")
|
215
|
+
menu_file.append(Caret_Move, "&Move caret\tCtrl-C")
|
216
|
+
menu_file.append_separator
|
217
|
+
menu_file.append(Wx::ID_ABOUT, "&About...\tCtrl-A", "Show about dialog")
|
218
|
+
menu_file.append_separator
|
219
|
+
menu_file.append(Wx::ID_EXIT, "E&xit\tAlt-X", "Quit self program")
|
220
|
+
|
221
|
+
# now append the freshly created menu to the menu bar...
|
222
|
+
menu_bar = MenuBar.new
|
223
|
+
menu_bar.append(menu_file, "&File")
|
224
|
+
|
225
|
+
# ... and attach self menu bar to the frame
|
226
|
+
self.menu_bar = menu_bar
|
227
|
+
|
228
|
+
@canvas = MyCanvas.new(self)
|
229
|
+
|
230
|
+
# This is required to set focus so that key events are directed to
|
231
|
+
# this Window, on Linux/GTK in particular
|
232
|
+
@canvas.set_focus
|
233
|
+
|
234
|
+
# create a status bar just for fun (by default with 1 pane only)
|
235
|
+
create_status_bar(2)
|
236
|
+
self.status_text = "Welcome to Windows!"
|
237
|
+
|
238
|
+
evt_menu Wx::ID_EXIT, :on_quit
|
239
|
+
evt_menu Wx::ID_ABOUT, :on_about
|
240
|
+
evt_menu Caret_set_blink_time, :on_set_blink_time
|
241
|
+
evt_menu Caret_Move, :on_caret_move
|
242
|
+
end
|
243
|
+
|
244
|
+
def on_quit
|
245
|
+
# true is to force the frame to close
|
246
|
+
close(true)
|
247
|
+
end
|
248
|
+
|
249
|
+
def on_about
|
250
|
+
message_box("The caret Windows sample, adapted for WxRuby",
|
251
|
+
"About Caret", OK | ICON_INFORMATION, self)
|
252
|
+
end
|
253
|
+
|
254
|
+
def on_caret_move
|
255
|
+
@canvas.move_caret(10, 10)
|
256
|
+
end
|
257
|
+
|
258
|
+
def on_set_blink_time
|
259
|
+
blink_time = get_number_from_user(
|
260
|
+
"The caret blink time is the time between two blinks",
|
261
|
+
"Time in milliseconds:",
|
262
|
+
"Caret sample",
|
263
|
+
Caret::get_blink_time, 0, 10000,
|
264
|
+
self)
|
265
|
+
if blink_time != -1
|
266
|
+
Caret::set_blink_time(blink_time)
|
267
|
+
@canvas.create_caret
|
268
|
+
log_status(self,"Blink time set to %d milliseconds.", blink_time)
|
269
|
+
end
|
270
|
+
end
|
271
|
+
end
|
272
|
+
|
273
|
+
class CaretApp < App
|
274
|
+
def on_init
|
275
|
+
frame = MyFrame.new("Caret Windows sample",
|
276
|
+
Point.new(50, 50), Size.new(450, 340))
|
277
|
+
frame.show(true)
|
278
|
+
end
|
279
|
+
end
|
280
|
+
|
281
|
+
a = CaretApp.new
|
282
|
+
a.main_loop
|
@@ -0,0 +1,44 @@
|
|
1
|
+
/* XPM */
|
2
|
+
static char *mondrian_xpm[] = {
|
3
|
+
/* columns rows colors chars-per-pixel */
|
4
|
+
"32 32 6 1",
|
5
|
+
" c Black",
|
6
|
+
". c Blue",
|
7
|
+
"X c #00bf00",
|
8
|
+
"o c Red",
|
9
|
+
"O c Yellow",
|
10
|
+
"+ c Gray100",
|
11
|
+
/* pixels */
|
12
|
+
" ",
|
13
|
+
" oooooo +++++++++++++++++++++++ ",
|
14
|
+
" oooooo +++++++++++++++++++++++ ",
|
15
|
+
" oooooo +++++++++++++++++++++++ ",
|
16
|
+
" oooooo +++++++++++++++++++++++ ",
|
17
|
+
" oooooo +++++++++++++++++++++++ ",
|
18
|
+
" oooooo +++++++++++++++++++++++ ",
|
19
|
+
" oooooo +++++++++++++++++++++++ ",
|
20
|
+
" ",
|
21
|
+
" ++++++ ++++++++++++++++++ .... ",
|
22
|
+
" ++++++ ++++++++++++++++++ .... ",
|
23
|
+
" ++++++ ++++++++++++++++++ .... ",
|
24
|
+
" ++++++ ++++++++++++++++++ .... ",
|
25
|
+
" ++++++ ++++++++++++++++++ .... ",
|
26
|
+
" ++++++ ++++++++++++++++++ ",
|
27
|
+
" ++++++ ++++++++++++++++++ ++++ ",
|
28
|
+
" ++++++ ++++++++++++++++++ ++++ ",
|
29
|
+
" ++++++ ++++++++++++++++++ ++++ ",
|
30
|
+
" ++++++ ++++++++++++++++++ ++++ ",
|
31
|
+
" ++++++ ++++++++++++++++++ ++++ ",
|
32
|
+
" ++++++ ++++++++++++++++++ ++++ ",
|
33
|
+
" ++++++ ++++++++++++++++++ ++++ ",
|
34
|
+
" ++++++ ++++++++++++++++++ ++++ ",
|
35
|
+
" ++++++ ++++++++++++++++++ ++++ ",
|
36
|
+
" ++++++ ++++ ",
|
37
|
+
" ++++++ OOOOOOOOOOOO XXXXX ++++ ",
|
38
|
+
" ++++++ OOOOOOOOOOOO XXXXX ++++ ",
|
39
|
+
" ++++++ OOOOOOOOOOOO XXXXX ++++ ",
|
40
|
+
" ++++++ OOOOOOOOOOOO XXXXX ++++ ",
|
41
|
+
" ++++++ OOOOOOOOOOOO XXXXX ++++ ",
|
42
|
+
" ++++++ OOOOOOOOOOOO XXXXX ++++ ",
|
43
|
+
" "
|
44
|
+
};
|
@@ -0,0 +1,1136 @@
|
|
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
|
+
include Wx
|
12
|
+
|
13
|
+
CONTROLS_QUIT = ID_EXIT
|
14
|
+
CONTROLS_TEXT = 101
|
15
|
+
CONTROLS_ABOUT = ID_ABOUT
|
16
|
+
CONTROLS_CLEAR_LOG = 103
|
17
|
+
# tooltip menu
|
18
|
+
CONTROLS_SET_TOOLTIP_DELAY = 200
|
19
|
+
CONTROLS_ENABLE_TOOLTIPS = 201
|
20
|
+
# panel menu
|
21
|
+
CONTROLS_ENABLE_ALL = 202
|
22
|
+
|
23
|
+
|
24
|
+
ID_NOTEBOOK = 1000
|
25
|
+
|
26
|
+
ID_LISTBOX = 130
|
27
|
+
ID_LISTBOX_SEL_NUM = 131
|
28
|
+
ID_LISTBOX_SEL_STR = 132
|
29
|
+
ID_LISTBOX_CLEAR = 133
|
30
|
+
ID_LISTBOX_APPEND = 134
|
31
|
+
ID_LISTBOX_DELETE = 135
|
32
|
+
ID_LISTBOX_FONT = 136
|
33
|
+
ID_LISTBOX_ENABLE = 137
|
34
|
+
ID_LISTBOX_SORTED = 138
|
35
|
+
|
36
|
+
ID_CHOICE = 120
|
37
|
+
ID_CHOICE_SEL_NUM = 121
|
38
|
+
ID_CHOICE_SEL_STR = 122
|
39
|
+
ID_CHOICE_CLEAR = 123
|
40
|
+
ID_CHOICE_APPEND = 124
|
41
|
+
ID_CHOICE_DELETE = 125
|
42
|
+
ID_CHOICE_FONT = 126
|
43
|
+
ID_CHOICE_ENABLE = 127
|
44
|
+
ID_CHOICE_SORTED = 128
|
45
|
+
|
46
|
+
ID_COMBO = 140
|
47
|
+
ID_COMBO_SEL_NUM = 141
|
48
|
+
ID_COMBO_SEL_STR = 142
|
49
|
+
ID_COMBO_CLEAR = 143
|
50
|
+
ID_COMBO_APPEND = 144
|
51
|
+
ID_COMBO_DELETE = 145
|
52
|
+
ID_COMBO_FONT = 146
|
53
|
+
ID_COMBO_ENABLE = 147
|
54
|
+
|
55
|
+
ID_RADIOBOX = 160
|
56
|
+
ID_RADIOBOX_SEL_NUM = 161
|
57
|
+
ID_RADIOBOX_SEL_STR = 162
|
58
|
+
ID_RADIOBOX_FONT = 163
|
59
|
+
ID_RADIOBOX_ENABLE = 164
|
60
|
+
|
61
|
+
ID_RADIOBUTTON_1 = 166
|
62
|
+
ID_RADIOBUTTON_2 = 167
|
63
|
+
|
64
|
+
ID_SET_FONT = 170
|
65
|
+
|
66
|
+
ID_GAUGE = 180
|
67
|
+
ID_SLIDER = 181
|
68
|
+
|
69
|
+
ID_SPIN = 182
|
70
|
+
ID_BTNPROGRESS = 183
|
71
|
+
ID_BUTTON_LABEL = 184
|
72
|
+
ID_SPINCTRL = 185
|
73
|
+
|
74
|
+
ID_BUTTON_TEST1 = 190
|
75
|
+
ID_BUTTON_TEST2 = 191
|
76
|
+
ID_BITMAP_BTN = 192
|
77
|
+
|
78
|
+
ID_CHANGE_COLOUR = 200
|
79
|
+
|
80
|
+
ID_SIZER_CHECK1 = 201
|
81
|
+
ID_SIZER_CHECK2 = 202
|
82
|
+
ID_SIZER_CHECK3 = 203
|
83
|
+
ID_SIZER_CHECK4 = 204
|
84
|
+
ID_SIZER_CHECK14 = 205
|
85
|
+
ID_SIZER_CHECKBIG = 206
|
86
|
+
|
87
|
+
Image_List, Image_Choice, Image_Combo, Image_Text, Image_Radio, Image_Gauge, Image_Max = (0..6).to_a
|
88
|
+
|
89
|
+
|
90
|
+
# a button which intercepts double clicks (for testing...)
|
91
|
+
class MyButton < Button
|
92
|
+
def initialize(parent,id,label = EmptyString,pos = DEFAULT_POSITION,size = DEFAULT_SIZE)
|
93
|
+
super(parent,id,label,pos,size)
|
94
|
+
|
95
|
+
evt_left_dclick {|event| onDClick(event)}
|
96
|
+
end
|
97
|
+
|
98
|
+
def onDClick(event)
|
99
|
+
log_message("MyButton::OnDClick")
|
100
|
+
event.skip()
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
104
|
+
|
105
|
+
# a combo which intercepts chars (to test Windows behaviour)
|
106
|
+
class MyComboBox < ComboBox
|
107
|
+
def initialize(parent,id,value = EmptyString,
|
108
|
+
pos = DEFAULT_POSITION,
|
109
|
+
size = DEFAULT_SIZE,
|
110
|
+
choices = [],
|
111
|
+
style = 0)
|
112
|
+
super(parent, id, value, pos, size, choices)#, style)
|
113
|
+
|
114
|
+
evt_char {|event| onChar(event)}
|
115
|
+
evt_key_down {|event| onKeyDown(event)}
|
116
|
+
evt_key_up {|event| onKeyUp(event)}
|
117
|
+
|
118
|
+
evt_set_focus {|event| onFocusGot(event)}
|
119
|
+
end
|
120
|
+
|
121
|
+
def onChar(event)
|
122
|
+
log_message("MyComboBox::OnChar")
|
123
|
+
if event.key_code() == ?w
|
124
|
+
log_message("MyComboBox: 'w' will be ignored.")
|
125
|
+
else
|
126
|
+
event.skip()
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
def onKeyDown(event)
|
131
|
+
log_message("MyComboBox::OnKeyDown")
|
132
|
+
if event.key_code() == ?w
|
133
|
+
log_message("MyComboBox: 'w' will be ignored.")
|
134
|
+
else
|
135
|
+
event.skip()
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
def onKeyUp(event)
|
140
|
+
#log_message("MyComboBox::OnKeyUp")
|
141
|
+
event.skip()
|
142
|
+
end
|
143
|
+
|
144
|
+
def onFocusGot(event)
|
145
|
+
#log_message("MyComboBox::OnFocusGot")
|
146
|
+
event.skip()
|
147
|
+
end
|
148
|
+
|
149
|
+
end
|
150
|
+
|
151
|
+
# a radiobox which handles focus set/kill (for testing)
|
152
|
+
class MyRadioBox < RadioBox
|
153
|
+
def initialize(parent,
|
154
|
+
id,title = EmptyString,
|
155
|
+
pos = DEFAULT_POSITION,
|
156
|
+
size = DEFAULT_SIZE,
|
157
|
+
choices = [],
|
158
|
+
majorDim = 1,
|
159
|
+
style = RA_HORIZONTAL)
|
160
|
+
super(parent, id, title, pos, size, choices, majorDim,style)
|
161
|
+
set_foreground_colour(RED)
|
162
|
+
|
163
|
+
evt_set_focus {|event| onFocusGot(event)}
|
164
|
+
evt_kill_focus {|event| onFocusLost(event)}
|
165
|
+
|
166
|
+
end
|
167
|
+
|
168
|
+
def onFocusGot(event)
|
169
|
+
log_message("MyRadioBox::OnFocusGot")
|
170
|
+
event.skip()
|
171
|
+
end
|
172
|
+
|
173
|
+
def onFocusLost(event)
|
174
|
+
log_message("MyRadioBox::OnFocusLost")
|
175
|
+
event.skip()
|
176
|
+
end
|
177
|
+
|
178
|
+
end
|
179
|
+
|
180
|
+
|
181
|
+
class MyPanel < Panel
|
182
|
+
|
183
|
+
# delete Log::set_active_target(@m_logTargetOld)
|
184
|
+
# delete @m_notebook.GetImageList()
|
185
|
+
attr_reader :m_text,:m_logTargetOld
|
186
|
+
|
187
|
+
def initialize(frame,x,y,w,h)
|
188
|
+
super( frame, -1, Point.new(x, y), Size.new(w, h) )
|
189
|
+
|
190
|
+
@s_colOld = NULL_COLOUR
|
191
|
+
|
192
|
+
@m_text = TextCtrl.new(self, -1, "This is the log window.\n",
|
193
|
+
Point.new(0, 250), Size.new(100, 50), TE_MULTILINE)
|
194
|
+
@m_text.set_background_colour(Colour.new("wheat"))
|
195
|
+
|
196
|
+
#@m_logTargetOld = Log::set_active_target(LogTextCtrl.new(@m_text))
|
197
|
+
|
198
|
+
@m_notebook = Wx::Notebook.new(self, ID_NOTEBOOK)
|
199
|
+
|
200
|
+
choices = [
|
201
|
+
"This",
|
202
|
+
"is one of my",
|
203
|
+
"really",
|
204
|
+
"wonderful",
|
205
|
+
"examples."
|
206
|
+
]
|
207
|
+
|
208
|
+
# fill the image list
|
209
|
+
|
210
|
+
imagelist = ImageList.new(16, 16)
|
211
|
+
|
212
|
+
imagelist.add( Bitmap.new( local_icon_file("list.xpm"),
|
213
|
+
Wx::BITMAP_TYPE_XPM))
|
214
|
+
imagelist.add( Bitmap.new( local_icon_file("choice.xpm"),
|
215
|
+
Wx::BITMAP_TYPE_XPM))
|
216
|
+
imagelist.add( Bitmap.new( local_icon_file("combo.xpm"),
|
217
|
+
Wx::BITMAP_TYPE_XPM))
|
218
|
+
imagelist.add( Bitmap.new( local_icon_file("text.xpm"),
|
219
|
+
Wx::BITMAP_TYPE_XPM))
|
220
|
+
imagelist.add( Bitmap.new( local_icon_file("radio.xpm"),
|
221
|
+
Wx::BITMAP_TYPE_XPM))
|
222
|
+
imagelist.add( Bitmap.new( local_icon_file("gauge.xpm"),
|
223
|
+
Wx::BITMAP_TYPE_XPM))
|
224
|
+
|
225
|
+
@m_notebook.set_image_list(imagelist)
|
226
|
+
|
227
|
+
panel = Panel.new(@m_notebook)
|
228
|
+
@m_listbox = ListBox.new( panel, ID_LISTBOX,
|
229
|
+
Point.new(10,10), Size.new(120,70),
|
230
|
+
choices, LB_ALWAYS_SB )
|
231
|
+
|
232
|
+
@m_listboxSorted = ListBox.new( panel, ID_LISTBOX_SORTED,
|
233
|
+
Point.new(10,90), Size.new(120,70),
|
234
|
+
choices, LB_SORT )
|
235
|
+
|
236
|
+
|
237
|
+
@m_listbox.set_cursor(CROSS_CURSOR)
|
238
|
+
|
239
|
+
@m_listbox.set_tool_tip( "This is a list box" )
|
240
|
+
|
241
|
+
|
242
|
+
@m_lbSelectNum = Button.new( panel, ID_LISTBOX_SEL_NUM, "Select #&2", Point.new(180,30), Size.new(140,30) )
|
243
|
+
@m_lbSelectThis = Button.new( panel, ID_LISTBOX_SEL_STR, "&Select 'This'", Point.new(340,30), Size.new(140,30) )
|
244
|
+
Button.new( panel, ID_LISTBOX_CLEAR, "&clear", Point.new(180,80), Size.new(140,30) )
|
245
|
+
MyButton.new( panel, ID_LISTBOX_APPEND, "&append 'Hi!'", Point.new(340,80), Size.new(140,30) )
|
246
|
+
Button.new( panel, ID_LISTBOX_DELETE, "D&elete selected item", Point.new(180,130), Size.new(140,30) )
|
247
|
+
button = MyButton.new( panel, ID_LISTBOX_FONT, "Set &Italic font", Point.new(340,130), Size.new(140,30) )
|
248
|
+
|
249
|
+
button.set_default()
|
250
|
+
|
251
|
+
button.set_foreground_colour(BLUE)
|
252
|
+
|
253
|
+
button.set_tool_tip( "Press here to set italic font" )
|
254
|
+
|
255
|
+
@m_checkbox = CheckBox.new( panel, ID_LISTBOX_ENABLE, "&Disable", Point.new(20,170) )
|
256
|
+
@m_checkbox.set_value(FALSE)
|
257
|
+
@m_checkbox.set_tool_tip( "Click here to disable the listbox" )
|
258
|
+
@m_toggle_color = CheckBox.new( panel, ID_CHANGE_COLOUR, "&Toggle colour",
|
259
|
+
Point.new(110,170) )
|
260
|
+
panel.set_cursor(Cursor.new(CURSOR_HAND))
|
261
|
+
@m_notebook.add_page(panel, "ListBox", TRUE, Image_List)
|
262
|
+
|
263
|
+
panel = Panel.new(@m_notebook)
|
264
|
+
@m_choice = Choice.new( panel, ID_CHOICE, Point.new(10,10), Size.new(120,-1), choices )
|
265
|
+
@m_choiceSorted = Choice.new( panel, ID_CHOICE_SORTED, Point.new(10,70), Size.new(120,-1),
|
266
|
+
choices, CB_SORT )
|
267
|
+
|
268
|
+
@m_choice.set_selection(2)
|
269
|
+
@m_choice.set_background_colour(Colour.new("red"))
|
270
|
+
Button.new( panel, ID_CHOICE_SEL_NUM, "Select #&2", Point.new(180,30), Size.new(140,30) )
|
271
|
+
Button.new( panel, ID_CHOICE_SEL_STR, "&Select 'This'", Point.new(340,30), Size.new(140,30) )
|
272
|
+
Button.new( panel, ID_CHOICE_CLEAR, "&clear", Point.new(180,80), Size.new(140,30) )
|
273
|
+
Button.new( panel, ID_CHOICE_APPEND, "&append 'Hi!'", Point.new(340,80), Size.new(140,30) )
|
274
|
+
Button.new( panel, ID_CHOICE_DELETE, "D&elete selected item", Point.new(180,130), Size.new(140,30) )
|
275
|
+
Button.new( panel, ID_CHOICE_FONT, "Set &Italic font", Point.new(340,130), Size.new(140,30) )
|
276
|
+
CheckBox.new( panel, ID_CHOICE_ENABLE, "&Disable", Point.new(20,130), Size.new(140,30) )
|
277
|
+
|
278
|
+
@m_notebook.add_page(panel, "Choice", FALSE, Image_Choice)
|
279
|
+
|
280
|
+
panel = Panel.new(@m_notebook)
|
281
|
+
StaticBox.new( panel, -1, "&Box around combobox",
|
282
|
+
Point.new(5, 5), Size.new(150, 100))
|
283
|
+
@m_combo = MyComboBox.new( panel, ID_COMBO, "This",
|
284
|
+
Point.new(20,25), Size.new(120, -1),
|
285
|
+
choices,PROCESS_ENTER)
|
286
|
+
# CB_READONLY | PROCESS_ENTER)
|
287
|
+
|
288
|
+
@m_combo.set_tool_tip("This is a natural\ncombobox - can you believe me?")
|
289
|
+
|
290
|
+
Button.new( panel, ID_COMBO_SEL_NUM, "Select #&2", Point.new(180,30), Size.new(140,30) )
|
291
|
+
Button.new( panel, ID_COMBO_SEL_STR, "&Select 'This'", Point.new(340,30), Size.new(140,30) )
|
292
|
+
Button.new( panel, ID_COMBO_CLEAR, "&clear", Point.new(180,80), Size.new(140,30) )
|
293
|
+
Button.new( panel, ID_COMBO_APPEND, "&append 'Hi!'", Point.new(340,80), Size.new(140,30) )
|
294
|
+
Button.new( panel, ID_COMBO_DELETE, "D&elete selected item", Point.new(180,130), Size.new(140,30) )
|
295
|
+
Button.new( panel, ID_COMBO_FONT, "Set &Italic font", Point.new(340,130), Size.new(140,30) )
|
296
|
+
CheckBox.new( panel, ID_COMBO_ENABLE, "&Disable", Point.new(20,130), Size.new(140,30) )
|
297
|
+
@m_notebook.add_page(panel, "ComboBox", FALSE, Image_Combo)
|
298
|
+
|
299
|
+
choices2 = ["First", "Second"]
|
300
|
+
# "Third",
|
301
|
+
#"Fourth", "Fifth", "Sixth",
|
302
|
+
#"Seventh", "Eighth", "Nineth", "Tenth" */
|
303
|
+
|
304
|
+
panel = Panel.new(@m_notebook)
|
305
|
+
MyRadioBox.new( panel, ID_RADIOBOX, "&That", Point.new(10,160), Size.new(-1,-1), choices2, 1, RA_SPECIFY_ROWS )
|
306
|
+
@m_radio = RadioBox.new( panel, ID_RADIOBOX, "T&his", Point.new(10,10), Size.new(-1,-1), choices, 1, RA_SPECIFY_COLS )
|
307
|
+
@m_radio.set_foreground_colour(RED)
|
308
|
+
|
309
|
+
@m_radio.set_tool_tip("Ever seen a radiobox?")
|
310
|
+
|
311
|
+
Button.new( panel, ID_RADIOBOX_SEL_NUM, "Select #&2", Point.new(180,30), Size.new(140,30) )
|
312
|
+
Button.new( panel, ID_RADIOBOX_SEL_STR, "&Select 'This'", Point.new(180,80), Size.new(140,30) )
|
313
|
+
@m_fontButton = Button.new( panel, ID_SET_FONT, "Set &more Italic font", Point.new(340,30), Size.new(140,30) )
|
314
|
+
Button.new( panel, ID_RADIOBOX_FONT, "Set &Italic font", Point.new(340,80), Size.new(140,30) )
|
315
|
+
CheckBox.new( panel, ID_RADIOBOX_ENABLE, "&Disable", Point.new(340,130), DEFAULT_SIZE )
|
316
|
+
rb = RadioButton.new( panel, ID_RADIOBUTTON_1, "Radiobutton1", Point.new(210,170), DEFAULT_SIZE, RB_GROUP )
|
317
|
+
rb.set_value( FALSE )
|
318
|
+
RadioButton.new( panel, ID_RADIOBUTTON_2, "&Radiobutton2", Point.new(340,170), DEFAULT_SIZE )
|
319
|
+
@m_notebook.add_page(panel, "RadioBox", FALSE, Image_Radio)
|
320
|
+
|
321
|
+
panel = Panel.new(@m_notebook)
|
322
|
+
StaticBox.new( panel, -1, "&Gauge and Slider", Point.new(10,10), Size.new(222,130) )
|
323
|
+
@m_gauge = Gauge.new( panel, -1, 200, Point.new(18,50), Size.new(155, 30), GA_HORIZONTAL|NO_BORDER )
|
324
|
+
@m_gauge.set_background_colour(GREEN)
|
325
|
+
@m_gauge.set_foreground_colour(RED)
|
326
|
+
@m_gaugeVert = Gauge.new( panel, -1, 100,
|
327
|
+
Point.new(195,35), Size.new(30, 90),
|
328
|
+
GA_VERTICAL | GA_SMOOTH | NO_BORDER )
|
329
|
+
@m_slider = Slider.new( panel, ID_SLIDER, 0, 0, 200, Point.new(18,90), Size.new(155,-1),
|
330
|
+
SL_AUTOTICKS | SL_LABELS )
|
331
|
+
@m_slider.set_tick_freq(40, 0)
|
332
|
+
@m_slider.set_tool_tip("This is a sliding slider")
|
333
|
+
|
334
|
+
StaticBox.new( panel, -1, "&Explanation",
|
335
|
+
Point.new(230,10), Size.new(270,130),
|
336
|
+
ALIGN_CENTER )
|
337
|
+
|
338
|
+
StaticText.new( panel, -1,
|
339
|
+
"In order see the gauge (aka progress bar)\n"+
|
340
|
+
"control do something you have to drag the\n"+
|
341
|
+
"handle of the slider to the right.\n"+
|
342
|
+
"\n"+
|
343
|
+
"This is also supposed to demonstrate how\n"+
|
344
|
+
"to use static controls.\n",
|
345
|
+
Point.new(250,25),
|
346
|
+
Size.new(240, 110))
|
347
|
+
initialSpinValue = -5
|
348
|
+
s = initialSpinValue.to_s
|
349
|
+
@m_spintext = TextCtrl.new( panel, -1, s, Point.new(20,160), Size.new(80,-1) )
|
350
|
+
@m_spinbutton = SpinButton.new( panel, ID_SPIN, Point.new(103,160), Size.new(80, -1) )
|
351
|
+
@m_spinbutton.set_range(-40,30)
|
352
|
+
@m_spinbutton.set_value(initialSpinValue)
|
353
|
+
|
354
|
+
@m_btnProgress = Button.new( panel, ID_BTNPROGRESS, "&Show progress dialog",
|
355
|
+
Point.new(300, 160) )
|
356
|
+
|
357
|
+
@m_spinctrl = SpinCtrl.new( panel, ID_SPINCTRL, "", Point.new(200, 160), Size.new(80, -1) )
|
358
|
+
@m_spinctrl.set_range(10,30)
|
359
|
+
@m_spinctrl.set_value(15)
|
360
|
+
|
361
|
+
@m_notebook.add_page(panel, "Gauge", FALSE, Image_Gauge)
|
362
|
+
|
363
|
+
panel = Panel.new(@m_notebook)
|
364
|
+
|
365
|
+
icon = ArtProvider::get_icon(ART_INFORMATION)
|
366
|
+
StaticBitmap.new( panel, -1, icon, Point.new(10, 10) )
|
367
|
+
|
368
|
+
bitmap = Bitmap.new( 100, 100 )
|
369
|
+
bitmap.draw do | dc |
|
370
|
+
dc.clear()
|
371
|
+
dc.set_pen(GREEN_PEN)
|
372
|
+
dc.draw_ellipse(5, 5, 90, 90)
|
373
|
+
dc.draw_text("Bitmap", 30, 40)
|
374
|
+
end
|
375
|
+
|
376
|
+
BitmapButton.new(panel, ID_BITMAP_BTN, bitmap, Point.new(100, 20))
|
377
|
+
|
378
|
+
# test for masked bitmap display
|
379
|
+
bitmap = Bitmap.new( File.join(File.dirname(__FILE__), "test2.bmp"),
|
380
|
+
BITMAP_TYPE_BMP)
|
381
|
+
if bitmap.is_ok()
|
382
|
+
bitmap.set_mask(Mask.new(bitmap, BLUE))
|
383
|
+
StaticBitmap.new(panel, -1, bitmap, Point.new(300, 120))
|
384
|
+
end
|
385
|
+
# bmp1 = ArtProvider::get_bitmap(ART_INFORMATION)
|
386
|
+
# bmp2 = ArtProvider::get_bitmap(ART_WARNING)
|
387
|
+
# bmp3 = ArtProvider::get_bitmap(ART_QUESTION)
|
388
|
+
# bmpBtn = BitmapButton.new(panel, -1,
|
389
|
+
# bmp1,
|
390
|
+
# Point.new(30, 70))
|
391
|
+
|
392
|
+
# bmpBtn.set_bitmap_selected(bmp2)
|
393
|
+
# bmpBtn.set_bitmap_focus(bmp3)
|
394
|
+
ToggleButton.new(panel, ID_BUTTON_LABEL,
|
395
|
+
"&Toggle label", Point.new(250, 20))
|
396
|
+
@m_label = StaticText.new(panel, -1, "Label with some long text",
|
397
|
+
Point.new(250, 60), DEFAULT_SIZE,
|
398
|
+
ALIGN_RIGHT)
|
399
|
+
@m_label.set_foreground_colour(BLUE )
|
400
|
+
|
401
|
+
@m_notebook.add_page(panel, "BitmapXXX")
|
402
|
+
|
403
|
+
# sizer
|
404
|
+
|
405
|
+
panel = Panel.new(@m_notebook)
|
406
|
+
panel.set_auto_layout( TRUE )
|
407
|
+
|
408
|
+
sizer = BoxSizer.new( VERTICAL )
|
409
|
+
|
410
|
+
csizer =
|
411
|
+
StaticBoxSizer.new(StaticBox.new(panel, -1, "Show Buttons"),
|
412
|
+
HORIZONTAL )
|
413
|
+
|
414
|
+
check1 = CheckBox.new(panel, ID_SIZER_CHECK1, "1")
|
415
|
+
check1.set_value(TRUE)
|
416
|
+
csizer.add(check1)
|
417
|
+
check2 = CheckBox.new(panel, ID_SIZER_CHECK2, "2")
|
418
|
+
check2.set_value(TRUE)
|
419
|
+
csizer.add(check2)
|
420
|
+
check3 = CheckBox.new(panel, ID_SIZER_CHECK3, "3")
|
421
|
+
check3.set_value(TRUE)
|
422
|
+
csizer.add(check3)
|
423
|
+
check4 = CheckBox.new(panel, ID_SIZER_CHECK4, "4")
|
424
|
+
check4.set_value(TRUE)
|
425
|
+
csizer.add(check4)
|
426
|
+
check14 = CheckBox.new(panel, ID_SIZER_CHECK14, "1-4")
|
427
|
+
check14.set_value(TRUE)
|
428
|
+
csizer.add(check14)
|
429
|
+
checkBig = CheckBox.new(panel, ID_SIZER_CHECKBIG, "Big")
|
430
|
+
checkBig.set_value(TRUE)
|
431
|
+
csizer.add(checkBig)
|
432
|
+
|
433
|
+
sizer.add(csizer)
|
434
|
+
|
435
|
+
@m_hsizer = BoxSizer.new( HORIZONTAL )
|
436
|
+
|
437
|
+
@m_buttonSizer = BoxSizer.new(VERTICAL)
|
438
|
+
|
439
|
+
@m_sizerBtn1 = Button.new(panel, -1, "Test Button &1" )
|
440
|
+
@m_buttonSizer.add( @m_sizerBtn1, 0, ALL, 10 )
|
441
|
+
@m_sizerBtn2 = Button.new(panel, -1, "Test Button &2" )
|
442
|
+
@m_buttonSizer.add( @m_sizerBtn2, 0, ALL, 10 )
|
443
|
+
@m_sizerBtn3 = Button.new(panel, -1, "Test Button &3" )
|
444
|
+
@m_buttonSizer.add( @m_sizerBtn3, 0, ALL, 10 )
|
445
|
+
@m_sizerBtn4 = Button.new(panel, -1, "Test Button &4" )
|
446
|
+
@m_buttonSizer.add( @m_sizerBtn4, 0, ALL, 10 )
|
447
|
+
|
448
|
+
@m_hsizer.add(@m_buttonSizer)
|
449
|
+
@m_hsizer.add( 20,20, 1 )
|
450
|
+
@m_bigBtn = Button.new(panel, -1, "Multiline\nbutton" )
|
451
|
+
@m_hsizer.add( @m_bigBtn , 3, GROW|ALL, 10 )
|
452
|
+
|
453
|
+
sizer.add(@m_hsizer, 1, GROW)
|
454
|
+
|
455
|
+
panel.set_sizer( sizer )
|
456
|
+
|
457
|
+
@m_notebook.add_page(panel, "Sizer")
|
458
|
+
|
459
|
+
evt_size {|event| onSize(event) }
|
460
|
+
evt_notebook_page_changing(ID_NOTEBOOK) {|event| onPageChanging(event) }
|
461
|
+
evt_notebook_page_changed(ID_NOTEBOOK) {|event| onPageChanged(event) }
|
462
|
+
evt_listbox(ID_LISTBOX) {|event| onListBox(event) }
|
463
|
+
evt_listbox(ID_LISTBOX_SORTED) {|event| onListBox(event) }
|
464
|
+
evt_listbox_dclick(ID_LISTBOX) {|event| onListBoxDoubleClick(event) }
|
465
|
+
evt_button(ID_LISTBOX_SEL_NUM) {|event| onListBoxButtons(event) }
|
466
|
+
evt_button(ID_LISTBOX_SEL_STR) {|event| onListBoxButtons(event) }
|
467
|
+
evt_button(ID_LISTBOX_CLEAR) {|event| onListBoxButtons(event) }
|
468
|
+
evt_button(ID_LISTBOX_APPEND) {|event| onListBoxButtons(event) }
|
469
|
+
evt_button(ID_LISTBOX_DELETE) {|event| onListBoxButtons(event) }
|
470
|
+
evt_button(ID_LISTBOX_FONT) {|event| onListBoxButtons(event) }
|
471
|
+
evt_checkbox(ID_LISTBOX_ENABLE) {|event| onListBoxButtons(event) }
|
472
|
+
evt_choice(ID_CHOICE) {|event| onChoice(event) }
|
473
|
+
evt_choice(ID_CHOICE_SORTED) {|event| onChoice(event) }
|
474
|
+
evt_button(ID_CHOICE_SEL_NUM) {|event| onChoiceButtons(event) }
|
475
|
+
evt_button(ID_CHOICE_SEL_STR) {|event| onChoiceButtons(event) }
|
476
|
+
evt_button(ID_CHOICE_CLEAR) {|event| onChoiceButtons(event) }
|
477
|
+
evt_button(ID_CHOICE_APPEND) {|event| onChoiceButtons(event) }
|
478
|
+
evt_button(ID_CHOICE_DELETE) {|event| onChoiceButtons(event) }
|
479
|
+
evt_button(ID_CHOICE_FONT) {|event| onChoiceButtons(event) }
|
480
|
+
evt_checkbox(ID_CHOICE_ENABLE) {|event| onChoiceButtons(event) }
|
481
|
+
evt_combobox(ID_COMBO) {|event| onCombo(event) }
|
482
|
+
evt_text(ID_COMBO) {|event| onComboTextChanged(event) }
|
483
|
+
evt_text_enter(ID_COMBO) {|event| onComboTextEnter(event) }
|
484
|
+
evt_button(ID_COMBO_SEL_NUM) {|event| onComboButtons(event) }
|
485
|
+
evt_button(ID_COMBO_SEL_STR) {|event| onComboButtons(event) }
|
486
|
+
evt_button(ID_COMBO_CLEAR) {|event| onComboButtons(event) }
|
487
|
+
evt_button(ID_COMBO_APPEND) {|event| onComboButtons(event) }
|
488
|
+
evt_button(ID_COMBO_DELETE) {|event| onComboButtons(event) }
|
489
|
+
evt_button(ID_COMBO_FONT) {|event| onComboButtons(event) }
|
490
|
+
evt_checkbox(ID_COMBO_ENABLE) {|event| onComboButtons(event) }
|
491
|
+
evt_radiobox(ID_RADIOBOX) {|event| onRadio(event) }
|
492
|
+
evt_button(ID_RADIOBOX_SEL_NUM) {|event| onRadioButtons(event) }
|
493
|
+
evt_button(ID_RADIOBOX_SEL_STR) {|event| onRadioButtons(event) }
|
494
|
+
evt_button(ID_RADIOBOX_FONT) {|event| onRadioButtons(event) }
|
495
|
+
evt_checkbox(ID_RADIOBOX_ENABLE) {|event| onRadioButtons(event) }
|
496
|
+
evt_button(ID_SET_FONT) {|event| onSetFont(event) }
|
497
|
+
evt_slider(ID_SLIDER) {|event| onSliderupdate(event) }
|
498
|
+
evt_spin(ID_SPIN) {|event| onSpinupdate(event) }
|
499
|
+
evt_spin_up(ID_SPIN) {|event| onSpinUp(event) }
|
500
|
+
evt_spin_down(ID_SPIN) {|event| onSpinDown(event) }
|
501
|
+
evt_update_ui(ID_BTNPROGRESS) {|event| onupdateShowProgress(event) }
|
502
|
+
evt_button(ID_BTNPROGRESS) {|event| onShowProgress(event) }
|
503
|
+
evt_spinctrl(ID_SPINCTRL) {|event| onSpinCtrl(event) }
|
504
|
+
evt_spin_up(ID_SPINCTRL) {|event| onSpinCtrlUp(event) }
|
505
|
+
evt_spin_down(ID_SPINCTRL) {|event| onSpinCtrlDown(event) }
|
506
|
+
evt_text(ID_SPINCTRL) {|event| onSpinCtrlText(event) }
|
507
|
+
if (RUBY_PLATFORM =~ /mswin/)
|
508
|
+
evt_togglebutton(ID_BUTTON_LABEL) {|event| onupdateLabel(event) }
|
509
|
+
end
|
510
|
+
evt_checkbox(ID_CHANGE_COLOUR) {|event| onChangeColour(event) }
|
511
|
+
evt_button(ID_BUTTON_TEST1) {|event| onTestButton(event) }
|
512
|
+
evt_button(ID_BUTTON_TEST2) {|event| onTestButton(event) }
|
513
|
+
evt_button(ID_BITMAP_BTN) {|event| onBmpButton(event) }
|
514
|
+
|
515
|
+
evt_checkbox(ID_SIZER_CHECK1) {|event| onSizerCheck(event) }
|
516
|
+
evt_checkbox(ID_SIZER_CHECK2) {|event| onSizerCheck(event) }
|
517
|
+
evt_checkbox(ID_SIZER_CHECK3) {|event| onSizerCheck(event) }
|
518
|
+
evt_checkbox(ID_SIZER_CHECK4) {|event| onSizerCheck(event) }
|
519
|
+
evt_checkbox(ID_SIZER_CHECK14) {|event| onSizerCheck(event) }
|
520
|
+
evt_checkbox(ID_SIZER_CHECKBIG) {|event| onSizerCheck(event) }
|
521
|
+
|
522
|
+
end
|
523
|
+
|
524
|
+
# utility function to find an icon relative to this ruby script
|
525
|
+
def local_icon_file(icon_name)
|
526
|
+
File.join( File.dirname(__FILE__), 'icons', icon_name)
|
527
|
+
end
|
528
|
+
|
529
|
+
|
530
|
+
def onSize(event)
|
531
|
+
size = get_client_size()
|
532
|
+
x = size.get_width
|
533
|
+
y = size.get_height
|
534
|
+
if @m_notebook
|
535
|
+
@m_notebook.set_dimensions( 2, 2, x-4, y*2/3-4 )
|
536
|
+
end
|
537
|
+
if @m_text
|
538
|
+
@m_text.set_dimensions( 2, y*2/3+2, x-4, y/3-4 )
|
539
|
+
end
|
540
|
+
end
|
541
|
+
|
542
|
+
def onPageChanging(event)
|
543
|
+
|
544
|
+
selOld = event.get_old_selection()
|
545
|
+
if selOld == 2
|
546
|
+
if message_box("This demonstrates how a program may prevent the\n"+
|
547
|
+
"page change from taking place - if you select\n"+
|
548
|
+
"[No] the current page will stay the third one\n",
|
549
|
+
"Control sample",
|
550
|
+
ICON_QUESTION | YES_NO, self) != YES
|
551
|
+
event.veto()
|
552
|
+
return nil
|
553
|
+
end
|
554
|
+
end
|
555
|
+
@m_text << "Notebook selection is being changed from " << selOld \
|
556
|
+
<< " to " << event.get_selection() \
|
557
|
+
<< " (current page from notebook is " \
|
558
|
+
<< @m_notebook.get_selection() << ")\n"
|
559
|
+
end
|
560
|
+
|
561
|
+
def onPageChanged(event)
|
562
|
+
@m_text << "Notebook selection is now " << event.get_selection() \
|
563
|
+
<< " (from notebook: " << @m_notebook.get_selection() \
|
564
|
+
<< ")\n"
|
565
|
+
end
|
566
|
+
|
567
|
+
def onTestButton(event)
|
568
|
+
log_message("Button %s clicked.",
|
569
|
+
event.get_id() == ID_BUTTON_TEST1 ? '1' : '2')
|
570
|
+
end
|
571
|
+
|
572
|
+
def onBmpButton(event)
|
573
|
+
log_message("Bitmap button clicked.")
|
574
|
+
end
|
575
|
+
|
576
|
+
def onChangeColour(event)
|
577
|
+
# test panel colour changing and propagation to the subcontrols
|
578
|
+
if @s_colOld.is_ok()
|
579
|
+
|
580
|
+
set_background_colour(@s_colOld)
|
581
|
+
@s_colOld = NULL_COLOUR
|
582
|
+
|
583
|
+
@m_lbSelectThis.set_foreground_colour(Colour.new("red"))
|
584
|
+
@m_lbSelectThis.set_background_colour(Colour.new("white"))
|
585
|
+
else
|
586
|
+
@s_colOld = Colour.new("red")
|
587
|
+
set_background_colour(Colour.new("white"))
|
588
|
+
|
589
|
+
@m_lbSelectThis.set_foreground_colour(Colour.new("white"))
|
590
|
+
@m_lbSelectThis.set_background_colour(Colour.new("red"))
|
591
|
+
end
|
592
|
+
|
593
|
+
@m_lbSelectThis.refresh()
|
594
|
+
refresh()
|
595
|
+
end
|
596
|
+
|
597
|
+
def onListBox(event)
|
598
|
+
# GetParent().Move(100, 100)
|
599
|
+
if event.get_int() == -1
|
600
|
+
@m_text.append_text( "ListBox has no selections anymore\n" )
|
601
|
+
return Qnil
|
602
|
+
end
|
603
|
+
|
604
|
+
listbox = (event.get_id() == ID_LISTBOX) ? @m_listbox : @m_listboxSorted
|
605
|
+
|
606
|
+
@m_text.append_text( "ListBox event selection string is: '" )
|
607
|
+
@m_text.append_text( event.get_string() )
|
608
|
+
@m_text.append_text( "'\n" )
|
609
|
+
@m_text.append_text( "ListBox control selection string is: '" )
|
610
|
+
@m_text.append_text( listbox.get_string_selection() )
|
611
|
+
@m_text.append_text( "'\n" )
|
612
|
+
|
613
|
+
# NOTE: get_client_data and set_client_data have been removed from wxRuby 0.4
|
614
|
+
# because they could cause crashes
|
615
|
+
# obj = event.get_client_data()
|
616
|
+
# @m_text.append_text( "ListBox event client data string is: '" )
|
617
|
+
# if obj
|
618
|
+
# @m_text.append_text( obj )
|
619
|
+
# else
|
620
|
+
# @m_text.append_text( "none" )
|
621
|
+
# end
|
622
|
+
|
623
|
+
# @m_text.append_text( "'\n" )
|
624
|
+
# @m_text.append_text( "ListBox control client data string is: '" )
|
625
|
+
# obj = listbox.get_client_data(listbox.get_selection())
|
626
|
+
# if obj
|
627
|
+
# @m_text.append_text( obj )
|
628
|
+
# else
|
629
|
+
# @m_text.append_text( "none" )
|
630
|
+
# end
|
631
|
+
# @m_text.append_text( "'\n" )
|
632
|
+
end
|
633
|
+
|
634
|
+
def onListBoxDoubleClick(event)
|
635
|
+
@m_text.append_text( "ListBox double click string is: " )
|
636
|
+
@m_text.append_text( event.get_string() )
|
637
|
+
@m_text.append_text( "\n" )
|
638
|
+
end
|
639
|
+
|
640
|
+
def onListBoxButtons(event)
|
641
|
+
case event.get_id()
|
642
|
+
when ID_LISTBOX_ENABLE
|
643
|
+
@m_text.append_text("Checkbox clicked.\n")
|
644
|
+
if event.get_int() != 0
|
645
|
+
@m_checkbox.set_tool_tip( "Click to enable listbox" )
|
646
|
+
@m_toggle_color.enable(false)
|
647
|
+
else
|
648
|
+
@m_checkbox.set_tool_tip( "Click to disable listbox" )
|
649
|
+
@m_toggle_color.enable(true)
|
650
|
+
end
|
651
|
+
@m_listbox.enable( event.get_int() == 0 )
|
652
|
+
@m_lbSelectThis.enable( event.get_int() == 0 )
|
653
|
+
@m_lbSelectNum.enable( event.get_int() == 0 )
|
654
|
+
@m_listboxSorted.enable( event.get_int() == 0 )
|
655
|
+
#w = Window::find_window_by_id(ID_CHANGE_COLOUR)
|
656
|
+
#if(w)
|
657
|
+
# w.enable( event.get_int() == 0 )
|
658
|
+
#else
|
659
|
+
# puts("Window ID_CHANGE_COLOR not found")
|
660
|
+
#end
|
661
|
+
when ID_LISTBOX_SEL_NUM
|
662
|
+
@m_listbox.set_selection( 2 )
|
663
|
+
@m_listboxSorted.set_selection( 2 )
|
664
|
+
@m_lbSelectThis.warp_pointer( 40, 14 )
|
665
|
+
when ID_LISTBOX_SEL_STR
|
666
|
+
@m_listbox.set_string_selection( "This" )
|
667
|
+
@m_listboxSorted.set_string_selection( "This" )
|
668
|
+
@m_lbSelectNum.warp_pointer( 40, 14 )
|
669
|
+
when ID_LISTBOX_CLEAR
|
670
|
+
@m_listbox.clear()
|
671
|
+
@m_listboxSorted.clear()
|
672
|
+
when ID_LISTBOX_APPEND
|
673
|
+
@m_listbox.append( "Hi!" )
|
674
|
+
@m_listboxSorted.append( "Hi!" )
|
675
|
+
when ID_LISTBOX_DELETE
|
676
|
+
idx = @m_listbox.get_selection()
|
677
|
+
if idx != NOT_FOUND
|
678
|
+
@m_listbox.delete( idx )
|
679
|
+
end
|
680
|
+
idx = @m_listboxSorted.get_selection()
|
681
|
+
if idx != NOT_FOUND
|
682
|
+
@m_listboxSorted.delete( idx )
|
683
|
+
end
|
684
|
+
when ID_LISTBOX_FONT
|
685
|
+
@m_listbox.set_font( ITALIC_FONT )
|
686
|
+
@m_listboxSorted.set_font( ITALIC_FONT )
|
687
|
+
@m_checkbox.set_font( ITALIC_FONT )
|
688
|
+
end
|
689
|
+
end
|
690
|
+
|
691
|
+
|
692
|
+
def onChoice(event)
|
693
|
+
|
694
|
+
choice = (event.get_id() == ID_CHOICE) ? @m_choice : @m_choiceSorted
|
695
|
+
|
696
|
+
@m_text.append_text( "Choice event selection string is: '" )
|
697
|
+
@m_text.append_text( event.get_string() )
|
698
|
+
@m_text.append_text( "'\n" )
|
699
|
+
@m_text.append_text( "Choice control selection string is: '" )
|
700
|
+
@m_text.append_text( choice.get_string_selection() )
|
701
|
+
@m_text.append_text( "'\n" )
|
702
|
+
|
703
|
+
# NOTE: get_client_data and set_client_data have been removed from wxRuby 0.4
|
704
|
+
# because they could cause crashes
|
705
|
+
# obj = event.get_client_data()
|
706
|
+
# @m_text.append_text( "Choice event client data string is: '" )
|
707
|
+
|
708
|
+
# if obj
|
709
|
+
# @m_text.append_text( obj )
|
710
|
+
# else
|
711
|
+
# @m_text.append_text( "none" )
|
712
|
+
# end
|
713
|
+
|
714
|
+
# @m_text.append_text( "'\n" )
|
715
|
+
# @m_text.append_text( "Choice control client data string is: '" )
|
716
|
+
|
717
|
+
# obj = choice.get_client_data(choice.get_selection())
|
718
|
+
# if obj
|
719
|
+
# @m_text.append_text( obj )
|
720
|
+
# else
|
721
|
+
# @m_text.append_text( "none" )
|
722
|
+
# end
|
723
|
+
# @m_text.append_text( "'\n" )
|
724
|
+
end
|
725
|
+
|
726
|
+
def onChoiceButtons(event)
|
727
|
+
case event.get_id()
|
728
|
+
when ID_CHOICE_ENABLE
|
729
|
+
@m_choice.enable( event.get_int() == 0 )
|
730
|
+
@m_choiceSorted.enable( event.get_int() == 0 )
|
731
|
+
when ID_CHOICE_SEL_NUM
|
732
|
+
@m_choice.set_selection( 2 )
|
733
|
+
@m_choiceSorted.set_selection( 2 )
|
734
|
+
when ID_CHOICE_SEL_STR
|
735
|
+
@m_choice.set_string_selection( "This" )
|
736
|
+
@m_choiceSorted.set_string_selection( "This" )
|
737
|
+
when ID_CHOICE_CLEAR
|
738
|
+
@m_choice.clear()
|
739
|
+
@m_choiceSorted.clear()
|
740
|
+
when ID_CHOICE_APPEND
|
741
|
+
@m_choice.append( "Hi!" )
|
742
|
+
@m_choiceSorted.append( "Hi!" )
|
743
|
+
when ID_CHOICE_DELETE
|
744
|
+
idx = @m_choice.get_selection()
|
745
|
+
if idx != NOT_FOUND
|
746
|
+
@m_choice.delete( idx )
|
747
|
+
end
|
748
|
+
idx = @m_choiceSorted.get_selection()
|
749
|
+
if idx != NOT_FOUND
|
750
|
+
@m_choiceSorted.delete( idx )
|
751
|
+
end
|
752
|
+
when ID_CHOICE_FONT
|
753
|
+
@m_choice.set_font( ITALIC_FONT )
|
754
|
+
@m_choiceSorted.set_font( ITALIC_FONT )
|
755
|
+
end
|
756
|
+
end
|
757
|
+
|
758
|
+
def onCombo(event)
|
759
|
+
@m_text.append_text( "ComboBox event selection string is: " )
|
760
|
+
@m_text.append_text( event.get_string() )
|
761
|
+
@m_text.append_text( "\n" )
|
762
|
+
@m_text.append_text( "ComboBox control selection string is: " )
|
763
|
+
@m_text.append_text( @m_combo.get_string_selection() )
|
764
|
+
@m_text.append_text( "\n" )
|
765
|
+
end
|
766
|
+
|
767
|
+
def onComboTextChanged(event)
|
768
|
+
str = sprintf( "Text in the combobox changed: now is '%s'.",
|
769
|
+
event.get_string())
|
770
|
+
log_message( str )
|
771
|
+
end
|
772
|
+
|
773
|
+
def onComboTextEnter(event)
|
774
|
+
log_message("Enter pressed in the combobox: value is '%s'.",
|
775
|
+
@m_combo.get_value())
|
776
|
+
end
|
777
|
+
|
778
|
+
def onComboButtons(event)
|
779
|
+
case event.get_id()
|
780
|
+
when ID_COMBO_ENABLE
|
781
|
+
@m_combo.enable( event.get_int() == 0 )
|
782
|
+
when ID_COMBO_SEL_NUM
|
783
|
+
@m_combo.set_selection( 2 )
|
784
|
+
when ID_COMBO_SEL_STR
|
785
|
+
@m_combo.set_string_selection( "This" )
|
786
|
+
when ID_COMBO_CLEAR
|
787
|
+
@m_combo.clear()
|
788
|
+
when ID_COMBO_APPEND
|
789
|
+
@m_combo.append( "Hi!" )
|
790
|
+
when ID_COMBO_DELETE
|
791
|
+
idx = @m_combo.get_selection()
|
792
|
+
@m_combo.delete( idx )
|
793
|
+
when ID_COMBO_FONT
|
794
|
+
@m_combo.set_font( ITALIC_FONT )
|
795
|
+
end
|
796
|
+
end
|
797
|
+
|
798
|
+
def onRadio(event)
|
799
|
+
@m_text.append_text( "RadioBox selection string is: " )
|
800
|
+
@m_text.append_text( event.get_string() )
|
801
|
+
@m_text.append_text( "\n" )
|
802
|
+
end
|
803
|
+
|
804
|
+
def onRadioButtons(event)
|
805
|
+
case event.get_id()
|
806
|
+
when ID_RADIOBOX_ENABLE
|
807
|
+
@m_radio.enable( event.get_int() == 0 )
|
808
|
+
when ID_RADIOBOX_SEL_NUM
|
809
|
+
@m_radio.set_selection( 2 )
|
810
|
+
when ID_RADIOBOX_SEL_STR
|
811
|
+
@m_radio.set_string_selection( "This" )
|
812
|
+
when ID_RADIOBOX_FONT
|
813
|
+
@m_radio.set_foreground_colour(GREEN)
|
814
|
+
@m_radio.set_font( ITALIC_FONT )
|
815
|
+
end
|
816
|
+
end
|
817
|
+
|
818
|
+
def onSetFont(event)
|
819
|
+
@m_fontButton.set_font( ITALIC_FONT )
|
820
|
+
@m_text.set_font( ITALIC_FONT )
|
821
|
+
end
|
822
|
+
|
823
|
+
def onupdateLabel(event)
|
824
|
+
@m_label.set_label(event.get_int() != 0 ? "Very very very very very long text." : "Shorter text.")
|
825
|
+
end
|
826
|
+
|
827
|
+
def onSliderupdate(event)
|
828
|
+
@m_gauge.set_value( @m_slider.get_value() )
|
829
|
+
@m_gaugeVert.set_value( @m_slider.get_value() / 2 )
|
830
|
+
end
|
831
|
+
|
832
|
+
|
833
|
+
def onSpinCtrlText(event)
|
834
|
+
if @m_spinctrl
|
835
|
+
s = sprintf( "Spin ctrl text changed: now %d (from event: %s)\n",
|
836
|
+
@m_spinctrl.get_value(), event.get_string() )
|
837
|
+
@m_text.append_text(s)
|
838
|
+
end
|
839
|
+
end
|
840
|
+
|
841
|
+
def onSpinCtrl(event)
|
842
|
+
if @m_spinctrl
|
843
|
+
s = sprintf( "Spin ctrl changed: now %d (from event: %d)\n",
|
844
|
+
@m_spinctrl.get_value(), event.get_int() )
|
845
|
+
@m_text.append_text(s)
|
846
|
+
end
|
847
|
+
end
|
848
|
+
|
849
|
+
def onSpinCtrlUp(event)
|
850
|
+
if @m_spinctrl
|
851
|
+
@m_text.append_text( sprintf(
|
852
|
+
"Spin up: %d (from event: %d)\n",
|
853
|
+
@m_spinctrl.get_value(), event.get_int() ) )
|
854
|
+
end
|
855
|
+
end
|
856
|
+
|
857
|
+
def onSpinCtrlDown(event)
|
858
|
+
if @m_spinctrl
|
859
|
+
@m_text.append_text( sprintf(
|
860
|
+
"Spin down: %d (from event: %d)\n",
|
861
|
+
@m_spinctrl.get_value(), event.get_int() ) )
|
862
|
+
end
|
863
|
+
end
|
864
|
+
|
865
|
+
|
866
|
+
def onSpinUp(event)
|
867
|
+
value = sprintf( "Spin control up: current = %d\n",
|
868
|
+
@m_spinbutton.get_value())
|
869
|
+
|
870
|
+
if event.get_position() > 17
|
871
|
+
value += "Preventing the spin button from going above 17.\n"
|
872
|
+
event.veto()
|
873
|
+
end
|
874
|
+
|
875
|
+
@m_text.append_text(value)
|
876
|
+
end
|
877
|
+
|
878
|
+
def onSpinDown(event)
|
879
|
+
value = sprintf( "Spin control down: current = %d\n",
|
880
|
+
@m_spinbutton.get_value())
|
881
|
+
|
882
|
+
if event.get_position() < -17
|
883
|
+
value += "Preventing the spin button from going below -17.\n"
|
884
|
+
event.veto()
|
885
|
+
end
|
886
|
+
|
887
|
+
@m_text.append_text(value)
|
888
|
+
end
|
889
|
+
|
890
|
+
def onSpinupdate(event)
|
891
|
+
value = sprintf( "%d", event.get_position() )
|
892
|
+
@m_spintext.set_value( value )
|
893
|
+
|
894
|
+
value = sprintf( "Spin control range: (%d, %d), current = %d\n",
|
895
|
+
@m_spinbutton.get_min(), @m_spinbutton.get_max(),
|
896
|
+
@m_spinbutton.get_value())
|
897
|
+
|
898
|
+
@m_text.append_text(value)
|
899
|
+
end
|
900
|
+
|
901
|
+
def onupdateShowProgress(event)
|
902
|
+
event.enable( @m_spinbutton.get_value() > 0 )
|
903
|
+
end
|
904
|
+
|
905
|
+
def onShowProgress(event)
|
906
|
+
max = @m_spinbutton.get_value()
|
907
|
+
if max <= 0
|
908
|
+
log_error("You must set positive range!")
|
909
|
+
return nil
|
910
|
+
end
|
911
|
+
|
912
|
+
dialog = ProgressDialog.new("Progress dialog example",
|
913
|
+
"An informative message",
|
914
|
+
max, # range
|
915
|
+
self, # parent
|
916
|
+
PD_CAN_ABORT |
|
917
|
+
PD_AUTO_HIDE |
|
918
|
+
PD_APP_MODAL |
|
919
|
+
PD_ELAPSED_TIME |
|
920
|
+
PD_ESTIMATED_TIME |
|
921
|
+
PD_REMAINING_TIME)
|
922
|
+
|
923
|
+
cont = TRUE
|
924
|
+
0.upto(max) {|i|
|
925
|
+
break if !cont
|
926
|
+
sleep(1)
|
927
|
+
if i == max
|
928
|
+
cont = dialog.update(i, "That's all, folks!")
|
929
|
+
elsif i == max / 2
|
930
|
+
cont = dialog.update(i, "Only a half left (very long message)!")
|
931
|
+
else
|
932
|
+
cont = dialog.update(i)
|
933
|
+
end
|
934
|
+
}
|
935
|
+
dialog.destroy()
|
936
|
+
if !cont
|
937
|
+
@m_text << "Progress dialog aborted!\n"
|
938
|
+
else
|
939
|
+
@m_text << "Countdown from " << max << " finished.\n"
|
940
|
+
end
|
941
|
+
end
|
942
|
+
|
943
|
+
def onSizerCheck(event)
|
944
|
+
case event.get_id()
|
945
|
+
when ID_SIZER_CHECK1
|
946
|
+
@m_buttonSizer.show(@m_sizerBtn1, event.is_checked())
|
947
|
+
@m_buttonSizer.layout()
|
948
|
+
when ID_SIZER_CHECK2
|
949
|
+
@m_buttonSizer.show(@m_sizerBtn2, event.is_checked())
|
950
|
+
@m_buttonSizer.layout()
|
951
|
+
when ID_SIZER_CHECK3
|
952
|
+
@m_buttonSizer.show(@m_sizerBtn3, event.is_checked())
|
953
|
+
@m_buttonSizer.layout()
|
954
|
+
when ID_SIZER_CHECK4
|
955
|
+
@m_buttonSizer.show(@m_sizerBtn4, event.is_checked())
|
956
|
+
@m_buttonSizer.layout()
|
957
|
+
when ID_SIZER_CHECK14
|
958
|
+
@m_hsizer.show(@m_buttonSizer, event.is_checked())
|
959
|
+
@m_hsizer.layout()
|
960
|
+
when ID_SIZER_CHECKBIG
|
961
|
+
@m_hsizer.show(@m_bigBtn, event.is_checked())
|
962
|
+
@m_hsizer.layout()
|
963
|
+
end
|
964
|
+
end
|
965
|
+
end
|
966
|
+
|
967
|
+
|
968
|
+
class MyFrame < Frame
|
969
|
+
def initialize(title,x,y)
|
970
|
+
super(nil, -1, title, Point.new(x, y), Size.new(500, 430))
|
971
|
+
|
972
|
+
@s_delay = 5000
|
973
|
+
@s_enabled = TRUE
|
974
|
+
@s_enable2 = TRUE
|
975
|
+
@s_windowFocus = nil
|
976
|
+
mondrian_icon =
|
977
|
+
case Wx::PLATFORM
|
978
|
+
when "WXMSW"
|
979
|
+
Icon.new( File.join( File.dirname(__FILE__), "mondrian.ico"),
|
980
|
+
Wx::BITMAP_TYPE_ICO )
|
981
|
+
else
|
982
|
+
Icon.new( File.join( File.dirname(__FILE__), "mondrian.xpm"),
|
983
|
+
Wx::BITMAP_TYPE_XPM )
|
984
|
+
end
|
985
|
+
|
986
|
+
set_icon(mondrian_icon)
|
987
|
+
|
988
|
+
file_menu = Menu.new
|
989
|
+
|
990
|
+
file_menu.append(CONTROLS_CLEAR_LOG, "&clear log\tCtrl-L")
|
991
|
+
file_menu.append_separator()
|
992
|
+
file_menu.append(CONTROLS_ABOUT, "&About\tF1")
|
993
|
+
file_menu.append_separator()
|
994
|
+
file_menu.append(CONTROLS_QUIT, "E&xit\tAlt-X", "Quit controls sample")
|
995
|
+
|
996
|
+
menu_bar = MenuBar.new
|
997
|
+
menu_bar.append(file_menu, "&File")
|
998
|
+
|
999
|
+
tooltip_menu = Menu.new
|
1000
|
+
tooltip_menu.append(CONTROLS_SET_TOOLTIP_DELAY, "Set &delay\tCtrl-D")
|
1001
|
+
tooltip_menu.append_separator()
|
1002
|
+
tooltip_menu.append(CONTROLS_ENABLE_TOOLTIPS, "&Toggle tooltips\tCtrl-T",
|
1003
|
+
"enable/disable tooltips", ITEM_CHECK)
|
1004
|
+
tooltip_menu.check(CONTROLS_ENABLE_TOOLTIPS, TRUE)
|
1005
|
+
menu_bar.append(tooltip_menu, "&Tooltips")
|
1006
|
+
|
1007
|
+
panel_menu = Menu.new
|
1008
|
+
panel_menu.append(CONTROLS_ENABLE_ALL, "&Disable all\tCtrl-E",
|
1009
|
+
"enable/disable all panel controls", ITEM_CHECK)
|
1010
|
+
menu_bar.append(panel_menu, "&Panel")
|
1011
|
+
|
1012
|
+
set_menu_bar(menu_bar)
|
1013
|
+
|
1014
|
+
create_status_bar(2)
|
1015
|
+
|
1016
|
+
@m_panel = MyPanel.new( self, 10, 10, 300, 100 )
|
1017
|
+
|
1018
|
+
set_size_hints( 500, 425 )
|
1019
|
+
|
1020
|
+
evt_menu(CONTROLS_QUIT) {|event| onQuit(event) }
|
1021
|
+
evt_menu(CONTROLS_ABOUT) {|event| onAbout(event) }
|
1022
|
+
evt_menu(CONTROLS_CLEAR_LOG) {|event| onClearLog(event) }
|
1023
|
+
evt_menu(CONTROLS_SET_TOOLTIP_DELAY) {|event| onSetTooltipDelay(event) }
|
1024
|
+
evt_menu(CONTROLS_ENABLE_TOOLTIPS) {|event| onToggleTooltips(event) }
|
1025
|
+
evt_menu(CONTROLS_ENABLE_ALL) {|event| onenableAll(event) }
|
1026
|
+
|
1027
|
+
evt_size() {|event| onSize(event) }
|
1028
|
+
evt_move() {|event| onMove(event) }
|
1029
|
+
evt_idle() {|event| onIdle(event) }
|
1030
|
+
evt_close() {|event| onClose(event) }
|
1031
|
+
end
|
1032
|
+
|
1033
|
+
def onClose(event)
|
1034
|
+
Log::set_active_target(@m_panel.m_logTargetOld)
|
1035
|
+
destroy()
|
1036
|
+
end
|
1037
|
+
|
1038
|
+
def onQuit(event)
|
1039
|
+
close(TRUE)
|
1040
|
+
end
|
1041
|
+
|
1042
|
+
def onAbout(event)
|
1043
|
+
BusyCursor.busy do
|
1044
|
+
dialog = MessageDialog.new(self, "This is a control sample", "About Controls", OK)
|
1045
|
+
dialog.show_modal()
|
1046
|
+
end
|
1047
|
+
end
|
1048
|
+
|
1049
|
+
def onClearLog(event)
|
1050
|
+
@m_panel.m_text.clear()
|
1051
|
+
end
|
1052
|
+
|
1053
|
+
def onSetTooltipDelay(event)
|
1054
|
+
delay = @s_delay.to_s
|
1055
|
+
|
1056
|
+
delay = get_text_from_user("Enter delay (in milliseconds)",
|
1057
|
+
"Set tooltip delay",
|
1058
|
+
delay,
|
1059
|
+
self)
|
1060
|
+
if !delay
|
1061
|
+
return Qnil # cancelled
|
1062
|
+
end
|
1063
|
+
|
1064
|
+
@s_delay = delay.to_i
|
1065
|
+
|
1066
|
+
ToolTip::set_delay(@s_delay)
|
1067
|
+
|
1068
|
+
log_status(self, "Tooltip delay set to %d milliseconds", @s_delay)
|
1069
|
+
end
|
1070
|
+
|
1071
|
+
def onToggleTooltips(event)
|
1072
|
+
@s_enabled = ! @s_enabled
|
1073
|
+
ToolTip::enable(@s_enabled)
|
1074
|
+
log_status(self, "Tooltips %sabled", @s_enabled ? "en" : "dis" )
|
1075
|
+
end
|
1076
|
+
|
1077
|
+
def onenableAll(event)
|
1078
|
+
@s_enable2 = ! @s_enable2
|
1079
|
+
@m_panel.enable(@s_enable2)
|
1080
|
+
end
|
1081
|
+
|
1082
|
+
def onMove(event)
|
1083
|
+
update_status_bar(event.get_position(), get_size())
|
1084
|
+
event.skip()
|
1085
|
+
end
|
1086
|
+
|
1087
|
+
def onSize(event)
|
1088
|
+
update_status_bar(get_position(), event.get_size())
|
1089
|
+
event.skip()
|
1090
|
+
end
|
1091
|
+
|
1092
|
+
def onIdle(event)
|
1093
|
+
|
1094
|
+
# track the window which has the focus in the status bar
|
1095
|
+
focus = Window::find_focus()
|
1096
|
+
if focus && (focus != @s_windowFocus)
|
1097
|
+
@s_windowFocus = focus
|
1098
|
+
msg = sprintf( "Focus: %s, HWND = %08x",
|
1099
|
+
@s_windowFocus.wx_class,
|
1100
|
+
@s_windowFocus.get_handle )
|
1101
|
+
set_status_text(msg)
|
1102
|
+
end
|
1103
|
+
end
|
1104
|
+
|
1105
|
+
def GetPanel()
|
1106
|
+
@m_panel
|
1107
|
+
end
|
1108
|
+
|
1109
|
+
def update_status_bar(pos,size)
|
1110
|
+
if get_status_bar()
|
1111
|
+
sizeAll = get_size()
|
1112
|
+
sizeCl = get_client_size()
|
1113
|
+
msg = sprintf("pos=(%d, %d), size=%dx%d or %dx%d (client=%dx%d)",
|
1114
|
+
pos.x, pos.y,
|
1115
|
+
size.x, size.y,
|
1116
|
+
sizeAll.x, sizeAll.y,
|
1117
|
+
sizeCl.x, sizeCl.y)
|
1118
|
+
set_status_text(msg, 1)
|
1119
|
+
end
|
1120
|
+
end
|
1121
|
+
|
1122
|
+
end
|
1123
|
+
|
1124
|
+
class MyApp < App
|
1125
|
+
def on_init()
|
1126
|
+
# parse the cmd line
|
1127
|
+
x = 50
|
1128
|
+
y = 50
|
1129
|
+
# Create the main frame window
|
1130
|
+
frame = MyFrame.new("Controls Windows App", x, y)
|
1131
|
+
frame.show(TRUE)
|
1132
|
+
end
|
1133
|
+
end
|
1134
|
+
|
1135
|
+
a = MyApp.new
|
1136
|
+
a.main_loop
|