wxruby64 2.0.1-x64-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (279) hide show
  1. checksums.yaml +7 -0
  2. data/INSTALL +254 -0
  3. data/LICENSE +53 -0
  4. data/README +198 -0
  5. data/art/wxruby-128x128.png +0 -0
  6. data/art/wxruby-256x256.png +0 -0
  7. data/art/wxruby-64x64.png +0 -0
  8. data/art/wxruby.png +0 -0
  9. data/lib/wx.rb +53 -0
  10. data/lib/wx/accessors.rb +68 -0
  11. data/lib/wx/classes/acceleratortable.rb +28 -0
  12. data/lib/wx/classes/animation.rb +18 -0
  13. data/lib/wx/classes/app.rb +51 -0
  14. data/lib/wx/classes/artprovider.rb +31 -0
  15. data/lib/wx/classes/auinotebook.rb +9 -0
  16. data/lib/wx/classes/bitmap.rb +59 -0
  17. data/lib/wx/classes/busycursor.rb +12 -0
  18. data/lib/wx/classes/checklistbox.rb +46 -0
  19. data/lib/wx/classes/choice.rb +4 -0
  20. data/lib/wx/classes/clientdc.rb +13 -0
  21. data/lib/wx/classes/clipboard.rb +56 -0
  22. data/lib/wx/classes/colour.rb +49 -0
  23. data/lib/wx/classes/combobox.rb +4 -0
  24. data/lib/wx/classes/commandevent.rb +7 -0
  25. data/lib/wx/classes/controlwithitems.rb +10 -0
  26. data/lib/wx/classes/data_object.rb +14 -0
  27. data/lib/wx/classes/data_object_simple.rb +6 -0
  28. data/lib/wx/classes/dataformat.rb +23 -0
  29. data/lib/wx/classes/dc.rb +57 -0
  30. data/lib/wx/classes/event.rb +5 -0
  31. data/lib/wx/classes/evthandler.rb +1039 -0
  32. data/lib/wx/classes/font.rb +118 -0
  33. data/lib/wx/classes/functions.rb +44 -0
  34. data/lib/wx/classes/gauge.rb +12 -0
  35. data/lib/wx/classes/genericdirctrl.rb +36 -0
  36. data/lib/wx/classes/grid.rb +146 -0
  37. data/lib/wx/classes/hboxsizer.rb +6 -0
  38. data/lib/wx/classes/helpcontroller.rb +5 -0
  39. data/lib/wx/classes/helpcontrollerhelpprovider.rb +23 -0
  40. data/lib/wx/classes/helpprovider.rb +15 -0
  41. data/lib/wx/classes/htmlhelpcontroller.rb +5 -0
  42. data/lib/wx/classes/htmlwindow.rb +14 -0
  43. data/lib/wx/classes/icon.rb +32 -0
  44. data/lib/wx/classes/iconbundle.rb +3 -0
  45. data/lib/wx/classes/image.rb +53 -0
  46. data/lib/wx/classes/imagelist.rb +3 -0
  47. data/lib/wx/classes/listbox.rb +4 -0
  48. data/lib/wx/classes/listctrl.rb +33 -0
  49. data/lib/wx/classes/locale.rb +28 -0
  50. data/lib/wx/classes/mediactrl.rb +48 -0
  51. data/lib/wx/classes/menu.rb +62 -0
  52. data/lib/wx/classes/menuitem.rb +7 -0
  53. data/lib/wx/classes/notebook.rb +9 -0
  54. data/lib/wx/classes/object.rb +14 -0
  55. data/lib/wx/classes/paintdc.rb +12 -0
  56. data/lib/wx/classes/point.rb +56 -0
  57. data/lib/wx/classes/previewframe.rb +13 -0
  58. data/lib/wx/classes/rect.rb +19 -0
  59. data/lib/wx/classes/richtextctrl.rb +63 -0
  60. data/lib/wx/classes/simplehelpprovider.rb +38 -0
  61. data/lib/wx/classes/size.rb +58 -0
  62. data/lib/wx/classes/sizer.rb +43 -0
  63. data/lib/wx/classes/sound.rb +23 -0
  64. data/lib/wx/classes/splitterwindow.rb +10 -0
  65. data/lib/wx/classes/standardpaths.rb +9 -0
  66. data/lib/wx/classes/styledtextctrl.rb +92 -0
  67. data/lib/wx/classes/textctrl.rb +14 -0
  68. data/lib/wx/classes/texturlevent.rb +18 -0
  69. data/lib/wx/classes/timer.rb +96 -0
  70. data/lib/wx/classes/toolbar.rb +36 -0
  71. data/lib/wx/classes/toolbartool.rb +4 -0
  72. data/lib/wx/classes/treectrl.rb +44 -0
  73. data/lib/wx/classes/validator.rb +7 -0
  74. data/lib/wx/classes/vboxsizer.rb +6 -0
  75. data/lib/wx/classes/window.rb +89 -0
  76. data/lib/wx/classes/xmlresource.rb +54 -0
  77. data/lib/wx/helpers.rb +54 -0
  78. data/lib/wx/keyword_ctors.rb +204 -0
  79. data/lib/wx/keyword_defs.rb +585 -0
  80. data/lib/wx/version.rb +3 -0
  81. data/lib/wxruby2.so +0 -0
  82. data/samples/SAMPLES-LICENSE.TXT +18 -0
  83. data/samples/aui/aui.rb +1356 -0
  84. data/samples/bigdemo/About.rbw +39 -0
  85. data/samples/bigdemo/ColorPanel.rbw +23 -0
  86. data/samples/bigdemo/GridSimple.rbw +78 -0
  87. data/samples/bigdemo/MDIDemo.rbw +57 -0
  88. data/samples/bigdemo/PopupMenu.rbw +149 -0
  89. data/samples/bigdemo/ShapedWindow.rbw +128 -0
  90. data/samples/bigdemo/Sizers.rbw +543 -0
  91. data/samples/bigdemo/bigdemo.rb +823 -0
  92. data/samples/bigdemo/demoTemplate.rbw +33 -0
  93. data/samples/bigdemo/helpfile.htb +0 -0
  94. data/samples/bigdemo/icons/Test 015.jpg +0 -0
  95. data/samples/bigdemo/icons/Test 015.png +0 -0
  96. data/samples/bigdemo/icons/choice.bmp +0 -0
  97. data/samples/bigdemo/icons/choice.xpm +27 -0
  98. data/samples/bigdemo/icons/combo.bmp +0 -0
  99. data/samples/bigdemo/icons/combo.xpm +27 -0
  100. data/samples/bigdemo/icons/copy.xpm +25 -0
  101. data/samples/bigdemo/icons/cut.xpm +24 -0
  102. data/samples/bigdemo/icons/gauge.bmp +0 -0
  103. data/samples/bigdemo/icons/gauge.xpm +27 -0
  104. data/samples/bigdemo/icons/help.xpm +25 -0
  105. data/samples/bigdemo/icons/list.bmp +0 -0
  106. data/samples/bigdemo/icons/list.xpm +27 -0
  107. data/samples/bigdemo/icons/mondrian.ico +0 -0
  108. data/samples/bigdemo/icons/mondrian.xpm +44 -0
  109. data/samples/bigdemo/icons/new.xpm +24 -0
  110. data/samples/bigdemo/icons/ogl.ico +0 -0
  111. data/samples/bigdemo/icons/ogl.xpm +45 -0
  112. data/samples/bigdemo/icons/open.xpm +26 -0
  113. data/samples/bigdemo/icons/paste.bmp +0 -0
  114. data/samples/bigdemo/icons/paste.xpm +38 -0
  115. data/samples/bigdemo/icons/pointy.png +0 -0
  116. data/samples/bigdemo/icons/preview.xpm +26 -0
  117. data/samples/bigdemo/icons/print.xpm +26 -0
  118. data/samples/bigdemo/icons/radio.bmp +0 -0
  119. data/samples/bigdemo/icons/radio.xpm +27 -0
  120. data/samples/bigdemo/icons/robert.xpm +415 -0
  121. data/samples/bigdemo/icons/sashtest.ico +0 -0
  122. data/samples/bigdemo/icons/save.xpm +25 -0
  123. data/samples/bigdemo/icons/smiles.bmp +0 -0
  124. data/samples/bigdemo/icons/smiles.xpm +39 -0
  125. data/samples/bigdemo/icons/smiley.ico +0 -0
  126. data/samples/bigdemo/icons/smiley.xpm +42 -0
  127. data/samples/bigdemo/icons/stattext.xpm +24 -0
  128. data/samples/bigdemo/icons/test2.bmp +0 -0
  129. data/samples/bigdemo/icons/test2.png +0 -0
  130. data/samples/bigdemo/icons/test2.xpm +79 -0
  131. data/samples/bigdemo/icons/text.bmp +0 -0
  132. data/samples/bigdemo/icons/text.xpm +27 -0
  133. data/samples/bigdemo/icons/tog1.bmp +0 -0
  134. data/samples/bigdemo/icons/tog1.xpm +38 -0
  135. data/samples/bigdemo/icons/tog2.bmp +0 -0
  136. data/samples/bigdemo/icons/tog2.xpm +38 -0
  137. data/samples/bigdemo/icons/wxruby-128x128.png +0 -0
  138. data/samples/bigdemo/icons/wxwin.ico +0 -0
  139. data/samples/bigdemo/icons/wxwin16x16.png +0 -0
  140. data/samples/bigdemo/icons/wxwin16x16.xpm +25 -0
  141. data/samples/bigdemo/icons/wxwin32x32.png +0 -0
  142. data/samples/bigdemo/icons/wxwin48x48.png +0 -0
  143. data/samples/bigdemo/run.rb +90 -0
  144. data/samples/bigdemo/tips.txt +7 -0
  145. data/samples/bigdemo/utils.rb +12 -0
  146. data/samples/bigdemo/wxArtProvider.rbw +281 -0
  147. data/samples/bigdemo/wxBitmapButton.rbw +65 -0
  148. data/samples/bigdemo/wxButton.rbw +64 -0
  149. data/samples/bigdemo/wxCalendarCtrl.rbw +60 -0
  150. data/samples/bigdemo/wxCheckBox.rbw +50 -0
  151. data/samples/bigdemo/wxCheckListBox.rbw +65 -0
  152. data/samples/bigdemo/wxChoice.rbw +47 -0
  153. data/samples/bigdemo/wxChoicebook.rbw +78 -0
  154. data/samples/bigdemo/wxColourDialog.rbw +31 -0
  155. data/samples/bigdemo/wxComboBox.rbw +77 -0
  156. data/samples/bigdemo/wxCursor.rbw +136 -0
  157. data/samples/bigdemo/wxDialog.rbw +74 -0
  158. data/samples/bigdemo/wxDirDialog.rbw +29 -0
  159. data/samples/bigdemo/wxDragImage.rbw +70 -0
  160. data/samples/bigdemo/wxFileDialog.rbw +37 -0
  161. data/samples/bigdemo/wxFileDialog_Save.rbw +35 -0
  162. data/samples/bigdemo/wxFindReplaceDialog.rbw +82 -0
  163. data/samples/bigdemo/wxFontDialog.rbw +173 -0
  164. data/samples/bigdemo/wxFrame.rbw +53 -0
  165. data/samples/bigdemo/wxGauge.rbw +71 -0
  166. data/samples/bigdemo/wxGenericDirCtrl.rbw +74 -0
  167. data/samples/bigdemo/wxGrid.rbw +66 -0
  168. data/samples/bigdemo/wxHtmlHelpController.rbw +52 -0
  169. data/samples/bigdemo/wxListBox.rbw +140 -0
  170. data/samples/bigdemo/wxListCtrl_virtual.rbw +112 -0
  171. data/samples/bigdemo/wxMDIWindows.rbw +50 -0
  172. data/samples/bigdemo/wxMenu.rbw +236 -0
  173. data/samples/bigdemo/wxMessageDialog.rbw +27 -0
  174. data/samples/bigdemo/wxMiniFrame.rbw +70 -0
  175. data/samples/bigdemo/wxMultipleChoiceDialog.rbw +32 -0
  176. data/samples/bigdemo/wxNotebook.rbw +136 -0
  177. data/samples/bigdemo/wxProgressDialog.rbw +43 -0
  178. data/samples/bigdemo/wxRadioBox.rbw +72 -0
  179. data/samples/bigdemo/wxRadioButton.rbw +125 -0
  180. data/samples/bigdemo/wxSashWindow.rbw +141 -0
  181. data/samples/bigdemo/wxScrolledMessageDialog.rbw +57 -0
  182. data/samples/bigdemo/wxScrolledWindow.rbw +199 -0
  183. data/samples/bigdemo/wxSingleChoiceDialog.rbw +33 -0
  184. data/samples/bigdemo/wxSlider.rbw +42 -0
  185. data/samples/bigdemo/wxSpinButton.rbw +50 -0
  186. data/samples/bigdemo/wxSpinCtrl.rbw +51 -0
  187. data/samples/bigdemo/wxSplitterWindow.rbw +63 -0
  188. data/samples/bigdemo/wxStaticBitmap.rbw +47 -0
  189. data/samples/bigdemo/wxStaticText.rbw +55 -0
  190. data/samples/bigdemo/wxStatusBar.rbw +126 -0
  191. data/samples/bigdemo/wxTextCtrl.rbw +149 -0
  192. data/samples/bigdemo/wxTextEntryDialog.rbw +31 -0
  193. data/samples/bigdemo/wxToggleButton.rbw +49 -0
  194. data/samples/bigdemo/wxToolBar.rbw +131 -0
  195. data/samples/bigdemo/wxTreeCtrl.rbw +191 -0
  196. data/samples/calendar/calendar.rb +348 -0
  197. data/samples/caret/caret.rb +282 -0
  198. data/samples/caret/mondrian.xpm +44 -0
  199. data/samples/controls/controls.rb +1136 -0
  200. data/samples/controls/get_item_sample.rb +87 -0
  201. data/samples/controls/icons/choice.xpm +27 -0
  202. data/samples/controls/icons/combo.xpm +27 -0
  203. data/samples/controls/icons/gauge.xpm +27 -0
  204. data/samples/controls/icons/list.xpm +27 -0
  205. data/samples/controls/icons/radio.xpm +27 -0
  206. data/samples/controls/icons/stattext.xpm +24 -0
  207. data/samples/controls/icons/text.xpm +27 -0
  208. data/samples/controls/mondrian.ico +0 -0
  209. data/samples/controls/mondrian.xpm +44 -0
  210. data/samples/controls/test2.bmp +0 -0
  211. data/samples/dialogs/dialogs.rb +797 -0
  212. data/samples/dialogs/tips.txt +18 -0
  213. data/samples/dragdrop/dragdrop.rb +177 -0
  214. data/samples/drawing/bitmap.rb +49 -0
  215. data/samples/drawing/bitmap_image.rb +92 -0
  216. data/samples/drawing/graphics_drawing.rb +235 -0
  217. data/samples/drawing/maths_images.rb +265 -0
  218. data/samples/drawing/rmagic_bitmap_image.rb +110 -0
  219. data/samples/drawing/ruby-logo.jpg +0 -0
  220. data/samples/etc/activation.rb +102 -0
  221. data/samples/etc/choice.rb +67 -0
  222. data/samples/etc/miniframe.rb +79 -0
  223. data/samples/etc/sash.rb +130 -0
  224. data/samples/etc/scrollwin.rb +110 -0
  225. data/samples/etc/system_settings.rb +252 -0
  226. data/samples/etc/threaded.rb +72 -0
  227. data/samples/etc/toolbar_sizer_additem.rb +55 -0
  228. data/samples/etc/wizard.rb +74 -0
  229. data/samples/event/event.rb +182 -0
  230. data/samples/event/update_ui_event.rb +70 -0
  231. data/samples/grid/grid.rb +198 -0
  232. data/samples/grid/gridtablebase.rb +148 -0
  233. data/samples/html/html.rb +262 -0
  234. data/samples/listbook/listbook.rb +174 -0
  235. data/samples/listbook/listbook.xrc +370 -0
  236. data/samples/mdi/mdi.rb +85 -0
  237. data/samples/media/mediactrl.rb +167 -0
  238. data/samples/minimal/minimal.rb +77 -0
  239. data/samples/minimal/mondrian.ico +0 -0
  240. data/samples/minimal/mondrian.png +0 -0
  241. data/samples/minimal/nothing.rb +16 -0
  242. data/samples/opengl/cube.rb +130 -0
  243. data/samples/opengl/cube_anim_lighting.rb +191 -0
  244. data/samples/printing/mondrian.ico +0 -0
  245. data/samples/printing/mondrian.xpm +44 -0
  246. data/samples/printing/printing.rb +487 -0
  247. data/samples/sockets/SocketPackets.rb +27 -0
  248. data/samples/sockets/res/message-new.png +0 -0
  249. data/samples/sockets/res/user.png +0 -0
  250. data/samples/sockets/wxClient.rb +395 -0
  251. data/samples/sockets/wxServer.rb +422 -0
  252. data/samples/sockets/wxSocketGUI.rb +97 -0
  253. data/samples/text/document-open.png +0 -0
  254. data/samples/text/document-save.png +0 -0
  255. data/samples/text/edit-copy.png +0 -0
  256. data/samples/text/edit-cut.png +0 -0
  257. data/samples/text/edit-paste.png +0 -0
  258. data/samples/text/edit-redo.png +0 -0
  259. data/samples/text/edit-undo.png +0 -0
  260. data/samples/text/format-text-bold.png +0 -0
  261. data/samples/text/format-text-italic.png +0 -0
  262. data/samples/text/format-text-underline.png +0 -0
  263. data/samples/text/mondrian.ico +0 -0
  264. data/samples/text/mondrian.xpm +44 -0
  265. data/samples/text/preferences-desktop-font.png +0 -0
  266. data/samples/text/rich_textctrl.rb +290 -0
  267. data/samples/text/scintilla.rb +169 -0
  268. data/samples/text/textctrl.rb +111 -0
  269. data/samples/text/unicode.rb +242 -0
  270. data/samples/text/utf8.txt +15 -0
  271. data/samples/treectrl/icon1.xpm +79 -0
  272. data/samples/treectrl/icon2.xpm +53 -0
  273. data/samples/treectrl/icon3.xpm +79 -0
  274. data/samples/treectrl/icon4.xpm +43 -0
  275. data/samples/treectrl/icon5.xpm +79 -0
  276. data/samples/treectrl/treectrl.rb +1166 -0
  277. data/samples/xrc/samples.xrc +46 -0
  278. data/samples/xrc/xrc_sample.rb +76 -0
  279. metadata +330 -0
