wxruby 1.9.2-i386-mswin32 → 1.9.3-i386-mswin32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (149) hide show
  1. data/LICENSE +53 -53
  2. data/README +299 -299
  3. data/lib/wx/classes/app.rb +6 -0
  4. data/lib/wx/classes/checklistbox.rb +45 -30
  5. data/lib/wx/classes/clipboard.rb +16 -0
  6. data/lib/wx/classes/event.rb +5 -0
  7. data/lib/wx/classes/evthandler.rb +20 -10
  8. data/lib/wx/classes/grid.rb +38 -39
  9. data/lib/wx/classes/listctrl.rb +12 -0
  10. data/lib/wx/classes/mediactrl.rb +22 -0
  11. data/lib/wx/classes/menu.rb +6 -6
  12. data/lib/wx/classes/sound.rb +23 -0
  13. data/lib/wx/classes/styledtextctrl.rb +2 -2
  14. data/lib/wx/classes/treectrl.rb +26 -0
  15. data/lib/wx/keyword_ctors.rb +19 -5
  16. data/lib/wx/keyword_defs.rb +20 -0
  17. data/lib/wx/version.rb +1 -1
  18. data/lib/wx.rb +42 -42
  19. data/lib/wxruby2.exp +0 -0
  20. data/lib/wxruby2.lib +0 -0
  21. data/lib/wxruby2.so +0 -0
  22. data/samples/SAMPLES-LICENSE.TXT +17 -17
  23. data/samples/aui/aui.rb +8 -1
  24. data/samples/bigdemo/About.rbw +39 -39
  25. data/samples/bigdemo/ColorPanel.rbw +25 -25
  26. data/samples/bigdemo/GridSimple.rbw +80 -80
  27. data/samples/bigdemo/MDIDemo.rbw +59 -59
  28. data/samples/bigdemo/PopupMenu.rbw +151 -151
  29. data/samples/bigdemo/Sizers.rbw +545 -545
  30. data/samples/bigdemo/bigdemo.rb +826 -826
  31. data/samples/bigdemo/demoTemplate.rbw +37 -37
  32. data/samples/bigdemo/icons/choice.xpm +27 -27
  33. data/samples/bigdemo/icons/combo.xpm +27 -27
  34. data/samples/bigdemo/icons/copy.xpm +25 -25
  35. data/samples/bigdemo/icons/cut.xpm +24 -24
  36. data/samples/bigdemo/icons/gauge.xpm +27 -27
  37. data/samples/bigdemo/icons/help.xpm +25 -25
  38. data/samples/bigdemo/icons/list.xpm +27 -27
  39. data/samples/bigdemo/icons/mondrian.xpm +44 -44
  40. data/samples/bigdemo/icons/new.xpm +24 -24
  41. data/samples/bigdemo/icons/ogl.ico +0 -0
  42. data/samples/bigdemo/icons/ogl.xpm +45 -45
  43. data/samples/bigdemo/icons/open.xpm +26 -26
  44. data/samples/bigdemo/icons/paste.xpm +38 -38
  45. data/samples/bigdemo/icons/preview.xpm +26 -26
  46. data/samples/bigdemo/icons/print.xpm +26 -26
  47. data/samples/bigdemo/icons/radio.xpm +27 -27
  48. data/samples/bigdemo/icons/robert.xpm +415 -415
  49. data/samples/bigdemo/icons/save.xpm +25 -25
  50. data/samples/bigdemo/icons/smiles.xpm +39 -39
  51. data/samples/bigdemo/icons/smiley.xpm +42 -42
  52. data/samples/bigdemo/icons/stattext.xpm +24 -24
  53. data/samples/bigdemo/icons/test2.bmp +0 -0
  54. data/samples/bigdemo/icons/test2.xpm +79 -79
  55. data/samples/bigdemo/icons/text.xpm +27 -27
  56. data/samples/bigdemo/icons/tog1.xpm +38 -38
  57. data/samples/bigdemo/icons/tog2.xpm +38 -38
  58. data/samples/bigdemo/icons/wxwin16x16.xpm +25 -25
  59. data/samples/bigdemo/tips.txt +7 -7
  60. data/samples/bigdemo/utils.rb +11 -11
  61. data/samples/bigdemo/wxButton.rbw +66 -66
  62. data/samples/bigdemo/wxCalendarCtrl.rbw +72 -72
  63. data/samples/bigdemo/wxCheckBox.rbw +52 -52
  64. data/samples/bigdemo/wxCheckListBox.rbw +77 -77
  65. data/samples/bigdemo/wxChoice.rbw +49 -49
  66. data/samples/bigdemo/wxColourDialog.rbw +34 -34
  67. data/samples/bigdemo/wxComboBox.rbw +79 -79
  68. data/samples/bigdemo/wxDialog.rbw +92 -92
  69. data/samples/bigdemo/wxDirDialog.rbw +32 -32
  70. data/samples/bigdemo/wxFileDialog.rbw +39 -39
  71. data/samples/bigdemo/wxFileDialog_Save.rbw +38 -38
  72. data/samples/bigdemo/wxFindReplaceDialog.rbw +85 -85
  73. data/samples/bigdemo/wxFontDialog.rbw +176 -176
  74. data/samples/bigdemo/wxFrame.rbw +55 -55
  75. data/samples/bigdemo/wxGauge.rbw +73 -73
  76. data/samples/bigdemo/wxGrid.rbw +68 -68
  77. data/samples/bigdemo/wxListBox.rbw +142 -142
  78. data/samples/bigdemo/wxListCtrl_virtual.rbw +109 -109
  79. data/samples/bigdemo/wxMDIWindows.rbw +52 -52
  80. data/samples/bigdemo/wxMenu.rbw +238 -238
  81. data/samples/bigdemo/wxMessageDialog.rbw +30 -30
  82. data/samples/bigdemo/wxMultipleChoiceDialog.rbw +34 -34
  83. data/samples/bigdemo/wxNotebook.rbw +138 -138
  84. data/samples/bigdemo/wxProgressDialog.rbw +45 -45
  85. data/samples/bigdemo/wxRadioBox.rbw +74 -74
  86. data/samples/bigdemo/wxRadioButton.rbw +127 -127
  87. data/samples/bigdemo/wxSashWindow.rbw +94 -104
  88. data/samples/bigdemo/wxScrolledMessageDialog.rbw +59 -59
  89. data/samples/bigdemo/wxScrolledWindow.rbw +201 -201
  90. data/samples/bigdemo/wxSingleChoiceDialog.rbw +35 -35
  91. data/samples/bigdemo/wxSlider.rbw +44 -44
  92. data/samples/bigdemo/wxSpinButton.rbw +52 -52
  93. data/samples/bigdemo/wxSpinCtrl.rbw +53 -53
  94. data/samples/bigdemo/wxSplitterWindow.rbw +65 -65
  95. data/samples/bigdemo/wxStaticBitmap.rbw +53 -53
  96. data/samples/bigdemo/wxStaticText.rbw +57 -57
  97. data/samples/bigdemo/wxStatusBar.rbw +128 -128
  98. data/samples/bigdemo/wxTextCtrl.rbw +151 -151
  99. data/samples/bigdemo/wxTextEntryDialog.rbw +34 -34
  100. data/samples/bigdemo/wxToggleButton.rbw +51 -51
  101. data/samples/bigdemo/wxToolBar.rbw +133 -133
  102. data/samples/bigdemo/wxTreeCtrl.rbw +192 -192
  103. data/samples/calendar/calendar.rb +275 -275
  104. data/samples/caret/caret.rb +286 -286
  105. data/samples/caret/mondrian.xpm +44 -44
  106. data/samples/controls/controls.rb +1140 -1140
  107. data/samples/controls/get_item_sample.rb +87 -87
  108. data/samples/controls/icons/choice.xpm +27 -27
  109. data/samples/controls/icons/combo.xpm +27 -27
  110. data/samples/controls/icons/gauge.xpm +27 -27
  111. data/samples/controls/icons/list.xpm +27 -27
  112. data/samples/controls/icons/radio.xpm +27 -27
  113. data/samples/controls/icons/stattext.xpm +24 -24
  114. data/samples/controls/icons/text.xpm +27 -27
  115. data/samples/controls/mondrian.xpm +44 -44
  116. data/samples/dialogs/dialogs.rb +724 -724
  117. data/samples/dialogs/tips.txt +18 -18
  118. data/samples/drawing/graphics_drawing.rb +232 -0
  119. data/samples/{images → drawing}/images.rb +48 -48
  120. data/samples/{images → drawing}/paperclip.png +0 -0
  121. data/samples/etc/activation.rb +108 -108
  122. data/samples/etc/choice.rb +72 -72
  123. data/samples/etc/miniframe.rb +84 -84
  124. data/samples/etc/sash.rb +135 -135
  125. data/samples/etc/scrollwin.rb +116 -116
  126. data/samples/etc/system_settings.rb +258 -258
  127. data/samples/etc/wizard.rb +79 -79
  128. data/samples/grid/grid.rb +1 -0
  129. data/samples/listbook/listbook.rb +181 -181
  130. data/samples/listbook/listbook.xrc +370 -370
  131. data/samples/mdi/mdi.rb +87 -87
  132. data/samples/media/mediactrl.rb +173 -0
  133. data/samples/minimal/minimal.rb +85 -85
  134. data/samples/minimal/nothing.rb +21 -21
  135. data/samples/opengl/cube.rb +123 -0
  136. data/samples/sockets/SocketPackets.rb +27 -0
  137. data/samples/sockets/res/message-new.png +0 -0
  138. data/samples/sockets/res/user.png +0 -0
  139. data/samples/sockets/wxClient.rb +395 -0
  140. data/samples/sockets/wxServer.rb +422 -0
  141. data/samples/sockets/wxSocketGUI.rb +97 -0
  142. data/samples/text/textctrl.rb +124 -124
  143. data/samples/text/unicode.rb +238 -238
  144. data/samples/text/utf8.txt +14 -14
  145. data/samples/treectrl/treectrl.rb +1180 -1181
  146. data/samples/xrc/samples.xrc +46 -46
  147. data/samples/xrc/xrc_sample.rb +107 -107
  148. metadata +26 -9
  149. data/samples/images/Thumbs.db +0 -0
