wxruby3 0.9.1 → 0.9.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (472) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +1 -0
  3. data/INSTALL.md +35 -29
  4. data/README.md +24 -15
  5. data/ext/wxruby3/include/wxRubyApp.h +338 -0
  6. data/ext/wxruby3/include/wxruby-ClientData.h +48 -0
  7. data/ext/wxruby3/include/wxruby-Config.h +6 -6
  8. data/ext/wxruby3/include/wxruby-Validator.h +39 -0
  9. data/ext/wxruby3/include/wxruby-ValidatorBinding.h +64 -0
  10. data/ext/wxruby3/swig/common.i +1 -1
  11. data/ext/wxruby3/swig/custom/director.swg +8 -0
  12. data/ext/wxruby3/swig/mark_free_impl.i +0 -33
  13. data/lib/wx/aui/aui_tab_ctrl.rb +18 -0
  14. data/lib/wx/aui/auinotebook.rb +6 -2
  15. data/lib/wx/aui/require.rb +1 -0
  16. data/lib/wx/core/app.rb +2 -2
  17. data/lib/wx/core/bitmap_combobox.rb +17 -21
  18. data/lib/wx/core/collapsible_pane.rb +1 -1
  19. data/lib/wx/core/combobox.rb +13 -3
  20. data/lib/wx/core/controlwithitems.rb +40 -128
  21. data/lib/wx/core/enum.rb +17 -1
  22. data/lib/wx/core/event.rb +6 -1
  23. data/lib/wx/core/evthandler.rb +8 -2
  24. data/lib/wx/core/generic_validator.rb +312 -0
  25. data/lib/wx/core/listbox.rb +2 -2
  26. data/lib/wx/core/log.rb +1 -1
  27. data/lib/wx/core/menu.rb +10 -0
  28. data/lib/wx/core/notebook.rb +6 -2
  29. data/lib/wx/core/owner_drawn_combobox.rb +45 -0
  30. data/lib/wx/core/size.rb +4 -0
  31. data/lib/wx/core/sizer.rb +12 -2
  32. data/lib/wx/core/standard_paths.rb +22 -0
  33. data/lib/wx/core/task_bar_button.rb +19 -0
  34. data/lib/wx/core/text_entry.rb +4 -1
  35. data/lib/wx/core/textctrl.rb +11 -1
  36. data/lib/wx/core/{treectrl.rb → tree_ctrl.rb} +31 -12
  37. data/lib/wx/core/validator.rb +70 -5
  38. data/lib/wx/core/window.rb +13 -7
  39. data/lib/wx/doc/app.rb +48 -38
  40. data/lib/wx/doc/art_locator.rb +48 -43
  41. data/lib/wx/doc/aui/auimanager.rb +16 -8
  42. data/lib/wx/doc/aui/auinotebook.rb +20 -5
  43. data/lib/wx/doc/clipboard.rb +11 -7
  44. data/lib/wx/doc/colour_dialog.rb +14 -10
  45. data/lib/wx/doc/comboctrl.rb +18 -0
  46. data/lib/wx/doc/controlwithitems.rb +34 -8
  47. data/lib/wx/doc/data_object.rb +2 -2
  48. data/lib/wx/doc/date_picker_ctrl.rb +23 -0
  49. data/lib/wx/doc/editable_listbox.rb +44 -0
  50. data/lib/wx/doc/enum.rb +15 -0
  51. data/lib/wx/doc/event.rb +12 -0
  52. data/lib/wx/doc/evthandler.rb +113 -108
  53. data/lib/wx/doc/extra/12_client_data.md +89 -0
  54. data/lib/wx/doc/extra/13_validators.md +139 -0
  55. data/lib/wx/doc/font.rb +1 -0
  56. data/lib/wx/doc/gc_dc.rb +6 -1
  57. data/lib/wx/doc/gdi_common.rb +4 -0
  58. data/lib/wx/doc/generic_validator.rb +95 -0
  59. data/lib/wx/doc/graphics_context.rb +1 -0
  60. data/lib/wx/doc/grid/grid.rb +22 -1
  61. data/lib/wx/doc/help_controller.rb +11 -7
  62. data/lib/wx/doc/html/html_help_controller.rb +12 -4
  63. data/lib/wx/doc/html/simple_html_listbox.rb +22 -0
  64. data/lib/wx/doc/list_ctrl.rb +33 -29
  65. data/lib/wx/doc/menu.rb +20 -0
  66. data/lib/wx/doc/notebook.rb +21 -0
  67. data/lib/wx/doc/num_validator.rb +387 -0
  68. data/lib/wx/doc/owner_drawn_combobox.rb +96 -0
  69. data/lib/wx/doc/pg/events.rb +13 -9
  70. data/lib/wx/doc/pg/numeric_property_validator.rb +33 -0
  71. data/lib/wx/doc/pg/pg_property.rb +18 -0
  72. data/lib/wx/doc/progress_dialog.rb +36 -32
  73. data/lib/wx/doc/prt/page_setup_dialog.rb +20 -12
  74. data/lib/wx/doc/prt/print_data.rb +13 -5
  75. data/lib/wx/doc/prt/print_dialog.rb +31 -23
  76. data/lib/wx/doc/prt/printer.rb +20 -12
  77. data/lib/wx/doc/radio_box.rb +19 -15
  78. data/lib/wx/doc/rbn/ribbon_bar.rb +13 -5
  79. data/lib/wx/doc/rbn/ribbon_button_bar.rb +13 -5
  80. data/lib/wx/doc/rbn/ribbon_gallery.rb +13 -5
  81. data/lib/wx/doc/rbn/ribbon_tool_bar.rb +13 -5
  82. data/lib/wx/doc/region_iterator.rb +32 -28
  83. data/lib/wx/doc/rtc/rich_text_composite_object.rb +24 -0
  84. data/lib/wx/doc/rtc/rich_text_ctrl.rb +24 -0
  85. data/lib/wx/doc/rtc/rich_text_paragraph.rb +24 -0
  86. data/lib/wx/doc/rtc/richtext_buffer.rb +27 -19
  87. data/lib/wx/doc/rtc/richtext_printing.rb +17 -9
  88. data/lib/wx/doc/rtc/richtext_style_sheet.rb +17 -9
  89. data/lib/wx/doc/sizer.rb +20 -0
  90. data/lib/wx/doc/static_bitmap.rb +25 -0
  91. data/lib/wx/doc/stc/styled_text_ctrl.rb +24 -0
  92. data/lib/wx/doc/stream.rb +39 -35
  93. data/lib/wx/doc/system_settings.rb +30 -26
  94. data/lib/wx/doc/text_validator.rb +23 -9
  95. data/lib/wx/doc/textctrl.rb +16 -0
  96. data/lib/wx/doc/tree_ctrl.rb +95 -0
  97. data/lib/wx/doc/treebook.rb +9 -5
  98. data/lib/wx/doc/v_list_box.rb +9 -5
  99. data/lib/wx/doc/validator.rb +113 -0
  100. data/lib/wx/doc/variant.rb +164 -160
  101. data/lib/wx/doc/window.rb +87 -47
  102. data/lib/wx/doc/window_disabler.rb +10 -6
  103. data/lib/wx/grid/grid.rb +27 -4
  104. data/lib/wx/html/simple_html_listbox.rb +24 -91
  105. data/lib/wx/keyword_defs.rb +34 -2
  106. data/lib/wx/pg/pg_property.rb +22 -0
  107. data/lib/wx/rbn/ribbon_gallery.rb +0 -21
  108. data/lib/wx/rtc/require.rb +3 -0
  109. data/lib/wx/rtc/rich_text_composite_object.rb +25 -0
  110. data/lib/wx/rtc/rich_text_ctrl.rb +25 -0
  111. data/lib/wx/rtc/rich_text_paragraph.rb +25 -0
  112. data/lib/wx/stc/require.rb +1 -0
  113. data/lib/wx/stc/styled_text_ctrl.rb +25 -0
  114. data/lib/wx/version.rb +1 -1
  115. data/rakelib/lib/config/linux.rb +0 -3
  116. data/rakelib/lib/config/macosx.rb +2 -2
  117. data/rakelib/lib/config/mingw.rb +13 -1
  118. data/rakelib/lib/config/unixish.rb +1 -1
  119. data/rakelib/lib/config.rb +14 -4
  120. data/rakelib/lib/core/include/client_data.inc +65 -0
  121. data/rakelib/lib/core/include/funcall.inc +1 -1
  122. data/rakelib/lib/core/package.rb +31 -9
  123. data/rakelib/lib/core/parameter.rb +1 -1
  124. data/rakelib/lib/core/spec.rb +6 -1
  125. data/rakelib/lib/core/spec_helper.rb +7 -1
  126. data/rakelib/lib/director/accelerator.rb +2 -3
  127. data/rakelib/lib/director/accessible.rb +47 -0
  128. data/rakelib/lib/director/app.rb +30 -319
  129. data/rakelib/lib/director/app_traits.rb +13 -13
  130. data/rakelib/lib/director/bitmap_combobox.rb +2 -2
  131. data/rakelib/lib/director/combobox.rb +22 -0
  132. data/rakelib/lib/director/comboctrl.rb +1 -55
  133. data/rakelib/lib/director/ctrl_with_items.rb +105 -26
  134. data/rakelib/lib/director/data_format.rb +1 -1
  135. data/rakelib/lib/director/date_picker_ctrl.rb +8 -6
  136. data/rakelib/lib/director/derived_dc.rb +1 -1
  137. data/rakelib/lib/director/dialog.rb +1 -0
  138. data/rakelib/lib/director/drag_image.rb +2 -3
  139. data/rakelib/lib/director/editable_listbox.rb +30 -0
  140. data/rakelib/lib/director/event.rb +104 -14
  141. data/rakelib/lib/director/event_handler.rb +3 -2
  142. data/rakelib/lib/director/frame.rb +1 -3
  143. data/rakelib/lib/director/functions.rb +4 -2
  144. data/rakelib/lib/director/gdicommon.rb +8 -10
  145. data/rakelib/lib/director/generic_dirctrl.rb +17 -0
  146. data/rakelib/lib/director/graphics_context.rb +2 -4
  147. data/rakelib/lib/director/grid_cell_attr.rb +0 -2
  148. data/rakelib/lib/director/grid_cell_editor.rb +0 -2
  149. data/rakelib/lib/director/grid_cell_renderer.rb +0 -2
  150. data/rakelib/lib/director/grid_ctrl.rb +34 -3
  151. data/rakelib/lib/director/header_ctrl.rb +6 -1
  152. data/rakelib/lib/director/html_listbox.rb +96 -22
  153. data/rakelib/lib/director/icon.rb +5 -2
  154. data/rakelib/lib/director/list_ctrl.rb +5 -6
  155. data/rakelib/lib/director/locale.rb +1 -3
  156. data/rakelib/lib/director/log.rb +1 -4
  157. data/rakelib/lib/director/media_ctrl.rb +54 -0
  158. data/rakelib/lib/director/menu.rb +16 -1
  159. data/rakelib/lib/director/menu_item.rb +2 -2
  160. data/rakelib/lib/director/num_validator.rb +495 -0
  161. data/rakelib/lib/director/numeric_property_validator.rb +131 -6
  162. data/rakelib/lib/director/owner_drawn_combobox.rb +192 -0
  163. data/rakelib/lib/director/pgproperties.rb +1 -1
  164. data/rakelib/lib/director/pgproperty.rb +27 -30
  165. data/rakelib/lib/director/property_grid_interface.rb +5 -10
  166. data/rakelib/lib/director/ribbon_button_bar.rb +3 -3
  167. data/rakelib/lib/director/ribbon_gallery.rb +3 -5
  168. data/rakelib/lib/director/richtext_composite_object.rb +25 -0
  169. data/rakelib/lib/director/richtext_ctrl.rb +14 -4
  170. data/rakelib/lib/director/richtext_formatting_dialog.rb +7 -5
  171. data/rakelib/lib/director/richtext_paragraph_layout_box.rb +9 -7
  172. data/rakelib/lib/director/sizer.rb +30 -4
  173. data/rakelib/lib/director/sizer_item.rb +13 -0
  174. data/rakelib/lib/director/static_bitmap.rb +28 -0
  175. data/rakelib/lib/director/static_box.rb +4 -5
  176. data/rakelib/lib/director/styled_text_ctrl.rb +12 -0
  177. data/rakelib/lib/director/task_bar_button.rb +30 -0
  178. data/rakelib/lib/director/task_bar_icon.rb +5 -13
  179. data/rakelib/lib/director/text_entry.rb +4 -0
  180. data/rakelib/lib/director/text_validator.rb +124 -13
  181. data/rakelib/lib/director/textctrl.rb +12 -1
  182. data/rakelib/lib/director/toggle_button.rb +1 -0
  183. data/rakelib/lib/director/tool_tip.rb +1 -1
  184. data/rakelib/lib/director/top_level_window.rb +4 -7
  185. data/rakelib/lib/director/tree_ctrl.rb +40 -6
  186. data/rakelib/lib/director/utils.rb +16 -2
  187. data/rakelib/lib/director/validator.rb +196 -21
  188. data/rakelib/lib/director/variant.rb +1 -1
  189. data/rakelib/lib/director/window.rb +40 -7
  190. data/rakelib/lib/director.rb +4 -4
  191. data/rakelib/lib/extractor/function.rb +8 -7
  192. data/rakelib/lib/extractor.rb +34 -5
  193. data/rakelib/lib/generate/analyzer.rb +9 -4
  194. data/rakelib/lib/generate/doc/busy_info.yaml +0 -2
  195. data/rakelib/lib/generate/doc/clipboard.yaml +0 -2
  196. data/rakelib/lib/generate/doc/cursor.yaml +0 -2
  197. data/rakelib/lib/generate/doc/panel.yaml +7 -0
  198. data/rakelib/lib/generate/doc.rb +85 -17
  199. data/rakelib/lib/specs/interfaces.rb +163 -160
  200. data/rakelib/lib/swig_runner.rb +55 -9
  201. data/rakelib/lib/typemap/client_data.rb +67 -0
  202. data/rakelib/lib/typemap/common.rb +33 -4
  203. data/rakelib/lib/typemap/datetime.rb +1 -1
  204. data/rakelib/lib/typemap/tree_itemid.rb +2 -2
  205. data/rakelib/yard/templates/default/fulldoc/html/css/wxruby3.css +74 -2
  206. data/rakelib/yard/templates/default/fulldoc/html/full_list.erb +38 -0
  207. data/rakelib/yard/templates/default/fulldoc/html/setup.rb +39 -0
  208. data/rakelib/yard/templates/default/tags/html/wxrb_require.erb +10 -0
  209. data/rakelib/yard/templates/default/tags/setup.rb +16 -0
  210. data/rakelib/yard/yard-custom-templates.rb +3 -0
  211. data/samples/aui/aui.rb +1237 -1233
  212. data/samples/calendar/calendar.rb +293 -289
  213. data/samples/controls/get_item_sample.rb +83 -79
  214. data/samples/controls/htlbox.rb +331 -327
  215. data/samples/dialogs/dialogs.rb +682 -694
  216. data/samples/dialogs/wizard.rb +52 -55
  217. data/samples/dragdrop/dragdrop.rb +146 -142
  218. data/samples/drawing/bitmap.rb +29 -26
  219. data/samples/drawing/bitmap_image.rb +84 -80
  220. data/samples/drawing/graphics_drawing.rb +209 -205
  221. data/samples/drawing/image_prt.rb +344 -340
  222. data/samples/drawing/maths_images.rb +18 -1
  223. data/samples/drawing/rmagic_bitmap_image.rb +88 -84
  224. data/samples/etc/caret.rb +306 -0
  225. data/samples/etc/miniframe.rb +65 -60
  226. data/samples/etc/sash.rb +109 -105
  227. data/samples/etc/scrollwin.rb +86 -80
  228. data/samples/etc/system_settings.rb +216 -209
  229. data/samples/event/activation.rb +72 -67
  230. data/samples/event/event.rb +160 -153
  231. data/samples/event/threaded.rb +8 -1
  232. data/samples/event/update_ui_event.rb +67 -60
  233. data/samples/grid/grid.rb +188 -181
  234. data/samples/grid/gridtablebase.rb +136 -129
  235. data/samples/html/html.rb +208 -204
  236. data/samples/mdi/mdi.rb +59 -54
  237. data/samples/minimal/minimal.rb +54 -51
  238. data/samples/minimal/nothing.rb +1 -0
  239. data/samples/printing/printing.rb +367 -377
  240. data/samples/printing/printing2.rb +203 -198
  241. data/samples/propgrid/propgrid.rb +2312 -2308
  242. data/samples/propgrid/propgrid_minimal.rb +57 -50
  243. data/samples/ribbon/ribbon.rb +780 -774
  244. data/samples/sampler/ext.rb +0 -33
  245. data/samples/sampler/sample.rb +4 -9
  246. data/samples/sampler.rb +1 -1
  247. data/samples/splash/splash.rb +118 -116
  248. data/samples/text/rich_textctrl.rb +207 -201
  249. data/samples/text/richtext.rb +1409 -1405
  250. data/samples/text/scintilla.rb +137 -128
  251. data/samples/text/textctrl.rb +89 -83
  252. data/samples/text/unicode.rb +175 -168
  253. data/samples/treectrl/treectrl.rb +1430 -1426
  254. data/samples/widgets/activityindicator.rb +95 -0
  255. data/samples/widgets/art/widgets/activityindicator.xpm +278 -0
  256. data/samples/widgets/art/widgets/bmpbtn.xpm +37 -0
  257. data/samples/widgets/art/widgets/bmpcombobox.xpm +54 -0
  258. data/samples/widgets/art/widgets/button.xpm +54 -0
  259. data/samples/widgets/art/widgets/checkbox.xpm +54 -0
  260. data/samples/{bigdemo/icons → widgets/art/widgets}/choice.xpm +1 -1
  261. data/samples/widgets/art/widgets/choicebk.xpm +54 -0
  262. data/samples/widgets/art/widgets/clrpicker.xpm +193 -0
  263. data/samples/widgets/art/widgets/combobox.xpm +54 -0
  264. data/samples/widgets/art/widgets/datepick.xpm +200 -0
  265. data/samples/widgets/art/widgets/dirctrl.xpm +54 -0
  266. data/samples/widgets/art/widgets/dirpicker.xpm +213 -0
  267. data/samples/widgets/art/widgets/filepicker.xpm +214 -0
  268. data/samples/widgets/art/widgets/fontpicker.xpm +185 -0
  269. data/samples/widgets/art/widgets/gauge.xpm +54 -0
  270. data/samples/widgets/art/widgets/header.xpm +54 -0
  271. data/samples/widgets/art/widgets/hyperlnk.xpm +54 -0
  272. data/samples/widgets/art/widgets/listbook.xpm +54 -0
  273. data/samples/widgets/art/widgets/listbox.xpm +54 -0
  274. data/samples/widgets/art/widgets/native.xpm +81 -0
  275. data/samples/widgets/art/widgets/notebook.xpm +54 -0
  276. data/samples/widgets/art/widgets/odcombobox.xpm +54 -0
  277. data/samples/widgets/art/widgets/radiobox.xpm +54 -0
  278. data/samples/widgets/art/widgets/scrolbar.xpm +54 -0
  279. data/samples/widgets/art/widgets/slider.xpm +54 -0
  280. data/samples/widgets/art/widgets/spinbtn.xpm +40 -0
  281. data/samples/widgets/art/widgets/statbmp.xpm +40 -0
  282. data/samples/widgets/art/widgets/statbox.xpm +54 -0
  283. data/samples/widgets/art/widgets/stattext.xpm +54 -0
  284. data/samples/widgets/art/widgets/text.xpm +54 -0
  285. data/samples/widgets/art/widgets/timepick.xpm +207 -0
  286. data/samples/widgets/art/widgets/toggle.xpm +54 -0
  287. data/samples/widgets/art/widgets/toucan.png +0 -0
  288. data/samples/widgets/bmpcombobox.rb +651 -0
  289. data/samples/widgets/button.rb +462 -0
  290. data/samples/widgets/checkbox.rb +211 -0
  291. data/samples/widgets/choice.rb +287 -0
  292. data/samples/widgets/clrpicker.rb +156 -0
  293. data/samples/widgets/combobox.rb +516 -0
  294. data/samples/widgets/datepick.rb +215 -0
  295. data/samples/widgets/dirctrl.rb +265 -0
  296. data/samples/widgets/dirpicker.rb +158 -0
  297. data/samples/widgets/editlbox.rb +122 -0
  298. data/samples/widgets/filectrl.rb +216 -0
  299. data/samples/widgets/filepicker.rb +214 -0
  300. data/samples/widgets/fontpicker.rb +135 -0
  301. data/samples/widgets/gauge.rb +311 -0
  302. data/samples/widgets/headerctrl.rb +236 -0
  303. data/samples/widgets/hyperlink.rb +203 -0
  304. data/samples/widgets/itemcontainer.rb +185 -0
  305. data/samples/widgets/listbox.rb +473 -0
  306. data/samples/widgets/notebook.rb +488 -0
  307. data/samples/widgets/odcombobox.rb +608 -0
  308. data/samples/widgets/radiobox.rb +328 -0
  309. data/samples/widgets/searchctrl.rb +159 -0
  310. data/samples/widgets/slider.rb +594 -0
  311. data/samples/widgets/spinbtn.rb +443 -0
  312. data/samples/widgets/statbmp.rb +130 -0
  313. data/samples/widgets/static.rb +436 -0
  314. data/samples/widgets/textctrl.rb +700 -0
  315. data/samples/widgets/timepick.rb +148 -0
  316. data/samples/widgets/tn_widgets.png +0 -0
  317. data/samples/widgets/toggle.rb +385 -0
  318. data/samples/widgets/widgets.rb +1233 -0
  319. data/samples/xrc/custom_xrc_sample.rb +47 -41
  320. data/samples/xrc/xrc_sample.rb +53 -47
  321. data/tests/media/beep_lo.wav +0 -0
  322. data/tests/test_event_handling.rb +52 -34
  323. data/tests/test_events.rb +7 -0
  324. data/tests/test_item_data.rb +24 -0
  325. data/tests/test_list_ctrl.rb +1 -1
  326. data/tests/test_media_ctrl.rb +38 -0
  327. data/tests/test_menu.rb +69 -0
  328. data/tests/test_pg.rb +27 -0
  329. data/tests/test_richtext.rb +45 -0
  330. data/tests/test_sizer.rb +59 -0
  331. data/tests/test_std_controls.rb +42 -1
  332. data/tests/test_styled_text_ctrl.rb +46 -0
  333. data/tests/test_tree_ctrl.rb +138 -0
  334. data/tests/test_validators.rb +805 -0
  335. data/tests/test_window.rb +12 -0
  336. data/tests/testapp_noframe.rb +1 -1
  337. metadata +121 -139
  338. data/lib/wx/core/choice.rb +0 -14
  339. data/lib/wx/core/combo_ctrl.rb +0 -110
  340. data/rakelib/lib/typemap/grid_client_data.rb +0 -58
  341. data/samples/bigdemo/About.rbw +0 -39
  342. data/samples/bigdemo/ColorPanel.rbw +0 -23
  343. data/samples/bigdemo/GridSimple.rbw +0 -78
  344. data/samples/bigdemo/MDIDemo.rbw +0 -57
  345. data/samples/bigdemo/PopupMenu.rbw +0 -146
  346. data/samples/bigdemo/ShapedWindow.rbw +0 -128
  347. data/samples/bigdemo/Sizers.rbw +0 -541
  348. data/samples/bigdemo/bigdemo.rb +0 -817
  349. data/samples/bigdemo/demoTemplate.rbw +0 -33
  350. data/samples/bigdemo/helpfile.htb +0 -0
  351. data/samples/bigdemo/icons/Test 015.jpg +0 -0
  352. data/samples/bigdemo/icons/Test 015.png +0 -0
  353. data/samples/bigdemo/icons/choice.bmp +0 -0
  354. data/samples/bigdemo/icons/combo.bmp +0 -0
  355. data/samples/bigdemo/icons/combo.xpm +0 -27
  356. data/samples/bigdemo/icons/copy.xpm +0 -25
  357. data/samples/bigdemo/icons/cut.xpm +0 -24
  358. data/samples/bigdemo/icons/gauge.bmp +0 -0
  359. data/samples/bigdemo/icons/gauge.xpm +0 -27
  360. data/samples/bigdemo/icons/help.xpm +0 -25
  361. data/samples/bigdemo/icons/list.bmp +0 -0
  362. data/samples/bigdemo/icons/list.xpm +0 -27
  363. data/samples/bigdemo/icons/mondrian.ico +0 -0
  364. data/samples/bigdemo/icons/mondrian.xpm +0 -44
  365. data/samples/bigdemo/icons/new.xpm +0 -24
  366. data/samples/bigdemo/icons/ogl.ico +0 -0
  367. data/samples/bigdemo/icons/ogl.xpm +0 -45
  368. data/samples/bigdemo/icons/open.xpm +0 -26
  369. data/samples/bigdemo/icons/paste.bmp +0 -0
  370. data/samples/bigdemo/icons/paste.xpm +0 -38
  371. data/samples/bigdemo/icons/pointy.png +0 -0
  372. data/samples/bigdemo/icons/preview.xpm +0 -26
  373. data/samples/bigdemo/icons/print.xpm +0 -26
  374. data/samples/bigdemo/icons/radio.bmp +0 -0
  375. data/samples/bigdemo/icons/radio.xpm +0 -27
  376. data/samples/bigdemo/icons/robert.xpm +0 -415
  377. data/samples/bigdemo/icons/sashtest.ico +0 -0
  378. data/samples/bigdemo/icons/save.xpm +0 -25
  379. data/samples/bigdemo/icons/smiles.bmp +0 -0
  380. data/samples/bigdemo/icons/smiles.xpm +0 -39
  381. data/samples/bigdemo/icons/smiley.ico +0 -0
  382. data/samples/bigdemo/icons/smiley.xpm +0 -42
  383. data/samples/bigdemo/icons/stattext.xpm +0 -24
  384. data/samples/bigdemo/icons/test2.bmp +0 -0
  385. data/samples/bigdemo/icons/test2.png +0 -0
  386. data/samples/bigdemo/icons/test2.xpm +0 -79
  387. data/samples/bigdemo/icons/text.bmp +0 -0
  388. data/samples/bigdemo/icons/text.xpm +0 -27
  389. data/samples/bigdemo/icons/tog1.bmp +0 -0
  390. data/samples/bigdemo/icons/tog1.xpm +0 -38
  391. data/samples/bigdemo/icons/tog2.bmp +0 -0
  392. data/samples/bigdemo/icons/tog2.xpm +0 -38
  393. data/samples/bigdemo/icons/wxruby-128x128.png +0 -0
  394. data/samples/bigdemo/icons/wxwin.ico +0 -0
  395. data/samples/bigdemo/icons/wxwin16x16.png +0 -0
  396. data/samples/bigdemo/icons/wxwin16x16.xpm +0 -25
  397. data/samples/bigdemo/icons/wxwin32x32.png +0 -0
  398. data/samples/bigdemo/icons/wxwin48x48.png +0 -0
  399. data/samples/bigdemo/run.rb +0 -98
  400. data/samples/bigdemo/tips.txt +0 -7
  401. data/samples/bigdemo/utils.rb +0 -20
  402. data/samples/bigdemo/wxArtProvider.rbw +0 -282
  403. data/samples/bigdemo/wxBitmapButton.rbw +0 -65
  404. data/samples/bigdemo/wxButton.rbw +0 -64
  405. data/samples/bigdemo/wxCalendarCtrl.rbw +0 -59
  406. data/samples/bigdemo/wxCheckBox.rbw +0 -50
  407. data/samples/bigdemo/wxCheckListBox.rbw +0 -65
  408. data/samples/bigdemo/wxChoice.rbw +0 -47
  409. data/samples/bigdemo/wxChoicebook.rbw +0 -78
  410. data/samples/bigdemo/wxColourDialog.rbw +0 -33
  411. data/samples/bigdemo/wxComboBox.rbw +0 -77
  412. data/samples/bigdemo/wxCursor.rbw +0 -136
  413. data/samples/bigdemo/wxDialog.rbw +0 -74
  414. data/samples/bigdemo/wxDirDialog.rbw +0 -29
  415. data/samples/bigdemo/wxDragImage.rbw +0 -70
  416. data/samples/bigdemo/wxFileDialog.rbw +0 -37
  417. data/samples/bigdemo/wxFileDialog_Save.rbw +0 -35
  418. data/samples/bigdemo/wxFindReplaceDialog.rbw +0 -82
  419. data/samples/bigdemo/wxFontDialog.rbw +0 -200
  420. data/samples/bigdemo/wxFrame.rbw +0 -53
  421. data/samples/bigdemo/wxGauge.rbw +0 -65
  422. data/samples/bigdemo/wxGenericDirCtrl.rbw +0 -74
  423. data/samples/bigdemo/wxGrid.rbw +0 -66
  424. data/samples/bigdemo/wxHtmlHelpController.rbw +0 -52
  425. data/samples/bigdemo/wxListBox.rbw +0 -140
  426. data/samples/bigdemo/wxListCtrl_virtual.rbw +0 -112
  427. data/samples/bigdemo/wxMDIWindows.rbw +0 -50
  428. data/samples/bigdemo/wxMenu.rbw +0 -247
  429. data/samples/bigdemo/wxMessageDialog.rbw +0 -27
  430. data/samples/bigdemo/wxMiniFrame.rbw +0 -70
  431. data/samples/bigdemo/wxMultipleChoiceDialog.rbw +0 -29
  432. data/samples/bigdemo/wxNotebook.rbw +0 -136
  433. data/samples/bigdemo/wxProgressDialog.rbw +0 -43
  434. data/samples/bigdemo/wxRadioBox.rbw +0 -72
  435. data/samples/bigdemo/wxRadioButton.rbw +0 -125
  436. data/samples/bigdemo/wxSashWindow.rbw +0 -141
  437. data/samples/bigdemo/wxScrolledMessageDialog.rbw +0 -57
  438. data/samples/bigdemo/wxScrolledWindow.rbw +0 -199
  439. data/samples/bigdemo/wxSingleChoiceDialog.rbw +0 -33
  440. data/samples/bigdemo/wxSlider.rbw +0 -42
  441. data/samples/bigdemo/wxSpinButton.rbw +0 -50
  442. data/samples/bigdemo/wxSpinCtrl.rbw +0 -51
  443. data/samples/bigdemo/wxSplitterWindow.rbw +0 -63
  444. data/samples/bigdemo/wxStaticBitmap.rbw +0 -47
  445. data/samples/bigdemo/wxStaticText.rbw +0 -55
  446. data/samples/bigdemo/wxStatusBar.rbw +0 -126
  447. data/samples/bigdemo/wxTextCtrl.rbw +0 -149
  448. data/samples/bigdemo/wxTextEntryDialog.rbw +0 -31
  449. data/samples/bigdemo/wxToggleButton.rbw +0 -49
  450. data/samples/bigdemo/wxToolBar.rbw +0 -131
  451. data/samples/bigdemo/wxTreeCtrl.rbw +0 -191
  452. data/samples/caret/caret.rb +0 -298
  453. data/samples/caret/mondrian.xpm +0 -44
  454. data/samples/controls/books.rb +0 -189
  455. data/samples/controls/choice.xpm +0 -27
  456. data/samples/controls/combo.xpm +0 -27
  457. data/samples/controls/controls.rb +0 -1099
  458. data/samples/controls/gauge.xpm +0 -27
  459. data/samples/controls/list.xpm +0 -27
  460. data/samples/controls/mondrian.ico +0 -0
  461. data/samples/controls/mondrian.xpm +0 -44
  462. data/samples/controls/radio.xpm +0 -27
  463. data/samples/controls/stattext.xpm +0 -24
  464. data/samples/controls/test2.bmp +0 -0
  465. data/samples/controls/text.xpm +0 -27
  466. data/samples/controls/tn_books.png +0 -0
  467. data/samples/controls/tn_controls.png +0 -0
  468. data/samples/etc/choice.rb +0 -87
  469. data/samples/etc/tn_choice.png +0 -0
  470. data/samples/text/mondrian.ico +0 -0
  471. data/samples/text/mondrian.xpm +0 -44
  472. /data/samples/{caret → etc}/tn_caret.png +0 -0
