wxruby3 1.5.4 → 1.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/ext/wxruby3/swig/RubyStockObjects.i +1 -0
- data/lib/wx/aui/auifloatframe.rb +1 -1
- data/lib/wx/aui/auimanager.rb +1 -1
- data/lib/wx/aui/auinotebook.rb +2 -2
- data/lib/wx/core/animation.rb +1 -1
- data/lib/wx/core/cursor.rb +10 -0
- data/lib/wx/core/dataformat.rb +1 -1
- data/lib/wx/core/file_dialog.rb +1 -1
- data/lib/wx/core/geometry.rb +34 -0
- data/lib/wx/core/hboxsizer.rb +22 -0
- data/lib/wx/core/hyperlink_ctrl.rb +18 -0
- data/lib/wx/core/position.rb +58 -0
- data/lib/wx/core/vboxsizer.rb +22 -0
- data/lib/wx/doc/aui/auimanager.rb +6 -3
- data/lib/wx/doc/aui/auinotebook.rb +6 -3
- data/lib/wx/doc/config.rb +14 -8
- data/lib/wx/doc/controlwithitems.rb +7 -3
- data/lib/wx/doc/core.rb +21 -0
- data/lib/wx/doc/geometry.rb +47 -7
- data/lib/wx/doc/graphics_object.rb +24 -0
- data/lib/wx/doc/grid/grid.rb +18 -9
- data/lib/wx/doc/hboxsizer.rb +41 -5
- data/lib/wx/doc/list_ctrl.rb +12 -6
- data/lib/wx/doc/menu.rb +6 -3
- data/lib/wx/doc/notebook.rb +6 -3
- data/lib/wx/doc/pg/pg_property.rb +18 -9
- data/lib/wx/doc/pg/property_grid_interface.rb +4 -4
- data/lib/wx/doc/region_iterator.rb +1 -1
- data/lib/wx/doc/rtc/rich_text_composite_object.rb +6 -3
- data/lib/wx/doc/rtc/rich_text_ctrl.rb +6 -3
- data/lib/wx/doc/rtc/rich_text_paragraph.rb +6 -3
- data/lib/wx/doc/sizer.rb +6 -3
- data/lib/wx/doc/stc/styled_text_ctrl.rb +6 -3
- data/lib/wx/doc/textctrl.rb +6 -3
- data/lib/wx/doc/tree_ctrl.rb +7 -3
- data/lib/wx/doc/v_list_box.rb +6 -3
- data/lib/wx/doc/variant.rb +1 -1
- data/lib/wx/doc/vboxsizer.rb +41 -5
- data/lib/wx/doc/window.rb +6 -3
- data/lib/wx/helpers.rb +28 -0
- data/lib/wx/keyword_ctors.rb +2 -2
- data/lib/wx/keyword_defs.rb +11 -2
- data/lib/wx/pg/pg_property.rb +1 -1
- data/lib/wx/version.rb +1 -1
- data/rakelib/lib/config/mingw.rb +1 -1
- data/rakelib/lib/config.rb +6 -0
- data/rakelib/lib/director/affine_matrix.rb +33 -0
- data/rakelib/lib/director/animation_ctrl.rb +1 -1
- data/rakelib/lib/director/app.rb +1 -1
- data/rakelib/lib/director/aui_manager.rb +2 -2
- data/rakelib/lib/director/aui_notebook.rb +1 -1
- data/rakelib/lib/director/aui_tab_art.rb +4 -4
- data/rakelib/lib/director/ctrl_with_items.rb +1 -1
- data/rakelib/lib/director/cursor.rb +11 -1
- data/rakelib/lib/director/dc.rb +2 -2
- data/rakelib/lib/director/defs.rb +1 -1
- data/rakelib/lib/director/derived_dc.rb +14 -14
- data/rakelib/lib/director/dialog.rb +3 -3
- data/rakelib/lib/director/gdicommon.rb +2 -2
- data/rakelib/lib/director/geometry.rb +55 -3
- data/rakelib/lib/director/graphics_context.rb +8 -3
- data/rakelib/lib/director/graphics_object.rb +29 -2
- data/rakelib/lib/director/html_listbox.rb +6 -5
- data/rakelib/lib/director/hvscrolled_window.rb +140 -0
- data/rakelib/lib/director/hyperlink_ctrl.rb +38 -1
- data/rakelib/lib/director/menu_item.rb +1 -1
- data/rakelib/lib/director/persistent_window.rb +2 -2
- data/rakelib/lib/director/pgeditor.rb +1 -1
- data/rakelib/lib/director/pgproperties.rb +4 -4
- data/rakelib/lib/director/pgproperty.rb +1 -1
- data/rakelib/lib/director/pgvalidation_info.rb +1 -1
- data/rakelib/lib/director/print_data.rb +1 -1
- data/rakelib/lib/director/property_grid_event.rb +1 -1
- data/rakelib/lib/director/property_grid_page.rb +1 -1
- data/rakelib/lib/director/property_grid_page_state.rb +1 -1
- data/rakelib/lib/director/ribbon_tool_bar.rb +1 -1
- data/rakelib/lib/director/richtext_buffer.rb +1 -1
- data/rakelib/lib/director/richtext_formatting_dialog.rb +1 -1
- data/rakelib/lib/director/richtext_paragraph_layout_box.rb +1 -1
- data/rakelib/lib/director/richtext_style_listbox.rb +2 -1
- data/rakelib/lib/director/scrolled_t.rb +22 -0
- data/rakelib/lib/director/sizer.rb +21 -0
- data/rakelib/lib/director/styled_text_event.rb +1 -1
- data/rakelib/lib/director/textctrl.rb +2 -2
- data/rakelib/lib/director/tree_ctrl.rb +1 -1
- data/rakelib/lib/director/utils.rb +1 -1
- data/rakelib/lib/director/variant.rb +1 -1
- data/rakelib/lib/director/vlistbox.rb +5 -3
- data/rakelib/lib/director/window.rb +14 -3
- data/rakelib/lib/extractor/function.rb +46 -15
- data/rakelib/lib/generate/doc/hyperlink_ctrl.yaml +22 -0
- data/rakelib/lib/generate/doc/scrolled_canvas.yaml +38 -0
- data/rakelib/lib/generate/doc/scrolled_control.yaml +38 -0
- data/rakelib/lib/generate/doc/scrolled_window.yaml +38 -0
- data/rakelib/lib/specs/interfaces.rb +2 -2
- data/rakelib/lib/typemap/print_page_range.rb +1 -1
- data/samples/scrolling/tn_varscroll.png +0 -0
- data/samples/scrolling/varscroll.rb +416 -0
- data/samples/widgets/hyperlink.rb +85 -60
- metadata +12 -6
- data/rakelib/lib/director/vscrolled_window.rb +0 -62
- /data/samples/{controls → scrolling}/htlbox.rb +0 -0
- /data/samples/{etc → scrolling}/scrollwin.rb +0 -0
- /data/samples/{controls → scrolling}/tn_htlbox.png +0 -0
- /data/samples/{etc → scrolling}/tn_scrollwin.png +0 -0
@@ -0,0 +1,416 @@
|
|
1
|
+
# Copyright (c) 2023 M.J.N. Corino, The Netherlands
|
2
|
+
#
|
3
|
+
# This software is released under the MIT license.
|
4
|
+
#
|
5
|
+
# Adapted for wxRuby from wxWidgets vscroll sample
|
6
|
+
# Copyright (c) 2001 Vadim Zeitlin
|
7
|
+
|
8
|
+
require 'wx'
|
9
|
+
|
10
|
+
# Example demonstrating the use of Wx::VScrolledWindow, Wx::HScrolledWindow and
|
11
|
+
# Wx::HVScrolledWindow
|
12
|
+
|
13
|
+
module VarScroll
|
14
|
+
|
15
|
+
MAX_LINES = 10000
|
16
|
+
|
17
|
+
# Define a new frame type: this is going to be our main frame
|
18
|
+
class VarScrollFrame < Wx::Frame
|
19
|
+
|
20
|
+
module ID
|
21
|
+
include Wx::IDHelper
|
22
|
+
|
23
|
+
# menu items
|
24
|
+
VScroll_Quit = Wx::ID_EXIT
|
25
|
+
|
26
|
+
# it is important for the id corresponding to the "About" command to have
|
27
|
+
# this standard value as otherwise it won't be handled properly under Mac
|
28
|
+
# (where it is special and put into the "Apple" menu)
|
29
|
+
VScroll_About = Wx::ID_ABOUT
|
30
|
+
|
31
|
+
VScroll_VScrollMode = self.next_id
|
32
|
+
VScroll_HScrollMode = self.next_id
|
33
|
+
VScroll_HVScrollMode = self.next_id
|
34
|
+
end
|
35
|
+
|
36
|
+
def initialize
|
37
|
+
super(nil, Wx::ID_ANY, 'VarScroll wxWidgets Sample', size: [400, 350])
|
38
|
+
|
39
|
+
set_icon(Wx.Icon(:sample, art_path: File.dirname(__dir__)))
|
40
|
+
|
41
|
+
# either a Wx::VScrolledWindow, Wx::HScrolledWindow or a Wx::HVScrolledWindow, depending on current mode
|
42
|
+
@scrollWindow = nil
|
43
|
+
|
44
|
+
if Wx.has_feature?(:USE_MENUS)
|
45
|
+
# create a menu bar
|
46
|
+
menuFile = Wx::Menu.new
|
47
|
+
|
48
|
+
menuMode = Wx::Menu.new
|
49
|
+
|
50
|
+
# the "About" item should be in the help menu
|
51
|
+
menuHelp = Wx::Menu.new
|
52
|
+
menuHelp.append(ID::VScroll_About, "&About\tF1", 'Show about dialog')
|
53
|
+
|
54
|
+
menuMode.append_radio_item(ID::VScroll_VScrollMode, "&Vertical\tAlt-V",
|
55
|
+
'Vertical scrolling only')
|
56
|
+
menuMode.append_radio_item(ID::VScroll_HScrollMode, "&Horizontal\tAlt-H",
|
57
|
+
'Horizontal scrolling only')
|
58
|
+
menuMode.append_radio_item(ID::VScroll_HVScrollMode,
|
59
|
+
"Hori&zontal/Vertical\tAlt-Z",
|
60
|
+
'Horizontal and vertical scrolling')
|
61
|
+
menuMode.check(ID::VScroll_VScrollMode, true)
|
62
|
+
|
63
|
+
menuFile.append(ID::VScroll_Quit, "E&xit\tAlt-X", 'Quit this program')
|
64
|
+
|
65
|
+
# now append the freshly created menu to the menu bar...
|
66
|
+
menuBar = Wx::MenuBar.new
|
67
|
+
menuBar.append(menuFile, '&File')
|
68
|
+
menuBar.append(menuMode, '&Mode')
|
69
|
+
menuBar.append(menuHelp, '&Help')
|
70
|
+
|
71
|
+
# ... and attach this menu bar to the frame
|
72
|
+
set_menu_bar(menuBar)
|
73
|
+
end # USE_MENUS
|
74
|
+
|
75
|
+
if Wx.has_feature?(:USE_STATUSBAR)
|
76
|
+
# create a status bar just for fun (by default with 1 pane only)
|
77
|
+
create_status_bar(2)
|
78
|
+
set_status_text("Welcome to wxWidgets!")
|
79
|
+
set_status_widths([-1, 100])
|
80
|
+
end # USE_STATUSBAR
|
81
|
+
|
82
|
+
# create our one and only child -- it will take our entire client area
|
83
|
+
if menuMode.is_checked(ID::VScroll_VScrollMode)
|
84
|
+
@scrollWindow = VScrollWindow.new(self)
|
85
|
+
elsif menuMode.is_checked(ID::VScroll_HScrollMode)
|
86
|
+
@scrollWindow = HScrollWindow.new(self)
|
87
|
+
else
|
88
|
+
@scrollWindow = HVScrollWindow.new(self)
|
89
|
+
end
|
90
|
+
|
91
|
+
evt_menu(ID::VScroll_Quit, :on_quit)
|
92
|
+
evt_menu(ID::VScroll_VScrollMode, :on_mode_v_scroll)
|
93
|
+
evt_menu(ID::VScroll_HScrollMode, :on_mode_h_scroll)
|
94
|
+
evt_menu(ID::VScroll_HVScrollMode, :on_mode_hv_scroll)
|
95
|
+
evt_menu(ID::VScroll_About, :on_about)
|
96
|
+
evt_size :on_size
|
97
|
+
end
|
98
|
+
|
99
|
+
# event handlers
|
100
|
+
def on_quit(_event)
|
101
|
+
close(true)
|
102
|
+
end
|
103
|
+
|
104
|
+
def on_mode_v_scroll(_event)
|
105
|
+
@scrollWindow.destroy if @scrollWindow
|
106
|
+
|
107
|
+
@scrollWindow = VScrollWindow.new(self)
|
108
|
+
send_size_event
|
109
|
+
end
|
110
|
+
|
111
|
+
def on_mode_h_scroll(_event)
|
112
|
+
@scrollWindow.destroy if @scrollWindow
|
113
|
+
|
114
|
+
@scrollWindow = HScrollWindow.new(self)
|
115
|
+
send_size_event
|
116
|
+
end
|
117
|
+
|
118
|
+
def on_mode_hv_scroll(_event)
|
119
|
+
@scrollWindow.destroy if @scrollWindow
|
120
|
+
|
121
|
+
@scrollWindow = HVScrollWindow.new(self)
|
122
|
+
send_size_event
|
123
|
+
end
|
124
|
+
|
125
|
+
def on_about(_event)
|
126
|
+
Wx.message_box("VarScroll shows how to implement scrolling with\n" +
|
127
|
+
"variable line widths and heights.\n" +
|
128
|
+
"(c) 2025 Martin Corino\n" +
|
129
|
+
"Adapted for wxRuby from wxWidgets vscroll sample, \n" +
|
130
|
+
"(c) 2003 Vadim Zeitlin",
|
131
|
+
"About VarScroll",
|
132
|
+
Wx::OK | Wx::ICON_INFORMATION,
|
133
|
+
self)
|
134
|
+
end
|
135
|
+
|
136
|
+
def on_size(event)
|
137
|
+
# show current size in the status bar
|
138
|
+
if Wx.has_feature?(:USE_STATUSBAR)
|
139
|
+
sz = get_client_size
|
140
|
+
set_status_text('%dx%d' % [sz.x, sz.y], 1)
|
141
|
+
end # USE_STATUSBAR
|
142
|
+
|
143
|
+
event.skip
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
class VScrollWindow < Wx::VScrolledWindow
|
148
|
+
def initialize(frame)
|
149
|
+
super(frame, Wx::ID_ANY)
|
150
|
+
@frame = frame
|
151
|
+
|
152
|
+
@heights = ::Array.new(MAX_LINES) { |i| rand(16..40) } # low: 16; high: 40
|
153
|
+
|
154
|
+
@changed = true
|
155
|
+
|
156
|
+
set_row_count(MAX_LINES)
|
157
|
+
|
158
|
+
evt_idle :on_idle
|
159
|
+
evt_paint :on_paint
|
160
|
+
evt_scrollwin :on_scroll
|
161
|
+
evt_mouse_events :on_mouse
|
162
|
+
end
|
163
|
+
|
164
|
+
def on_idle(_)
|
165
|
+
if Wx.has_feature?(:USE_STATUSBAR)
|
166
|
+
@frame.set_status_text('Page size = %d, pos = %d, max = %d' % [
|
167
|
+
get_scroll_thumb(Wx::VERTICAL),
|
168
|
+
get_scroll_pos(Wx::VERTICAL),
|
169
|
+
get_scroll_range(Wx::VERTICAL) ])
|
170
|
+
end # USE_STATUSBAR
|
171
|
+
@changed = false
|
172
|
+
end
|
173
|
+
|
174
|
+
def on_paint(_)
|
175
|
+
paint do |dc|
|
176
|
+
|
177
|
+
dc.with_pen(Wx::BLACK_PEN) do
|
178
|
+
lineFirst = get_visible_begin
|
179
|
+
lineLast = get_visible_end
|
180
|
+
|
181
|
+
hText = dc.get_char_height
|
182
|
+
|
183
|
+
clientSize = get_client_size
|
184
|
+
|
185
|
+
y = 0
|
186
|
+
(lineFirst...lineLast).each do |line|
|
187
|
+
dc.draw_line(0, y, clientSize.width, y)
|
188
|
+
|
189
|
+
hLine = on_get_row_height(line)
|
190
|
+
dc.draw_text('Line %d' % line, 2, y + (hLine - hText) / 2)
|
191
|
+
|
192
|
+
y += hLine
|
193
|
+
dc.draw_line(0, y, 1000, y)
|
194
|
+
end
|
195
|
+
end
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
def on_scroll(event)
|
200
|
+
@changed = true
|
201
|
+
|
202
|
+
event.skip
|
203
|
+
end
|
204
|
+
|
205
|
+
def on_mouse(event)
|
206
|
+
if event.left_down
|
207
|
+
capture_mouse
|
208
|
+
elsif event.left_up
|
209
|
+
release_mouse
|
210
|
+
end
|
211
|
+
event.skip
|
212
|
+
end
|
213
|
+
|
214
|
+
def on_get_row_height(n)
|
215
|
+
raise ArgumentError, 'row index too high' unless n < get_row_count
|
216
|
+
|
217
|
+
@heights[n]
|
218
|
+
end
|
219
|
+
|
220
|
+
end
|
221
|
+
|
222
|
+
class HScrollWindow < Wx::HScrolledWindow
|
223
|
+
def initialize(frame)
|
224
|
+
super(frame, Wx::ID_ANY)
|
225
|
+
@frame = frame
|
226
|
+
|
227
|
+
@widths = ::Array.new(MAX_LINES) { |i| rand(16..40) } # low: 16; high: 40
|
228
|
+
|
229
|
+
@changed = true
|
230
|
+
|
231
|
+
set_column_count(MAX_LINES)
|
232
|
+
|
233
|
+
evt_idle :on_idle
|
234
|
+
evt_paint :on_paint
|
235
|
+
evt_scrollwin :on_scroll
|
236
|
+
evt_mouse_events :on_mouse
|
237
|
+
end
|
238
|
+
|
239
|
+
def on_idle(_)
|
240
|
+
if Wx.has_feature?(:USE_STATUSBAR)
|
241
|
+
@frame.set_status_text('Page size = %d, pos = %d, max = %d' % [
|
242
|
+
get_scroll_thumb(Wx::HORIZONTAL),
|
243
|
+
get_scroll_pos(Wx::HORIZONTAL),
|
244
|
+
get_scroll_range(Wx::HORIZONTAL) ])
|
245
|
+
end # USE_STATUSBAR
|
246
|
+
@changed = false
|
247
|
+
end
|
248
|
+
|
249
|
+
def on_paint(_)
|
250
|
+
paint do |dc|
|
251
|
+
|
252
|
+
dc.with_pen(Wx::BLACK_PEN) do
|
253
|
+
lineFirst = get_visible_begin
|
254
|
+
lineLast = get_visible_end
|
255
|
+
|
256
|
+
hText = dc.get_char_height
|
257
|
+
|
258
|
+
clientSize = get_client_size
|
259
|
+
|
260
|
+
x = 0
|
261
|
+
(lineFirst...lineLast).each do |col|
|
262
|
+
dc.draw_line(x, 0, x, clientSize.height)
|
263
|
+
|
264
|
+
wCol = on_get_column_width(col)
|
265
|
+
dc.draw_rotated_text('Column %d' % col, x + (wCol - hText) / 2, clientSize.height - 5, 90)
|
266
|
+
|
267
|
+
x += wCol
|
268
|
+
dc.draw_line(x, 0, x, 1000)
|
269
|
+
end
|
270
|
+
end
|
271
|
+
end
|
272
|
+
end
|
273
|
+
|
274
|
+
def on_scroll(event)
|
275
|
+
@changed = true
|
276
|
+
|
277
|
+
event.skip
|
278
|
+
end
|
279
|
+
|
280
|
+
def on_mouse(event)
|
281
|
+
if event.left_down
|
282
|
+
capture_mouse
|
283
|
+
elsif event.left_up
|
284
|
+
release_mouse
|
285
|
+
end
|
286
|
+
event.skip
|
287
|
+
end
|
288
|
+
|
289
|
+
def on_get_column_width(n)
|
290
|
+
raise ArgumentError, 'column index too high' unless n < get_column_count
|
291
|
+
|
292
|
+
@widths[n]
|
293
|
+
end
|
294
|
+
|
295
|
+
end
|
296
|
+
|
297
|
+
class HVScrollWindow < Wx::HVScrolledWindow
|
298
|
+
def initialize(frame)
|
299
|
+
super(frame, Wx::ID_ANY)
|
300
|
+
@frame = frame
|
301
|
+
|
302
|
+
@widths = ::Array.new(MAX_LINES) { |i| rand(60..90) } # low: 60; high: 90
|
303
|
+
@heights = ::Array.new(MAX_LINES) { |i| rand(30..60) } # low: 30; high: 60
|
304
|
+
|
305
|
+
@changed = true
|
306
|
+
|
307
|
+
set_row_column_count(MAX_LINES, MAX_LINES)
|
308
|
+
|
309
|
+
evt_idle :on_idle
|
310
|
+
evt_paint :on_paint
|
311
|
+
evt_scrollwin :on_scroll
|
312
|
+
evt_mouse_events :on_mouse
|
313
|
+
end
|
314
|
+
|
315
|
+
def on_idle(_)
|
316
|
+
if Wx.has_feature?(:USE_STATUSBAR)
|
317
|
+
@frame.set_status_text('Page size = %d rows %d columns; pos = row: %d, column: %d; max = %d rows, %d columns' % [
|
318
|
+
get_scroll_thumb(Wx::VERTICAL),
|
319
|
+
get_scroll_thumb(Wx::HORIZONTAL),
|
320
|
+
get_scroll_pos(Wx::VERTICAL),
|
321
|
+
get_scroll_pos(Wx::HORIZONTAL),
|
322
|
+
get_scroll_range(Wx::VERTICAL),
|
323
|
+
get_scroll_range(Wx::HORIZONTAL) ])
|
324
|
+
end # USE_STATUSBAR
|
325
|
+
@changed = false
|
326
|
+
end
|
327
|
+
|
328
|
+
def on_paint(_)
|
329
|
+
paint do |dc|
|
330
|
+
|
331
|
+
dc.with_pen(Wx::BLACK_PEN) do
|
332
|
+
rowFirst = get_visible_rows_begin
|
333
|
+
rowLast = get_visible_rows_end
|
334
|
+
columnFirst = get_visible_columns_begin
|
335
|
+
columnLast = get_visible_columns_end
|
336
|
+
|
337
|
+
hText = dc.get_char_height
|
338
|
+
|
339
|
+
clientSize = get_client_size
|
340
|
+
|
341
|
+
y =0
|
342
|
+
(rowFirst...rowLast).each do |row|
|
343
|
+
rowHeight = on_get_row_height(row)
|
344
|
+
dc.draw_line(0, y, clientSize.width, y)
|
345
|
+
x = 0
|
346
|
+
(columnFirst...columnLast).each do |col|
|
347
|
+
colWidth = on_get_column_width(col)
|
348
|
+
|
349
|
+
dc.draw_line(x, 0, x, clientSize.height) if row == rowFirst
|
350
|
+
|
351
|
+
dc.draw_text('Row %d' % row, x + 2, y + rowHeight / 2 - hText)
|
352
|
+
dc.draw_text('Col %d' % col, x + 2, y + rowHeight / 2)
|
353
|
+
|
354
|
+
|
355
|
+
x += colWidth;
|
356
|
+
dc.draw_line(x, 0, x, clientSize.height) if row == rowFirst
|
357
|
+
end
|
358
|
+
|
359
|
+
y += rowHeight
|
360
|
+
dc.draw_line(0, y, clientSize.width, y)
|
361
|
+
end
|
362
|
+
end
|
363
|
+
end
|
364
|
+
end
|
365
|
+
|
366
|
+
def on_scroll(event)
|
367
|
+
@changed = true
|
368
|
+
|
369
|
+
event.skip
|
370
|
+
end
|
371
|
+
|
372
|
+
def on_mouse(event)
|
373
|
+
if event.left_down
|
374
|
+
capture_mouse
|
375
|
+
elsif event.left_up
|
376
|
+
release_mouse
|
377
|
+
end
|
378
|
+
event.skip
|
379
|
+
end
|
380
|
+
|
381
|
+
def on_get_row_height(n)
|
382
|
+
raise ArgumentError, 'row index too high' unless n < get_row_count
|
383
|
+
|
384
|
+
@heights[n]
|
385
|
+
end
|
386
|
+
|
387
|
+
def on_get_column_width(n)
|
388
|
+
raise ArgumentError, 'column index too high' unless n < get_column_count
|
389
|
+
|
390
|
+
@widths[n]
|
391
|
+
end
|
392
|
+
|
393
|
+
end
|
394
|
+
end
|
395
|
+
|
396
|
+
module VarScrollSample
|
397
|
+
|
398
|
+
include WxRuby::Sample if defined? WxRuby::Sample
|
399
|
+
|
400
|
+
def self.describe
|
401
|
+
{ file: __FILE__,
|
402
|
+
summary: 'wxRuby VarScroll example.',
|
403
|
+
description: 'wxRuby example demonstrating the use of Wx::VScrolledWindow, Wx::HScrolledWindow and Wx::HVScrolledWindow.' }
|
404
|
+
end
|
405
|
+
|
406
|
+
def self.activate
|
407
|
+
frame = VarScroll::VarScrollFrame.new
|
408
|
+
frame.show(true)
|
409
|
+
frame
|
410
|
+
end
|
411
|
+
|
412
|
+
if $0 == __FILE__
|
413
|
+
Wx::App.run { VarScrollSample.activate }
|
414
|
+
end
|
415
|
+
|
416
|
+
end
|
@@ -34,8 +34,14 @@ module Widgets
|
|
34
34
|
def get_widget
|
35
35
|
@hyperlink
|
36
36
|
end
|
37
|
+
|
38
|
+
def get_widgets
|
39
|
+
[get_widget, @hyperlinkLong]
|
40
|
+
end
|
41
|
+
|
37
42
|
def recreate_widget
|
38
43
|
create_hyperlink
|
44
|
+
create_hyperlink_long
|
39
45
|
end
|
40
46
|
|
41
47
|
# lazy creation of the content
|
@@ -45,32 +51,42 @@ module Widgets
|
|
45
51
|
# left pane
|
46
52
|
sizerLeft = Wx::StaticBoxSizer.new(Wx::VERTICAL, self, 'Hyperlink details')
|
47
53
|
sizerLeftBox = sizerLeft.get_static_box
|
48
|
-
|
54
|
+
|
55
|
+
choices = Wx::PLATFORM == 'WXOSX' ? %w[default generic] : %w[native generic]
|
56
|
+
@radioImplementation = Wx::RadioBox.new(sizerLeftBox, Wx::ID_ANY, 'Implementation',
|
57
|
+
choices: choices)
|
58
|
+
sizerLeft.add(@radioImplementation, 0, Wx::ALL|Wx::GROW, 5)
|
59
|
+
|
49
60
|
szr, @label = create_sizer_with_text_and_button(ID::SetLabel,'Set &Label', Wx::ID_ANY, sizerLeftBox)
|
50
61
|
sizerLeft.add(szr, 0, Wx::ALL | Wx::ALIGN_RIGHT, 5)
|
51
|
-
|
62
|
+
|
52
63
|
szr, @url = create_sizer_with_text_and_button(ID::SetURL,'Set &URL', Wx::ID_ANY, sizerLeftBox)
|
53
64
|
sizerLeft.add(szr, 0, Wx::ALL | Wx::ALIGN_RIGHT, 5)
|
54
|
-
|
65
|
+
|
55
66
|
alignments = %w{&left ¢re &right}
|
56
67
|
|
57
68
|
@radioAlignMode = Wx::RadioBox.new(sizerLeftBox, Wx::ID_ANY, 'alignment',
|
58
69
|
choices: alignments)
|
59
|
-
@radioAlignMode.set_selection(1) # start with "centre" selected since
|
60
|
-
# wxHL_DEFAULT_STYLE contains wxHL_ALIGN_CENTRE
|
61
70
|
sizerLeft.add(@radioAlignMode, 0, Wx::ALL|Wx::GROW, 5)
|
62
|
-
|
71
|
+
|
72
|
+
b0 = Wx::Button.new(sizerLeftBox, Wx::ID_ANY, '&Reset')
|
73
|
+
b0.evt_button(Wx::ID_ANY, self.method(:on_button_reset))
|
74
|
+
sizerLeft.add(b0, 0, Wx::ALIGN_CENTRE_HORIZONTAL | Wx::ALL, 15)
|
75
|
+
|
76
|
+
@hyperlink = nil
|
77
|
+
@hyperlinkLong = nil
|
78
|
+
|
79
|
+
# initializations
|
80
|
+
reset
|
81
|
+
|
82
|
+
recreate_widget # create hyperlink controls
|
83
|
+
|
63
84
|
# right pane
|
64
85
|
szHyperlinkLong = Wx::VBoxSizer.new
|
65
86
|
szHyperlink = Wx::HBoxSizer.new
|
66
87
|
|
67
88
|
@visit = Wx::StaticText.new(self, Wx::ID_ANY, 'Visit ')
|
68
89
|
|
69
|
-
@hyperlink = Wx::HyperlinkCtrl.new(self,
|
70
|
-
ID::Ctrl,
|
71
|
-
'wxRuby website',
|
72
|
-
'www.github.com/mcorino/wxRuby3')
|
73
|
-
|
74
90
|
@fun = Wx::StaticText.new(self, Wx::ID_ANY, " for fun!")
|
75
91
|
|
76
92
|
szHyperlink.add(0, 0, 1, Wx::CENTRE)
|
@@ -80,11 +96,6 @@ module Widgets
|
|
80
96
|
szHyperlink.add(0, 0, 1, Wx::CENTRE)
|
81
97
|
szHyperlink.set_min_size(150, 0)
|
82
98
|
|
83
|
-
@hyperlinkLong = Wx::HyperlinkCtrl.new(self,
|
84
|
-
Wx::ID_ANY,
|
85
|
-
'This is a long hyperlink',
|
86
|
-
'www.github.com/mcorino/wxRuby3')
|
87
|
-
|
88
99
|
szHyperlinkLong.add(0, 0, 1, Wx::CENTRE)
|
89
100
|
szHyperlinkLong.add(szHyperlink, 0, Wx::CENTRE|Wx::GROW)
|
90
101
|
szHyperlinkLong.add(0, 0, 1, Wx::CENTRE)
|
@@ -95,10 +106,7 @@ module Widgets
|
|
95
106
|
# the 3 panes panes compose the window
|
96
107
|
sizerTop.add(sizerLeft, 0, (Wx::ALL & ~Wx::LEFT), 10)
|
97
108
|
sizerTop.add(szHyperlinkLong, 1, Wx::GROW | (Wx::ALL & ~Wx::RIGHT), 10)
|
98
|
-
|
99
|
-
# final initializations
|
100
|
-
reset
|
101
|
-
|
109
|
+
|
102
110
|
set_sizer(sizerTop)
|
103
111
|
|
104
112
|
# connect event handlers
|
@@ -114,86 +122,103 @@ module Widgets
|
|
114
122
|
# event handlers
|
115
123
|
def on_button_set_label(_event)
|
116
124
|
@hyperlink.set_label(@label.value)
|
117
|
-
|
125
|
+
recreate_widget
|
118
126
|
end
|
119
127
|
|
120
128
|
def on_button_set_url(_event)
|
121
129
|
@hyperlink.set_url(@url.value)
|
122
|
-
|
130
|
+
recreate_widget
|
123
131
|
end
|
124
132
|
|
125
133
|
def on_button_reset(_event)
|
126
134
|
reset
|
127
135
|
|
128
|
-
|
136
|
+
recreate_widget
|
129
137
|
end
|
130
138
|
|
131
139
|
def on_alignment(_event)
|
132
|
-
case @radioAlignMode.selection
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
140
|
+
@alignment = case @radioAlignMode.selection
|
141
|
+
when ID::Align_Left
|
142
|
+
addstyle = Wx::HL_ALIGN_LEFT
|
143
|
+
when ID::Align_Centre
|
144
|
+
addstyle = Wx::HL_ALIGN_CENTRE
|
145
|
+
when ID::Align_Right
|
146
|
+
addstyle = Wx::HL_ALIGN_RIGHT
|
147
|
+
else
|
148
|
+
::Kernel.raise RuntimeError, 'unknown alignment'
|
149
|
+
end
|
150
|
+
|
151
|
+
recreate_widget
|
144
152
|
end
|
145
153
|
|
146
154
|
# reset the control parameters
|
147
155
|
def reset
|
148
|
-
@
|
149
|
-
@
|
156
|
+
@radioImplementation.set_selection(0) # start with "native" or "default" selected
|
157
|
+
@label.value = 'wxRuby website'
|
158
|
+
@url.value = 'www.github.com/mcorino/wxRuby3'
|
159
|
+
@radioAlignMode.set_selection(1) # start with "centre" selected
|
160
|
+
@alignment = Wx::HL_ALIGN_CENTRE
|
150
161
|
end
|
151
162
|
|
152
163
|
# (re)create the hyperlinkctrl
|
153
164
|
def create_hyperlink
|
154
|
-
label = @hyperlink.label
|
155
|
-
url = @hyperlink.url
|
156
165
|
style = get_attrs.default_flags
|
157
|
-
|
166
|
+
|
158
167
|
style |= Wx::HL_DEFAULT_STYLE & ~Wx::BORDER_MASK
|
159
|
-
|
160
|
-
hyp =
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
168
|
+
|
169
|
+
hyp = if @radioImplementation.selection == 0
|
170
|
+
Wx::HyperlinkCtrl.new(self,
|
171
|
+
Wx::ID_ANY,
|
172
|
+
@label.value,
|
173
|
+
@url.value,
|
174
|
+
style: style)
|
175
|
+
else
|
176
|
+
Wx::GenericHyperlinkCtrl.new(self,
|
177
|
+
Wx::ID_ANY,
|
178
|
+
@label.value,
|
179
|
+
@url.value,
|
180
|
+
style: style)
|
181
|
+
end
|
165
182
|
|
166
183
|
# update sizer's child window
|
167
|
-
get_sizer.replace(@hyperlink, hyp, true)
|
184
|
+
get_sizer.replace(@hyperlink, hyp, true) if get_sizer
|
168
185
|
|
169
186
|
# update our pointer
|
170
|
-
@hyperlink.destroy
|
187
|
+
@hyperlink.destroy if @hyperlink
|
171
188
|
@hyperlink = hyp
|
172
189
|
|
173
190
|
# re-layout the sizer
|
174
|
-
get_sizer.layout
|
191
|
+
get_sizer.layout if get_sizer
|
175
192
|
end
|
176
193
|
|
177
|
-
def create_hyperlink_long
|
194
|
+
def create_hyperlink_long
|
178
195
|
style = get_attrs.default_flags
|
179
|
-
style |=
|
196
|
+
style |= @alignment
|
180
197
|
style |= Wx::HL_DEFAULT_STYLE & ~(Wx::HL_ALIGN_CENTRE | Wx::BORDER_MASK)
|
181
|
-
|
182
|
-
hyp =
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
198
|
+
|
199
|
+
hyp = if @radioImplementation.selection == 0
|
200
|
+
Wx::HyperlinkCtrl.new(self,
|
201
|
+
Wx::ID_ANY,
|
202
|
+
'This is a long hyperlink',
|
203
|
+
@url.value,
|
204
|
+
style: style)
|
205
|
+
else
|
206
|
+
Wx::GenericHyperlinkCtrl.new(self,
|
207
|
+
Wx::ID_ANY,
|
208
|
+
'This is a long hyperlink',
|
209
|
+
@url.value,
|
210
|
+
style: style)
|
211
|
+
end
|
187
212
|
|
188
213
|
# update sizer's child window
|
189
|
-
get_sizer.replace(@hyperlinkLong, hyp, true)
|
214
|
+
get_sizer.replace(@hyperlinkLong, hyp, true) if get_sizer
|
190
215
|
|
191
216
|
# update our pointer
|
192
|
-
@hyperlinkLong.destroy
|
217
|
+
@hyperlinkLong.destroy if @hyperlinkLong
|
193
218
|
@hyperlinkLong = hyp
|
194
219
|
|
195
220
|
# re-layout the sizer
|
196
|
-
get_sizer.layout
|
221
|
+
get_sizer.layout if get_sizer
|
197
222
|
end
|
198
223
|
|
199
224
|
end
|