wxruby3 0.9.0.pre.beta.13 → 0.9.0.pre.rc.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +1 -0
- data/README.md +47 -4
- data/assets/hello_button.png +0 -0
- data/assets/hello_button_clicked.png +0 -0
- data/assets/hello_world.png +0 -0
- data/assets/repo-social-preview.png +0 -0
- data/ext/wxruby3/include/wxruby-runtime.h +1 -0
- data/ext/wxruby3/swig/memory_management.i +6 -10
- data/ext/wxruby3/swig/wx.i +17 -6
- data/lib/wx/accessors.rb +8 -2
- data/lib/wx/core/art_locator.rb +2 -2
- data/lib/wx/core/artprovider.rb +2 -2
- data/lib/wx/core/bitmap.rb +6 -5
- data/lib/wx/core/bitmap_combobox.rb +34 -0
- data/lib/wx/core/controlwithitems.rb +52 -14
- data/lib/wx/core/cursor.rb +1 -1
- data/lib/wx/core/dc.rb +0 -20
- data/lib/wx/core/event_blocker.rb +14 -0
- data/lib/wx/core/evthandler.rb +36 -0
- data/lib/wx/core/find_replace_dialog.rb +24 -0
- data/lib/wx/core/icon.rb +1 -1
- data/lib/wx/core/image.rb +1 -1
- data/lib/wx/core/paintdc.rb +8 -0
- data/lib/wx/core/text_entry.rb +15 -0
- data/lib/wx/core/v_list_box.rb +13 -0
- data/lib/wx/core/window.rb +1 -1
- data/lib/wx/doc/busy_info.rb +21 -0
- data/lib/wx/doc/client_dc.rb +28 -0
- data/lib/wx/doc/controlwithitems.rb +11 -0
- data/lib/wx/doc/dc.rb +0 -14
- data/lib/wx/doc/event_blocker.rb +27 -0
- data/lib/wx/doc/evthandler.rb +4 -0
- data/lib/wx/doc/extra/02_lifecycles.md +49 -0
- data/lib/wx/doc/extra/10_art.md +1 -1
- data/lib/wx/doc/extra/11_drawing_and_dc.md +62 -0
- data/lib/wx/doc/memory_dc.rb +75 -0
- data/lib/wx/doc/mirror_dc.rb +16 -0
- data/lib/wx/doc/prt/printer_dc.rb +26 -0
- data/lib/wx/doc/screen_dc.rb +10 -6
- data/lib/wx/doc/svg_file_dc.rb +20 -0
- data/lib/wx/doc/v_list_box.rb +9 -0
- data/lib/wx/doc/window_disabler.rb +10 -0
- data/lib/wx/global_const.rb +24 -18
- data/lib/wx/html/keyword_defs.rb +6 -7
- data/lib/wx/html/require.rb +1 -0
- data/lib/wx/html/simple_html_listbox.rb +105 -0
- data/lib/wx/keyword_defs.rb +7 -0
- data/lib/wx/version.rb +1 -1
- data/lib/wx/wxruby/cmd/test.rb +1 -1
- data/rakelib/install.rb +3 -1
- data/rakelib/lib/core/mapping.rb +5 -5
- data/rakelib/lib/core/spec.rb +7 -3
- data/rakelib/lib/core/spec_helper.rb +9 -1
- data/rakelib/lib/director/accelerator.rb +1 -1
- data/rakelib/lib/director/app.rb +25 -3
- data/rakelib/lib/director/art_provider.rb +5 -1
- data/rakelib/lib/director/aui_pane_info.rb +1 -1
- data/rakelib/lib/director/aui_tab_ctrl.rb +1 -1
- data/rakelib/lib/director/bitmap.rb +2 -1
- data/rakelib/lib/director/bitmap_combobox.rb +32 -0
- data/rakelib/lib/director/brush.rb +1 -0
- data/rakelib/lib/director/busy_info.rb +1 -1
- data/rakelib/lib/director/choice.rb +1 -0
- data/rakelib/lib/director/clipboard.rb +1 -1
- data/rakelib/lib/director/colour.rb +1 -0
- data/rakelib/lib/director/colour_picker_ctrl.rb +1 -1
- data/rakelib/lib/director/combobox.rb +1 -2
- data/rakelib/lib/director/ctrl_with_items.rb +3 -0
- data/rakelib/lib/director/cursor.rb +1 -0
- data/rakelib/lib/director/data_object.rb +5 -7
- data/rakelib/lib/director/dc.rb +5 -1
- data/rakelib/lib/director/defs.rb +3 -0
- data/rakelib/lib/director/derived_dc.rb +278 -27
- data/rakelib/lib/director/dialog.rb +4 -1
- data/rakelib/lib/director/dir_picker_ctrl.rb +1 -1
- data/rakelib/lib/director/event.rb +3 -3
- data/rakelib/lib/director/event_blocker.rb +41 -0
- data/rakelib/lib/director/event_filter.rb +20 -0
- data/rakelib/lib/director/event_handler.rb +29 -2
- data/rakelib/lib/director/file_picker_ctrl.rb +1 -1
- data/rakelib/lib/director/find_replace_data.rb +1 -0
- data/rakelib/lib/director/font.rb +2 -1
- data/rakelib/lib/director/font_data.rb +1 -0
- data/rakelib/lib/director/font_picker_ctrl.rb +1 -1
- data/rakelib/lib/director/gdi_object.rb +1 -0
- data/rakelib/lib/director/graphics_context.rb +6 -6
- data/rakelib/lib/director/grid_table_message.rb +1 -1
- data/rakelib/lib/director/html_cell.rb +1 -1
- data/rakelib/lib/director/html_data_object.rb +5 -7
- data/rakelib/lib/director/html_listbox.rb +65 -1
- data/rakelib/lib/director/icon.rb +2 -0
- data/rakelib/lib/director/listbox.rb +1 -0
- data/rakelib/lib/director/locale.rb +2 -1
- data/rakelib/lib/director/palette.rb +1 -0
- data/rakelib/lib/director/pen.rb +2 -1
- data/rakelib/lib/director/pgproperties.rb +1 -1
- data/rakelib/lib/director/pgproperty.rb +1 -1
- data/rakelib/lib/director/pgvalidation_info.rb +1 -1
- data/rakelib/lib/director/platform_info.rb +1 -1
- data/rakelib/lib/director/print_data.rb +1 -1
- data/rakelib/lib/director/property_grid_interface.rb +1 -1
- data/rakelib/lib/director/property_grid_page_state.rb +1 -1
- data/rakelib/lib/director/region.rb +1 -0
- data/rakelib/lib/director/ribbon_art_provider.rb +1 -1
- data/rakelib/lib/director/richtext_buffer_data_object.rb +5 -7
- data/rakelib/lib/director/richtext_header_footer_data.rb +1 -1
- data/rakelib/lib/director/searchctrl.rb +24 -0
- data/rakelib/lib/director/sizer.rb +2 -2
- data/rakelib/lib/director/styled_text_ctrl.rb +2 -0
- data/rakelib/lib/director/text_entry.rb +2 -2
- data/rakelib/lib/director/tree_ctrl.rb +6 -3
- data/rakelib/lib/director/uiaction_simulator.rb +20 -0
- data/rakelib/lib/director/variant.rb +1 -1
- data/rakelib/lib/director/vlistbox.rb +25 -0
- data/rakelib/lib/director/window.rb +0 -6
- data/rakelib/lib/director/with_images.rb +1 -1
- data/rakelib/lib/director/xml_node.rb +1 -1
- data/rakelib/lib/extractor/function.rb +5 -3
- data/rakelib/lib/generate/doc/about_dialog_info.yaml +46 -0
- data/rakelib/lib/generate/doc/accelerator.yaml +21 -0
- data/rakelib/lib/generate/doc/art_provider.yaml +35 -0
- data/rakelib/lib/generate/doc/bitmap.yaml +37 -0
- data/rakelib/lib/generate/doc/box_sizer.yaml +15 -0
- data/rakelib/lib/generate/doc/busy_info.yaml +74 -0
- data/rakelib/lib/generate/doc/client_dc.yaml +19 -0
- data/rakelib/lib/generate/doc/clipboard.yaml +43 -0
- data/rakelib/lib/generate/doc/collapsible_pane.yaml +21 -0
- data/rakelib/lib/generate/doc/colour_dialog.yaml +32 -0
- data/rakelib/lib/generate/doc/control.yaml +46 -0
- data/rakelib/lib/generate/doc/cursor.yaml +40 -0
- data/rakelib/lib/generate/doc/data_object.yaml +55 -0
- data/rakelib/lib/generate/doc/dc.yaml +14 -0
- data/rakelib/lib/generate/doc/dialog.yaml +36 -0
- data/rakelib/lib/generate/doc/dir_dialog.yaml +25 -0
- data/rakelib/lib/generate/doc/events.yaml +152 -0
- data/rakelib/lib/generate/doc/evt_handler.yaml +63 -0
- data/rakelib/lib/generate/doc.rb +77 -14
- data/rakelib/lib/generate/interface.rb +11 -0
- data/rakelib/lib/specs/interfaces.rb +5 -4
- data/rakelib/lib/swig_runner.rb +3 -3
- data/rakelib/lib/typemap/common.rb +15 -3
- data/rakelib/lib/util/string.rb +1 -0
- data/rakelib/yard/yard/relative_markdown_links.rb +5 -1
- data/samples/bigdemo/wxArtProvider.rbw +5 -4
- data/samples/controls/controls.rb +2 -2
- data/samples/controls/htlbox.rb +411 -0
- data/samples/controls/tn_htlbox.png +0 -0
- data/samples/drawing/graphics_drawing.rb +1 -2
- data/samples/drawing/{svgtest.rb → image_prt.rb} +49 -18
- data/samples/drawing/tn_image_prt.png +0 -0
- data/samples/propgrid/propgrid.rb +23 -21
- data/samples/ribbon/ribbon.rb +47 -46
- data/tests/lib/wxapp_runner.rb +3 -3
- data/tests/lib/wxframe_runner.rb +59 -0
- data/tests/test_app_event_filter.rb +74 -0
- data/tests/test_art_provider.rb +52 -0
- data/tests/test_clipboard.rb +2 -1
- data/tests/test_event_handling.rb +199 -16
- data/tests/test_events.rb +4 -11
- data/tests/test_gdi_object.rb +161 -0
- data/tests/test_intl.rb +11 -14
- data/tests/test_item_data.rb +33 -1
- data/tests/test_std_controls.rb +147 -0
- metadata +56 -4
- data/samples/drawing/tn_svgtest.png +0 -0
data/samples/ribbon/ribbon.rb
CHANGED
@@ -153,9 +153,7 @@ class MyFrame < Wx::Frame
|
|
153
153
|
sizer_panelsizer_h.add(sizer_panelsizer_v, 0)
|
154
154
|
sizer_panel.set_sizer(sizer_panelsizer_h)
|
155
155
|
|
156
|
-
label_font = Wx::Font.new(Wx::FontInfo.new(8).light)
|
157
|
-
@bitmap_creation_dc = Wx::MemoryDC.new
|
158
|
-
@bitmap_creation_dc.set_font(label_font)
|
156
|
+
@label_font = Wx::Font.new(Wx::FontInfo.new(8).light)
|
159
157
|
|
160
158
|
scheme = Wx::RBN::RibbonPage.new(@ribbon, Wx::ID_ANY, "Appearance", bitmap_(:eye_xpm))
|
161
159
|
@default_primary = Wx::Colour.new
|
@@ -507,9 +505,10 @@ class MyFrame < Wx::Frame
|
|
507
505
|
|
508
506
|
# Colour not in gallery - add it
|
509
507
|
unless item
|
510
|
-
|
511
|
-
|
512
|
-
|
508
|
+
Wx::MemoryDC.draw_on do |dc|
|
509
|
+
item = add_colour_to_gallery(gallery,
|
510
|
+
clr.get_as_string(Wx::C2S_HTML_SYNTAX), dc, clr)
|
511
|
+
end
|
513
512
|
gallery.realise
|
514
513
|
end
|
515
514
|
|
@@ -738,46 +737,47 @@ class MyFrame < Wx::Frame
|
|
738
737
|
else
|
739
738
|
gallery = Wx::RBN::RibbonGallery.new(panel, gallery_id)
|
740
739
|
end
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
747
|
-
|
748
|
-
|
749
|
-
|
750
|
-
|
751
|
-
|
752
|
-
|
753
|
-
|
754
|
-
|
755
|
-
|
756
|
-
|
757
|
-
|
758
|
-
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
740
|
+
Wx::MemoryDC.draw_on do |dc|
|
741
|
+
def_item = add_colour_to_gallery(gallery, "Default", dc, defclr)
|
742
|
+
gallery.set_selection(def_item)
|
743
|
+
add_colour_to_gallery(gallery, "BLUE", dc)
|
744
|
+
add_colour_to_gallery(gallery, "BLUE VIOLET", dc)
|
745
|
+
add_colour_to_gallery(gallery, "BROWN", dc)
|
746
|
+
add_colour_to_gallery(gallery, "CADET BLUE", dc)
|
747
|
+
add_colour_to_gallery(gallery, "CORAL", dc)
|
748
|
+
add_colour_to_gallery(gallery, "CYAN", dc)
|
749
|
+
add_colour_to_gallery(gallery, "DARK GREEN", dc)
|
750
|
+
add_colour_to_gallery(gallery, "DARK ORCHID", dc)
|
751
|
+
add_colour_to_gallery(gallery, "FIREBRICK", dc)
|
752
|
+
add_colour_to_gallery(gallery, "GOLD", dc)
|
753
|
+
add_colour_to_gallery(gallery, "GOLDENROD", dc)
|
754
|
+
add_colour_to_gallery(gallery, "GREEN", dc)
|
755
|
+
add_colour_to_gallery(gallery, "INDIAN RED", dc)
|
756
|
+
add_colour_to_gallery(gallery, "KHAKI", dc)
|
757
|
+
add_colour_to_gallery(gallery, "LIGHT BLUE", dc)
|
758
|
+
add_colour_to_gallery(gallery, "LIME GREEN", dc)
|
759
|
+
add_colour_to_gallery(gallery, "MAGENTA", dc)
|
760
|
+
add_colour_to_gallery(gallery, "MAROON", dc)
|
761
|
+
add_colour_to_gallery(gallery, "NAVY", dc)
|
762
|
+
add_colour_to_gallery(gallery, "ORANGE", dc)
|
763
|
+
add_colour_to_gallery(gallery, "ORCHID", dc)
|
764
|
+
add_colour_to_gallery(gallery, "PINK", dc)
|
765
|
+
add_colour_to_gallery(gallery, "PLUM", dc)
|
766
|
+
add_colour_to_gallery(gallery, "PURPLE", dc)
|
767
|
+
add_colour_to_gallery(gallery, "RED", dc)
|
768
|
+
add_colour_to_gallery(gallery, "SALMON", dc)
|
769
|
+
add_colour_to_gallery(gallery, "SEA GREEN", dc)
|
770
|
+
add_colour_to_gallery(gallery, "SIENNA", dc)
|
771
|
+
add_colour_to_gallery(gallery, "SKY BLUE", dc)
|
772
|
+
add_colour_to_gallery(gallery, "TAN", dc)
|
773
|
+
add_colour_to_gallery(gallery, "THISTLE", dc)
|
774
|
+
add_colour_to_gallery(gallery, "TURQUOISE", dc)
|
775
|
+
add_colour_to_gallery(gallery, "VIOLET", dc)
|
776
|
+
add_colour_to_gallery(gallery, "VIOLET RED", dc)
|
777
|
+
add_colour_to_gallery(gallery, "WHEAT", dc)
|
778
|
+
add_colour_to_gallery(gallery, "WHITE", dc)
|
779
|
+
add_colour_to_gallery(gallery, "YELLOW", dc)
|
780
|
+
end
|
781
781
|
|
782
782
|
gallery
|
783
783
|
end
|
@@ -802,6 +802,7 @@ class MyFrame < Wx::Frame
|
|
802
802
|
|
803
803
|
bitmap = Wx::Bitmap.new(iWidth, iHeight)
|
804
804
|
dc.select_object(bitmap)
|
805
|
+
dc.set_font(@label_font)
|
805
806
|
b = Wx::Brush.new (c)
|
806
807
|
dc.set_pen(Wx::BLACK_PEN)
|
807
808
|
dc.set_brush(b)
|
data/tests/lib/wxapp_runner.rb
CHANGED
@@ -3,7 +3,7 @@ require 'test/unit'
|
|
3
3
|
require 'test/unit/ui/console/testrunner'
|
4
4
|
require 'wx'
|
5
5
|
|
6
|
-
module
|
6
|
+
module WxRuby
|
7
7
|
|
8
8
|
module Test
|
9
9
|
|
@@ -33,7 +33,7 @@ module Wx::SF
|
|
33
33
|
|
34
34
|
org_start_mtd = instance_method :start
|
35
35
|
define_method :start do
|
36
|
-
(app =
|
36
|
+
(app = WxRuby::Test::App.new(self, org_start_mtd)).run
|
37
37
|
app.result
|
38
38
|
end
|
39
39
|
|
@@ -46,7 +46,7 @@ end
|
|
46
46
|
module Test
|
47
47
|
module Unit
|
48
48
|
AutoRunner.register_runner(:wxapp) do |auto_runner|
|
49
|
-
|
49
|
+
WxRuby::Test::Runner
|
50
50
|
end
|
51
51
|
AutoRunner.default_runner = :wxapp
|
52
52
|
if defined? ::IntelliJ
|
@@ -0,0 +1,59 @@
|
|
1
|
+
|
2
|
+
require_relative './wxapp_runner'
|
3
|
+
|
4
|
+
module WxRuby
|
5
|
+
|
6
|
+
module Test
|
7
|
+
|
8
|
+
class App < Wx::App
|
9
|
+
def on_init
|
10
|
+
@tests_have_run = false
|
11
|
+
evt_idle :on_idle
|
12
|
+
@frame = Wx::Frame.new(nil, size: [600,400])
|
13
|
+
@frame.show
|
14
|
+
end
|
15
|
+
|
16
|
+
def on_idle(_evt)
|
17
|
+
done = @tests_have_run
|
18
|
+
@tests_have_run = true
|
19
|
+
@result = @start_mtd.bind(@test_runner).call unless done
|
20
|
+
self.exit_main_loop
|
21
|
+
end
|
22
|
+
|
23
|
+
attr_reader :frame
|
24
|
+
end
|
25
|
+
|
26
|
+
class GUITests < ::Test::Unit::TestCase
|
27
|
+
|
28
|
+
def test_frame
|
29
|
+
Wx.get_app.frame
|
30
|
+
end
|
31
|
+
|
32
|
+
class EventCounter
|
33
|
+
def initialize
|
34
|
+
@count = 0
|
35
|
+
end
|
36
|
+
attr_accessor :count
|
37
|
+
|
38
|
+
def inc
|
39
|
+
@count +=1
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def count_events(win, evt, id1=Wx::ID_ANY, id2=nil)
|
44
|
+
return 0 unless block_given?
|
45
|
+
evt_count = EventCounter.new
|
46
|
+
if id2.nil?
|
47
|
+
win.event_handler.send(evt.to_sym, id1, ->(_evt){ evt_count.inc })
|
48
|
+
else
|
49
|
+
win.event_handler.send(evt.to_sym, id1, id2, ->(_evt){ evt_count.inc })
|
50
|
+
end
|
51
|
+
yield evt_count
|
52
|
+
evt_count.count
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
@@ -0,0 +1,74 @@
|
|
1
|
+
|
2
|
+
require_relative './lib/wxapp_runner'
|
3
|
+
|
4
|
+
class AppEventFilterTests < Test::Unit::TestCase
|
5
|
+
|
6
|
+
class TestEvent < Wx::Event
|
7
|
+
EVT_TEST_EVENT = Wx::EvtHandler.register_class(self, nil, 'evt_test_event', 0)
|
8
|
+
def initialize(id=0)
|
9
|
+
super(EVT_TEST_EVENT, id)
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
class TestCmdEvent < Wx::CommandEvent
|
14
|
+
EVT_TEST_CMD_EVENT = Wx::EvtHandler.register_class(self, nil, 'evt_test_cmd_event', 0)
|
15
|
+
def initialize(id=0)
|
16
|
+
super(EVT_TEST_CMD_EVENT, id)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class TestFrame < Wx::Frame
|
21
|
+
def initialize
|
22
|
+
super(nil, size: [300,300])
|
23
|
+
@test_event = false
|
24
|
+
@test_cmd_event = false
|
25
|
+
|
26
|
+
evt_test_event { |evt| @test_event = true }
|
27
|
+
evt_test_cmd_event { |evt| @test_cmd_event = true }
|
28
|
+
end
|
29
|
+
|
30
|
+
attr_reader :test_event, :test_cmd_event
|
31
|
+
|
32
|
+
def reset
|
33
|
+
@test_event = false
|
34
|
+
@test_cmd_event = false
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
module ::WxRuby
|
39
|
+
module Test
|
40
|
+
class App < Wx::App
|
41
|
+
def filter_event(event)
|
42
|
+
@filtered = true if event.is_a?(TestEvent)
|
43
|
+
super
|
44
|
+
end
|
45
|
+
|
46
|
+
def filtered
|
47
|
+
@filtered
|
48
|
+
end
|
49
|
+
|
50
|
+
def filtered=(f)
|
51
|
+
@filtered = f
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_app_event_filter
|
58
|
+
GC.start
|
59
|
+
win = TestFrame.new
|
60
|
+
win.event_handler.process_event(TestEvent.new)
|
61
|
+
GC.start
|
62
|
+
assert(Wx.get_app.filtered)
|
63
|
+
Wx.get_app.filtered = false
|
64
|
+
win.event_handler.process_event(TestCmdEvent.new)
|
65
|
+
GC.start
|
66
|
+
assert(!Wx.get_app.filtered)
|
67
|
+
assert_nothing_raised { Wx::EvtHandler.clear_filters }
|
68
|
+
GC.start
|
69
|
+
win.event_handler.process_event(TestEvent.new)
|
70
|
+
assert(Wx.get_app.filtered)
|
71
|
+
GC.start
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
|
2
|
+
require_relative './lib/wxapp_runner'
|
3
|
+
|
4
|
+
class TestArtProvider < Test::Unit::TestCase
|
5
|
+
|
6
|
+
class MyArtProvider < Wx::ArtProvider
|
7
|
+
|
8
|
+
class << self
|
9
|
+
def is_called?
|
10
|
+
!!@called
|
11
|
+
end
|
12
|
+
def set_called(f = true)
|
13
|
+
@called = f
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def create_bitmap(id, client, size)
|
18
|
+
if id == Wx::ArtProvider.get_message_box_icon_id(Wx::ICON_INFORMATION)
|
19
|
+
MyArtProvider.set_called
|
20
|
+
Wx::Bitmap(:sample3)
|
21
|
+
else
|
22
|
+
MyArtProvider.set_called(false)
|
23
|
+
super
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_custom_provider
|
30
|
+
assert_not_nil(Wx::ArtProvider.get_message_box_icon(Wx::ICON_INFORMATION))
|
31
|
+
GC.start
|
32
|
+
assert(!MyArtProvider.is_called?)
|
33
|
+
GC.start
|
34
|
+
assert_nothing_raised { Wx::ArtProvider.push(MyArtProvider.new) }
|
35
|
+
GC.start
|
36
|
+
assert_not_nil(Wx::ArtProvider.get_message_box_icon(Wx::ICON_INFORMATION))
|
37
|
+
GC.start
|
38
|
+
assert(MyArtProvider.is_called?)
|
39
|
+
GC.start
|
40
|
+
assert_not_nil(Wx::ArtProvider.get_message_box_icon(Wx::ICON_ERROR))
|
41
|
+
GC.start
|
42
|
+
assert(!MyArtProvider.is_called?)
|
43
|
+
GC.start
|
44
|
+
assert_nothing_raised { Wx::ArtProvider.pop }
|
45
|
+
GC.start
|
46
|
+
assert_not_nil(Wx::ArtProvider.get_message_box_icon(Wx::ICON_INFORMATION))
|
47
|
+
GC.start
|
48
|
+
assert(!MyArtProvider.is_called?)
|
49
|
+
GC.start
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
data/tests/test_clipboard.rb
CHANGED
@@ -54,6 +54,7 @@ if Wx.has_feature?(:USE_HTML) && Wx::WXWIDGETS_VERSION >= '3.3'
|
|
54
54
|
Wx::Clipboard.open do | clip |
|
55
55
|
clip.fetch td_2
|
56
56
|
end
|
57
|
+
|
57
58
|
assert_equal('<html><body><h1>Header</h1></body></html>', td_2.html)
|
58
59
|
|
59
60
|
Wx::Clipboard.open do | clip |
|
@@ -64,7 +65,7 @@ if Wx.has_feature?(:USE_HTML) && Wx::WXWIDGETS_VERSION >= '3.3'
|
|
64
65
|
Wx::Clipboard.open do | clip |
|
65
66
|
clip.fetch td_3
|
66
67
|
end
|
67
|
-
assert_equal('', td_3.
|
68
|
+
assert_equal('', td_3.get_html)
|
68
69
|
end
|
69
70
|
end
|
70
71
|
end
|
@@ -41,6 +41,7 @@ class EventHandlingTests < Test::Unit::TestCase
|
|
41
41
|
@child = Child.new(self)
|
42
42
|
@test_event = false
|
43
43
|
@test_cmd_event = false
|
44
|
+
@called_after = false
|
44
45
|
|
45
46
|
evt_test_event { |evt| @test_event = true }
|
46
47
|
evt_test_cmd_event { |evt| @test_cmd_event = true }
|
@@ -48,45 +49,227 @@ class EventHandlingTests < Test::Unit::TestCase
|
|
48
49
|
|
49
50
|
attr_reader :child
|
50
51
|
attr_reader :test_event, :test_cmd_event
|
52
|
+
attr_accessor :called_after
|
51
53
|
|
52
54
|
def reset
|
53
55
|
@test_event = false
|
54
56
|
@test_cmd_event = false
|
57
|
+
@called_after = false
|
55
58
|
child.reset
|
56
59
|
end
|
57
60
|
end
|
58
61
|
|
59
62
|
def test_event
|
60
63
|
win = TestFrame.new
|
61
|
-
|
62
|
-
|
64
|
+
assert(!win.test_event)
|
65
|
+
assert(!win.child.test_event)
|
63
66
|
win.child.event_handler.process_event(TestEvent.new)
|
64
|
-
|
65
|
-
|
67
|
+
assert(!win.test_event)
|
68
|
+
assert(win.child.test_event)
|
66
69
|
win.reset
|
67
70
|
win.child.event_handler.process_event(TestEvent.new(1))
|
68
|
-
|
69
|
-
|
71
|
+
assert(!win.test_event)
|
72
|
+
assert(win.child.test_event)
|
70
73
|
win.reset
|
71
74
|
win.event_handler.process_event(TestEvent.new)
|
72
|
-
|
73
|
-
|
75
|
+
assert(win.test_event)
|
76
|
+
assert(!win.child.test_event)
|
77
|
+
win.destroy
|
78
|
+
Wx.get_app.yield
|
74
79
|
end
|
75
80
|
|
76
81
|
def test_cmd_event
|
77
82
|
win = TestFrame.new
|
78
|
-
|
79
|
-
|
83
|
+
assert(!win.test_cmd_event)
|
84
|
+
assert(!win.child.test_cmd_event)
|
80
85
|
win.child.event_handler.process_event(TestCmdEvent.new)
|
81
|
-
|
82
|
-
|
86
|
+
assert(!win.test_cmd_event)
|
87
|
+
assert(win.child.test_cmd_event)
|
83
88
|
win.reset
|
84
89
|
win.child.event_handler.process_event(TestCmdEvent.new(1))
|
85
|
-
|
86
|
-
|
90
|
+
assert(win.test_cmd_event)
|
91
|
+
assert(win.child.test_cmd_event)
|
87
92
|
win.reset
|
88
93
|
win.event_handler.process_event(TestCmdEvent.new)
|
89
|
-
|
90
|
-
|
94
|
+
assert(win.test_cmd_event)
|
95
|
+
assert(!win.child.test_cmd_event)
|
96
|
+
win.destroy
|
97
|
+
Wx.get_app.yield
|
91
98
|
end
|
99
|
+
|
100
|
+
def test_queue_event
|
101
|
+
win = TestFrame.new
|
102
|
+
assert(!win.test_cmd_event)
|
103
|
+
assert(!win.child.test_cmd_event)
|
104
|
+
win.child.event_handler.queue_event(TestCmdEvent.new)
|
105
|
+
Wx.get_app.yield
|
106
|
+
assert(!win.test_cmd_event)
|
107
|
+
assert(win.child.test_cmd_event)
|
108
|
+
win.reset
|
109
|
+
win.child.event_handler.queue_event(TestCmdEvent.new(1))
|
110
|
+
Wx.get_app.yield
|
111
|
+
assert(win.test_cmd_event)
|
112
|
+
assert(win.child.test_cmd_event)
|
113
|
+
win.reset
|
114
|
+
win.event_handler.queue_event(TestCmdEvent.new)
|
115
|
+
Wx.get_app.yield
|
116
|
+
assert(win.test_cmd_event)
|
117
|
+
assert(!win.child.test_cmd_event)
|
118
|
+
win.destroy
|
119
|
+
Wx.get_app.yield
|
120
|
+
end
|
121
|
+
|
122
|
+
def test_pending_event
|
123
|
+
win = TestFrame.new
|
124
|
+
assert(!win.test_cmd_event)
|
125
|
+
assert(!win.child.test_cmd_event)
|
126
|
+
win.child.event_handler.add_pending_event(TestCmdEvent.new)
|
127
|
+
Wx.get_app.yield
|
128
|
+
assert(!win.test_cmd_event)
|
129
|
+
assert(win.child.test_cmd_event)
|
130
|
+
win.reset
|
131
|
+
win.child.event_handler.add_pending_event(TestCmdEvent.new(1))
|
132
|
+
Wx.get_app.yield
|
133
|
+
assert(win.test_cmd_event)
|
134
|
+
assert(win.child.test_cmd_event)
|
135
|
+
win.reset
|
136
|
+
win.event_handler.add_pending_event(TestCmdEvent.new)
|
137
|
+
Wx.get_app.yield
|
138
|
+
assert(win.test_cmd_event)
|
139
|
+
assert(!win.child.test_cmd_event)
|
140
|
+
win.destroy
|
141
|
+
Wx.get_app.yield
|
142
|
+
end
|
143
|
+
|
144
|
+
def test_post_event
|
145
|
+
win = TestFrame.new
|
146
|
+
assert(!win.test_cmd_event)
|
147
|
+
assert(!win.child.test_cmd_event)
|
148
|
+
Wx.post_event(win.child.event_handler, TestCmdEvent.new)
|
149
|
+
Wx.get_app.yield
|
150
|
+
assert(!win.test_cmd_event)
|
151
|
+
assert(win.child.test_cmd_event)
|
152
|
+
win.reset
|
153
|
+
Wx.post_event(win.child.event_handler, TestCmdEvent.new(1))
|
154
|
+
Wx.get_app.yield
|
155
|
+
assert(win.test_cmd_event)
|
156
|
+
assert(win.child.test_cmd_event)
|
157
|
+
win.reset
|
158
|
+
Wx.post_event(win.event_handler, TestCmdEvent.new)
|
159
|
+
Wx.get_app.yield
|
160
|
+
assert(win.test_cmd_event)
|
161
|
+
assert(!win.child.test_cmd_event)
|
162
|
+
win.destroy
|
163
|
+
Wx.get_app.yield
|
164
|
+
end
|
165
|
+
|
166
|
+
def test_call_after
|
167
|
+
win = TestFrame.new
|
168
|
+
assert(!win.called_after)
|
169
|
+
win.event_handler.call_after { win.called_after = true }
|
170
|
+
Wx.get_app.yield
|
171
|
+
assert(win.called_after)
|
172
|
+
win.reset
|
173
|
+
win.child.event_handler.call_after { win.called_after = true }
|
174
|
+
Wx.get_app.yield
|
175
|
+
assert(win.called_after)
|
176
|
+
win.destroy
|
177
|
+
Wx.get_app.yield
|
178
|
+
end
|
179
|
+
|
180
|
+
def test_event_blocker
|
181
|
+
win = TestFrame.new
|
182
|
+
assert(!win.test_event)
|
183
|
+
win.event_handler.process_event(TestEvent.new)
|
184
|
+
assert(win.test_event)
|
185
|
+
win.reset
|
186
|
+
Wx::EventBlocker.blocked_for(win) do |blkr|
|
187
|
+
win.event_handler.process_event(TestEvent.new(1))
|
188
|
+
end
|
189
|
+
assert(!win.test_event)
|
190
|
+
win.event_handler.process_event(TestEvent.new)
|
191
|
+
assert(win.test_event)
|
192
|
+
win.reset
|
193
|
+
Wx::EventBlocker.blocked_for(win, TestEvent::EVT_TEST_EVENT) do |blkr|
|
194
|
+
win.event_handler.process_event(TestEvent.new(1))
|
195
|
+
end
|
196
|
+
assert(!win.test_event)
|
197
|
+
win.event_handler.process_event(TestEvent.new)
|
198
|
+
assert(win.test_event)
|
199
|
+
win.reset
|
200
|
+
Wx::EventBlocker.blocked_for(win, Wx::EVT_ACTIVATE) do |blkr|
|
201
|
+
win.event_handler.process_event(TestEvent.new(1))
|
202
|
+
end
|
203
|
+
assert(win.test_event)
|
204
|
+
win.destroy
|
205
|
+
Wx.get_app.yield
|
206
|
+
end
|
207
|
+
|
208
|
+
class MyEventFilter < Wx::EventFilter
|
209
|
+
def initialize
|
210
|
+
super
|
211
|
+
@filtered = false
|
212
|
+
end
|
213
|
+
|
214
|
+
attr_accessor :filtered
|
215
|
+
|
216
|
+
def filter_event(event)
|
217
|
+
@filtered = true if event.is_a?(TestEvent)
|
218
|
+
Wx::EventFilter::Event_Skip
|
219
|
+
end
|
220
|
+
end
|
221
|
+
|
222
|
+
def test_event_filter
|
223
|
+
filter = MyEventFilter.new
|
224
|
+
assert_nothing_raised { Wx::EvtHandler.add_filter(filter) }
|
225
|
+
GC.start
|
226
|
+
win = TestFrame.new
|
227
|
+
win.child.event_handler.process_event(TestEvent.new)
|
228
|
+
GC.start
|
229
|
+
assert(filter.filtered)
|
230
|
+
filter.filtered = false
|
231
|
+
win.child.event_handler.process_event(TestCmdEvent.new)
|
232
|
+
GC.start
|
233
|
+
assert(!filter.filtered)
|
234
|
+
assert_nothing_raised { Wx::EvtHandler.remove_filter(filter) }
|
235
|
+
GC.start
|
236
|
+
win.child.event_handler.process_event(TestEvent.new)
|
237
|
+
assert(!filter.filtered)
|
238
|
+
GC.start
|
239
|
+
win.destroy
|
240
|
+
Wx.get_app.yield
|
241
|
+
end
|
242
|
+
|
243
|
+
class MyEventFilter2 < Wx::EventFilter
|
244
|
+
|
245
|
+
class << self
|
246
|
+
attr_accessor :filtered
|
247
|
+
end
|
248
|
+
|
249
|
+
def filter_event(event)
|
250
|
+
MyEventFilter2.filtered = true if event.is_a?(TestEvent)
|
251
|
+
Wx::EventFilter::Event_Skip
|
252
|
+
end
|
253
|
+
end
|
254
|
+
|
255
|
+
def test_event_filter_clear
|
256
|
+
assert_nothing_raised { Wx::EvtHandler.add_filter(MyEventFilter2.new) }
|
257
|
+
GC.start
|
258
|
+
win = TestFrame.new
|
259
|
+
win.child.event_handler.process_event(TestEvent.new)
|
260
|
+
GC.start
|
261
|
+
assert(MyEventFilter2.filtered)
|
262
|
+
MyEventFilter2.filtered = false
|
263
|
+
win.child.event_handler.process_event(TestCmdEvent.new)
|
264
|
+
GC.start
|
265
|
+
assert(!MyEventFilter2.filtered)
|
266
|
+
assert_nothing_raised { Wx::EvtHandler.clear_filters }
|
267
|
+
GC.start
|
268
|
+
win.child.event_handler.process_event(TestEvent.new)
|
269
|
+
assert(!MyEventFilter2.filtered)
|
270
|
+
GC.start
|
271
|
+
win.destroy
|
272
|
+
Wx.get_app.yield
|
273
|
+
end
|
274
|
+
|
92
275
|
end
|
data/tests/test_events.rb
CHANGED
@@ -7,9 +7,9 @@ class EventTests < Test::Unit::TestCase
|
|
7
7
|
evt = Wx::Event.new(100, 1)
|
8
8
|
assert_equal(100, evt.event_type)
|
9
9
|
assert_equal(1, evt.id)
|
10
|
-
|
10
|
+
assert(!evt.should_propagate)
|
11
11
|
evt.skip
|
12
|
-
|
12
|
+
assert(evt.skipped)
|
13
13
|
evt_dup = evt.clone
|
14
14
|
assert_not_equal(evt, evt_dup)
|
15
15
|
assert_equal(evt.event_type, evt_dup.event_type)
|
@@ -20,9 +20,9 @@ class EventTests < Test::Unit::TestCase
|
|
20
20
|
evt = Wx::CommandEvent.new(100, 1)
|
21
21
|
assert_equal(100, evt.event_type)
|
22
22
|
assert_equal(1, evt.id)
|
23
|
-
|
23
|
+
assert(evt.should_propagate)
|
24
24
|
evt.skip
|
25
|
-
|
25
|
+
assert(evt.skipped)
|
26
26
|
evt.string = 'CommandEvent Test'
|
27
27
|
assert_equal('CommandEvent Test', evt.string)
|
28
28
|
evt_dup = evt.clone
|
@@ -44,10 +44,3 @@ class EventTests < Test::Unit::TestCase
|
|
44
44
|
assert_equal(evt.position, evt_dup.position)
|
45
45
|
end
|
46
46
|
end
|
47
|
-
|
48
|
-
class TestApp < Wx::App
|
49
|
-
def on_init
|
50
|
-
Test::Unit::UI::Console::TestRunner.run(EventTests)
|
51
|
-
false
|
52
|
-
end
|
53
|
-
end
|