@@ -1,30 +1,45 @@
1
- # Display a listbox with a checkbox for each item
2
- class Wx::CheckListBox < Wx::ListBox
3
-
4
- # According to the wxWidgets documentation: "wxCheckListBox uses
5
- # client data in its implementation, and therefore this is not
6
- # available to the application."
7
- #
8
- # So, rather than crashing, raise an Exception if this is attempted
9
- def append(*args)
10
- if args.length == 2
11
- Kernel.raise "Cannot use item data with Wx::CheckListBox"
12
- else
13
- super
14
- end
15
- end
16
-
17
- # As above
18
- def insert(*args)
19
- if args.length == 3
20
- Kernel.raise "Cannot use item data with Wx::CheckListBox"
21
- else
22
- super
23
- end
24
- end
25
-
26
- # As above
27
- def set_item_data(index, data)
28
- Kernel.raise "Cannot use item data with Wx::CheckListBox"
29
- end
30
- end
1
+ # A ListBox, where each item has a checkbox next to it
2
+ class Wx::CheckListBox
3
+ # wxRuby redefinitions of core methods to add item data support (not
4
+ # available in wxWidgets). Use a private method to initialize and
5
+ # access the data, rather than in initialize(), b/c can't guarantee
6
+ # that initialize will be called (eg when loaded from XRC)
7
+ def __wx_item_data
8
+ @__wx_item_data ||= []
9
+ end
10
+ private :__wx_item_data
11
+
12
+ # Call method in ControlWithItems, then sync item data
13
+ def append(item, data = nil)
14
+ super(item)
15
+ __wx_item_data[count - 1] = data
16
+ end
17
+
18
+ # Call method in ControlWithItems, then sync item data
19
+ def clear
20
+ super
21
+ __wx_item_data.clear
22
+ end
23
+
24
+ # delete is defined in Wx::CheckListBox, so must be called in this class
25
+ wx_delete = self.instance_method(:delete)
26
+ define_method(:delete) do | n |
27
+ wx_delete.bind(self).call(n)
28
+ __wx_item_data.delete_at(n)
29
+ end
30
+
31
+ # Returns an array of indices of items that are currently checked.
32
+ def get_checked_items
33
+ find_all { | i | checked?(i) }
34
+ end
35
+
36
+ # Wholly redefined here
37
+ def get_item_data(n)
38
+ __wx_item_data[n]
39
+ end
40
+
41
+ # Wholly redefined here
42
+ def set_item_data(n, data)
43
+ __wx_item_data[n] = data
44
+ end
45
+ end
@@ -0,0 +1,16 @@
1
+ class Wx::Clipboard
2
+ class << self
3
+ # Class method to provide access to the clipboard within a ruby
4
+ # block. Tests that the clipboard could be accessed, and ensures
5
+ # that it is closed when the block is finished.
6
+ def open
7
+ clip = Wx::Clipboard.new
8
+ unless clip.open
9
+ Kernel.raise "Could not open clipboard"
10
+ end
11
+ yield clip
12
+ ensure
13
+ clip.close
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,5 @@
1
+ # Base class for all events
2
+ class Wx::Event
3
+ # Get the Wx id, not Ruby's deprecated Object#id
4
+ alias :id :get_id
5
+ end
@@ -113,9 +113,9 @@ class Wx::EvtHandler
113
113
  return block
