wxruby 1.9.0-i686-darwin8.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (199) hide show
  1. data/lib/wx.rb +35 -0
  2. data/lib/wx/classes/app.rb +25 -0
  3. data/lib/wx/classes/artprovider.rb +31 -0
  4. data/lib/wx/classes/bitmap.rb +23 -0
  5. data/lib/wx/classes/choice.rb +4 -0
  6. data/lib/wx/classes/clientdc.rb +13 -0
  7. data/lib/wx/classes/colour.rb +47 -0
  8. data/lib/wx/classes/combobox.rb +4 -0
  9. data/lib/wx/classes/evthandler.rb +824 -0
  10. data/lib/wx/classes/font.rb +118 -0
  11. data/lib/wx/classes/grid.rb +130 -0
  12. data/lib/wx/classes/helpcontroller.rb +5 -0
  13. data/lib/wx/classes/htmlhelpcontroller.rb +5 -0
  14. data/lib/wx/classes/htmlwindow.rb +6 -0
  15. data/lib/wx/classes/icon.rb +14 -0
  16. data/lib/wx/classes/image.rb +14 -0
  17. data/lib/wx/classes/listbox.rb +4 -0
  18. data/lib/wx/classes/locale.rb +28 -0
  19. data/lib/wx/classes/object.rb +7 -0
  20. data/lib/wx/classes/paintdc.rb +12 -0
  21. data/lib/wx/classes/point.rb +5 -0
  22. data/lib/wx/classes/previewframe.rb +13 -0
  23. data/lib/wx/classes/rect.rb +5 -0
  24. data/lib/wx/classes/size.rb +5 -0
  25. data/lib/wx/classes/texturlevent.rb +6 -0
  26. data/lib/wx/classes/timer.rb +69 -0
  27. data/lib/wx/classes/window.rb +38 -0
  28. data/lib/wx/classes/xmlresource.rb +16 -0
  29. data/lib/wx/version.rb +3 -0
  30. data/lib/wxruby2.bundle +0 -0
  31. data/samples/SAMPLES-LICENSE.TXT +18 -0
  32. data/samples/aui/aui.rb +1352 -0
  33. data/samples/bigdemo/About.rbw +39 -0
  34. data/samples/bigdemo/ColorPanel.rbw +25 -0
  35. data/samples/bigdemo/GridSimple.rbw +80 -0
  36. data/samples/bigdemo/MDIDemo.rbw +59 -0
  37. data/samples/bigdemo/PopupMenu.rbw +151 -0
  38. data/samples/bigdemo/ShapedWindow.rbw +135 -0
  39. data/samples/bigdemo/Sizers.rbw +545 -0
  40. data/samples/bigdemo/bigdemo.rb +826 -0
  41. data/samples/bigdemo/demoTemplate.rbw +37 -0
  42. data/samples/bigdemo/helpfile.htb +0 -0
  43. data/samples/bigdemo/icons/Test 015.jpg +0 -0
  44. data/samples/bigdemo/icons/Test 015.png +0 -0
  45. data/samples/bigdemo/icons/choice.bmp +0 -0
  46. data/samples/bigdemo/icons/choice.xpm +27 -0
  47. data/samples/bigdemo/icons/combo.bmp +0 -0
  48. data/samples/bigdemo/icons/combo.xpm +27 -0
  49. data/samples/bigdemo/icons/copy.xpm +25 -0
  50. data/samples/bigdemo/icons/cut.xpm +24 -0
  51. data/samples/bigdemo/icons/gauge.bmp +0 -0
  52. data/samples/bigdemo/icons/gauge.xpm +27 -0
  53. data/samples/bigdemo/icons/help.xpm +25 -0
  54. data/samples/bigdemo/icons/list.bmp +0 -0
  55. data/samples/bigdemo/icons/list.xpm +27 -0
  56. data/samples/bigdemo/icons/mondrian.ico +0 -0
  57. data/samples/bigdemo/icons/mondrian.xpm +44 -0
  58. data/samples/bigdemo/icons/new.xpm +24 -0
  59. data/samples/bigdemo/icons/ogl.ico +0 -0
  60. data/samples/bigdemo/icons/ogl.xpm +45 -0
  61. data/samples/bigdemo/icons/open.xpm +26 -0
  62. data/samples/bigdemo/icons/paste.bmp +0 -0
  63. data/samples/bigdemo/icons/paste.xpm +38 -0
  64. data/samples/bigdemo/icons/pointy.png +0 -0
  65. data/samples/bigdemo/icons/preview.xpm +26 -0
  66. data/samples/bigdemo/icons/print.xpm +26 -0
  67. data/samples/bigdemo/icons/radio.bmp +0 -0
  68. data/samples/bigdemo/icons/radio.xpm +27 -0
  69. data/samples/bigdemo/icons/robert.xpm +415 -0
  70. data/samples/bigdemo/icons/ruby.png +0 -0
  71. data/samples/bigdemo/icons/sashtest.ico +0 -0
  72. data/samples/bigdemo/icons/save.xpm +25 -0
  73. data/samples/bigdemo/icons/smiles.bmp +0 -0
  74. data/samples/bigdemo/icons/smiles.xpm +39 -0
  75. data/samples/bigdemo/icons/smiley.ico +0 -0
  76. data/samples/bigdemo/icons/smiley.xpm +42 -0
  77. data/samples/bigdemo/icons/stattext.xpm +24 -0
  78. data/samples/bigdemo/icons/test2.bmp +0 -0
  79. data/samples/bigdemo/icons/test2.png +0 -0
  80. data/samples/bigdemo/icons/test2.xpm +79 -0
  81. data/samples/bigdemo/icons/text.bmp +0 -0
  82. data/samples/bigdemo/icons/text.xpm +27 -0
  83. data/samples/bigdemo/icons/tog1.bmp +0 -0
  84. data/samples/bigdemo/icons/tog1.xpm +38 -0
  85. data/samples/bigdemo/icons/tog2.bmp +0 -0
  86. data/samples/bigdemo/icons/tog2.xpm +38 -0
  87. data/samples/bigdemo/icons/wxwin.ico +0 -0
  88. data/samples/bigdemo/icons/wxwin16x16.png +0 -0
  89. data/samples/bigdemo/icons/wxwin16x16.xpm +25 -0
  90. data/samples/bigdemo/icons/wxwin32x32.png +0 -0
  91. data/samples/bigdemo/icons/wxwin48x48.png +0 -0
  92. data/samples/bigdemo/run.rb +94 -0
  93. data/samples/bigdemo/tips.txt +7 -0
  94. data/samples/bigdemo/utils.rb +12 -0
  95. data/samples/bigdemo/wxArtProvider.rbw +285 -0
  96. data/samples/bigdemo/wxBitmapButton.rbw +64 -0
  97. data/samples/bigdemo/wxButton.rbw +66 -0
  98. data/samples/bigdemo/wxCalendarCtrl.rbw +72 -0
  99. data/samples/bigdemo/wxCheckBox.rbw +52 -0
  100. data/samples/bigdemo/wxCheckListBox.rbw +77 -0
  101. data/samples/bigdemo/wxChoice.rbw +49 -0
  102. data/samples/bigdemo/wxChoicebook.rbw +80 -0
  103. data/samples/bigdemo/wxColourDialog.rbw +34 -0
  104. data/samples/bigdemo/wxComboBox.rbw +79 -0
  105. data/samples/bigdemo/wxCursor.rbw +140 -0
  106. data/samples/bigdemo/wxDialog.rbw +92 -0
  107. data/samples/bigdemo/wxDirDialog.rbw +32 -0
  108. data/samples/bigdemo/wxDragImage.rbw +74 -0
  109. data/samples/bigdemo/wxFileDialog.rbw +39 -0
  110. data/samples/bigdemo/wxFileDialog_Save.rbw +38 -0
  111. data/samples/bigdemo/wxFindReplaceDialog.rbw +85 -0
  112. data/samples/bigdemo/wxFontDialog.rbw +176 -0
  113. data/samples/bigdemo/wxFrame.rbw +55 -0
  114. data/samples/bigdemo/wxGauge.rbw +73 -0
  115. data/samples/bigdemo/wxGenericDirCtrl.rbw +78 -0
  116. data/samples/bigdemo/wxGrid.rbw +68 -0
  117. data/samples/bigdemo/wxHtmlHelpController.rbw +57 -0
  118. data/samples/bigdemo/wxListBox.rbw +142 -0
  119. data/samples/bigdemo/wxListCtrl_virtual.rbw +109 -0
  120. data/samples/bigdemo/wxMDIWindows.rbw +52 -0
  121. data/samples/bigdemo/wxMenu.rbw +238 -0
  122. data/samples/bigdemo/wxMessageDialog.rbw +30 -0
  123. data/samples/bigdemo/wxMiniFrame.rbw +74 -0
  124. data/samples/bigdemo/wxMultipleChoiceDialog.rbw +34 -0
  125. data/samples/bigdemo/wxNotebook.rbw +138 -0
  126. data/samples/bigdemo/wxProgressDialog.rbw +45 -0
  127. data/samples/bigdemo/wxRadioBox.rbw +74 -0
  128. data/samples/bigdemo/wxRadioButton.rbw +127 -0
  129. data/samples/bigdemo/wxSashWindow.rbw +155 -0
  130. data/samples/bigdemo/wxScrolledMessageDialog.rbw +59 -0
  131. data/samples/bigdemo/wxScrolledWindow.rbw +196 -0
  132. data/samples/bigdemo/wxSingleChoiceDialog.rbw +35 -0
  133. data/samples/bigdemo/wxSlider.rbw +44 -0
  134. data/samples/bigdemo/wxSpinButton.rbw +52 -0
  135. data/samples/bigdemo/wxSpinCtrl.rbw +53 -0
  136. data/samples/bigdemo/wxSplitterWindow.rbw +65 -0
  137. data/samples/bigdemo/wxStaticBitmap.rbw +53 -0
  138. data/samples/bigdemo/wxStaticText.rbw +57 -0
  139. data/samples/bigdemo/wxStatusBar.rbw +128 -0
  140. data/samples/bigdemo/wxTextCtrl.rbw +151 -0
  141. data/samples/bigdemo/wxTextEntryDialog.rbw +34 -0
  142. data/samples/bigdemo/wxToggleButton.rbw +51 -0
  143. data/samples/bigdemo/wxToolBar.rbw +133 -0
  144. data/samples/bigdemo/wxTreeCtrl.rbw +192 -0
  145. data/samples/calendar/calendar.rb +275 -0
  146. data/samples/caret/caret.rb +296 -0
  147. data/samples/caret/mondrian.xpm +44 -0
  148. data/samples/controls/controls.rb +1140 -0
  149. data/samples/controls/get_item_sample.rb +87 -0
  150. data/samples/controls/icons/choice.xpm +27 -0
  151. data/samples/controls/icons/combo.xpm +27 -0
  152. data/samples/controls/icons/gauge.xpm +27 -0
  153. data/samples/controls/icons/list.xpm +27 -0
  154. data/samples/controls/icons/radio.xpm +27 -0
  155. data/samples/controls/icons/stattext.xpm +24 -0
  156. data/samples/controls/icons/text.xpm +27 -0
  157. data/samples/controls/mondrian.ico +0 -0
  158. data/samples/controls/mondrian.xpm +44 -0
  159. data/samples/controls/test2.bmp +0 -0
  160. data/samples/dialogs/dialogs.rb +724 -0
  161. data/samples/dialogs/tips.txt +18 -0
  162. data/samples/etc/activation.rb +108 -0
  163. data/samples/etc/choice.rb +72 -0
  164. data/samples/etc/miniframe.rb +84 -0
  165. data/samples/etc/sash.rb +135 -0
  166. data/samples/etc/scrollwin.rb +116 -0
  167. data/samples/etc/system_settings.rb +258 -0
  168. data/samples/etc/wizard.rb +81 -0
  169. data/samples/grid/grid.rb +201 -0
  170. data/samples/html/html.rb +251 -0
  171. data/samples/images/Thumbs.db +0 -0
  172. data/samples/images/images.rb +48 -0
  173. data/samples/images/paperclip.png +0 -0
  174. data/samples/listbook/listbook.rb +183 -0
  175. data/samples/listbook/listbook.xrc +370 -0
  176. data/samples/mdi/mdi.rb +87 -0
  177. data/samples/minimal/minimal.rb +95 -0
  178. data/samples/minimal/mondrian.ico +0 -0
  179. data/samples/minimal/mondrian.xpm +44 -0
  180. data/samples/minimal/nothing.rb +46 -0
  181. data/samples/minimal/text.rb +35 -0
  182. data/samples/printing/mondrian.ico +0 -0
  183. data/samples/printing/mondrian.xpm +44 -0
  184. data/samples/printing/printing.rb +484 -0
  185. data/samples/text/mondrian.ico +0 -0
  186. data/samples/text/mondrian.xpm +44 -0
  187. data/samples/text/scintilla.rb +180 -0
  188. data/samples/text/textctrl.rb +124 -0
  189. data/samples/text/unicode.rb +238 -0
  190. data/samples/text/utf8.txt +15 -0
  191. data/samples/treectrl/icon1.xpm +79 -0
  192. data/samples/treectrl/icon2.xpm +53 -0
  193. data/samples/treectrl/icon3.xpm +79 -0
  194. data/samples/treectrl/icon4.xpm +43 -0
  195. data/samples/treectrl/icon5.xpm +79 -0
  196. data/samples/treectrl/treectrl.rb +1210 -0
  197. data/samples/xrc/samples.xrc +46 -0
  198. data/samples/xrc/xrc_sample.rb +107 -0
  199. metadata +264 -0
