wxruby 1.9.6-x86-mingw32 → 1.9.8-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/wx/classes/auinotebook.rb +9 -0
- data/lib/wx/classes/controlwithitems.rb +1 -1
- data/lib/wx/classes/evthandler.rb +47 -4
- data/lib/wx/classes/helpcontrollerhelpprovider.rb +23 -0
- data/lib/wx/classes/helpprovider.rb +15 -0
- data/lib/wx/classes/mediactrl.rb +29 -3
- data/lib/wx/classes/notebook.rb +9 -0
- data/lib/wx/classes/object.rb +8 -1
- data/lib/wx/classes/simplehelpprovider.rb +38 -0
- data/lib/wx/classes/sizer.rb +22 -0
- data/lib/wx/classes/toolbar.rb +29 -0
- data/lib/wx/helpers.rb +30 -0
- data/lib/wx/keyword_ctors.rb +1 -20
- data/lib/wx/keyword_defs.rb +15 -0
- data/lib/wx/version.rb +1 -1
- data/lib/wx.rb +12 -1
- data/lib/wxruby2.so +0 -0
- data/samples/aui/aui.rb +1 -1
- data/samples/dragdrop/dragdrop.rb +177 -0
- data/samples/mdi/mdi.rb +35 -40
- data/samples/media/mediactrl.rb +3 -3
- data/samples/printing/printing.rb +177 -0
- metadata +217 -207
@@ -126,10 +126,11 @@ class Wx::EvtHandler
|
|
126
126
|
when Proc then meth
|
127
127
|
when Method then meth.to_proc
|
128
128
|
end
|
129
|
+
# Create an anonymous block to call the relevant method
|
129
130
|
if h_meth.arity == 1
|
130
|
-
return
|
131
|
+
return proc { | evt | h_meth.call(evt) }
|
131
132
|
else
|
132
|
-
return
|
133
|
+
return proc { h_meth.call }
|
133
134
|
end
|
134
135
|
else
|
135
136
|
Kernel.raise ArgumentError,
|
@@ -177,12 +178,18 @@ class Wx::EvtHandler
|
|
177
178
|
EventType['evt_auinotebook_begin_drag', 1,
|
178
179
|
Wx::EVT_COMMAND_AUINOTEBOOK_BEGIN_DRAG,
|
179
180
|
Wx::AuiNotebookEvent],
|
181
|
+
EventType['evt_auinotebook_bg_dclick', 1,
|
182
|
+
Wx::EVT_COMMAND_AUINOTEBOOK_BG_DCLICK,
|
183
|
+
Wx::AuiNotebookEvent],
|
180
184
|
EventType['evt_auinotebook_button', 1,
|
181
185
|
Wx::EVT_COMMAND_AUINOTEBOOK_BUTTON,
|
182
186
|
Wx::AuiNotebookEvent],
|
183
187
|
EventType['evt_auinotebook_drag_motion', 1,
|
184
188
|
Wx::EVT_COMMAND_AUINOTEBOOK_DRAG_MOTION,
|
185
189
|
Wx::AuiNotebookEvent],
|
190
|
+
EventType['evt_auinotebook_drag_done', 1,
|
191
|
+
Wx::EVT_COMMAND_AUINOTEBOOK_DRAG_DONE,
|
192
|
+
Wx::AuiNotebookEvent],
|
186
193
|
EventType['evt_auinotebook_end_drag', 1,
|
187
194
|
Wx::EVT_COMMAND_AUINOTEBOOK_END_DRAG,
|
188
195
|
Wx::AuiNotebookEvent],
|
@@ -195,6 +202,21 @@ class Wx::EvtHandler
|
|
195
202
|
EventType['evt_auinotebook_page_close', 1,
|
196
203
|
Wx::EVT_COMMAND_AUINOTEBOOK_PAGE_CLOSE,
|
197
204
|
Wx::AuiNotebookEvent],
|
205
|
+
EventType['evt_auinotebook_page_closed', 1,
|
206
|
+
Wx::EVT_COMMAND_AUINOTEBOOK_PAGE_CLOSED,
|
207
|
+
Wx::AuiNotebookEvent],
|
208
|
+
EventType['evt_auinotebook_tab_middle_down', 1,
|
209
|
+
Wx::EVT_COMMAND_AUINOTEBOOK_TAB_MIDDLE_DOWN,
|
210
|
+
Wx::AuiNotebookEvent],
|
211
|
+
EventType['evt_auinotebook_tab_middle_up', 1,
|
212
|
+
Wx::EVT_COMMAND_AUINOTEBOOK_TAB_MIDDLE_UP,
|
213
|
+
Wx::AuiNotebookEvent],
|
214
|
+
EventType['evt_auinotebook_tab_right_down', 1,
|
215
|
+
Wx::EVT_COMMAND_AUINOTEBOOK_TAB_RIGHT_DOWN,
|
216
|
+
Wx::AuiNotebookEvent],
|
217
|
+
EventType['evt_auinotebook_tab_right_up', 1,
|
218
|
+
Wx::EVT_COMMAND_AUINOTEBOOK_TAB_RIGHT_UP,
|
219
|
+
Wx::AuiNotebookEvent],
|
198
220
|
EventType['evt_aui_find_manager', 0,
|
199
221
|
Wx::EVT_AUI_FIND_MANAGER,
|
200
222
|
Wx::AuiManagerEvent],
|
@@ -294,6 +316,12 @@ class Wx::EvtHandler
|
|
294
316
|
EventType['evt_drop_files', 0,
|
295
317
|
Wx::EVT_DROP_FILES,
|
296
318
|
Wx::Event],
|
319
|
+
EventType['evt_detailed_help', 1,
|
320
|
+
Wx::EVT_DETAILED_HELP,
|
321
|
+
Wx::HelpEvent],
|
322
|
+
EventType['evt_detailed_help_range', 2,
|
323
|
+
Wx::EVT_DETAILED_HELP,
|
324
|
+
Wx::HelpEvent],
|
297
325
|
EventType['evt_end_process', 1,
|
298
326
|
Wx::EVT_END_PROCESS,
|
299
327
|
Wx::Event],
|
@@ -419,10 +447,13 @@ class Wx::EvtHandler
|
|
419
447
|
Wx::GridEvent],
|
420
448
|
EventType['evt_help', 1,
|
421
449
|
Wx::EVT_HELP,
|
422
|
-
Wx::
|
450
|
+
Wx::HelpEvent],
|
423
451
|
EventType['evt_help_range', 2,
|
424
452
|
Wx::EVT_HELP,
|
425
|
-
Wx::
|
453
|
+
Wx::HelpEvent],
|
454
|
+
EventType['evt_hibernate', 2,
|
455
|
+
Wx::EVT_HIBERNATE,
|
456
|
+
Wx::ActivateEvent],
|
426
457
|
EventType['evt_html_cell_clicked', 1,
|
427
458
|
Wx::EVT_COMMAND_HTML_CELL_CLICKED,
|
428
459
|
Wx::HtmlCellEvent],
|
@@ -762,12 +793,21 @@ class Wx::EvtHandler
|
|
762
793
|
EventType['evt_text', 1,
|
763
794
|
Wx::EVT_COMMAND_TEXT_UPDATED,
|
764
795
|
Wx::CommandEvent],
|
796
|
+
EventType['evt_text_copy', 1,
|
797
|
+
Wx::EVT_COMMAND_TEXT_COPY,
|
798
|
+
Wx::ClipboardTextEvent],
|
799
|
+
EventType['evt_text_cut', 1,
|
800
|
+
Wx::EVT_COMMAND_TEXT_CUT,
|
801
|
+
Wx::ClipboardTextEvent],
|
765
802
|
EventType['evt_text_enter', 1,
|
766
803
|
Wx::EVT_COMMAND_TEXT_ENTER,
|
767
804
|
Wx::CommandEvent],
|
768
805
|
EventType['evt_text_maxlen', 1,
|
769
806
|
Wx::EVT_COMMAND_TEXT_MAXLEN,
|
770
807
|
Wx::CommandEvent],
|
808
|
+
EventType['evt_text_paste', 1,
|
809
|
+
Wx::EVT_COMMAND_TEXT_PASTE,
|
810
|
+
Wx::ClipboardTextEvent],
|
771
811
|
EventType['evt_text_url', 1,
|
772
812
|
Wx::EVT_COMMAND_TEXT_URL,
|
773
813
|
Wx::TextUrlEvent],
|
@@ -852,6 +892,9 @@ class Wx::EvtHandler
|
|
852
892
|
EventType['evt_tree_set_info', 1,
|
853
893
|
Wx::EVT_COMMAND_TREE_SET_INFO,
|
854
894
|
Wx::TreeEvent],
|
895
|
+
EventType['evt_tree_state_image_click', 1,
|
896
|
+
Wx::EVT_COMMAND_TREE_STATE_IMAGE_CLICK,
|
897
|
+
Wx::TreeEvent],
|
855
898
|
EventType['evt_update_ui', 1,
|
856
899
|
Wx::EVT_UPDATE_UI,
|
857
900
|
Wx::UpdateUIEvent],
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# Pure-ruby implementation of the corresponding Wx class. Shows a
|
2
|
+
# relevant section of help, if available, or a native popup
|
3
|
+
require 'wx/classes/simplehelpprovider'
|
4
|
+
class Wx::HelpControllerHelpProvider < Wx::SimpleHelpProvider
|
5
|
+
def initialize(help_controller)
|
6
|
+
super()
|
7
|
+
@hc = help_controller
|
8
|
+
end
|
9
|
+
|
10
|
+
# Show help for +win+; if the help text for +win+ is a string with a
|
11
|
+
# single integer only, treats that as a section id for help and shows
|
12
|
+
# that, otherwise shows a popup (native-style on Windows) of the text.
|
13
|
+
def show_help(win)
|
14
|
+
help_text = get_help(win)
|
15
|
+
return false if help_text.empty?
|
16
|
+
if help_text =~ /\A\d+\z/
|
17
|
+
@hc.display_context_popup(help_text.to_i)
|
18
|
+
else
|
19
|
+
@hc.display_text_popup(help_text, Wx::get_mouse_position)
|
20
|
+
end
|
21
|
+
true
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# Base class for providing context-sensitive help. The main definition
|
2
|
+
# is in SWIG/C++
|
3
|
+
class Wx::HelpProvider
|
4
|
+
class << self
|
5
|
+
# We need to protect the currently set HelpProvider from GC as it is a
|
6
|
+
# SWIG Director; it can't be reaped and re-wrapped later. The
|
7
|
+
# easiest way is to make the currently set one an instance variable
|
8
|
+
# of this class
|
9
|
+
alias :__wx_set :set
|
10
|
+
define_method(:set) do | help_provider |
|
11
|
+
__wx_set(help_provider)
|
12
|
+
@__hp__ = help_provider
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/wx/classes/mediactrl.rb
CHANGED
@@ -9,14 +9,40 @@ if defined?(Wx::MediaCtrl)
|
|
9
9
|
evt_type['evt_media_finished', 1,
|
10
10
|
Wx::EVT_MEDIA_FINISHED,
|
11
11
|
Wx::MediaEvent],
|
12
|
-
evt_type['evt_media_stop', 1,
|
13
|
-
Wx::EVT_MEDIA_STOP,
|
14
|
-
Wx::MediaEvent],
|
15
12
|
evt_type['evt_media_loaded', 1,
|
16
13
|
Wx::EVT_MEDIA_LOADED,
|
14
|
+
Wx::MediaEvent],
|
15
|
+
evt_type['evt_media_pause', 1,
|
16
|
+
Wx::EVT_MEDIA_PAUSE,
|
17
|
+
Wx::MediaEvent],
|
18
|
+
evt_type['evt_media_play', 1,
|
19
|
+
Wx::EVT_MEDIA_PLAY,
|
20
|
+
Wx::MediaEvent],
|
21
|
+
evt_type['evt_media_statechanged', 1,
|
22
|
+
Wx::EVT_MEDIA_STATECHANGED,
|
23
|
+
Wx::MediaEvent],
|
24
|
+
evt_type['evt_media_stop', 1,
|
25
|
+
Wx::EVT_MEDIA_STOP,
|
17
26
|
Wx::MediaEvent]
|
18
27
|
]
|
19
28
|
mediactrl_event_types.each do | ev_type |
|
20
29
|
Wx::EvtHandler.register_event_type(ev_type)
|
21
30
|
end
|
31
|
+
|
32
|
+
# Extend with a nicer interface to get_state
|
33
|
+
class Wx::MediaCtrl
|
34
|
+
# Returns true if the media is currently paused, else false
|
35
|
+
def is_paused
|
36
|
+
get_state == Wx::MEDIASTATE_PAUSED
|
37
|
+
end
|
38
|
+
# Returns true if the media is currently playing, else false
|
39
|
+
def is_playing
|
40
|
+
get_state == Wx::MEDIASTATE_PLAYING
|
41
|
+
end
|
42
|
+
# Returns true if the media is currently stopped, else false
|
43
|
+
def is_stopped
|
44
|
+
get_state == Wx::MEDIASTATE_STOPPED
|
45
|
+
end
|
46
|
+
end
|
22
47
|
end
|
48
|
+
|
data/lib/wx/classes/object.rb
CHANGED
@@ -1,7 +1,14 @@
|
|
1
1
|
# The root class for most (not all) WxRuby classes
|
2
2
|
class Wx::Object
|
3
|
-
#
|
3
|
+
# Massage the output of inspect to show the public module name (Wx),
|
4
|
+
# instead of the internal name (Wxruby2)
|
4
5
|
def to_s
|
5
6
|
super.sub('ruby2', '')
|
6
7
|
end
|
8
|
+
|
9
|
+
# Returns a string containing the C++ pointer address of this
|
10
|
+
# object. Only useful for debugging.
|
11
|
+
def ptr_addr
|
12
|
+
Wx::ptr_addr(self)
|
13
|
+
end
|
7
14
|
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# Pure-ruby implementation of the corresponding Wx class. Simply shows
|
2
|
+
# the Window's help text in a tooltip.
|
3
|
+
class Wx::SimpleHelpProvider < Wx::HelpProvider
|
4
|
+
def initialize
|
5
|
+
super
|
6
|
+
# Store for mapping windows -> help strings
|
7
|
+
@help_wins = {}
|
8
|
+
# Store for mapping ids -> help strings
|
9
|
+
@help_ids = {}
|
10
|
+
end
|
11
|
+
|
12
|
+
# This is what is called by Wx::Window#set_help_text
|
13
|
+
def add_help(identifier, text)
|
14
|
+
if identifier.kind_of? Wx::Window
|
15
|
+
@help_wins[identifier.object_id] = text
|
16
|
+
else
|
17
|
+
@help_ids[identifier] = text
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# Retrieve help text for the given window +win+
|
22
|
+
def get_help(win)
|
23
|
+
@help_wins[win.object_id] || @help_ids[win.wx_id] || ""
|
24
|
+
end
|
25
|
+
|
26
|
+
# Remove the help text for +win+
|
27
|
+
def remove_help(win)
|
28
|
+
@help_wins.delete(win.object_id)
|
29
|
+
end
|
30
|
+
|
31
|
+
# Show help for +win+
|
32
|
+
def show_help(win)
|
33
|
+
help_text = get_help(win)
|
34
|
+
return false if help_text.empty?
|
35
|
+
tip = Wx::TipWindow.new(win, help_text, 100)
|
36
|
+
true
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# Class for automatically managing layouts
|
2
|
+
class Wx::Sizer
|
3
|
+
# Generic method to add items, supporting positional and named
|
4
|
+
# arguments
|
5
|
+
ADD_ITEM_PARAMS = [ Wx::Parameter[ :index, -1 ],
|
6
|
+
Wx::Parameter[ :proportion, 0 ],
|
7
|
+
Wx::Parameter[ :flag, 0 ],
|
8
|
+
Wx::Parameter[ :border, 0 ],
|
9
|
+
Wx::Parameter[ :user_data, nil ] ]
|
10
|
+
|
11
|
+
def add_item(item, *mixed_args)
|
12
|
+
args = Wx::args_as_list(ADD_ITEM_PARAMS, *mixed_args)
|
13
|
+
|
14
|
+
# Call add to append if default position
|
15
|
+
idx = args.shift
|
16
|
+
if idx == -1
|
17
|
+
add(item, *args)
|
18
|
+
else
|
19
|
+
insert(idx, item, *args)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# A set of buttons and controls attached to one edge of a Wx::Frame
|
2
|
+
class Wx::ToolBar
|
3
|
+
# Generic method to add items, supporting positional and named
|
4
|
+
# arguments
|
5
|
+
ADD_ITEM_PARAMS = [ Wx::Parameter[ :position, -1 ],
|
6
|
+
Wx::Parameter[ :id, -1 ],
|
7
|
+
Wx::Parameter[ :label, "" ],
|
8
|
+
Wx::Parameter[ :bitmap, Wx::NULL_BITMAP ],
|
9
|
+
Wx::Parameter[ :bitmap2, Wx::NULL_BITMAP ],
|
10
|
+
Wx::Parameter[ :kind, Wx::ITEM_NORMAL ],
|
11
|
+
Wx::Parameter[ :short_help, "" ],
|
12
|
+
Wx::Parameter[ :long_help, "" ],
|
13
|
+
Wx::Parameter[ :client_data, nil ] ]
|
14
|
+
|
15
|
+
def add_item(*mixed_args)
|
16
|
+
args = Wx::args_as_list(ADD_ITEM_PARAMS, *mixed_args)
|
17
|
+
if args[3] == Wx::NULL_BITMAP
|
18
|
+
Kernel.raise ArgumentError, "Main button bitmap may not be NULL"
|
19
|
+
end
|
20
|
+
|
21
|
+
# Call add_tool to append if default position
|
22
|
+
pos = args.shift
|
23
|
+
if pos == -1
|
24
|
+
add_tool(*args)
|
25
|
+
else
|
26
|
+
insert_tool(pos, *args)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/wx/helpers.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
# Various non-GUI helper functions
|
2
|
+
module Wx
|
3
|
+
# A named parameter in a Wx named-arg parameter list
|
4
|
+
Parameter = Struct.new( :name, :default )
|
5
|
+
|
6
|
+
# Convert mixed positional / named args into a list to be passed to
|
7
|
+
# an underlying API method. +param_spec+ is an Array of Parameter
|
8
|
+
# structs containing the keyword name and default value for each
|
9
|
+
# possible argument. +mixed_args+ is an array which may optionally end
|
10
|
+
# with a set of named arguments
|
11
|
+
|
12
|
+
def self.args_as_list(param_spec, *mixed_args)
|
13
|
+
# get keyword arguments from mixed args if supplied, else empty
|
14
|
+
kwa = mixed_args.last.kind_of?(Hash) ? mixed_args.pop : {}
|
15
|
+
out_args = []
|
16
|
+
param_spec.each_with_index do | param, i |
|
17
|
+
if arg = mixed_args[i] # use the supplied list arg
|
18
|
+
out_args << arg
|
19
|
+
elsif kwa.key?(param.name) # use the keyword arg
|
20
|
+
out_args << kwa[param.name]
|
21
|
+
else # use the default argument
|
22
|
+
out_args << param.default
|
23
|
+
end
|
24
|
+
end
|
25
|
+
out_args
|
26
|
+
rescue
|
27
|
+
Kernel.raise ArgumentError,
|
28
|
+
"Bad arg composition of #{mixed_args.inspect}"
|
29
|
+
end
|
30
|
+
end
|
data/lib/wx/keyword_ctors.rb
CHANGED
@@ -106,10 +106,6 @@ module Wx
|
|
106
106
|
:choices => [] # for Choice, ComboBox etc
|
107
107
|
}
|
108
108
|
|
109
|
-
|
110
|
-
# A named parameter in a Wx constructor parameter list
|
111
|
-
Parameter = Struct.new( :name, :default )
|
112
|
-
|
113
109
|
attr_writer :param_spec
|
114
110
|
def param_spec
|
115
111
|
@param_spec ||= []
|
@@ -132,22 +128,7 @@ module Wx
|
|
132
128
|
end
|
133
129
|
|
134
130
|
def args_as_list(*mixed_args)
|
135
|
-
|
136
|
-
kwa = mixed_args.last.kind_of?(Hash) ? mixed_args.pop : {}
|
137
|
-
out_args = []
|
138
|
-
param_spec.each_with_index do | param, i |
|
139
|
-
if arg = mixed_args[i] # use the supplied list arg
|
140
|
-
out_args << arg
|
141
|
-
elsif kwa.key?(param.name) # use the keyword arg
|
142
|
-
out_args << kwa[param.name]
|
143
|
-
else # use the default argument
|
144
|
-
out_args << param.default
|
145
|
-
end
|
146
|
-
end
|
147
|
-
out_args
|
148
|
-
rescue
|
149
|
-
Kernel.raise ArgumentError,
|
150
|
-
"Bad arg composition of #{mixed_args.inspect}"
|
131
|
+
Wx::args_as_list(param_spec, *mixed_args)
|
151
132
|
end
|
152
133
|
|
153
134
|
def args_as_hash(*mixed_args)
|
data/lib/wx/keyword_defs.rb
CHANGED
@@ -141,6 +141,21 @@ Wx::define_keyword_ctors('ToolBar') do
|
|
141
141
|
wx_ctor_params :name => 'toolBar' # not as documented in Wx 2.6.3
|
142
142
|
end
|
143
143
|
|
144
|
+
# ToolBarTool class
|
145
|
+
Wx::define_keyword_ctors('ToolBarTool') do
|
146
|
+
# By default we want Wx to generate an id for us, thus it doesn't
|
147
|
+
# respect the wxWidgets default constructor value which is
|
148
|
+
# ID_SEPARATOR
|
149
|
+
wx_ctor_params :id => Wx::ID_ANY
|
150
|
+
wx_ctor_params :label => ''
|
151
|
+
wx_ctor_params :bitmap
|
152
|
+
wx_ctor_params :disabled_bitmap => Wx::NULL_BITMAP
|
153
|
+
wx_ctor_params :kind => Wx::ITEM_NORMAL
|
154
|
+
wx_ctor_params :data => nil
|
155
|
+
wx_ctor_params :short_help => ''
|
156
|
+
wx_ctor_params :long_help => ''
|
157
|
+
end
|
158
|
+
|
144
159
|
# Notebook class
|
145
160
|
Wx::define_keyword_ctors('Notebook') do
|
146
161
|
wx_ctor_params :id, :pos, :size, :style, :name => 'noteBook'
|
data/lib/wx/version.rb
CHANGED
data/lib/wx.rb
CHANGED
@@ -25,6 +25,8 @@ Wx::WXWIDGETS_VERSION = '%i.%i.%i' % [ Wx::WXWIDGETS_MAJOR_VERSION,
|
|
25
25
|
Wx::WXWIDGETS_MINOR_VERSION,
|
26
26
|
Wx::WXWIDGETS_RELEASE_NUMBER ]
|
27
27
|
|
28
|
+
# Helper functions
|
29
|
+
require 'wx/helpers'
|
28
30
|
|
29
31
|
# Load in all the class extension methods written in ruby
|
30
32
|
# evthandler must be required first b/c it sets up methods modified elsewhere
|
@@ -34,9 +36,18 @@ Dir.glob(class_files) do | class_file |
|
|
34
36
|
require 'wx/classes/' + class_file[/\w+\.rb$/]
|
35
37
|
end
|
36
38
|
|
37
|
-
# Load in syntax
|
39
|
+
# Load in syntax sweeteners
|
38
40
|
require 'wx/accessors'
|
39
41
|
require 'wx/keyword_ctors'
|
40
42
|
require 'wx/keyword_defs'
|
41
43
|
|
44
|
+
# If a program is ended by ruby's exit, it can bypass doing the proper
|
45
|
+
# Wx clean-up routines called by Wx::App#on_exit. This can under some
|
46
|
+
# circumstances cause crashes as the application ends.
|
47
|
+
Kernel::at_exit do
|
48
|
+
# This is set in wxRubyApp.OnExit (see swig/classes/App.i)
|
49
|
+
if not $__wx_app_ended__
|
50
|
+
Wx::THE_APP.on_exit
|
51
|
+
end
|
52
|
+
end
|
42
53
|
|
data/lib/wxruby2.so
CHANGED
Binary file
|
data/samples/aui/aui.rb
CHANGED
@@ -994,7 +994,7 @@ class AuiFrame < Wx::Frame
|
|
994
994
|
event.check((@notebook_style & Wx::AUI_NB_CLOSE_ON_ALL_TABS) != 0)
|
995
995
|
when ID_NotebookCloseButtonActive
|
996
996
|
event.check((@notebook_style & Wx::AUI_NB_CLOSE_ON_ACTIVE_TAB) != 0)
|
997
|
-
when ID_NotebookAllowTabSplit
|
997
|
+
when ID_NotebookAllowTabSplit
|
998
998
|
event.check((@notebook_style & Wx::AUI_NB_TAB_SPLIT) != 0)
|
999
999
|
when ID_NotebookAllowTabMove
|
1000
1000
|
event.check((@notebook_style & Wx::AUI_NB_TAB_MOVE) != 0)
|
@@ -0,0 +1,177 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# wxRuby2 Sample Code. Copyright (c) 2004-2008 wxRuby development team
|
3
|
+
# Freely reusable code: see SAMPLES-LICENSE.TXT for details
|
4
|
+
begin
|
5
|
+
require 'rubygems'
|
6
|
+
rescue LoadError
|
7
|
+
end
|
8
|
+
require 'wx'
|
9
|
+
|
10
|
+
# This sample demonstrates the use of the Clipboard and Drag and Drop
|
11
|
+
# classes. Whilst the functionality of these is slightly different, they
|
12
|
+
# are both based around the use of the DataObject classes to exchange
|
13
|
+
# data of various sorts between applications (i.e. into and out of
|
14
|
+
# wxRuby)
|
15
|
+
|
16
|
+
# A ListBox that collects file names dropped onto it
|
17
|
+
class FileDropList < Wx::ListBox
|
18
|
+
def initialize(*args)
|
19
|
+
super
|
20
|
+
# Set the handler for drag and drop actions
|
21
|
+
self.drop_target = ListFileDropTarget.new(self)
|
22
|
+
end
|
23
|
+
|
24
|
+
# The class that actually handles the dropped files; it keeps a
|
25
|
+
# reference to the ListBox, and appends items as they are added
|
26
|
+
class ListFileDropTarget < Wx::FileDropTarget
|
27
|
+
def initialize(list)
|
28
|
+
super()
|
29
|
+
@list = list
|
30
|
+
end
|
31
|
+
|
32
|
+
# This method is overridden to specify what happens when a file is
|
33
|
+
# dropped
|
34
|
+
def on_drop_files(x, y, files)
|
35
|
+
files.each { | file | @list.append(file) }
|
36
|
+
true # currently need to return boolean from this method
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
class FileDropPane < Wx::Panel
|
42
|
+
LABEL = "Drag and drop files from Explorer/Finder/etc to here\n" +
|
43
|
+
"to add them to the list."
|
44
|
+
def initialize(parent)
|
45
|
+
super
|
46
|
+
sizer = Wx::BoxSizer.new(Wx::VERTICAL)
|
47
|
+
txt = Wx::StaticText.new( self, :label => LABEL)
|
48
|
+
sizer.add(txt, 0, Wx::ALL, 4)
|
49
|
+
|
50
|
+
@drop = FileDropList.new(self)
|
51
|
+
sizer.add(@drop, 1, Wx::GROW|Wx::ALL, 4)
|
52
|
+
self.sizer = sizer
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
# A canvas which can display a pasted image
|
57
|
+
class PasteCanvas < Wx::Window
|
58
|
+
attr_accessor :bitmap
|
59
|
+
def initialize(parent)
|
60
|
+
super(parent, :style => Wx::SUNKEN_BORDER)
|
61
|
+
self.size = [ 200, 200 ]
|
62
|
+
@bitmap = Wx::NULL_BITMAP
|
63
|
+
evt_paint :on_paint
|
64
|
+
end
|
65
|
+
|
66
|
+
def on_paint(evt)
|
67
|
+
paint do | dc |
|
68
|
+
dc.clear
|
69
|
+
if bitmap.ok?
|
70
|
+
dc.draw_bitmap(bitmap, 0, 0, false)
|
71
|
+
end
|
72
|
+
dc.pen = Wx::BLACK_PEN
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
# A Notebook panel to hold an image-paste canvas
|
78
|
+
class PastePane < Wx::Panel
|
79
|
+
LABEL = "Use the buttons below to paste text and images from\n" +
|
80
|
+
"the system clipboard, and then to copy them back."
|
81
|
+
def initialize(parent)
|
82
|
+
super
|
83
|
+
sizer = Wx::BoxSizer.new(Wx::VERTICAL)
|
84
|
+
txt = Wx::StaticText.new( self, :label => LABEL)
|
85
|
+
sizer.add(txt, 0, Wx::ALL, 4)
|
86
|
+
|
87
|
+
# Sizer for displaying text and image from the clipboard
|
88
|
+
paste_sizer = Wx::FlexGridSizer.new(2, 2, 2, 2)
|
89
|
+
paste_sizer.add_growable_col(0, 1)
|
90
|
+
paste_sizer.add_growable_col(1, 1)
|
91
|
+
paste_sizer.add_growable_row(1)
|
92
|
+
|
93
|
+
paste_sizer.add( Wx::StaticText.new(self, :label => 'Clipboard text') )
|
94
|
+
paste_sizer.add( Wx::StaticText.new(self, :label => 'Clipboard image') )
|
95
|
+
|
96
|
+
# Target for displaying text from the clipboard
|
97
|
+
@text = Wx::TextCtrl.new(self, :style => Wx::TE_MULTILINE)
|
98
|
+
paste_sizer.add(@text, 1, Wx::GROW)
|
99
|
+
|
100
|
+
# Target for displaying images from the clipboard
|
101
|
+
@canvas = PasteCanvas.new(self)
|
102
|
+
paste_sizer.add(@canvas, 1, Wx::GROW)
|
103
|
+
|
104
|
+
sizer.add(paste_sizer, 1, Wx::ALL|Wx::GROW, 4)
|
105
|
+
|
106
|
+
button_sizer = Wx::BoxSizer.new(Wx::HORIZONTAL)
|
107
|
+
|
108
|
+
@paste_bt = Wx::Button.new(self, :label => 'Paste')
|
109
|
+
evt_button @paste_bt, :on_paste
|
110
|
+
button_sizer.add(@paste_bt, 0, Wx::ALL, 4)
|
111
|
+
|
112
|
+
@copy_img_bt = Wx::Button.new(self, :label => 'Copy image')
|
113
|
+
evt_button @copy_img_bt, :on_copy_image
|
114
|
+
button_sizer.add(@copy_img_bt, 0, Wx::ALL, 4)
|
115
|
+
|
116
|
+
@copy_txt_bt = Wx::Button.new(self, :label => 'Copy text')
|
117
|
+
evt_button @copy_txt_bt, :on_copy_text
|
118
|
+
button_sizer.add(@copy_txt_bt, 0, Wx::ALL, 4)
|
119
|
+
|
120
|
+
sizer.add(button_sizer, 0)
|
121
|
+
self.sizer = sizer
|
122
|
+
end
|
123
|
+
|
124
|
+
# Receive data from the clipboard
|
125
|
+
def on_paste(evt)
|
126
|
+
# Temporarily open the clipboard
|
127
|
+
Wx::Clipboard.open do | clip |
|
128
|
+
# Test if bitmap data is available on the clipboard; if so, copy
|
129
|
+
if clip.supported?(Wx::DF_BITMAP)
|
130
|
+
bmp = Wx::BitmapDataObject.new
|
131
|
+
clip.get_data(bmp) # Fill the data object with bitmap`
|
132
|
+
@canvas.bitmap = bmp.bitmap
|
133
|
+
@canvas.refresh
|
134
|
+
end
|
135
|
+
# Test if text data is available on the clipboard; if so, copy
|
136
|
+
if clip.supported?(Wx::DF_TEXT)
|
137
|
+
txt = Wx::TextDataObject.new
|
138
|
+
clip.get_data(txt) # Fill the data object with text
|
139
|
+
@text.value = txt.text
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
# Paste an image to the clipboard
|
145
|
+
def on_copy_image
|
146
|
+
Wx::Clipboard.open do | clip |
|
147
|
+
clip.data = Wx::BitmapDataObject.new(@canvas.bitmap)
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
# Paste text to the clipboard
|
152
|
+
def on_copy_text
|
153
|
+
Wx::Clipboard.open do | clip |
|
154
|
+
clip.data = Wx::TextDataObject.new(@text.value)
|
155
|
+
end
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
class DataObjectFrame < Wx::Frame
|
160
|
+
def initialize(parent)
|
161
|
+
super
|
162
|
+
panel = Wx::Panel.new(self)
|
163
|
+
panel.sizer = Wx::BoxSizer.new(Wx::VERTICAL)
|
164
|
+
nb = Wx::Notebook.new(panel)
|
165
|
+
panel.sizer.add(nb, 1, Wx::ALL|Wx::GROW, 8)
|
166
|
+
fd = FileDropPane.new(nb)
|
167
|
+
nb.add_page(fd, 'Drag and Drop')
|
168
|
+
cv = PastePane.new(nb)
|
169
|
+
nb.add_page(cv, 'Clipboard')
|
170
|
+
# urldrop = URLDropList.new(self)
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
Wx::App.run do
|
175
|
+
frame = DataObjectFrame.new(nil)
|
176
|
+
frame.show
|
177
|
+
end
|