114
114
  elsif meth and not block
115
115
  h_meth = case meth
116
- when Symbol, String : self.method(meth)
117
- when Proc : meth
118
- when Method : meth.to_proc
116
+ when Symbol, String then self.method(meth)
117
+ when Proc then meth
118
+ when Method then meth.to_proc
119
119
  end
120
120
  if h_meth.arity == 1
121
121
  return lambda { | evt | h_meth.call(evt) }
@@ -133,8 +133,8 @@ class Wx::EvtHandler
133
133
  # parameter or by calling the wx_id method of a passed Window.
134
134
  def acquire_id(window_or_id)
135
135
  case window_or_id
136
- when Fixnum : window_or_id
137
- when Wx::Window, Wx::MenuItem : window_or_id.wx_id
136
+ when Fixnum then window_or_id
137
+ when Wx::Window, Wx::MenuItem then window_or_id.wx_id
138
138
  else Kernel.raise ArgumentError,
139
139
  "Must specify Wx::Window event source or its Wx id, " +
140
140
  "not '#{window_or_id.inspect}'",
@@ -145,9 +145,13 @@ class Wx::EvtHandler
145
145
 
146
146
  # Definitions for all event types that are part by core wxRuby. Events
147
147
  # that are mapped to class Wx::Event are TODO as they are not