@@ -8,872 +8,878 @@
8
8
 
9
9
  require 'wx'
10
10
 
11
- class MyFrame < Wx::Frame
12
-
13
- module ID
14
- %i[
15
- CIRCLE
16
- CROSS
17
- TRIANGLE
18
- SQUARE
19
- POLYGON
20
- SELECTION_EXPAND_H
21
- SELECTION_EXPAND_V
22
- SELECTION_CONTRACT
23
- BUTTON_XX
24
- BUTTON_XY
25
- PRIMARY_COLOUR
26
- SECONDARY_COLOUR
27
- DEFAULT_PROVIDER
28
- AUI_PROVIDER
29
- MSW_PROVIDER
30
- MAIN_TOOLBAR
31
- POSITION_TOP
32
- POSITION_TOP_ICONS
33
- POSITION_TOP_BOTH
34
- POSITION_LEFT
35
- POSITION_LEFT_LABELS
36
- POSITION_LEFT_BOTH
37
- TOGGLE_PANELS
38
- ENABLE
39
- DISABLE
40
- DISABLED
41
- UI_ENABLE_UPDATED
42
- CHECK
43
- UI_CHECK_UPDATED
44
- CHANGE_TEXT1
45
- CHANGE_TEXT2
46
- UI_CHANGE_TEXT_UPDATED
47
- REMOVE_PAGE
48
- HIDE_PAGES
49
- SHOW_PAGES
50
- PLUS_MINUS
51
- CHANGE_LABEL
52
- SMALL_BUTTON_1
53
- SMALL_BUTTON_2
54
- SMALL_BUTTON_3
55
- SMALL_BUTTON_4
56
- SMALL_BUTTON_5
57
- SMALL_BUTTON_6
58
- ].each_with_index { |sym, ix| self.const_set(sym, Wx::ID_HIGHEST+1+ix) }
59
- end
11
+ module Ribbon
12
+
13
+ class MyFrame < Wx::Frame
14
+
15
+ module ID
16
+ %i[
17
+ CIRCLE
18
+ CROSS
19
+ TRIANGLE
20
+ SQUARE
21
+ POLYGON
22
+ SELECTION_EXPAND_H
23
+ SELECTION_EXPAND_V
24
+ SELECTION_CONTRACT
25
+ BUTTON_XX
26
+ BUTTON_XY
27
+ PRIMARY_COLOUR
28
+ SECONDARY_COLOUR
29
+ DEFAULT_PROVIDER
30
+ AUI_PROVIDER
31
+ MSW_PROVIDER
32
+ MAIN_TOOLBAR
33
+ POSITION_TOP
34
+ POSITION_TOP_ICONS
35
+ POSITION_TOP_BOTH
36
+ POSITION_LEFT
37
+ POSITION_LEFT_LABELS
38
+ POSITION_LEFT_BOTH
39
+ TOGGLE_PANELS
40
+ ENABLE
41
+ DISABLE
42
+ DISABLED
43
+ UI_ENABLE_UPDATED
44
+ CHECK
45
+ UI_CHECK_UPDATED
46
+ CHANGE_TEXT1
47
+ CHANGE_TEXT2
48
+ UI_CHANGE_TEXT_UPDATED
49
+ REMOVE_PAGE
50
+ HIDE_PAGES
51
+ SHOW_PAGES
52
+ PLUS_MINUS
53
+ CHANGE_LABEL
54
+ SMALL_BUTTON_1
55
+ SMALL_BUTTON_2
56
+ SMALL_BUTTON_3
57
+ SMALL_BUTTON_4
58
+ SMALL_BUTTON_5
59
+ SMALL_BUTTON_6
60
+ ].each_with_index { |sym, ix| self.const_set(sym, Wx::ID_HIGHEST+1+ix) }
61
+ end
60
62
 
