wxruby 1.9.0-powerpc-darwin8.10.0 → 1.9.2-powerpc-darwin8.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. data/LICENSE +53 -0
  2. data/README +299 -0
  3. data/lib/wx.rb +7 -0
  4. data/lib/wx/accessors.rb +52 -0
  5. data/lib/wx/classes/app.rb +15 -1
  6. data/lib/wx/classes/bitmap.rb +2 -2
  7. data/lib/wx/classes/checklistbox.rb +30 -0
  8. data/lib/wx/classes/clientdc.rb +1 -1
  9. data/lib/wx/classes/commandevent.rb +7 -0
  10. data/lib/wx/classes/controlwithitems.rb +10 -0
  11. data/lib/wx/classes/evthandler.rb +99 -39
  12. data/lib/wx/classes/grid.rb +13 -13
  13. data/lib/wx/classes/listctrl.rb +9 -0
  14. data/lib/wx/classes/menu.rb +62 -0
  15. data/lib/wx/classes/menuitem.rb +7 -0
  16. data/lib/wx/classes/paintdc.rb +1 -1
  17. data/lib/wx/classes/point.rb +43 -0
  18. data/lib/wx/classes/size.rb +44 -0
  19. data/lib/wx/classes/styledtextctrl.rb +92 -0
  20. data/lib/wx/classes/textctrl.rb +14 -0
  21. data/lib/wx/classes/timer.rb +2 -2
  22. data/lib/wx/classes/treectrl.rb +18 -0
  23. data/lib/wx/classes/window.rb +13 -2
  24. data/lib/wx/keyword_ctors.rb +205 -0
  25. data/lib/wx/keyword_defs.rb +465 -0
  26. data/lib/wx/version.rb +1 -1
  27. data/lib/wxruby2.bundle +0 -0
  28. data/samples/aui/aui.rb +6 -5
  29. data/samples/bigdemo/wxListCtrl_virtual.rbw +21 -21
  30. data/samples/bigdemo/wxScrolledWindow.rbw +8 -3
  31. data/samples/calendar/calendar.rb +1 -1
  32. data/samples/caret/caret.rb +29 -39
  33. data/samples/etc/threaded.rb +81 -0
  34. data/samples/etc/wizard.rb +22 -24
  35. data/samples/event/event.rb +184 -0
  36. data/samples/html/html.rb +25 -12
  37. data/samples/listbook/listbook.rb +65 -67
  38. data/samples/minimal/minimal.rb +40 -50
  39. data/samples/minimal/mondrian.png +0 -0
  40. data/samples/minimal/nothing.rb +5 -30
  41. data/samples/text/scintilla.rb +22 -28
  42. data/samples/text/unicode.rb +1 -1
  43. data/samples/treectrl/treectrl.rb +197 -226
  44. metadata +20 -4
  45. data/samples/minimal/mondrian.xpm +0 -44
  46. data/samples/minimal/text.rb +0 -35
@@ -13,41 +13,45 @@ rescue LoadError => no_wx_err
13
13
  end
14
14
  end
15
15
 
16
- # The frame or self-contained window for this application
16
+ # This sample shows a fairly minimal Wx::App using a Frame, with a
17
+ # MenuBar and StatusBar but no controls. For the absolute minimum app,
18
+ # see nothing.rb
19
+
20
+ # A Wx::Frame is a self-contained, top-level Window that can contain
21
+ # controls, menubars, and statusbars
17
22
  class MinimalFrame < Wx::Frame
18
- def initialize(title, pos, size, style = Wx::DEFAULT_FRAME_STYLE)
19
-
20
- # A main application frame has no parent (nil)
21
- # -1 means this frame will be supplied a default id
22
- super(nil, -1, title, pos, size, style)
23
+ def initialize(title)
24
+ # The main application frame has no parent (nil)
25
+ super(nil, :title => title, :size => [ 400, 300 ])
23
26
 
24
- # Set the frame's icon - use .ico on windows, else .xpm
25
- if Wx::PLATFORM == "WXMSW"
26
- set_icon( Wx::Icon.new(local_icon_file("mondrian.ico"),
27
- Wx::BITMAP_TYPE_ICO) )
28
- else
29
- set_icon( Wx::Icon.new(local_icon_file("mondrian.xpm"),
30
- Wx::BITMAP_TYPE_XPM) )
31
- end
27
+ icon_file = File.join( File.dirname(__FILE__), "mondrian.png")
28
+ # PNG can be used on all platforms, but icon type must be specified
29
+ # to work on Windows; OS X doesn't have "Frame" icons.
30
+ self.icon = Wx::Icon.new(icon_file, Wx::BITMAP_TYPE_PNG)
32
31
 
33
- menu_file = Wx::Menu.new()
34
- menu_help = Wx::Menu.new()
35
- # Using Wx::ID_ABOUT default id means the menu item will be placed
36
- # in the correct platform-specific place
37
- menu_help.append(Wx::ID_ABOUT, "&About...\tF1", "Show about dialog")
32
+ menu_bar = Wx::MenuBar.new
33
+ # The "file" menu
34
+ menu_file = Wx::Menu.new
38
35
  menu_file.append(Wx::ID_EXIT, "E&xit\tAlt-X", "Quit this program")
39
- menu_bar = Wx::MenuBar.new()
40
36
  menu_bar.append(menu_file, "&File")
37
+
38
+ # The "help" menu
39
+ menu_help = Wx::Menu.new
40
+ # Using Wx::ID_ABOUT default id means the menu item will be placed
41
+ # in the correct platform-specific place - eg on OS X
42
+ menu_help.append(Wx::ID_ABOUT, "&About...\tF1", "Show about dialog")
41
43
  menu_bar.append(menu_help, "&Help")
42
- # Assign the menus to this frame
43
- set_menu_bar(menu_bar)
44
44
 
45
+ # Assign the menubar to this frame
46
+ self.menu_bar = menu_bar
47
+
48
+ # Create a status bar
45
49
  create_status_bar(2)
46
- set_status_text("Welcome to wxRuby!")
50
+ self.status_text = "Welcome to wxRuby!"
47
51
 
48
- # handle menu events
49
- evt_menu(Wx::ID_EXIT) { on_quit }
50
- evt_menu(Wx::ID_ABOUT) { on_about }
52
+ # Set it up to handle menu events using the relevant methods
53
+ evt_menu Wx::ID_EXIT, :on_quit
54
+ evt_menu Wx::ID_ABOUT, :on_about
51
55
  end
52
56
 
53
57
  # End the application; it should finish automatically when the last
@@ -64,32 +68,18 @@ class MinimalFrame < Wx::Frame
64
68
  # create a simple message dialog with OK button
65
69
  about_dlg = Wx::MessageDialog.new( self, msg, 'About Minimal',
66
70
  Wx::OK|Wx::ICON_INFORMATION )
71
+ # Display the dialog on top of and blocking other windows, until
72
+ # dismissed by clicking the 'OK' button
67
73
  about_dlg.show_modal
68
74
  end
69
-
70
- # utility function to find an icon relative to this ruby script
71
- def local_icon_file(icon_name)
72
- File.join( File.dirname(__FILE__), icon_name)
73
- end
74
75
  end
75
76
 
