wxruby3 0.9.3-x64-mingw-ucrt → 0.9.5-x64-mingw-ucrt

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.
Files changed (160) hide show
  1. checksums.yaml +4 -4
  2. data/INSTALL.md +1 -1
  3. data/README.md +2 -2
  4. data/ext/wxbase32u_gcc_custom.dll +0 -0
  5. data/ext/wxbase32u_net_gcc_custom.dll +0 -0
  6. data/ext/wxbase32u_xml_gcc_custom.dll +0 -0
  7. data/ext/wxmsw32u_aui_gcc_custom.dll +0 -0
  8. data/ext/wxmsw32u_core_gcc_custom.dll +0 -0
  9. data/ext/wxmsw32u_gl_gcc_custom.dll +0 -0
  10. data/ext/wxmsw32u_html_gcc_custom.dll +0 -0
  11. data/ext/wxmsw32u_media_gcc_custom.dll +0 -0
  12. data/ext/wxmsw32u_propgrid_gcc_custom.dll +0 -0
  13. data/ext/wxmsw32u_qa_gcc_custom.dll +0 -0
  14. data/ext/wxmsw32u_ribbon_gcc_custom.dll +0 -0
  15. data/ext/wxmsw32u_richtext_gcc_custom.dll +0 -0
  16. data/ext/wxmsw32u_stc_gcc_custom.dll +0 -0
  17. data/ext/wxmsw32u_webview_gcc_custom.dll +0 -0
  18. data/ext/wxmsw32u_xrc_gcc_custom.dll +0 -0
  19. data/lib/wx/core/book_ctrl_base.rb +16 -0
  20. data/lib/wx/core/combo_ctrl.rb +171 -0
  21. data/lib/wx/core/config.rb +454 -83
  22. data/lib/wx/core/notebook.rb +10 -8
  23. data/lib/wx/core/peristent_object.rb +15 -0
  24. data/lib/wx/core/persistence_manager.rb +39 -0
  25. data/lib/wx/core/persistent_window.rb +16 -0
  26. data/lib/wx/core/top_level_window.rb +16 -0
  27. data/lib/wx/core/treebook.rb +18 -0
  28. data/lib/wx/core.rb +4 -0
  29. data/lib/wx/doc/book_ctrl_base.rb +19 -0
  30. data/lib/wx/doc/comboctrl.rb +128 -3
  31. data/lib/wx/doc/config.rb +101 -41
  32. data/lib/wx/doc/extra/14_config.md +101 -0
  33. data/lib/wx/doc/extra/15_persistence.md +148 -0
  34. data/lib/wx/doc/gen/app_traits.rb +2 -54
  35. data/lib/wx/doc/gen/art_provider.rb +0 -2
  36. data/lib/wx/doc/gen/aui/aui_dock_art.rb +77 -77
  37. data/lib/wx/doc/gen/aui/aui_manager.rb +0 -1
  38. data/lib/wx/doc/gen/aui/aui_manager_event.rb +1 -1
  39. data/lib/wx/doc/gen/aui/aui_mdi_client_window.rb +5 -4
  40. data/lib/wx/doc/gen/aui/aui_notebook_event.rb +1 -1
  41. data/lib/wx/doc/gen/aui/aui_tool_bar_event.rb +21 -21
  42. data/lib/wx/doc/gen/book_ctrl_event.rb +1 -1
  43. data/lib/wx/doc/gen/calendar_event.rb +1 -1
  44. data/lib/wx/doc/gen/colour.rb +0 -1
  45. data/lib/wx/doc/gen/colour_dialog.rb +1 -1
  46. data/lib/wx/doc/gen/combo_box.rb +3 -2
  47. data/lib/wx/doc/gen/combo_ctrl.rb +91 -227
  48. data/lib/wx/doc/gen/core.rb +2 -2
  49. data/lib/wx/doc/gen/date_event.rb +1 -1
  50. data/lib/wx/doc/gen/dc.rb +0 -3
  51. data/lib/wx/doc/gen/dialog.rb +0 -1
  52. data/lib/wx/doc/gen/event.rb +4 -4
  53. data/lib/wx/doc/gen/event_blocker.rb +1 -1
  54. data/lib/wx/doc/gen/event_filter.rb +0 -2
  55. data/lib/wx/doc/gen/events.rb +17 -39
  56. data/lib/wx/doc/gen/file_ctrl_event.rb +1 -1
  57. data/lib/wx/doc/gen/file_dialog.rb +0 -2
  58. data/lib/wx/doc/gen/file_dialog_customize_hook.rb +55 -63
  59. data/lib/wx/doc/gen/file_dir_picker_event.rb +1 -1
  60. data/lib/wx/doc/gen/file_system.rb +1 -58
  61. data/lib/wx/doc/gen/find_dialog_event.rb +1 -1
  62. data/lib/wx/doc/gen/frame.rb +0 -1
  63. data/lib/wx/doc/gen/gdi_common.rb +0 -8
  64. data/lib/wx/doc/gen/grid/grid_cell_activatable_editor.rb +0 -2
  65. data/lib/wx/doc/gen/grid/grid_cell_attr.rb +0 -2
  66. data/lib/wx/doc/gen/grid/grid_cell_auto_wrap_string_editor.rb +0 -2
  67. data/lib/wx/doc/gen/grid/grid_cell_auto_wrap_string_renderer.rb +0 -2
  68. data/lib/wx/doc/gen/grid/grid_cell_bool_editor.rb +0 -2
  69. data/lib/wx/doc/gen/grid/grid_cell_bool_renderer.rb +0 -2
  70. data/lib/wx/doc/gen/grid/grid_cell_choice_editor.rb +0 -2
  71. data/lib/wx/doc/gen/grid/grid_cell_date_editor.rb +0 -2
  72. data/lib/wx/doc/gen/grid/grid_cell_date_renderer.rb +0 -2
  73. data/lib/wx/doc/gen/grid/grid_cell_date_time_renderer.rb +0 -2
  74. data/lib/wx/doc/gen/grid/grid_cell_editor.rb +0 -2
  75. data/lib/wx/doc/gen/grid/grid_cell_enum_editor.rb +0 -2
  76. data/lib/wx/doc/gen/grid/grid_cell_enum_renderer.rb +0 -2
  77. data/lib/wx/doc/gen/grid/grid_cell_float_editor.rb +0 -2
  78. data/lib/wx/doc/gen/grid/grid_cell_float_renderer.rb +0 -2
  79. data/lib/wx/doc/gen/grid/grid_cell_number_editor.rb +0 -2
  80. data/lib/wx/doc/gen/grid/grid_cell_number_renderer.rb +0 -2
  81. data/lib/wx/doc/gen/grid/grid_cell_renderer.rb +0 -2
  82. data/lib/wx/doc/gen/grid/grid_cell_string_renderer.rb +0 -2
  83. data/lib/wx/doc/gen/grid/grid_cell_text_editor.rb +0 -2
  84. data/lib/wx/doc/gen/grid/grid_ctrl.rb +0 -12
  85. data/lib/wx/doc/gen/grid/grid_editor_created_event.rb +1 -1
  86. data/lib/wx/doc/gen/grid/grid_event.rb +1 -1
  87. data/lib/wx/doc/gen/grid/grid_range_select_event.rb +1 -1
  88. data/lib/wx/doc/gen/grid/grid_size_event.rb +1 -1
  89. data/lib/wx/doc/gen/gui_event_loop.rb +0 -2
  90. data/lib/wx/doc/gen/header_ctrl.rb +0 -7
  91. data/lib/wx/doc/gen/header_ctrl_event.rb +1 -1
  92. data/lib/wx/doc/gen/html/html_cell_event.rb +1 -1
  93. data/lib/wx/doc/gen/image.rb +0 -2
  94. data/lib/wx/doc/gen/list_ctrl.rb +0 -1
  95. data/lib/wx/doc/gen/list_event.rb +1 -1
  96. data/lib/wx/doc/gen/media_ctrl.rb +0 -6
  97. data/lib/wx/doc/gen/media_event.rb +1 -1
  98. data/lib/wx/doc/gen/menu.rb +0 -2
  99. data/lib/wx/doc/gen/notebook.rb +0 -1
  100. data/lib/wx/doc/gen/persistence_manager.rb +135 -0
  101. data/lib/wx/doc/gen/persistent_object.rb +52 -0
  102. data/lib/wx/doc/gen/persistent_window.rb +116 -0
  103. data/lib/wx/doc/gen/pg/pg_property.rb +0 -13
  104. data/lib/wx/doc/gen/pg/pg_validation_info.rb +0 -2
  105. data/lib/wx/doc/gen/pg/property_grid.rb +0 -2
  106. data/lib/wx/doc/gen/pg/property_grid_event.rb +1 -1
  107. data/lib/wx/doc/gen/pg/property_grid_interface.rb +2 -2
  108. data/lib/wx/doc/gen/pg/property_grid_manager.rb +0 -2
  109. data/lib/wx/doc/gen/pg/property_grid_page.rb +0 -2
  110. data/lib/wx/doc/gen/pg/property_grid_page_state.rb +0 -1
  111. data/lib/wx/doc/gen/prt/post_script_dc.rb +0 -1
  112. data/lib/wx/doc/gen/rbn/ribbon_bar_event.rb +1 -1
  113. data/lib/wx/doc/gen/rbn/ribbon_button_bar_event.rb +1 -1
  114. data/lib/wx/doc/gen/rbn/ribbon_gallery_event.rb +1 -1
  115. data/lib/wx/doc/gen/rbn/ribbon_panel_event.rb +1 -1
  116. data/lib/wx/doc/gen/rbn/ribbon_tool_bar_event.rb +1 -1
  117. data/lib/wx/doc/gen/rtc/rich_text_event.rb +1 -1
  118. data/lib/wx/doc/gen/rtc/rich_text_html_handler.rb +0 -1
  119. data/lib/wx/doc/gen/rtc/rich_text_style_list_box.rb +3 -0
  120. data/lib/wx/doc/gen/rtc/rich_text_xml_handler.rb +0 -1
  121. data/lib/wx/doc/gen/scroll_bar.rb +0 -1
  122. data/lib/wx/doc/gen/sizer.rb +0 -1
  123. data/lib/wx/doc/gen/slider.rb +0 -1
  124. data/lib/wx/doc/gen/spin_double_event.rb +1 -1
  125. data/lib/wx/doc/gen/spin_event.rb +1 -1
  126. data/lib/wx/doc/gen/splash_screen.rb +1 -1
  127. data/lib/wx/doc/gen/splitter_event.rb +1 -1
  128. data/lib/wx/doc/gen/stc/styled_text_ctrl.rb +0 -1
  129. data/lib/wx/doc/gen/stc/styled_text_event.rb +1 -2
  130. data/lib/wx/doc/gen/task_bar_icon.rb +0 -1
  131. data/lib/wx/doc/gen/task_bar_icon_event.rb +1 -1
  132. data/lib/wx/doc/gen/text_ctrl.rb +0 -5
  133. data/lib/wx/doc/gen/text_entry.rb +0 -4
  134. data/lib/wx/doc/gen/tree_ctrl.rb +0 -2
  135. data/lib/wx/doc/gen/tree_event.rb +1 -1
  136. data/lib/wx/doc/gen/utils.rb +0 -16
  137. data/lib/wx/doc/gen/v_scrolled_window.rb +0 -1
  138. data/lib/wx/doc/gen/wizard.rb +0 -1
  139. data/lib/wx/doc/gen/wizard_event.rb +1 -1
  140. data/lib/wx/doc/gen/wizard_page.rb +0 -1
  141. data/lib/wx/doc/owner_drawn_combobox.rb +5 -1
  142. data/lib/wx/doc/persistence_manager.rb +36 -0
  143. data/lib/wx/doc/persistent_object.rb +27 -0
  144. data/lib/wx/doc/top_level_window.rb +19 -0
  145. data/lib/wx/doc/treebook.rb +6 -1
  146. data/lib/wx/version.rb +1 -1
  147. data/lib/wxruby_aui.so +0 -0
  148. data/lib/wxruby_core.so +0 -0
  149. data/lib/wxruby_grid.so +0 -0
  150. data/lib/wxruby_html.so +0 -0
  151. data/lib/wxruby_pg.so +0 -0
  152. data/lib/wxruby_prt.so +0 -0
  153. data/lib/wxruby_rbn.so +0 -0
  154. data/lib/wxruby_rtc.so +0 -0
  155. data/lib/wxruby_stc.so +0 -0
  156. data/samples/widgets/widgets.rb +5 -9
  157. data/tests/test_combo_ctrl.rb +196 -0
  158. data/tests/test_config.rb +207 -42
  159. data/tests/test_persistence.rb +142 -0
  160. metadata +20 -2
