wxruby3 0.9.4 → 0.9.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/INSTALL.md +1 -1
- data/README.md +2 -2
- data/ext/wxruby3/include/wxruby-ComboPopup.h +777 -0
- data/lib/wx/core/combo_ctrl.rb +171 -0
- data/lib/wx/doc/comboctrl.rb +128 -3
- data/lib/wx/doc/owner_drawn_combobox.rb +5 -1
- data/lib/wx/version.rb +1 -1
- data/rakelib/lib/core/include/funcall.inc +2 -1
- data/rakelib/lib/director/comboctrl.rb +104 -3
- data/rakelib/lib/director/defs.rb +1 -3
- data/rakelib/lib/director/gdicommon.rb +6 -0
- data/rakelib/lib/director/menu_item.rb +1 -1
- data/rakelib/lib/director/num_validator.rb +5 -7
- data/rakelib/lib/director/owner_drawn_combobox.rb +1 -0
- data/rakelib/lib/director/persistent_window.rb +2 -2
- data/rakelib/lib/director/pgeditor.rb +1 -1
- data/rakelib/lib/director/pgproperties.rb +3 -3
- data/rakelib/lib/director/pgproperty.rb +5 -1
- data/rakelib/lib/director/richtext_style_listbox.rb +5 -0
- data/rakelib/lib/director/sizer.rb +1 -1
- data/rakelib/lib/director/window.rb +4 -0
- data/rakelib/lib/extractor/module.rb +15 -0
- data/rakelib/lib/generate/doc/combo_ctrl.yaml +135 -0
- data/rakelib/lib/generate/doc/file_dialog_customize_hook.yaml +62 -0
- data/rakelib/lib/generate/doc/file_system.yaml +28 -0
- data/rakelib/lib/generate/interface.rb +12 -4
- data/rakelib/lib/swig_runner.rb +7 -4
- data/rakelib/lib/typemap/combo_popup.rb +42 -0
- data/tests/test_combo_ctrl.rb +196 -0
- metadata +9 -2
@@ -0,0 +1,135 @@
|
|
1
|
+
---
|
2
|
+
:wxComboCtrl:
|
3
|
+
:detail:
|
4
|
+
:pre:
|
5
|
+
:programlisting:
|
6
|
+
- :pattern: !ruby/regexp /wxDECLARE_EVENT_TABLE/
|
7
|
+
:replace: |
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
class ListViewComboPopup < Wx::ListView
|
11
|
+
|
12
|
+
include Wx::ComboPopup
|
13
|
+
|
14
|
+
# Allow only default ctor
|
15
|
+
def initialize
|
16
|
+
# call default control ctor; need to call Wx::ListView#create later
|
17
|
+
super
|
18
|
+
end
|
19
|
+
|
20
|
+
# Initialize member variables
|
21
|
+
def init
|
22
|
+
@value = -1
|
23
|
+
end
|
24
|
+
|
25
|
+
# Create popup control
|
26
|
+
def create(parent)
|
27
|
+
# need to finish creating the list view here
|
28
|
+
# as calling super here would just call Wx::ComboPopup#create and not Wx::ListView#create
|
29
|
+
# we need to use Ruby magic
|
30
|
+
wx_lv_create = (Wx::ListView.instance_method :create).bind(self)
|
31
|
+
wx_lv_create.call(parent, 1, [0,0], Wx::DEFAULT_SIZE)
|
32
|
+
evt_motion :on_mouse_move
|
33
|
+
evt_left_up :on_mouse_click
|
34
|
+
end
|
35
|
+
|
36
|
+
# Return pointer to the created control
|
37
|
+
def get_control
|
38
|
+
self
|
39
|
+
end
|
40
|
+
|
41
|
+
def lv_find_item(*args)
|
42
|
+
unless @wx_lv_find_item
|
43
|
+
@wx_lv_find_item = (Wx::ListView.instance_method :find_item).bind(self)
|
44
|
+
end
|
45
|
+
@wx_lv_find_item.call(*args)
|
46
|
+
end
|
47
|
+
protected :lv_find_item
|
48
|
+
|
49
|
+
# Translate string into a list selection
|
50
|
+
def set_string_value(s)
|
51
|
+
n = lv_find_item(-1, s)
|
52
|
+
if n >= 0 && n < get_item_count
|
53
|
+
select(n)
|
54
|
+
@value = n
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
# Get list selection as a string
|
59
|
+
def get_string_value
|
60
|
+
return get_item_text(@value) if @value >= 0
|
61
|
+
''
|
62
|
+
end
|
63
|
+
|
64
|
+
# Do mouse hot-tracking (which is typical in list popups)
|
65
|
+
def on_mouse_move(event)
|
66
|
+
# Move selection to cursor ...
|
67
|
+
end
|
68
|
+
|
69
|
+
# On mouse left up, set the value and close the popup
|
70
|
+
def on_mouse_click(_event)
|
71
|
+
@value = get_first_selected
|
72
|
+
|
73
|
+
# Send event as well ...
|
74
|
+
|
75
|
+
dismiss
|
76
|
+
end
|
77
|
+
|
78
|
+
end
|
79
|
+
```
|
80
|
+
- :pattern: !ruby/regexp /wxComboCtrl/
|
81
|
+
:replace: |
|
82
|
+
|
83
|
+
```ruby
|
84
|
+
comboCtrl = Wx::ComboCtrl.new(self, Wx::ID_ANY, '')
|
85
|
+
|
86
|
+
popupCtrl = ListViewComboPopup.new
|
87
|
+
|
88
|
+
# It is important to call #set_popup_control as soon as possible
|
89
|
+
comboCtrl.set_popup_control(popupCtrl)
|
90
|
+
|
91
|
+
# Populate using Wx::ListView methods
|
92
|
+
popupCtrl.insert_item((popupCtrl.item_count, 'First Item')
|
93
|
+
popupCtrl.insert_item((popupCtrl.item_count, 'Second Item')
|
94
|
+
popupCtrl.insert_item((popupCtrl.item_count, 'Third Item')
|
95
|
+
```
|
96
|
+
:wxComboCtrl.SetMainControl:
|
97
|
+
:detail:
|
98
|
+
:pre:
|
99
|
+
:programlisting:
|
100
|
+
- :pattern: !ruby/regexp /.*/
|
101
|
+
:replace: |
|
102
|
+
|
103
|
+
```ruby
|
104
|
+
# Create the combo control using its default ctor.
|
105
|
+
combo = Wx::ComboCtrl.new
|
106
|
+
|
107
|
+
# Create the custom main control using its default ctor too.
|
108
|
+
main = SomeWindow.new
|
109
|
+
|
110
|
+
# Set the custom main control before creating the combo.
|
111
|
+
combo.set_main_control(main)
|
112
|
+
|
113
|
+
# And only create it now: Wx::TextCtrl won't be unnecessarily
|
114
|
+
# created because the combo already has a main window.
|
115
|
+
combo.create(panel, Wx::ID_ANY, '')
|
116
|
+
|
117
|
+
# Finally create the main window itself, now that its parent was
|
118
|
+
# created.
|
119
|
+
main.create(combo, ...)
|
120
|
+
```
|
121
|
+
:wxComboCtrl.SetTextCtrlStyle:
|
122
|
+
:detail:
|
123
|
+
:pre:
|
124
|
+
:programlisting:
|
125
|
+
- :pattern: !ruby/regexp /.*/
|
126
|
+
:replace: |
|
127
|
+
|
128
|
+
```ruby
|
129
|
+
comboCtrl = Wx::ComboCtrl.new
|
130
|
+
|
131
|
+
# Let's make the text right-aligned
|
132
|
+
comboCtrl.set_text_ctrl_style(Wx::TE_RIGHT)
|
133
|
+
|
134
|
+
comboCtrl.create(parent, Wx::ID_ANY, '')
|
135
|
+
```
|
@@ -0,0 +1,62 @@
|
|
1
|
+
---
|
2
|
+
:wxFileDialogCustomizeHook:
|
3
|
+
:detail:
|
4
|
+
:pre:
|
5
|
+
:programlisting:
|
6
|
+
- :pattern: !ruby/regexp /.*/
|
7
|
+
:replace: |
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
class EncryptHook < Wx::FileDialogCustomizeHook
|
11
|
+
|
12
|
+
attr_reader :encrypt
|
13
|
+
|
14
|
+
# Override to add custom controls using the provided customizer object.
|
15
|
+
def add_custom_controls(customizer)
|
16
|
+
# Suppose we can encrypt files when saving them.
|
17
|
+
@checkbox = customizer.add_check_box('Encrypt')
|
18
|
+
|
19
|
+
# While @checkbox is not a Wx::CheckBox, it looks almost like one
|
20
|
+
# and, in particular, we can bind to custom control events as usual.
|
21
|
+
@checkbox.evt_checkbox(Wx::ID_ANY) do |event|
|
22
|
+
# We can also call Wx::Window-like functions on them.
|
23
|
+
@button.enable(event.checked?)
|
24
|
+
end
|
25
|
+
|
26
|
+
# The encryption parameters can be edited in a dedicated dialog.
|
27
|
+
@button = customizer.add_button('Parameters...')
|
28
|
+
@button.evt_button(Wx::ID_ANY) do |event|
|
29
|
+
# ... show the encryption parameters dialog here ...
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
# Override to save the values of the custom controls.
|
34
|
+
def transfer_data_from_custom_controls
|
35
|
+
# Save the checkbox value, as we won't be able to use it any more
|
36
|
+
# once this function returns.
|
37
|
+
@encrypt = @checkbox.get_value
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
# ...
|
43
|
+
|
44
|
+
def some_method
|
45
|
+
Wx.FileDialog(nil, 'Save document', '', 'file.my',
|
46
|
+
'My files (*.my)|*.my',
|
47
|
+
Wx::FD_SAVE | Wx::FD_OVERWRITE_PROMPT) do |dialog|
|
48
|
+
|
49
|
+
# This object may be destroyed before the dialog, but must remain
|
50
|
+
# alive until #show_modal returns.
|
51
|
+
customize_hook = EncryptHook.new
|
52
|
+
dialog.set_customize_hook(custom_hook)
|
53
|
+
|
54
|
+
if dialog.show_modal == Wx::ID_OK
|
55
|
+
if customize_hook.encrypt
|
56
|
+
# ... save with encryption ...
|
57
|
+
else
|
58
|
+
# ... save without encryption ...
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
```
|
@@ -0,0 +1,28 @@
|
|
1
|
+
---
|
2
|
+
:wxFileSystemHandler.CanOpen:
|
3
|
+
:detail:
|
4
|
+
:pre:
|
5
|
+
:para:
|
6
|
+
- :pattern: !ruby/regexp /Example:/
|
7
|
+
:subst: ''
|
8
|
+
:programlisting:
|
9
|
+
- :pattern: !ruby/regexp /.*/
|
10
|
+
:replace: ''
|
11
|
+
:wxFileSystemHandler.GetMimeTypeFromExt:
|
12
|
+
:detail:
|
13
|
+
:pre:
|
14
|
+
:para:
|
15
|
+
- :pattern: !ruby/regexp /Example:/
|
16
|
+
:subst: ''
|
17
|
+
:programlisting:
|
18
|
+
- :pattern: !ruby/regexp /.*/
|
19
|
+
:replace: ''
|
20
|
+
:wxMemoryFSHandler:
|
21
|
+
:detail:
|
22
|
+
:pre:
|
23
|
+
:para:
|
24
|
+
- :pattern: !ruby/regexp /Example:/
|
25
|
+
:subst: ''
|
26
|
+
:programlisting:
|
27
|
+
- :pattern: !ruby/regexp /.*/
|
28
|
+
:replace: ''
|
@@ -547,10 +547,18 @@ module WXRuby3
|
|
547
547
|
if Extractor::EnumDef === item && !item.ignored && !item.items.all? {|e| e.ignored }
|
548
548
|
fout.puts
|
549
549
|
fout.puts "// from enum #{item.is_anonymous ? '' : item.name}"
|
550
|
-
|
551
|
-
|
552
|
-
|
553
|
-
|
550
|
+
if item.is_anonymous
|
551
|
+
item.items.each do |e|
|
552
|
+
unless e.ignored
|
553
|
+
fout.puts "%constant int #{e.name} = #{e.fqn};"
|
554
|
+
end
|
555
|
+
end
|
556
|
+
else
|
557
|
+
fout.puts "enum #{item.name};"
|
558
|
+
item.items.each do |e|
|
559
|
+
unless e.ignored
|
560
|
+
fout.puts "%constant int #{item.name}_#{e.name} = #{e.fqn};"
|
561
|
+
end
|
554
562
|
end
|
555
563
|
end
|
556
564
|
end
|
data/rakelib/lib/swig_runner.rb
CHANGED
@@ -262,7 +262,7 @@ module WXRuby3
|
|
262
262
|
def_items.each do |item|
|
263
263
|
case item
|
264
264
|
when Extractor::EnumDef
|
265
|
-
item.items.each { |e| enumerators[rb_wx_name(e.name
|
265
|
+
item.items.each { |e| enumerators["#{rb_wx_name(item.name)}_#{e.name}"] = item } if item.is_type
|
266
266
|
when Extractor::ClassDef
|
267
267
|
item.items.select { |itm| Extractor::EnumDef === itm }.each do |enum|
|
268
268
|
enum.items.each { |e| enumerators[rb_wx_name(e.name)] = enum } if enum.is_type
|
@@ -334,6 +334,7 @@ module WXRuby3
|
|
334
334
|
fix_enum = true
|
335
335
|
enum_item = enum_table[md[2]]
|
336
336
|
enum_name = rb_wx_name(enum_item.name)
|
337
|
+
enumerator_name = rb_wx_name(md[2].sub(/\A#{enum_name}_/, ''))
|
337
338
|
enum_id = enum_item.scope.empty? ? enum_name : "#{rb_wx_name(enum_item.scope)}::#{enum_name}"
|
338
339
|
enum_var = enum_id.gsub('::', '_')
|
339
340
|
line = [
|
@@ -343,7 +344,7 @@ module WXRuby3
|
|
343
344
|
# add enum class constant to current module (use unscoped name)
|
344
345
|
" rb_define_const(#{md[1]}, \"#{enum_name}\", cWx#{enum_var}); // Inserted by fixmodule.rb",
|
345
346
|
# create enumerator value const under new enum class
|
346
|
-
" wxRuby_AddEnumValue(cWx#{enum_var}, \"#{
|
347
|
+
" wxRuby_AddEnumValue(cWx#{enum_var}, \"#{enumerator_name}\"#{md[3]} // Updated by fixmodule.rb"
|
347
348
|
].join("\n")
|
348
349
|
end
|
349
350
|
else
|
@@ -352,13 +353,15 @@ module WXRuby3
|
|
352
353
|
# of the same enum?
|
353
354
|
if enum_item && enum_table[md[2]] == enum_item
|
354
355
|
enum_name = rb_wx_name(enum_item.name)
|
356
|
+
enumerator_name = rb_wx_name(md[2].sub(/\A#{enum_name}_/, ''))
|
355
357
|
enum_id = enum_item.scope.empty? ? enum_name : "#{rb_wx_name(enum_item.scope)}::#{enum_name}"
|
356
358
|
enum_var = enum_id.gsub('::', '_')
|
357
359
|
# create enumerator value const under new enum class
|
358
|
-
line = " wxRuby_AddEnumValue(cWx#{enum_var}, \"#{
|
360
|
+
line = " wxRuby_AddEnumValue(cWx#{enum_var}, \"#{enumerator_name}\"#{md[3]} // Updated by fixmodule.rb"
|
359
361
|
else # we found the start of another enum
|
360
362
|
enum_item = enum_table[md[2]]
|
361
363
|
enum_name = rb_wx_name(enum_item.name)
|
364
|
+
enumerator_name = rb_wx_name(md[2].sub(/\A#{enum_name}_/, ''))
|
362
365
|
enum_id = enum_item.scope.empty? ? enum_name : "#{rb_wx_name(enum_item.scope)}::#{enum_name}"
|
363
366
|
enum_var = enum_id.gsub('::', '_')
|
364
367
|
line = [
|
@@ -368,7 +371,7 @@ module WXRuby3
|
|
368
371
|
# add enum class constant to current module (use unscoped name)
|
369
372
|
" rb_define_const(#{md[1]}, \"#{enum_name}\", cWx#{enum_var}); // Inserted by fixmodule.rb",
|
370
373
|
# create enumerator value const under new enum class
|
371
|
-
" wxRuby_AddEnumValue(cWx#{enum_var}, \"#{
|
374
|
+
" wxRuby_AddEnumValue(cWx#{enum_var}, \"#{enumerator_name}\"#{md[3]} // Updated by fixmodule.rb"
|
372
375
|
].join("\n")
|
373
376
|
end
|
374
377
|
else # end of enum def
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# Copyright (c) 2023 M.J.N. Corino, The Netherlands
|
2
|
+
#
|
3
|
+
# This software is released under the MIT license.
|
4
|
+
|
5
|
+
###
|
6
|
+
# wxRuby3 wxComboPopup typemap definition
|
7
|
+
###
|
8
|
+
|
9
|
+
require_relative '../core/mapping'
|
10
|
+
|
11
|
+
module WXRuby3
|
12
|
+
|
13
|
+
module Typemap
|
14
|
+
|
15
|
+
module ComboPopup
|
16
|
+
|
17
|
+
include Typemap::Module
|
18
|
+
|
19
|
+
define do
|
20
|
+
|
21
|
+
# for DoSetPopupControl
|
22
|
+
map 'wxComboPopup* popup' => 'Wx::ComboPopup,nil' do
|
23
|
+
|
24
|
+
add_header_code <<~__CODE
|
25
|
+
#include <wx/combo.h>
|
26
|
+
|
27
|
+
WXRUBY_EXPORT wxComboPopup* wxRuby_ComboPopupFromRuby(VALUE popup);
|
28
|
+
WXRUBY_EXPORT VALUE wxRuby_ComboPopupToRuby(wxComboPopup* popup);
|
29
|
+
__CODE
|
30
|
+
|
31
|
+
map_in code: '$1 = wxRuby_ComboPopupFromRuby($input);'
|
32
|
+
|
33
|
+
map_directorin code: '$input = wxRuby_ComboPopupToRuby($1);'
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
@@ -0,0 +1,196 @@
|
|
1
|
+
# Copyright (c) 2023 M.J.N. Corino, The Netherlands
|
2
|
+
#
|
3
|
+
# This software is released under the MIT license.
|
4
|
+
|
5
|
+
require_relative './lib/wxframe_runner'
|
6
|
+
require_relative './lib/text_entry_tests'
|
7
|
+
|
8
|
+
class ComboCtrlCtrlTests < WxRuby::Test::GUITests
|
9
|
+
|
10
|
+
include TextEntryTests
|
11
|
+
|
12
|
+
class LVComboPopup < Wx::ListView
|
13
|
+
|
14
|
+
include Wx::ComboPopup
|
15
|
+
|
16
|
+
def initialize
|
17
|
+
# call default control ctor; need to call Wx::ListView#create later
|
18
|
+
super
|
19
|
+
end
|
20
|
+
|
21
|
+
def init
|
22
|
+
@value = -1
|
23
|
+
end
|
24
|
+
|
25
|
+
def create(parent)
|
26
|
+
# need to finish creating the list view here
|
27
|
+
# as calling super here would just call Wx::ComboPopup#create and not Wx::ListView#create
|
28
|
+
# we need to use Ruby magic
|
29
|
+
wx_lv_create = (Wx::ListView.instance_method :create).bind(self)
|
30
|
+
wx_lv_create.call(parent, 1, [0,0], Wx::DEFAULT_SIZE)
|
31
|
+
evt_motion :on_mouse_move
|
32
|
+
evt_left_up :on_mouse_click
|
33
|
+
end
|
34
|
+
|
35
|
+
# Return pointer to the created control
|
36
|
+
def get_control
|
37
|
+
self
|
38
|
+
end
|
39
|
+
|
40
|
+
def lv_find_item(*args)
|
41
|
+
unless @wx_lv_find_item
|
42
|
+
@wx_lv_find_item = (Wx::ListView.instance_method :find_item).bind(self)
|
43
|
+
end
|
44
|
+
@wx_lv_find_item.call(*args)
|
45
|
+
end
|
46
|
+
protected :lv_find_item
|
47
|
+
|
48
|
+
# Translate string into a list selection
|
49
|
+
def set_string_value(s)
|
50
|
+
n = lv_find_item(-1, s)
|
51
|
+
if n >= 0 && n < get_item_count
|
52
|
+
select(n)
|
53
|
+
@value = n
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
# Get list selection as a string
|
58
|
+
def get_string_value
|
59
|
+
return get_item_text(@value) if @value >= 0
|
60
|
+
''
|
61
|
+
end
|
62
|
+
|
63
|
+
# Do mouse hot-tracking (which is typical in list popups)
|
64
|
+
def on_mouse_move(event)
|
65
|
+
# Move selection to cursor ...
|
66
|
+
end
|
67
|
+
|
68
|
+
# On mouse left up, set the value and close the popup
|
69
|
+
def on_mouse_click(_event)
|
70
|
+
@value = get_first_selected
|
71
|
+
|
72
|
+
# Send event as well ...
|
73
|
+
|
74
|
+
dismiss
|
75
|
+
end
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
def setup
|
80
|
+
super
|
81
|
+
@combo = Wx::ComboCtrl.new(frame_win, name: 'ComboCtrl')
|
82
|
+
@combo.set_popup_control(LVComboPopup.new)
|
83
|
+
end
|
84
|
+
|
85
|
+
def cleanup
|
86
|
+
@combo.destroy
|
87
|
+
super
|
88
|
+
end
|
89
|
+
|
90
|
+
attr_reader :combo
|
91
|
+
alias :text_entry :combo
|
92
|
+
|
93
|
+
def fill_list(list)
|
94
|
+
list.insert_item(0, 'This is the first item')
|
95
|
+
list.insert_item(1, 'This is the second item')
|
96
|
+
list.insert_item(2, 'This is the third item')
|
97
|
+
list.insert_item(3, 'This is the fourth item')
|
98
|
+
end
|
99
|
+
|
100
|
+
def test_popup
|
101
|
+
assert_equal('', combo.get_value)
|
102
|
+
|
103
|
+
assert_kind_of(Wx::ComboPopup, combo.get_popup_control)
|
104
|
+
assert_kind_of(Wx::ListView, combo.get_popup_control)
|
105
|
+
assert_kind_of(Wx::ListView, combo.get_popup_control.get_control)
|
106
|
+
|
107
|
+
assert_nothing_raised { fill_list(combo.get_popup_control) }
|
108
|
+
combo.popup
|
109
|
+
|
110
|
+
combo.set_value_by_user('This is the second item')
|
111
|
+
|
112
|
+
assert_equal('This is the second item', combo.get_popup_control.get_string_value)
|
113
|
+
|
114
|
+
combo.dismiss
|
115
|
+
end
|
116
|
+
|
117
|
+
end
|
118
|
+
|
119
|
+
class OwnerDrawnCBTests < WxRuby::Test::GUITests
|
120
|
+
|
121
|
+
include TextEntryTests
|
122
|
+
|
123
|
+
class TestODComboBox < Wx::OwnerDrawnComboBox
|
124
|
+
|
125
|
+
def on_draw_item(dc, rect, item, _flags)
|
126
|
+
return if item == Wx::NOT_FOUND
|
127
|
+
|
128
|
+
dc.set_text_foreground(Wx::BLACK)
|
129
|
+
dc.draw_text(get_string(item),
|
130
|
+
rect.x + 3,
|
131
|
+
rect.y + ((rect.height - dc.char_height)/2))
|
132
|
+
end
|
133
|
+
|
134
|
+
def on_draw_background(dc, rect, item, flags)
|
135
|
+
# If item is selected or even, or we are painting the
|
136
|
+
# combo control itself, use the default rendering.
|
137
|
+
if flags.anybits?(Wx::ODCB_PAINTING_CONTROL|Wx::ODCB_PAINTING_SELECTED) || (item & 1) == 0
|
138
|
+
super(dc,rect,item,flags)
|
139
|
+
return
|
140
|
+
end
|
141
|
+
|
142
|
+
# Otherwise, draw every other background with different colour.
|
143
|
+
bgCol = Wx::Colour.new(240,240,250)
|
144
|
+
dc.set_brush(Wx::Brush.new(bgCol))
|
145
|
+
dc.set_pen(Wx::Pen.new(bgCol))
|
146
|
+
dc.draw_rectangle(rect)
|
147
|
+
end
|
148
|
+
|
149
|
+
def on_measure_item(_item)
|
150
|
+
48
|
151
|
+
end
|
152
|
+
|
153
|
+
def on_measure_item_width(_item)
|
154
|
+
-1 # default - will be measured from text width
|
155
|
+
end
|
156
|
+
|
157
|
+
end
|
158
|
+
|
159
|
+
def setup
|
160
|
+
super
|
161
|
+
@combo = TestODComboBox.new(frame_win, name: 'ODComboBox')
|
162
|
+
end
|
163
|
+
|
164
|
+
def cleanup
|
165
|
+
@combo.destroy
|
166
|
+
super
|
167
|
+
end
|
168
|
+
|
169
|
+
attr_reader :combo
|
170
|
+
alias :text_entry :combo
|
171
|
+
|
172
|
+
def fill_list(list)
|
173
|
+
list.append('This is the first item')
|
174
|
+
list.append('This is the second item')
|
175
|
+
list.append('This is the third item')
|
176
|
+
list.append('This is the fourth item')
|
177
|
+
end
|
178
|
+
|
179
|
+
def test_popup
|
180
|
+
assert_equal('', combo.get_value)
|
181
|
+
|
182
|
+
assert_kind_of(Wx::ComboPopup, combo.get_popup_control)
|
183
|
+
assert_kind_of(Wx::ComboPopupWx, combo.get_popup_control)
|
184
|
+
assert_kind_of(Wx::VListBox, combo.get_popup_control.get_control)
|
185
|
+
|
186
|
+
assert_nothing_raised { fill_list(combo) }
|
187
|
+
combo.popup
|
188
|
+
|
189
|
+
combo.set_value_by_user('This is the third item')
|
190
|
+
|
191
|
+
assert_equal('This is the third item', combo.get_popup_control.get_string_value)
|
192
|
+
|
193
|
+
combo.dismiss
|
194
|
+
end
|
195
|
+
|
196
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wxruby3
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martin Corino
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-01-
|
11
|
+
date: 2024-01-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -99,6 +99,7 @@ files:
|
|
99
99
|
- ext/mkrf_conf_srcgem.rb
|
100
100
|
- ext/wxruby3/include/wxRubyApp.h
|
101
101
|
- ext/wxruby3/include/wxruby-ClientData.h
|
102
|
+
- ext/wxruby3/include/wxruby-ComboPopup.h
|
102
103
|
- ext/wxruby3/include/wxruby-Config.h
|
103
104
|
- ext/wxruby3/include/wxruby-Persistence.h
|
104
105
|
- ext/wxruby3/include/wxruby-ScaledDC.h
|
@@ -147,6 +148,7 @@ files:
|
|
147
148
|
- lib/wx/core/clipboard.rb
|
148
149
|
- lib/wx/core/collapsible_pane.rb
|
149
150
|
- lib/wx/core/colour.rb
|
151
|
+
- lib/wx/core/combo_ctrl.rb
|
150
152
|
- lib/wx/core/combobox.rb
|
151
153
|
- lib/wx/core/config.rb
|
152
154
|
- lib/wx/core/const.rb
|
@@ -683,6 +685,7 @@ files:
|
|
683
685
|
- rakelib/lib/generate/doc/clipboard.yaml
|
684
686
|
- rakelib/lib/generate/doc/collapsible_pane.yaml
|
685
687
|
- rakelib/lib/generate/doc/colour_dialog.yaml
|
688
|
+
- rakelib/lib/generate/doc/combo_ctrl.yaml
|
686
689
|
- rakelib/lib/generate/doc/context_help_button.yaml
|
687
690
|
- rakelib/lib/generate/doc/control.yaml
|
688
691
|
- rakelib/lib/generate/doc/cursor.yaml
|
@@ -695,6 +698,8 @@ files:
|
|
695
698
|
- rakelib/lib/generate/doc/events.yaml
|
696
699
|
- rakelib/lib/generate/doc/evt_handler.yaml
|
697
700
|
- rakelib/lib/generate/doc/file_dialog.yaml
|
701
|
+
- rakelib/lib/generate/doc/file_dialog_customize_hook.yaml
|
702
|
+
- rakelib/lib/generate/doc/file_system.yaml
|
698
703
|
- rakelib/lib/generate/doc/font.yaml
|
699
704
|
- rakelib/lib/generate/doc/frame.yaml
|
700
705
|
- rakelib/lib/generate/doc/fs_file.yaml
|
@@ -764,6 +769,7 @@ files:
|
|
764
769
|
- rakelib/lib/swig_runner.rb
|
765
770
|
- rakelib/lib/typemap/array_int_selections.rb
|
766
771
|
- rakelib/lib/typemap/client_data.rb
|
772
|
+
- rakelib/lib/typemap/combo_popup.rb
|
767
773
|
- rakelib/lib/typemap/common.rb
|
768
774
|
- rakelib/lib/typemap/config.rb
|
769
775
|
- rakelib/lib/typemap/data_format.rb
|
@@ -1088,6 +1094,7 @@ files:
|
|
1088
1094
|
- tests/test_book_controls.rb
|
1089
1095
|
- tests/test_box_sizer.rb
|
1090
1096
|
- tests/test_clipboard.rb
|
1097
|
+
- tests/test_combo_ctrl.rb
|
1091
1098
|
- tests/test_config.rb
|
1092
1099
|
- tests/test_dc.rb
|
1093
1100
|
- tests/test_dialog.rb
|