76
- # Wx::App is the container class for any wxruby app - only a single
77
- # instance is required
78
- class MinimalApp < Wx::App
79
- # This method is called when main_loop is entered; it should set up
80
- # the application's and display initial GUI windows.
81
- def on_init
82
- frame = MinimalFrame.new("Minimal wxRuby App",
83
- Wx::Point.new(50, 50),
84
- Wx::Size.new(450, 340))
85
- set_app_name('Minimal')
86
- # This is required, and on_init must return a true value else the
87
- # app will not start
88
- frame.show()
89
- end
77
+ # Wx::App is the container class for any wxruby app. To start an
78
+ # application, either define a subclass of Wx::App, create an instance,
79
+ # and call its main_loop method, OR, simply call the Wx::App.run class
80
+ # method, as shown here.
81
+ Wx::App.run do
82
+ self.app_name = 'Minimal'
83
+ frame = MinimalFrame.new("Minimal wxRuby App")
84
+ frame.show
90
85
  end
91
-
92
- # Create an instance ...
93
- app = MinimalApp.new
94
- # ... and run the application
95
- app.main_loop()
@@ -13,34 +13,9 @@ rescue LoadError => no_wx_err
13
13
  end
14
14
  end
15
15
 
16
- class MyFrame < Wx::Frame
17
- def initialize(title)
18
- super(nil, -1, title)
19
- end
16
+ # This is the minimum code to start a WxRuby app - create a Frame, and
17
+ # show it.
18
+ Wx::App.run do
19
+ frame = Wx::Frame.new(nil, :title => "Minimal wxRuby App")
20
+ frame.show
20
21
  end
21
-
22
- class NothingApp < Wx::App
23
- def on_init
24
- puts("in on_init")
25
- $frame = MyFrame.new("Minimal wxRuby App")
26
- puts("about to call show")
27
- $frame.show
28
- puts("returning from on_init")
29
- return true
30
- end
31
-
32
- def on_fatal_exception
33
- puts("on_fatal_exception")
34
- end
35
-
36
- def on_exit
37
- puts("on_exit")
38
- return super
39
- end
40
- end
41
-
42
- a = NothingApp.new
43
- a.main_loop()
44
- puts("back from main_loop...")
45
- GC.start
46
- puts("survived gc")
@@ -24,12 +24,6 @@ class MyFrame < Frame
24
24
  def initialize(title,pos,size,style=DEFAULT_FRAME_STYLE)
25
25
  super(nil,-1,title,pos,size,style)
26
26
 
27
- if Wx::PLATFORM == "WXMSW"
28
- set_icon(Icon.new("mondrian.ico",BITMAP_TYPE_ICO))
29
- else
30
- set_icon(Icon.new("mondrian.xpm",BITMAP_TYPE_XPM))
31
- end
32
-
33
27
  menuFile = Menu.new()
34
28
  menuFile.append(Minimal_Quit, "E&xit\tAlt-X", "Quit this program")
35
29
 
@@ -51,23 +45,23 @@ class MyFrame < Frame
51
45
  create_status_bar(2)
52
46
  set_status_text("Welcome to wxRuby!")
53
47
 
54
- @sci = Wx::Scintilla.new(self)
48
+ @sci = Wx::StyledTextCtrl.new(self)
55
49
 
56
50
  font = Font.new(10, TELETYPE, NORMAL, NORMAL)
57
- @sci.style_set_font(SCI_STYLE_DEFAULT, font);
51
+ @sci.style_set_font(STC_STYLE_DEFAULT, font);
58
52
 
59
53
  @ws_visible = false
60
54
  @eol_visible = false
61
- @sci.set_edge_mode(SCI_EDGE_LINE)
55
+ @sci.set_edge_mode(STC_EDGE_LINE)
62
56
 
63
- line_num_margin = @sci.text_width(SCI_STYLE_LINENUMBER, "_99999")
57
+ line_num_margin = @sci.text_width(STC_STYLE_LINENUMBER, "_99999")
64
58
  @sci.set_margin_width(0, line_num_margin)
65
59
 
66
- @sci.style_set_foreground(SCI_STYLE_DEFAULT, BLACK);
67
- @sci.style_set_background(SCI_STYLE_DEFAULT, WHITE);
68
- @sci.style_set_foreground(SCI_STYLE_LINENUMBER, LIGHT_GREY);
69
- @sci.style_set_background(SCI_STYLE_LINENUMBER, WHITE);
70
- @sci.style_set_foreground(SCI_STYLE_INDENTGUIDE, LIGHT_GREY);
60
+ @sci.style_set_foreground(STC_STYLE_DEFAULT, BLACK);
61
+ @sci.style_set_background(STC_STYLE_DEFAULT, WHITE);
62
+ @sci.style_set_foreground(STC_STYLE_LINENUMBER, LIGHT_GREY);
63
+ @sci.style_set_background(STC_STYLE_LINENUMBER, WHITE);
64
+ @sci.style_set_foreground(STC_STYLE_INDENTGUIDE, LIGHT_GREY);
71
65
 
72
66
  @sci.set_tab_width(4)
73
67
  @sci.set_use_tabs(false)
@@ -76,7 +70,7 @@ class MyFrame < Frame
76
70
  @sci.set_indent(4)
77
71
  @sci.set_edge_column(80)
78
72
 
79
- @sci.set_lexer(SCI_LEX_RUBY)
73
+ @sci.set_lexer(STC_LEX_RUBY)
80
74
  @sci.style_clear_all
81
75
  @sci.style_set_foreground(2, RED)
82
76
  @sci.style_set_foreground(3, GREEN)
@@ -91,17 +85,17 @@ class MyFrame < Frame
91
85
  @sci.set_property("fold.preprocessor", "1")
92
86
 
93
87
  @sci.set_margin_width(1, 0)
94
- @sci.set_margin_type(1, SCI_MARGIN_SYMBOL)
95
- @sci.set_margin_mask(1, SCI_MASK_FOLDERS)
88
+ @sci.set_margin_type(1, STC_MARGIN_SYMBOL)
89
+ @sci.set_margin_mask(1, STC_MASK_FOLDERS)
96
90
  @sci.set_margin_width(1, 20)
97
91
 
98
- @sci.marker_define(SCI_MARKNUM_FOLDER, SCI_MARK_PLUS)
99
- @sci.marker_define(SCI_MARKNUM_FOLDEROPEN, SCI_MARK_MINUS)
100
- @sci.marker_define(SCI_MARKNUM_FOLDEREND, SCI_MARK_EMPTY)
101
- @sci.marker_define(SCI_MARKNUM_FOLDERMIDTAIL, SCI_MARK_EMPTY)
102
- @sci.marker_define(SCI_MARKNUM_FOLDEROPENMID, SCI_MARK_EMPTY)
103
- @sci.marker_define(SCI_MARKNUM_FOLDERSUB, SCI_MARK_EMPTY)
104
- @sci.marker_define(SCI_MARKNUM_FOLDERTAIL, SCI_MARK_EMPTY)
92
+ @sci.marker_define(STC_MARKNUM_FOLDER, STC_MARK_PLUS)
93
+ @sci.marker_define(STC_MARKNUM_FOLDEROPEN, STC_MARK_MINUS)
94
+ @sci.marker_define(STC_MARKNUM_FOLDEREND, STC_MARK_EMPTY)
95
+ @sci.marker_define(STC_MARKNUM_FOLDERMIDTAIL, STC_MARK_EMPTY)
96
+ @sci.marker_define(STC_MARKNUM_FOLDEROPENMID, STC_MARK_EMPTY)
97
+ @sci.marker_define(STC_MARKNUM_FOLDERSUB, STC_MARK_EMPTY)
98
+ @sci.marker_define(STC_MARKNUM_FOLDERTAIL, STC_MARK_EMPTY)
105
99
  @sci.set_fold_flags(16)