@@ -0,0 +1,36 @@
1
+ # :stopdoc:
2
+ # Copyright (c) 2023 M.J.N. Corino, The Netherlands
3
+ #
4
+ # This software is released under the MIT license.
5
+ # :startdoc:
6
+
7
+
8
+ module Wx
9
+
10
+ # Function used to create the correct persistent adapter for the given object.
11
+ #
12
+ # This is a compatibility function that simply redirects the call to the object itself. Any object class
13
+ # supporting persistence should implement the #create_persistent_object method to return a Wx::PersistentObject
14
+ # instance for the object it is called for.
15
+ # This method raises a NoImplementError if the object class does not support persistence.
16
+ # @see Defining Custom Persistent Windows
17
+ # @param obj [Object]
18
+ # @return [Wx::PersistentObject]
19
+ def self.create_persistent_object(obj) end
20
+
21
+ # A shorter synonym for {Wx::PersistenceManager#register_and_restore}.
22
+ #
23
+ # This function simply calls {Wx::PersistenceManager#register_and_restore} but using it results in slightly shorter
24
+ # code as it calls {Wx::PersistenceManager.get} internally. As an additional convenience, this function can also set the window name.
25
+ #
26
+ # Returns true if the settings were restored or false otherwise (this will always be the case when the program runs
27
+ # for the first time, for example).
28
+ # @param obj [Wx::Window] window to register with persistence manager and to try to restore the settings for.
29
+ # @param name [String] If specified non-empty, window name is changed to the provided value before registering it.
30
+ # @return [Boolean]
31
+ def self.persistent_register_and_restore(obj, name=nil) end
32
+
33
+ # class alias
34
+ PersistentWindow = PersistentWindowBase
35
+
36
+ end
@@ -0,0 +1,27 @@
1
+ # :stopdoc:
2
+ # Copyright (c) 2023 M.J.N. Corino, The Netherlands
3
+ #
4
+ # This software is released under the MIT license.
5
+ # :startdoc:
6
+
7
+
8
+ module Wx
9
+
10
+ class PersistentObject < ::Object
11
+
12
+ # Save the specified value using the given name.
13
+ # @param [String] name The name of the value in the configuration file.
14
+ # @param [Object] value The value to save, currently must be a type supported by wxConfig.
15
+ # @return [Boolean] true if the value was saved or false if an error occurred.
16
+ def save_value(name, value); end
17
+ protected :save_value
18
+
19
+ # Restore a value saved by {#save_value}.
20
+ # @param [String] name The name of the value in the configuration file.
21
+ # @return [Object,nil] The value if successfully read, nil otherwise
22
+ def restore_value(name); end
23
+ protected :restore_value
24
+
25
+ end
26
+
27
+ end
@@ -0,0 +1,19 @@
1
+ # :stopdoc:
2
+ # Copyright (c) 2023 M.J.N. Corino, The Netherlands
3
+ #
4
+ # This software is released under the MIT license.
5
+ # :startdoc:
6
+
7
+
8
+ module Wx
9
+
10
+ class TopLevelWindow < NonOwnedWindow
11
+
12
+ # Creates PersistentObject for this toplevel window instance (incl. Dialog and Frame).
13
+ # @see Wx.create_persistent_object
14
+ # @return [Wx::PersistentTLW]
15
+ def create_persistent_object; end
16
+
17
+ end
18
+
19
+ end
@@ -7,13 +7,18 @@
7
7
 
