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