106
100
 
107
101
  @sci.set_margin_sensitive(1,1)
@@ -110,8 +104,8 @@ class MyFrame < Frame
110
104
  evt_menu(Minimal_About) {onAbout}
111
105
  evt_menu(Toggle_Whitespace) {onWhitespace}
112
106
  evt_menu(Toggle_EOL) {onEOL}
113
- evt_sci_charadded {|evt| onCharadded(evt)}
114
- evt_sci_marginclick {|evt| onMarginClick(evt)}
107
+ evt_stc_charadded(@sci.get_id) {|evt| onCharadded(evt)}
108
+ evt_stc_marginclick(@sci.get_id) {|evt| onMarginClick(evt)}
115
109
 
116
110
  end
117
111
 
@@ -130,7 +124,7 @@ class MyFrame < Frame
130
124
 
131
125
  def onWhitespace
132
126
  @ws_visible = !@ws_visible
133
- @sci.set_view_white_space(@ws_visible ? SCI_WS_VISIBLEALWAYS : SCI_WS_INVISIBLE)
127
+ @sci.set_view_white_space(@ws_visible ? STC_WS_VISIBLEALWAYS : STC_WS_INVISIBLE)
134
128
  end
135
129
 
136
130
  def onEOL
@@ -102,7 +102,7 @@ class IConvFrame < Wx::Frame
102
102
 
103
103
  sizer.add(ctrl_sizer, 0, Wx::ADJUST_MINSIZE|Wx::ALL, 2)
104
104
  construct_menus()
105
- panel.set_sizer( sizer )
105
+ panel.set_sizer_and_fit( sizer )
106
106
  end
107
107
 
108
108
  # Prompt the user to specify a file whose contents should be loaded
@@ -59,7 +59,6 @@ TreeTest_DecSpacing,
59
59
  TreeTest_ToggleIcon,
60
60
  TreeTest_Select,
61
61
  TreeTest_Unselect = (Wx::ID_HIGHEST..Wx::ID_HIGHEST+39).to_a
62
- TreeTest_Ctrl = 1000
63
62
 
64
63
  TreeCtrlIcon_File,
65
64
  TreeCtrlIcon_FileSelected,
@@ -68,8 +67,8 @@ TreeCtrlIcon_FolderSelected,
68
67
  TreeCtrlIcon_FolderOpened = 0,1,2,3,4
69
68
 
70
69
  class MyTreeCtrl < Wx::TreeCtrl
71
- def initialize(parent, id,pos, size,style)
72
- super(parent, id, pos, size, style)
70
+ def initialize(parent, args)
71
+ super
73
72
 
74
73
  @reverse_sort = false
75
74
 
@@ -79,26 +78,25 @@ class MyTreeCtrl < Wx::TreeCtrl
79
78
  add_test_items_to_tree(5, 2)
80
79
 
81
80
  # TreeCtrl supports a large number of different events...
82
- evt_tree_begin_drag(TreeTest_Ctrl) { | e | on_begin_drag(e) }
83
- evt_tree_begin_rdrag(TreeTest_Ctrl) { | e | on_begin_rdrag(e) }
84
- evt_tree_end_drag(TreeTest_Ctrl) { | e | on_end_drag(e) }
85
- evt_tree_begin_label_edit(TreeTest_Ctrl) { | e | on_begin_label_edit(e) }
86
- evt_tree_end_label_edit(TreeTest_Ctrl) { | e | on_end_label_edit(e) }
87
- evt_tree_delete_item(TreeTest_Ctrl) { | e | on_delete_item(e) }
88
- evt_tree_set_info(TreeTest_Ctrl) { | e | on_set_info(e) }
89
- evt_tree_item_expanded(TreeTest_Ctrl) { | e | on_item_expanded(e) }
90
- evt_tree_item_expanding(TreeTest_Ctrl) { | e | on_item_expanding(e) }
91
- evt_tree_item_collapsed(TreeTest_Ctrl) { | e | on_item_collapsed(e) }
92
- evt_tree_item_collapsing(TreeTest_Ctrl) { | e | on_item_collapsing(e) }
93
- evt_tree_item_right_click(TreeTest_Ctrl) { | e | on_item_right_click(e) }
94
-
95
- evt_right_up { | e | on_rmouse_up(e) }
96
- evt_tree_sel_changed(TreeTest_Ctrl) { | e | on_sel_changed(e) }
97
- evt_tree_sel_changing(TreeTest_Ctrl) { | e | on_sel_changing(e) }
98
- evt_tree_key_down(TreeTest_Ctrl) { | e | on_tree_key_down(e) }
99
- evt_tree_item_activated(TreeTest_Ctrl) { | e | on_item_activated(e) }
100
- evt_right_dclick { | e | on_rmouse_dclick(event) }
101
-
81
+ evt_tree_begin_drag self, :on_begin_drag
82
+ evt_tree_begin_rdrag self, :on_begin_rdrag
83
+ evt_tree_end_drag self, :on_end_drag
84
+ evt_tree_begin_label_edit self, :on_begin_label_edit
85
+ evt_tree_end_label_edit self, :on_end_label_edit
86
+ evt_tree_delete_item self, :on_delete_item
87
+ evt_tree_set_info self, :on_set_info
88
+ evt_tree_item_expanded self, :on_item_expanded
89
+ evt_tree_item_expanding self, :on_item_expanding
90
+ evt_tree_item_collapsed self, :on_item_collapsed
91
+ evt_tree_item_collapsing self, :on_item_collapsing
92
+ evt_tree_item_right_click self, :on_item_right_click
93
+ evt_tree_sel_changed self, :on_sel_changed
94
+ evt_tree_sel_changing self, :on_sel_changing
95
+ evt_tree_key_down self, :on_tree_key_down
96
+ evt_tree_item_activated self, :on_item_activated
97
+
98
+ evt_right_dclick :on_rmouse_dclick
99
+ evt_right_up :on_rmouse_up
102
100
  end
103
101
 
104
102
  def show_info(id)
@@ -131,7 +129,7 @@ class MyTreeCtrl < Wx::TreeCtrl
131
129
 
132
130
  def is_test_item(item)
133
131
  # the test item is the first child folder
134
- return get_item_parent(item) == get_root_item() && !get_prev_sibling(item)
132
+ return item_parent(item) == root_item && ! prev_sibling(item)
135
133
  end
136
134
 
137
135
  def create_image_list
@@ -143,16 +141,15 @@ class MyTreeCtrl < Wx::TreeCtrl
143
141
  Wx::BusyCursor.busy do
144
142
  icons = (1 .. 5).map do | i |
145
143
  icon_file = File.join(File.dirname(__FILE__), "icon#{i}.xpm")
146
- # Wx::Icon.new(icon_file, Wx::BITMAP_TYPE_XPM, 16, 16)
147
144
  Wx::Bitmap.new(icon_file, Wx::BITMAP_TYPE_XPM)
148
145
  end
149
146
  icons.each { | ic | images.add(ic) }