8
8
  module Wx
9
9
 
10
- class Treebook
10
+ class Treebook < BookCtrlBase
11
11
 
12
12
  # Returns the Wx::TreeCtrl used for this Treebook
13
13
  # @return [Wx::TreeCtrl] the tree control
14
14
  def get_tree_ctrl; end
15
15
  alias :tree_ctrl :get_tree_ctrl
16
16
 
17
+ # Creates PersistentObject for this treebook control instance.
18
+ # @see Wx.create_persistent_object
19
+ # @return [Wx::PersistentTreeBookCtrl]
20
+ def create_persistent_object; end
21
+
17
22
  end
18
23
 
19
24
  end
data/lib/wx/version.rb CHANGED
@@ -3,5 +3,5 @@
3
3
  # This software is released under the MIT license.
4
4
 
5
5
  module Wx
6
- WXRUBY_VERSION = '0.9.3'
6
+ WXRUBY_VERSION = '0.9.5'
7
7
  end
data/lib/wxruby_aui.so CHANGED
Binary file
data/lib/wxruby_core.so CHANGED
Binary file
data/lib/wxruby_grid.so CHANGED
Binary file
data/lib/wxruby_html.so CHANGED
Binary file
data/lib/wxruby_pg.so CHANGED
Binary file
data/lib/wxruby_prt.so CHANGED
Binary file
data/lib/wxruby_rbn.so CHANGED
Binary file
data/lib/wxruby_rtc.so CHANGED
Binary file
data/lib/wxruby_stc.so CHANGED
Binary file
@@ -456,12 +456,10 @@ module Widgets
456
456
 