61
- def initialize
62
- super(nil, Wx::ID_ANY, "wxRibbon Sample Application", size: [800, 600], style: Wx::DEFAULT_FRAME_STYLE)
63
-
64
- @colour_data = Wx::ColourData.new
65
- @ribbon = Wx::RBN::RibbonBar.new(self, Wx::ID_ANY,
66
- style: Wx::RBN::RIBBON_BAR_FLOW_HORIZONTAL |
67
- Wx::RBN::RIBBON_BAR_SHOW_PAGE_LABELS |
68
- Wx::RBN::RIBBON_BAR_SHOW_PANEL_EXT_BUTTONS |
69
- Wx::RBN::RIBBON_BAR_SHOW_TOGGLE_BUTTON |
70
- Wx::RBN::RIBBON_BAR_SHOW_HELP_BUTTON)
71
-
72
- home = Wx::RBN::RibbonPage.new(@ribbon, Wx::ID_ANY, "Examples", bitmap_(:ribbon_xpm))
73
- toolbar_panel = Wx::RBN::RibbonPanel.new(home, Wx::ID_ANY, "Toolbar",
74
- style: Wx::RBN::RIBBON_PANEL_NO_AUTO_MINIMISE |
75
- Wx::RBN::RIBBON_PANEL_EXT_BUTTON)
76
- toolbar = Wx::RBN::RibbonToolBar.new(toolbar_panel, ID::MAIN_TOOLBAR)
77
- toolbar.add_toggle_tool(Wx::ID_JUSTIFY_LEFT, bitmap_(:align_left_xpm))
78
- toolbar.add_toggle_tool(Wx::ID_JUSTIFY_CENTER , bitmap_(:align_center_xpm))
79
- toolbar.add_toggle_tool(Wx::ID_JUSTIFY_RIGHT, bitmap_(:align_right_xpm))
80
- toolbar.add_separator
81
- toolbar.add_hybrid_tool(Wx::ID_NEW, Wx::ArtProvider.get_bitmap(Wx::ART_NEW, Wx::ART_OTHER, Wx::Size.new(16, 15)))
82
- toolbar.add_tool(Wx::ID_OPEN, Wx::ArtProvider.get_bitmap(Wx::ART_FILE_OPEN, Wx::ART_OTHER, Wx::Size.new(16, 15)), "Open something")
83
- toolbar.add_tool(Wx::ID_SAVE, Wx::ArtProvider.get_bitmap(Wx::ART_FILE_SAVE, Wx::ART_OTHER, Wx::Size.new(16, 15)), "Save something")
84
- toolbar.add_tool(Wx::ID_SAVEAS, Wx::ArtProvider.get_bitmap(Wx::ART_FILE_SAVE_AS, Wx::ART_OTHER, Wx::Size.new(16, 15)), "Save something as ...")
85
- toolbar.enable_tool(Wx::ID_OPEN, false)
86
- toolbar.enable_tool(Wx::ID_SAVE, false)
87
- toolbar.enable_tool(Wx::ID_SAVEAS, false)
88
- toolbar.add_separator
89
- toolbar.add_dropdown_tool(Wx::ID_UNDO, Wx::ArtProvider.get_bitmap(Wx::ART_UNDO, Wx::ART_OTHER, Wx::Size.new(16, 15)))
90
- toolbar.add_dropdown_tool(Wx::ID_REDO, Wx::ArtProvider.get_bitmap(Wx::ART_REDO, Wx::ART_OTHER, Wx::Size.new(16, 15)))
91
- toolbar.add_separator
92
- toolbar.add_tool(Wx::ID_ANY, Wx::ArtProvider.get_bitmap(Wx::ART_REPORT_VIEW, Wx::ART_OTHER, Wx::Size.new(16, 15)))
93
- toolbar.add_tool(Wx::ID_ANY, Wx::ArtProvider.get_bitmap(Wx::ART_LIST_VIEW, Wx::ART_OTHER, Wx::Size.new(16, 15)))
94
- toolbar.add_separator
95
- toolbar.add_hybrid_tool(ID::POSITION_LEFT, bitmap_(:position_left_xpm),
96
- "Align ribbonbar vertically\non the left\nfor demonstration purposes")
97
- toolbar.add_hybrid_tool(ID::POSITION_TOP, bitmap_(:position_top_xpm),
98
- "Align the ribbonbar horizontally\nat the top\nfor demonstration purposes")
99
- toolbar.add_separator
100
- prt_tool = toolbar.add_hybrid_tool(Wx::ID_PRINT, Wx::ArtProvider.get_bitmap(Wx::ART_PRINT, Wx::ART_OTHER, Wx::Size.new(16, 15)),
101
- "This is the Print button tooltip\ndemonstrating a tooltip")
102
- toolbar.set_rows(2, 3)
103
-
104
- if toolbar.tool_count != (toolbar.tool_pos(prt_tool)+1)
105
- Wx.log_error('Wx::RibbonToolBar::get_tool_count or Wx::RibbonToolBar::get_tool_pos is broken')
106
- elsif Wx::ID_PRINT != toolbar.tool_by_pos(toolbar.tool_pos(prt_tool))
107
- Wx.log_error('Wx::RibbonToolBar::get_tool_by_pos is broken')
108
- end
109
-
110
- selection_panel = Wx::RBN::RibbonPanel.new(home, Wx::ID_ANY, "Selection", bitmap_(:selection_panel_xpm))
111
- selection = Wx::RBN::RibbonButtonBar.new(selection_panel)
112
- selection.add_button(ID::SELECTION_EXPAND_V, "Expand Vertically", bitmap_(:expand_selection_v_xpm),
113
- "This is a tooltip for Expand Vertically\ndemonstrating a tooltip")
114
- selection.add_button(ID::SELECTION_EXPAND_H, "Expand Horizontally", bitmap_(:expand_selection_h_xpm), '')
115
- selection.add_button(ID::SELECTION_CONTRACT, "Contract", bitmap_(:auto_crop_selection_xpm), bitmap_(:auto_crop_selection_small_xpm))
116
-
117
- shapes_panel = Wx::RBN::RibbonPanel.new(home, Wx::ID_ANY, "Shapes", bitmap_(:circle_small_xpm))
118
- shapes = Wx::RBN::RibbonButtonBar.new(shapes_panel)
119
- shapes.add_button(ID::CIRCLE, "Circle", bitmap_(:circle_xpm), bitmap_(:circle_small_xpm),
120
- Wx::NULL_BITMAP, Wx::NULL_BITMAP, Wx::RBN::RIBBON_BUTTON_NORMAL,
121
- "This is a tooltip for the circle button\ndemonstrating another tooltip")
122
- shapes.add_button(ID::CROSS, "Cross", bitmap_(:cross_xpm), '')
123
- shapes.add_hybrid_button(ID::TRIANGLE, "Triangle", bitmap_(:triangle_xpm))
124
- shapes.add_button(ID::SQUARE, "Square", bitmap_(:square_xpm), '')
125
- shapes.add_dropdown_button(ID::POLYGON, "Other Polygon", bitmap_(:hexagon_xpm), '')
126
-
127
- sizer_panel = Wx::RBN::RibbonPanel.new(home, Wx::ID_ANY, "Panel with Sizer",
128
- style: Wx::RBN::RIBBON_PANEL_DEFAULT_STYLE)
129
-
130
- as = ["Item 1 using a box sizer now", "Item 2 using a box sizer now"]
131
- sizer_panelcombo = Wx::ComboBox.new(sizer_panel, Wx::ID_ANY,
132
- choices: as, style: Wx::CB_READONLY)
133
-
134
- sizer_panelcombo2 = Wx::ComboBox.new(sizer_panel, Wx::ID_ANY,
135
- choices: as, style: Wx::CB_READONLY)
136
-
137
- sizer_panelcombo.select(0)
138
- sizer_panelcombo2.select(1)
139
- sizer_panelcombo.set_min_size(Wx::Size.new(150, -1))
140
- sizer_panelcombo2.set_min_size(Wx::Size.new(150, -1))
141
-
142
- bar = Wx::RBN::RibbonButtonBar.new(sizer_panel, Wx::ID_ANY)
143
- bar.add_button(ID::BUTTON_XX, "xx", bitmap_(:ribbon_xpm))
144
- bar.add_button(ID::BUTTON_XY, "xy", bitmap_(:ribbon_xpm))
145
- # This prevents ribbon buttons in panels with sizer from collapsing.
146
- bar.set_button_min_size_class(ID::BUTTON_XX, Wx::RBN::RIBBON_BUTTONBAR_BUTTON_LARGE)
147
- bar.set_button_min_size_class(ID::BUTTON_XY, Wx::RBN::RIBBON_BUTTONBAR_BUTTON_LARGE)
148
-
149
- sizer_panelsizer_h = Wx::BoxSizer.new(Wx::HORIZONTAL)
150
- sizer_panelsizer_v = Wx::BoxSizer.new(Wx::VERTICAL)
151
- sizer_panelsizer_v.add_stretch_spacer(1)
152
- sizer_panelsizer_v.add(sizer_panelcombo, 0, Wx::ALL|Wx::EXPAND, 2)
153
- sizer_panelsizer_v.add(sizer_panelcombo2, 0, Wx::ALL|Wx::EXPAND, 2)
154
- sizer_panelsizer_v.add_stretch_spacer(1)
155
- sizer_panelsizer_h.add(bar, 0, Wx::EXPAND)
156
- sizer_panelsizer_h.add(sizer_panelsizer_v, 0)
157
- sizer_panel.set_sizer(sizer_panelsizer_h)
158
-
159
- @label_font = Wx::Font.new(Wx::FontInfo.new(8).light)
160
-
161
- scheme = Wx::RBN::RibbonPage.new(@ribbon, Wx::ID_ANY, "Appearance", bitmap_(:eye_xpm))
162
- @default_primary = Wx::Colour.new
163
- @default_secondary = Wx::Colour.new
164
- @default_tertiary = Wx::Colour.new
165
- @ribbon.get_art_provider.get_colour_scheme(@default_primary, @default_secondary, @default_tertiary)
166
- provider_panel = Wx::RBN::RibbonPanel.new(scheme, Wx::ID_ANY,
167
- "Art", style: Wx::RBN::RIBBON_PANEL_NO_AUTO_MINIMISE)
168
- provider_bar = Wx::RBN::RibbonButtonBar.new(provider_panel, Wx::ID_ANY)
169
- provider_bar.add_button(ID::DEFAULT_PROVIDER, "Default Provider",
170
- Wx::ArtProvider.get_bitmap(Wx::ART_QUESTION, Wx::ART_OTHER, Wx::Size.new(32, 32)))
171
- provider_bar.add_button(ID::AUI_PROVIDER, "AUI Provider", bitmap_(:aui_style_xpm))
172
- provider_bar.add_button(ID::MSW_PROVIDER, "MSW Provider", bitmap_(:msw_style_xpm))
173
- primary_panel = Wx::RBN::RibbonPanel.new(scheme, Wx::ID_ANY,
174
- "Primary Colour", bitmap_(:colours_xpm))
175
- @primary_gallery = populate_colours_panel(primary_panel,
176
- @default_primary, ID::PRIMARY_COLOUR)
177
- secondary_panel = Wx::RBN::RibbonPanel.new(scheme, Wx::ID_ANY,
178
- "Secondary Colour", bitmap_(:colours_xpm))
179
- @secondary_gallery = populate_colours_panel(secondary_panel,
180
- @default_secondary, ID::SECONDARY_COLOUR)
181
-
182
- page = Wx::RBN::RibbonPage.new(@ribbon, Wx::ID_ANY, "UI Updated", bitmap_(:ribbon_xpm))
183
- panel = Wx::RBN::RibbonPanel.new(page, Wx::ID_ANY, "Enable/Disable", bitmap_(:ribbon_xpm))
184
- bar = Wx::RBN::RibbonButtonBar.new(panel, Wx::ID_ANY)
185
- bar.add_button(ID::DISABLED, "Disabled", bitmap_(:ribbon_xpm))
186
- bar.add_button(ID::ENABLE, "Enable", bitmap_(:ribbon_xpm))
187
- bar.add_button(ID::DISABLE, "Disable", bitmap_(:ribbon_xpm))
188
- bar.add_button(ID::UI_ENABLE_UPDATED, "Enable UI updated", bitmap_(:ribbon_xpm))
189
- bar.enable_button(ID::DISABLED, false)
190
- @bEnabled = true
191
-
192
- panel = Wx::RBN::RibbonPanel.new(page, Wx::ID_ANY, "Toggle", bitmap_(:ribbon_xpm))
193
- bar = Wx::RBN::RibbonButtonBar.new(panel, Wx::ID_ANY)
194
- bar.add_button(ID::CHECK, "Toggle", bitmap_(:ribbon_xpm))
195
- bar.add_toggle_button(ID::UI_CHECK_UPDATED, "Toggled UI updated", bitmap_(:ribbon_xpm))
196
- @bChecked = true
197
-
198
- panel = Wx::RBN::RibbonPanel.new(page, Wx::ID_ANY, "Change text", bitmap_(:ribbon_xpm))
199
- bar = Wx::RBN::RibbonButtonBar.new(panel, Wx::ID_ANY)
200
- bar.add_button(ID::CHANGE_TEXT1, "One", bitmap_(:ribbon_xpm))
201
- bar.add_button(ID::CHANGE_TEXT2, "Two", bitmap_(:ribbon_xpm))
202
- bar.add_button(ID::UI_CHANGE_TEXT_UPDATED, "Zero", bitmap_(:ribbon_xpm))
203
-
204
- # Also set the general disabled text colour:
205
- artProvider = @ribbon.get_art_provider
206
- tColour = artProvider.get_color(Wx::RBN::RIBBON_ART_BUTTON_BAR_LABEL_COLOUR)
207
- artProvider.set_color(Wx::RBN::RIBBON_ART_BUTTON_BAR_LABEL_DISABLED_COLOUR, tColour.make_disabled)
208
-
209
- Wx::RBN::RibbonPage.new(@ribbon, Wx::ID_ANY, "Empty Page", bitmap_(:empty_xpm))
210
-
211
- page = Wx::RBN::RibbonPage.new(@ribbon, Wx::ID_ANY, "Another Page", bitmap_(:empty_xpm))
212
- panel = Wx::RBN::RibbonPanel.new(page, Wx::ID_ANY, "Page manipulation", bitmap_(:ribbon_xpm))
213
- bar = Wx::RBN::RibbonButtonBar.new(panel, Wx::ID_ANY)
214
- bar.add_button(ID::REMOVE_PAGE, "Remove", Wx::ArtProvider.get_bitmap(Wx::ART_DELETE, Wx::ART_OTHER, Wx::Size.new(24, 24)))
215
- bar.add_button(ID::HIDE_PAGES, "Hide Pages", bitmap_(:ribbon_xpm))
216
- bar.add_button(ID::SHOW_PAGES, "Show Pages", bitmap_(:ribbon_xpm))
217
-
218
- panel = Wx::RBN::RibbonPanel.new(page, Wx::ID_ANY, "Button bar manipulation", bitmap_(:ribbon_xpm))
219
- button_bar = Wx::RBN::RibbonButtonBar.new(panel, Wx::ID_ANY)
220
- button_bar.add_button(ID::PLUS_MINUS, "+/-",
221
- Wx::ArtProvider.get_bitmap(Wx::ART_PLUS, Wx::ART_OTHER, Wx::Size.new(24, 24)))
222
- @plus_minus_state = false
223
- button_bar.add_button(ID::CHANGE_LABEL, "short", bitmap_(:ribbon_xpm))
224
- button_bar.set_button_text_min_width(ID::CHANGE_LABEL, "some long text")
225
- @change_label_state = false
226
-
227
- panel = Wx::RBN::RibbonPanel.new(page, Wx::ID_ANY, "Always medium buttons", bitmap_(:ribbon_xpm))
228
- bar = Wx::RBN::RibbonButtonBar.new(panel, Wx::ID_ANY)
229
- bar.add_button(ID::SMALL_BUTTON_1, "Button 1", bitmap_(:ribbon_xpm))
230
- bar.set_button_max_size_class(ID::SMALL_BUTTON_1, Wx::RBN::RIBBON_BUTTONBAR_BUTTON_MEDIUM)
231
- bar.add_button(ID::SMALL_BUTTON_2, "Button 2", bitmap_(:ribbon_xpm))
232
- bar.set_button_max_size_class(ID::SMALL_BUTTON_2, Wx::RBN::RIBBON_BUTTONBAR_BUTTON_MEDIUM)
233
- bar.add_button(ID::SMALL_BUTTON_3, "Button 3", bitmap_(:ribbon_xpm))
234
- bar.add_button(ID::SMALL_BUTTON_4, "Button 4", bitmap_(:ribbon_xpm))
235
- bar.add_button(ID::SMALL_BUTTON_5, "Button 5", bitmap_(:ribbon_xpm))
236
- bar.set_button_max_size_class(ID::SMALL_BUTTON_5, Wx::RBN::RIBBON_BUTTONBAR_BUTTON_MEDIUM)
237
- bar.add_button(ID::SMALL_BUTTON_6, "Button 6", bitmap_(:ribbon_xpm))
238
- bar.set_button_max_size_class(ID::SMALL_BUTTON_6, Wx::RBN::RIBBON_BUTTONBAR_BUTTON_MEDIUM)
239
-
240
- Wx::RBN::RibbonPage.new(@ribbon, Wx::ID_ANY, "Highlight Page", bitmap_(:empty_xpm))
241
- @ribbon.add_page_highlight(@ribbon.get_page_count-1)
242
-
243
-
244
- page = Wx::RBN::RibbonPage.new(@ribbon, Wx::ID_ANY, "Advanced", bitmap_(:empty_xpm))
245
- panel = Wx::RBN::RibbonPanel.new(page, Wx::ID_ANY, "Button bar manipulation", bitmap_(:ribbon_xpm))
246
- button_bar = Wx::RBN::RibbonButtonBar.new(panel, Wx::ID_ANY)
247
- button_bar.add_button(ID::PLUS_MINUS, "+/-",
248
- Wx::ArtProvider.get_bitmap(Wx::ART_PLUS, Wx::ART_OTHER, Wx::Size.new(24, 24)))
249
- @plus_minus_state = false
250
- button_bar.add_button(ID::CHANGE_LABEL, "short", bitmap_(:ribbon_xpm))
251
- button_bar.set_button_text_min_width(ID::CHANGE_LABEL, "some long text")
252
- @change_label_state = false
253
-
254
- panel = Wx::RBN::RibbonPanel.new(page, Wx::ID_ANY, "Always medium buttons", bitmap_(:ribbon_xpm))
255
- bar = Wx::RBN::RibbonButtonBar.new(panel, Wx::ID_ANY)
256
- bar.add_button(ID::SMALL_BUTTON_1, "Button 1", bitmap_(:ribbon_xpm))
257
- bar.set_button_max_size_class(ID::SMALL_BUTTON_1, Wx::RBN::RIBBON_BUTTONBAR_BUTTON_MEDIUM)
258
- bar.add_button(ID::SMALL_BUTTON_2, "Button 2", bitmap_(:ribbon_xpm))
259
- bar.set_button_max_size_class(ID::SMALL_BUTTON_2, Wx::RBN::RIBBON_BUTTONBAR_BUTTON_MEDIUM)
260
- bar.add_button(ID::SMALL_BUTTON_3, "Button 3", bitmap_(:ribbon_xpm))
261
- bar.add_button(ID::SMALL_BUTTON_4, "Button 4", bitmap_(:ribbon_xpm))
262
- bar.add_button(ID::SMALL_BUTTON_5, "Button 5", bitmap_(:ribbon_xpm))
263
- bar.set_button_max_size_class(ID::SMALL_BUTTON_5, Wx::RBN::RIBBON_BUTTONBAR_BUTTON_MEDIUM)
264
- bar.add_button(ID::SMALL_BUTTON_6, "Button 6", bitmap_(:ribbon_xpm))
265
- bar.set_button_max_size_class(ID::SMALL_BUTTON_6, Wx::RBN::RIBBON_BUTTONBAR_BUTTON_MEDIUM)
266
-
267
- @ribbon.realize
268
-
269
- @logwindow = Wx::TextCtrl.new(self, Wx::ID_ANY, style: Wx::TE_MULTILINE | Wx::TE_READONLY |
270
- Wx::TE_LEFT | Wx::TE_BESTWRAP | Wx::BORDER_NONE)
271
-
272
- @togglePanels = Wx::ToggleButton.new(self, ID::TOGGLE_PANELS, "&Toggle panels")
273
- @togglePanels.set_value(true)
274
-
275
- s = Wx::BoxSizer.new(Wx::VERTICAL)
276
-
277
- s.add(@ribbon, 0, Wx::EXPAND)
278
- s.add(@logwindow, 1, Wx::EXPAND)
279
- s.add(@togglePanels, Wx::SizerFlags.new.border)
280
-
281
- set_sizer(s)
282
-
283
- evt_ribbonbuttonbar_clicked(ID::ENABLE, :on_enable)
284
- evt_ribbonbuttonbar_clicked(ID::DISABLE, :on_disable)
285
- evt_ribbonbuttonbar_clicked(ID::DISABLED, :on_disabled)
286
- evt_ribbonbuttonbar_clicked(ID::UI_ENABLE_UPDATED, :on_enable_updated)
287
- evt_update_ui(ID::UI_ENABLE_UPDATED, :on_enable_update_ui)
288
- evt_ribbonbuttonbar_clicked(ID::CHECK, :on_check)
289
- evt_update_ui(ID::UI_CHECK_UPDATED, :on_check_update_ui)
290
- evt_ribbonbuttonbar_clicked(ID::CHANGE_TEXT1, :on_change_text1)
291
- evt_ribbonbuttonbar_clicked(ID::CHANGE_TEXT2, :on_change_text2)
292
- evt_update_ui(ID::UI_CHANGE_TEXT_UPDATED, :on_change_text_update_ui)
293
- evt_ribbonbuttonbar_clicked(ID::DEFAULT_PROVIDER, :on_default_provider)
294
- evt_ribbonbuttonbar_clicked(ID::AUI_PROVIDER, :on_aui_provider)
295
- evt_ribbonbuttonbar_clicked(ID::MSW_PROVIDER, :on_msw_provider)
296
- evt_ribbonbuttonbar_clicked(ID::SELECTION_EXPAND_H, :on_selection_expand_h_button)
297
- evt_ribbonbuttonbar_clicked(ID::SELECTION_EXPAND_V, :on_selection_expand_v_button)
298
- evt_ribbonbuttonbar_clicked(ID::SELECTION_CONTRACT, :on_selection_contract_button)
299
- evt_ribbonbuttonbar_clicked(ID::CIRCLE, :on_circle_button)
300
- evt_ribbonbuttonbar_clicked(ID::CROSS, :on_cross_button)
301
- evt_ribbonbuttonbar_clicked(ID::TRIANGLE, :on_triangle_button)
302
- evt_ribbonbuttonbar_clicked(ID::SQUARE, :on_square_button)
303
- evt_ribbonbuttonbar_dropdown_clicked(ID::TRIANGLE, :on_triangle_dropdown)
304
- evt_ribbonbuttonbar_dropdown_clicked(ID::POLYGON, :on_polygon_dropdown)
305
- evt_ribbongallery_hover_changed(ID::PRIMARY_COLOUR, :on_hovered_colour_change)
306
- evt_ribbongallery_hover_changed(ID::SECONDARY_COLOUR, :on_hovered_colour_change)
307
- evt_ribbongallery_selected(ID::PRIMARY_COLOUR, :on_primary_colour_select)
308
- evt_ribbongallery_selected(ID::SECONDARY_COLOUR, :on_secondary_colour_select)
309
- evt_ribbontoolbar_clicked(Wx::ID_JUSTIFY_LEFT, :on_justify)
310
- evt_ribbontoolbar_clicked(Wx::ID_JUSTIFY_CENTER, :on_justify)
311
- evt_ribbontoolbar_clicked(Wx::ID_JUSTIFY_RIGHT, :on_justify)
312
- evt_update_ui(Wx::ID_JUSTIFY_LEFT, :on_justify_update_ui)
313
- evt_update_ui(Wx::ID_JUSTIFY_CENTER, :on_justify_update_ui)
314
- evt_update_ui(Wx::ID_JUSTIFY_RIGHT, :on_justify_update_ui)
315
- evt_ribbontoolbar_clicked(Wx::ID_NEW, :on_new)
316
- evt_ribbontoolbar_dropdown_clicked(Wx::ID_NEW, :on_new_dropdown)
317
- evt_ribbontoolbar_clicked(Wx::ID_PRINT, :on_print)
318
- evt_ribbontoolbar_dropdown_clicked(Wx::ID_PRINT, :on_print_dropdown)
319
- evt_ribbontoolbar_dropdown_clicked(Wx::ID_REDO, :on_redo_dropdown)
320
- evt_ribbontoolbar_dropdown_clicked(Wx::ID_UNDO, :on_undo_dropdown)
321
- evt_ribbontoolbar_clicked(ID::POSITION_LEFT, :on_position_left)
322
- evt_ribbontoolbar_dropdown_clicked(ID::POSITION_LEFT, :on_position_left_dropdown)
323
- evt_ribbontoolbar_clicked(ID::POSITION_TOP, :on_position_top)
324
- evt_ribbontoolbar_dropdown_clicked(ID::POSITION_TOP, :on_position_top_dropdown)
325
- evt_button(ID::PRIMARY_COLOUR, :on_colour_gallery_button)
326
- evt_button(ID::SECONDARY_COLOUR, :on_colour_gallery_button)
327
- evt_menu(ID::POSITION_LEFT, :on_position_left_icons)
328
- evt_menu(ID::POSITION_LEFT_LABELS, :on_position_left_labels)
329
- evt_menu(ID::POSITION_LEFT_BOTH, :on_position_left_both)
330
- evt_menu(ID::POSITION_TOP, :on_position_top_labels)
331
- evt_menu(ID::POSITION_TOP_ICONS, :on_position_top_icons)
332
- evt_menu(ID::POSITION_TOP_BOTH, :on_position_top_both)
333
- evt_togglebutton(ID::TOGGLE_PANELS, :on_toggle_panels)
334
- evt_ribbonpanel_extbutton_activated(Wx::ID_ANY, :on_ext_button)
335
- evt_ribbonbuttonbar_clicked(ID::REMOVE_PAGE, :on_remove_page)
336
- evt_ribbonbuttonbar_clicked(ID::HIDE_PAGES, :on_hide_pages)
337
- evt_ribbonbuttonbar_clicked(ID::SHOW_PAGES, :on_show_pages)
338
- evt_ribbonbuttonbar_clicked(ID::PLUS_MINUS, :on_plus_minus)
339
- evt_ribbonbuttonbar_clicked(ID::CHANGE_LABEL, :on_change_label)
340
- evt_ribbonbar_toggled(Wx::ID_ANY, :on_ribbon_bar_toggled)
341
- evt_ribbonbar_help_click(Wx::ID_ANY, :on_ribbon_bar_help_clicked)
342
- evt_size(:on_size_event)
343
- end
63
+ def initialize
64
+ super(nil, Wx::ID_ANY, "wxRibbon Sample Application", size: [800, 600], style: Wx::DEFAULT_FRAME_STYLE)
65
+
66
+ self.icon = Wx.Icon(:sample, Wx::BITMAP_TYPE_XPM, art_path: File.join(__dir__, '..'))
67
+
68
+ @colour_data = Wx::ColourData.new
69
+ @ribbon = Wx::RBN::RibbonBar.new(self, Wx::ID_ANY,
70
+ style: Wx::RBN::RIBBON_BAR_FLOW_HORIZONTAL |
71
+ Wx::RBN::RIBBON_BAR_SHOW_PAGE_LABELS |
72
+ Wx::RBN::RIBBON_BAR_SHOW_PANEL_EXT_BUTTONS |
73
+ Wx::RBN::RIBBON_BAR_SHOW_TOGGLE_BUTTON |
74
+ Wx::RBN::RIBBON_BAR_SHOW_HELP_BUTTON)
75
+
76
+ home = Wx::RBN::RibbonPage.new(@ribbon, Wx::ID_ANY, "Examples", bitmap_(:ribbon_xpm))
77
+ toolbar_panel = Wx::RBN::RibbonPanel.new(home, Wx::ID_ANY, "Toolbar",
78
+ style: Wx::RBN::RIBBON_PANEL_NO_AUTO_MINIMISE |
79
+ Wx::RBN::RIBBON_PANEL_EXT_BUTTON)
80
+ toolbar = Wx::RBN::RibbonToolBar.new(toolbar_panel, ID::MAIN_TOOLBAR)
81
+ toolbar.add_toggle_tool(Wx::ID_JUSTIFY_LEFT, bitmap_(:align_left_xpm))
82
+ toolbar.add_toggle_tool(Wx::ID_JUSTIFY_CENTER , bitmap_(:align_center_xpm))
83
+ toolbar.add_toggle_tool(Wx::ID_JUSTIFY_RIGHT, bitmap_(:align_right_xpm))
84
+ toolbar.add_separator
85
+ toolbar.add_hybrid_tool(Wx::ID_NEW, Wx::ArtProvider.get_bitmap(Wx::ART_NEW, Wx::ART_OTHER, Wx::Size.new(16, 15)))
86
+ toolbar.add_tool(Wx::ID_OPEN, Wx::ArtProvider.get_bitmap(Wx::ART_FILE_OPEN, Wx::ART_OTHER, Wx::Size.new(16, 15)), "Open something")
87
+ toolbar.add_tool(Wx::ID_SAVE, Wx::ArtProvider.get_bitmap(Wx::ART_FILE_SAVE, Wx::ART_OTHER, Wx::Size.new(16, 15)), "Save something")
88
+ toolbar.add_tool(Wx::ID_SAVEAS, Wx::ArtProvider.get_bitmap(Wx::ART_FILE_SAVE_AS, Wx::ART_OTHER, Wx::Size.new(16, 15)), "Save something as ...")
89
+ toolbar.enable_tool(Wx::ID_OPEN, false)
90
+ toolbar.enable_tool(Wx::ID_SAVE, false)
91
+ toolbar.enable_tool(Wx::ID_SAVEAS, false)
92
+ toolbar.add_separator
93
+ toolbar.add_dropdown_tool(Wx::ID_UNDO, Wx::ArtProvider.get_bitmap(Wx::ART_UNDO, Wx::ART_OTHER, Wx::Size.new(16, 15)))
94
+ toolbar.add_dropdown_tool(Wx::ID_REDO, Wx::ArtProvider.get_bitmap(Wx::ART_REDO, Wx::ART_OTHER, Wx::Size.new(16, 15)))
95
+ toolbar.add_separator
96
+ toolbar.add_tool(Wx::ID_ANY, Wx::ArtProvider.get_bitmap(Wx::ART_REPORT_VIEW, Wx::ART_OTHER, Wx::Size.new(16, 15)))
97
+ toolbar.add_tool(Wx::ID_ANY, Wx::ArtProvider.get_bitmap(Wx::ART_LIST_VIEW, Wx::ART_OTHER, Wx::Size.new(16, 15)))
98
+ toolbar.add_separator
99
+ toolbar.add_hybrid_tool(ID::POSITION_LEFT, bitmap_(:position_left_xpm),
100
+ "Align ribbonbar vertically\non the left\nfor demonstration purposes")
101
+ toolbar.add_hybrid_tool(ID::POSITION_TOP, bitmap_(:position_top_xpm),
102
+ "Align the ribbonbar horizontally\nat the top\nfor demonstration purposes")
103
+ toolbar.add_separator
104
+ prt_tool = toolbar.add_hybrid_tool(Wx::ID_PRINT, Wx::ArtProvider.get_bitmap(Wx::ART_PRINT, Wx::ART_OTHER, Wx::Size.new(16, 15)),
105
+ "This is the Print button tooltip\ndemonstrating a tooltip")
106
+ toolbar.set_rows(2, 3)
107
+
108
+ if toolbar.tool_count != (toolbar.tool_pos(prt_tool)+1)
109
+ Wx.log_error('Wx::RibbonToolBar::get_tool_count or Wx::RibbonToolBar::get_tool_pos is broken')
110
+ elsif Wx::ID_PRINT != toolbar.tool_by_pos(toolbar.tool_pos(prt_tool))
111
+ Wx.log_error('Wx::RibbonToolBar::get_tool_by_pos is broken')
112
+ end
344
113
 