150
- set_image_list(images)
147
+ self.image_list = images
151
148
  end
152
149
  end
153
150
 
154
151
  def unset_image_list
155
- set_image_list(nil)
152
+ self.image_list = nil
156
153
  end
157
154
 
158
155
  def create_buttons_image_list()
@@ -165,19 +162,19 @@ class MyTreeCtrl < Wx::TreeCtrl
165
162
  Wx::Icon.new("icon3.xpm"), # closed
166
163
  Wx::Icon.new("icon3.xpm"), # closed, selected
167
164
  Wx::Icon.new("icon5.xpm"), # open
168
- Wx::Icon.new("icon5.xpm")] # open, selected
165
+ Wx::Icon.new("icon5.xpm") ] # open, selected
169
166
 
170
167
  icons.each do | ic |
171
168
  orig_size = ic.get_width()
172
169
  if size == orig_size
173
170
  images.add(ic)
174
171
  else
175
- resized = ic.convert_to_image().rescale(size, size)
172
+ resized = ic.convert_to_image.rescale(size, size)
176
173
  images.add( Wx::Bitmap.new(resized) )
177
174
  end
178
175
  end
179
176
 
180
- set_buttons_image_list(images)
177
+ self.buttons_image_list = images
181
178
  end
182
179
  end
183
180
 
@@ -203,7 +200,7 @@ class MyTreeCtrl < Wx::TreeCtrl
203
200
  end
204
201
  # here we pass to append_item() normal and selected item images (we
205
202
  # suppose that selected image follows the normal one in the enum)
206
- if Wx::get_app.show_images()
203
+ if Wx::THE_APP.show_images
207
204
  image = depth == 1 ? TreeCtrlIcon_File : TreeCtrlIcon_Folder
208
205
  imageSel = image + 1
209
206
  else
@@ -213,8 +210,8 @@ class MyTreeCtrl < Wx::TreeCtrl
213
210
 
214
211
  # and now we also set the expanded one (only for the folders)
215
212
  if has_children && Wx::get_app.show_images()
216
- set_item_image(id, TreeCtrlIcon_FolderOpened,
217
- Wx::TREE_ITEM_ICON_EXPANDED)
213
+ set_item_image( id, TreeCtrlIcon_FolderOpened,
214
+ Wx::TREE_ITEM_ICON_EXPANDED)
218
215
  end
219
216
 
220
217
  # remember the last child for OnEnsureVisible()
@@ -228,10 +225,10 @@ class MyTreeCtrl < Wx::TreeCtrl
228
225
  end
229
226
 
230
227
  def add_test_items_to_tree(num_children,depth)
231
- image = Wx::get_app.show_images ? TreeCtrlIcon_Folder : -1
228
+ image = Wx::THE_APP.show_images ? TreeCtrlIcon_Folder : -1
232
229
  root_id = add_root("Root",image, image)
233
230
  if image != -1
234
- set_item_image(root_id, TreeCtrlIcon_FolderOpened,
231
+ set_item_image( root_id, TreeCtrlIcon_FolderOpened,
235
232
  Wx::TREE_ITEM_ICON_EXPANDED)
236
233
  end
237
234
 
@@ -242,17 +239,18 @@ class MyTreeCtrl < Wx::TreeCtrl
242
239
  # that use the generic TreeCtrl - OS X and GTK, and only if
243
240
  # Wx::TR_HAS_VARIABLE_ROW_HEIGHT style was used in the constructor
244
241
  font = get_font
245
- font.set_style(Wx::FONTSTYLE_ITALIC)
242
+ font.style = Wx::FONTSTYLE_ITALIC
246
243
  set_item_font(root_id, font)
247
244
 
248
- id,cookie = get_first_child(root_id)
249
- set_item_text_colour(id, Wx::BLUE)
245
+ ids = get_children(root_id)
246
+
247
+ # make the first item blue
248
+ set_item_text_colour(ids[0], Wx::BLUE)
250
249
 
251
- id,cookie = get_next_child(root_id,cookie)
252
- id,cookie = get_next_child(root_id,cookie)
250
+ # make the third item red on grey
253
251
  if Wx::PLATFORM == "WXMSW"
254
- set_item_text_colour(id, Wx::RED)
255
- set_item_background_colour(id, Wx::LIGHT_GREY)
252
+ set_item_text_colour(ids[2], Wx::RED)
253
+ set_item_background_colour(ids[2], Wx::LIGHT_GREY)
256
254
  end
257
255
  end
258
256
 
@@ -266,7 +264,7 @@ class MyTreeCtrl < Wx::TreeCtrl
266
264
  return nil
267
265
  end
268
266
 
269
- text = get_item_text(id)
267
+ text = item_text(id)
270
268
  Wx::log_message(text)
271
269
 
272
270
  if item_has_children(id)
@@ -288,51 +286,51 @@ class MyTreeCtrl < Wx::TreeCtrl
288
286
 
289
287
  def on_begin_rdrag(event)
290
288
  Wx::log_message("OnBeginRDrag")
291
- event.skip()
289
+ event.skip
292
290
  end
293
291
 
294
292
  def on_delete_item(event)
295
293
  Wx::log_message("OnDeleteItem")
296
- event.skip()
294
+ event.skip
297
295
  end
298
296
 
299
297
  def on_get_info(event)
300
298
  Wx::log_message("OnGetInfo")
301
- event.skip()
299
+ event.skip
302
300
  end
303
301
 
304
302
  def on_set_info(event)
305
303
  Wx::log_message("OnSetInfo")
306
- event.skip()
304
+ event.skip
307
305
  end
308
306
 
309
307
  def on_item_expanded(event)
310
308
  Wx::log_message("OnItemExpanded")
311
- event.skip()
309
+ event.skip
312
310
  end
313
311
 
314
312
  def on_item_expanding(event)
315
313
  Wx::log_message("OnItemExpanding")
316
- event.skip()
314
+ event.skip
317
315
  end
318
316
 
319
317
  def on_item_collapsed(event)
320
318
  Wx::log_message("OnItemCollapsed")
321
- event.skip()
319
+ event.skip
322
320
  end
323
321
 
324
322
  def on_sel_changed(event)
325
323
  Wx::log_message("OnSelChanged")
326
- event.skip()
324
+ event.skip
327
325
  end
328
326
 
329
327
  def on_sel_changing(event)
330
328
  Wx::log_message("OnSelChanging")
331
- event.skip()
329
+ event.skip
332
330
  end
333
331
 
334
332
  def log_key_event(name,event)
335
- keycode = event.get_key_code()
333
+ keycode = event.key_code
336
334
 
337
335
  case keycode
338
336
  when Wx::K_BACK
@@ -548,26 +546,25 @@ class MyTreeCtrl < Wx::TreeCtrl
548
546
  end
549
547
 
550
548
  Wx::log_message( "%s event: %s (flags = %s%s%s%s)",
551
- name, key,
552
- event.control_down() ? 'C' : '-',
553
- event.alt_down() ? 'A' : '-',
554
- event.shift_down() ? 'S' : '-',
555
- event.meta_down() ? 'M' : '-')
549
+ name, key,
550
+ event.control_down() ? 'C' : '-',
551
+ event.alt_down() ? 'A' : '-',
552
+ event.shift_down() ? 'S' : '-',
553
+ event.meta_down() ? 'M' : '-')
556
554
  end