457
457
  @panel.set_sizer(sizerTop)
458
458
 
459
- # TODO - review wxPersistenceManager
460
- # sizeSet = wxPersistentRegisterAndRestore(this, "Main")
461
-
459
+ sizeSet = Wx.persistent_register_and_restore(self, "Main")
460
+
462
461
  sizeMin = @panel.get_best_size
463
- # if ( !sizeSet )
464
- set_client_size(sizeMin)
462
+ set_client_size(sizeMin) unless sizeSet
465
463
  set_min_client_size(sizeMin)
466
464
 
467
465
  # connect the event handlers
@@ -1068,10 +1066,8 @@ module Widgets
1068
1066
  evt_choicebook_page_changed(ID::Widgets_BookCtrl, :on_page_changed)
1069
1067
  end
1070
1068
 
1071
- # TODO - review wxPersistenceManager
1072
- # const bool pageSet = wxPersistentRegisterAndRestore(m_book)
1073
- pageSet = false
1074
-
1069
+ pageSet = Wx.persistent_register_and_restore(@book)
1070
+
1075
1071
  if Wx.has_feature?(:USE_TREEBOOK)
1076
1072
  # for treebook page #0 is empty parent page only so select the first page
1077
1073
  # with some contents
@@ -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
data/tests/test_config.rb CHANGED
@@ -13,21 +13,21 @@ class TestConfig < Test::Unit::TestCase
13
13
  'RootEntry4' => 3.14,