345
- # utility function to find an icon relative to this ruby script
346
- def bitmap_(bitmap_name)
347
- Wx::Bitmap.new(File.join(File.dirname(__FILE__), bitmap_name.to_s.sub(/_([A-Za-z]+)\Z/, '.\1')))
348
- end
114
+ selection_panel = Wx::RBN::RibbonPanel.new(home, Wx::ID_ANY, "Selection", bitmap_(:selection_panel_xpm))
115
+ selection = Wx::RBN::RibbonButtonBar.new(selection_panel)
116
+ selection.add_button(ID::SELECTION_EXPAND_V, "Expand Vertically", bitmap_(:expand_selection_v_xpm),
117
+ "This is a tooltip for Expand Vertically\ndemonstrating a tooltip")
118
+ selection.add_button(ID::SELECTION_EXPAND_H, "Expand Horizontally", bitmap_(:expand_selection_h_xpm), '')
119
+ selection.add_button(ID::SELECTION_CONTRACT, "Contract", bitmap_(:auto_crop_selection_xpm), bitmap_(:auto_crop_selection_small_xpm))
120
+
121
+ shapes_panel = Wx::RBN::RibbonPanel.new(home, Wx::ID_ANY, "Shapes", bitmap_(:circle_small_xpm))
122
+ shapes = Wx::RBN::RibbonButtonBar.new(shapes_panel)
123
+ shapes.add_button(ID::CIRCLE, "Circle", bitmap_(:circle_xpm), bitmap_(:circle_small_xpm),
124
+ Wx::NULL_BITMAP, Wx::NULL_BITMAP, Wx::RBN::RIBBON_BUTTON_NORMAL,
125
+ "This is a tooltip for the circle button\ndemonstrating another tooltip")
126
+ shapes.add_button(ID::CROSS, "Cross", bitmap_(:cross_xpm), '')
127
+ shapes.add_hybrid_button(ID::TRIANGLE, "Triangle", bitmap_(:triangle_xpm))
128
+ shapes.add_button(ID::SQUARE, "Square", bitmap_(:square_xpm), '')
129
+ shapes.add_dropdown_button(ID::POLYGON, "Other Polygon", bitmap_(:hexagon_xpm), '')
130
+
131
+ sizer_panel = Wx::RBN::RibbonPanel.new(home, Wx::ID_ANY, "Panel with Sizer",
132
+ style: Wx::RBN::RIBBON_PANEL_DEFAULT_STYLE)
133
+
134
+ as = ["Item 1 using a box sizer now", "Item 2 using a box sizer now"]
135
+ sizer_panelcombo = Wx::ComboBox.new(sizer_panel, Wx::ID_ANY,
136
+ choices: as, style: Wx::CB_READONLY)
137
+
138
+ sizer_panelcombo2 = Wx::ComboBox.new(sizer_panel, Wx::ID_ANY,
139
+ choices: as, style: Wx::CB_READONLY)
140
+
141
+ sizer_panelcombo.select(0)
142
+ sizer_panelcombo2.select(1)
143
+ sizer_panelcombo.set_min_size(Wx::Size.new(150, -1))
144
+ sizer_panelcombo2.set_min_size(Wx::Size.new(150, -1))
145
+
146
+ bar = Wx::RBN::RibbonButtonBar.new(sizer_panel, Wx::ID_ANY)
147
+ bar.add_button(ID::BUTTON_XX, "xx", bitmap_(:ribbon_xpm))
148
+ bar.add_button(ID::BUTTON_XY, "xy", bitmap_(:ribbon_xpm))
149
+ # This prevents ribbon buttons in panels with sizer from collapsing.
150
+ bar.set_button_min_size_class(ID::BUTTON_XX, Wx::RBN::RIBBON_BUTTONBAR_BUTTON_LARGE)
151
+ bar.set_button_min_size_class(ID::BUTTON_XY, Wx::RBN::RIBBON_BUTTONBAR_BUTTON_LARGE)
152
+
153
+ sizer_panelsizer_h = Wx::BoxSizer.new(Wx::HORIZONTAL)
154
+ sizer_panelsizer_v = Wx::BoxSizer.new(Wx::VERTICAL)
155
+ sizer_panelsizer_v.add_stretch_spacer(1)
156
+ sizer_panelsizer_v.add(sizer_panelcombo, 0, Wx::ALL|Wx::EXPAND, 2)
157
+ sizer_panelsizer_v.add(sizer_panelcombo2, 0, Wx::ALL|Wx::EXPAND, 2)
158
+ sizer_panelsizer_v.add_stretch_spacer(1)
159
+ sizer_panelsizer_h.add(bar, 0, Wx::EXPAND)
160
+ sizer_panelsizer_h.add(sizer_panelsizer_v, 0)
161
+ sizer_panel.set_sizer(sizer_panelsizer_h)
162
+
163
+ @label_font = Wx::Font.new(Wx::FontInfo.new(8).light)
164
+
165
+ scheme = Wx::RBN::RibbonPage.new(@ribbon, Wx::ID_ANY, "Appearance", bitmap_(:eye_xpm))
166
+ @default_primary = Wx::Colour.new
167
+ @default_secondary = Wx::Colour.new
168
+ @default_tertiary = Wx::Colour.new
169
+ @ribbon.get_art_provider.get_colour_scheme(@default_primary, @default_secondary, @default_tertiary)
170
+ provider_panel = Wx::RBN::RibbonPanel.new(scheme, Wx::ID_ANY,
171
+ "Art", style: Wx::RBN::RIBBON_PANEL_NO_AUTO_MINIMISE)
172
+ provider_bar = Wx::RBN::RibbonButtonBar.new(provider_panel, Wx::ID_ANY)
173
+ provider_bar.add_button(ID::DEFAULT_PROVIDER, "Default Provider",
174
+ Wx::ArtProvider.get_bitmap(Wx::ART_QUESTION, Wx::ART_OTHER, Wx::Size.new(32, 32)))
175
+ provider_bar.add_button(ID::AUI_PROVIDER, "AUI Provider", bitmap_(:aui_style_xpm))
176
+ provider_bar.add_button(ID::MSW_PROVIDER, "MSW Provider", bitmap_(:msw_style_xpm))
177
+ primary_panel = Wx::RBN::RibbonPanel.new(scheme, Wx::ID_ANY,
178
+ "Primary Colour", bitmap_(:colours_xpm))
179
+ @primary_gallery = populate_colours_panel(primary_panel,
180
+ @default_primary, ID::PRIMARY_COLOUR)
181
+ secondary_panel = Wx::RBN::RibbonPanel.new(scheme, Wx::ID_ANY,
182
+ "Secondary Colour", bitmap_(:colours_xpm))
183
+ @secondary_gallery = populate_colours_panel(secondary_panel,
184
+ @default_secondary, ID::SECONDARY_COLOUR)
185
+
186
+ page = Wx::RBN::RibbonPage.new(@ribbon, Wx::ID_ANY, "UI Updated", bitmap_(:ribbon_xpm))
187
+ panel = Wx::RBN::RibbonPanel.new(page, Wx::ID_ANY, "Enable/Disable", bitmap_(:ribbon_xpm))
188
+ bar = Wx::RBN::RibbonButtonBar.new(panel, Wx::ID_ANY)
189
+ bar.add_button(ID::DISABLED, "Disabled", bitmap_(:ribbon_xpm))
190
+ bar.add_button(ID::ENABLE, "Enable", bitmap_(:ribbon_xpm))
191
+ bar.add_button(ID::DISABLE, "Disable", bitmap_(:ribbon_xpm))
192
+ bar.add_button(ID::UI_ENABLE_UPDATED, "Enable UI updated", bitmap_(:ribbon_xpm))
193
+ bar.enable_button(ID::DISABLED, false)
194
+ @bEnabled = true
195
+
196
+ panel = Wx::RBN::RibbonPanel.new(page, Wx::ID_ANY, "Toggle", bitmap_(:ribbon_xpm))
197
+ bar = Wx::RBN::RibbonButtonBar.new(panel, Wx::ID_ANY)
198
+ bar.add_button(ID::CHECK, "Toggle", bitmap_(:ribbon_xpm))
199
+ bar.add_toggle_button(ID::UI_CHECK_UPDATED, "Toggled UI updated", bitmap_(:ribbon_xpm))
200
+ @bChecked = true
201
+
202
+ panel = Wx::RBN::RibbonPanel.new(page, Wx::ID_ANY, "Change text", bitmap_(:ribbon_xpm))
203
+ bar = Wx::RBN::RibbonButtonBar.new(panel, Wx::ID_ANY)
204
+ bar.add_button(ID::CHANGE_TEXT1, "One", bitmap_(:ribbon_xpm))
205
+ bar.add_button(ID::CHANGE_TEXT2, "Two", bitmap_(:ribbon_xpm))
206
+ bar.add_button(ID::UI_CHANGE_TEXT_UPDATED, "Zero", bitmap_(:ribbon_xpm))
207
+
208
+ # Also set the general disabled text colour:
209
+ artProvider = @ribbon.get_art_provider
210
+ tColour = artProvider.get_color(Wx::RBN::RIBBON_ART_BUTTON_BAR_LABEL_COLOUR)
211
+ artProvider.set_color(Wx::RBN::RIBBON_ART_BUTTON_BAR_LABEL_DISABLED_COLOUR, tColour.make_disabled)
212
+
213
+ Wx::RBN::RibbonPage.new(@ribbon, Wx::ID_ANY, "Empty Page", bitmap_(:empty_xpm))
214
+
215
+ page = Wx::RBN::RibbonPage.new(@ribbon, Wx::ID_ANY, "Another Page", bitmap_(:empty_xpm))
216
+ panel = Wx::RBN::RibbonPanel.new(page, Wx::ID_ANY, "Page manipulation", bitmap_(:ribbon_xpm))
217
+ bar = Wx::RBN::RibbonButtonBar.new(panel, Wx::ID_ANY)
218
+ bar.add_button(ID::REMOVE_PAGE, "Remove", Wx::ArtProvider.get_bitmap(Wx::ART_DELETE, Wx::ART_OTHER, Wx::Size.new(24, 24)))
219
+ bar.add_button(ID::HIDE_PAGES, "Hide Pages", bitmap_(:ribbon_xpm))
220
+ bar.add_button(ID::SHOW_PAGES, "Show Pages", bitmap_(:ribbon_xpm))
221
+
222
+ panel = Wx::RBN::RibbonPanel.new(page, Wx::ID_ANY, "Button bar manipulation", bitmap_(:ribbon_xpm))
223
+ button_bar = Wx::RBN::RibbonButtonBar.new(panel, Wx::ID_ANY)
224
+ button_bar.add_button(ID::PLUS_MINUS, "+/-",
225
+ Wx::ArtProvider.get_bitmap(Wx::ART_PLUS, Wx::ART_OTHER, Wx::Size.new(24, 24)))
226
+ @plus_minus_state = false
227
+ button_bar.add_button(ID::CHANGE_LABEL, "short", bitmap_(:ribbon_xpm))
228
+ button_bar.set_button_text_min_width(ID::CHANGE_LABEL, "some long text")
229
+ @change_label_state = false
349
230
 