557
555
 
558
556
  def on_tree_key_down(event)
559
- log_key_event("Tree key down ", event.get_key_event())
560
-
561
- event.skip()
557
+ log_key_event("Tree key down ", event.key_event )
558
+ event.skip
562
559
  end
563
560
 
564
561
  def on_begin_drag(event)
565
562
  # need to explicitly allow drag
566
- if event.get_item() != get_root_item()
567
- @dragged_item = event.get_item()
568
- Wx::log_message("OnBeginDrag: started dragging %s",
569
- get_item_text(@dragged_item))
570
- event.allow()
563
+ if event.item != root_item()
564
+ @dragged_item = event.item
565
+ Wx::log_message( "OnBeginDrag: started dragging %s",
566
+ item_text(@dragged_item))
567
+ event.allow
571
568
  else
572
569
  Wx::log_message("OnBeginDrag: selected item can't be dragged.")
573
570
  end
@@ -575,12 +572,12 @@ class MyTreeCtrl < Wx::TreeCtrl
575
572
 
576
573
  def on_end_drag(event)
577
574
  src_item = @dragged_item
578
- dest_item = event.get_item()
575
+ dest_item = event.item
579
576
  @dragged_item = 0
580
577
 
581
578
  if dest_item.nonzero? && ! item_has_children(dest_item)
582
579
  # copy to the parent then
583
- dest_item = get_item_parent(dest_item)
580
+ dest_item = item_parent(dest_item)
584
581
  end
585
582
 
586
583
  unless dest_item.nonzero?()
@@ -588,9 +585,9 @@ class MyTreeCtrl < Wx::TreeCtrl
588
585
  return nil
589
586
  end
590
587
 
591
- text = get_item_text(src_item)
588
+ text = item_text(src_item)
592
589
  Wx::log_message("OnEndDrag: '%s' copied to '%s'.",
593
- text, get_item_text(dest_item))
590
+ text, item_text(dest_item))
594
591
 
595
592
  # just do append here - we could also insert it just before/after the item
596
593
  # on which it was dropped, but self requires slightly more work... we also
@@ -599,7 +596,7 @@ class MyTreeCtrl < Wx::TreeCtrl
599
596
  #
600
597
  # Finally, we only copy one item here but we might copy the entire tree if
601
598
  # we were dragging a folder.
602
- image = Wx::get_app().show_images() ? TreeCtrlIcon_File : -1
599
+ image = Wx::THE_APP.show_images() ? TreeCtrlIcon_File : -1
603
600
  append_item(dest_item, text, image)
604
601
  end
605
602
 
@@ -607,26 +604,25 @@ class MyTreeCtrl < Wx::TreeCtrl
607
604
  Wx::log_message("OnBeginLabelEdit")
608
605
 
609
606
  # for testing, prevent self item's label editing
610
- item_id = event.get_item()
611
- if is_test_item(item_id)
612
- message_box("The demo prevents you editing this item.")
607
+ if is_test_item(event.item)
608
+ Wx::message_box("The demo prevents you editing this item.")
613
609
  event.veto()
614
610
  end
615
611
  end
616
612
 
617
613
  def on_end_label_edit(event)
618
614
  Wx::log_message("OnEndLabelEdit")
619
- if event.is_edit_cancelled
615
+ if event.edit_cancelled?
620
616
  Wx::log_message("Label edit was cancelled by user")
621
617
  return
622
618
  end
623
619
 
624
620
  # For a demo, don't allow anything except letters in the labels
625
- if event.get_label =~ /[^\w.]/
621
+ if event.label =~ /[^\w.]/
626
622
  msg = "Only letters, numbers and full stops are allowed in the label."
627
- message_box(msg)
623
+ Wx::message_box(msg)
628
624
  Wx::log_message("Label edit was cancelled by demo")
629
- event.veto()
625
+ event.veto
630
626
  end
631
627
  end
632
628
 
@@ -634,28 +630,26 @@ class MyTreeCtrl < Wx::TreeCtrl
634
630
  Wx::log_message("OnItemCollapsing")
635
631
 
636
632
  # for testing, prevent the user from collapsing the first child folder
637
- item_id = event.get_item()
638
- if is_test_item(item_id)
639
- message_box("You can't collapse self item.")
640
-
641
- event.veto()
633
+ if is_test_item(event.item)
634
+ Wx::message_box("You can't collapse self item.")
635
+ event.veto
642
636
  end
643
637
  end
644
638
 
645
639
  # show some info about activated item
646
640
  def on_item_activated(event)
647
- if item_id = event.get_item()
641
+ if item_id = event.item
648
642
  show_info(item_id)
649
643
  end
650
644
  Wx::log_message("OnItemActivated")
651
645
  end
652
646
 
653
647
  def on_item_right_click(event)
654
- show_popup_menu(event.get_item(), event.get_point())
648
+ show_popup_menu(event.item, event.point)
655
649
  end
656
650
 
657
651
  def on_rmouse_up(event)
658
- pos = event.get_position()
652
+ pos = event.position
659
653
  item = hit_test(pos)
660
654
  show_popup_menu(item, pos)
661
655
  end
@@ -663,7 +657,7 @@ class MyTreeCtrl < Wx::TreeCtrl
663
657
  def show_popup_menu(id, pos)
664
658
  title = ""
665
659
  if id.nonzero?
666
- title << "Menu for " << get_item_text(id)
660
+ title << "Menu for " << item_text(id)
667
661
  else
668
662
  title = "Menu for no particular item"
669
663
  end
@@ -690,7 +684,7 @@ end
690
684
 
691
685
  class MyFrame < Wx::Frame
692
686
  def initialize(title, x, y, w, h)
693
- super(nil, -1, title, Wx::Point.new(x, y), Wx::Size.new(w, h))
687
+ super( nil, :title => title, :pos => [ x, y ], :size => [ w, h ] )
694
688
  @treectrl = nil
695
689
  @textctrl = nil
696
690
  @s_num = 0
@@ -698,7 +692,7 @@ class MyFrame < Wx::Frame
698
692
  # This reduces flicker effects - even better would be to define
699
693
  # OnEraseBackground to do nothing. When the tree control's scrollbars are
700
694
  # show or hidden, the frame is sent a background erase event.
701
- set_background_colour(Wx::Colour.new(255, 255, 255))
695
+ self.background_colour = Wx::WHITE
702
696
 
703
697
  # Make a menubar
704
698
  file_menu = Wx::Menu.new
@@ -782,13 +776,13 @@ class MyFrame < Wx::Frame
782
776
  menu_bar.append(style_menu, "&Style")
783
777
  menu_bar.append(tree_menu, "&Tree")
784
778
  menu_bar.append(item_menu, "&Item")
785
- set_menu_bar(menu_bar)
779
+ self.menu_bar = menu_bar
786
780
 
787
781
 
788
782
  # create the controls
789
- @textctrl = Wx::TextCtrl.new(self, -1, "",
790
- Wx::DEFAULT_POSITION, Wx::DEFAULT_SIZE,
791
- Wx::TE_MULTILINE|Wx::SUNKEN_BORDER)
783
+ @textctrl = Wx::TextCtrl.new( self,
784
+ :text => '',
785
+ :style => Wx::TE_MULTILINE|Wx::SUNKEN_BORDER)
792
786
 
793
787
  create_tree_with_default_style()