148
- # currently wrapped by the correct class. All StyledTextCtrl
149
- # (Scintilla) events with prefix EVT_STC are dealt with in the
150
- # separate styledtextctrl.rb file.
148
+ # currently wrapped by the correct class.
149
+
150
+ # All StyledTextCtrl (Scintilla) events with prefix EVT_STC are dealt
151
+ # with in the separate styledtextctrl.rb file.
152
+ #
153
+ # All MediaCtrl events with prefix EVT_MEDIA are dealt with in the
154
+ # separate mediactrl.rb file
151
155
  EVENT_DEFINITIONS = [
152
156
  EventType['evt_activate', 0,
153
157
  Wx::EVT_ACTIVATE,
@@ -202,7 +206,7 @@ class Wx::EvtHandler
202
206
  Wx::CommandEvent],
203
207
  EventType['evt_calculate_layout', 0,
204
208
  Wx::EVT_CALCULATE_LAYOUT,
205
- Wx::Event],
209
+ Wx::CalculateLayoutEvent],
206
210
  EventType['evt_calendar', 1,
207
211
  Wx::EVT_CALENDAR_DOUBLECLICKED,
208
212
  Wx::CalendarEvent],
@@ -589,7 +593,7 @@ class Wx::EvtHandler
589
593
  Wx::Event],
590
594
  EventType['evt_query_layout_info', 0,
591
595
  Wx::EVT_QUERY_LAYOUT_INFO,
592
- Wx::Event],
596
+ Wx::QueryLayoutInfoEvent],
593
597
  EventType['evt_radiobox', 1,
594
598
  Wx::EVT_COMMAND_RADIOBOX_SELECTED,
595
599
  Wx::CommandEvent],
@@ -662,6 +666,12 @@ class Wx::EvtHandler
662
666
  EventType['evt_scroll_top', 0,
663
667
  Wx::EVT_SCROLL_TOP,
664
668
  Wx::ScrollEvent],
669
+ EventType['evt_searchctrl_cancel_btn', 1,
670
+ Wx::EVT_COMMAND_SEARCHCTRL_CANCEL_BTN,
671
+ Wx::CommandEvent],
672
+ EventType['evt_searchctrl_search_btn', 1,
673
+ Wx::EVT_COMMAND_SEARCHCTRL_SEARCH_BTN,
674
+ Wx::CommandEvent],
665
675
  EventType['evt_set_cursor', 0,
666
676
  Wx::EVT_SET_CURSOR,
667
677
  Wx::SetCursorEvent],
@@ -13,21 +13,19 @@ class Wx::Grid
13
13
  # The code below stores Ruby redefines all methods that may
14
14
  # potentially set an Editor or Renderer, and stores a reference to
15
15
  # it in an instance variable, so they are not disposed of up when GC sweeps.
16
- wx_init = self.instance_method(:initialize)
17
- define_method(:initialize) do | *args |
18
- wx_init.bind(self).call(*args)
19
- @__default_editor = nil
20
- @__default_renderer = nil
21
-
22
- @__cell_editors = []
23
- @__cell_renderers = []
24
-
25
- @__col_renderers = []
26
- @__col_editors = []
27
- @__row_renderers = []
28
- @__row_editors = []
29
- end
30
16
 
17
+ # These all need to be set up as private methods which default to an
18
+ # array. This can't be done in initialize b/c that may not be called
19
+ # when a Grid is loaded from XRC
20
+ %w| __cell_editors __col_editors __row_editors
21
+ __cell_renderers __col_renderers __row_renderers |.each do | meth |
22
+ define_method(meth) do
23
+ instance_variable_get("@#{meth}") ||
24
+ instance_variable_set("@#{meth}", [])
25
+ end
26
+ private meth
27
+ end
28
+
31
29
  # store default editor
32
30
  wx_set_default_editor = self.instance_method(:set_default_editor)
33
31
  define_method(:set_default_editor) do | editr |
@@ -46,38 +44,39 @@ class Wx::Grid
46
44
  wx_set_cell_editor = self.instance_method(:set_cell_editor)
47
45
  define_method(:set_cell_editor) do | row, col, editr |
48
46
  wx_set_cell_editor.bind(self).call(row, col, editr)
49
- @__cell_editors[row] ||= []
50
- @__cell_editors[row][col] = editr
47
+ __cell_editors[row] ||= []
48
+ __cell_editors[row][col] = editr
51
49
  end
52
50
 
53
51
  # store cell renderer
54
52
  wx_set_cell_renderer = self.instance_method(:set_cell_renderer)
55
53
  define_method(:set_cell_renderer) do | row, col, rendr |