350
- def on_enable_update_ui(evt)
351
- evt.enable(@bEnabled)
352
- end
231
+ panel = Wx::RBN::RibbonPanel.new(page, Wx::ID_ANY, "Always medium buttons", bitmap_(:ribbon_xpm))
232
+ bar = Wx::RBN::RibbonButtonBar.new(panel, Wx::ID_ANY)
233
+ bar.add_button(ID::SMALL_BUTTON_1, "Button 1", bitmap_(:ribbon_xpm))
234
+ bar.set_button_max_size_class(ID::SMALL_BUTTON_1, Wx::RBN::RIBBON_BUTTONBAR_BUTTON_MEDIUM)
235
+ bar.add_button(ID::SMALL_BUTTON_2, "Button 2", bitmap_(:ribbon_xpm))
236
+ bar.set_button_max_size_class(ID::SMALL_BUTTON_2, Wx::RBN::RIBBON_BUTTONBAR_BUTTON_MEDIUM)
237
+ bar.add_button(ID::SMALL_BUTTON_3, "Button 3", bitmap_(:ribbon_xpm))
238
+ bar.add_button(ID::SMALL_BUTTON_4, "Button 4", bitmap_(:ribbon_xpm))
239
+ bar.add_button(ID::SMALL_BUTTON_5, "Button 5", bitmap_(:ribbon_xpm))
240
+ bar.set_button_max_size_class(ID::SMALL_BUTTON_5, Wx::RBN::RIBBON_BUTTONBAR_BUTTON_MEDIUM)
241
+ bar.add_button(ID::SMALL_BUTTON_6, "Button 6", bitmap_(:ribbon_xpm))
242
+ bar.set_button_max_size_class(ID::SMALL_BUTTON_6, Wx::RBN::RIBBON_BUTTONBAR_BUTTON_MEDIUM)
243
+
244
+ Wx::RBN::RibbonPage.new(@ribbon, Wx::ID_ANY, "Highlight Page", bitmap_(:empty_xpm))
245
+ @ribbon.add_page_highlight(@ribbon.get_page_count-1)
246
+
247
+
248
+ page = Wx::RBN::RibbonPage.new(@ribbon, Wx::ID_ANY, "Advanced", bitmap_(:empty_xpm))
249
+ panel = Wx::RBN::RibbonPanel.new(page, Wx::ID_ANY, "Button bar manipulation", bitmap_(:ribbon_xpm))
250
+ button_bar = Wx::RBN::RibbonButtonBar.new(panel, Wx::ID_ANY)
251
+ button_bar.add_button(ID::PLUS_MINUS, "+/-",
252
+ Wx::ArtProvider.get_bitmap(Wx::ART_PLUS, Wx::ART_OTHER, Wx::Size.new(24, 24)))
253
+ @plus_minus_state = false
254
+ button_bar.add_button(ID::CHANGE_LABEL, "short", bitmap_(:ribbon_xpm))
255
+ button_bar.set_button_text_min_width(ID::CHANGE_LABEL, "some long text")
256
+ @change_label_state = false
353
257
 
354
- def on_check_update_ui(evt)
355
- evt.check(@bChecked)
356
- end
258
+ panel = Wx::RBN::RibbonPanel.new(page, Wx::ID_ANY, "Always medium buttons", bitmap_(:ribbon_xpm))
259
+ bar = Wx::RBN::RibbonButtonBar.new(panel, Wx::ID_ANY)
260
+ bar.add_button(ID::SMALL_BUTTON_1, "Button 1", bitmap_(:ribbon_xpm))
261
+ bar.set_button_max_size_class(ID::SMALL_BUTTON_1, Wx::RBN::RIBBON_BUTTONBAR_BUTTON_MEDIUM)
262
+ bar.add_button(ID::SMALL_BUTTON_2, "Button 2", bitmap_(:ribbon_xpm))
263
+ bar.set_button_max_size_class(ID::SMALL_BUTTON_2, Wx::RBN::RIBBON_BUTTONBAR_BUTTON_MEDIUM)
264
+ bar.add_button(ID::SMALL_BUTTON_3, "Button 3", bitmap_(:ribbon_xpm))
265
+ bar.add_button(ID::SMALL_BUTTON_4, "Button 4", bitmap_(:ribbon_xpm))
266
+ bar.add_button(ID::SMALL_BUTTON_5, "Button 5", bitmap_(:ribbon_xpm))
267
+ bar.set_button_max_size_class(ID::SMALL_BUTTON_5, Wx::RBN::RIBBON_BUTTONBAR_BUTTON_MEDIUM)
268
+ bar.add_button(ID::SMALL_BUTTON_6, "Button 6", bitmap_(:ribbon_xpm))
269
+ bar.set_button_max_size_class(ID::SMALL_BUTTON_6, Wx::RBN::RIBBON_BUTTONBAR_BUTTON_MEDIUM)
270
+
271
+ @ribbon.realize
357
272
 
