wxruby 1.9.9-x86-mingw32 → 1.9.10-x86-mingw32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (152) hide show
  1. data/LICENSE +53 -53
  2. data/README +297 -297
  3. data/lib/wx.rb +53 -53
  4. data/lib/wx/classes/bitmap.rb +29 -1
  5. data/lib/wx/classes/clipboard.rb +19 -3
  6. data/lib/wx/classes/colour.rb +6 -4
  7. data/lib/wx/classes/data_object.rb +14 -0
  8. data/lib/wx/classes/data_object_simple.rb +6 -0
  9. data/lib/wx/classes/dataformat.rb +23 -0
  10. data/lib/wx/classes/evthandler.rb +31 -4
  11. data/lib/wx/classes/genericdirctrl.rb +36 -0
  12. data/lib/wx/classes/grid.rb +8 -0
  13. data/lib/wx/classes/hboxsizer.rb +6 -0
  14. data/lib/wx/classes/icon.rb +12 -1
  15. data/lib/wx/classes/image.rb +13 -1
  16. data/lib/wx/classes/listctrl.rb +12 -0
  17. data/lib/wx/classes/point.rb +8 -0
  18. data/lib/wx/classes/rect.rb +10 -1
  19. data/lib/wx/classes/richtextctrl.rb +22 -0
  20. data/lib/wx/classes/size.rb +9 -0
  21. data/lib/wx/classes/sizer.rb +18 -3
  22. data/lib/wx/classes/toolbar.rb +4 -6
  23. data/lib/wx/classes/vboxsizer.rb +6 -0
  24. data/lib/wx/classes/window.rb +7 -0
  25. data/lib/wx/classes/xmlresource.rb +17 -0
  26. data/lib/wx/helpers.rb +16 -1
  27. data/lib/wx/keyword_ctors.rb +3 -2
  28. data/lib/wx/keyword_defs.rb +27 -5
  29. data/lib/wx/version.rb +1 -1
  30. data/lib/wxruby2.so +0 -0
  31. data/samples/SAMPLES-LICENSE.TXT +17 -17
  32. data/samples/bigdemo/About.rbw +39 -39
  33. data/samples/bigdemo/ColorPanel.rbw +23 -23
  34. data/samples/bigdemo/GridSimple.rbw +78 -78
  35. data/samples/bigdemo/MDIDemo.rbw +57 -57
  36. data/samples/bigdemo/PopupMenu.rbw +149 -149
  37. data/samples/bigdemo/Sizers.rbw +543 -543
  38. data/samples/bigdemo/bigdemo.rb +823 -823
  39. data/samples/bigdemo/demoTemplate.rbw +33 -33
  40. data/samples/bigdemo/icons/choice.xpm +27 -27
  41. data/samples/bigdemo/icons/combo.xpm +27 -27
  42. data/samples/bigdemo/icons/copy.xpm +25 -25
  43. data/samples/bigdemo/icons/cut.xpm +24 -24
  44. data/samples/bigdemo/icons/gauge.xpm +27 -27
  45. data/samples/bigdemo/icons/help.xpm +25 -25
  46. data/samples/bigdemo/icons/list.xpm +27 -27
  47. data/samples/bigdemo/icons/mondrian.xpm +44 -44
  48. data/samples/bigdemo/icons/new.xpm +24 -24
  49. data/samples/bigdemo/icons/ogl.ico +0 -0
  50. data/samples/bigdemo/icons/ogl.xpm +45 -45
  51. data/samples/bigdemo/icons/open.xpm +26 -26
  52. data/samples/bigdemo/icons/paste.xpm +38 -38
  53. data/samples/bigdemo/icons/preview.xpm +26 -26
  54. data/samples/bigdemo/icons/print.xpm +26 -26
  55. data/samples/bigdemo/icons/radio.xpm +27 -27
  56. data/samples/bigdemo/icons/robert.xpm +415 -415
  57. data/samples/bigdemo/icons/save.xpm +25 -25
  58. data/samples/bigdemo/icons/smiles.xpm +39 -39
  59. data/samples/bigdemo/icons/smiley.xpm +42 -42
  60. data/samples/bigdemo/icons/stattext.xpm +24 -24
  61. data/samples/bigdemo/icons/test2.bmp +0 -0
  62. data/samples/bigdemo/icons/test2.xpm +79 -79
  63. data/samples/bigdemo/icons/text.xpm +27 -27
  64. data/samples/bigdemo/icons/tog1.xpm +38 -38
  65. data/samples/bigdemo/icons/tog2.xpm +38 -38
  66. data/samples/bigdemo/icons/wxwin16x16.xpm +25 -25
  67. data/samples/bigdemo/tips.txt +7 -7
  68. data/samples/bigdemo/utils.rb +11 -11
  69. data/samples/bigdemo/wxButton.rbw +64 -64
  70. data/samples/bigdemo/wxCalendarCtrl.rbw +60 -60
  71. data/samples/bigdemo/wxCheckBox.rbw +50 -50
  72. data/samples/bigdemo/wxCheckListBox.rbw +65 -75
  73. data/samples/bigdemo/wxChoice.rbw +47 -47
  74. data/samples/bigdemo/wxColourDialog.rbw +31 -31
  75. data/samples/bigdemo/wxComboBox.rbw +77 -77
  76. data/samples/bigdemo/wxDialog.rbw +74 -74
  77. data/samples/bigdemo/wxDirDialog.rbw +29 -29
  78. data/samples/bigdemo/wxFileDialog.rbw +37 -37
  79. data/samples/bigdemo/wxFileDialog_Save.rbw +35 -35
  80. data/samples/bigdemo/wxFindReplaceDialog.rbw +82 -82
  81. data/samples/bigdemo/wxFontDialog.rbw +173 -173
  82. data/samples/bigdemo/wxFrame.rbw +53 -53
  83. data/samples/bigdemo/wxGauge.rbw +71 -71
  84. data/samples/bigdemo/wxGrid.rbw +66 -66
  85. data/samples/bigdemo/wxListBox.rbw +140 -140
  86. data/samples/bigdemo/wxListCtrl_virtual.rbw +112 -107
  87. data/samples/bigdemo/wxMDIWindows.rbw +50 -50
  88. data/samples/bigdemo/wxMenu.rbw +236 -236
  89. data/samples/bigdemo/wxMessageDialog.rbw +27 -27
  90. data/samples/bigdemo/wxMultipleChoiceDialog.rbw +32 -32
  91. data/samples/bigdemo/wxNotebook.rbw +136 -136
  92. data/samples/bigdemo/wxProgressDialog.rbw +43 -43
  93. data/samples/bigdemo/wxRadioBox.rbw +72 -72
  94. data/samples/bigdemo/wxRadioButton.rbw +125 -125
  95. data/samples/bigdemo/wxSashWindow.rbw +2 -2
  96. data/samples/bigdemo/wxScrolledMessageDialog.rbw +57 -57
  97. data/samples/bigdemo/wxScrolledWindow.rbw +199 -199
  98. data/samples/bigdemo/wxSingleChoiceDialog.rbw +33 -33
  99. data/samples/bigdemo/wxSlider.rbw +42 -42
  100. data/samples/bigdemo/wxSpinButton.rbw +50 -50
  101. data/samples/bigdemo/wxSpinCtrl.rbw +51 -51
  102. data/samples/bigdemo/wxSplitterWindow.rbw +63 -63
  103. data/samples/bigdemo/wxStaticBitmap.rbw +51 -51
  104. data/samples/bigdemo/wxStaticText.rbw +55 -55
  105. data/samples/bigdemo/wxStatusBar.rbw +126 -126
  106. data/samples/bigdemo/wxTextCtrl.rbw +149 -149
  107. data/samples/bigdemo/wxTextEntryDialog.rbw +31 -31
  108. data/samples/bigdemo/wxToggleButton.rbw +49 -49
  109. data/samples/bigdemo/wxToolBar.rbw +131 -131
  110. data/samples/bigdemo/wxTreeCtrl.rbw +191 -190
  111. data/samples/calendar/calendar.rb +256 -271
  112. data/samples/caret/caret.rb +282 -282
  113. data/samples/caret/mondrian.xpm +44 -44
  114. data/samples/controls/controls.rb +1136 -1136
  115. data/samples/controls/get_item_sample.rb +87 -87
  116. data/samples/controls/icons/choice.xpm +27 -27
  117. data/samples/controls/icons/combo.xpm +27 -27
  118. data/samples/controls/icons/gauge.xpm +27 -27
  119. data/samples/controls/icons/list.xpm +27 -27
  120. data/samples/controls/icons/radio.xpm +27 -27
  121. data/samples/controls/icons/stattext.xpm +24 -24
  122. data/samples/controls/icons/text.xpm +27 -27
  123. data/samples/controls/mondrian.xpm +44 -44
  124. data/samples/dialogs/dialogs.rb +797 -723
  125. data/samples/dialogs/tips.txt +18 -18
  126. data/samples/drawing/images.rb +37 -37
  127. data/samples/etc/activation.rb +102 -102
  128. data/samples/etc/choice.rb +67 -67
  129. data/samples/etc/miniframe.rb +79 -79
  130. data/samples/etc/sash.rb +130 -130
  131. data/samples/etc/scrollwin.rb +110 -110
  132. data/samples/etc/system_settings.rb +252 -252
  133. data/samples/etc/toolbar_sizer_additem.rb +55 -0
  134. data/samples/etc/wizard.rb +74 -74
  135. data/samples/event/update_ui_event.rb +70 -0
  136. data/samples/grid/gridtablebase.rb +43 -29
  137. data/samples/listbook/listbook.rb +174 -174
  138. data/samples/listbook/listbook.xrc +370 -370
  139. data/samples/mdi/mdi.rb +85 -77
  140. data/samples/minimal/minimal.rb +77 -77
  141. data/samples/minimal/nothing.rb +16 -16
  142. data/samples/text/format-text-bold.png +0 -0
  143. data/samples/text/format-text-italic.png +0 -0
  144. data/samples/text/format-text-underline.png +0 -0
  145. data/samples/text/rich_textctrl.rb +98 -0
  146. data/samples/text/textctrl.rb +111 -113
  147. data/samples/text/unicode.rb +242 -242
  148. data/samples/text/utf8.txt +14 -14
  149. data/samples/treectrl/treectrl.rb +1166 -1174
  150. data/samples/xrc/samples.xrc +46 -46
  151. data/samples/xrc/xrc_sample.rb +76 -96
  152. metadata +15 -3