56
54
  wx_set_cell_renderer.bind(self).call(row, col, rendr)
57
- @__cell_renderers[row] ||= []
58
- @__cell_renderers[row][col] = rendr
55
+ __cell_renderers[row] ||= []
56
+ __cell_renderers[row][col] = rendr
59
57
  end
60
58
 
59
+ # Store an editor and/or renderer for a whole column
61
60
  wx_set_col_attr = self.instance_method(:set_col_attr)
62
61
  define_method(:set_col_attr) do | col, attr |
63
62
  wx_set_col_attr.bind(self).call(col, attr)
64
63
  if attr.has_editor
65
- @__col_editors[col] = attr.get_editor(self, 0, col)
64
+ __col_editors[col] = attr.get_editor(self, 0, col)
66
65
  end
67
66
  if attr.has_renderer
68
- @__col_renderers[col] = attr.get_renderer(self, 0, col)
67
+ __col_renderers[col] = attr.get_renderer(self, 0, col)
69
68
  end
70
69
  end
71
70
 
71
+ # Store an editor and/or renderer for a whole row
72
72
  wx_set_row_attr = self.instance_method(:set_row_attr)
73
73
  define_method(:set_row_attr) do | row, attr |
74
74
  wx_set_row_attr.bind(self).call(row, attr)
75
75
  if attr.has_editor
76
- @__row_editors[row] = attr.get_editor(self, row, 0)
76
+ __row_editors[row] = attr.get_editor(self, row, 0)
77
77
  end
78
-
79
78
  if attr.has_renderer
80
- @__row_renderers[row] = attr.get_renderer(self, row, 0)
79
+ __row_renderers[row] = attr.get_renderer(self, row, 0)
81
80
  end
82
81
  end
83
82
 
@@ -87,44 +86,44 @@ class Wx::Grid
87
86
  alias :__insert_rows :insert_rows
88
87
  def insert_rows(pos = 0, num = 1, update_labels = true)
89
88
  __insert_rows(pos, num, update_labels)
90
- num.times { @__row_editors.insert(pos, nil) }
91
- num.times { @__row_renderers.insert(pos, nil) }
92
- num.times { @__cell_editors.insert(pos, []) }
93
- num.times { @__cell_renderers.insert(pos, []) }
89
+ num.times { __row_editors.insert(pos, nil) }
90
+ num.times { __row_renderers.insert(pos, nil) }
91
+ num.times { __cell_editors.insert(pos, []) }
92
+ num.times { __cell_renderers.insert(pos, []) }
94
93
  end
95
94
 
96
95
  alias :__insert_cols :insert_cols
97
96
  def insert_cols(pos = 0, num = 1, update_labels = true)
98
97
  __insert_cols(pos, num, update_labels)
99
- num.times { @__col_editors.insert(pos, nil) }
100
- num.times { @__col_renderers.insert(pos, nil) }
98
+ num.times { __col_editors.insert(pos, nil) }
99
+ num.times { __col_renderers.insert(pos, nil) }
101
100
  num.times do
102
- @__cell_editors.map { | col | col.insert(pos, []) if col }
101
+ __cell_editors.map { | col | col.insert(pos, []) if col }
103
102
  end
104
103
  num.times do
105
- @__cell_renderers.map { | col | col.insert(pos, []) if col }
104
+ __cell_renderers.map { | col | col.insert(pos, []) if col }
106
105
  end
107
106
  end
108
107
 
109
108
  alias :__delete_rows :delete_rows
110
109
  def delete_rows(pos = 0, num = 1, update_labels = true)
111
110
  __delete_rows(pos, num, update_labels)
112
- @__row_editors.slice!(pos, num)
113
- @__row_renderers.slice!(pos, num)
114
- @__cell_editors.slice!(pos, num)
115
- @__cell_renderers.slice!(pos, num)
111
+ __row_editors.slice!(pos, num)
112
+ __row_renderers.slice!(pos, num)
113
+ __cell_editors.slice!(pos, num)
114
+ __cell_renderers.slice!(pos, num)
116
115
  end
117
116
 
118
117
  alias :__delete_cols :delete_cols
119
118
  def delete_cols(pos = 0, num = 1, update_labels = true)
120
119
  __delete_cols(pos, num, update_labels)
121
- @__col_editors.slice!(pos, num)
122
- @__col_renderers.slice!(pos, num)
120
+ __col_editors.slice!(pos, num)
121
+ __col_renderers.slice!(pos, num)
123
122
  num.times do
124
- @__cell_editors.map { | col | col.slice!(pos, num) if col }
123
+ __cell_editors.map { | col | col.slice!(pos, num) if col }
125
124
  end
126
125
  num.times do
127
- @__cell_renderers.map { | col | col.slice!(pos, num) if col }
126
+ __cell_renderers.map { | col | col.slice!(pos, num) if col }
128
127
  end
129
128
  end
130
129
  end
