wxruby3 0.9.0.pre.beta.14 → 0.9.0.pre.rc.2
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/INSTALL.md +51 -22
- data/README.md +81 -6
- data/assets/hello_button-macos.png +0 -0
- data/assets/hello_button-msw.png +0 -0
- data/assets/hello_button.png +0 -0
- data/assets/hello_button_clicked-macos.png +0 -0
- data/assets/hello_button_clicked-msw.png +0 -0
- data/assets/hello_button_clicked.png +0 -0
- data/assets/hello_button_clicked_combi.png +0 -0
- data/assets/hello_world-macos.png +0 -0
- data/assets/hello_world-msw.png +0 -0
- data/assets/hello_world.png +0 -0
- data/assets/hello_world_combi.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/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/brush.rb +6 -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 +48 -2
- data/lib/wx/core/find_replace_dialog.rb +24 -0
- data/lib/wx/core/font.rb +22 -14
- data/lib/wx/core/helpprovider.rb +2 -2
- data/lib/wx/core/icon.rb +1 -1
- data/lib/wx/core/image.rb +1 -1
- data/lib/wx/core/menu.rb +5 -0
- data/lib/wx/core/paintdc.rb +8 -0
- data/lib/wx/core/pen.rb +6 -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 +29 -2
- data/lib/wx/doc/app.rb +40 -0
- data/lib/wx/doc/brush.rb +17 -0
- 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/font.rb +27 -0
- data/lib/wx/doc/memory_dc.rb +75 -0
- data/lib/wx/doc/mirror_dc.rb +16 -0
- data/lib/wx/doc/pen.rb +17 -0
- data/lib/wx/doc/prt/printer_dc.rb +26 -0
- data/lib/wx/doc/radio_box.rb +20 -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.rb +27 -0
- data/lib/wx/doc/window_disabler.rb +10 -0
- 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 +83 -75
- data/lib/wx/prt/keyword_defs.rb +5 -1
- data/lib/wx/version.rb +1 -1
- data/lib/wx/wxruby/cmd/test.rb +1 -1
- data/rakelib/install.rb +20 -7
- data/rakelib/lib/config/linux.rb +4 -2
- data/rakelib/lib/config/macosx.rb +120 -1
- data/rakelib/lib/config/mingw.rb +6 -1
- data/rakelib/lib/config/unixish.rb +26 -11
- data/rakelib/lib/config.rb +15 -6
- data/rakelib/lib/core/mapping.rb +5 -5
- data/rakelib/lib/core/package.rb +1 -1
- data/rakelib/lib/core/spec.rb +9 -5
- data/rakelib/lib/core/spec_helper.rb +9 -1
- data/rakelib/lib/director/accelerator.rb +1 -1
- data/rakelib/lib/director/app.rb +55 -4
- 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/aui_toolbar.rb +41 -0
- data/rakelib/lib/director/bitmap.rb +2 -1
- data/rakelib/lib/director/bitmap_combobox.rb +32 -0
- data/rakelib/lib/director/brush.rb +11 -1
- 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 +2 -3
- data/rakelib/lib/director/context_help_button.rb +23 -0
- 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 +12 -3
- 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 +14 -4
- 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/help_provider.rb +8 -10
- 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/hyperlink_event.rb +22 -0
- 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/menu.rb +0 -3
- data/rakelib/lib/director/menu_bar.rb +3 -0
- data/rakelib/lib/director/palette.rb +1 -0
- data/rakelib/lib/director/pen.rb +12 -2
- 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/popup_window.rb +18 -0
- 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/radio_box.rb +15 -4
- 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 +25 -0
- data/rakelib/lib/director/sizer.rb +2 -2
- data/rakelib/lib/director/static_box.rb +1 -1
- data/rakelib/lib/director/styled_text_ctrl.rb +2 -0
- data/rakelib/lib/director/text_entry.rb +7 -2
- data/rakelib/lib/director/textctrl.rb +1 -1
- 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 +37 -7
- 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/context_help_button.yaml +16 -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/event_blocker.yaml +27 -0
- data/rakelib/lib/generate/doc/event_filter.yaml +47 -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/file_dialog.yaml +68 -0
- data/rakelib/lib/generate/doc.rb +77 -14
- data/rakelib/lib/generate/interface.rb +22 -10
- data/rakelib/lib/specs/interfaces.rb +9 -5
- 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/aui/aui.rb +432 -363
- 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 +26 -21
- data/samples/ribbon/ribbon.rb +47 -46
- data/samples/sampler/editor.rb +33 -25
- data/samples/sampler/sample.rb +2 -2
- data/samples/sampler/stc_editor.rb +4 -2
- data/tests/lib/item_container_tests.rb +82 -0
- data/tests/lib/text_entry_tests.rb +80 -0
- data/tests/lib/wxapp_runner.rb +15 -3
- data/tests/lib/wxframe_runner.rb +144 -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_ext_controls.rb +28 -0
- data/tests/test_font.rb +239 -0
- data/tests/test_gdi_object.rb +161 -0
- data/tests/test_intl.rb +16 -15
- data/tests/test_item_data.rb +33 -1
- data/tests/test_std_controls.rb +373 -0
- data/tests/test_window.rb +340 -0
- metadata +82 -4
- data/samples/drawing/tn_svgtest.png +0 -0
data/lib/wx/core/dc.rb
CHANGED
@@ -69,24 +69,4 @@ module Wx
|
|
69
69
|
|
70
70
|
end
|
71
71
|
|
72
|
-
class MemoryDC
|
73
|
-
|
74
|
-
# convenience method for drawing on a temporary memory DC
|
75
|
-
def self.draw_on(arg)
|
76
|
-
dc = case arg
|
77
|
-
when Wx::Bitmap, Wx::DC
|
78
|
-
self.new(arg)
|
79
|
-
else
|
80
|
-
::Kernel.raise ArgumentError, 'Expected Wx::Bitmap or Wx::DC'
|
81
|
-
end
|
82
|
-
begin
|
83
|
-
yield(dc) if block_given?
|
84
|
-
ensure
|
85
|
-
dc.select_object(Wx::NULL_BITMAP)
|
86
|
-
end
|
87
|
-
nil
|
88
|
-
end
|
89
|
-
|
90
|
-
end
|
91
|
-
|
92
72
|
end
|
data/lib/wx/core/evthandler.rb
CHANGED
@@ -17,9 +17,53 @@ class Wx::EvtHandler
|
|
17
17
|
|
18
18
|
# Fast look-up hash to map event type ids to ruby event classes
|
19
19
|
EVENT_TYPE_CLASS_MAP = {}
|
20
|
+
private_constant :EVENT_TYPE_CLASS_MAP
|
20
21
|
# Hash to look up EVT constants from symbol names of evt handler
|
21
22
|
# methods; used internally by disconnect (see EvtHandler.i)
|
22
23
|
EVENT_NAME_TYPE_MAP = {}
|
24
|
+
private_constant :EVENT_NAME_TYPE_MAP
|
25
|
+
# Hash to look up event handler arity from symbol names of evt handler
|
26
|
+
# methods; internal use
|
27
|
+
EVENT_NAME_EVENT_ARITY_MAP = {}
|
28
|
+
private_constant :EVENT_NAME_EVENT_ARITY_MAP
|
29
|
+
|
30
|
+
class << self
|
31
|
+
|
32
|
+
def event_type_arity(name)
|
33
|
+
EVENT_NAME_EVENT_ARITY_MAP[name.to_sym] || 0
|
34
|
+
end
|
35
|
+
|
36
|
+
def get_event_type_class_map
|
37
|
+
EVENT_TYPE_CLASS_MAP
|
38
|
+
end
|
39
|
+
private :get_event_type_class_map
|
40
|
+
|
41
|
+
# Add caching for added event filters as we need to keep these alive
|
42
|
+
# for as long as they are registered
|
43
|
+
|
44
|
+
def event_filters
|
45
|
+
@event_filters ||= []
|
46
|
+
end
|
47
|
+
private :event_filters
|
48
|
+
|
49
|
+
wx_add_filter = instance_method :add_filter
|
50
|
+
define_method :add_filter do |filter|
|
51
|
+
wx_add_filter.bind(self).call(filter)
|
52
|
+
event_filters << filter
|
53
|
+
end
|
54
|
+
|
55
|
+
wx_remove_filter = instance_method :remove_filter
|
56
|
+
define_method :remove_filter do |filter|
|
57
|
+
wx_remove_filter.bind(self).call(filter)
|
58
|
+
event_filters.delete(filter)
|
59
|
+
end
|
60
|
+
|
61
|
+
def clear_filters
|
62
|
+
event_filters.each { |f| remove_filter(f) }
|
63
|
+
event_filters.clear
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
23
67
|
|
24
68
|
# Given a Wx EventType id (eg Wx::EVT_MENU), returns a WxRuby Event
|
25
69
|
# class which should be passed to event handler blocks. The actual
|
@@ -43,8 +87,8 @@ class Wx::EvtHandler
|
|
43
87
|
|
44
88
|
# Given the Integer constant Wx::EVT_XXX, returns the convenience
|
45
89
|
# handler method name associated with that type of event.
|
46
|
-
def self.event_name_for_type(
|
47
|
-
EVENT_NAME_TYPE_MAP.key(
|
90
|
+
def self.event_name_for_type(evt_id)
|
91
|
+
EVENT_NAME_TYPE_MAP.key(evt_id)
|
48
92
|
end
|
49
93
|
|
50
94
|
# Given an integer value +int_val+, returns the name of the EVT_xxx
|
@@ -85,6 +129,8 @@ class Wx::EvtHandler
|
|
85
129
|
return
|
86
130
|
end
|
87
131
|
|
132
|
+
EVENT_NAME_EVENT_ARITY_MAP[ev_type.name.to_sym] = ev_type.arity
|
133
|
+
|
88
134
|
# set up the evt_xxx method
|
89
135
|
case ev_type.arity
|
90
136
|
when 0 # events without an id
|
@@ -0,0 +1,24 @@
|
|
1
|
+
|
2
|
+
module Wx
|
3
|
+
|
4
|
+
class FindReplaceDialog < Wx::Dialog
|
5
|
+
|
6
|
+
# add caching for FindReplaceData object
|
7
|
+
# dialog does not take over ownership but does allow referencing
|
8
|
+
# the data object so we need to keep it alive here
|
9
|
+
|
10
|
+
wx_initialize = instance_method :initialize
|
11
|
+
define_method :initialize do |parent, data, *args|
|
12
|
+
wx_initialize.bind(self).call(parent, data, *args)
|
13
|
+
@fr_data = data
|
14
|
+
end
|
15
|
+
|
16
|
+
wx_set_data = instance_method :set_data
|
17
|
+
define_method :set_data do |data|
|
18
|
+
wx_set_data.bind(self).call(data)
|
19
|
+
@fr_data = data
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
data/lib/wx/core/font.rb
CHANGED
@@ -1,22 +1,30 @@
|
|
1
1
|
|
2
2
|
require_relative './font/encoding'
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
4
|
+
module Wx
|
5
|
+
|
6
|
+
class Font
|
7
|
+
class << self
|
8
|
+
# Returns the name of the platform's default font encoding
|
9
|
+
def get_default_encoding_name
|
10
|
+
ENCODING_NAMES[ get_default_encoding ]
|
11
|
+
end
|
10
12
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
13
|
+
# Sets the default encoding to be +enc+, which may be the string
|
14
|
+
# name of an encoding (eg 'UTF8') or an internal WxWidgets flag
|
15
|
+
# (eg Wx::FONTENCODING_UTF8).
|
16
|
+
def set_default_encoding_name(enc)
|
17
|
+
if flag_int = ENCODING_NAMES.index(enc.upcase)
|
18
|
+
set_default_encoding(Wx::FontEncoding.new(flag_int))
|
19
|
+
else
|
20
|
+
raise ArgumentError, "Unknown font encoding name '#{enc}'"
|
21
|
+
end
|
19
22
|
end
|
20
23
|
end
|
21
24
|
end
|
25
|
+
|
26
|
+
# make this simply an alias for the Font class so the #find_or_create_font methods
|
27
|
+
# can be accessed through that name too.
|
28
|
+
TheFontList = Font
|
29
|
+
|
22
30
|
end
|
data/lib/wx/core/helpprovider.rb
CHANGED
@@ -6,9 +6,9 @@ class Wx::HelpProvider
|
|
6
6
|
# SWIG Director; it can't be reaped and re-wrapped later. The
|
7
7
|
# easiest way is to make the currently set one an instance variable
|
8
8
|
# of this class
|
9
|
-
|
9
|
+
wx_set = instance_method :set
|
10
10
|
define_method(:set) do | help_provider |
|
11
|
-
|
11
|
+
wx_set.bind(self).call(help_provider)
|
12
12
|
@__hp__ = help_provider
|
13
13
|
end
|
14
14
|
end
|
data/lib/wx/core/icon.rb
CHANGED
@@ -51,7 +51,7 @@ module Wx
|
|
51
51
|
end
|
52
52
|
|
53
53
|
def self.Icon(name, bmp_type = nil, *rest)
|
54
|
-
art_path = File.dirname(caller_path = caller_locations(1).first.absolute_path)
|
54
|
+
art_path = File.dirname(caller_path = caller_locations(1).first.absolute_path || caller_locations(1).first.path)
|
55
55
|
art_owner = File.basename(caller_path, '.*')
|
56
56
|
art_file = ArtLocator.find_art(name, art_type: :icon, art_path: art_path, art_section: art_owner, bmp_type: bmp_type)
|
57
57
|
::Kernel.raise ArgumentError, "Cannot locate art file for #{name}:Icon" unless art_file
|
data/lib/wx/core/image.rb
CHANGED
@@ -69,7 +69,7 @@ module Wx
|
|
69
69
|
end
|
70
70
|
|
71
71
|
def self.Image(name, bmp_type = nil, *rest)
|
72
|
-
art_path = File.dirname(caller_path = caller_locations(1).first.absolute_path)
|
72
|
+
art_path = File.dirname(caller_path = caller_locations(1).first.absolute_path || caller_locations(1).first.path)
|
73
73
|
art_owner = File.basename(caller_path, '.*')
|
74
74
|
art_file = ArtLocator.find_art(name, art_type: :image, art_path: art_path, art_section: art_owner, bmp_type: bmp_type)
|
75
75
|
::Kernel.raise ArgumentError, "Cannot locate art file for #{name}:Image" unless art_file
|
data/lib/wx/core/menu.rb
CHANGED
data/lib/wx/core/pen.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
|
2
|
+
module Wx
|
3
|
+
|
4
|
+
module TextEntry
|
5
|
+
|
6
|
+
wx_auto_complete = instance_method :auto_complete
|
7
|
+
define_method :auto_complete do |completer|
|
8
|
+
if wx_auto_complete.bind(self).call(completer)
|
9
|
+
@completer = completer # keep the Ruby object alive
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
|
2
|
+
class Wx::VListBox
|
3
|
+
|
4
|
+
wx_each_selected = instance_method :each_selected
|
5
|
+
define_method :each_selected do |&block|
|
6
|
+
if block
|
7
|
+
wx_each_selected.bind(self).call(&block)
|
8
|
+
else
|
9
|
+
::Enumerator.new { |y| wx_each_selected.bind(self).call { |sel| y << sel } }
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
data/lib/wx/core/window.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
# Copyright 2004-2007 by Kevin Smith
|
2
|
-
#
|
2
|
+
# Copyright 2022 by Martin Corino
|
3
|
+
# released under the MIT(-style) wxruby2/3 license
|
3
4
|
|
4
5
|
# The base class for all things displayed on screen
|
5
6
|
class Wx::Window
|
@@ -49,7 +50,7 @@ class Wx::Window
|
|
49
50
|
# This modified version of evt_paint sets a variable indicating that a
|
50
51
|
# paint event is being handled just before running the event
|
51
52
|
# handler. This ensures that any call to Window#paint within the
|
52
|
-
# handler will supply a Wx::PaintDC (see
|
53
|
+
# handler will supply a Wx::PaintDC (see Window SWIG director).
|
53
54
|
def evt_paint(meth = nil, &block)
|
54
55
|
paint_proc = acquire_handler(meth, block)
|
55
56
|
wrapped_block = proc do | event |
|
@@ -69,4 +70,30 @@ class Wx::Window
|
|
69
70
|
self.paint(&block)
|
70
71
|
end
|
71
72
|
end
|
73
|
+
|
74
|
+
# implement non-static variants of these
|
75
|
+
|
76
|
+
def from_dip(*args)
|
77
|
+
Wx::Window.from_dip(*args, self)
|
78
|
+
end
|
79
|
+
def to_dip(*args)
|
80
|
+
Wx::Window.to_dip(*args, self)
|
81
|
+
end
|
82
|
+
|
83
|
+
def from_phys(*args)
|
84
|
+
Wx::Window.from_phys(*args, self)
|
85
|
+
end
|
86
|
+
def to_phys(*args)
|
87
|
+
Wx::Window.to_phys(*args, self)
|
88
|
+
end
|
89
|
+
|
90
|
+
# implement Window update locker
|
91
|
+
def locked(&block)
|
92
|
+
self.freeze
|
93
|
+
begin
|
94
|
+
block.call if block_given?
|
95
|
+
ensure
|
96
|
+
self.thaw
|
97
|
+
end
|
98
|
+
end
|
72
99
|
end
|
data/lib/wx/doc/app.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
|
2
|
+
class Wx::App
|
3
|
+
|
4
|
+
# Set the menu item id for the About menu item.
|
5
|
+
# Default is {Wx::ID_ABOUT}
|
6
|
+
# @param [Integer] id
|
7
|
+
def set_mac_about_menu_itemid(id) end
|
8
|
+
alias :mac_about_menu_itemid= :set_mac_about_menu_itemid
|
9
|
+
|
10
|
+
# Get the current menu item id for the About menu item.
|
11
|
+
# Default is {Wx::ID_ABOUT}
|
12
|
+
# @return [Integer]
|
13
|
+
def get_mac_about_menu_itemid(id) end
|
14
|
+
alias :mac_about_menu_itemid :get_mac_about_menu_itemid
|
15
|
+
|
16
|
+
# Set the menu item id for the Preferences menu item.
|
17
|
+
# Default is {Wx::ID_PREFERENCES}
|
18
|
+
# @param [Integer] id
|
19
|
+
def set_mac_preferences_menu_itemid(id) end
|
20
|
+
alias :mac_preferences_menu_itemid= :set_mac_preferences_menu_itemid
|
21
|
+
|
22
|
+
# Get the current menu item id for the Preferences menu item.
|
23
|
+
# Default is {Wx::ID_PREFERENCES}
|
24
|
+
# @return [Integer]
|
25
|
+
def get_mac_preferences_menu_itemid(id) end
|
26
|
+
alias :mac_preferences_menu_itemid :get_mac_preferences_menu_itemid
|
27
|
+
|
28
|
+
# Set the menu item id for the Exit menu item.
|
29
|
+
# Default is {Wx::ID_EXIT}
|
30
|
+
# @param [Integer] id
|
31
|
+
def set_mac_exit_menu_itemid(id) end
|
32
|
+
alias :mac_exit_menu_itemid= :set_mac_exit_menu_itemid
|
33
|
+
|
34
|
+
# Get the current menu item id for the Exit menu item.
|
35
|
+
# Default is {Wx::ID_EXIT}
|
36
|
+
# @return [Integer]
|
37
|
+
def get_mac_exit_menu_itemid(id) end
|
38
|
+
alias :mac_exit_menu_itemid :get_mac_exit_menu_itemid
|
39
|
+
|
40
|
+
end
|
data/lib/wx/doc/brush.rb
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
|
2
|
+
module Wx
|
3
|
+
|
4
|
+
class Brush
|
5
|
+
|
6
|
+
# Finds a brush with the specified attributes in the global list and returns it, else creates a new brush, adds it to the global brush list, and returns it.
|
7
|
+
# @param [Wx::Colour,String,Symbol] colour The Brush colour.
|
8
|
+
# @param [Wx::BrushStyle] style The brush style. See {Wx::BrushStyle} for a list of the styles.
|
9
|
+
# @return [Wx::Brush]
|
10
|
+
def self.find_or_create_brush(colour, style=Wx::BrushStyle::BRUSHSTYLE_SOLID) end
|
11
|
+
|
12
|
+
end
|
13
|
+
|
14
|
+
# In wxRuby this is simply an alias for the Brush class.
|
15
|
+
TheBrushList = Wx::Brush
|
16
|
+
|
17
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
|
2
|
+
module Wx
|
3
|
+
|
4
|
+
class BusyInfo
|
5
|
+
|
6
|
+
# @overload busy(message, parent=nil)
|
7
|
+
# Shows busy info window with message, blocks event handling and calls the given block
|
8
|
+
# passing the BusyInfo instance as argument.
|
9
|
+
# @param [String] message
|
10
|
+
# @param [Wx::Window,nil] parent
|
11
|
+
# @yieldparam [Wx::BusyInfo] bi BusyInfo instance
|
12
|
+
# @overload busy(busy_info)
|
13
|
+
# Shows busy info window according to busy_info settings, blocks event handling and calls the given block
|
14
|
+
# passing the BusyInfo instance as argument.
|
15
|
+
# @param [Wx::BusyInfoFlags] busy_info
|
16
|
+
# @yieldparam [Wx::BusyInfo] bi BusyInfo instance
|
17
|
+
def self.busy(*args) end
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
|
2
|
+
module Wx
|
3
|
+
|
4
|
+
class ClientDC < Wx::DC
|
5
|
+
|
6
|
+
# Executes the given block providing a temporary (client) dc as
|
7
|
+
# it's single argument.
|
8
|
+
# @param [Wx::Window] win window to draw on
|
9
|
+
# @yieldparam [Wx::ClientDC] dc the ClientDC instance to paint on
|
10
|
+
# @return [Object] result of the block
|
11
|
+
def self.draw_on(win) end
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
class PaintDC < Wx::ClientDC
|
16
|
+
|
17
|
+
# Executes the given block providing a temporary dc as
|
18
|
+
# it's single argument.
|
19
|
+
# Pass a pointer to the window on which you wish to paint.
|
20
|
+
# @note In wxRuby this method mostly exists to be consistent with the other DC classes. It is however recommended to use Wx::Window#paint instead.
|
21
|
+
# @param [Wx::Window] win window to draw on
|
22
|
+
# @yieldparam [Wx::PaintDC] dc the PaintDC instance to paint on
|
23
|
+
# @return [Object] result of the block
|
24
|
+
def self.draw_on(win) end
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
|
2
|
+
class Wx::ControlWithItems
|
3
|
+
|
4
|
+
# Returns true if the items in the control are sorted
|
5
|
+
# (style Wx::LB_SORT for list boxes or Wx::CB_SORT for combo boxes).
|
6
|
+
# This method is mostly meant for internal use only.
|
7
|
+
# @return [Boolean] true is sorted, false otherwise
|
8
|
+
def is_sorted; end
|
9
|
+
alias :sorted? :is_sorted
|
10
|
+
|
11
|
+
end
|
data/lib/wx/doc/dc.rb
CHANGED
@@ -49,18 +49,4 @@ module Wx
|
|
49
49
|
|
50
50
|
end
|
51
51
|
|
52
|
-
class MemoryDC
|
53
|
-
|
54
|
-
# Creates a Memory DC and passes that to the given block to draw on.
|
55
|
-
# Automatically unselects any source object of the MemoryDC after the block finishes.
|
56
|
-
# @overload self.draw_on(bitmap)
|
57
|
-
# @param [Wx::Bitmap]
|
58
|
-
# @yieldparam [WxMemoryDC] dc
|
59
|
-
# @overload self.draw_on(dc)
|
60
|
-
# @param [Wx::DC]
|
61
|
-
# @yieldparam [WxMemoryDC] dc
|
62
|
-
def self.draw_on(arg, &block) end
|
63
|
-
|
64
|
-
end
|
65
|
-
|
66
52
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
|
2
|
+
module Wx
|
3
|
+
|
4
|
+
class EventBlocker
|
5
|
+
|
6
|
+
class << self
|
7
|
+
|
8
|
+
# Constructs the blocker for the given window and for the given event type and passes the blocker to the
|
9
|
+
# given block. The blocker is destroyed after the block returns.
|
10
|
+
#
|
11
|
+
# If type is Wx::EVT_ANY, then all events for that window are blocked. You can call #block after creation to
|
12
|
+
# add other event types to the list of events to block.
|
13
|
+
#
|
14
|
+
# @note Note that the win window must remain alive until the given block returns (i.e. until Wx::EventBlocker's
|
15
|
+
# object destruction).
|
16
|
+
# @param [Wx::Window] win the window to block events for
|
17
|
+
# @param [Integer] evt_type the event type to block
|
18
|
+
# @yieldparam [Wx::EventBlocker] blkr the blocker object
|
19
|
+
# @return [Object] the value returned by the block
|
20
|
+
def blocked_for(win, evt_type=Wx::EVT_ANY) end
|
21
|
+
alias :block_for :blocked_for
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
data/lib/wx/doc/evthandler.rb
CHANGED
@@ -3,6 +3,10 @@
|
|
3
3
|
|
4
4
|
class Wx::EvtHandler
|
5
5
|
|
6
|
+
# Removes all (Ruby) installed EventFilter-s.
|
7
|
+
# @return [void]
|
8
|
+
def self.clear_filters; end
|
9
|
+
|
6
10
|
# Public method to register the mapping of a custom event type
|
7
11
|
# +konstant+ (which should be a unique integer; one will be created if
|
8
12
|
# not supplied) to a custom event class +klass+. If +meth+ and +arity+
|
@@ -114,3 +114,52 @@ destroy these on a regular basis when not used (closed) possibly re-creating the
|
|
114
114
|
|
115
115
|
Dialogs are special cases of toplevel windows which are not automatically destroyed when closed. The wxRuby library
|
116
116
|
therefor provides special support to ease handling the destruction of these. See [here](03_dialogs.md) for more details.
|
117
|
+
|
118
|
+
## Object identities
|
119
|
+
|
120
|
+
One of the trickier things to handle correctly in the kind of native extensions like wxRuby is maintaining object
|
121
|
+
identities i.e. keeping native instances synced with their Ruby wrapper counter parts.
|
122
|
+
|
123
|
+
Whenever a native extension is allowed to call back into Ruby space we encounter the problem the we need to map any
|
124
|
+
native object data provided for the call to the right Ruby types and when necessary to the right Ruby instance (object
|
125
|
+
identity).
|
126
|
+
|
127
|
+
Objects that are considered POD types (*plain old data* types) like numerics, booleans, strings, arrays and hashes do
|
128
|
+
not require maintaining *object identity*. For these objects it is enough to map them to the right Ruby type before
|
129
|
+
passing them on to Ruby space.
|
130
|
+
|
131
|
+
For a lot of other objects though it is essential to not only map to the right **most derived** class type but also to
|
132
|
+
the exact Ruby instance which was originally instantiated as wrapper for the native object if any exists (in case no
|
133
|
+
Ruby instance existed yet a new instance of the correct **most derived** class should be instantiated at that point).
|
134
|
+
The reason this is important is 1. because the Ruby instance may have been used to identify, link to or otherwise
|
135
|
+
reference other data and/or functionality related to that specific Ruby/native pair and 2. the Ruby instance could
|
136
|
+
contain data elements (instance variables) related to that specific Ruby/native pair.<br>
|
137
|
+
In the case of wxRuby Window instance for example it is common to derive custom Window classes with custom behaviour and
|
138
|
+
corresponding instance variables that drive that behaviour. When an event handler or an overloaded native method is passed
|
139
|
+
a native window object we absolutely need to be able to map that native object to the correct Ruby wrapper instance so
|
140
|
+
all information stays in sync.
|
141
|
+
|
142
|
+
For this purpose wxRuby uses *object tracking* i.e. maintaining hash tables mapping native object pointers to Ruby object
|
143
|
+
values. Whenever a tracked object is instantiated it is registered and can from than on be resolved whenever needed to map
|
144
|
+
from native object to Ruby object.<br>
|
145
|
+
Of course this also means wxRuby has to track object destruction so mappings can be removed when a native object is
|
146
|
+
destructed.<br>
|
147
|
+
Additionally the tracking tables are also used to mark Ruby objects during the GC marking phase so they do not get garbage
|
148
|
+
collected whenever they are not referenced in Ruby space anymore but still functioning in native space (this is for example
|
149
|
+
a common situation for many child windows created but not permanently referenced in Ruby space).
|
150
|
+
|
151
|
+
Tracking and resolving mappings from tracking tables produces a certain computing overhead but testing has shown this to be
|
152
|
+
absolutely acceptable for normal applications.
|
153
|
+
|
154
|
+
There are however quite a lot of wrapped native objects in wxRuby for which *object identity* is not essential. For these
|
155
|
+
object tracking has been disabled for their classes. This means these kind of classes/object should **not** be derived from
|
156
|
+
(if even possible and/or useful) to add functionality/information or their identity used as key to link other information.<br>
|
157
|
+
These classes include:
|
158
|
+
- classes considered POD types like Wx::Size, Wx::Point, Wx::RealPoint, Wx::Rect, Wx::GBSpan, Wx::GBPosition, Wx::BusyInfoFlags,
|
159
|
+
Wx::AboutDialogInfo
|
160
|
+
- final non-instantiatable classes like the Wx::DC (Device Context) class family, Wx::GraphicsContext, Wx::WindowsDisabler,
|
161
|
+
Wx::EventBlocker, Wx::BusyInfo
|
162
|
+
- classes with native singleton objects like Wx::Clipboard
|
163
|
+
- the reference counted GDI objects like Wx::Pen, Wx::Brush, Wx::Colour, Wx::Cursor, Wx::Bitmap, Wx::Icon
|
164
|
+
|
165
|
+
The reference documentation will note untracked object classes.
|
data/lib/wx/doc/extra/10_art.md
CHANGED
@@ -0,0 +1,62 @@
|
|
1
|
+
<!--
|
2
|
+
# @markup markdown
|
3
|
+
# @title 11. wxRuby Drawing and Device Contexts
|
4
|
+
-->
|
5
|
+
|
6
|
+
# 11. wxRuby Drawing and Device Contexts (DC)
|
7
|
+
|
8
|
+
In wxRuby the Wx::DC class family provides functionality for drawing to windows, bitmaps, printers etc.
|
9
|
+
|
10
|
+
What most of these classes have in common is that actual drawing output is buffered until the time the
|
11
|
+
device context object is destroyed.
|
12
|
+
For this reason the common practice in wxWidgets C++ code would be to create temporary DC objects on the
|
13
|
+
stack and draw on them while they are in scope (for several classes it is even strongly advised to never create
|
14
|
+
them any other way and to never keep objects alive out of scope). When leaving the scope these object would than be
|
15
|
+
automatically destroyed and the any buffered output flushed to the final target.
|
16
|
+
|
17
|
+
In Ruby this approach is impossible as Ruby is a purely dynamic language and does not **this kind** of scope bound
|
18
|
+
life cycles. Any DC object created would have to be dynamically created and due to the properties of the GC driven
|
19
|
+
life cycles could well be kept alive beyond the scope of it's creation. This will not always cause problems but could
|
20
|
+
and does not really have an upside.
|
21
|
+
|
22
|
+
To prevent confusion and potential problems wxRuby defines all `Wx::DC` derived classes to be abstract classes that
|
23
|
+
cannot be instantiated using `new`. Rather all `Wx::DC` derived classes provide `::draw_on` factory methods to create
|
24
|
+
temporary dc objects that will be passed on to blocks given and will only exist for the duration of the execution of
|
25
|
+
the block. This will guarantee proper DC cleanup when leaving it's usage scope.
|
26
|
+
|
27
|
+
> Note that it is a **BAD** idea to think about storing the dc reference provide to the block for later access!
|
28
|
+
|
29
|
+
A typical usage of a `::draw_on` method would be:
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
myTestBitmap1x = Wx::Bitmap.new(60, 15, 32)
|
33
|
+
Wx::MemoryDC.draw_on(myTestBitmap1x) do |mdc|
|
34
|
+
mdc.set_background(Wx::WHITE_BRUSH)
|
35
|
+
mdc.clear
|
36
|
+
mdc.set_pen(Wx::BLACK_PEN)
|
37
|
+
mdc.set_brush(Wx::WHITE_BRUSH)
|
38
|
+
mdc.draw_rectangle(0, 0, 60, 15)
|
39
|
+
mdc.draw_line(0, 0, 59, 14)
|
40
|
+
mdc.set_text_foreground(Wx::BLACK)
|
41
|
+
mdc.draw_text("x1", 0, 0)
|
42
|
+
end
|
43
|
+
```
|
44
|
+
|
45
|
+
## Windows, Wx::PaintDC and Wx::AutoBufferedPaintDC
|
46
|
+
|
47
|
+
The `Wx::PaintDC` and `Wx::AutoBufferedPaintDC` classes provide `::draw_on` methods just like all other DC classes but
|
48
|
+
this is mostly to be consistent.
|
49
|
+
|
50
|
+
In this case it is recommended to instead use the `Wx::Window#paint` or `Wx::Window#paint_buffered` methods as these
|
51
|
+
provide some optimizations with regard to automatically detecting is the methods are called inside `Wx::EVT_PAINT`
|
52
|
+
handlers (which should normally be the case) or not.
|
53
|
+
|
54
|
+
So the typical way to do buffered painting inside a windows `Wx::EVT_PAINT` handler would be something like:
|
55
|
+
|
56
|
+
```ruby
|
57
|
+
def on_paint(_event)
|
58
|
+
self.paint_buffered do |dc|
|
59
|
+
# ... do some drawing ...
|
60
|
+
end
|
61
|
+
end
|
62
|
+
```
|
data/lib/wx/doc/font.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
|
2
|
+
class Wx
|
3
|
+
class Font
|
4
|
+
|
5
|
+
# @overload find_or_create_font(point_size, family, style, weight, underline=false, facename='', encoding=Wx::FontEncoding::FONTENCODING_DEFAULT)
|
6
|
+
# Finds a font of the given specification in the global font list, or creates one and adds it to the list.
|
7
|
+
# @param [Integer] point_size Size in points. See {Wx::Font#set_point_size} for more info.
|
8
|
+
# @param [Wx::FontFamily] family The font family: a generic portable way of referring to fonts without specifying a facename.
|
9
|
+
# @param [Wx::FontStyle] style One of {Wx::FontStyle::FONTSTYLE_NORMAL}, {Wx::FontStyle::FONTSTYLE_SLANT} and {Wx::FontStyle::FONTSTYLE_ITALIC}.
|
10
|
+
# @param [Wx::FontWeight] weight Font weight, sometimes also referred to as font boldness. One of the {Wx::FontWeight} enumeration values.
|
11
|
+
# @param [Boolean] underline The value can be true or false.
|
12
|
+
# @param [String] facename An optional string specifying the face name to be used. If it is an empty string, a default face name will be chosen based on the family.
|
13
|
+
# @param [Wx::FontEncoding] encoding An encoding which may be one of the enumeration values of {Wx::FontEncoding}. If the specified encoding isn't available, no font is created (see also Font Encodings).
|
14
|
+
# @return [Wx::Font]
|
15
|
+
# @see Wx::Font#initialize
|
16
|
+
# @overload find_or_create_font(font_info)
|
17
|
+
# Finds a font of the given specification in the global font list, or creates one and adds it to the list.
|
18
|
+
# @param [Wx::FontInfo] font_info
|
19
|
+
# @return [Wx::Font]
|
20
|
+
def self.find_or_create_font(*args) end
|
21
|
+
|
22
|
+
end
|
23
|
+
|
24
|
+
# In wxRuby this is simply an alias for the Font class.
|
25
|
+
TheFontList = Font
|
26
|
+
|
27
|
+
end
|