@@ -1,31 +1,31 @@
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
-
11
-
12
- module Demo
13
- def Demo.run(frame, nb, log)
14
- dlg = Wx::TextEntryDialog.new(frame, "What is your favorite programming language?", "Duh??", "Ruby")
15
- dlg.set_value("Ruby is the best!")
16
- if dlg.show_modal() == Wx::ID_OK
17
- log.write_text("You entered: " + dlg.get_value().to_s + "\n")
18
- end
19
- return nil
20
- end
21
-
22
- def Demo.overview
23
- return "This dialog allows the user to input text"
24
- end
25
- end
26
-
27
- if __FILE__ == $0
28
- run_solo_lib = File.join( File.dirname(__FILE__), 'run.rb')
29
- load run_solo_lib
30
- run File.basename($0)
31
- end
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
+
11
+
12
+ module Demo
13
+ def Demo.run(frame, nb, log)
14
+ dlg = Wx::TextEntryDialog.new(frame, "What is your favorite programming language?", "Duh??", "Ruby")
15
+ dlg.set_value("Ruby is the best!")
16
+ if dlg.show_modal() == Wx::ID_OK
17
+ log.write_text("You entered: " + dlg.get_value().to_s + "\n")
18
+ end
19
+ return nil
20
+ end
21
+
22
+ def Demo.overview
23
+ return "This dialog allows the user to input text"
24
+ end
25
+ end
26
+
27
+ if __FILE__ == $0
28
+ run_solo_lib = File.join( File.dirname(__FILE__), 'run.rb')
29
+ load run_solo_lib
30
+ run File.basename($0)
31
+ end
@@ -1,49 +1,49 @@
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
-
11
-
12
- class TestPanel < Wx::Panel
13
- def initialize(parent, log)
14
- super(parent, -1)
15
- @log = log
16
- panel = Wx::Panel.new(self, -1)
17
- buttons = Wx::BoxSizer.new(Wx::HORIZONTAL)
18
- "These are toggle buttons".split().each do |word|
19
- b = Wx::ToggleButton.new(panel, -1, word)
20
- evt_togglebutton(b.get_id()) {|event| on_toggle(event)}
21
- buttons.add(b, 0, Wx::ALL, 5)
22
- end
23
- panel.set_sizer(buttons)
24
- buttons.fit(panel)
25
- panel.move(Wx::Point.new(50,50))
26
- end
27
-
28
- def on_toggle(event)
29
- @log.write_text("Button " + event.get_id().to_s() + " toggled")
30
- end
31
- end
32
-
33
- module Demo
34
- def Demo.run(frame,nb,log)
35
- win = TestPanel.new(nb, log)
36
- return win
37
- end
38
-
39
- def Demo.overview
40
- "Wx::ToggleButton is a button that stays pressed when clicked by the user. In other words, it is similar to Wx::CheckBox in functionality but looks like a Wx::Button."
41
- end
42
- end
43
-
44
-
45
- if __FILE__ == $0
46
- run_solo_lib = File.join( File.dirname(__FILE__), 'run.rb')
47
- load run_solo_lib
48
- run File.basename($0)
49
- end
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
+
11
+
12
+ class TestPanel < Wx::Panel
13
+ def initialize(parent, log)
14
+ super(parent, -1)
15
+ @log = log
16
+ panel = Wx::Panel.new(self, -1)
17
+ buttons = Wx::BoxSizer.new(Wx::HORIZONTAL)
18
+ "These are toggle buttons".split().each do |word|
19
+ b = Wx::ToggleButton.new(panel, -1, word)
20
+ evt_togglebutton(b.get_id()) {|event| on_toggle(event)}
21
+ buttons.add(b, 0, Wx::ALL, 5)
22
+ end
23
+ panel.set_sizer(buttons)
24
+ buttons.fit(panel)
25
+ panel.move(Wx::Point.new(50,50))
26
+ end
27
+
28
+ def on_toggle(event)
29
+ @log.write_text("Button " + event.get_id().to_s() + " toggled")
30
+ end
31
+ end
32
+
33
+ module Demo
34
+ def Demo.run(frame,nb,log)
35
+ win = TestPanel.new(nb, log)
36
+ return win
37
+ end
38
+
39
+ def Demo.overview
40
+ "Wx::ToggleButton is a button that stays pressed when clicked by the user. In other words, it is similar to Wx::CheckBox in functionality but looks like a Wx::Button."
41
+ end
42
+ end
43
+
44
+
45
+ if __FILE__ == $0
46
+ run_solo_lib = File.join( File.dirname(__FILE__), 'run.rb')
47
+ load run_solo_lib
48
+ run File.basename($0)
49
+ end
@@ -1,131 +1,131 @@
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
-
11
-
12
- class TestToolBar < Wx::Frame
13
- # returns a Bitmap icon object
14
- def xpm_bitmap(base_name)
15
-
16
- xpm_file = File.join( File.dirname(__FILE__), 'icons', base_name )
17
- Wx::Bitmap.new(xpm_file, Wx::BITMAP_TYPE_XPM)
18
- end
19
-
20
- def initialize(parent, log)
21
- super(parent, -1, "Test ToolBar", Wx::DEFAULT_POSITION, Wx::Size.new(500,300))
22
- @log = log
23
- @timer = nil
24
- evt_close {|event| on_close_window(event)}
25
-
26
- Wx::Window.new(self, -1).set_background_colour(Wx::WHITE)
27
-
28
- tb = create_tool_bar(Wx::TB_HORIZONTAL | Wx::NO_BORDER | Wx::TB_FLAT | Wx::TB_TEXT)
29
-
30
- create_status_bar()
31
- tb.add_tool(10, "New", xpm_bitmap('new.xpm'), "Long help for New")
32
- evt_tool(10) {|event| on_tool_click(event)}
33
- evt_tool_rclicked(10) {|event| on_tool_rclick(event)}
34
-
35
- tb.add_tool(20, "Open", xpm_bitmap('open.xpm'), "Long help for Open")
36
- evt_tool(20) {|event| on_tool_click(event)}
37
- evt_tool_rclicked(20) {|event| on_tool_rclick(event)}
38
-
39
- tb.add_separator()
40
-
41
- tb.add_tool(30, "Copy", xpm_bitmap('copy.xpm'), "Long help for Copy")
42
- evt_tool(30) {|event| on_tool_click(event)}
43
- evt_tool_rclicked(30) {|event| on_tool_rclick(event)}
44
-
45
- tb.add_tool(40, "Paste", xpm_bitmap('paste.xpm'), "Long help for Paste")
46
- evt_tool(40) {|event| on_tool_click(event)}
47
- evt_tool_rclicked(40) {|event| on_tool_rclick(event)}
48
-
49
- tb.add_separator()
50
-
51
- tb.add_check_tool(50, "", xpm_bitmap('tog1.xpm'),
52
- Wx::NULL_BITMAP, "Toggle this")
53
- evt_tool(50) {|event| on_tool_click(event)}
54
-
55
- evt_tool_enter(-1) {|event| on_tool_enter(event)}
56
- evt_tool_rclicked(-1) {|event| on_tool_rclick(event)}
57
- evt_timer(5000) {|event| on_clear_sb(event)}
58
-
59
- tb.add_separator()
60
- cbID = 5000
61
- choices = ["", "This", "is a", "wxComboBox"]
62
-
63
- tb.add_control(Wx::ComboBox.new(tb, cbID, "", Wx::DEFAULT_POSITION, Wx::Size.new(150,-1), choices,
64
- Wx::CB_DROPDOWN))
65
- evt_combobox(cbID) {|event| on_combo(event)}
66
- tb.add_control(Wx::TextCtrl.new(tb, -1, "ToolBar controls!!", Wx::DEFAULT_POSITION, Wx::Size.new(150,-1)))
67
-
68
- tb.realize()
69
- end
70
-
71
- def on_tool_click(event)
72
- @log.write_text("tool " + event.get_id().to_s() + " clicked")
73
- tb = get_tool_bar()
74
- tb.enable_tool(10, tb.get_tool_enabled(10) ? false : true)
75
- end
76
-
77
- def on_tool_rclick(event)
78
- @log.write_text("tool " + event.get_id().to_s() + " right-clicked")
79
- end
80
-
81
- def on_combo(event)
82
- @log.write_text("combobox item selected " + event.get_string())
83
- end
84
-
85
- def on_tool_enter(event)
86
- @log.write_text("on_tool_enter: " + event.get_id().to_s + ", " + event.get_int().to_s())
87
- if @timer == nil
88
- @timer = Wx::Timer.new(self, 5000)
89
- end
90
- if @timer != nil
91
- @timer.stop()
92
- end
93
- @timer.start(2000)
94
- @timer.stop()
95
- @timer.start(2000)
96
- event.skip()
97
- end
98
-
99
- def on_clear_sb(event) # called for the timer event handler
100
- set_status_text("")
101
- @timer.stop()
102
- @timer = nil
103
- end
104
-
105
- def on_close_window(event)
106
- if @timer != nil
107
- @timer.stop()
108
- @timer = nil
109
- end
110
- destroy()
111
- end
112
- end
113
-
114
- module Demo
115
- def Demo.run(frame,nb,log)
116
- win = TestToolBar.new(frame, log)
117
- frame.otherWin = win
118
- win.show()
119
- end
120
-
121
- def Demo.overview
122
- "A toolbar is that familiar little rectangular strip below the menubar that hosts various 'buttons', which are usually shortcuts to menu commands."
123
- end
124
- end
125
-
126
-
127
- if __FILE__ == $0
128
- run_solo_lib = File.join( File.dirname(__FILE__), 'run.rb')
129
- load run_solo_lib
130
- run File.basename($0)
131
- end
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
+
11
+
12
+ class TestToolBar < Wx::Frame
13
+ # returns a Bitmap icon object
14
+ def xpm_bitmap(base_name)
15
+
16
+ xpm_file = File.join( File.dirname(__FILE__), 'icons', base_name )
17
+ Wx::Bitmap.new(xpm_file, Wx::BITMAP_TYPE_XPM)
18
+ end
19
+
20
+ def initialize(parent, log)
21
+ super(parent, -1, "Test ToolBar", Wx::DEFAULT_POSITION, Wx::Size.new(500,300))
22
+ @log = log
23
+ @timer = nil
24
+ evt_close {|event| on_close_window(event)}
25
+
26
+ Wx::Window.new(self, -1).set_background_colour(Wx::WHITE)
27
+
28
+ tb = create_tool_bar(Wx::TB_HORIZONTAL | Wx::NO_BORDER | Wx::TB_FLAT | Wx::TB_TEXT)
29
+
30
+ create_status_bar()
31
+ tb.add_tool(10, "New", xpm_bitmap('new.xpm'), "Long help for New")
32
+ evt_tool(10) {|event| on_tool_click(event)}
33
+ evt_tool_rclicked(10) {|event| on_tool_rclick(event)}
34
+
35
+ tb.add_tool(20, "Open", xpm_bitmap('open.xpm'), "Long help for Open")
36
+ evt_tool(20) {|event| on_tool_click(event)}
37
+ evt_tool_rclicked(20) {|event| on_tool_rclick(event)}
38
+
39
+ tb.add_separator()
40
+
41
+ tb.add_tool(30, "Copy", xpm_bitmap('copy.xpm'), "Long help for Copy")
42
+ evt_tool(30) {|event| on_tool_click(event)}
43
+ evt_tool_rclicked(30) {|event| on_tool_rclick(event)}
44
+
45
+ tb.add_tool(40, "Paste", xpm_bitmap('paste.xpm'), "Long help for Paste")
46
+ evt_tool(40) {|event| on_tool_click(event)}
47
+ evt_tool_rclicked(40) {|event| on_tool_rclick(event)}
48
+
49
+ tb.add_separator()
50
+
51
+ tb.add_check_tool(50, "", xpm_bitmap('tog1.xpm'),
52
+ Wx::NULL_BITMAP, "Toggle this")
53
+ evt_tool(50) {|event| on_tool_click(event)}
54
+
55
+ evt_tool_enter(-1) {|event| on_tool_enter(event)}
56
+ evt_tool_rclicked(-1) {|event| on_tool_rclick(event)}
57
+ evt_timer(5000) {|event| on_clear_sb(event)}
58
+
59
+ tb.add_separator()
60
+ cbID = 5000
61
+ choices = ["", "This", "is a", "wxComboBox"]
62
+
63
+ tb.add_control(Wx::ComboBox.new(tb, cbID, "", Wx::DEFAULT_POSITION, Wx::Size.new(150,-1), choices,
64
+ Wx::CB_DROPDOWN))
65
+ evt_combobox(cbID) {|event| on_combo(event)}
66
+ tb.add_control(Wx::TextCtrl.new(tb, -1, "ToolBar controls!!", Wx::DEFAULT_POSITION, Wx::Size.new(150,-1)))
67
+
68
+ tb.realize()
69
+ end
70
+
71
+ def on_tool_click(event)
72
+ @log.write_text("tool " + event.get_id().to_s() + " clicked")
73
+ tb = get_tool_bar()
74
+ tb.enable_tool(10, tb.get_tool_enabled(10) ? false : true)
75
+ end
76
+
77
+ def on_tool_rclick(event)
78
+ @log.write_text("tool " + event.get_id().to_s() + " right-clicked")
79
+ end
80
+
81
+ def on_combo(event)
82
+ @log.write_text("combobox item selected " + event.get_string())
83
+ end
84
+
85
+ def on_tool_enter(event)
86
+ @log.write_text("on_tool_enter: " + event.get_id().to_s + ", " + event.get_int().to_s())
87
+ if @timer == nil
88
+ @timer = Wx::Timer.new(self, 5000)
89
+ end
90
+ if @timer != nil
91
+ @timer.stop()
92
+ end
93
+ @timer.start(2000)
94
+ @timer.stop()
95
+ @timer.start(2000)
96
+ event.skip()
97
+ end
98
+
99
+ def on_clear_sb(event) # called for the timer event handler
100
+ set_status_text("")
101
+ @timer.stop()
102
+ @timer = nil
103
+ end
104
+
105
+ def on_close_window(event)
106
+ if @timer != nil
107
+ @timer.stop()
108
+ @timer = nil
109
+ end
110
+ destroy()
111
+ end
112
+ end
113
+
114
+ module Demo
115
+ def Demo.run(frame,nb,log)
116
+ win = TestToolBar.new(frame, log)
117
+ frame.otherWin = win
118
+ win.show()
119
+ end
120
+
121
+ def Demo.overview
122
+ "A toolbar is that familiar little rectangular strip below the menubar that hosts various 'buttons', which are usually shortcuts to menu commands."
123
+ end
124
+ end
125
+
126
+
127
+ if __FILE__ == $0
128
+ run_solo_lib = File.join( File.dirname(__FILE__), 'run.rb')
129
+ load run_solo_lib
130
+ run File.basename($0)
131
+ end
@@ -1,190 +1,191 @@
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
-
11
-
12
- class MyTreeCtrl < Wx::TreeCtrl
13
- def initialize(parent, id, pos, size, style, log)
14
- super(parent,id,pos,size,style)
15
- @log = log
16
-
17
- evt_left_dclick {|event| on_left_dclick(event)}
18
- evt_right_down {|event| on_right_click(event)}
19
- evt_right_up {|event| on_right_up(event)}
20
- end
21
-
22
- def on_left_dclick(event)
23
- pt = Wx::Point.new(event.get_x(), event.get_y())
24
-
25
- end
26
-
27
- def on_right_click(event)
28
- pt = Wx::Point.new(event.get_x(), event.get_y())
29
- id = hit_test(pt)
30
- if id
31
- @log.write_text("on_right_click: ")# + @tree.get_item_text(id))
32
- end
33
- end
34
-
35
- def on_right_up(event)
36
- pt = Wx::Point.new(event.get_x(), event.get_y())
37
- id = hit_test(pt)
38
- if id
39
- @log.write_text("on_right_up: ")#+ @tree.get_item_text(id) + " (manually starting label edit)")
40
- end
41
- end
42
-
43
- def on_compare_items(item1, item2)
44
- t1 = get_item_text(item1)
45
- t2 = get_item_text(item2)
46
- @log.write_text('compare: ' + t1 + ' <> ' + t2)
47
- if t1 < t2 then return -1 end
48
- if t1 == t2 then return 0 end
49
- return 1
50
- end
51
- end
52
-
53
- class TestTreeCtrlPanel < Wx::Panel
54
- def initialize(parent, log)
55
- # Use the WANTS_CHARS style so the panel doesn't eat the Return key
56
- super(parent, -1, Wx::DEFAULT_POSITION, Wx::DEFAULT_SIZE, Wx::WANTS_CHARS)
57
- evt_size {|event| on_size(event)}
58
-
59
- @log = log
60
- tID = 5000
61
-
62
- @tree = MyTreeCtrl.new(self, tID, Wx::DEFAULT_POSITION, Wx::DEFAULT_SIZE, Wx::TR_HAS_BUTTONS | Wx::TR_EDIT_LABELS, @log)
63
-
64
- isz = Wx::Size.new(16,16)
65
- il = Wx::ImageList.new(16,16)
66
- bm = Wx::Bitmap.new
67
- bm.copy_from_icon(Wx::ArtProvider::get_icon(Wx::ART_FOLDER, Wx::ART_OTHER, isz))
68
- fldridx = il.add(bm)
69
- bm.copy_from_icon(Wx::ArtProvider::get_icon(Wx::ART_FILE_OPEN, Wx::ART_OTHER, isz))
70
- fldropenidx = il.add(bm)
71
- bm.copy_from_icon(Wx::ArtProvider::get_icon(Wx::ART_FILE_OPEN, Wx::ART_OTHER, isz))
72
- fileidx = il.add(bm)
73
- bmp_file = File.join(File.dirname(__FILE__), 'icons', 'wxwin16x16.xpm')
74
- smileidx = il.add(Wx::Bitmap.new(bmp_file))
75
-
76
- @tree.set_image_list(il)
77
- @il = il
78
-
79
- @root = @tree.add_root("The Root Item")
80
- @tree.set_item_image(@root, fldridx, Wx::TREE_ITEM_ICON_NORMAL)
81
- @tree.set_item_image(@root, fldropenidx, Wx::TREE_ITEM_ICON_EXPANDED)
82
-
83
- 0.upto(15) do |x|
84
- child = @tree.append_item(@root, "Item " + x.to_s())
85
- @tree.set_item_image(child, fldridx, Wx::TREE_ITEM_ICON_NORMAL)
86
- @tree.set_item_image(child, fldropenidx, Wx::TREE_ITEM_ICON_EXPANDED)
87
- 0.upto(4) do |y|
88
- last = @tree.append_item(child, "item " + x.to_s() + "-" + (?a + y).chr)
89
- @tree.set_item_image(last, fldridx, Wx::TREE_ITEM_ICON_NORMAL)
90
- @tree.set_item_image(last, fldropenidx, Wx::TREE_ITEM_ICON_EXPANDED)
91
- 0.upto(4) do |z|
92
- item = @tree.append_item(last, "item " + x.to_s() + "-" + (?a + y).chr + "-" + z.to_s())
93
- @tree.set_item_image(item, fileidx, Wx::TREE_ITEM_ICON_NORMAL)
94
- @tree.set_item_image(item, smileidx, Wx::TREE_ITEM_ICON_SELECTED)
95
- end
96
- end
97
- end
98
-
99
- @tree.expand(@root)
100
- evt_tree_item_expanded(tID) {|event| on_item_expanded(event)}
101
- evt_tree_item_collapsed(tID) {|event| on_item_collapsed(event)}
102
- evt_tree_sel_changed(tID) {|event| on_sel_changed(event)}
103
- evt_tree_begin_label_edit(tID) {|event| on_begin_edit(event)}
104
- evt_tree_end_label_edit(tID) {|event| on_end_edit(event)}
105
- evt_tree_item_activated(tID) {|event| on_activate(event)}
106
-
107
-
108
- end
109
-
110
-
111
- def on_begin_edit(event)
112
- @log.write_text("on_begin_edit")
113
- # show how to prevent edit
114
- if @tree.get_item_text(event.get_item()) == "The Root Item"
115
- @log.write_text("You can't edit this one...")
116
-
117
- # Let's just see what's visible of its children
118
- cookie = 0
119
- root = event.get_item()
120
- child, cookie = @tree.get_first_child(root)
121
- while child != nil
122
- @log.write_text("Child [" + @tree.get_item_text(child) + "] visible = " + @tree.is_visible(child).to_s())
123
- child,cookie = @tree.get_next_child(root, cookie)
124
- end
125
- event.veto()
126
- end
127
- end
128
-
129
- def on_end_edit(event)
130
- @log.write_text("on_end_edit")
131
- #show how to reject edit, we'll not allow any digits
132
- nums = ("0".."9").to_a()
133
- x = event.get_label()
134
- x.each_byte do |byte|
135
- if nums.include?(byte.chr())
136
- @log.write_text("You can't enter digits...")
137
- event.veto()
138
- return
139
- end
140
- end
141
- end
142
-
143
- def on_size(event)
144
- size = get_client_size()
145
- @tree.set_dimensions(0,0,size.x, size.y)
146
- end
147
-
148
- def on_item_expanded(event)
149
- item = event.get_item()
150
- @log.write_text("on_item_expanded: " + @tree.get_item_text(item))
151
- end
152
-
153
- def on_item_collapsed(event)
154
- item = event.get_item()
155
- @log.write_text("on_item_collapsed: " + @tree.get_item_text(item))
156
- end
157
-
158
- def on_sel_changed(event)
159
- @item = event.get_item()
160
- if @item.nonzero?
161
- @log.write_text("on_sel_changed: " + @tree.get_item_text(@item))
162
- # if Wx::PLATFORM == "WXMSW"
163
- #@log.write_text("BoundingRect: " + @tree.get_bounding_rect(@item))
164
- #end
165
- end
166
- event.skip()
167
- end
168
-
169
- def on_activate(event)
170
- @log.write_text("on_activate: " + @tree.get_item_text(@item))
171
- end
172
- end
173
-
174
- module Demo
175
- def Demo.run(frame, nb, log)
176
- win = TestTreeCtrlPanel.new(nb, log)
177
- return win
178
- end
179
-
180
- def Demo.overview
181
- return ""
182
- end
183
- end
184
-
185
-
186
- if __FILE__ == $0
187
- run_solo_lib = File.join( File.dirname(__FILE__), 'run.rb')
188
- load run_solo_lib
189
- run File.basename($0)
190
- end
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
+
11
+
12
+ class MyTreeCtrl < Wx::TreeCtrl
13
+ def initialize(parent, id, pos, size, style, log)
14
+ super(parent,id,pos,size,style)
15
+ @log = log
16
+
17
+ evt_left_dclick {|event| on_left_dclick(event)}
18
+ evt_right_down {|event| on_right_click(event)}
19
+ evt_right_up {|event| on_right_up(event)}
20
+ end
21
+
22
+ def on_left_dclick(event)
23
+ pt = Wx::Point.new(event.get_x(), event.get_y())
24
+
25
+ end
26
+
27
+ def on_right_click(event)
28
+ pt = Wx::Point.new(event.get_x(), event.get_y())
29
+ id = hit_test(pt)
30
+ if id
31
+ @log.write_text("on_right_click: ")# + @tree.get_item_text(id))
32
+ end
33
+ end
34
+
35
+ def on_right_up(event)
36
+ pt = Wx::Point.new(event.get_x(), event.get_y())
37
+ id = hit_test(pt)
38
+ if id
39
+ @log.write_text("on_right_up: ")#+ @tree.get_item_text(id) + " (manually starting label edit)")
40
+ end
41
+ end
42
+
43
+ def on_compare_items(item1, item2)
44
+ t1 = get_item_text(item1)
45
+ t2 = get_item_text(item2)
46
+ @log.write_text('compare: ' + t1 + ' <> ' + t2)
47
+ if t1 < t2 then return -1 end
48
+ if t1 == t2 then return 0 end
49
+ return 1
50
+ end
51
+ end
52
+
53
+ class TestTreeCtrlPanel < Wx::Panel
54
+ def initialize(parent, log)
55
+ # Use the WANTS_CHARS style so the panel doesn't eat the Return key
56
+ super(parent, -1, Wx::DEFAULT_POSITION, Wx::DEFAULT_SIZE, Wx::WANTS_CHARS)
57
+ evt_size {|event| on_size(event)}
58
+
59
+ @log = log
60
+ tID = 5000
61
+
62
+ @tree = MyTreeCtrl.new(self, tID, Wx::DEFAULT_POSITION, Wx::DEFAULT_SIZE, Wx::TR_HAS_BUTTONS | Wx::TR_EDIT_LABELS, @log)
63
+
64
+ isz = Wx::Size.new(16,16)
65
+ il = Wx::ImageList.new(16,16)
66
+ bm = Wx::Bitmap.new
67
+ bm.copy_from_icon(Wx::ArtProvider::get_icon(Wx::ART_FOLDER, Wx::ART_OTHER, isz))
68
+ fldridx = il.add(bm)
69
+ bm.copy_from_icon(Wx::ArtProvider::get_icon(Wx::ART_FILE_OPEN, Wx::ART_OTHER, isz))
70
+ fldropenidx = il.add(bm)
71
+ bm.copy_from_icon(Wx::ArtProvider::get_icon(Wx::ART_FILE_OPEN, Wx::ART_OTHER, isz))
72
+ fileidx = il.add(bm)
73
+ bmp_file = File.join(File.dirname(__FILE__), 'icons', 'wxwin16x16.xpm')
74
+ smileidx = il.add(Wx::Bitmap.new(bmp_file))
75
+
76
+ @tree.set_image_list(il)
77
+ @il = il
78
+
79
+ @root = @tree.add_root("The Root Item")
80
+ @tree.set_item_image(@root, fldridx, Wx::TREE_ITEM_ICON_NORMAL)
81
+ @tree.set_item_image(@root, fldropenidx, Wx::TREE_ITEM_ICON_EXPANDED)
82
+ 0.upto(15) do |x|
83
+ child = @tree.append_item(@root, "Item " + x.to_s())
84
+ @tree.set_item_image(child, fldridx, Wx::TREE_ITEM_ICON_NORMAL)
85
+ @tree.set_item_image(child, fldropenidx, Wx::TREE_ITEM_ICON_EXPANDED)
86
+ character = "a"
87
+ 0.upto(4) do |y|
88
+ last = @tree.append_item(child, "item " + x.to_s() + "-" + character)
89
+ @tree.set_item_image(last, fldridx, Wx::TREE_ITEM_ICON_NORMAL)
90
+ @tree.set_item_image(last, fldropenidx, Wx::TREE_ITEM_ICON_EXPANDED)
91
+ 0.upto(4) do |z|
92
+ item = @tree.append_item(last, "item " + x.to_s() + "-" + character + "-" + z.to_s())
93
+ @tree.set_item_image(item, fileidx, Wx::TREE_ITEM_ICON_NORMAL)
94
+ @tree.set_item_image(item, smileidx, Wx::TREE_ITEM_ICON_SELECTED)
95
+ end
96
+ character.succ!
97
+ end
98
+ end
99
+
100
+ @tree.expand(@root)
101
+ evt_tree_item_expanded(tID) {|event| on_item_expanded(event)}
102
+ evt_tree_item_collapsed(tID) {|event| on_item_collapsed(event)}
103
+ evt_tree_sel_changed(tID) {|event| on_sel_changed(event)}
104
+ evt_tree_begin_label_edit(tID) {|event| on_begin_edit(event)}
105
+ evt_tree_end_label_edit(tID) {|event| on_end_edit(event)}
106
+ evt_tree_item_activated(tID) {|event| on_activate(event)}
107
+
108
+
109
+ end
110
+
111
+
112
+ def on_begin_edit(event)
113
+ @log.write_text("on_begin_edit")
114
+ # show how to prevent edit
115
+ if @tree.get_item_text(event.get_item()) == "The Root Item"
116
+ @log.write_text("You can't edit this one...")
117
+
118
+ # Let's just see what's visible of its children
119
+ cookie = 0
120
+ root = event.get_item()
121
+ child, cookie = @tree.get_first_child(root)
122
+ while child != nil
123
+ @log.write_text("Child [" + @tree.get_item_text(child) + "] visible = " + @tree.is_visible(child).to_s())
124
+ child,cookie = @tree.get_next_child(root, cookie)
125
+ end
126
+ event.veto()
127
+ end
128
+ end
129
+
130
+ def on_end_edit(event)
131
+ @log.write_text("on_end_edit")
132
+ #show how to reject edit, we'll not allow any digits
133
+ nums = ("0".."9").to_a()
134
+ x = event.get_label()
135
+ x.each_byte do |byte|
136
+ if nums.include?(byte.chr())
137
+ @log.write_text("You can't enter digits...")
138
+ event.veto()
139
+ return
140
+ end
141
+ end
142
+ end
143
+
144
+ def on_size(event)
145
+ size = get_client_size()
146
+ @tree.set_dimensions(0,0,size.x, size.y)
147
+ end
148
+
149
+ def on_item_expanded(event)
150
+ item = event.get_item()
151
+ @log.write_text("on_item_expanded: " + @tree.get_item_text(item))
152
+ end
153
+
154
+ def on_item_collapsed(event)
155
+ item = event.get_item()
156
+ @log.write_text("on_item_collapsed: " + @tree.get_item_text(item))
157
+ end
158
+
159
+ def on_sel_changed(event)
160
+ @item = event.get_item()
161
+ if @item.nonzero?
162
+ @log.write_text("on_sel_changed: " + @tree.get_item_text(@item))
163
+ # if Wx::PLATFORM == "WXMSW"
164
+ #@log.write_text("BoundingRect: " + @tree.get_bounding_rect(@item))
165
+ #end
166
+ end
167
+ event.skip()
168
+ end
169
+
170
+ def on_activate(event)
171
+ @log.write_text("on_activate: " + @tree.get_item_text(@item))
172
+ end
173
+ end
174
+
175
+ module Demo
176
+ def Demo.run(frame, nb, log)
177
+ win = TestTreeCtrlPanel.new(nb, log)
178
+ return win
179
+ end
180
+
181
+ def Demo.overview
182
+ return ""
183
+ end
184
+ end
185
+
186
+
187
+ if __FILE__ == $0
188
+ run_solo_lib = File.join( File.dirname(__FILE__), 'run.rb')
189
+ load run_solo_lib
190
+ run File.basename($0)
191
+ end