@@ -6,4 +6,16 @@ class Wx::ListCtrl
6
6
  def each
7
7
  0.upto(item_count - 1) { | i | yield i }
8
8
  end
9
+
10
+ # Stub version for LC_VIRTUAL controls that does nothing; may be
11
+ # overridden in subclasses.
12
+ def on_get_item_attr(i)
13
+ nil
14
+ end
15
+
16
+ # Stub version for LC_VIRTUAL|LC_REPORT controls that does nothing;
17
+ # may be overridden in subclasses.
18
+ def on_get_item_column_image(i, col)
19
+ -1
20
+ end
9
21
  end
@@ -0,0 +1,22 @@
1
+ # Functionality here must be loaded first to add custom events
2
+ require 'wx/classes/evthandler'
3
+
4
+ # These event handlers should only be defined if MediaCtrl is actually
5
+ # available; some builds may not include it
6
+ if defined?(Wx::MediaCtrl)
7
+ evt_type = Wx::EvtHandler::EventType
8
+ mediactrl_event_types = [
9
+ evt_type['evt_media_finished', 1,
10
+ Wx::EVT_MEDIA_FINISHED,
11
+ Wx::MediaEvent],
12
+ evt_type['evt_media_stop', 1,
13
+ Wx::EVT_MEDIA_STOP,
14
+ Wx::MediaEvent],
15
+ evt_type['evt_media_loaded', 1,
16
+ Wx::EVT_MEDIA_LOADED,
17
+ Wx::MediaEvent]
18
+ ]
19
+ mediactrl_event_types.each do | ev_type |
20
+ Wx::EvtHandler.register_event_type(ev_type)
21
+ end
22
+ end
@@ -23,9 +23,9 @@ class Wx::Menu
23
23
  old_meth = instance_method(meth)
24
24
  define_method(meth) do | *args |
25
25
  case args.first
26
- when Fixnum : old_meth.bind(self).call(*args)
27
- when String : old_meth.bind(self).call(Wx::ID_ANY, *args)
28
- when Wx::MenuItem : old_meth.bind(self).call(args.first)
26
+ when Fixnum then old_meth.bind(self).call(*args)
27
+ when String then old_meth.bind(self).call(Wx::ID_ANY, *args)
28
+ when Wx::MenuItem then old_meth.bind(self).call(args.first)
29
29
  end
30
30
  end
31
31
  end
@@ -46,9 +46,9 @@ class Wx::Menu
46
46
  old_meth = instance_method(meth)
47
47
  define_method(meth) do | pos, *args |
48
48
  case args.first
49
- when Fixnum : old_meth.bind(self).call(pos, *args)
50
- when String : old_meth.bind(self).call(pos, Wx::ID_ANY, *args)
51
- when Wx::MenuItem : old_meth.bind(self).call(pos, args.first)
49
+ when Fixnum then old_meth.bind(self).call(pos, *args)
50
+ when String then old_meth.bind(self).call(pos, Wx::ID_ANY, *args)
51
+ when Wx::MenuItem then old_meth.bind(self).call(pos, args.first)
52
52
  end
53
53
  end
54
54
  end
@@ -0,0 +1,23 @@
1
+ # Plays simple sounds from .wav files
2
+ class Wx::Sound
3
+ class << self
4
+ # Shortcut class method, as per the wxWidgets docs, but easier to do
5
+ # in Ruby
6
+ def play(file, flags = Wx::SOUND_ASYNC)
7
+ new(file).play(flags)
8
+ end
9
+ end
10
+
11
+ # Test if newly created Sound is valid; if not, raise an exception
12
+ # rather than failing silently.
13
+ wx_init = self.instance_method(:initialize)
14
+ define_method(:initialize) do | *args |
15
+ if not File.exist?( File.expand_path(args[0]) )
16
+ Kernel.raise(ArgumentError, "Sound file does not exist: #{args[0]}")
17
+ end
18
+ wx_init.bind(self).call(*args)
19
+ if not ok?
20
+ Kernel.raise(ArgumentError, "Error loading sound file #{args[0]}")
21
+ end
22
+ end
23
+ end
@@ -8,7 +8,7 @@ require 'wx/classes/evthandler'
8
8
  if defined?(Wx::StyledTextCtrl)
9
9
  EventType = Wx::EvtHandler::EventType
10
10
 
11
- STC_EVENT_TYPES = [
11
+ stc_event_types = [
12
12
  EventType['evt_stc_calltip_click', 1,
13
13
  Wx::EVT_STC_CALLTIP_CLICK,
14
14
  Wx::StyledTextEvent],
@@ -86,7 +86,7 @@ if defined?(Wx::StyledTextCtrl)
86
86
  Wx::StyledTextEvent]
87
87
  ]
88
88
 
89
- STC_EVENT_TYPES.each do | ev_type |
89
+ stc_event_types.each do | ev_type |
90
90
  Wx::EvtHandler.register_event_type(ev_type)