794
788
 
@@ -800,55 +794,54 @@ class MyFrame < Wx::Frame
800
794
 
801
795
  # set our text control as the log target
802
796
  logWindow = Wx::LogTextCtrl.new(@textctrl)
803
- Wx::Log::set_active_target(logWindow)
804
-
805
- evt_size {|event| on_size(event) }
806
-
807
- evt_menu(Wx::ID_EXIT) {|event| on_quit(event) }
808
- evt_menu(Wx::ID_ABOUT) {|event| on_about(event) }
809
-
810
- evt_menu(TreeTest_TogButtons) {|event| on_tog_buttons(event) }
811
- evt_menu(TreeTest_TogTwist) {|event| on_tog_twist(event) }
812
- evt_menu(TreeTest_TogLines) {|event| on_tog_lines(event) }
813
- evt_menu(TreeTest_TogEdit) {|event| on_tog_edit(event) }
814
- evt_menu(TreeTest_TogHideRoot) {|event| on_tog_hide_root(event) }
815
- evt_menu(TreeTest_TogRootLines) {|event| on_tog_root_lines(event) }
816
- evt_menu(TreeTest_TogBorder) {|event| on_tog_border(event) }
817
- evt_menu(TreeTest_TogFullHighlight) {|event| on_tog_full_highlight(event) }
818
- evt_menu(TreeTest_SetFgColour) {|event| on_set_fg_colour(event) }
819
- evt_menu(TreeTest_SetBgColour) {|event| on_set_bg_colour(event) }
820
- evt_menu(TreeTest_ResetStyle) {|event| on_reset_style(event) }
821
-
822
- evt_menu(TreeTest_Dump) {|event| on_dump(event) }
823
- evt_menu(TreeTest_DumpSelected) {|event| on_dump_selected(event) }
824
- evt_menu(TreeTest_Select) {|event| on_select(event) }
825
- evt_menu(TreeTest_Unselect) {|event| on_unselect(event) }
826
- evt_menu(TreeTest_ToggleSel) {|event| on_toggle_sel(event) }
827
- evt_menu(TreeTest_Rename) {|event| on_rename(event) }
828
- evt_menu(TreeTest_Count) {|event| on_count(event) }
829
- evt_menu(TreeTest_CountRec) {|event| on_count_rec(event) }
830
- evt_menu(TreeTest_Sort) {|event| on_sort(event) }
831
- evt_menu(TreeTest_SortRev) {|event| on_sort_rev(event) }
832
- evt_menu(TreeTest_SetBold) {|event| on_set_bold(event) }
833
- evt_menu(TreeTest_ClearBold) {|event| on_clear_bold(event) }
834
- evt_menu(TreeTest_Delete) {|event| on_delete(event) }
835
- evt_menu(TreeTest_DeleteChildren) {|event| on_delete_children(event) }
836
- evt_menu(TreeTest_DeleteAll) {|event| on_delete_all(event) }
837
- evt_menu(TreeTest_Recreate) {|event| on_recreate(event) }
838
- evt_menu(TreeTest_ToggleImages) {|event| on_toggle_images(event) }
839
- evt_menu(TreeTest_ToggleButtons) {|event| on_toggle_buttons(event) }
840
- evt_menu(TreeTest_SetImageSize) {|event| on_set_image_size(event) }
841
- evt_menu(TreeTest_CollapseAndReset) {|event| on_collapse_and_reset(event) }
842
- evt_menu(TreeTest_EnsureVisible) {|event| on_ensure_visible(event) }
843
- evt_menu(TreeTest_AddItem) {|event| on_add_item(event) }
844
- evt_menu(TreeTest_InsertItem) {|event| on_insert_item(event) }
845
- evt_menu(TreeTest_IncIndent) {|event| on_inc_indent(event) }
846
- evt_menu(TreeTest_DecIndent) {|event| on_dec_indent(event) }
847
- evt_menu(TreeTest_IncSpacing) {|event| on_inc_spacing(event) }
848
- evt_menu(TreeTest_DecSpacing) {|event| on_dec_spacing(event) }
849
- evt_menu(TreeTest_ToggleIcon) {|event| on_toggle_icon(event) }
850
-
851
- evt_close {|event| on_close(event) }
797
+ Wx::Log::active_target = logWindow
798
+
799
+ evt_size :on_size
800
+ evt_close :on_close
801
+
802
+ evt_menu Wx::ID_EXIT, :on_quit
803
+ evt_menu Wx::ID_ABOUT, :on_about
804
+
805
+ evt_menu TreeTest_TogButtons, :on_tog_buttons
806
+ evt_menu TreeTest_TogTwist, :on_tog_twist
807
+ evt_menu TreeTest_TogLines, :on_tog_lines
808
+ evt_menu TreeTest_TogEdit, :on_tog_edit
809
+ evt_menu TreeTest_TogHideRoot, :on_tog_hide_root
810
+ evt_menu TreeTest_TogRootLines, :on_tog_root_lines
811
+ evt_menu TreeTest_TogBorder, :on_tog_border
812
+ evt_menu TreeTest_TogFullHighlight, :on_tog_full_highlight
813
+ evt_menu TreeTest_SetFgColour, :on_set_fg_colour
814
+ evt_menu TreeTest_SetBgColour, :on_set_bg_colour
815
+ evt_menu TreeTest_ResetStyle, :on_reset_style
816
+
817
+ evt_menu TreeTest_Dump, :on_dump
818
+ evt_menu TreeTest_DumpSelected, :on_dump_selected
819
+ evt_menu TreeTest_Select, :on_select
820
+ evt_menu TreeTest_Unselect, :on_unselect
821
+ evt_menu TreeTest_ToggleSel, :on_toggle_sel
822
+ evt_menu TreeTest_Rename, :on_rename
823
+ evt_menu TreeTest_Count, :on_count
824
+ evt_menu TreeTest_CountRec, :on_count_rec
825
+ evt_menu TreeTest_Sort, :on_sort
826
+ evt_menu TreeTest_SortRev, :on_sort_rev
827
+ evt_menu TreeTest_SetBold, :on_set_bold
828
+ evt_menu TreeTest_ClearBold, :on_clear_bold
829
+ evt_menu TreeTest_Delete, :on_delete
830
+ evt_menu TreeTest_DeleteChildren, :on_delete_children
831
+ evt_menu TreeTest_DeleteAll, :on_delete_all
832
+ evt_menu TreeTest_Recreate, :on_recreate
833
+ evt_menu TreeTest_ToggleImages, :on_toggle_images
834
+ evt_menu TreeTest_ToggleButtons, :on_toggle_buttons
835
+ evt_menu TreeTest_SetImageSize, :on_set_image_size
836
+ evt_menu TreeTest_CollapseAndReset, :on_collapse_and_reset
837
+ evt_menu TreeTest_EnsureVisible, :on_ensure_visible
838
+ evt_menu TreeTest_AddItem, :on_add_item
839
+ evt_menu TreeTest_InsertItem, :on_insert_item
840
+ evt_menu TreeTest_IncIndent, :on_inc_indent
841
+ evt_menu TreeTest_DecIndent, :on_dec_indent
842
+ evt_menu TreeTest_IncSpacing, :on_inc_spacing
843
+ evt_menu TreeTest_DecSpacing, :on_dec_spacing
844
+ evt_menu TreeTest_ToggleIcon, :on_toggle_icon
852
845
  end