@@ -0,0 +1,198 @@
1
+ #!/usr/bin/env ruby
2
+ # wxRuby2 Sample Code. Copyright (c) 2004-2008 wxRuby development team
3
+ # Freely reusable code: see SAMPLES-LICENSE.TXT for details
4
+ begin
5
+ require 'rubygems'
6
+ rescue LoadError
7
+ end
8
+ require 'wx'
9
+
10
+ class GridFrame < Wx::Frame
11
+
12
+ def initialize(parent, id = -1, title = "MyFrame",
13
+ pos = Wx::DEFAULT_POSITION,
14
+ size = Wx::DEFAULT_SIZE,
15
+ style = Wx::DEFAULT_FRAME_STYLE)
16
+
17
+ super(parent, id, title, pos, size, style)
18
+ sizer = Wx::BoxSizer.new(Wx::VERTICAL)
19
+ create_status_bar()
20
+ set_status_text(Wx::VERSION_STRING)
21
+
22
+ # panel = Wx::Panel.new(self)
23
+ sel_menu = Wx::Menu.new
24
+ sel_menu.append(1002, 'Select all', 'Select all')
25
+ evt_menu(1002) { @grid.select_all }
26
+ sel_menu.append(1003, 'Select row 2', 'Select row 2')
27
+ evt_menu(1003) { @grid.select_row(1) }
28
+ sel_menu.append(1004, 'Select column 4', 'Select col 4')
29
+ evt_menu(1004) { @grid.select_col(3) }
30
+ sel_menu.append(1005, 'Select block', 'Select block')
31
+ evt_menu(1005) { @grid.select_block(1, 1, 6, 3) }
32
+ menu_bar = Wx::MenuBar.new
33
+ menu_bar.append(sel_menu, 'Select')
34
+ set_menu_bar(menu_bar)
35
+
36
+ make_grid(self)
37
+ sizer.add(@grid, 1, Wx::ALL|Wx::GROW, 4)
38
+ set_sizer(sizer)
39
+
40
+ evt_grid_cell_left_click() do |evt|
41
+ set_status_text("#{evt.get_row} x #{evt.get_col} is clicked")
42
+ evt.skip
43
+ end
44
+
45
+ evt_grid_cell_right_click() do |evt|
46
+ set_status_text("#{evt.get_row} x #{evt.get_col} is right clicked")
47
+ evt.skip
48
+ end
49
+
50
+ evt_grid_cell_left_dclick() do |evt|
51
+ set_status_text("#{evt.get_row} x #{evt.get_col} is double clicked")
52
+ evt.skip
53
+ end
54
+
55
+ evt_grid_cell_right_dclick() do |evt|
56
+ set_status_text("#{evt.get_row} x #{evt.get_col} is right double clicked")
57
+ evt.skip
58
+ end
59
+
60
+ evt_grid_label_left_click() do |evt|
61
+ set_status_text("#{evt.get_row} x #{evt.get_col} label is clicked")
62
+ evt.skip
63
+ end
64
+
65
+ evt_grid_label_right_click() do |evt|
66
+ set_status_text("#{evt.get_row} x #{evt.get_col} label is right clicked")
67
+ evt.skip
68
+ end
69
+
70
+ evt_grid_label_left_dclick() do |evt|
71
+ set_status_text("#{evt.get_row} x #{evt.get_col} labelis double clicked")
72
+ evt.skip
73
+ end
74
+
75
+ evt_grid_label_right_dclick() do |evt|
76
+ set_status_text("#{evt.get_row} x #{evt.get_col} label is right double clicked")
77
+ evt.skip
78
+ end
79
+
80
+ evt_grid_select_cell() do |evt|
81
+ set_status_text("#{evt.get_row} x #{evt.get_col} cell is selected")
82
+ evt.skip
83
+ end
84
+
85
+ evt_grid_row_size do |evt|
86
+ set_status_text("Row #{evt.get_row_or_col} size changed")
87
+ evt.skip
88
+ end
89
+
90
+ evt_grid_col_size do |evt|
91
+ set_status_text("Column #{evt.get_row_or_col} size changed")
92
+ evt.skip
93
+ end
94
+
95
+ evt_grid_editor_shown do |evt|
96
+ set_status_text("Begin editing")
97
+ evt.skip
98
+ end
99
+
100
+ evt_grid_editor_hidden do |evt|
101
+ set_status_text("End editing")
102
+ evt.skip
103
+ end
104
+
105
+ evt_grid_range_select do |evt|
106
+ top = evt.get_top_left_coords
107
+ bottom = evt.get_bottom_right_coords
108
+ set_status_text("[ #{top[0].to_s} x #{top[1].to_s} ] to [ #{bottom[0].to_s} x #{bottom[1].to_s} ] is selected")
109
+ end
110
+
111
+ evt_grid_editor_created do |evt|
112
+ set_status_text("Control #{evt.get_control} created")
113
+ evt.skip
114
+ end
115
+
116
+ evt_grid_cell_change() do |evt|
117
+ set_status_text("Cell #{evt.get_row} x #{evt.get_col} has changed")
118
+ end
119
+ end
120
+
121
+ # Create a wxGrid object
122
+ def make_grid(panel)
123
+ @grid = Wx::Grid.new(panel, -1)
124
+
125
+ # Then we call CreateGrid to set the dimensions of the grid
126
+ # (11 rows and 12 columns in this example)
127
+ @grid.create_grid( 20, 12 )
128
+ @grid.set_default_cell_background_colour(Wx::WHITE)
129
+ # We can set the sizes of individual rows and columns
130
+ # in pixels, and the label value string
131
+ @grid.set_row_size( 0, 60 )
132
+ @grid.set_row_label_value( 0, "Row1" )
133
+ @grid.set_row_label_alignment(Wx::ALIGN_CENTRE, Wx::ALIGN_CENTRE)
134
+
135
+ @grid.set_col_size( 0, 120 )
136
+ @grid.set_col_label_value( 0, "Col1" )
137
+ @grid.set_col_label_alignment(Wx::ALIGN_CENTRE, Wx::ALIGN_CENTRE)
138
+
139
+ # And set grid cell contents as strings
140
+ @grid.set_cell_value( 0, 0, "wxGrid is good" )
141
+
142
+ # We can specify that some cells are read-only
143
+ @grid.set_cell_value( 0, 2, "Read-only" )
144
+ @grid.set_read_only( 0, 2 )
145
+
146
+ # Colours can be specified for grid cell contents
147
+ @grid.set_cell_value(1, 1, "white on red")
148
+ @grid.set_cell_text_colour(1, 1, Wx::WHITE)
149
+ @grid.set_cell_background_colour(1, 1, Wx::RED)
150
+
151
+ # We can specify the some cells will store numeric
152
+ # values rather than strings. Here we set grid column 6
153
+ # to hold floating point values displayed with width
154
+ # of 2 and precision of 2. The column is highlighted in light grey
155
+ cell_attr = Wx::GridCellAttr.new
156
+ cell_attr.set_background_colour( Wx::LIGHT_GREY )
157
+ cell_attr.set_renderer( Wx::GridCellFloatRenderer.new(2, 2) )
158
+
159
+ @grid.set_col_attr(5, cell_attr)
160
+ @grid.set_cell_value(0, 5, "3.1415")
161
+ @grid.set_cell_value(0, 6,
162
+ "The whole column to the left uses float format")
163
+
164
+ # Custom Editors Can be used
165
+ editor = Wx::GridCellNumberEditor.new(5, 20)
166
+ @grid.set_cell_value(3, 1, 'Number editor below')
167
+ @grid.set_cell_editor(4, 1, editor)
168
+
169
+ editor = Wx::GridCellFloatEditor.new(4, 2)
170
+ @grid.set_cell_value(3, 2, 'Float editor below')
171
+ @grid.set_cell_editor(4, 2, editor)
172
+
173
+ editor = Wx::GridCellChoiceEditor.new(['foo', 'bar', 'baz'])
174
+ @grid.set_cell_value(3, 3, 'Choice editor below')
175
+ @grid.set_cell_editor(4, 3, editor)
176
+
177
+ @grid.auto_size_row(3, true)
178
+
179
+ # Display of cells can be customised
180
+ @grid.set_cell_editor(6, 0, Wx::GridCellBoolEditor.new)
181
+ @grid.set_cell_renderer(6, 0, Wx::GridCellBoolRenderer.new)
182
+ @grid.set_cell_value(6, 1, 'Cell to the left displayed as boolean')
183
+ end
184
+
185
+ end
186
+
187
+ class GridApp < Wx::App
188
+ def on_init
189
+ frame = GridFrame.new(nil, -1, "Grid Sample",
190
+ Wx::Point.new(10, 100),
191
+ Wx::Size.new(630,400))
192
+
193
+ set_top_window(frame)
194
+ frame.show()
195
+ end
196
+ end
197
+
198
+ GridApp.new.main_loop()
@@ -0,0 +1,148 @@
1
+ #!/usr/bin/env ruby
2
+ # wxRuby2 Sample Code. Copyright (c) 2004-2009 wxRuby development team
3
+ # Freely reusable code: see SAMPLES-LICENSE.TXT for details
4
+ begin
5
+ require 'rubygems'
6
+ rescue LoadError
7
+ end
8
+ require 'wx'
9
+
10
+ # GridTableBase is an alternative way to provide data to a Wx::Grid. A
11
+ # subclass of Wx::GridTableBase is created which is reqiured to provide
12
+ # methods to report the total size of the Grid in rows and columns, and
13
+ # the contents and style of individual cells.
14
+ #
15
+ # Then, when creating the Grid, instead of calling create_grid and
16
+ # set_value to populate it, the GridTableBase-derived class is
17
+ # associated with the Grid, and provides these functions (see below)
18
+ #
19
+ # This approach is typically useful for dealing with very large sets of
20
+ # data, as each cell's value is only requested as it becomes visible.v
21
+ class MyGridTable < Wx::GridTableBase
22
+ attr_reader :cols, :rows
23
+ def initialize(rows, cols)
24
+ super()
25
+ @rows = rows
26
+ @cols = cols
27
+ @number_col = 1
28
+ end
29
+
30
+ # Letter labels for columns
31
+ COLS = ('AA' .. 'ZZ').to_a
32
+
33
+ # Firstly, a GridTableBase must indicate the size of the grid in
34
+ # terms of rows ...
35
+ def get_number_rows
36
+ @rows
37
+ end
38
+
39
+ # ... and columns
40
+ def get_number_cols
41
+ @cols
42
+ end
43
+
44
+ # Most importantly, it should be able to return any given cell's
45
+ # contents, given its row and column reference
46
+ def get_value(row, col)
47
+ if col == @number_col
48
+ (row * 5).to_s
49
+ else
50
+ "#{row}:#{COLS[col]}"
51
+ end
52
+ end
53
+
54
+ # This is not needed if the cell contents are simply strings. However,
55
+ # if you wish to use custom GridCellRenderers and/or GridCellEditors,
56
+ # this should return a type name which has the correct renderer /
57
+ # editor defined for it in the Grid, using register_
58
+ def get_type_name(row, col)
59
+ if col == @number_col
60
+ "NUMBER"
61
+ else
62
+ "STRING"
63
+ end
64
+ end
65
+
66
+ # It should also return the attributes that should apply to any given
67
+ # cell; this example give alternate rows red text letters
68
+ def get_attr(row, col, attr_kind)
69
+ attr = Wx::GridCellAttr.new
70
+ if (row % 2).zero?
71
+ attr.text_colour = Wx::RED
72
+ end
73
+ attr
74
+ end
75
+
76
+ # It should indicate whether any given cell is empty
77
+ def is_empty_cell(row, col)
78
+ false
79
+ end
80
+
81
+ # It may also provide labels for the columns and rows
82
+ def get_col_label_value(col)
83
+ COLS[col]
84
+ end
85
+
86
+ # If the Grid is to support write as well as read operations,
87
+ # set_value should also be implemented. In this case, the change is
88
+ # merely echoed back and doesn't alter the underlying value; a real
89
+ # implementation could, for example, write back to a database
90
+ def set_value(x, y, val)
91
+ puts "Changing the value of cell (#{x}, #{y}) to '#{val}'"
92
+ end
93
+ end
94
+
95
+ class GridFrame < Wx::Frame
96
+ def initialize()
97
+ super(nil, :title => 'GridTableBase demo', :size => [600, 300])
98
+ main_sizer = Wx::VBoxSizer.new
99
+ # Create a grid and associate an instance of the GridTable as the
100
+ # data provider for the grid
101
+ @grid = Wx::Grid.new(self)
102
+
103
+ # Define the renderers and editors used by the different data types
104
+ # displayed in this Grid. The type of a given cell is determined by
105
+ # calling the source's get_type_name method; see above.
106
+ @grid.register_data_type( "STRING",
107
+ Wx::GridCellStringRenderer.new,
108
+ Wx::GridCellTextEditor.new )
109
+ @grid.register_data_type( "NUMBER",
110
+ Wx::GridCellNumberRenderer.new,
111
+ Wx::GridCellNumberEditor.new(0, 500) )
112
+
113
+ # Set the data source
114
+ @grid.table = MyGridTable.new(10, 10)
115
+
116
+
117
+ main_sizer.add(@grid, 1, Wx::EXPAND|Wx::ALL, 5)
118
+
119
+ # Add some buttons that can change the contents
120
+ butt_sizer = Wx::BoxSizer.new(Wx::HORIZONTAL)
121
+
122
+ butt_1 = Wx::Button.new(self, :label => "Add row")
123
+ # When resizing the grid to have a new number of rows or columns,
124
+ # need to allocate a new grid table source
125
+ evt_button(butt_1) do
126
+ @grid.table = MyGridTable.new( @grid.table.rows + 1,
127
+ @grid.table.cols)
128
+ @grid.refresh
129
+ end
130
+ butt_sizer.add(butt_1)
131
+
132
+ butt_2 = Wx::Button.new(self, :label => "Add column")
133
+ evt_button(butt_2) do
134
+ @grid.table = MyGridTable.new( @grid.table.rows,
135
+ @grid.table.cols + 1)
136
+ @grid.refresh
137
+ end
138
+ butt_sizer.add(butt_2)
139
+
140
+ main_sizer.add(butt_sizer, 0, Wx::EXPAND|Wx::ALL, 5)
141
+ self.sizer = main_sizer
142
+ end
143
+ end
144
+
145
+ Wx::App.run do
146
+ GridFrame.new.show
147
+ end
148
+
@@ -0,0 +1,262 @@
1
+ #!/usr/bin/env ruby
2
+ # wxRuby2 Sample Code. Copyright (c) 2004-2008 wxRuby development team
3
+ # Freely reusable code: see SAMPLES-LICENSE.TXT for details
4
+ begin
5
+ require 'rubygems'
6
+ rescue LoadError
7
+ end
8
+ require 'wx'
9
+
10
+ require 'net/http'
11
+ require 'uri'
12
+
13
+ class MyHtmlWindow < Wx::HtmlWindow
14
+ attr_reader :html_src
15
+ def initialize(*args)
16
+ super
17
+ evt_html_link_clicked self, :on_link_clicked
18
+ evt_html_cell_hover self, :on_hover
19
+ end
20
+
21
+ def load_page_from_uri(uri)
22
+ case uri
23
+ when URI::HTTP
24
+ Wx::BusyCursor.busy do
25
+ begin
26
+ res = Net::HTTP.start(uri.host, uri.port) do | http |
27
+ http.get(uri.path)
28
+ end
29
+ @loaded_uri = uri
30
+ set_page(res.body)
31
+ rescue => err
32
+ msg = "Could not load page:\n#{err}"
33
+ Wx::MessageDialog.new(nil, msg, 'Error loading page',
34
+ Wx::OK|Wx::ICON_ERROR).show_modal
35
+ return ''
36
+ end
37
+ end
38
+ return @loaded_uri
39
+ when URI::Generic
40
+ if @loaded_uri and @loaded_uri.kind_of?(URI::HTTP)
41
+ return load_page_from_uri( @loaded_uri.merge(uri) )
42
+ elsif @loaded_uri # current viewing a file
43
+ if uri.to_s =~ /^\//
44
+ return load_file(uri.path)
45
+ elsif not uri.path.empty?
46
+ local_file = File.join( File.dirname(@loaded_uri.path), uri.path)
47
+ return load_file( local_file )
48
+ end
49
+ end
50
+ end
51
+
52
+ dlg = Wx::MessageDialog.new(nil, "Can't load link",
53
+ "Unable to load the link #{uri}",
54
+ Wx::ICON_ERROR)
55
+ dlg.show_modal
56
+ end
57
+
58
+ def load_file(file)
59
+ @loaded_uri = URI.parse("file:////" + file)
60
+ super file
61
+ @loaded_uri
62
+ end
63
+
64
+ def set_page(html)
65
+ super html
66
+ @html_src = html
67
+ related_frame.addr_bar.value = @loaded_uri.to_s
68
+ end
69
+
70
+ def on_link_clicked(event)
71
+ href = event.link_info.href
72
+ return if href =~ /^#/
73
+ link_uri = URI.parse(href)
74
+ @loaded_uri = load_page_from_uri(link_uri)
75
+ end
76
+
77
+ def on_hover(event)
78
+ if link = event.cell.link
79
+ related_frame.set_status_text(link.href)
80
+ else
81
+ related_frame.status_text = ''
82
+ end
83
+ end
84
+ end
85
+
86
+ # The frame or self-contained window for this application
87
+ class HtmlFrame < Wx::Frame
88
+ attr_reader :html_win, :addr_bar
89
+
90
+ def initialize(title, pos, size, style = Wx::DEFAULT_FRAME_STYLE)
91
+ # A main application frame has no parent (nil)
92
+ # -1 means this frame will be supplied a default id
93
+ super(nil, -1, title, pos, size, style)
94
+ setup_menus
95
+ setup_panel
96
+ create_status_bar
97
+ self.status_text = "Welcome to wxRuby!"
98
+ end
99
+
100
+ def setup_panel
101
+ panel = Wx::Panel.new(self, -1)
102
+
103
+ sizer = Wx::BoxSizer.new(Wx::VERTICAL)
104
+ top_sizer = Wx::BoxSizer.new(Wx::HORIZONTAL)
105
+
106
+ @go_butt = Wx::StaticText.new(panel, -1, 'Location:')
107
+ top_sizer.add(@go_butt, 0, Wx::ALL, 4)
108
+ @addr_bar = Wx::TextCtrl.new(panel, -1, 'HOME', Wx::DEFAULT_POSITION,
109
+ Wx::DEFAULT_SIZE, Wx::TE_READONLY)
110
+ top_sizer.add(@addr_bar, 1, Wx::ALL, 4)
111
+ sizer.add(top_sizer, 0, Wx::EXPAND|Wx::TOP|Wx::BOTTOM, 4)
112
+
113
+ @html_win = MyHtmlWindow.new(panel, -1)
114
+ @html_win.set_related_frame(self, 'HTML Window: %s')
115
+
116
+ @html_win.set_page(DATA.read)
117
+ sizer.add(@html_win, 1, Wx::ALL|Wx::GROW, 4)
118
+ panel.set_sizer(sizer)
119
+ end
120
+
121
+ def setup_menus
122
+ menu_file = Wx::Menu.new()
123
+ menu_help = Wx::Menu.new()
124
+ # Using Wx::ID_ABOUT default id means the menu item will be placed
125
+ # in the correct platform-specific place
126
+ menu_help.append(Wx::ID_ABOUT, "&About...\tF1", "Show about dialog")
127
+ menu_file.append(Wx::ID_OPEN, "&Open File...\tCtrl-O", "Open File")
128
+ menu_file.append(Wx::ID_HIGHEST + 1, "&Open URL...\tCtrl-U", "Open URL")
129
+ menu_file.append(Wx::ID_PRINT, "&Print...\tCtrl-P", "Print")
130
+
131
+ menu_file.append(Wx::ID_PREVIEW, "&Preview...\tCtrl-Shift-P",
132
+ "Print Preview")
133
+ menu_file.append(Wx::ID_EXIT, "E&xit\tAlt-X", "Quit this program")
134
+
135
+ menu_bar = Wx::MenuBar.new()
136
+ menu_bar.append(menu_file, "&File")
137
+ menu_bar.append(menu_help, "&Help")
138
+ # Assign the menus to this frame
139
+ self.menu_bar = menu_bar
140
+ # handle menu events
141
+ evt_menu Wx::ID_OPEN, :on_open_file
142
+ evt_menu Wx::ID_HIGHEST + 1, :on_open_url
143
+ evt_menu Wx::ID_PRINT, :on_print
144
+ evt_menu Wx::ID_PREVIEW, :on_preview
145
+ evt_menu Wx::ID_EXIT, :on_quit
146
+ evt_menu Wx::ID_ABOUT, :on_about
147
+ end
148
+
149
+ # end the application
150
+ def on_quit
151
+ close
152
+ end
153
+
154
+ def on_open_file
155
+ f_dlg = Wx::FileDialog.new(self, "Open an HTML file", "", "",
156
+ "HTML files (*.html;*.htm)|*.html;*.htm)",
157
+ Wx::OPEN)
158
+ if not f_dlg.show_modal == Wx::ID_OK
159
+ return
160
+ end
161
+ html_file = f_dlg.get_path
162
+ if html_file.index("\\")
163
+ html_file = html_file.split("\\").join("/")
164
+ end
165
+ @html_win.load_file(html_file)
166
+ end
167
+
168
+ def on_open_url
169
+ url = Wx::get_text_from_user('Enter URL to open', 'Enter URL')
170
+ if not url.empty?
171
+ uri = URI.parse(url)
172
+ uri.path = '/' if uri.path.empty?
173
+ @html_win.load_page_from_uri(uri)
174
+ end
175
+ end
176
+
177
+ # show an 'About' dialog
178
+ def on_about
179
+ msg = sprintf("This is the About dialog of the HTML sample.\n" \
180
+ "Welcome to wxRuby, version %s", Wx::WXRUBY_VERSION)
181
+
182
+ # create a simple message dialog with OK button
183
+ about_dlg = Wx::MessageDialog.new( self, msg, 'About WxRuby HTML',
184
+ Wx::OK|Wx::ICON_INFORMATION )
185
+ about_dlg.show_modal()
186
+ about_dlg.destroy()
187
+ end
188
+
189
+ def on_preview
190
+ print = Wx::HtmlEasyPrinting.new('Print HTML', self)
191
+ print.preview_text(@html_win.html_src)
192
+ end
193
+
194
+ def on_print
195
+ print = Wx::HtmlEasyPrinting.new('Print HTML', self)
196
+ print.print_text(@html_win.html_src)
197
+ end
198
+
199
+ # utility function to find an icon relative to this ruby script
200
+ def local_icon_file(icon_name)
201
+ File.join( File.dirname(__FILE__), icon_name)
202
+ end
203
+ end
204
+
205
+ # Wx::App is the container class for any wxruby app - only a single
206
+ # instance is required
207
+ class HtmlApp < Wx::App
208
+ def on_init
209
+ frame = HtmlFrame.new("Minimal wxRuby App",
210
+ Wx::Point.new(50, 50),
211
+ Wx::Size.new(450, 340))
212
+ set_app_name('HtmlDemo')
213
+ # required
214
+ frame.show()
215
+ end
216
+ end
217
+
218
+ # Create an instance ...
219
+ app = HtmlApp.new
220
+ # ... and run the application
221
+ app.main_loop()
222
+
223
+ __END__
224
+ <html>
225
+ <head>
226
+ <title>WxRuby HTML Demo</title>
227
+ </head>
228
+
229
+ <body bgcolor="#ffffff">
230
+ <h1>The HtmlWindow widget</h1>
231
+ <p>This is a very simple demonstration of
232
+ <strong>Wx::HtmlWindow</strong>, a control for displaying hypertext. The
233
+ control understands most HTML tags, including links, tables, images,
234
+ lists and the venerable FONT tag. It does not know about CSS or
235
+ Javascript; it is not really intended for building a general-purpose
236
+ web browser.</p>
237
+ <h2>This demo</h2>
238
+ <p>In this demo you can open local files for viewing (by choosing the
239
+ File / Open). If you have an internet connection http:// links will be
240
+ downloaded as well. Its features are otherwise limited - for example,
241
+ this example doesn't know about HTML anchor targets, because it has
242
+ over-ridden default link handling to show how to subclass and
243
+ specialise HtmlWindow in Ruby.</a>
244
+ <h2>Html Easy Printing</h2>
245
+ <p>A useful feature included with WxRuby is a simple interface for
246
+ printing HTML. You can see this in action by choosing 'Print' or
247
+ 'Preview' from the File menu.</p>
248
+ <h3>Further information</h3>
249
+ <p>Here's a table with some links</p>
250
+ <table border="1">
251
+ <tr>
252
+ <td>WxRuby online documentation</td>
253
+ <td><a href="http://wxruby.rubyforge.org/doc/">http://wxruby.rubyforge.org/doc/</a></td>
254
+ </tr>
255
+ <tr>
256
+ <td>WxRuby Wiki</td>
257
+ <td><a href="http://wxruby.rubyforge.org/wiki/wiki.pl">http://wxruby.rubyforge.org/wiki/wiki.pl</a></td>
258
+ </tr>
259
+ </table>
260
+
261
+ </body>
262
+ </html>