91
91
  end
92
92
  end
@@ -15,4 +15,30 @@ class Wx::TreeCtrl
15
15
  end
16
16
  kids
17
17
  end
18
+
19
+ # Returns a Wx::Rect corresponding to the edges of an individual tree
20
+ # item, including the button, identified by id. The standard wxWidgets
21
+ # API for getting the pixel location of an item is unrubyish, using an
22
+ # input/output parameter. But since the underlying get_bounding_rect
23
+ # method works, it's easier to fix the API in Ruby than adding more to
24
+ # the already-toxic swig interface TreeCtrl.i file.
25
+ def get_item_rect(tree_item_id)
26
+ rect = Wx::Rect.new
27
+ if get_bounding_rect(tree_item_id, rect, false)
28
+ return rect
29
+ else
30
+ return nil
31
+ end
32
+ end
33
+
34
+ # Returns a Wx::Rect corresponding to the edges of an individual tree
35
+ # item's text label. See above.
36
+ def get_label_rect(tree_item_id)
37
+ rect = Wx::Rect.new
38
+ if get_bounding_rect(tree_item_id, rect, true)
39
+ return rect
40
+ else
41
+ nil
42
+ end
43
+ end
18
44
  end
@@ -135,8 +135,8 @@ module Wx
135
135
  # get keyword arguments from mixed args if supplied, else empty
136
136
  kwa = mixed_args.last.kind_of?(Hash) ? mixed_args.pop : {}
137
137
  out_args = []
138
- param_spec.zip(mixed_args) do | param, arg |
139
- if arg # use the supplied list arg
138
+ param_spec.each_with_index do | param, i |
139
+ if arg = mixed_args[i] # use the supplied list arg
140
140
  out_args << arg
141
141
  elsif kwa.key?(param.name) # use the keyword arg
142
142
  out_args << kwa[param.name]
@@ -171,7 +171,10 @@ module Wx
171
171
 
172
172
  alias :pre_wx_kwctor_init :initialize
173
173
 
174
- def initialize(parent = :default_ctor, *mixed_args)
174
+ # The new definition of initialize; accepts a parent arg
175
+ # mixed_args, which may zero or more position args, optionally
176
+ # terminated with hash keyword args, and an optional block
177
+ def initialize(parent = :default_ctor, *mixed_args, &block)
175
178
  # allow zero-args ctor for use with XRC
176
179
  if parent == :default_ctor
177
180
  pre_wx_kwctor_init()
@@ -188,8 +191,19 @@ module Wx
188
191
  self.class.describe_constructor()
189
192
  Kernel.raise ArgumentError, msg
190
193
  end
191
-
192
- yield self if block_given?
194
+
195
+ # If a block was given, pass the newly created Window instance
196
+ # into it; use block
197
+ if block
198
+ if block.arity == -1 or block.arity == 0
199
+ self.instance_eval(&block)
200
+ elsif block.arity == 1
201
+ block.call(self)
202
+ else
203
+ Kernel.raise ArgumentError,
204
+ "Block to initialize accepts zero or one arg"
205
+ end
206
+ end
193
207
  end
194
208
  end
195
209
 
@@ -428,6 +428,13 @@ Wx::define_keyword_ctors('SpinButton') do
428
428
  wx_ctor_params :name => 'spinButton'
429
429
  end
430
430
 
431
+ # wxScrollBar - standalone scrollbar with arrows and thumb
432
+ Wx::define_keyword_ctors('ScrollBar') do
433
+ wx_ctor_params :id, :pos, :size, :style => Wx::SB_HORIZONTAL
434
+ wx_ctor_params :validator, :name => 'scrollBar'
435
+ end
436
+
437
+
431
438
  # wxVListBox A listbox supporting variable height rows
432
439
 
433
440
  # wxTextCtrl Single or multiline text editing control
@@ -463,3 +470,16 @@ Wx::define_keyword_ctors('CollapsiblePane') do
463
470
  wx_ctor_params :validator, :name => 'collapsiblePane'
464
471
  end
465
472
 
473
+ Wx::define_keyword_ctors('MediaCtrl') do
474
+ wx_ctor_params :id, :filename => ''
475
+ wx_ctor_params :pos, :size, :style => 0
476
+ wx_ctor_params :backend => ''
477
+ wx_ctor_params :validator, :name => 'mediaCtrl'
478
+ end
479
+
480
+ Wx::define_keyword_ctors('SearchCtrl') do
481
+ wx_ctor_params :id, :value => ''
482
+ wx_ctor_params :pos, :size, :style => 0
483
+ wx_ctor_params :validator, :name => 'searchCtrl'
484
+ end
485
+
data/lib/wx/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Wx
2
- WXRUBY_VERSION = '1.9.2'
2
+ WXRUBY_VERSION = '1.9.3'
3
3
  end