14
14
  'Group1' => {
15
15
  'Group1Entry' => 'Group1 string',
16
- 'Group1.1' => {
17
- 'Group1.1Integer' => 999,
18
- 'Group1.1Bignum' => 2**999,
19
- 'Group1.1Float' => (2**999)-0.1
16
+ 'Group1_1' => {
17
+ 'Group1_1Integer' => 999,
18
+ 'Group1_1Bignum' => 2**999,
19
+ 'Group1_1Float' => (2**999)-0.1
20
20
  }
21
21
  },
22
22
  'Group2' => {
23
- 'Group2.1' => {
24
- 'Group2.1.1' => {
23
+ 'Group2_1' => {
24
+ 'Group2_1_1' => {
25
25
  'String' => 'hello'
26
26
  },
27
- 'Group2.1.2' => {
27
+ 'Group2_1_2' => {
28
28
  'String' => 'world'
29
29
  },
30
- 'Group2.1.3' => {
30
+ 'Group2_1_3' => {
31
31
  'True' => true,
32
32
  'False' => false
33
33
  }
@@ -35,79 +35,222 @@ class TestConfig < Test::Unit::TestCase
35
35
  }
36
36
  }
37
37
 
38
+ def stringified_entry(val)
39
+ case val
40
+ when TrueClass,FalseClass
41
+ val ? '1' : '0'
42
+ when Float
43
+ '%g' % val
44
+ else
45
+ val.to_s
46
+ end
47
+ end
48
+
49
+ def stringified(val)
50
+ val.is_a?(::Hash) ? val.inject({}) { |hash, pair| hash[pair.first] = stringified(pair.last); hash } : stringified_entry(val)
51
+ end
52
+
53
+ def assert_true_cfg(val)
54
+ assert_block('expected "1" or true') do
55
+ val == '1' || val == 1 || val == true
56
+ end
57
+ end
58
+
59
+ def assert_false_cfg(val)
60
+ assert_block("expected '0' or false") do
61
+ val == '0' || val == 0 || val == false
62
+ end
63
+ end
64
+
65
+ def assert_equal_cfg(expected, val)
66
+ assert_block("expected #{expected.is_a?(::Hash) ? stringified(expected) : %Q['#{stringified(expected)}']} \nor #{expected}\nbut got #{val}") do
67
+ expected == val || stringified(expected) == stringified(val)
68
+ end
69
+ end
70
+
38
71
  def run_config_tests(cfg)
39
- assert_equal(DEMO_CONFIG, cfg.to_h)
72
+ assert_equal_cfg(DEMO_CONFIG, cfg.to_h)
40
73
 
41
- assert_equal(4, cfg.number_of_entries)
42
- assert_equal(2, cfg.number_of_groups)
43
- assert_equal(12, cfg.number_of_entries(recurse: true))
44
- assert_equal(7, cfg.number_of_groups(recurse: true))
74
+ assert_equal_cfg(4, cfg.number_of_entries)
75
+ assert_equal_cfg(2, cfg.number_of_groups)
76
+ assert_equal_cfg(12, cfg.number_of_entries(recurse: true))
77
+ assert_equal_cfg(7, cfg.number_of_groups(recurse: true))
45
78
 
46
79
  assert_true(cfg.has_entry?('/RootEntry2'))
47
80
  assert_true(cfg.has_entry?('/Group1/Group1Entry'))
48
- assert_true(cfg.has_entry?('/Group2/Group2.1/Group2.1.2/String'))
81
+ assert_true(cfg.has_entry?('/Group2/Group2_1/Group2_1_2/String'))
49
82
 
50
- assert_false(cfg.has_entry?('/Group2/Group2.2/Group2.1.2/String'))
83
+ assert_false(cfg.has_entry?('/Group2/Group2.2/Group2_1_2/String'))
51
84
 
52
85
  assert_true(cfg.has_group?('/Group2'))
53
- assert_true(cfg.has_group?('/Group1/Group1.1'))
54
- assert_true(cfg.has_group?('/Group2/Group2.1/Group2.1.2'))
86
+ assert_true(cfg.has_group?('/Group1/Group1_1'))
87
+ assert_true(cfg.has_group?('/Group2/Group2_1/Group2_1_2'))
55
88
 
56
- assert_false(cfg.has_group?('/Group2/Group2.1/Group2.1.2/String'))
89
+ assert_false(cfg.has_group?('/Group2/Group2_1/Group2_1_2/String'))
57
90
 
58
- grp = cfg['/Group1/Group1.1']
91
+ grp = cfg['/Group1/Group1_1']
59
92
 
60
- assert_equal(DEMO_CONFIG['Group1']['Group1.1'], grp.to_h)
93
+ assert_equal_cfg(DEMO_CONFIG['Group1']['Group1_1'], grp.to_h)
61
94
 
62
95
  assert_equal(3, grp.number_of_entries)
63
96
  assert_equal(0, grp.number_of_groups)
64
97
 
65
- assert_true(grp.has_entry?('Group1.1Integer'))
98
+ assert_true(grp.has_entry?('Group1_1Integer'))
66
99
  assert_false(grp.has_entry?('Group1Entry'))
67
100
  assert_true(grp.has_entry?('../Group1Entry'))
68
101
 
69
- assert_true(grp.has_group?('/Group2/Group2.1/Group2.1.2'))
102
+ assert_true(grp.has_group?('/Group2/Group2_1/Group2_1_2'))
70
103
 
71
104
  assert_equal('This is a string value', cfg['/RootEntry1'])
72
- assert_equal(true, cfg['/RootEntry2'])
73
- assert_equal(101, cfg['/RootEntry3'])
74
- assert_equal(3.14, cfg['/RootEntry4'])
105
+ assert_equal_cfg(true, cfg['/RootEntry2'])
106
+ assert_equal_cfg(101, cfg['/RootEntry3'])
107
+ assert_equal_cfg(3.14, cfg['/RootEntry4'])
75
108
 
76
- grp = cfg['/Group2/Group2.1/Group2.1.3']
77
- assert_true(grp.get('True'))
78
- assert_false(grp.get('False'))
79
- assert_nil(grp.get('../Group2.1.2/String'))
109
+ grp = cfg['/Group2/Group2_1/Group2_1_3']
110
+ assert_true_cfg(grp.get('True'))
111
+ assert_false_cfg(grp.get('False'))
112
+ assert_raise(ArgumentError) { grp.get('../Group2_1_2/String') }
80
113
 
81
- assert_true(grp['True'])
82
- assert_false(grp['False'])
83
- assert_equal('world', grp['../Group2.1.2/String'])
114
+ assert_true_cfg(grp['True'])
115
+ assert_false_cfg(grp['False'])
116
+ assert_equal('world', grp['../Group2_1_2/String'])
84
117
 
85
118
  cfg.set('RootEntry1', 'Altered string value')
86
119
  assert_equal('Altered string value', cfg['RootEntry1'])
87
120
  assert_equal('Altered string value', cfg['/RootEntry1'])
88
121
  assert_equal('Altered string value', cfg.get('RootEntry1'))
89
122
 
90
- cfg.set('RootEntry3', cfg.get('RootEntry3')+99)
91
- assert_equal(200, cfg['/RootEntry3'])
123
+ cfg.set('RootEntry3', cfg.read('RootEntry3', ::Integer)+99)
124
+ assert_equal_cfg(200, cfg['/RootEntry3'])
125
+
126
+ cfg.set('Group1', { 'Group1_2' => { 'Integer' => 777 }})
127
+ assert_equal_cfg(777, cfg['/Group1/Group1_2/Integer'])
128
+
129
+ cfg['/Group1/Group1_2/Integer'] = 666
130
+ assert_equal_cfg(666, cfg['/Group1/Group1_2'].get('Integer'))
131
+
132
+ cfg['/Group1/Group1_2'] = { 'Float' => 0.3330 }
133
+ assert_equal_cfg(0.3330, cfg['/Group1/Group1_2'].get('Float'))
134
+
135
+ assert_equal(0.3330, cfg.read('/Group1/Group1_2/Float').to_f)
136
+ assert_equal(0.3330, cfg.read('/Group1/Group1_2/Float', Float))
137
+ assert_equal(0.3330, cfg.read('/Group1/Group1_2/Float', ->(v) { v.to_f }))
138
+
139
+ cfg.replace(DEMO_CONFIG) # reset
140
+ end
141
+
142
+ def run_auto_accessor_tests(cfg)
143
+ assert_not_nil(cfg.RootEntry2)
144
+ assert_not_nil(cfg.Group1.Group1Entry)
145
+ assert_not_nil(cfg.Group2.Group2_1.Group2_1_2.String)
146
+
147
+ assert_nil(cfg.Group2.Group2_1.Group2_1_2.AString)
148
+
149
+ assert_kind_of(cfg.class::Group, cfg.Group2)
150
+ assert_kind_of(cfg.class::Group, cfg.Group1.Group1_1)
151
+ assert_kind_of(cfg.class::Group, cfg.Group2.Group2_1.Group2_1_2)
152
+
153
+ assert_not_kind_of(cfg.class::Group, cfg.Group2.Group2_1.Group2_1_2.String)
154
+
155
+ grp = cfg.Group1
156
+
157
+ assert_equal_cfg(DEMO_CONFIG['Group1'], grp.to_h)
158
+
159
+ assert_not_nil(grp.Group1Entry)
160
+ assert_nil(grp.Group1_1Integer)
161
+
162
+ assert_kind_of(grp.class, grp.Group1_1)
163
+ assert_not_nil(grp.Group1_1.Group1_1Integer)
164
+
165
+ assert_true(grp.has_entry?('../RootEntry1'))
166
+
167
+ assert_true(grp.has_group?('/Group2/Group2_1/Group2_1_2'))
168
+
169
+ assert_equal_cfg('This is a string value', cfg.RootEntry1)
170
+ assert_equal_cfg(true, cfg.RootEntry2)
171
+ assert_equal_cfg(101, cfg.RootEntry3)
172
+ assert_equal_cfg(3.14, cfg.RootEntry4)
92
173
 
93
- cfg.set('Group1', { 'Group1.2' => { 'Integer' => 777 }})
94
- assert_equal(777, cfg['/Group1/Group1.2/Integer'])
174
+ grp = cfg.Group2.Group2_1.Group2_1_3
175
+ assert_true_cfg(grp.True)
176
+ assert_false_cfg(grp.False)
95
177
 
96
- cfg['/Group1/Group1.2/Integer'] = 666
97
- assert_equal(666, cfg['/Group1/Group1.2'].get('Integer'))
178
+ assert_true_cfg(grp['True'])
179
+ assert_false_cfg(grp['False'])
180
+ assert_equal_cfg('world', grp['../Group2_1_2/String'])
98
181
 
99
- cfg['/Group1/Group1.2'] = { 'Float' => 0.3330 }
100
- assert_equal(0.3330, cfg['/Group1/Group1.2'].get('Float'))
182
+ cfg.RootEntry1 = 'Altered string value'
183
+ assert_equal_cfg('Altered string value', cfg['RootEntry1'])
184
+ assert_equal_cfg('Altered string value', cfg['/RootEntry1'])
185
+ assert_equal_cfg('Altered string value', cfg.get('RootEntry1'))
186
+ assert_equal_cfg('Altered string value', cfg.RootEntry1)
187
+
188
+ cfg.RootEntry3 = (Kernel.Integer(cfg.RootEntry3) rescue 0)+99
189
+ assert_equal_cfg(200, cfg.RootEntry3)
190
+
191
+ cfg.Group1 = { 'Group1_2' => { 'Integer' => 777 }}
192
+ assert_equal_cfg(777, cfg.Group1.Group1_2.Integer)
193
+
194
+ cfg.Group1.Group1_2.Integer = 666
195
+ assert_equal_cfg(666, cfg.Group1.Group1_2.get('Integer'))
196
+
197
+ cfg.Group1.Group1_2 = { 'Float' => 0.3330 }
198
+ assert_equal_cfg(0.3330, cfg.Group1.Group1_2.get('Float'))
199
+
200
+ cfg.replace(DEMO_CONFIG) # reset
201
+ end
202
+
203
+ def run_env_var_tests(cfg)
204
+ # by default expansion is on
205
+
206
+ # add a number of entries for env var in new group 'Environment'
207
+ cfg['/Environment/HOME'] = '$HOME'
208
+ cfg['Environment'].USER = Wx::PLATFORM == 'WXMSW' ? '%USERNAME%' : '${USER}'
209
+ cfg['/Environment/PATH'] = '$(PATH)'
210
+
211
+ assert_equal(ENV['HOME'], cfg.Environment['HOME'])
212
+ assert_equal(ENV[Wx::PLATFORM == 'WXMSW' ? 'USERNAME' : 'USER'], cfg['/Environment/USER'])
213
+ assert_equal(ENV['PATH'], cfg.Environment.PATH)
214
+
215
+ # test escaping
216
+ cfg['/Environment/Escaped_HOME'] = '\$HOME'
217
+ cfg['/Environment/Escaped_HOME2'] = '\\$HOME'
218
+ cfg['/Environment/Escaped_HOME3'] = '\\\$HOME'
219
+
220
+ assert_equal('$HOME', cfg.Environment['Escaped_HOME'])
221
+ assert_equal('$HOME', cfg.Environment['Escaped_HOME2'])
222
+ assert_equal('\$HOME', cfg.Environment['Escaped_HOME3'])
223
+
224
+ cfg['/Environment/NONSENSE'] = '${NonExistingLongNonsenseVariable}'
225
+
226
+ assert_equal('${NonExistingLongNonsenseVariable}', cfg.Environment['NONSENSE'])
227
+
228
+ cfg['/Environment/MULTIPLE'] = "$HOME / #{Wx::PLATFORM == 'WXMSW' ? '%USERNAME%' : '${USER}'}"
229
+
230
+ assert_equal("#{ENV['HOME']} / #{Wx::PLATFORM == 'WXMSW' ? ENV['USERNAME'] : ENV['USER']}", cfg.Environment['MULTIPLE'])
231
+
232
+ # disable env var expansion
233
+ cfg.expand_env_vars = false
234
+ begin
235
+ assert_equal('$HOME', cfg.Environment['HOME'])
236
+ ensure
237
+ # re-enable
238
+ cfg.set_expand_env_vars(true)
239
+ end
101
240
  end
102
241
 
103
242
  def test_basic
104
243
  cfg = Wx::Config.new(DEMO_CONFIG)
105
244
 
106
245
  run_config_tests(cfg)
246
+ run_auto_accessor_tests(cfg)
247
+ run_env_var_tests(cfg)
107
248
  end
108
249
 
109
250
  def test_global
110
- cfg = Wx::ConfigBase.create
251
+ cfg = Wx::ConfigBase.create(true, use_hash_config: true)
252
+
253
+ assert_kind_of(Wx::Config, cfg)
111
254
 
112
255
  cfg.replace(DEMO_CONFIG)
113
256
 
@@ -116,6 +259,8 @@ class TestConfig < Test::Unit::TestCase
116
259
  assert_equal(cfg, Wx::ConfigBase.get(false))
117
260
 
118
261
  run_config_tests(cfg)
262
+ run_auto_accessor_tests(cfg)
263
+ run_env_var_tests(cfg)
119
264
 
120
265
  cfg_old = Wx::ConfigBase.set(nil)
121
266
 
@@ -123,8 +268,28 @@ class TestConfig < Test::Unit::TestCase
123
268
  assert_nil(Wx::ConfigBase.get(false))
124
269
  end
125
270
 
271
+ # default registry based config does not seem to do well in CI build env
272
+ unless is_ci_build? && Wx::PLATFORM == 'WXMSW'
273
+
274
+ def test_default_wx
275
+ Wx::ConfigBase.set(nil) # reset global instance
276
+ cfg = Wx::ConfigBase.get # forced auto creation of default config
277
+
278
+ assert_kind_of(Wx::ConfigWx, cfg)
279
+
280
+ cfg.replace(DEMO_CONFIG)
281
+
282
+ run_config_tests(cfg)
283
+ run_auto_accessor_tests(cfg)
284
+ run_env_var_tests(cfg)
285
+
286
+ assert_true(cfg.clear) # cleanup
287
+ end
288
+
289
+ end
290
+
126
291
  def test_html_help
127
- cfg = Wx::ConfigBase.create
292
+ cfg = Wx::ConfigBase.create(true, use_hash_config: true)
128
293
 
129
294
  assert_true(cfg.to_h.empty?)
130
295