853
846
 
854
847
  def create_tree_with_default_style()
@@ -860,7 +853,7 @@ class MyFrame < Wx::Frame
860
853
 
861
854
  # as we don't know what Wx::TR_DEFAULT_STYLE could contain, test for
862
855
  # everything
863
- mbar = get_menu_bar()
856
+ mbar = menu_bar
864
857
  mbar.check(TreeTest_TogButtons, (style & Wx::TR_HAS_BUTTONS) != 0)
865
858
  mbar.check(TreeTest_TogButtons, (style & Wx::TR_TWIST_BUTTONS) != 0)
866
859
  mbar.check(TreeTest_TogLines, (style & Wx::TR_NO_LINES) == 0)
@@ -872,53 +865,51 @@ class MyFrame < Wx::Frame
872
865
  end
873
866
 
874
867
  def create_tree(style)
875
- @treectrl = MyTreeCtrl.new(self, TreeTest_Ctrl,
876
- Wx::DEFAULT_POSITION, Wx::DEFAULT_SIZE,
877
- style)
878
- resize()
868
+ @treectrl = MyTreeCtrl.new(self, :style => style)
869
+ resize
879
870
  end
880
871
 
881
872
  def tog_style(id,flag)
882
873
 
883
- style = @treectrl.get_window_style_flag() ^ flag
874
+ style = @treectrl.window_style_flag ^ flag
884
875
 
885
876
  # most treectrl styles can't be changed on the fly using the native
886
877
  # control and the tree must be recreated
887
878
  @treectrl.destroy
888
879
  create_tree(style)
889
- get_menu_bar().check(id, (style & flag) != 0)
880
+ menu_bar.check(id, (style & flag) != 0)
890
881
  end
891
882
 
892
883
  def on_tog_buttons(event)
893
- tog_style(event.get_id(), Wx::TR_HAS_BUTTONS)
884
+ tog_style(event.id, Wx::TR_HAS_BUTTONS)
894
885
  end
895
886
 
896
887
  def on_tog_twist(event)
897
- tog_style(event.get_id(), Wx::TR_TWIST_BUTTONS)
888
+ tog_style(event.id, Wx::TR_TWIST_BUTTONS)
898
889
  end
899
890
 
900
891
  def on_tog_lines(event)
901
- tog_style(event.get_id(), Wx::TR_NO_LINES)
892
+ tog_style(event.id, Wx::TR_NO_LINES)
902
893
  end
903
894
 
904
895
  def on_tog_edit(event)
905
- tog_style(event.get_id(), Wx::TR_EDIT_LABELS)
896
+ tog_style(event.id, Wx::TR_EDIT_LABELS)
906
897
  end
907
898
 
908
899
  def on_tog_hide_root(event)
909
- tog_style(event.get_id(), Wx::TR_HIDE_ROOT)
900
+ tog_style(event.id, Wx::TR_HIDE_ROOT)
910
901
  end
911
902
 
912
903
  def on_tog_root_lines(event)
913
- tog_style(event.get_id(), Wx::TR_LINES_AT_ROOT)
904
+ tog_style(event.id, Wx::TR_LINES_AT_ROOT)
914
905
  end
915
906
 
916
907
  def on_tog_border(event)
917
- tog_style(event.get_id(), Wx::TR_ROW_LINES)
908
+ tog_style(event.id, Wx::TR_ROW_LINES)
918
909
  end
919
910
 
920
911
  def on_tog_full_highlight(event)
921
- tog_style(event.get_id(), Wx::TR_FULL_ROW_HIGHLIGHT)
912
+ tog_style(event.id, Wx::TR_FULL_ROW_HIGHLIGHT)
922
913
  end
923
914
 
924
915
  def on_reset_style(event)
@@ -934,7 +925,7 @@ class MyFrame < Wx::Frame
934
925
  end
935
926
 
936
927
  def on_sort(event)
937
- do_sort()
928
+ do_sort
938
929
  end
939
930
 
940
931
  def on_sort_rev(event)
@@ -943,22 +934,19 @@ class MyFrame < Wx::Frame
943
934
 
944
935
  def on_size(event)
945
936
  if @treectrl && @textctrl
946
- resize()
937
+ resize
947
938
  end
948
-
949
- event.skip()
939
+ event.skip
950
940
  end
951
941
 
952
- def resize()
953
- my_size = get_client_size()
954
- tree_size = Wx::Size.new(my_size.x, 2*my_size.y/3)
955
- @treectrl.set_size( tree_size )
956
- @textctrl.set_dimensions(0, 2*my_size.y/3, my_size.x, my_size.y/3)
942
+ def resize
943
+ my_size = self.client_size
944
+ @treectrl.size = [ my_size.x, 2 * my_size.y / 3 ]
957
945
  end
958
946
 
959
947
  def on_close(event)
960
- Wx::Log::set_active_target(nil)
961
- destroy()
948
+ Wx::Log::active_target = nil
949
+ destroy
962
950
  end
963
951
 
964
952
  def on_quit(event)
@@ -966,15 +954,15 @@ class MyFrame < Wx::Frame
966
954
  end
967
955
 
968
956
  def on_about(event)
969
- Wx::message_box("Tree test sample\n" +
970
- "(c) Julian Smart 1997, Vadim Zeitlin 1998",
971
- "About tree test",
972
- Wx::OK|Wx::ICON_INFORMATION, self)
957
+ Wx::message_box( "Tree test sample\n" +
958
+ "(c) Julian Smart 1997, Vadim Zeitlin 1998",
959
+ "About tree test",
960
+ Wx::OK|Wx::ICON_INFORMATION, self)
973
961
  end
974
962
 
975
963
  def check_item(item)
976
964
  unless item.nonzero?