358
- def on_change_text_update_ui(evt)
359
- unless @new_text.nil? || @new_text.empty?
360
- evt.set_text(@new_text)
361
- @new_text = ''
273
+ @logwindow = Wx::TextCtrl.new(self, Wx::ID_ANY, style: Wx::TE_MULTILINE | Wx::TE_READONLY |
274
+ Wx::TE_LEFT | Wx::TE_BESTWRAP | Wx::BORDER_NONE)
275
+
276
+ @togglePanels = Wx::ToggleButton.new(self, ID::TOGGLE_PANELS, "&Toggle panels")
277
+ @togglePanels.set_value(true)
278
+
279
+ s = Wx::BoxSizer.new(Wx::VERTICAL)
280
+
281
+ s.add(@ribbon, 0, Wx::EXPAND)
282
+ s.add(@logwindow, 1, Wx::EXPAND)
283
+ s.add(@togglePanels, Wx::SizerFlags.new.border)
284
+
285
+ set_sizer(s)
286
+
287
+ evt_ribbonbuttonbar_clicked(ID::ENABLE, :on_enable)
288
+ evt_ribbonbuttonbar_clicked(ID::DISABLE, :on_disable)
289
+ evt_ribbonbuttonbar_clicked(ID::DISABLED, :on_disabled)
290
+ evt_ribbonbuttonbar_clicked(ID::UI_ENABLE_UPDATED, :on_enable_updated)
291
+ evt_update_ui(ID::UI_ENABLE_UPDATED, :on_enable_update_ui)
292
+ evt_ribbonbuttonbar_clicked(ID::CHECK, :on_check)
293
+ evt_update_ui(ID::UI_CHECK_UPDATED, :on_check_update_ui)
294
+ evt_ribbonbuttonbar_clicked(ID::CHANGE_TEXT1, :on_change_text1)
295
+ evt_ribbonbuttonbar_clicked(ID::CHANGE_TEXT2, :on_change_text2)
296
+ evt_update_ui(ID::UI_CHANGE_TEXT_UPDATED, :on_change_text_update_ui)
297
+ evt_ribbonbuttonbar_clicked(ID::DEFAULT_PROVIDER, :on_default_provider)
298
+ evt_ribbonbuttonbar_clicked(ID::AUI_PROVIDER, :on_aui_provider)
299
+ evt_ribbonbuttonbar_clicked(ID::MSW_PROVIDER, :on_msw_provider)
300
+ evt_ribbonbuttonbar_clicked(ID::SELECTION_EXPAND_H, :on_selection_expand_h_button)
301
+ evt_ribbonbuttonbar_clicked(ID::SELECTION_EXPAND_V, :on_selection_expand_v_button)
302
+ evt_ribbonbuttonbar_clicked(ID::SELECTION_CONTRACT, :on_selection_contract_button)
303
+ evt_ribbonbuttonbar_clicked(ID::CIRCLE, :on_circle_button)
304
+ evt_ribbonbuttonbar_clicked(ID::CROSS, :on_cross_button)
305
+ evt_ribbonbuttonbar_clicked(ID::TRIANGLE, :on_triangle_button)
306
+ evt_ribbonbuttonbar_clicked(ID::SQUARE, :on_square_button)
307
+ evt_ribbonbuttonbar_dropdown_clicked(ID::TRIANGLE, :on_triangle_dropdown)
308
+ evt_ribbonbuttonbar_dropdown_clicked(ID::POLYGON, :on_polygon_dropdown)
309
+ evt_ribbongallery_hover_changed(ID::PRIMARY_COLOUR, :on_hovered_colour_change)
310
+ evt_ribbongallery_hover_changed(ID::SECONDARY_COLOUR, :on_hovered_colour_change)
311
+ evt_ribbongallery_selected(ID::PRIMARY_COLOUR, :on_primary_colour_select)
312
+ evt_ribbongallery_selected(ID::SECONDARY_COLOUR, :on_secondary_colour_select)
313
+ evt_ribbontoolbar_clicked(Wx::ID_JUSTIFY_LEFT, :on_justify)
314
+ evt_ribbontoolbar_clicked(Wx::ID_JUSTIFY_CENTER, :on_justify)
315
+ evt_ribbontoolbar_clicked(Wx::ID_JUSTIFY_RIGHT, :on_justify)
316
+ evt_update_ui(Wx::ID_JUSTIFY_LEFT, :on_justify_update_ui)
317
+ evt_update_ui(Wx::ID_JUSTIFY_CENTER, :on_justify_update_ui)
318
+ evt_update_ui(Wx::ID_JUSTIFY_RIGHT, :on_justify_update_ui)
319
+ evt_ribbontoolbar_clicked(Wx::ID_NEW, :on_new)
320
+ evt_ribbontoolbar_dropdown_clicked(Wx::ID_NEW, :on_new_dropdown)
321
+ evt_ribbontoolbar_clicked(Wx::ID_PRINT, :on_print)
322
+ evt_ribbontoolbar_dropdown_clicked(Wx::ID_PRINT, :on_print_dropdown)
323
+ evt_ribbontoolbar_dropdown_clicked(Wx::ID_REDO, :on_redo_dropdown)
324
+ evt_ribbontoolbar_dropdown_clicked(Wx::ID_UNDO, :on_undo_dropdown)
325
+ evt_ribbontoolbar_clicked(ID::POSITION_LEFT, :on_position_left)
326
+ evt_ribbontoolbar_dropdown_clicked(ID::POSITION_LEFT, :on_position_left_dropdown)
327
+ evt_ribbontoolbar_clicked(ID::POSITION_TOP, :on_position_top)
328
+ evt_ribbontoolbar_dropdown_clicked(ID::POSITION_TOP, :on_position_top_dropdown)
329
+ evt_button(ID::PRIMARY_COLOUR, :on_colour_gallery_button)
330
+ evt_button(ID::SECONDARY_COLOUR, :on_colour_gallery_button)
331
+ evt_menu(ID::POSITION_LEFT, :on_position_left_icons)
332
+ evt_menu(ID::POSITION_LEFT_LABELS, :on_position_left_labels)
333
+ evt_menu(ID::POSITION_LEFT_BOTH, :on_position_left_both)
334
+ evt_menu(ID::POSITION_TOP, :on_position_top_labels)
335
+ evt_menu(ID::POSITION_TOP_ICONS, :on_position_top_icons)
336
+ evt_menu(ID::POSITION_TOP_BOTH, :on_position_top_both)
337
+ evt_togglebutton(ID::TOGGLE_PANELS, :on_toggle_panels)
338
+ evt_ribbonpanel_extbutton_activated(Wx::ID_ANY, :on_ext_button)
339
+ evt_ribbonbuttonbar_clicked(ID::REMOVE_PAGE, :on_remove_page)
340
+ evt_ribbonbuttonbar_clicked(ID::HIDE_PAGES, :on_hide_pages)
341
+ evt_ribbonbuttonbar_clicked(ID::SHOW_PAGES, :on_show_pages)
342
+ evt_ribbonbuttonbar_clicked(ID::PLUS_MINUS, :on_plus_minus)
343
+ evt_ribbonbuttonbar_clicked(ID::CHANGE_LABEL, :on_change_label)
344
+ evt_ribbonbar_toggled(Wx::ID_ANY, :on_ribbon_bar_toggled)
345
+ evt_ribbonbar_help_click(Wx::ID_ANY, :on_ribbon_bar_help_clicked)
346
+ evt_size(:on_size_event)
362
347
  end
363
- end
364
348
 
365
- def on_check(evt)
366
- @bChecked = !@bChecked
367
- end
349
+ # utility function to find an icon relative to this ruby script
350
+ def bitmap_(bitmap_name)
351
+ Wx::Bitmap.new(File.join(File.dirname(__FILE__), bitmap_name.to_s.sub(/_([A-Za-z]+)\Z/, '.\1')))
352
+ end
368
353
 
369
- def on_enable(evt)
370
- @bEnabled = true
371
- end
354
+ def on_enable_update_ui(evt)
355
+ evt.enable(@bEnabled)
356
+ end
372
357
 
373
- def on_disable(evt)
374
- @bEnabled = false
375
- end
358
+ def on_check_update_ui(evt)
359
+ evt.check(@bChecked)
360
+ end
376
361
 
377
- def on_disabled(evt)
378
- add_text("ERROR: Disabled button activated (not supposed to happen)")
379
- end
362
+ def on_change_text_update_ui(evt)
363
+ unless @new_text.nil? || @new_text.empty?
364
+ evt.set_text(@new_text)
365
+ @new_text = ''
366
+ end
367
+ end
380
368
 
381
- def on_enable_updated(evt)
382
- add_text("Button activated")
383
- end
369
+ def on_check(evt)
370
+ @bChecked = !@bChecked
371
+ end
384
372
 
385
- def on_change_text1(evt)
386
- @new_text = "One"
387
- end
373
+ def on_enable(evt)
374
+ @bEnabled = true
375
+ end
388
376
 
389
- def on_change_text2(evt)
390
- @new_text = "Two"
391
- end
377
+ def on_disable(evt)
378
+ @bEnabled = false
379
+ end
392
380
 
393
- def on_circle_button(evt)
394
- add_text("Circle button clicked.")
395
- end
381
+ def on_disabled(evt)
382
+ add_text("ERROR: Disabled button activated (not supposed to happen)")
383
+ end
396
384
 
397
- def on_cross_button(evt)
398
- add_text("Cross button clicked.")
399
- end
385
+ def on_enable_updated(evt)
386
+ add_text("Button activated")
387
+ end
400
388
 
401
- def on_triangle_button(evt)
402
- add_text("Triangle button clicked.")
403
- end
389
+ def on_change_text1(evt)
390
+ @new_text = "One"
391
+ end
404
392
 
405
- def on_triangle_dropdown(evt)
406
- menu = Wx::Menu.new
407
- menu.append(Wx::ID_ANY, "Equilateral")
408
- menu.append(Wx::ID_ANY, "Isosceles")
409
- menu.append(Wx::ID_ANY, "Scalene")
393
+ def on_change_text2(evt)
394
+ @new_text = "Two"
395
+ end
410
396
 
411
- evt.popup_menu(menu)
412
- end
397
+ def on_circle_button(evt)
398
+ add_text("Circle button clicked.")
399
+ end
413
400
 
414
- def on_square_button(evt)
415
- add_text("Square button clicked.")
416
- end
401
+ def on_cross_button(evt)
402
+ add_text("Cross button clicked.")
403
+ end
417
404
 
418
- def on_polygon_dropdown(evt)
419
- menu = Wx::Menu.new
420
- menu.append(Wx::ID_ANY, "Pentagon (5 sided)")
421
- menu.append(Wx::ID_ANY, "Hexagon (6 sided)")
422
- menu.append(Wx::ID_ANY, "Heptagon (7 sided)")
423
- menu.append(Wx::ID_ANY, "Octogon (8 sided)")
424
- menu.append(Wx::ID_ANY, "Nonagon (9 sided)")
425
- menu.append(Wx::ID_ANY, "Decagon (10 sided)")
405
+ def on_triangle_button(evt)
406
+ add_text("Triangle button clicked.")
407
+ end
426
408
 
427
- evt.popup_menu(menu)
428
- end
409
+ def on_triangle_dropdown(evt)
410
+ menu = Wx::Menu.new
411
+ menu.append(Wx::ID_ANY, "Equilateral")
412
+ menu.append(Wx::ID_ANY, "Isosceles")
413
+ menu.append(Wx::ID_ANY, "Scalene")
429
414
 
430
- def on_selection_expand_v_button(evt)
431
- add_text("Expand selection horizontally button clicked.")
432
- end
415
+ evt.popup_menu(menu)
416
+ end
433
417
 
434
- def on_selection_expand_h_button(evt)
435
- add_text("Expand selection vertically button clicked.")
436
- end
418
+ def on_square_button(evt)
419
+ add_text("Square button clicked.")
420
+ end
437
421
 
438
- def on_selection_contract_button(evt)
439
- add_text("Contract selection button clicked.")
440
- end
422
+ def on_polygon_dropdown(evt)
423
+ menu = Wx::Menu.new
424
+ menu.append(Wx::ID_ANY, "Pentagon (5 sided)")
425
+ menu.append(Wx::ID_ANY, "Hexagon (6 sided)")
426
+ menu.append(Wx::ID_ANY, "Heptagon (7 sided)")
427
+ menu.append(Wx::ID_ANY, "Octogon (8 sided)")
428
+ menu.append(Wx::ID_ANY, "Nonagon (9 sided)")
429
+ menu.append(Wx::ID_ANY, "Decagon (10 sided)")
441
430
 
442
- def on_hovered_colour_change(evt)
443
- # Set the background of the gallery to the hovered colour, or back to the
444
- # default if there is no longer a hovered item.
431
+ evt.popup_menu(menu)
432
+ end
445
433
 
446
- gallery = evt.gallery
447
- provider = gallery.get_art_provider
434
+ def on_selection_expand_v_button(evt)
435
+ add_text("Expand selection horizontally button clicked.")
436
+ end
448
437
 
449
- if evt.gallery_item != 0
450
- if provider == @ribbon.art_provider
451
- provider = provider.clone
452
- gallery.set_art_provider(provider)
453
- end
454
- _, colour = get_gallery_colour(evt.get_gallery, evt.get_gallery_item)
455
- provider.set_colour(Wx::RIBBON_ART_GALLERY_HOVER_BACKGROUND_COLOUR,
456
- colour)
457
- else
458
- if provider != @ribbon.get_art_provider
459
- gallery.set_art_provider(@ribbon.get_art_provider)
438
+ def on_selection_expand_h_button(evt)
439
+ add_text("Expand selection vertically button clicked.")
440
+ end
441
+
442
+ def on_selection_contract_button(evt)
443
+ add_text("Contract selection button clicked.")
444
+ end
445
+
446
+ def on_hovered_colour_change(evt)
447
+ # Set the background of the gallery to the hovered colour, or back to the
448
+ # default if there is no longer a hovered item.
449
+
450
+ gallery = evt.gallery
451
+ provider = gallery.get_art_provider
452
+
453
+ if evt.gallery_item != 0
454
+ if provider == @ribbon.art_provider
455
+ provider = provider.clone
456
+ gallery.set_art_provider(provider)
457
+ end
458
+ _, colour = get_gallery_colour(evt.get_gallery, evt.get_gallery_item)
459
+ provider.set_colour(Wx::RIBBON_ART_GALLERY_HOVER_BACKGROUND_COLOUR,
460
+ colour)
461
+ else
462
+ if provider != @ribbon.get_art_provider
463
+ gallery.set_art_provider(@ribbon.get_art_provider)
464
+ end
460
465
  end
461
466
  end
462
- end
463
467
 
464
- def on_primary_colour_select(evt)
465
- name, colour = get_gallery_colour(evt.get_gallery, evt.get_gallery_item)
466
- add_text("Colour \"" + name + "\" selected as primary.")
467
- secondary = Wx::Colour.new
468
- tertiary = Wx::Colour.new
469
- @ribbon.get_art_provider.get_colour_scheme(nil, secondary, tertiary)
470
- @ribbon.get_art_provider.set_colour_scheme(colour, secondary, tertiary)
471
- reset_gallery_art_providers
472
- @ribbon.refresh
473
- end
468
+ def on_primary_colour_select(evt)
469
+ name, colour = get_gallery_colour(evt.get_gallery, evt.get_gallery_item)
470
+ add_text("Colour \"" + name + "\" selected as primary.")
471
+ secondary = Wx::Colour.new
472
+ tertiary = Wx::Colour.new
473
+ @ribbon.get_art_provider.get_colour_scheme(nil, secondary, tertiary)
474
+ @ribbon.get_art_provider.set_colour_scheme(colour, secondary, tertiary)
475
+ reset_gallery_art_providers
476
+ @ribbon.refresh
477
+ end
474
478
 
475
- def on_secondary_colour_select(evt)
476
- name, colour = get_gallery_colour(evt.get_gallery, evt.get_gallery_item)
477
- add_text("Colour \"" + name + "\" selected as secondary.")
478
- primary = Wx::Colour.new
479
- tertiary = Wx::Colour.new
480
- @ribbon.art_provider.get_colour_scheme(primary, nil, tertiary)
481
- @ribbon.art_provider.set_colour_scheme(primary, colour, tertiary)
482
- reset_gallery_art_providers
483
- @ribbon.refresh
484
- end
479
+ def on_secondary_colour_select(evt)
480
+ name, colour = get_gallery_colour(evt.get_gallery, evt.get_gallery_item)
481
+ add_text("Colour \"" + name + "\" selected as secondary.")
482
+ primary = Wx::Colour.new
483
+ tertiary = Wx::Colour.new
484
+ @ribbon.art_provider.get_colour_scheme(primary, nil, tertiary)
485
+ @ribbon.art_provider.set_colour_scheme(primary, colour, tertiary)
486
+ reset_gallery_art_providers
487
+ @ribbon.refresh
488
+ end
489
+
490
+ def on_colour_gallery_button(evt)
491
+ gallery = evt.get_event_object
492
+ return unless gallery
493
+
494
+ @ribbon.dismiss_expanded_panel
495
+ if gallery.get_selection
496
+ _, c = get_gallery_colour(gallery, gallery.get_selection)
497
+ @colour_data.colour = c
498
+ end
499
+ Wx.ColourDialog(self, @colour_data) do |dlg|
500
+ if dlg.show_modal == Wx::ID_OK
501
+ @colour_data = dlg.colour_data
502
+ clr = @colour_data.colour
485
503
 
