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

Sign up to get free protection for your applications and to get access to all the features.
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,24 +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
- " "};
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
+ " "};
@@ -1,27 +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
- " "};
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
+ " "};
@@ -1,44 +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
- };
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
+ };
@@ -1,723 +1,797 @@
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
- require 'wx'
12
-
13
-
14
- include Wx
15
-
16
- DIALOGS_CHOOSE_COLOUR = 1
17
- DIALOGS_CHOOSE_COLOUR_GENERIC = 2
18
- DIALOGS_CHOOSE_FONT = 3
19
- DIALOGS_CHOOSE_FONT_GENERIC = 4
20
- DIALOGS_MESSAGE_BOX = 5
21
- DIALOGS_SINGLE_CHOICE = 6
22
- DIALOGS_MULTI_CHOICE = 7
23
- DIALOGS_TEXT_ENTRY = 8
24
- DIALOGS_PASSWORD_ENTRY = 9
25
- DIALOGS_FILE_OPEN = 10
26
- DIALOGS_FILE_OPEN2 = 11
27
- DIALOGS_FILES_OPEN = 12
28
- DIALOGS_FILE_SAVE = 13
29
- DIALOGS_DIR_CHOOSE = 14
30
- DIALOGS_GENERIC_DIR_CHOOSE = 15
31
- DIALOGS_TIP = 16
32
- DIALOGS_NUM_ENTRY = 17
33
- DIALOGS_LOG_DIALOG = 18
34
- DIALOGS_MODAL = 19
35
- DIALOGS_MODELESS = 20
36
- DIALOGS_MODELESS_BTN = 21
37
- DIALOGS_PROGRESS = 22
38
- DIALOGS_BUSYINFO = 23
39
- DIALOGS_FIND = 24
40
- DIALOGS_REPLACE = 25
41
-
42
- $my_canvas = nil
43
-
44
- class MyModalDialog < Dialog
45
- def initialize(parent)
46
- super(parent, -1, "Modal dialog")
47
-
48
- sizer_top = BoxSizer.new(HORIZONTAL)
49
-
50
- @btn_focused = Button.new(self, -1, "Default button")
51
- @btn_delete = Button.new(self, -1, "&Delete button")
52
- btn_ok = Button.new(self, ID_CANCEL, "&Close")
53
- sizer_top.add(@btn_focused, 0, ALIGN_CENTER | ALL, 5)
54
- sizer_top.add(@btn_delete, 0, ALIGN_CENTER | ALL, 5)
55
- sizer_top.add(btn_ok, 0, ALIGN_CENTER | ALL, 5)
56
-
57
- set_auto_layout(true)
58
- set_sizer(sizer_top)
59
-
60
- sizer_top.set_size_hints(self)
61
- sizer_top.fit(self)
62
-
63
- @btn_focused.set_focus()
64
- @btn_focused.set_default()
65
-
66
- evt_button(-1) {|event| on_button(event) }
67
- end
68
-
69
- def on_button(event)
70
- id = event.get_id
71
-
72
- if id == @btn_delete.get_id
73
- @btn_focused.destroy
74
- @btn_focused = nil
75
-
76
- @btn_delete.disable()
77
- elsif @btn_focused && id == @btn_focused.get_id
78
- get_text_from_user("Dummy prompt", "Modal dialog called from dialog",
79
- "", self)
80
- else
81
- event.skip()
82
- end
83
- end
84
- end
85
-
86
-
87
- class MyModelessDialog < Dialog
88
- def initialize(parent)
89
- super(parent, -1, "Modeless dialog")
90
-
91
- sizer_top = BoxSizer.new(VERTICAL)
92
-
93
- btn = Button.new(self, DIALOGS_MODELESS_BTN, "Press me")
94
- check = CheckBox.new(self, -1, "Should be disabled")
95
- check.disable()
96
-
97
- sizer_top.add(btn, 1, EXPAND | ALL, 5)
98
- sizer_top.add(check, 1, EXPAND | ALL, 5)
99
-
100
- set_auto_layout(true)
101
- set_sizer(sizer_top)
102
-
103
- sizer_top.set_size_hints(self)
104
- sizer_top.fit(self)
105
-
106
- evt_button(DIALOGS_MODELESS_BTN) {|event| on_button(event) }
107
-
108
- evt_close() {|event| on_close(event) }
109
-
110
- end
111
-
112
- def on_button(event)
113
- message_box("Button pressed in modeless dialog", "Info",
114
- OK | ICON_INFORMATION, self)
115
- end
116
-
117
- def on_close(event)
118
- if event.can_veto()
119
- message_box("Use the menu item to close self dialog",
120
- "Modeless dialog",
121
- OK | ICON_INFORMATION, self)
122
-
123
- event.veto()
124
- end
125
- end
126
- end
127
-
128
-
129
- class MyCanvas < ScrolledWindow
130
- def initialize(parent)
131
- super(parent,-1,DEFAULT_POSITION,DEFAULT_SIZE, NO_FULL_REPAINT_ON_RESIZE)
132
- evt_paint { |event| on_paint(event) }
133
- end
134
-
135
- def clear
136
-
137
- end
138
-
139
- def on_paint(event)
140
- paint do |dc|
141
- dc.set_text_foreground( get_app.canvas_text_colour )
142
- dc.set_font( get_app.canvas_font )
143
- dc.draw_text("Windows common dialogs test application", 10, 10)
144
- end
145
- end
146
- end
147
-
148
- class MyFrame < Frame
149
- def initialize(parent,
150
- title,
151
- pos,
152
- size)
153
- super(parent, -1, title, pos, size)
154
-
155
- @dialog = nil
156
-
157
- @dlg_find = nil
158
- @dlg_replace = nil
159
-
160
- @find_data = FindReplaceData.new
161
-
162
- @ext_def = ""
163
- @index = -1
164
-
165
- @max = 10
166
-
167
- create_status_bar()
168
-
169
- evt_menu(DIALOGS_CHOOSE_COLOUR) {|event| on_choose_colour(event) }
170
- evt_menu(DIALOGS_CHOOSE_FONT) {|event| on_choose_font(event) }
171
- evt_menu(DIALOGS_LOG_DIALOG) {|event| on_log_dialog(event) }
172
- evt_menu(DIALOGS_MESSAGE_BOX) {|event| on_message_box(event) }
173
- evt_menu(DIALOGS_TEXT_ENTRY) {|event| on_text_entry(event) }
174
- evt_menu(DIALOGS_PASSWORD_ENTRY) {|event| on_password_entry(event) }
175
- evt_menu(DIALOGS_NUM_ENTRY) {|event| on_numeric_entry(event) }
176
- evt_menu(DIALOGS_SINGLE_CHOICE) {|event| on_single_choice(event) }
177
- evt_menu(DIALOGS_MULTI_CHOICE) {|event| on_multi_choice(event) }
178
- evt_menu(DIALOGS_FILE_OPEN) {|event| on_file_open(event) }
179
- evt_menu(DIALOGS_FILE_OPEN2) {|event| on_file_open2(event) }
180
- evt_menu(DIALOGS_FILES_OPEN) {|event| on_files_open(event) }
181
- evt_menu(DIALOGS_FILE_SAVE) {|event| on_file_save(event) }
182
- evt_menu(DIALOGS_DIR_CHOOSE) {|event| on_dir_choose(event) }
183
- evt_menu(DIALOGS_MODAL) {|event| on_modal_dlg(event) }
184
- evt_menu(DIALOGS_MODELESS) {|event| on_modeless_dlg(event) }
185
- evt_menu(DIALOGS_TIP) {|event| on_show_tip(event) }
186
- evt_menu(DIALOGS_PROGRESS) {|event| on_show_progress(event) }
187
- evt_menu(DIALOGS_BUSYINFO) {|event| on_show_busy_info(event) }
188
- evt_menu(DIALOGS_FIND) {|event| on_show_find_dialog(event) }
189
- evt_menu(DIALOGS_REPLACE) {|event| on_show_replace_dialog(event) }
190
- evt_find(-1) {|event| on_find_dialog(event) }
191
- evt_find_next(-1) {|event| on_find_dialog(event) }
192
- evt_find_replace(-1) {|event| on_find_dialog(event) }
193
- evt_find_replace_all(-1) {|event| on_find_dialog(event) }
194
- evt_find_close(-1) {|event| on_find_dialog(event) }
195
- evt_menu(ID_EXIT) {|event| on_exit(event) }
196
-
197
- end
198
-
199
- def on_choose_colour(event)
200
-
201
- col = $my_canvas.get_background_colour()
202
-
203
- data = ColourData.new
204
- data.set_colour(col)
205
- data.set_choose_full(true)
206
- for i in 0 ... 16
207
- colour = Colour.new(i*16, i*16, i*16)
208
- data.set_custom_colour(i, colour)
209
- end
210
-
211
- dialog = ColourDialog.new(self, data)
212
- dialog.set_title("Choose the background colour (not OS X)")
213
- if dialog.show_modal() == ID_OK
214
- retData = dialog.get_colour_data()
215
- col = retData.get_colour()
216
- $my_canvas.set_background_colour(col)
217
- #$my_canvas.clear()
218
- $my_canvas.refresh()
219
- end
220
- end
221
-
222
-
223
- def on_choose_font(event)
224
- data = FontData.new
225
- data.set_initial_font(Wx::get_app.canvas_font)
226
- data.set_colour(Wx::get_app.canvas_text_colour)
227
-
228
- dialog = FontDialog.new(self, data)
229
-
230
- if dialog.show_modal() == ID_OK
231
- ret_data = dialog.get_font_data()
232
- Wx::get_app.canvas_font = ret_data.get_chosen_font()
233
- Wx::get_app.canvas_text_colour = ret_data.get_colour()
234
- font = ret_data.get_chosen_font
235
- msg = "Font = %s, %i pt" % [ font.get_face_name,
236
- font.get_point_size ]
237
- dialog2 = MessageDialog.new(self, msg, "Got font")
238
- dialog2.show_modal()
239
- # $my_canvas.refresh()
240
- end
241
- #else: cancelled by the user, don't change the font
242
- end
243
-
244
-
245
- def on_log_dialog(event)
246
-
247
- # calling yield() (as ~BusyCursor does) shouldn't result in messages
248
- # being flushed -- test it
249
-
250
- BusyCursor.busy() do
251
-
252
- log_message("This is some message - everything is ok so far.")
253
- log_message("Another message...\n... self one is on multiple lines")
254
- log_warning("And then something went wrong!")
255
-
256
- # and if ~BusyCursor doesn't do it, then call it manually
257
- Wx::get_app.yield()
258
-
259
- log_error("Intermediary error handler decided to abort.")
260
- log_error("DEMO: The top level caller detected an unrecoverable error.")
261
-
262
- Log::flush_active()
263
-
264
- log_message("And this is the same dialog but with only one message.")
265
- end
266
- end
267
-
268
- def on_message_box(event)
269
-
270
- dialog = MessageDialog.new(nil, "This is a message box\nA long, long string to test out the message box properly",
271
- "Message box text", NO_DEFAULT|YES_NO|CANCEL|ICON_INFORMATION)
272
-
273
- case dialog.show_modal()
274
- when ID_YES
275
- log_status("You pressed \"Yes\"")
276
- when ID_NO
277
- log_status("You pressed \"No\"")
278
- when ID_CANCEL
279
- log_status("You pressed \"Cancel\"")
280
- else
281
- log_error("Unexpected MessageDialog return code!")
282
- end
283
- end
284
-
285
-
286
- def on_numeric_entry(event)
287
-
288
- res = get_number_from_user( "This is some text, actually a lot of text.\n" +
289
- "Even two rows of text.",
290
- "Enter a number:", "Numeric input test",
291
- 50, 0, 100, self )
292
-
293
- if res == -1
294
- msg = "Invalid number entered or dialog cancelled."
295
- icon = ICON_HAND
296
- else
297
- msg = sprintf("You've entered %d", res )
298
- icon = ICON_INFORMATION
299
- end
300
-
301
- message_box(msg, "Numeric test result", OK | icon, self)
302
- end
303
-
304
- def on_password_entry(event)
305
-
306
- pwd = get_password_from_user("Enter password:",
307
- "Password entry dialog",
308
- "", self)
309
- if pwd
310
- message_box(sprintf("Your password is '%s'", pwd),
311
- "Got password", OK | ICON_INFORMATION, self)
312
- end
313
- end
314
-
315
-
316
- def on_text_entry(event)
317
-
318
- dialog = TextEntryDialog.new(self,
319
- "This is a small sample\n" +
320
- "A long, long string to test out the text entrybox",
321
- "Please enter a string",
322
- "Default value",
323
- OK | CANCEL)
324
-
325
- if dialog.show_modal() == ID_OK
326
- dialog2 = MessageDialog.new(self, dialog.get_value(), "Got string")
327
- dialog2.show_modal()
328
- end
329
- end
330
-
331
- def on_single_choice(event)
332
-
333
- choices = ["One", "Two", "Three", "Four", "Five"]
334
-
335
- dialog = SingleChoiceDialog.new(self,
336
- "This is a small sample\n" +
337
- "A single-choice convenience dialog",
338
- "Please select a value",
339
- choices, nil, OK | CANCEL)
340
-
341
- dialog.set_selection(2)
342
-
343
- if dialog.show_modal() == ID_OK
344
- dialog2 = MessageDialog.new(self, dialog.get_string_selection(), "Got string")
345
- dialog2.show_modal()
346
- end
347
- end
348
-
349
-
350
- def on_multi_choice(event)
351
-
352
- choices = [
353
- "One", "Two", "Three", "Four", "Five",
354
- "Six", "Seven", "Eight", "Nine", "Ten",
355
- "Eleven", "Twelve", "Seventeen"]
356
-
357
- selections = get_multiple_choices("This is a small sample\n" +
358
- "A multi-choice convenience dialog",
359
- "Please select a value",
360
- choices,
361
- self)
362
- if selections
363
- msg = sprintf("You selected %d items:\n", selections.length)
364
- for n in 0 ... selections.length
365
- msg += sprintf("\t%d: %d (%s)\n", n, selections[n],
366
- choices[selections[n]])
367
- end
368
- log_message(msg)
369
- end
370
- #else: cancelled or nothing selected
371
- end
372
-
373
-
374
- def on_file_open(event)
375
-
376
- dialog = FileDialog.new(
377
- self,
378
- "Testing open file dialog",
379
- "",
380
- "",
381
- "C++ files (*.h;*.cpp)|*.h;*.cpp"
382
- )
383
-
384
- dialog.set_directory(get_home_dir())
385
-
386
- if dialog.show_modal() == ID_OK
387
- info = sprintf("Full file name: %s\n" +
388
- "Path: %s\n" +
389
- "Name: %s",
390
- dialog.get_path(),
391
- dialog.get_directory(),
392
- dialog.get_filename())
393
- dialog2 = MessageDialog.new(self, info, "Selected file")
394
- dialog2.show_modal()
395
- end
396
- end
397
-
398
-
399
- # this shows how to take advantage of specifying a default extension in the
400
- # call to FileSelector: it is remembered after each new call and the next
401
- # one will use it by default
402
- def on_file_open2(event)
403
-
404
- path = file_selector(
405
- "Select the file to load",
406
- "", "",
407
- @ext_def,
408
- "Waveform (*.wav)|*.wav|Plain text (*.txt)|*.txt|All files (*.*)|*.*",
409
- CHANGE_DIR,
410
- self
411
- )
412
-
413
- if path == nil
414
- return nil
415
- end
416
-
417
- # it is just a sample, would use SplitPath in real program
418
- @ext_def = path[/[^\.]*$/]
419
-
420
- log_message("You selected the file '%s', remembered extension '%s'",
421
- path, @ext_def)
422
- end
423
-
424
-
425
- def on_files_open(event)
426
-
427
- dialog = FileDialog.new(self, "Testing open multiple file dialog",
428
- "", "", FILE_SELECTOR_DEFAULT_WILDCARD_STR,
429
- MULTIPLE)
430
-
431
- if dialog.show_modal() == ID_OK
432
-
433
- paths = dialog.get_paths()
434
- filenames = dialog.get_filenames()
435
-
436
- count = paths.length
437
- msg = ""
438
- for n in 0 ... count
439
- s = sprintf("File %d: %s (%s)\n",
440
- n, paths[n], filenames[n])
441
- msg += s
442
- end
443
-
444
- dialog2 = MessageDialog.new(self, msg, "Selected files")
445
- dialog2.show_modal()
446
- end
447
- end
448
-
449
-
450
- def on_file_save(event)
451
-
452
- dialog = FileDialog.new(self,
453
- "Testing save file dialog",
454
- "",
455
- "myletter.doc",
456
- "Text files (*.txt)|*.txt|Document files (*.doc)|*.doc",
457
- SAVE|OVERWRITE_PROMPT)
458
-
459
- dialog.set_filter_index(1)
460
-
461
- if dialog.show_modal() == ID_OK
462
-
463
- log_message("%s, filter %d",
464
- dialog.get_path(), dialog.get_filter_index())
465
- end
466
- end
467
-
468
- def on_dir_choose(event)
469
-
470
- # pass some initial dir to DirDialog
471
- dir_home = get_home_dir()
472
-
473
- dialog = DirDialog.new(self, "Testing directory picker", dir_home)
474
-
475
- if dialog.show_modal() == ID_OK
476
- log_message("Selected path: %s", dialog.get_path())
477
- end
478
- end
479
-
480
-
481
- def on_modal_dlg(event)
482
- dlg = MyModalDialog.new(self)
483
- dlg.show_modal()
484
- end
485
-
486
- def on_modeless_dlg(event)
487
- show = get_menu_bar().is_checked(event.get_id())
488
- if show
489
- if !@dialog
490
- @dialog = MyModelessDialog.new(self)
491
- end
492
- @dialog.show(true)
493
- else # hide
494
- @dialog.hide()
495
- end
496
- end
497
-
498
-
499
- def on_show_tip(event)
500
-
501
- if @index == -1
502
- @index = rand(5)
503
- end
504
-
505
- tip_src = File.join( File.dirname(__FILE__), 'tips.txt')
506
- tip_provider = create_file_tip_provider(tip_src, @index)
507
-
508
- show_at_startup = show_tip(self, tip_provider)
509
-
510
- if show_at_startup
511
- message_box("Will show tips on startup", "Tips dialog",
512
- OK | ICON_INFORMATION, self)
513
- end
514
-
515
- @index = tip_provider.get_current_tip()
516
-
517
- end
518
-
519
- def on_exit(event)
520
- close(true)
521
- end
522
-
523
-
524
- def on_show_progress(event)
525
-
526
- dialog = ProgressDialog.new("Progress dialog example",
527
- "An informative message",
528
- @max, # range
529
- self, # parent
530
- PD_CAN_ABORT|PD_APP_MODAL|
531
- PD_ELAPSED_TIME|PD_ESTIMATED_TIME|
532
- PD_REMAINING_TIME)
533
-
534
- cont = true
535
- for i in 0 .. @max
536
- sleep(1)
537
- if i == @max
538
- cont = dialog.update(i, "That's all, folks!")
539
- elsif i == @max / 2
540
- cont = dialog.update(i, "Only a half left (very long message)!")
541
- else
542
- cont = dialog.update(i)
543
- end
544
-
545
- if !cont
546
- if message_box("Do you really want to cancel?",
547
- "Progress dialog question", # caption
548
- YES_NO | ICON_QUESTION) == YES
549
- dialog.end_modal(ID_CANCEL)
550
- break
551
- end
552
- dialog.resume()
553
- end
554
- end
555
-
556
-
557
- if !cont
558
- log_status("Progress dialog aborted!")
559
- else
560
- log_status("Countdown from %d finished", @max)
561
- end
562
- end
563
-
564
- def on_show_busy_info(event)
565
- WindowDisabler.disable(self) do
566
- info = BusyInfo.busy("Working, please wait...", self) do
567
-
568
- for i in 0 ... 18
569
- Wx::get_app.yield()
570
- end
571
- sleep(2)
572
- end
573
- end
574
- end
575
-
576
- def on_show_replace_dialog(event)
577
-
578
- if @dlg_replace
579
- #@dlg_replace.destroy
580
- @dlg_replace = nil
581
- else
582
- @dlg_replace = FindReplaceDialog.new(
583
- self,
584
- @find_data,
585
- "Find and replace dialog",
586
- FR_REPLACEDIALOG
587
- )
588
-
589
- @dlg_replace.show(true)
590
- end
591
- end
592
-
593
- def on_show_find_dialog(event)
594
-
595
- if @dlg_find
596
- @dlg_find.destroy
597
- @dlg_find = nil
598
- else
599
- @dlg_find = FindReplaceDialog.new(
600
- self,
601
- @find_data,
602
- "Find dialog", # just for testing
603
- FR_NOWHOLEWORD
604
- )
605
-
606
- @dlg_find.show(true)
607
- end
608
- end
609
-
610
- def decode_find_dialog_event_flags(flags)
611
- str = ""
612
- str << ((flags & FR_DOWN) != 0 ? "down" : "up") << ", " \
613
- << ((flags & FR_WHOLEWORD) != 0 ? "whole words only, " : "") \
614
- << ((flags & FR_MATCHCASE) != 0 ? "" : "not ") \
615
- << "case sensitive"
616
-
617
- return str
618
- end
619
-
620
- def on_find_dialog(event)
621
-
622
- type = event.get_event_type()
623
-
624
- if type == EVT_COMMAND_FIND || type == EVT_COMMAND_FIND_NEXT
625
- log_message("Find %s'%s' (flags: %s)",
626
- type == EVT_COMMAND_FIND_NEXT ? "next " : "",
627
- event.get_find_string(),
628
- decode_find_dialog_event_flags(event.get_flags()))
629
- elsif type == EVT_COMMAND_FIND_REPLACE || type == EVT_COMMAND_FIND_REPLACE_ALL
630
- log_message("Replace %s'%s' with '%s' (flags: %s)",
631
- type == EVT_COMMAND_FIND_REPLACE_ALL ? "all " : "",
632
- event.get_find_string(),
633
- event.get_replace_string(),
634
- decode_find_dialog_event_flags(event.get_flags()))
635
- elsif type == EVT_COMMAND_FIND_CLOSE
636
- dlg = event.get_dialog()
637
- if dlg == @dlg_find
638
- txt = "Find"
639
- id_menu = DIALOGS_FIND
640
- @dlg_find = nil
641
- elsif dlg == @dlg_replace
642
- txt = "Replace"
643
- id_menu = DIALOGS_REPLACE
644
- @dlg_replace = nil
645
- else
646
- txt = "Unknown"
647
- id_menu = -1
648
- log_error("unexpected event")
649
- end
650
-
651
- log_message("%s dialog is being closed.", txt)
652
-
653
- if id_menu != -1
654
- get_menu_bar().check(id_menu, false)
655
- end
656
-
657
- dlg.destroy()
658
- else
659
- log_error("Unknown find dialog event!")
660
- end
661
- end
662
-
663
- end
664
-
665
-
666
- class MyApp < App
667
- attr_accessor :canvas_text_colour, :canvas_font
668
-
669
- def on_init()
670
- self.canvas_text_colour = Wx::Colour.new("BLACK")
671
- self.canvas_font = Wx::NORMAL_FONT
672
- # Create the main frame window
673
- frame = MyFrame.new(nil, "Windows dialogs example",
674
- Point.new(20, 20), Size.new(400, 300))
675
-
676
- # Make a menubar
677
- file_menu = Menu.new
678
-
679
- file_menu.append(DIALOGS_CHOOSE_COLOUR, "&Choose colour")
680
- file_menu.append_separator()
681
- file_menu.append(DIALOGS_CHOOSE_FONT, "Choose &font")
682
- file_menu.append_separator()
683
- file_menu.append(DIALOGS_LOG_DIALOG, "&Log dialog\tCtrl-L")
684
- file_menu.append(DIALOGS_MESSAGE_BOX, "&Message box\tCtrl-M")
685
- file_menu.append(DIALOGS_TEXT_ENTRY, "Text &entry\tCtrl-E")
686
- file_menu.append(DIALOGS_PASSWORD_ENTRY, "&Password entry\tCtrl-P")
687
- file_menu.append(DIALOGS_NUM_ENTRY, "&Numeric entry\tCtrl-N")
688
- file_menu.append(DIALOGS_SINGLE_CHOICE, "&Single choice\tCtrl-C")
689
- file_menu.append(DIALOGS_MULTI_CHOICE, "M&ultiple choice\tCtrl-U")
690
- file_menu.append_separator()
691
- file_menu.append(DIALOGS_TIP, "&Tip of the day\tCtrl-T")
692
- file_menu.append_separator()
693
- file_menu.append(DIALOGS_FILE_OPEN, "&Open file\tCtrl-O")
694
- file_menu.append(DIALOGS_FILE_OPEN2, "&Second open file\tCtrl-2")
695
- file_menu.append(DIALOGS_FILES_OPEN, "Open &files\tShift-Ctrl-O")
696
- file_menu.append(DIALOGS_FILE_SAVE, "Sa&ve file\tCtrl-S")
697
- file_menu.append(DIALOGS_DIR_CHOOSE, "&Choose a directory\tCtrl-D")
698
- file_menu.append(DIALOGS_PROGRESS, "Pro&gress dialog\tCtrl-G")
699
- file_menu.append(DIALOGS_BUSYINFO, "&Busy info dialog\tCtrl-B")
700
- file_menu.append(DIALOGS_FIND, "&Find dialog\tCtrl-F", "", ITEM_CHECK)
701
- file_menu.append(DIALOGS_REPLACE, "Find and &replace dialog\tShift-Ctrl-F", "", ITEM_CHECK)
702
- file_menu.append_separator()
703
- file_menu.append(DIALOGS_MODAL, "Mo&dal dialog\tCtrl-W")
704
- file_menu.append(DIALOGS_MODELESS, "Modeless &dialog\tCtrl-Z", "", ITEM_CHECK)
705
- file_menu.append_separator()
706
- file_menu.append(ID_EXIT, "E&xit\tAlt-X")
707
- menu_bar = MenuBar.new
708
- menu_bar.append(file_menu, "&File")
709
- frame.set_menu_bar(menu_bar)
710
-
711
- $my_canvas = MyCanvas.new(frame)
712
- $my_canvas.set_background_colour(WHITE)
713
-
714
- frame.centre(BOTH)
715
-
716
- # Show the frame
717
- frame.show()
718
- end
719
- end
720
-
721
- app = MyApp.new()
722
- app.main_loop()
723
-
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
+ require 'wx'
12
+
13
+
14
+ include Wx
15
+
16
+ DIALOGS_CHOOSE_COLOUR = 1
17
+ DIALOGS_CHOOSE_COLOUR_GENERIC = 2
18
+ DIALOGS_CHOOSE_FONT = 3
19
+ DIALOGS_CHOOSE_FONT_GENERIC = 4
20
+ DIALOGS_MESSAGE_BOX = 5
21
+ DIALOGS_SINGLE_CHOICE = 6
22
+ DIALOGS_MULTI_CHOICE = 7
23
+ DIALOGS_TEXT_ENTRY = 8
24
+ DIALOGS_PASSWORD_ENTRY = 9
25
+ DIALOGS_FILE_OPEN = 10
26
+ DIALOGS_FILE_OPEN2 = 11
27
+ DIALOGS_FILES_OPEN = 12
28
+ DIALOGS_FILE_SAVE = 13
29
+ DIALOGS_DIR_CHOOSE = 14
30
+ DIALOGS_GENERIC_DIR_CHOOSE = 15
31
+ DIALOGS_TIP = 16
32
+ DIALOGS_NUM_ENTRY = 17
33
+ DIALOGS_LOG_DIALOG = 18
34
+ DIALOGS_MODAL = 19
35
+ DIALOGS_MODELESS = 20
36
+ DIALOGS_MODELESS_BTN = 21
37
+ DIALOGS_PROGRESS = 22
38
+ DIALOGS_BUSYINFO = 23
39
+ DIALOGS_FIND = 24
40
+ DIALOGS_REPLACE = 25
41
+ DIALOGS_PREFS = 26
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
+ # PropertySheetDialog is specialised for doing preferences dialogs; it
130
+ # contains a BookCtrl of some sort
131
+ class MyPrefsDialog < Wx::PropertySheetDialog
132
+ def initialize(parent)
133
+ # Using Book type other than Notebook needs two-step construction
134
+ super()
135
+ self.sheet_style = Wx::PROPSHEET_BUTTONTOOLBOOK
136
+ self.sheet_outer_border = 1
137
+ self.sheet_inner_border = 2
138
+ img_list = Wx::ImageList.new(32, 32)
139
+ img_list << std_bitmap(Wx::ART_NORMAL_FILE)
140
+ img_list << std_bitmap(Wx::ART_CDROM)
141
+ img_list << std_bitmap(Wx::ART_REPORT_VIEW)
142
+
143
+ create(parent, -1, "Preferences")
144
+ create_buttons(Wx::ID_OK|Wx::ID_CANCEL)
145
+ book_ctrl.image_list = img_list
146
+ book_ctrl.add_page(file_panel(book_ctrl), "File", false, 0)
147
+ book_ctrl.add_page(cdrom_panel(book_ctrl), "CD ROM", false, 1)
148
+
149
+ layout_dialog
150
+ end
151
+
152
+ # Gets one of the rather ugly standard bitmaps from ArtProvider
153
+ def std_bitmap(art_id)
154
+ Wx::ArtProvider.bitmap(art_id, Wx::ART_TOOLBAR, [32, 32])
155
+ end
156
+
157
+ def file_panel(book)
158
+ panel = Wx::Panel.new(book)
159
+ panel.sizer = Wx::VBoxSizer.new
160
+
161
+ cb1 = Wx::CheckBox.new(panel, :label => 'Show hidden files')
162
+ panel.sizer.add(cb1, 0, Wx::ALL, 5)
163
+
164
+ cb2 = Wx::CheckBox.new(panel, :label => 'Always show extensions')
165
+ panel.sizer.add(cb2, 0, Wx::ALL, 5)
166
+
167
+ cb3 = Wx::CheckBox.new(panel, :label => 'Show icons')
168
+ panel.sizer.add(cb3, 0, Wx::ALL, 5)
169
+
170
+ cb4 = Wx::CheckBox.new(panel, :label => 'Show owner')
171
+ panel.sizer.add(cb4, 0, Wx::ALL, 5)
172
+
173
+ st = Wx::StaticText.new(panel, :label => "Sort by:")
174
+ panel.sizer.add(st, 0, Wx::ALL, 5)
175
+
176
+ cb1 = Wx::Choice.new(panel, :choices => %w|Name Created Modified Size|)
177
+ panel.sizer.add(cb1, 0, Wx::ALL, 5)
178
+ panel
179
+ end
180
+
181
+ def cdrom_panel(book)
182
+ panel = Wx::Panel.new(book)
183
+ panel.sizer = Wx::VBoxSizer.new
184
+
185
+ choices = [ 'Show files', 'Play media', 'Run CD', 'Do nothing' ]
186
+ rb = Wx::RadioBox.new( panel,
187
+ :label => 'When opening CD',
188
+ :choices => choices,
189
+ :major_dimension => 1)
190
+ panel.sizer.add(rb, 0, Wx::GROW|Wx::ALL, 5)
191
+ panel
192
+ end
193
+ end
194
+
195
+ class MyCanvas < ScrolledWindow
196
+ def initialize(parent)
197
+ super(parent,-1,DEFAULT_POSITION,DEFAULT_SIZE, NO_FULL_REPAINT_ON_RESIZE)
198
+ evt_paint { |event| on_paint(event) }
199
+ end
200
+
201
+ def clear
202
+
203
+ end
204
+
205
+ def on_paint(event)
206
+ paint do |dc|
207
+ dc.set_text_foreground( get_app.canvas_text_colour )
208
+ dc.set_font( get_app.canvas_font )
209
+ dc.draw_text("Windows common dialogs test application", 10, 10)
210
+ end
211
+ end
212
+ end
213
+
214
+ class MyFrame < Frame
215
+ def initialize(parent,
216
+ title,
217
+ pos,
218
+ size)
219
+ super(parent, -1, title, pos, size)
220
+
221
+ @dialog = nil
222
+
223
+ @dlg_find = nil
224
+ @dlg_replace = nil
225
+
226
+ @find_data = FindReplaceData.new
227
+
228
+ @ext_def = ""
229
+ @index = -1
230
+
231
+ @max = 10
232
+
233
+ create_status_bar()
234
+
235
+ evt_menu(DIALOGS_CHOOSE_COLOUR) {|event| on_choose_colour(event) }
236
+ evt_menu(DIALOGS_CHOOSE_FONT) {|event| on_choose_font(event) }
237
+ evt_menu(DIALOGS_LOG_DIALOG) {|event| on_log_dialog(event) }
238
+ evt_menu(DIALOGS_MESSAGE_BOX) {|event| on_message_box(event) }
239
+ evt_menu(DIALOGS_TEXT_ENTRY) {|event| on_text_entry(event) }
240
+ evt_menu(DIALOGS_PASSWORD_ENTRY) {|event| on_password_entry(event) }
241
+ evt_menu(DIALOGS_NUM_ENTRY) {|event| on_numeric_entry(event) }
242
+ evt_menu(DIALOGS_SINGLE_CHOICE) {|event| on_single_choice(event) }
243
+ evt_menu(DIALOGS_MULTI_CHOICE) {|event| on_multi_choice(event) }
244
+ evt_menu(DIALOGS_FILE_OPEN) {|event| on_file_open(event) }
245
+ evt_menu(DIALOGS_FILE_OPEN2) {|event| on_file_open2(event) }
246
+ evt_menu(DIALOGS_FILES_OPEN) {|event| on_files_open(event) }
247
+ evt_menu(DIALOGS_FILE_SAVE) {|event| on_file_save(event) }
248
+ evt_menu(DIALOGS_DIR_CHOOSE) {|event| on_dir_choose(event) }
249
+ evt_menu(DIALOGS_MODAL) {|event| on_modal_dlg(event) }
250
+ evt_menu(DIALOGS_MODELESS) {|event| on_modeless_dlg(event) }
251
+ evt_menu(DIALOGS_TIP) {|event| on_show_tip(event) }
252
+ evt_menu(DIALOGS_PROGRESS) {|event| on_show_progress(event) }
253
+ evt_menu(DIALOGS_BUSYINFO) {|event| on_show_busy_info(event) }
254
+ evt_menu(DIALOGS_PREFS) {|event| on_show_prefs(event) }
255
+ evt_menu(DIALOGS_FIND) {|event| on_show_find_dialog(event) }
256
+ evt_menu(DIALOGS_REPLACE) {|event| on_show_replace_dialog(event) }
257
+ evt_find(-1) {|event| on_find_dialog(event) }
258
+ evt_find_next(-1) {|event| on_find_dialog(event) }
259
+ evt_find_replace(-1) {|event| on_find_dialog(event) }
260
+ evt_find_replace_all(-1) {|event| on_find_dialog(event) }
261
+ evt_find_close(-1) {|event| on_find_dialog(event) }
262
+ evt_menu(ID_EXIT) {|event| on_exit(event) }
263
+
264
+ end
265
+
266
+ def on_choose_colour(event)
267
+
268
+ col = $my_canvas.get_background_colour()
269
+
270
+ data = ColourData.new
271
+ data.set_colour(col)
272
+ data.set_choose_full(true)
273
+ for i in 0 ... 16
274
+ colour = Colour.new(i*16, i*16, i*16)
275
+ data.set_custom_colour(i, colour)
276
+ end
277
+
278
+ dialog = ColourDialog.new(self, data)
279
+ dialog.set_title("Choose the background colour (not OS X)")
280
+ if dialog.show_modal() == ID_OK
281
+ retData = dialog.get_colour_data()
282
+ col = retData.get_colour()
283
+ $my_canvas.set_background_colour(col)
284
+ #$my_canvas.clear()
285
+ $my_canvas.refresh()
286
+ end
287
+ end
288
+
289
+
290
+ def on_choose_font(event)
291
+ data = FontData.new
292
+ data.set_initial_font(Wx::get_app.canvas_font)
293
+ data.set_colour(Wx::get_app.canvas_text_colour)
294
+
295
+ dialog = FontDialog.new(self, data)
296
+
297
+ if dialog.show_modal() == ID_OK
298
+ ret_data = dialog.get_font_data()
299
+ Wx::get_app.canvas_font = ret_data.get_chosen_font()
300
+ Wx::get_app.canvas_text_colour = ret_data.get_colour()
301
+ font = ret_data.get_chosen_font
302
+ msg = "Font = %s, %i pt" % [ font.get_face_name,
303
+ font.get_point_size ]
304
+ dialog2 = MessageDialog.new(self, msg, "Got font")
305
+ dialog2.show_modal()
306
+ # $my_canvas.refresh()
307
+ end
308
+ #else: cancelled by the user, don't change the font
309
+ end
310
+
311
+
312
+ def on_log_dialog(event)
313
+
314
+ # calling yield() (as ~BusyCursor does) shouldn't result in messages
315
+ # being flushed -- test it
316
+
317
+ BusyCursor.busy() do
318
+
319
+ log_message("This is some message - everything is ok so far.")
320
+ log_message("Another message...\n... self one is on multiple lines")
321
+ log_warning("And then something went wrong!")
322
+
323
+ # and if ~BusyCursor doesn't do it, then call it manually
324
+ Wx::get_app.yield()
325
+
326
+ log_error("Intermediary error handler decided to abort.")
327
+ log_error("DEMO: The top level caller detected an unrecoverable error.")
328
+
329
+ Log::flush_active()
330
+
331
+ log_message("And this is the same dialog but with only one message.")
332
+ end
333
+ end
334
+
335
+ def on_message_box(event)
336
+
337
+ dialog = MessageDialog.new(nil, "This is a message box\nA long, long string to test out the message box properly",
338
+ "Message box text", NO_DEFAULT|YES_NO|CANCEL|ICON_INFORMATION)
339
+
340
+ case dialog.show_modal()
341
+ when ID_YES
342
+ log_status("You pressed \"Yes\"")
343
+ when ID_NO
344
+ log_status("You pressed \"No\"")
345
+ when ID_CANCEL
346
+ log_status("You pressed \"Cancel\"")
347
+ else
348
+ log_error("Unexpected MessageDialog return code!")
349
+ end
350
+ end
351
+
352
+
353
+ def on_numeric_entry(event)
354
+
355
+ res = get_number_from_user( "This is some text, actually a lot of text.\n" +
356
+ "Even two rows of text.",
357
+ "Enter a number:", "Numeric input test",
358
+ 50, 0, 100, self )
359
+
360
+ if res == -1
361
+ msg = "Invalid number entered or dialog cancelled."
362
+ icon = ICON_HAND
363
+ else
364
+ msg = sprintf("You've entered %d", res )
365
+ icon = ICON_INFORMATION
366
+ end
367
+
368
+ message_box(msg, "Numeric test result", OK | icon, self)
369
+ end
370
+
371
+ def on_password_entry(event)
372
+
373
+ pwd = get_password_from_user("Enter password:",
374
+ "Password entry dialog",
375
+ "", self)
376
+ if pwd
377
+ message_box(sprintf("Your password is '%s'", pwd),
378
+ "Got password", OK | ICON_INFORMATION, self)
379
+ end
380
+ end
381
+
382
+
383
+ def on_text_entry(event)
384
+
385
+ dialog = TextEntryDialog.new(self,
386
+ "This is a small sample\n" +
387
+ "A long, long string to test out the text entrybox",
388
+ "Please enter a string",
389
+ "Default value",
390
+ OK | CANCEL)
391
+
392
+ if dialog.show_modal() == ID_OK
393
+ dialog2 = MessageDialog.new(self, dialog.get_value(), "Got string")
394
+ dialog2.show_modal()
395
+ end
396
+ end
397
+
398
+ def on_single_choice(event)
399
+
400
+ choices = ["One", "Two", "Three", "Four", "Five"]
401
+
402
+ dialog = SingleChoiceDialog.new(self,
403
+ "This is a small sample\n" +
404
+ "A single-choice convenience dialog",
405
+ "Please select a value",
406
+ choices, nil, OK | CANCEL)
407
+
408
+ dialog.set_selection(2)
409
+
410
+ if dialog.show_modal() == ID_OK
411
+ dialog2 = MessageDialog.new(self, dialog.get_string_selection(), "Got string")
412
+ dialog2.show_modal()
413
+ end
414
+ end
415
+
416
+
417
+ def on_multi_choice(event)
418
+
419
+ choices = [
420
+ "One", "Two", "Three", "Four", "Five",
421
+ "Six", "Seven", "Eight", "Nine", "Ten",
422
+ "Eleven", "Twelve", "Seventeen"]
423
+
424
+ selections = get_multiple_choices("This is a small sample\n" +
425
+ "A multi-choice convenience dialog",
426
+ "Please select a value",
427
+ choices,
428
+ self)
429
+ if selections
430
+ msg = sprintf("You selected %d items:\n", selections.length)
431
+ for n in 0 ... selections.length
432
+ msg += sprintf("\t%d: %d (%s)\n", n, selections[n],
433
+ choices[selections[n]])
434
+ end
435
+ log_message(msg)
436
+ end
437
+ #else: cancelled or nothing selected
438
+ end
439
+
440
+
441
+ def on_file_open(event)
442
+
443
+ dialog = FileDialog.new(
444
+ self,
445
+ "Testing open file dialog",
446
+ "",
447
+ "",
448
+ "C++ files (*.h;*.cpp)|*.h;*.cpp"
449
+ )
450
+
451
+ dialog.set_directory(get_home_dir())
452
+
453
+ if dialog.show_modal() == ID_OK
454
+ info = sprintf("Full file name: %s\n" +
455
+ "Path: %s\n" +
456
+ "Name: %s",
457
+ dialog.get_path(),
458
+ dialog.get_directory(),
459
+ dialog.get_filename())
460
+ dialog2 = MessageDialog.new(self, info, "Selected file")
461
+ dialog2.show_modal()
462
+ end
463
+ end
464
+
465
+
466
+ # this shows how to take advantage of specifying a default extension in the
467
+ # call to FileSelector: it is remembered after each new call and the next
468
+ # one will use it by default
469
+ def on_file_open2(event)
470
+
471
+ path = file_selector(
472
+ "Select the file to load",
473
+ "", "",
474
+ @ext_def,
475
+ "Waveform (*.wav)|*.wav|Plain text (*.txt)|*.txt|All files (*.*)|*.*",
476
+ CHANGE_DIR,
477
+ self
478
+ )
479
+
480
+ if path == nil
481
+ return nil
482
+ end
483
+
484
+ # it is just a sample, would use SplitPath in real program
485
+ @ext_def = path[/[^\.]*$/]
486
+
487
+ log_message("You selected the file '%s', remembered extension '%s'",
488
+ path, @ext_def)
489
+ end
490
+
491
+
492
+ def on_files_open(event)
493
+
494
+ dialog = FileDialog.new(self, "Testing open multiple file dialog",
495
+ "", "", FILE_SELECTOR_DEFAULT_WILDCARD_STR,
496
+ MULTIPLE)
497
+
498
+ if dialog.show_modal() == ID_OK
499
+
500
+ paths = dialog.get_paths()
501
+ filenames = dialog.get_filenames()
502
+
503
+ count = paths.length
504
+ msg = ""
505
+ for n in 0 ... count
506
+ s = sprintf("File %d: %s (%s)\n",
507
+ n, paths[n], filenames[n])
508
+ msg += s
509
+ end
510
+
511
+ dialog2 = MessageDialog.new(self, msg, "Selected files")
512
+ dialog2.show_modal()
513
+ end
514
+ end
515
+
516
+
517
+ def on_file_save(event)
518
+
519
+ dialog = FileDialog.new(self,
520
+ "Testing save file dialog",
521
+ "",
522
+ "myletter.doc",
523
+ "Text files (*.txt)|*.txt|Document files (*.doc)|*.doc",
524
+ SAVE|OVERWRITE_PROMPT)
525
+
526
+ dialog.set_filter_index(1)
527
+
528
+ if dialog.show_modal() == ID_OK
529
+
530
+ log_message("%s, filter %d",
531
+ dialog.get_path(), dialog.get_filter_index())
532
+ end
533
+ end
534
+
535
+ def on_dir_choose(event)
536
+
537
+ # pass some initial dir to DirDialog
538
+ dir_home = get_home_dir()
539
+
540
+ dialog = DirDialog.new(self, "Testing directory picker", dir_home)
541
+
542
+ if dialog.show_modal() == ID_OK
543
+ log_message("Selected path: %s", dialog.get_path())
544
+ end
545
+ end
546
+
547
+
548
+ def on_modal_dlg(event)
549
+ dlg = MyModalDialog.new(self)
550
+ dlg.show_modal()
551
+ end
552
+
553
+ def on_modeless_dlg(event)
554
+ show = get_menu_bar().is_checked(event.get_id())
555
+ if show
556
+ if !@dialog
557
+ @dialog = MyModelessDialog.new(self)
558
+ end
559
+ @dialog.show(true)
560
+ else # hide
561
+ @dialog.hide()
562
+ end
563
+ end
564
+
565
+
566
+ def on_show_tip(event)
567
+
568
+ if @index == -1
569
+ @index = rand(5)
570
+ end
571
+
572
+ tip_src = File.join( File.dirname(__FILE__), 'tips.txt')
573
+ tip_provider = create_file_tip_provider(tip_src, @index)
574
+
575
+ show_at_startup = show_tip(self, tip_provider)
576
+
577
+ if show_at_startup
578
+ message_box("Will show tips on startup", "Tips dialog",
579
+ OK | ICON_INFORMATION, self)
580
+ end
581
+
582
+ @index = tip_provider.get_current_tip()
583
+
584
+ end
585
+
586
+ def on_exit(event)
587
+ close(true)
588
+ end
589
+
590
+
591
+ def on_show_prefs(event)
592
+ dialog = MyPrefsDialog.new(self)
593
+ dialog.show_modal
594
+ end
595
+
596
+ def on_show_progress(event)
597
+
598
+ dialog = ProgressDialog.new("Progress dialog example",
599
+ "An informative message",
600
+ @max, # range
601
+ self, # parent
602
+ PD_CAN_ABORT|PD_APP_MODAL|
603
+ PD_ELAPSED_TIME|PD_ESTIMATED_TIME|
604
+ PD_REMAINING_TIME)
605
+
606
+ cont = true
607
+ for i in 0 .. @max
608
+ sleep(1)
609
+ if i == @max
610
+ cont = dialog.update(i, "That's all, folks!")
611
+ elsif i == @max / 2
612
+ cont = dialog.update(i, "Only a half left (very long message)!")
613
+ else
614
+ cont = dialog.update(i)
615
+ end
616
+
617
+ if !cont
618
+ if message_box("Do you really want to cancel?",
619
+ "Progress dialog question", # caption
620
+ YES_NO | ICON_QUESTION) == YES
621
+ dialog.end_modal(ID_CANCEL)
622
+ break
623
+ end
624
+ dialog.resume()
625
+ end
626
+ end
627
+
628
+
629
+ if !cont
630
+ log_status("Progress dialog aborted!")
631
+ else
632
+ log_status("Countdown from %d finished", @max)
633
+ end
634
+ end
635
+
636
+ def on_show_busy_info(event)
637
+ WindowDisabler.disable(self) do
638
+ info = BusyInfo.busy("Working, please wait...", self) do
639
+
640
+ for i in 0 ... 18
641
+ Wx::get_app.yield()
642
+ end
643
+ sleep(2)
644
+ end
645
+ end
646
+ end
647
+
648
+ def on_show_replace_dialog(event)
649
+
650
+ if @dlg_replace
651
+ #@dlg_replace.destroy
652
+ @dlg_replace = nil
653
+ else
654
+ @dlg_replace = FindReplaceDialog.new(
655
+ self,
656
+ @find_data,
657
+ "Find and replace dialog",
658
+ FR_REPLACEDIALOG
659
+ )
660
+
661
+ @dlg_replace.show(true)
662
+ end
663
+ end
664
+
665
+ def on_show_find_dialog(event)
666
+
667
+ if @dlg_find
668
+ @dlg_find.destroy
669
+ @dlg_find = nil
670
+ else
671
+ @dlg_find = FindReplaceDialog.new(
672
+ self,
673
+ @find_data,
674
+ "Find dialog", # just for testing
675
+ FR_NOWHOLEWORD
676
+ )
677
+
678
+ @dlg_find.show(true)
679
+ end
680
+ end
681
+
682
+ def decode_find_dialog_event_flags(flags)
683
+ str = ""
684
+ str << ((flags & FR_DOWN) != 0 ? "down" : "up") << ", " \
685
+ << ((flags & FR_WHOLEWORD) != 0 ? "whole words only, " : "") \
686
+ << ((flags & FR_MATCHCASE) != 0 ? "" : "not ") \
687
+ << "case sensitive"
688
+
689
+ return str
690
+ end
691
+
692
+ def on_find_dialog(event)
693
+
694
+ type = event.get_event_type()
695
+
696
+ if type == EVT_COMMAND_FIND || type == EVT_COMMAND_FIND_NEXT
697
+ log_message("Find %s'%s' (flags: %s)",
698
+ type == EVT_COMMAND_FIND_NEXT ? "next " : "",
699
+ event.get_find_string(),
700
+ decode_find_dialog_event_flags(event.get_flags()))
701
+ elsif type == EVT_COMMAND_FIND_REPLACE || type == EVT_COMMAND_FIND_REPLACE_ALL
702
+ log_message("Replace %s'%s' with '%s' (flags: %s)",
703
+ type == EVT_COMMAND_FIND_REPLACE_ALL ? "all " : "",
704
+ event.get_find_string(),
705
+ event.get_replace_string(),
706
+ decode_find_dialog_event_flags(event.get_flags()))
707
+ elsif type == EVT_COMMAND_FIND_CLOSE
708
+ dlg = event.get_dialog()
709
+ if dlg == @dlg_find
710
+ txt = "Find"
711
+ id_menu = DIALOGS_FIND
712
+ @dlg_find = nil
713
+ elsif dlg == @dlg_replace
714
+ txt = "Replace"
715
+ id_menu = DIALOGS_REPLACE
716
+ @dlg_replace = nil
717
+ else
718
+ txt = "Unknown"
719
+ id_menu = -1
720
+ log_error("unexpected event")
721
+ end
722
+
723
+ log_message("%s dialog is being closed.", txt)
724
+
725
+ if id_menu != -1
726
+ get_menu_bar().check(id_menu, false)
727
+ end
728
+
729
+ dlg.destroy()
730
+ else
731
+ log_error("Unknown find dialog event!")
732
+ end
733
+ end
734
+
735
+ end
736
+
737
+
738
+ class MyApp < App
739
+ attr_accessor :canvas_text_colour, :canvas_font
740
+
741
+ def on_init()
742
+ self.canvas_text_colour = Wx::Colour.new("BLACK")
743
+ self.canvas_font = Wx::NORMAL_FONT
744
+ # Create the main frame window
745
+ frame = MyFrame.new(nil, "Windows dialogs example",
746
+ Point.new(20, 20), Size.new(400, 300))
747
+
748
+ # Make a menubar
749
+ file_menu = Menu.new
750
+
751
+ file_menu.append(DIALOGS_CHOOSE_COLOUR, "&Choose colour")
752
+ file_menu.append_separator()
753
+ file_menu.append(DIALOGS_CHOOSE_FONT, "Choose &font")
754
+ file_menu.append_separator()
755
+ file_menu.append(DIALOGS_LOG_DIALOG, "&Log dialog\tCtrl-L")
756
+ file_menu.append(DIALOGS_MESSAGE_BOX, "&Message box\tCtrl-M")
757
+ file_menu.append(DIALOGS_TEXT_ENTRY, "Text &entry\tCtrl-E")
758
+ file_menu.append(DIALOGS_PASSWORD_ENTRY, "&Password entry\tCtrl-P")
759
+ file_menu.append(DIALOGS_NUM_ENTRY, "&Numeric entry\tCtrl-N")
760
+ file_menu.append(DIALOGS_SINGLE_CHOICE, "&Single choice\tCtrl-C")
761
+ file_menu.append(DIALOGS_MULTI_CHOICE, "M&ultiple choice\tCtrl-U")
762
+ file_menu.append_separator()
763
+ file_menu.append(DIALOGS_TIP, "&Tip of the day\tCtrl-T")
764
+ file_menu.append_separator()
765
+ file_menu.append(DIALOGS_FILE_OPEN, "&Open file\tCtrl-O")
766
+ file_menu.append(DIALOGS_FILE_OPEN2, "&Second open file\tCtrl-2")
767
+ file_menu.append(DIALOGS_FILES_OPEN, "Open &files\tShift-Ctrl-O")
768
+ file_menu.append(DIALOGS_FILE_SAVE, "Sa&ve file\tCtrl-S")
769
+ file_menu.append(DIALOGS_DIR_CHOOSE, "&Choose a directory\tCtrl-D")
770
+ file_menu.append(DIALOGS_PROGRESS, "Pro&gress dialog\tCtrl-G")
771
+ file_menu.append(DIALOGS_BUSYINFO, "&Busy info dialog\tCtrl-B")
772
+ file_menu.append(DIALOGS_PREFS, "Propert&y sheet dialog\tCtrl-Y")
773
+ file_menu.append(DIALOGS_FIND, "&Find dialog\tCtrl-F", "", ITEM_CHECK)
774
+ file_menu.append(DIALOGS_REPLACE, "Find and &replace dialog\tShift-Ctrl-F", "", ITEM_CHECK)
775
+
776
+ file_menu.append_separator()
777
+ file_menu.append(DIALOGS_MODAL, "Mo&dal dialog\tCtrl-W")
778
+ file_menu.append(DIALOGS_MODELESS, "Modeless &dialog\tCtrl-Z", "", ITEM_CHECK)
779
+ file_menu.append_separator()
780
+ file_menu.append(ID_EXIT, "E&xit\tAlt-X")
781
+ menu_bar = MenuBar.new
782
+ menu_bar.append(file_menu, "&File")
783
+ frame.set_menu_bar(menu_bar)
784
+
785
+ $my_canvas = MyCanvas.new(frame)
786
+ $my_canvas.set_background_colour(WHITE)
787
+
788
+ frame.centre(BOTH)
789
+
790
+ # Show the frame
791
+ frame.show()
792
+ end
793
+ end
794
+
795
+ app = MyApp.new()
796
+ app.main_loop()
797
+