977
- message_box("Please select some item first!",
965
+ Wx::message_box("Please select some item first!",
978
966
  "Tree sample error",
979
967
  Wx::OK|Wx::ICON_EXCLAMATION, self)
980
968
  return false
@@ -983,51 +971,44 @@ class MyFrame < Wx::Frame
983
971
  end
984
972
 
985
973
  def on_rename(event)
986
- item = @treectrl.get_selection()
987
-
974
+ item = @treectrl.selection
988
975
  return nil unless check_item( item )
989
-
990
976
  # TODO demonstrate creating a custom edit control...
991
977
  @treectrl.edit_label(item)
992
978
  end
993
979
 
994
980
  def on_count(event)
995
- item = @treectrl.get_selection()
996
-
981
+ item = @treectrl.selection
997
982
  return nil unless check_item( item )
998
-
999
- i = @treectrl.get_children_count( item, false )
1000
-
983
+ i = @treectrl.children_count( item, false )
1001
984
  Wx::log_message("%d children", i)
1002
985
  end
1003
986
 
1004
987
  def on_count_rec(event)
1005
- item = @treectrl.get_selection()
988
+ item = @treectrl.selection
1006
989
  return nil unless check_item( item )
1007
- Wx::log_message("%d children", @treectrl.get_children_count( item ))
990
+ Wx::log_message("%d children", @treectrl.children_count( item ))
1008
991
  end
1009
992
 
1010
993
  def do_sort(reverse = false)
1011
- item = @treectrl.get_selection()
994
+ item = @treectrl.selection
1012
995
  return nil unless check_item( item )
1013
996
  @treectrl.do_sort_children(item, reverse)
1014
997
  end
1015
998
 
1016
999
  def on_dump(event)
1017
- root = @treectrl.get_selection()
1018
-
1000
+ root = @treectrl.selection
1019
1001
  return nil unless check_item( root )
1020
-
1021
1002
  @treectrl.get_items_recursively(root, -1)
1022
1003
  end
1023
1004
 
1024
1005
  def on_toggle_sel(event)
1025
- tog_style(event.get_id(), Wx::TR_MULTIPLE)
1006
+ tog_style(event.id, Wx::TR_MULTIPLE)
1026
1007
  end
1027
1008
 
1028
1009
  def on_dump_selected(event)
1029
- if ( @treectrl.get_window_style & Wx::TR_MULTIPLE ) == 0
1030
- item_id = @treectrl.get_selection
1010
+ if ( @treectrl.window_style & Wx::TR_MULTIPLE ) == 0
1011
+ item_id = @treectrl.selection
1031
1012
  if item_id.nonzero?
1032
1013
  Wx::log_message("<TreeItem '%s'>",
1033
1014
  @treectrl.get_item_text(item_id))
@@ -1046,7 +1027,7 @@ class MyFrame < Wx::Frame
1046
1027
  end
1047
1028
 
1048
1029
  def on_select(event)
1049
- @treectrl.select_item(@treectrl.get_selection())
1030
+ @treectrl.select_item(@treectrl.selection)
1050
1031
  end
1051
1032
 
1052
1033
  def on_unselect(event)
@@ -1054,26 +1035,20 @@ class MyFrame < Wx::Frame
1054
1035
  end
1055
1036
 
1056
1037
  def do_set_bold(bold = true)
1057
- item = @treectrl.get_selection()
1058
-
1038
+ item = @treectrl.selection
1059
1039
  return nil unless check_item( item )
1060
-
1061
1040
  @treectrl.set_item_bold(item, bold)
1062
1041
  end
1063
1042
 
1064
1043
  def on_delete(event)
1065
- item = @treectrl.get_selection()
1066
-
1044
+ item = @treectrl.selection
1067
1045
  return nil unless check_item( item )
1068
-
1069
1046
  @treectrl.delete(item)
1070
1047
  end
1071
1048
 
1072
1049
  def on_delete_children(event)
1073
- item = @treectrl.get_selection()
1074
-
1050
+ item = @treectrl.selection
1075
1051
  return nil unless check_item( item )
1076
-
1077
1052
  @treectrl.delete_children(item)
1078
1053
  end
1079
1054
 
@@ -1096,7 +1071,7 @@ class MyFrame < Wx::Frame
1096
1071
  end
1097
1072
 
1098
1073
  @treectrl.create_image_list(size)
1099
- Wx::get_app.show_images = true
1074
+ Wx::THE_APP.show_images = true
1100
1075
  end
1101
1076
 
1102
1077
  def on_toggle_images(event)
@@ -1121,46 +1096,42 @@ class MyFrame < Wx::Frame
1121
1096
  end
1122
1097
 
1123
1098
  def on_insert_item(event)
1124
- image = Wx::get_app.show_images() ? TreeCtrlIcon_File : -1
1125
- @treectrl.insert_item(@treectrl.get_root_item(), -1, "2nd item", image)
1099
+ image = Wx::THE_APP.show_images() ? TreeCtrlIcon_File : -1
1100
+ @treectrl.insert_item(@treectrl.root_item, -1, "2nd item", image)
1126
1101
  end
1127
1102
 
1128
1103
  def on_add_item(event)
1129
1104
  @s_num += 1
1130
1105
  text = sprintf("Item #%d", @s_num)
1131
- @treectrl.append_item(@treectrl.get_root_item(), text)
1106
+ @treectrl.append_item(@treectrl.root_item, text)
1132
1107
  end
1133
1108
 
1134
1109
  def on_inc_indent(event)
1135
- indent = @treectrl.get_indent()
1136
- if indent < 100
1137
- @treectrl.set_indent( indent+5 )
1110
+ if @treectrl.indent < 100
1111
+ @treectrl.indent += 5
1138
1112
  end
1139
1113
  end
1140
1114
 
1141
1115
  def on_dec_indent(event)
1142
- indent = @treectrl.get_indent()
1143
- if indent > 10
1144
- @treectrl.set_indent( indent-5 )
1116
+ if @treectrl.indent > 10
1117
+ @treectrl.indent -= 5
1145
1118
  end
1146
1119
  end
1147
1120
 
1148
1121
  def on_inc_spacing(event)
1149
- indent = @treectrl.get_spacing()
1150
- if indent < 100
1151
- @treectrl.set_spacing( indent+5 )
1122
+ if @treectrl.spacing < 100
1123
+ @treectrl.spacing += 5
1152
1124
  end
1153
1125
  end
1154
1126
 
1155
1127
  def on_dec_spacing(event)
1156
- indent = @treectrl.get_spacing()
1157
- if indent > 10
1158
- @treectrl.set_spacing( indent-5 )
1128
+ if @treectrl.spacing > 10
1129
+ @treectrl.spacing -= 5
1159
1130
  end
1160
1131
  end
1161
1132
 
1162
1133
  def on_toggle_icon(event)
1163
- item = @treectrl.get_selection()
1134
+ item = @treectrl.selection
1164
1135
  return nil unless check_item( item )
1165
1136
  @treectrl.do_toggle_icon(item)
1166
1137
  end
@@ -1169,9 +1140,9 @@ class MyFrame < Wx::Frame
1169
1140
  def on_set_fg_colour(event)
1170
1141
  Wx::log_message('NOT IMPLEMENTED')
1171
1142
  return
1172
- col = Wx::get_colour_from_user(self, @treectrl.get_foreground_colour())
1173
- if col.is_ok
1174
- @treectrl.set_foreground_colour(col)
1143
+ col = Wx::get_colour_from_user(self, @treectrl.foreground_colour)
1144
+ if col.ok?
1145
+ @treectrl.foreground_colour = col
1175
1146
  end
1176
1147
  end
1177
1148
 
@@ -1179,9 +1150,9 @@ class MyFrame < Wx::Frame
1179
1150
  def on_set_bg_colour(event)
1180
1151
  Wx::log_message('NOT IMPLEMENTED')
1181
1152
  return
1182
- col = Wx::get_colour_from_user(self, @treectrl.get_background_colour())
1183
- if col.is_ok
1184
- @treectrl.set_background_colour(col)
1153
+ col = Wx::get_colour_from_user(self, @treectrl.background_colour)
1154
+ if col.ok?
1155
+ @treectrl.background_colour = col
1185
1156
  end
1186
1157
  end
1187
1158
 
@@ -1198,7 +1169,7 @@ class MyApp < Wx::App
1198
1169
  def on_init
1199
1170
  # Create the main frame window
1200
1171
  frame = MyFrame.new("TreeCtrl Test", 50, 50, 450, 600)
1201
-
1172
+ gc_stress
1202
1173
  # show the frame
1203
1174
  frame.show(true)
1204
1175
  # set_top_window(frame)
@@ -1206,5 +1177,5 @@ class MyApp < Wx::App
1206
1177
  end
1207
1178
  end
1208
1179
 
1209
- a = MyApp.new
1210
- a.main_loop()
1180
+ app = MyApp.new
1181
+ app.main_loop