486
- def on_colour_gallery_button(evt)
487
- gallery = evt.get_event_object
488
- return unless gallery
489
-
490
- @ribbon.dismiss_expanded_panel
491
- if gallery.get_selection
492
- _, c = get_gallery_colour(gallery, gallery.get_selection)
493
- @colour_data.colour = c
494
- end
495
- Wx.ColourDialog(self, @colour_data) do |dlg|
496
- if dlg.show_modal == Wx::ID_OK
497
- @colour_data = dlg.colour_data
498
- clr = @colour_data.colour
499
-
500
- # Try to find colour in gallery
501
- item = nil
502
- gallery.count.times do |i|
503
- item = gallery.item(i)
504
- _, c = get_gallery_colour(gallery, item)
505
- break if c == clr
504
+ # Try to find colour in gallery
506
505
  item = nil
507
- end
506
+ gallery.count.times do |i|
507
+ item = gallery.item(i)
508
+ _, c = get_gallery_colour(gallery, item)
509
+ break if c == clr
510
+ item = nil
511
+ end
508
512
 
509
- # Colour not in gallery - add it
510
- unless item
511
- Wx::MemoryDC.draw_on do |dc|
512
- item = add_colour_to_gallery(gallery,
513
- clr.get_as_string(Wx::C2S_HTML_SYNTAX), dc, clr)
513
+ # Colour not in gallery - add it
514
+ unless item
515
+ Wx::MemoryDC.draw_on do |dc|
516
+ item = add_colour_to_gallery(gallery,
517
+ clr.get_as_string(Wx::C2S_HTML_SYNTAX), dc, clr)
518
+ end
519
+ gallery.realise
514
520
  end
515
- gallery.realise
516
- end
517
521
 
518
- # Set selection
519
- gallery.ensure_visible(item)
520
- gallery.set_selection(item)
522
+ # Set selection
523
+ gallery.ensure_visible(item)
524
+ gallery.set_selection(item)
521
525
 
522
- # Send an event to respond to the selection change
523
- dummy = Wx::RBN::RibbonGalleryEvent.new(Wx::RBN::EVT_RIBBONGALLERY_SELECTED, gallery.id)
524
- dummy.set_event_object(gallery)
525
- dummy.set_gallery(gallery)
526
- dummy.set_gallery_item(item)
527
- process_window_event(dummy)
526
+ # Send an event to respond to the selection change
527
+ dummy = Wx::RBN::RibbonGalleryEvent.new(Wx::RBN::EVT_RIBBONGALLERY_SELECTED, gallery.id)
528
+ dummy.set_event_object(gallery)
529
+ dummy.set_gallery(gallery)
530
+ dummy.set_gallery_item(item)
531
+ process_window_event(dummy)
532
+ end
528
533
  end
529
534
  end
530
- end
531
535
 
532
- def on_default_provider(evt)
533
- @ribbon.dismiss_expanded_panel
534
- set_art_provider(Wx::RibbonDefaultArtProvider.new)
535
- end
536
+ def on_default_provider(evt)
537
+ @ribbon.dismiss_expanded_panel
538
+ set_art_provider(Wx::RibbonDefaultArtProvider.new)
539
+ end
536
540
 
537
- def on_aui_provider(evt)
538
- @ribbon.dismiss_expanded_panel
539
- set_art_provider(Wx::RBN::RibbonAUIArtProvider.new)
540
- end
541
+ def on_aui_provider(evt)
542
+ @ribbon.dismiss_expanded_panel
543
+ set_art_provider(Wx::RBN::RibbonAUIArtProvider.new)
544
+ end
541
545
 
542
- def on_msw_provider(evt)
543
- @ribbon.dismiss_expanded_panel
544
- set_art_provider(Wx::RBN::RibbonMSWArtProvider.new)
545
- end
546
+ def on_msw_provider(evt)
547
+ @ribbon.dismiss_expanded_panel
548
+ set_art_provider(Wx::RBN::RibbonMSWArtProvider.new)
549
+ end
546
550
 
547
- def on_justify(evt)
548
- style = @logwindow.get_window_style & ~(Wx::TE_LEFT | Wx::TE_CENTER | Wx::TE_RIGHT)
549
- case evt.id
550
- when Wx::ID_JUSTIFY_LEFT
551
- @logwindow.set_window_style(style | Wx::TE_LEFT)
552
- when Wx::ID_JUSTIFY_CENTER
553
- @logwindow.set_window_style(style | Wx::TE_CENTER)
554
- when Wx::ID_JUSTIFY_RIGHT
555
- @logwindow.set_window_style(style | Wx::TE_RIGHT)
551
+ def on_justify(evt)
552
+ style = @logwindow.get_window_style & ~(Wx::TE_LEFT | Wx::TE_CENTER | Wx::TE_RIGHT)
553
+ case evt.id
554
+ when Wx::ID_JUSTIFY_LEFT
555
+ @logwindow.set_window_style(style | Wx::TE_LEFT)
556
+ when Wx::ID_JUSTIFY_CENTER
557
+ @logwindow.set_window_style(style | Wx::TE_CENTER)
558
+ when Wx::ID_JUSTIFY_RIGHT
559
+ @logwindow.set_window_style(style | Wx::TE_RIGHT)
560
+ end
556
561
  end
557
- end
558
562
 
559
- def on_justify_update_ui(evt)
560
- case evt.id
561
- when Wx::ID_JUSTIFY_LEFT
562
- evt.check(!@logwindow.has_flag(Wx::TE_CENTER | Wx::TE_RIGHT))
563
- when Wx::ID_JUSTIFY_CENTER
564
- evt.check(@logwindow.has_flag(Wx::TE_CENTER))
565
- when Wx::ID_JUSTIFY_RIGHT
566
- evt.check(@logwindow.has_flag(Wx::TE_RIGHT))
563
+ def on_justify_update_ui(evt)
564
+ case evt.id
565
+ when Wx::ID_JUSTIFY_LEFT
566
+ evt.check(!@logwindow.has_flag(Wx::TE_CENTER | Wx::TE_RIGHT))
567
+ when Wx::ID_JUSTIFY_CENTER
568
+ evt.check(@logwindow.has_flag(Wx::TE_CENTER))
569
+ when Wx::ID_JUSTIFY_RIGHT
570
+ evt.check(@logwindow.has_flag(Wx::TE_RIGHT))
571
+ end
567
572
  end
568
- end
569
573
 
570
- def on_new(evt)
571
- add_text("New button clicked.")
572
- end
574
+ def on_new(evt)
575
+ add_text("New button clicked.")
576
+ end
573
577
 
574
- def on_new_dropdown(evt)
575
- menu = Wx::Menu.new
576
- menu.append(Wx::ID_ANY, "New Document")
577
- menu.append(Wx::ID_ANY, "New Template")
578
- menu.append(Wx::ID_ANY, "New Mail")
578
+ def on_new_dropdown(evt)
579
+ menu = Wx::Menu.new
580
+ menu.append(Wx::ID_ANY, "New Document")
581
+ menu.append(Wx::ID_ANY, "New Template")
582
+ menu.append(Wx::ID_ANY, "New Mail")
579
583
 
580
- evt.popup_menu(menu)
581
- end
584
+ evt.popup_menu(menu)
585
+ end
582
586
 
583
- def on_print(evt)
584
- add_text("Print button clicked.")
585
- end
587
+ def on_print(evt)
588
+ add_text("Print button clicked.")
589
+ end
586
590
 
587
- def on_print_dropdown(evt)
588
- menu = Wx::Menu.new
589
- menu.append(Wx::ID_ANY, "Print")
590
- menu.append(Wx::ID_ANY, "Preview")
591
- menu.append(Wx::ID_ANY, "Options")
591
+ def on_print_dropdown(evt)
592
+ menu = Wx::Menu.new
593
+ menu.append(Wx::ID_ANY, "Print")
594
+ menu.append(Wx::ID_ANY, "Preview")
595
+ menu.append(Wx::ID_ANY, "Options")
592
596
 
593
- evt.popup_menu(menu)
594
- end
597
+ evt.popup_menu(menu)
598
+ end
595
599
 
596
- def on_redo_dropdown(evt)
597
- menu = Wx::Menu.new
598
- menu.append(Wx::ID_ANY, "Redo E")
599
- menu.append(Wx::ID_ANY, "Redo F")
600
- menu.append(Wx::ID_ANY, "Redo G")
600
+ def on_redo_dropdown(evt)
601
+ menu = Wx::Menu.new
602
+ menu.append(Wx::ID_ANY, "Redo E")
603
+ menu.append(Wx::ID_ANY, "Redo F")
604
+ menu.append(Wx::ID_ANY, "Redo G")
601
605
 
602
- evt.popup_menu(menu)
603
- end
606
+ evt.popup_menu(menu)
607
+ end
604
608
 
605
- def on_undo_dropdown(evt)
606
- menu = Wx::Menu.new
607
- menu.append(Wx::ID_ANY, "Undo C")
608
- menu.append(Wx::ID_ANY, "Undo B")
609
- menu.append(Wx::ID_ANY, "Undo A")
609
+ def on_undo_dropdown(evt)
610
+ menu = Wx::Menu.new
611
+ menu.append(Wx::ID_ANY, "Undo C")
612
+ menu.append(Wx::ID_ANY, "Undo B")
613
+ menu.append(Wx::ID_ANY, "Undo A")
610
614
 
611
- evt.popup_menu(menu)
612
- end
615
+ evt.popup_menu(menu)
616
+ end
613
617
 
614
- def on_position_top(evt)
615
- on_position_top_labels(evt)
616
- end
618
+ def on_position_top(evt)
619
+ on_position_top_labels(evt)
620
+ end
617
621
 
618
- def on_position_top_labels(evt)
619
- set_bar_style(Wx::RBN::RIBBON_BAR_DEFAULT_STYLE)
620
- end
622
+ def on_position_top_labels(evt)
623
+ set_bar_style(Wx::RBN::RIBBON_BAR_DEFAULT_STYLE)
624
+ end
621
625
 
622
- def on_position_top_icons(evt)
623
- set_bar_style((Wx::RBN::RIBBON_BAR_DEFAULT_STYLE & (~Wx::RBN::RIBBON_BAR_SHOW_PAGE_LABELS)) | Wx::RBN::RIBBON_BAR_SHOW_PAGE_ICONS)
624
- end
626
+ def on_position_top_icons(evt)
627
+ set_bar_style((Wx::RBN::RIBBON_BAR_DEFAULT_STYLE & (~Wx::RBN::RIBBON_BAR_SHOW_PAGE_LABELS)) | Wx::RBN::RIBBON_BAR_SHOW_PAGE_ICONS)
628
+ end
625
629
 
626
- def on_position_top_both(evt)
627
- set_bar_style(Wx::RBN::RIBBON_BAR_DEFAULT_STYLE | Wx::RBN::RIBBON_BAR_SHOW_PAGE_ICONS)
628
- end
629
-
630
- def on_position_top_dropdown(evt)
631
- menu = Wx::Menu.new
632
- menu.append(ID::POSITION_TOP, "Top with Labels")
633
- menu.append(ID::POSITION_TOP_ICONS, "Top with Icons")
634
- menu.append(ID::POSITION_TOP_BOTH, "Top with Both")
635
- evt.popup_menu(menu)
636
- end
630
+ def on_position_top_both(evt)
631
+ set_bar_style(Wx::RBN::RIBBON_BAR_DEFAULT_STYLE | Wx::RBN::RIBBON_BAR_SHOW_PAGE_ICONS)
632
+ end
637
633
 
638
- def on_position_left(evt)
639
- on_position_left_icons(evt)
640
- end
634
+ def on_position_top_dropdown(evt)
635
+ menu = Wx::Menu.new
636
+ menu.append(ID::POSITION_TOP, "Top with Labels")
637
+ menu.append(ID::POSITION_TOP_ICONS, "Top with Icons")
638
+ menu.append(ID::POSITION_TOP_BOTH, "Top with Both")
639
+ evt.popup_menu(menu)
640
+ end
641
641
 
642
- def on_position_left_labels(evt)
643
- set_bar_style(Wx::RBN::RIBBON_BAR_DEFAULT_STYLE | Wx::RBN::RIBBON_BAR_FLOW_VERTICAL)
644
- end
642
+ def on_position_left(evt)
643
+ on_position_left_icons(evt)
644
+ end
645
645
 
646
- def on_position_left_icons(evt)
647
- set_bar_style((Wx::RBN::RIBBON_BAR_DEFAULT_STYLE & (~Wx::RBN::RIBBON_BAR_SHOW_PAGE_LABELS)) |
648
- Wx::RBN::RIBBON_BAR_SHOW_PAGE_ICONS | Wx::RBN::RIBBON_BAR_FLOW_VERTICAL)
649
- end
646
+ def on_position_left_labels(evt)
647
+ set_bar_style(Wx::RBN::RIBBON_BAR_DEFAULT_STYLE | Wx::RBN::RIBBON_BAR_FLOW_VERTICAL)
648
+ end
650
649
 
651
- def on_position_left_both(evt)
652
- set_bar_style(Wx::RBN::RIBBON_BAR_DEFAULT_STYLE | Wx::RBN::RIBBON_BAR_SHOW_PAGE_ICONS |
653
- Wx::RBN::RIBBON_BAR_FLOW_VERTICAL)
654
- end
650
+ def on_position_left_icons(evt)
651
+ set_bar_style((Wx::RBN::RIBBON_BAR_DEFAULT_STYLE & (~Wx::RBN::RIBBON_BAR_SHOW_PAGE_LABELS)) |
652
+ Wx::RBN::RIBBON_BAR_SHOW_PAGE_ICONS | Wx::RBN::RIBBON_BAR_FLOW_VERTICAL)
653
+ end
655
654
 
656
- def on_position_left_dropdown(evt)
657
- menu = Wx::Menu.new
658
- menu.append(ID::POSITION_LEFT, "Left with Icons")
659
- menu.append(ID::POSITION_LEFT_LABELS, "Left with Labels")
660
- menu.append(ID::POSITION_LEFT_BOTH, "Left with Both")
661
- evt.popup_menu(menu)
662
- end
655
+ def on_position_left_both(evt)
656
+ set_bar_style(Wx::RBN::RIBBON_BAR_DEFAULT_STYLE | Wx::RBN::RIBBON_BAR_SHOW_PAGE_ICONS |
657
+ Wx::RBN::RIBBON_BAR_FLOW_VERTICAL)
658
+ end
663
659
 
664
- def on_remove_page(evt)
665
- n = @ribbon.get_page_count
666
- if n > 0
667
- @ribbon.delete_page(n-1)
668
- @ribbon.realize
660
+ def on_position_left_dropdown(evt)
661
+ menu = Wx::Menu.new
662
+ menu.append(ID::POSITION_LEFT, "Left with Icons")
663
+ menu.append(ID::POSITION_LEFT_LABELS, "Left with Labels")
664
+ menu.append(ID::POSITION_LEFT_BOTH, "Left with Both")
665
+ evt.popup_menu(menu)
669
666
  end
670
- end
671
667
 
672
- def on_hide_pages(evt)
673
- @ribbon.hide_page(1)
674
- @ribbon.hide_page(2)
675
- @ribbon.hide_page(3)
676
- @ribbon.realize
677
- end
668
+ def on_remove_page(evt)
669
+ n = @ribbon.get_page_count
670
+ if n > 0
671
+ @ribbon.delete_page(n-1)
672
+ @ribbon.realize
673
+ end
674
+ end
678
675
 
679
- def on_show_pages(evt)
680
- @ribbon.show_page(1)
681
- @ribbon.show_page(2)
682
- @ribbon.show_page(3)
683
- @ribbon.realize
684
- end
676
+ def on_hide_pages(evt)
677
+ @ribbon.hide_page(1)
678
+ @ribbon.hide_page(2)
679
+ @ribbon.hide_page(3)
680
+ @ribbon.realize
681
+ end
685
682
 
686
- def on_plus_minus(evt)
687
- if @plus_minus_state
688
- evt.bar.set_button_icon(ID::PLUS_MINUS,
689
- Wx::ArtProvider.get_bitmap(Wx::ART_PLUS, Wx::ART_OTHER, [24, 24]))
690
- @plus_minus_state = false
691
- else
692
- evt.bar.set_button_icon(ID::PLUS_MINUS,
693
- Wx::ArtProvider.get_bitmap(Wx::ART_MINUS, Wx::ART_OTHER, [24, 24]))
694
- @plus_minus_state = true
683
+ def on_show_pages(evt)
684
+ @ribbon.show_page(1)
685
+ @ribbon.show_page(2)
686
+ @ribbon.show_page(3)
687
+ @ribbon.realize
695
688
  end
696
- end
697
689
 
698
- def on_change_label(evt)
699
- if @change_label_state
700
- evt.bar.set_button_text(ID::CHANGE_LABEL, "short")
701
- @change_label_state = false
702
- else
703
- evt.bar.set_button_text(ID::CHANGE_LABEL, "some long text")
704
- @change_label_state = true
690
+ def on_plus_minus(evt)
691
+ if @plus_minus_state
692
+ evt.bar.set_button_icon(ID::PLUS_MINUS,
693
+ Wx::ArtProvider.get_bitmap(Wx::ART_PLUS, Wx::ART_OTHER, [24, 24]))
694
+ @plus_minus_state = false
695
+ else
696
+ evt.bar.set_button_icon(ID::PLUS_MINUS,
697
+ Wx::ArtProvider.get_bitmap(Wx::ART_MINUS, Wx::ART_OTHER, [24, 24]))
698
+ @plus_minus_state = true
699
+ end
705
700
  end