@@ -0,0 +1,87 @@
1
+ #!/usr/bin/env ruby
2
+ # Written by Nobuaki Arima
3
+
4
+ require 'wx'
5
+
6
+ class ListctrlFrame < Wx::Frame
7
+ def initialize(title,pos,size)
8
+ super(nil,-1,title,pos,size,Wx::DEFAULT_FRAME_STYLE)
9
+
10
+ list = Wx::ListCtrl.new(self, -1, Wx::DEFAULT_POSITION,
11
+ Wx::DEFAULT_SIZE,
12
+ Wx::LC_REPORT)
13
+ list.insert_column(0,"column0",Wx::LIST_FORMAT_LEFT, -1)
14
+ list.insert_column(1,"column1",Wx::LIST_FORMAT_LEFT, -1)
15
+ list.insert_item(0, 'line0:column0')
16
+ list.set_item(0, 1, 'line0:column1')
17
+ list.insert_item(1, 'line1:column0')
18
+ list.set_text_colour(Wx::CYAN)
19
+ list.set_item(1, 1, 'line1:column1')
20
+ list.set_text_colour(Wx::RED)
21
+ list.insert_item(2, 'line2:column0')
22
+ list.set_item(2, 1, 'line2:column1')
23
+ item = Wx::ListItem.new
24
+ item.set_id(0)
25
+ item.set_text_colour(Wx::RED)
26
+ list.set_item( item )
27
+ item.set_id(1)
28
+ item.set_text_colour(Wx::GREEN)
29
+ list.set_item( item )
30
+ item.set_id(2)
31
+ item.set_text_colour(Wx::BLUE)
32
+ item.set_font(Wx::ITALIC_FONT)
33
+ item.set_background_colour(Wx::LIGHT_GREY)
34
+ list.set_item( item )
35
+
36
+ # test of get_item method
37
+ 0.upto(2) do |i|
38
+ if item = list.get_item(i)
39
+ print "ID:",item.get_id,"\n"
40
+ print "column: ",item.get_column,"\n"
41
+ print "text: ",item.get_text,"\n"
42
+ print "text color:",show_color(item.get_text_colour),"\n"
43
+ print "BG color: ",show_color(item.get_background_colour),"\n"
44
+ print "font: ",show_font(item.get_font),"\n\n"
45
+ end
46
+ end
47
+ # test other column
48
+ 0.upto(2) do |i|
49
+ if item = list.get_item(i, 1)
50
+ print "ID:",item.get_id,"\n"
51
+ print "column: ",item.get_column,"\n"
52
+ print "text: ",item.get_text,"\n"
53
+ print "text color:",show_color(item.get_text_colour),"\n"
54
+ print "BG color: ",show_color(item.get_background_colour),"\n"
55
+ print "font: ",show_font(item.get_font),"\n\n"
56
+ end
57
+ end
58
+ end
59
+
60
+ def show_color(color)
61
+ if color.is_ok
62
+ return '(%i, %i, %i)' % [color.red, color.green, color.blue]
63
+ else
64
+ return '(N/A)'
65
+ end
66
+ end
67
+
68
+ def show_font(font)
69
+ if font.get_style == Wx::ITALIC
70
+ return "Italic"
71
+ end
72
+ return "Normal"
73
+ end
74
+
75
+ end
76
+
77
+ class RbApp < Wx::App
78
+ def on_init
79
+ frame = ListctrlFrame.new("Listctrl test",Wx::Point.new(50, 50), Wx::Size.new(450, 340))
80
+
81
+ frame.show(true)
82
+
83
+ end
84
+ end
85
+
86
+ a = RbApp.new
87
+ a.main_loop()
@@ -0,0 +1,27 @@
1
+ /* XPM */
2
+ static char * choice_xpm[] = {
3
+ /* width height ncolors chars_per_pixel */
4
+ "16 16 5 1",
5
+ /* colors */
6
+ " s None c None",
7
+ ". c #000000",
8
+ "+ c #c0c0c0",
9
+ "@ c #808080",
10
+ "# c #ffffff",
11
+ /* pixels */
12
+ "@@@@@@@@@@@@@@@@",
13
+ "@..............@",
14
+ "@.########+++++@",
15
+ "@.########.....@",
16
+ "@.########+...+@",
17
+ "@.########++.++@",
18
+ "@.+++++++++++++@",
19
+ "@@@@@@@@@@@@@@@@",
20
+ " ##############",
21
+ " ..............",
22
+ " .#########+.+.",
23
+ " .#########....",
24
+ " .#########+++.",
25
+ " .#########....",
26
+ " .#########+.+.",
27
+ " .............."};
@@ -0,0 +1,27 @@
1
+ /* XPM */
2
+ static char * combo_xpm[] = {
3
+ /* width height ncolors chars_per_pixel */
4
+ "16 16 5 1",
5
+ /* colors */
6
+ " s None c None",
7
+ ". c #000000",
8
+ "+ c #c0c0c0",
9
+ "@ c #808080",
10
+ "# c #ffffff",
11
+ /* pixels */
12
+ "@@@@@@@@@@@@@@@@",
13
+ "@..............@",
14
+ "@....#####+++++@",
15
+ "@.#.######.....@",
16
+ "@.#.######+...+@",
17
+ "@....#####++.++@",
18
+ "@.+++++++++++++@",
19
+ "@@@@@@@@@@@@@@@@",
20
+ " ##############",
21
+ " ..............",
22
+ " .#########+.+.",
23
+ " .#########....",
24
+ " .#########+++.",
25
+ " .#########....",
26
+ " .#########+.+.",
27
+ " .............."};
@@ -0,0 +1,27 @@
1
+ /* XPM */
2
+ static char * gauge_xpm[] = {
3
+ /* width height ncolors chars_per_pixel */
4
+ "16 16 5 1",
5
+ /* colors */
6
+ " s None c None",
7
+ ". c #000000",
8
+ "+ c #000080",
9
+ "@ c #c0c0c0",
10
+ "# c #808080",
11
+ /* pixels */
12
+ " ",
13
+ " ",
14
+ " ",
15
+ "################",
16
+ "#..............#",
17
+ "#.++++++++@@@@@#",
18
+ "#.++++++++@@@@@#",
19
+ "#.++++++++@@@@@#",
20
+ "#.++++++++@@@@@#",
21
+ "#.++++++++@@@@@#",
22
+ "#.++++++++@@@@@#",
23
+ "#.++++++++@@@@@#",
24
+ "################",
25
+ " ",
26
+ " ",
27
+ " "};
@@ -0,0 +1,27 @@
1
+ /* XPM */
2
+ static char * list_xpm[] = {
3
+ /* width height ncolors chars_per_pixel */
4
+ "16 16 5 1",
5
+ /* colors */
6
+ " s None c None",
7
+ ". c #000000",
8
+ "+ c #c0c0c0",
9
+ "@ c #808080",
10
+ "# c #ffffff",
11
+ /* pixels */
12
+ "@@@@@@@@@@@@@@@@",
13
+ "@..............@",
14
+ "@.##########+++@",
15
+ "@.##########+.+@",
16
+ "@.++++++++++...@",
17
+ "@.##########+++@",
18
+ "@.##########+++@",
19
+ "@.+++++++++++++@",
20
+ "@.##########+++@",
21
+ "@.##########+++@",
22
+ "@.+++++++++++++@",
23
+ "@.##########+++@",
24
+ "@.##########...@",
25
+ "@.##########+.+@",
26
+ "@.+++++++++++++@",
27
+ "@@@@@@@@@@@@@@@@"};
@@ -0,0 +1,27 @@
1
+ /* XPM */
2
+ static char * radio_xpm[] = {
3
+ /* width height ncolors chars_per_pixel */
4
+ "16 16 5 1",
5
+ /* colors */
6
+ " s None c None",
7
+ ". c #000000",
8
+ "+ c #c0c0c0",
9
+ "@ c #808080",
10
+ "# c #ffffff",
11
+ /* pixels */
12
+ " . ",
13
+ " .. .. ",
14
+ "+++.+.++...++++.",
15
+ "+@.@...@@..@@@@.",
16
+ "+@.+++.+....++@.",
17
+ "+@++++++++++++@.",
18
+ "+@++++++++++++@.",
19
+ "+@++++...+++++@.",
20
+ "+@+++.###@++++@.",
21
+ "+@+++.#.#@++++@.",
22
+ "+@+++.###@++++@.",
23
+ "+@++++@@@+++++@.",
24
+ "+@++++++++++++@.",
25
+ "+@++++++++++++@.",
26
+ "+@@@@@@@@@@@@@@.",
27
+ "................"};
@@ -0,0 +1,24 @@
1
+ /* XPM */
2
+ static char * stattext_xpm[] = {
3
+ /* width height ncolors chars_per_pixel */
4
+ "16 16 2 1",
5
+ /* colors */
6
+ " s None c None",
7
+ ". c #000000",
8
+ /* pixels */
9
+ " ",
10
+ " ",
11
+ " ",
12
+ " .. ",
13
+ " .. ",
14
+ " .... ",
15
+ " .... .... ",
16
+ " . . .. .. ",
17
+ " .. .. .... ",
18
+ " .. .. .. .. ",
19
+ " ...... .. .. ",
20
+ ".. .. .. .. ",
21
+ ".. .. ..... ",
22
+ " ",
23
+ " ",
24
+ " "};
@@ -0,0 +1,27 @@
1
+ /* XPM */
2
+ static char * text_xpm[] = {
3
+ /* width height ncolors chars_per_pixel */
4
+ "16 16 5 1",
5
+ /* colors */
6
+ " s None c None",
7
+ ". c #000000",
8
+ "+ c #c0c0c0",
9
+ "@ c #808080",
10
+ "# c #ffffff",
11
+ /* pixels */
12
+ " ",
13
+ " ",
14
+ " ",
15
+ "@@@@@@@@@@@@@@@@",
16
+ "@..............@",
17
+ "@.############+@",
18
+ "@.#...########+@",
19
+ "@.##.#########+@",
20
+ "@.##.#########+@",
21
+ "@.#...########+@",
22
+ "@.############+@",
23
+ "@.+++++++++++++@",
24
+ "@@@@@@@@@@@@@@@@",
25
+ " ",
26
+ " ",
27
+ " "};
@@ -0,0 +1,44 @@
1
+ /* XPM */
2
+ static char *mondrian_xpm[] = {
3
+ /* columns rows colors chars-per-pixel */
4
+ "32 32 6 1",
5
+ " c Black",
6
+ ". c Blue",
7
+ "X c #00bf00",
8
+ "o c Red",
9
+ "O c Yellow",
10
+ "+ c Gray100",
11
+ /* pixels */
12
+ " ",
13
+ " oooooo +++++++++++++++++++++++ ",
14
+ " oooooo +++++++++++++++++++++++ ",
15
+ " oooooo +++++++++++++++++++++++ ",
16
+ " oooooo +++++++++++++++++++++++ ",
17
+ " oooooo +++++++++++++++++++++++ ",
18
+ " oooooo +++++++++++++++++++++++ ",
19
+ " oooooo +++++++++++++++++++++++ ",
20
+ " ",
21
+ " ++++++ ++++++++++++++++++ .... ",
22
+ " ++++++ ++++++++++++++++++ .... ",
23
+ " ++++++ ++++++++++++++++++ .... ",
24
+ " ++++++ ++++++++++++++++++ .... ",
25
+ " ++++++ ++++++++++++++++++ .... ",
26
+ " ++++++ ++++++++++++++++++ ",
27
+ " ++++++ ++++++++++++++++++ ++++ ",
28
+ " ++++++ ++++++++++++++++++ ++++ ",
29
+ " ++++++ ++++++++++++++++++ ++++ ",
30
+ " ++++++ ++++++++++++++++++ ++++ ",
31
+ " ++++++ ++++++++++++++++++ ++++ ",
32
+ " ++++++ ++++++++++++++++++ ++++ ",
33
+ " ++++++ ++++++++++++++++++ ++++ ",
34
+ " ++++++ ++++++++++++++++++ ++++ ",
35
+ " ++++++ ++++++++++++++++++ ++++ ",
36
+ " ++++++ ++++ ",
37
+ " ++++++ OOOOOOOOOOOO XXXXX ++++ ",
38
+ " ++++++ OOOOOOOOOOOO XXXXX ++++ ",
39
+ " ++++++ OOOOOOOOOOOO XXXXX ++++ ",
40
+ " ++++++ OOOOOOOOOOOO XXXXX ++++ ",
41
+ " ++++++ OOOOOOOOOOOO XXXXX ++++ ",
42
+ " ++++++ OOOOOOOOOOOO XXXXX ++++ ",
43
+ " "
44
+ };
@@ -0,0 +1,724 @@
1
+ #!/usr/bin/env ruby
2
+ # wxRuby2 Sample Code. Copyright (c) 2004-2006 Kevin B. Smith
3
+ # Freely reusable code: see SAMPLES-LICENSE.TXT for details
4
+
5
+ begin
6
+ require 'wx'
7
+ rescue LoadError => no_wx_err
8
+ begin
9
+ require 'rubygems'
10
+ require 'wx'
11
+ rescue LoadError
12
+ raise no_wx_err
13
+ end
14
+ end
15
+ include Wx
16
+
17
+ DIALOGS_CHOOSE_COLOUR = 1
18
+ DIALOGS_CHOOSE_COLOUR_GENERIC = 2
19
+ DIALOGS_CHOOSE_FONT = 3
20
+ DIALOGS_CHOOSE_FONT_GENERIC = 4
21
+ DIALOGS_MESSAGE_BOX = 5
22
+ DIALOGS_SINGLE_CHOICE = 6
23
+ DIALOGS_MULTI_CHOICE = 7
24
+ DIALOGS_TEXT_ENTRY = 8
25
+ DIALOGS_PASSWORD_ENTRY = 9
26
+ DIALOGS_FILE_OPEN = 10
27
+ DIALOGS_FILE_OPEN2 = 11
28
+ DIALOGS_FILES_OPEN = 12
29
+ DIALOGS_FILE_SAVE = 13
30
+ DIALOGS_DIR_CHOOSE = 14
31
+ DIALOGS_GENERIC_DIR_CHOOSE = 15
32
+ DIALOGS_TIP = 16
33
+ DIALOGS_NUM_ENTRY = 17
34
+ DIALOGS_LOG_DIALOG = 18
35
+ DIALOGS_MODAL = 19
36
+ DIALOGS_MODELESS = 20
37
+ DIALOGS_MODELESS_BTN = 21
38
+ DIALOGS_PROGRESS = 22
39
+ DIALOGS_BUSYINFO = 23
40
+ DIALOGS_FIND = 24
41
+ DIALOGS_REPLACE = 25
42
+
43
+ $my_canvas = nil
44
+
45
+ class MyModalDialog < Dialog
46
+ def initialize(parent)
47
+ super(parent, -1, "Modal dialog")
48
+
49
+ sizer_top = BoxSizer.new(HORIZONTAL)
50
+
51
+ @btn_focused = Button.new(self, -1, "Default button")
52
+ @btn_delete = Button.new(self, -1, "&Delete button")
53
+ btn_ok = Button.new(self, ID_CANCEL, "&Close")
54
+ sizer_top.add(@btn_focused, 0, ALIGN_CENTER | ALL, 5)
55
+ sizer_top.add(@btn_delete, 0, ALIGN_CENTER | ALL, 5)
56
+ sizer_top.add(btn_ok, 0, ALIGN_CENTER | ALL, 5)
57
+
58
+ set_auto_layout(true)
59
+ set_sizer(sizer_top)
60
+
61
+ sizer_top.set_size_hints(self)
62
+ sizer_top.fit(self)
63
+
64
+ @btn_focused.set_focus()
65
+ @btn_focused.set_default()
66
+
67
+ evt_button(-1) {|event| on_button(event) }
68
+ end
69
+
70
+ def on_button(event)
71
+ id = event.get_id
72
+
73
+ if id == @btn_delete.get_id
74
+ @btn_focused.destroy
75
+ @btn_focused = nil
76
+
77
+ @btn_delete.disable()
78
+ elsif @btn_focused && id == @btn_focused.get_id
79
+ get_text_from_user("Dummy prompt", "Modal dialog called from dialog",
80
+ "", self)
81
+ else
82
+ event.skip()
83
+ end
84
+ end
85
+ end
86
+
87
+
88
+ class MyModelessDialog < Dialog
89
+ def initialize(parent)
90
+ super(parent, -1, "Modeless dialog")
91
+
92
+ sizer_top = BoxSizer.new(VERTICAL)
93
+
94
+ btn = Button.new(self, DIALOGS_MODELESS_BTN, "Press me")
95
+ check = CheckBox.new(self, -1, "Should be disabled")
96
+ check.disable()
97
+
98
+ sizer_top.add(btn, 1, EXPAND | ALL, 5)
99
+ sizer_top.add(check, 1, EXPAND | ALL, 5)
100
+
101
+ set_auto_layout(true)
102
+ set_sizer(sizer_top)
103
+
104
+ sizer_top.set_size_hints(self)
105
+ sizer_top.fit(self)
106
+
107
+ evt_button(DIALOGS_MODELESS_BTN) {|event| on_button(event) }
108
+
109
+ evt_close() {|event| on_close(event) }
110
+
111
+ end
112
+
113
+ def on_button(event)
114
+ message_box("Button pressed in modeless dialog", "Info",
115
+ OK | ICON_INFORMATION, self)
116
+ end
117
+
118
+ def on_close(event)
119
+ if event.can_veto()
120
+ message_box("Use the menu item to close self dialog",
121
+ "Modeless dialog",
122
+ OK | ICON_INFORMATION, self)
123
+
124
+ event.veto()
125
+ end
126
+ end
127
+ end
128
+
129
+
130
+ class MyCanvas < ScrolledWindow
131
+ def initialize(parent)
132
+ super(parent,-1,DEFAULT_POSITION,DEFAULT_SIZE, NO_FULL_REPAINT_ON_RESIZE)
133
+ evt_paint { |event| on_paint(event) }
134
+ end
135
+
136
+ def clear
137
+
138
+ end
139
+
140
+ def on_paint(event)
141
+ paint do |dc|
142
+ dc.set_text_foreground( get_app.canvas_text_colour )
143
+ dc.set_font( get_app.canvas_font )
144
+ dc.draw_text("Windows common dialogs test application", 10, 10)
145
+ end
146
+ end
147
+ end
148
+
149
+ class MyFrame < Frame
150
+ def initialize(parent,
151
+ title,
152
+ pos,
153
+ size)
154
+ super(parent, -1, title, pos, size)
155
+
156
+ @dialog = nil
157
+
158
+ @dlg_find = nil
159
+ @dlg_replace = nil
160
+
161
+ @find_data = FindReplaceData.new
162
+
163
+ @ext_def = ""
164
+ @index = -1
165
+
166
+ @max = 10
167
+
168
+ create_status_bar()
169
+
170
+ evt_menu(DIALOGS_CHOOSE_COLOUR) {|event| on_choose_colour(event) }
171
+ evt_menu(DIALOGS_CHOOSE_FONT) {|event| on_choose_font(event) }
172
+ evt_menu(DIALOGS_LOG_DIALOG) {|event| on_log_dialog(event) }
173
+ evt_menu(DIALOGS_MESSAGE_BOX) {|event| on_message_box(event) }
174
+ evt_menu(DIALOGS_TEXT_ENTRY) {|event| on_text_entry(event) }
175
+ evt_menu(DIALOGS_PASSWORD_ENTRY) {|event| on_password_entry(event) }
176
+ evt_menu(DIALOGS_NUM_ENTRY) {|event| on_numeric_entry(event) }
177
+ evt_menu(DIALOGS_SINGLE_CHOICE) {|event| on_single_choice(event) }
178
+ evt_menu(DIALOGS_MULTI_CHOICE) {|event| on_multi_choice(event) }
179
+ evt_menu(DIALOGS_FILE_OPEN) {|event| on_file_open(event) }
180
+ evt_menu(DIALOGS_FILE_OPEN2) {|event| on_file_open2(event) }
181
+ evt_menu(DIALOGS_FILES_OPEN) {|event| on_files_open(event) }
182
+ evt_menu(DIALOGS_FILE_SAVE) {|event| on_file_save(event) }
183
+ evt_menu(DIALOGS_DIR_CHOOSE) {|event| on_dir_choose(event) }
184
+ evt_menu(DIALOGS_MODAL) {|event| on_modal_dlg(event) }
185
+ evt_menu(DIALOGS_MODELESS) {|event| on_modeless_dlg(event) }
186
+ evt_menu(DIALOGS_TIP) {|event| on_show_tip(event) }
187
+ evt_menu(DIALOGS_PROGRESS) {|event| on_show_progress(event) }
188
+ evt_menu(DIALOGS_BUSYINFO) {|event| on_show_busy_info(event) }
189
+ evt_menu(DIALOGS_FIND) {|event| on_show_find_dialog(event) }
190
+ evt_menu(DIALOGS_REPLACE) {|event| on_show_replace_dialog(event) }
191
+ evt_find(-1) {|event| on_find_dialog(event) }
192
+ evt_find_next(-1) {|event| on_find_dialog(event) }
193
+ evt_find_replace(-1) {|event| on_find_dialog(event) }
194
+ evt_find_replace_all(-1) {|event| on_find_dialog(event) }
195
+ evt_find_close(-1) {|event| on_find_dialog(event) }
196
+ evt_menu(ID_EXIT) {|event| on_exit(event) }
197
+
198
+ end
199
+
200
+ def on_choose_colour(event)
201
+
202
+ col = $my_canvas.get_background_colour()
203
+
204
+ data = ColourData.new
205
+ data.set_colour(col)
206
+ data.set_choose_full(true)
207
+ for i in 0 ... 16
208
+ colour = Colour.new(i*16, i*16, i*16)
209
+ data.set_custom_colour(i, colour)
210
+ end
211
+
212
+ dialog = ColourDialog.new(self, data)
213
+ dialog.set_title("Choose the background colour (not OS X)")
214
+ if dialog.show_modal() == ID_OK
215
+ retData = dialog.get_colour_data()
216
+ col = retData.get_colour()
217
+ $my_canvas.set_background_colour(col)
218
+ #$my_canvas.clear()
219
+ $my_canvas.refresh()
220
+ end
221
+ end
222
+
223
+
224
+ def on_choose_font(event)
225
+ data = FontData.new
226
+ data.set_initial_font(Wx::get_app.canvas_font)
227
+ data.set_colour(Wx::get_app.canvas_text_colour)
228
+
229
+ dialog = FontDialog.new(self, data)
230
+
231
+ if dialog.show_modal() == ID_OK
232
+ ret_data = dialog.get_font_data()
233
+ Wx::get_app.canvas_font = ret_data.get_chosen_font()
234
+ Wx::get_app.canvas_text_colour = ret_data.get_colour()
235
+ font = ret_data.get_chosen_font
236
+ msg = "Font = %s, %i pt" % [ font.get_face_name,
237
+ font.get_point_size ]
238
+ dialog2 = MessageDialog.new(self, msg, "Got font")
239
+ dialog2.show_modal()
240
+ # $my_canvas.refresh()
241
+ end
242
+ #else: cancelled by the user, don't change the font
243
+ end
244
+
245
+
246
+ def on_log_dialog(event)
247
+
248
+ # calling yield() (as ~BusyCursor does) shouldn't result in messages
249
+ # being flushed -- test it
250
+
251
+ BusyCursor.busy() do
252
+
253
+ log_message("This is some message - everything is ok so far.")
254
+ log_message("Another message...\n... self one is on multiple lines")
255
+ log_warning("And then something went wrong!")
256
+
257
+ # and if ~BusyCursor doesn't do it, then call it manually
258
+ Wx::yield()
259
+
260
+ log_error("Intermediary error handler decided to abort.")
261
+ log_error("DEMO: The top level caller detected an unrecoverable error.")
262
+
263
+ Log::flush_active()
264
+
265
+ log_message("And this is the same dialog but with only one message.")
266
+ end
267
+ end
268
+
269
+ def on_message_box(event)
270
+
271
+ dialog = MessageDialog.new(nil, "This is a message box\nA long, long string to test out the message box properly",
272
+ "Message box text", NO_DEFAULT|YES_NO|CANCEL|ICON_INFORMATION)
273
+
274
+ case dialog.show_modal()
275
+ when ID_YES
276
+ log_status("You pressed \"Yes\"")
277
+ when ID_NO
278
+ log_status("You pressed \"No\"")
279
+ when ID_CANCEL
280
+ log_status("You pressed \"Cancel\"")
281
+ else
282
+ log_error("Unexpected MessageDialog return code!")
283
+ end
284
+ end
285
+
286
+
287
+ def on_numeric_entry(event)
288
+
289
+ res = get_number_from_user( "This is some text, actually a lot of text.\n" +
290
+ "Even two rows of text.",
291
+ "Enter a number:", "Numeric input test",
292
+ 50, 0, 100, self )
293
+
294
+ if res == -1
295
+ msg = "Invalid number entered or dialog cancelled."
296
+ icon = ICON_HAND
297
+ else
298
+ msg = sprintf("You've entered %d", res )
299
+ icon = ICON_INFORMATION
300
+ end
301
+
302
+ message_box(msg, "Numeric test result", OK | icon, self)
303
+ end
304
+
305
+ def on_password_entry(event)
306
+
307
+ pwd = get_password_from_user("Enter password:",
308
+ "Password entry dialog",
309
+ "", self)
310
+ if pwd
311
+ message_box(sprintf("Your password is '%s'", pwd),
312
+ "Got password", OK | ICON_INFORMATION, self)
313
+ end
314
+ end
315
+
316
+
317
+ def on_text_entry(event)
318
+
319
+ dialog = TextEntryDialog.new(self,
320
+ "This is a small sample\n" +
321
+ "A long, long string to test out the text entrybox",
322
+ "Please enter a string",
323
+ "Default value",
324
+ OK | CANCEL)
325
+
326
+ if dialog.show_modal() == ID_OK
327
+ dialog2 = MessageDialog.new(self, dialog.get_value(), "Got string")
328
+ dialog2.show_modal()
329
+ end
330
+ end
331
+
332
+ def on_single_choice(event)
333
+
334
+ choices = ["One", "Two", "Three", "Four", "Five"]
335
+
336
+ dialog = SingleChoiceDialog.new(self,
337
+ "This is a small sample\n" +
338
+ "A single-choice convenience dialog",
339
+ "Please select a value",
340
+ choices, nil, OK | CANCEL)
341
+
342
+ dialog.set_selection(2)
343
+
344
+ if dialog.show_modal() == ID_OK
345
+ dialog2 = MessageDialog.new(self, dialog.get_string_selection(), "Got string")
346
+ dialog2.show_modal()
347
+ end
348
+ end
349
+
350
+
351
+ def on_multi_choice(event)
352
+
353
+ choices = [
354
+ "One", "Two", "Three", "Four", "Five",
355
+ "Six", "Seven", "Eight", "Nine", "Ten",
356
+ "Eleven", "Twelve", "Seventeen"]
357
+
358
+ selections = get_multiple_choices("This is a small sample\n" +
359
+ "A multi-choice convenience dialog",
360
+ "Please select a value",
361
+ choices,
362
+ self)
363
+ if selections
364
+ msg = sprintf("You selected %d items:\n", selections.length)
365
+ for n in 0 ... selections.length
366
+ msg += sprintf("\t%d: %d (%s)\n", n, selections[n],
367
+ choices[selections[n]])
368
+ end
369
+ log_message(msg)
370
+ end
371
+ #else: cancelled or nothing selected
372
+ end
373
+
374
+
375
+ def on_file_open(event)
376
+
377
+ dialog = FileDialog.new(
378
+ self,
379
+ "Testing open file dialog",
380
+ "",
381
+ "",
382
+ "C++ files (*.h;*.cpp)|*.h;*.cpp"
383
+ )
384
+
385
+ dialog.set_directory(get_home_dir())
386
+
387
+ if dialog.show_modal() == ID_OK
388
+ info = sprintf("Full file name: %s\n" +
389
+ "Path: %s\n" +
390
+ "Name: %s",
391
+ dialog.get_path(),
392
+ dialog.get_directory(),
393
+ dialog.get_filename())
394
+ dialog2 = MessageDialog.new(self, info, "Selected file")
395
+ dialog2.show_modal()
396
+ end
397
+ end
398
+
399
+
400
+ # this shows how to take advantage of specifying a default extension in the
401
+ # call to FileSelector: it is remembered after each new call and the next
402
+ # one will use it by default
403
+ def on_file_open2(event)
404
+
405
+ path = file_selector(
406
+ "Select the file to load",
407
+ "", "",
408
+ @ext_def,
409
+ "Waveform (*.wav)|*.wav|Plain text (*.txt)|*.txt|All files (*.*)|*.*",
410
+ CHANGE_DIR,
411
+ self
412
+ )
413
+
414
+ if path == nil
415
+ return nil
416
+ end
417
+
418
+ # it is just a sample, would use SplitPath in real program
419
+ @ext_def = path[/[^\.]*$/]
420
+
421
+ log_message("You selected the file '%s', remembered extension '%s'",
422
+ path, @ext_def)
423
+ end
424
+
425
+
426
+ def on_files_open(event)
427
+
428
+ dialog = FileDialog.new(self, "Testing open multiple file dialog",
429
+ "", "", FILE_SELECTOR_DEFAULT_WILDCARD_STR,
430
+ MULTIPLE)
431
+
432
+ if dialog.show_modal() == ID_OK
433
+
434
+ paths = dialog.get_paths()
435
+ filenames = dialog.get_filenames()
436
+
437
+ count = paths.length
438
+ msg = ""
439
+ for n in 0 ... count
440
+ s = sprintf("File %d: %s (%s)\n",
441
+ n, paths[n], filenames[n])
442
+ msg += s
443
+ end
444
+
445
+ dialog2 = MessageDialog.new(self, msg, "Selected files")
446
+ dialog2.show_modal()
447
+ end
448
+ end
449
+
450
+
451
+ def on_file_save(event)
452
+
453
+ dialog = FileDialog.new(self,
454
+ "Testing save file dialog",
455
+ "",
456
+ "myletter.doc",
457
+ "Text files (*.txt)|*.txt|Document files (*.doc)|*.doc",
458
+ SAVE|OVERWRITE_PROMPT)
459
+
460
+ dialog.set_filter_index(1)
461
+
462
+ if dialog.show_modal() == ID_OK
463
+
464
+ log_message("%s, filter %d",
465
+ dialog.get_path(), dialog.get_filter_index())
466
+ end
467
+ end
468
+
469
+ def on_dir_choose(event)
470
+
471
+ # pass some initial dir to DirDialog
472
+ dir_home = get_home_dir()
473
+
474
+ dialog = DirDialog.new(self, "Testing directory picker", dir_home)
475
+
476
+ if dialog.show_modal() == ID_OK
477
+ log_message("Selected path: %s", dialog.get_path())
478
+ end
479
+ end
480
+
481
+
482
+ def on_modal_dlg(event)
483
+ dlg = MyModalDialog.new(self)
484
+ dlg.show_modal()
485
+ end
486
+
487
+ def on_modeless_dlg(event)
488
+ show = get_menu_bar().is_checked(event.get_id())
489
+ if show
490
+ if !@dialog
491
+ @dialog = MyModelessDialog.new(self)
492
+ end
493
+ @dialog.show(true)
494
+ else # hide
495
+ @dialog.hide()
496
+ end
497
+ end
498
+
499
+
500
+ def on_show_tip(event)
501
+
502
+ if @index == -1
503
+ @index = rand(5)
504
+ end
505
+
506
+ tip_src = File.join( File.dirname(__FILE__), 'tips.txt')
507
+ tip_provider = create_file_tip_provider(tip_src, @index)
508
+
509
+ show_at_startup = show_tip(self, tip_provider)
510
+
511
+ if show_at_startup
512
+ message_box("Will show tips on startup", "Tips dialog",
513
+ OK | ICON_INFORMATION, self)
514
+ end
515
+
516
+ @index = tip_provider.get_current_tip()
517
+
518
+ end
519
+
520
+ def on_exit(event)
521
+ close(true)
522
+ end
523
+
524
+
525
+ def on_show_progress(event)
526
+
527
+ dialog = ProgressDialog.new("Progress dialog example",
528
+ "An informative message",
529
+ @max, # range
530
+ self, # parent
531
+ PD_CAN_ABORT|PD_APP_MODAL|
532
+ PD_ELAPSED_TIME|PD_ESTIMATED_TIME|
533
+ PD_REMAINING_TIME)
534
+
535
+ cont = true
536
+ for i in 0 .. @max
537
+ sleep(1)
538
+ if i == @max
539
+ cont = dialog.update(i, "That's all, folks!")
540
+ elsif i == @max / 2
541
+ cont = dialog.update(i, "Only a half left (very long message)!")
542
+ else
543
+ cont = dialog.update(i)
544
+ end
545
+
546
+ if !cont
547
+ if message_box("Do you really want to cancel?",
548
+ "Progress dialog question", # caption
549
+ YES_NO | ICON_QUESTION) == YES
550
+ dialog.end_modal(ID_CANCEL)
551
+ break
552
+ end
553
+ dialog.resume()
554
+ end
555
+ end
556
+
557
+
558
+ if !cont
559
+ log_status("Progress dialog aborted!")
560
+ else
561
+ log_status("Countdown from %d finished", @max)
562
+ end
563
+ end
564
+
565
+ def on_show_busy_info(event)
566
+ WindowDisabler.disable(self) do
567
+ info = BusyInfo.busy("Working, please wait...", self) do
568
+
569
+ for i in 0 ... 18
570
+ Wx::get_app.yield()
571
+ end
572
+ sleep(2)
573
+ end
574
+ end
575
+ end
576
+
577
+ def on_show_replace_dialog(event)
578
+
579
+ if @dlg_replace
580
+ #@dlg_replace.destroy
581
+ @dlg_replace = nil
582
+ else
583
+ @dlg_replace = FindReplaceDialog.new(
584
+ self,
585
+ @find_data,
586
+ "Find and replace dialog",
587
+ FR_REPLACEDIALOG
588
+ )
589
+
590
+ @dlg_replace.show(true)
591
+ end
592
+ end
593
+
594
+ def on_show_find_dialog(event)
595
+
596
+ if @dlg_find
597
+ @dlg_find.destroy
598
+ @dlg_find = nil
599
+ else
600
+ @dlg_find = FindReplaceDialog.new(
601
+ self,
602
+ @find_data,
603
+ "Find dialog", # just for testing
604
+ FR_NOWHOLEWORD
605
+ )
606
+
607
+ @dlg_find.show(true)
608
+ end
609
+ end
610
+
611
+ def decode_find_dialog_event_flags(flags)
612
+ str = ""
613
+ str << ((flags & FR_DOWN) != 0 ? "down" : "up") << ", " \
614
+ << ((flags & FR_WHOLEWORD) != 0 ? "whole words only, " : "") \
615
+ << ((flags & FR_MATCHCASE) != 0 ? "" : "not ") \
616
+ << "case sensitive"
617
+
618
+ return str
619
+ end
620
+
621
+ def on_find_dialog(event)
622
+
623
+ type = event.get_event_type()
624
+
625
+ if type == EVT_COMMAND_FIND || type == EVT_COMMAND_FIND_NEXT
626
+ log_message("Find %s'%s' (flags: %s)",
627
+ type == EVT_COMMAND_FIND_NEXT ? "next " : "",
628
+ event.get_find_string(),
629
+ decode_find_dialog_event_flags(event.get_flags()))
630
+ elsif type == EVT_COMMAND_FIND_REPLACE || type == EVT_COMMAND_FIND_REPLACE_ALL
631
+ log_message("Replace %s'%s' with '%s' (flags: %s)",
632
+ type == EVT_COMMAND_FIND_REPLACE_ALL ? "all " : "",
633
+ event.get_find_string(),
634
+ event.get_replace_string(),
635
+ decode_find_dialog_event_flags(event.get_flags()))
636
+ elsif type == EVT_COMMAND_FIND_CLOSE
637
+ dlg = event.get_dialog()
638
+ if dlg == @dlg_find
639
+ txt = "Find"
640
+ id_menu = DIALOGS_FIND
641
+ @dlg_find = nil
642
+ elsif dlg == @dlg_replace
643
+ txt = "Replace"
644
+ id_menu = DIALOGS_REPLACE
645
+ @dlg_replace = nil
646
+ else
647
+ txt = "Unknown"
648
+ id_menu = -1
649
+ log_error("unexpected event")
650
+ end
651
+
652
+ log_message("%s dialog is being closed.", txt)
653
+
654
+ if id_menu != -1
655
+ get_menu_bar().check(id_menu, false)
656
+ end
657
+
658
+ dlg.destroy()
659
+ else
660
+ log_error("Unknown find dialog event!")
661
+ end
662
+ end
663
+
664
+ end
665
+
666
+
667
+ class MyApp < App
668
+ attr_accessor :canvas_text_colour, :canvas_font
669
+
670
+ def on_init()
671
+ self.canvas_text_colour = Wx::Colour.new("BLACK")
672
+ self.canvas_font = Wx::NORMAL_FONT
673
+ # Create the main frame window
674
+ frame = MyFrame.new(nil, "Windows dialogs example",
675
+ Point.new(20, 20), Size.new(400, 300))
676
+
677
+ # Make a menubar
678
+ file_menu = Menu.new
679
+
680
+ file_menu.append(DIALOGS_CHOOSE_COLOUR, "&Choose colour")
681
+ file_menu.append_separator()
682
+ file_menu.append(DIALOGS_CHOOSE_FONT, "Choose &font")
683
+ file_menu.append_separator()
684
+ file_menu.append(DIALOGS_LOG_DIALOG, "&Log dialog\tCtrl-L")
685
+ file_menu.append(DIALOGS_MESSAGE_BOX, "&Message box\tCtrl-M")
686
+ file_menu.append(DIALOGS_TEXT_ENTRY, "Text &entry\tCtrl-E")
687
+ file_menu.append(DIALOGS_PASSWORD_ENTRY, "&Password entry\tCtrl-P")
688
+ file_menu.append(DIALOGS_NUM_ENTRY, "&Numeric entry\tCtrl-N")
689
+ file_menu.append(DIALOGS_SINGLE_CHOICE, "&Single choice\tCtrl-C")
690
+ file_menu.append(DIALOGS_MULTI_CHOICE, "M&ultiple choice\tCtrl-U")
691
+ file_menu.append_separator()
692
+ file_menu.append(DIALOGS_TIP, "&Tip of the day\tCtrl-T")
693
+ file_menu.append_separator()
694
+ file_menu.append(DIALOGS_FILE_OPEN, "&Open file\tCtrl-O")
695
+ file_menu.append(DIALOGS_FILE_OPEN2, "&Second open file\tCtrl-2")
696
+ file_menu.append(DIALOGS_FILES_OPEN, "Open &files\tShift-Ctrl-O")
697
+ file_menu.append(DIALOGS_FILE_SAVE, "Sa&ve file\tCtrl-S")
698
+ file_menu.append(DIALOGS_DIR_CHOOSE, "&Choose a directory\tCtrl-D")
699
+ file_menu.append(DIALOGS_PROGRESS, "Pro&gress dialog\tCtrl-G")
700
+ file_menu.append(DIALOGS_BUSYINFO, "&Busy info dialog\tCtrl-B")
701
+ file_menu.append(DIALOGS_FIND, "&Find dialog\tCtrl-F", "", ITEM_CHECK)
702
+ file_menu.append(DIALOGS_REPLACE, "Find and &replace dialog\tShift-Ctrl-F", "", ITEM_CHECK)
703
+ file_menu.append_separator()
704
+ file_menu.append(DIALOGS_MODAL, "Mo&dal dialog\tCtrl-W")
705
+ file_menu.append(DIALOGS_MODELESS, "Modeless &dialog\tCtrl-Z", "", ITEM_CHECK)
706
+ file_menu.append_separator()
707
+ file_menu.append(ID_EXIT, "E&xit\tAlt-X")
708
+ menu_bar = MenuBar.new
709
+ menu_bar.append(file_menu, "&File")
710
+ frame.set_menu_bar(menu_bar)
711
+
712
+ $my_canvas = MyCanvas.new(frame)
713
+ $my_canvas.set_background_colour(WHITE)
714
+
715
+ frame.centre(BOTH)
716
+
717
+ # Show the frame
718
+ frame.show()
719
+ end
720
+ end
721
+
722
+ app = MyApp.new()
723
+ app.main_loop()
724
+