data/lib/wx.rb CHANGED
@@ -1,42 +1,42 @@
1
- # Copyright 2004-2006 by Kevin Smith
2
- # released under the MIT-style wxruby2 license
3
-
4
- # This wrapper serves three functions:
5
- # 1. It loads the binary library 'wxruby2.so' or 'wxruby.dll', while
6
- # still allowing applications to just require 'wx'.
7
- # 2. It sets up the version information
8
- # 3. It loads in ruby extensions to the core Wx classes.
9
-
10
-
11
- # load the binary library
12
- require 'wxruby2'
13
-
14
- # alias the module
15
- Wx = Wxruby2
16
-
17
- # Load the version information (should be bundled with all released versions)
18
- begin
19
- require 'wx/version'
20
- rescue LoadError
21
- Wx::WXRUBY_VERSION = '0.0.0'
22
- end
23
- # Convenience string for WxWidgets version info
24
- Wx::WXWIDGETS_VERSION = '%i.%i.%i' % [ Wx::WXWIDGETS_MAJOR_VERSION,
25
- Wx::WXWIDGETS_MINOR_VERSION,
26
- Wx::WXWIDGETS_RELEASE_NUMBER ]
27
-
28
-
29
- # Load in all the class extension methods written in ruby
30
- # evthandler must be required first b/c it sets up methods modified elsewhere
31
- require 'wx/classes/evthandler.rb'
32
- class_files = File.join( File.dirname(__FILE__), 'wx', 'classes', '*.rb')
33
- Dir.glob(class_files) do | class_file |
34
- require 'wx/classes/' + class_file[/\w+\.rb$/]
35
- end
36
-
37
- # Load in syntax sweetner
38
- require 'wx/accessors'
39
- require 'wx/keyword_ctors'
40
- require 'wx/keyword_defs'
41
-
42
-
1
+ # Copyright 2004-2006 by Kevin Smith
2
+ # released under the MIT-style wxruby2 license
3
+
4
+ # This wrapper serves three functions:
5
+ # 1. It loads the binary library 'wxruby2.so' or 'wxruby.dll', while
6
+ # still allowing applications to just require 'wx'.
7
+ # 2. It sets up the version information
8
+ # 3. It loads in ruby extensions to the core Wx classes.
9
+
10
+
11
+ # load the binary library
12
+ require 'wxruby2'
13
+
14
+ # alias the module
15
+ Wx = Wxruby2
16
+
17
+ # Load the version information (should be bundled with all released versions)
18
+ begin
19
+ require 'wx/version'
20
+ rescue LoadError
21
+ Wx::WXRUBY_VERSION = '0.0.0'
22
+ end
23
+ # Convenience string for WxWidgets version info
24
+ Wx::WXWIDGETS_VERSION = '%i.%i.%i' % [ Wx::WXWIDGETS_MAJOR_VERSION,
25
+ Wx::WXWIDGETS_MINOR_VERSION,
26
+ Wx::WXWIDGETS_RELEASE_NUMBER ]
27
+
28
+
29
+ # Load in all the class extension methods written in ruby
30
+ # evthandler must be required first b/c it sets up methods modified elsewhere
31
+ require 'wx/classes/evthandler.rb'
32
+ class_files = File.join( File.dirname(__FILE__), 'wx', 'classes', '*.rb')
33
+ Dir.glob(class_files) do | class_file |
34
+ require 'wx/classes/' + class_file[/\w+\.rb$/]
35
+ end
36
+
37
+ # Load in syntax sweetner
38
+ require 'wx/accessors'
39
+ require 'wx/keyword_ctors'
40
+ require 'wx/keyword_defs'
41
+
42
+
data/lib/wxruby2.exp ADDED
Binary file
data/lib/wxruby2.lib ADDED
Binary file
data/lib/wxruby2.so CHANGED
Binary file
@@ -1,18 +1,18 @@
1
- wxRuby2 Sample Code
2
- Copyright (c) 2004-2006 Kevin B. Smith
3
-
4
- Permission is hereby granted, free of charge, to any person obtaining
5
- a copy of this software, to deal in the Software without restriction,
6
- including without limitation the rights to use, copy, modify, merge,
7
- publish, distribute, sublicense, and/or sell copies of any portion of
8
- this Software, and to permit persons to whom the Software is furnished
9
- to do so. This copyright notice need not be retained in any derived
10
- work.
11
-
12
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
13
- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
15
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
16
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
17
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
1
+ wxRuby2 Sample Code
2
+ Copyright (c) 2004-2006 Kevin B. Smith
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining
5
+ a copy of this software, to deal in the Software without restriction,
6
+ including without limitation the rights to use, copy, modify, merge,
7
+ publish, distribute, sublicense, and/or sell copies of any portion of
8
+ this Software, and to permit persons to whom the Software is furnished
9
+ to do so. This copyright notice need not be retained in any derived
10
+ work.
11
+
12
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
13
+ OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
15
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
16
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
17
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
18
18
  SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.