706
- end
707
701
 
708
- def on_toggle_panels(evt)
709
- @ribbon.show_panels(@togglePanels.value)
710
- end
702
+ def on_change_label(evt)
703
+ if @change_label_state
704
+ evt.bar.set_button_text(ID::CHANGE_LABEL, "short")
705
+ @change_label_state = false
706
+ else
707
+ evt.bar.set_button_text(ID::CHANGE_LABEL, "some long text")
708
+ @change_label_state = true
709
+ end
710
+ end
711
711
 
712
- def on_ribbon_bar_toggled(evt)
713
- add_text("Ribbon bar %s." %
714
- (@ribbon.are_panels_shown ? "expanded" : "collapsed"))
715
- end
712
+ def on_toggle_panels(evt)
713
+ @ribbon.show_panels(@togglePanels.value)
714
+ end
716
715
 
717
- def on_ribbon_bar_help_clicked(evt)
718
- add_text("Ribbon bar help clicked")
719
- end
716
+ def on_ribbon_bar_toggled(evt)
717
+ add_text("Ribbon bar %s." %
718
+ (@ribbon.are_panels_shown ? "expanded" : "collapsed"))
719
+ end
720
720
 
721
- def on_size_event(evt)
722
- if evt.size.width < 200
723
- @ribbon.hide()
724
- else
725
- @ribbon.show
721
+ def on_ribbon_bar_help_clicked(evt)
722
+ add_text("Ribbon bar help clicked")
726
723
  end
727
- evt.skip
728
- end
729
724
 
730
- def on_ext_button(evt)
731
- Wx.message_box("Extension button clicked")
732
- end
725
+ def on_size_event(evt)
726
+ if evt.size.width < 200
727
+ @ribbon.hide()
728
+ else
729
+ @ribbon.show
730
+ end
731
+ evt.skip
732
+ end
733
733
 
734
- protected
735
-
736
- def populate_colours_panel(panel, defclr, gallery_id)
737
- gallery = panel.find_window_by_id(gallery_id)
738
- if gallery
739
- gallery.clear
740
- else
741
- gallery = Wx::RBN::RibbonGallery.new(panel, gallery_id)
742
- end
743
- Wx::MemoryDC.draw_on do |dc|
744
- def_item = add_colour_to_gallery(gallery, "Default", dc, defclr)
745
- gallery.set_selection(def_item)
746
- add_colour_to_gallery(gallery, "BLUE", dc)
747
- add_colour_to_gallery(gallery, "BLUE VIOLET", dc)
748
- add_colour_to_gallery(gallery, "BROWN", dc)
749
- add_colour_to_gallery(gallery, "CADET BLUE", dc)
750
- add_colour_to_gallery(gallery, "CORAL", dc)
751
- add_colour_to_gallery(gallery, "CYAN", dc)
752
- add_colour_to_gallery(gallery, "DARK GREEN", dc)
753
- add_colour_to_gallery(gallery, "DARK ORCHID", dc)
754
- add_colour_to_gallery(gallery, "FIREBRICK", dc)
755
- add_colour_to_gallery(gallery, "GOLD", dc)
756
- add_colour_to_gallery(gallery, "GOLDENROD", dc)
757
- add_colour_to_gallery(gallery, "GREEN", dc)
758
- add_colour_to_gallery(gallery, "INDIAN RED", dc)
759
- add_colour_to_gallery(gallery, "KHAKI", dc)
760
- add_colour_to_gallery(gallery, "LIGHT BLUE", dc)
761
- add_colour_to_gallery(gallery, "LIME GREEN", dc)
762
- add_colour_to_gallery(gallery, "MAGENTA", dc)
763
- add_colour_to_gallery(gallery, "MAROON", dc)
764
- add_colour_to_gallery(gallery, "NAVY", dc)
765
- add_colour_to_gallery(gallery, "ORANGE", dc)
766
- add_colour_to_gallery(gallery, "ORCHID", dc)
767
- add_colour_to_gallery(gallery, "PINK", dc)
768
- add_colour_to_gallery(gallery, "PLUM", dc)
769
- add_colour_to_gallery(gallery, "PURPLE", dc)
770
- add_colour_to_gallery(gallery, "RED", dc)
771
- add_colour_to_gallery(gallery, "SALMON", dc)
772
- add_colour_to_gallery(gallery, "SEA GREEN", dc)
773
- add_colour_to_gallery(gallery, "SIENNA", dc)
774
- add_colour_to_gallery(gallery, "SKY BLUE", dc)
775
- add_colour_to_gallery(gallery, "TAN", dc)
776
- add_colour_to_gallery(gallery, "THISTLE", dc)
777
- add_colour_to_gallery(gallery, "TURQUOISE", dc)
778
- add_colour_to_gallery(gallery, "VIOLET", dc)
779
- add_colour_to_gallery(gallery, "VIOLET RED", dc)
780
- add_colour_to_gallery(gallery, "WHEAT", dc)
781
- add_colour_to_gallery(gallery, "WHITE", dc)
782
- add_colour_to_gallery(gallery, "YELLOW", dc)
783
- end
784
-
785
- gallery
786
- end
734
+ def on_ext_button(evt)
735
+ Wx.message_box("Extension button clicked")
736
+ end
787
737
 
788
- def add_text(msg)
789
- @logwindow.append_text(msg)
790
- @logwindow.append_text("\n")
791
- @ribbon.dismiss_expanded_panel
792
- end
738
+ protected
793
739
 
794
- def add_colour_to_gallery(gallery, colour, dc, value = nil)
795
- item = nil
796
-
797
- c = nil
798
- c = Wx::Colour.new(colour) if colour != "Default"
799
-
800
- c = value unless c && c.ok?
801
-
802
- if c.ok?
803
- iWidth = 64
804
- iHeight = 40
805
-
806
- bitmap = Wx::Bitmap.new(iWidth, iHeight)
807
- dc.select_object(bitmap)
808
- dc.set_font(@label_font)
809
- b = Wx::Brush.new (c)
810
- dc.set_pen(Wx::BLACK_PEN)
811
- dc.set_brush(b)
812
- dc.draw_rectangle(0, 0, iWidth, iHeight)
813
-
814
- colour = colour[0] + colour[1,colour.size].downcase
815
- size = dc.get_text_extent(colour)
816
- foreground = Wx::Colour.new(~c.red, ~c.green, ~c.blue)
817
- if ((foreground.red - c.red).abs +
818
- (foreground.blue - c.blue).abs +
819
- (foreground.green - c.green).abs) < 64
820
- # Foreground too similar to background - use a different
821
- # strategy to find a contrasting colour
822
- foreground = Wx::Colour.new((c.red + 64) % 256, 255 - c.green, (c.blue + 192) % 256)
740
+ def populate_colours_panel(panel, defclr, gallery_id)
741
+ gallery = panel.find_window_by_id(gallery_id)
742
+ if gallery
743
+ gallery.clear
744
+ else
745
+ gallery = Wx::RBN::RibbonGallery.new(panel, gallery_id)
746
+ end
747
+ Wx::MemoryDC.draw_on do |dc|
748
+ def_item = add_colour_to_gallery(gallery, "Default", dc, defclr)
749
+ gallery.set_selection(def_item)
750
+ add_colour_to_gallery(gallery, "BLUE", dc)
751
+ add_colour_to_gallery(gallery, "BLUE VIOLET", dc)
752
+ add_colour_to_gallery(gallery, "BROWN", dc)
753
+ add_colour_to_gallery(gallery, "CADET BLUE", dc)
754
+ add_colour_to_gallery(gallery, "CORAL", dc)
755
+ add_colour_to_gallery(gallery, "CYAN", dc)
756
+ add_colour_to_gallery(gallery, "DARK GREEN", dc)
757
+ add_colour_to_gallery(gallery, "DARK ORCHID", dc)
758
+ add_colour_to_gallery(gallery, "FIREBRICK", dc)
759
+ add_colour_to_gallery(gallery, "GOLD", dc)
760
+ add_colour_to_gallery(gallery, "GOLDENROD", dc)
761
+ add_colour_to_gallery(gallery, "GREEN", dc)
762
+ add_colour_to_gallery(gallery, "INDIAN RED", dc)
763
+ add_colour_to_gallery(gallery, "KHAKI", dc)
764
+ add_colour_to_gallery(gallery, "LIGHT BLUE", dc)
765
+ add_colour_to_gallery(gallery, "LIME GREEN", dc)
766
+ add_colour_to_gallery(gallery, "MAGENTA", dc)
767
+ add_colour_to_gallery(gallery, "MAROON", dc)
768
+ add_colour_to_gallery(gallery, "NAVY", dc)
769
+ add_colour_to_gallery(gallery, "ORANGE", dc)
770
+ add_colour_to_gallery(gallery, "ORCHID", dc)
771
+ add_colour_to_gallery(gallery, "PINK", dc)
772
+ add_colour_to_gallery(gallery, "PLUM", dc)
773
+ add_colour_to_gallery(gallery, "PURPLE", dc)
774
+ add_colour_to_gallery(gallery, "RED", dc)
775
+ add_colour_to_gallery(gallery, "SALMON", dc)
776
+ add_colour_to_gallery(gallery, "SEA GREEN", dc)
777
+ add_colour_to_gallery(gallery, "SIENNA", dc)
778
+ add_colour_to_gallery(gallery, "SKY BLUE", dc)
779
+ add_colour_to_gallery(gallery, "TAN", dc)
780
+ add_colour_to_gallery(gallery, "THISTLE", dc)
781
+ add_colour_to_gallery(gallery, "TURQUOISE", dc)
782
+ add_colour_to_gallery(gallery, "VIOLET", dc)
783
+ add_colour_to_gallery(gallery, "VIOLET RED", dc)
784
+ add_colour_to_gallery(gallery, "WHEAT", dc)
785
+ add_colour_to_gallery(gallery, "WHITE", dc)
786
+ add_colour_to_gallery(gallery, "YELLOW", dc)
823
787
  end
824
- dc.set_text_foreground(foreground)
825
- dc.draw_text(colour, (iWidth - size[0] + 1).div(2), (iHeight - size[1]).div(2))
826
- dc.select_object_as_source(Wx::NULL_BITMAP)
827
788
 
828
- item = gallery.append(bitmap, Wx::ID_ANY)
829
- gallery.set_item_client_data(item, [colour, c])
789
+ gallery
830
790
  end
831
- item
832
- end
833
791
 
834
- def get_gallery_colour(gallery, item)
835
- gallery.get_item_client_data(item)
836
- end
792
+ def add_text(msg)
793
+ @logwindow.append_text(msg)
794
+ @logwindow.append_text("\n")
795
+ @ribbon.dismiss_expanded_panel
796
+ end
797
+
798
+ def add_colour_to_gallery(gallery, colour, dc, value = nil)
799
+ item = nil
800
+
801
+ c = nil
802
+ c = Wx::Colour.new(colour) if colour != "Default"
803
+
804
+ c = value unless c && c.ok?
805
+
806
+ if c.ok?
807
+ iWidth = 64
808
+ iHeight = 40
809
+
810
+ bitmap = Wx::Bitmap.new(iWidth, iHeight)
811
+ dc.select_object(bitmap)
812
+ dc.set_font(@label_font)
813
+ b = Wx::Brush.new (c)
814
+ dc.set_pen(Wx::BLACK_PEN)
815
+ dc.set_brush(b)
816
+ dc.draw_rectangle(0, 0, iWidth, iHeight)
817
+
818
+ colour = colour[0] + colour[1,colour.size].downcase
819
+ size = dc.get_text_extent(colour)
820
+ foreground = Wx::Colour.new(~c.red, ~c.green, ~c.blue)
821
+ if ((foreground.red - c.red).abs +
822
+ (foreground.blue - c.blue).abs +
823
+ (foreground.green - c.green).abs) < 64
824
+ # Foreground too similar to background - use a different
825
+ # strategy to find a contrasting colour
826
+ foreground = Wx::Colour.new((c.red + 64) % 256, 255 - c.green, (c.blue + 192) % 256)
827
+ end
828
+ dc.set_text_foreground(foreground)
829
+ dc.draw_text(colour, (iWidth - size[0] + 1).div(2), (iHeight - size[1]).div(2))
830
+ dc.select_object_as_source(Wx::NULL_BITMAP)
837
831
 
838
- def reset_gallery_art_providers
839
- if @primary_gallery.get_art_provider != @ribbon.get_art_provider
840
- @primary_gallery.set_art_provider(@ribbon.get_art_provider)
832
+ item = gallery.append(bitmap, Wx::ID_ANY)
833
+ gallery.set_item_client_object(item, [colour, c])
834
+ end
835
+ item
841
836
  end
842
- if @secondary_gallery.art_provider != @ribbon.art_provider
843
- @secondary_gallery.art_provider= @ribbon.art_provider
837
+
838
+ def get_gallery_colour(gallery, item)
839
+ gallery.get_item_client_object(item)
844
840
  end
845
- end
846
841
 
847
- def set_art_provider(prov)
848
- @ribbon.freeze
849
- @ribbon.set_art_provider(prov)
842
+ def reset_gallery_art_providers
843
+ if @primary_gallery.get_art_provider != @ribbon.get_art_provider
844
+ @primary_gallery.set_art_provider(@ribbon.get_art_provider)
845
+ end
846
+ if @secondary_gallery.art_provider != @ribbon.art_provider
847
+ @secondary_gallery.art_provider= @ribbon.art_provider
848
+ end
849
+ end
850
850
 
851
- prov.get_colour_scheme(@default_primary, @default_secondary, @default_tertiary)
852
- populate_colours_panel(@primary_gallery.get_parent, @default_primary, ID::PRIMARY_COLOUR)
853
- populate_colours_panel(@secondary_gallery.parent, @default_secondary, ID::SECONDARY_COLOUR)
851
+ def set_art_provider(prov)
852
+ @ribbon.freeze
853
+ @ribbon.set_art_provider(prov)
854
854
 
855
- @ribbon.realize
856
- @ribbon.thaw
857
- get_sizer.layout
858
- end
855
+ prov.get_colour_scheme(@default_primary, @default_secondary, @default_tertiary)
856
+ populate_colours_panel(@primary_gallery.get_parent, @default_primary, ID::PRIMARY_COLOUR)
857
+ populate_colours_panel(@secondary_gallery.parent, @default_secondary, ID::SECONDARY_COLOUR)
858
+
859
+ @ribbon.realize
860
+ @ribbon.thaw
861
+ get_sizer.layout
862
+ end
863
+
864
+ def set_bar_style(style)
865
+ @ribbon.freeze
866
+ @ribbon.set_window_style_flag(style)
867
+ pTopSize = get_sizer
868
+ pToolbar = find_window_by_id(ID::MAIN_TOOLBAR)
869
+ if (style & Wx::RBN::RIBBON_BAR_FLOW_VERTICAL) == Wx::RBN::RIBBON_BAR_FLOW_VERTICAL
870
+ @ribbon.set_tab_ctrl_margins(10, 10)
871
+ pTopSize.set_orientation(Wx::HORIZONTAL)
872
+ pToolbar.set_rows(3, 5) if pToolbar
873
+ else
874
+ @ribbon.set_tab_ctrl_margins(50, 20)
875
+ pTopSize.set_orientation(Wx::VERTICAL)
876
+ pToolbar.set_rows(2, 3) if pToolbar
877
+ end
878
+ @ribbon.realise
879
+ layout
880
+ @ribbon.thaw
881
+ end
859
882
 
860
- def set_bar_style(style)
861
- @ribbon.freeze
862
- @ribbon.set_window_style_flag(style)
863
- pTopSize = get_sizer
864
- pToolbar = find_window_by_id(ID::MAIN_TOOLBAR)
865
- if (style & Wx::RBN::RIBBON_BAR_FLOW_VERTICAL) == Wx::RBN::RIBBON_BAR_FLOW_VERTICAL
866
- @ribbon.set_tab_ctrl_margins(10, 10)
867
- pTopSize.set_orientation(Wx::HORIZONTAL)
868
- pToolbar.set_rows(3, 5) if pToolbar
869
- else
870
- @ribbon.set_tab_ctrl_margins(50, 20)
871
- pTopSize.set_orientation(Wx::VERTICAL)
872
- pToolbar.set_rows(2, 3) if pToolbar
873
- end
874
- @ribbon.realise
875
- layout
876
- @ribbon.thaw
877
883
  end
878
884
 
879
885
  end
@@ -889,7 +895,7 @@ module RibbonSample
889
895
  end
890
896
 
891
897
  def self.activate
892
- frame = MyFrame.new
898
+ frame = Ribbon::MyFrame.new
893
899
  frame.show(true)
894
900
  frame
895
901
  end