wxruby 1.9.7-x86-linux → 1.9.8-x86-linux

Sign up to get free protection for your applications and to get access to all the features.
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 sweetner
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
 
@@ -0,0 +1,9 @@
1
+ # Advanced User Interface Notebook - draggable panes etc
2
+ class Wx::AuiNotebook
3
+ # Convenience method for iterating pages
4
+ def each_page
5
+ 0.upto(get_page_count - 1) do | i |
6
+ yield get_page(i)
7
+ end
8
+ end
9
+ end
@@ -5,6 +5,6 @@ class Wx::ControlWithItems
5
5
  include Enumerable
6
6
  # Passes each valid item index into the passed block
7
7
  def each
8
- 0.upto(count - 1) { | i | yield i }
8
+ 0.upto(get_count - 1) { | i | yield i }
9
9
  end
10
10
  end
@@ -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 lambda { | evt | h_meth.call(evt) }
131
+ return proc { | evt | h_meth.call(evt) }
131
132
  else
132
- return lambda { h_meth.call }
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::Event],
450
+ Wx::HelpEvent],
423
451
  EventType['evt_help_range', 2,
424
452
  Wx::EVT_HELP,
425
- Wx::Event],
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
@@ -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
+
@@ -0,0 +1,9 @@
1
+ # Displays a set of pages in parallel using tabs
2
+ class Wx::Notebook
3
+ # Convenience method for iterating pages
4
+ def each_page
5
+ 0.upto(get_page_count - 1) do | i |
6
+ yield get_page(i)
7
+ end
8
+ end
9
+ end
@@ -1,7 +1,14 @@
1
1
  # The root class for most (not all) WxRuby classes
2
2
  class Wx::Object
3
- # massage the output of inspect to show the public module name (Wx)
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
@@ -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
@@ -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
- # get keyword arguments from mixed args if supplied, else empty
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)
@@ -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'