wxruby 1.9.6-x86-mingw32

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (236) hide show
  1. data/LICENSE +53 -0
  2. data/README +297 -0
  3. data/lib/wx/accessors.rb +52 -0
  4. data/lib/wx/classes/acceleratortable.rb +28 -0
  5. data/lib/wx/classes/animation.rb +18 -0
  6. data/lib/wx/classes/app.rb +45 -0
  7. data/lib/wx/classes/artprovider.rb +31 -0
  8. data/lib/wx/classes/bitmap.rb +28 -0
  9. data/lib/wx/classes/busycursor.rb +12 -0
  10. data/lib/wx/classes/checklistbox.rb +45 -0
  11. data/lib/wx/classes/choice.rb +4 -0
  12. data/lib/wx/classes/clientdc.rb +13 -0
  13. data/lib/wx/classes/clipboard.rb +16 -0
  14. data/lib/wx/classes/colour.rb +47 -0
  15. data/lib/wx/classes/combobox.rb +4 -0
  16. data/lib/wx/classes/commandevent.rb +7 -0
  17. data/lib/wx/classes/controlwithitems.rb +10 -0
  18. data/lib/wx/classes/dc.rb +57 -0
  19. data/lib/wx/classes/event.rb +5 -0
  20. data/lib/wx/classes/evthandler.rb +921 -0
  21. data/lib/wx/classes/font.rb +118 -0
  22. data/lib/wx/classes/functions.rb +44 -0
  23. data/lib/wx/classes/gauge.rb +12 -0
  24. data/lib/wx/classes/grid.rb +138 -0
  25. data/lib/wx/classes/helpcontroller.rb +5 -0
  26. data/lib/wx/classes/htmlhelpcontroller.rb +5 -0
  27. data/lib/wx/classes/htmlwindow.rb +14 -0
  28. data/lib/wx/classes/icon.rb +21 -0
  29. data/lib/wx/classes/iconbundle.rb +3 -0
  30. data/lib/wx/classes/image.rb +31 -0
  31. data/lib/wx/classes/imagelist.rb +3 -0
  32. data/lib/wx/classes/listbox.rb +4 -0
  33. data/lib/wx/classes/listctrl.rb +21 -0
  34. data/lib/wx/classes/locale.rb +28 -0
  35. data/lib/wx/classes/mediactrl.rb +22 -0
  36. data/lib/wx/classes/menu.rb +62 -0
  37. data/lib/wx/classes/menuitem.rb +7 -0
  38. data/lib/wx/classes/object.rb +7 -0
  39. data/lib/wx/classes/paintdc.rb +12 -0
  40. data/lib/wx/classes/point.rb +48 -0
  41. data/lib/wx/classes/previewframe.rb +13 -0
  42. data/lib/wx/classes/rect.rb +10 -0
  43. data/lib/wx/classes/size.rb +49 -0
  44. data/lib/wx/classes/sound.rb +23 -0
  45. data/lib/wx/classes/styledtextctrl.rb +92 -0
  46. data/lib/wx/classes/textctrl.rb +14 -0
  47. data/lib/wx/classes/texturlevent.rb +6 -0
  48. data/lib/wx/classes/timer.rb +94 -0
  49. data/lib/wx/classes/toolbartool.rb +4 -0
  50. data/lib/wx/classes/treectrl.rb +44 -0
  51. data/lib/wx/classes/window.rb +82 -0
  52. data/lib/wx/classes/xmlresource.rb +37 -0
  53. data/lib/wx/keyword_ctors.rb +222 -0
  54. data/lib/wx/keyword_defs.rb +492 -0
  55. data/lib/wx/version.rb +3 -0
  56. data/lib/wx.rb +42 -0
  57. data/lib/wxruby2.so +0 -0
  58. data/samples/SAMPLES-LICENSE.TXT +18 -0
  59. data/samples/aui/aui.rb +1356 -0
  60. data/samples/bigdemo/About.rbw +39 -0
  61. data/samples/bigdemo/ColorPanel.rbw +23 -0
  62. data/samples/bigdemo/GridSimple.rbw +78 -0
  63. data/samples/bigdemo/MDIDemo.rbw +57 -0
  64. data/samples/bigdemo/PopupMenu.rbw +149 -0
  65. data/samples/bigdemo/ShapedWindow.rbw +131 -0
  66. data/samples/bigdemo/Sizers.rbw +543 -0
  67. data/samples/bigdemo/bigdemo.rb +823 -0
  68. data/samples/bigdemo/demoTemplate.rbw +33 -0
  69. data/samples/bigdemo/helpfile.htb +0 -0
  70. data/samples/bigdemo/icons/Test 015.jpg +0 -0
  71. data/samples/bigdemo/icons/Test 015.png +0 -0
  72. data/samples/bigdemo/icons/choice.bmp +0 -0
  73. data/samples/bigdemo/icons/choice.xpm +27 -0
  74. data/samples/bigdemo/icons/combo.bmp +0 -0
  75. data/samples/bigdemo/icons/combo.xpm +27 -0
  76. data/samples/bigdemo/icons/copy.xpm +25 -0
  77. data/samples/bigdemo/icons/cut.xpm +24 -0
  78. data/samples/bigdemo/icons/gauge.bmp +0 -0
  79. data/samples/bigdemo/icons/gauge.xpm +27 -0
  80. data/samples/bigdemo/icons/help.xpm +25 -0
  81. data/samples/bigdemo/icons/list.bmp +0 -0
  82. data/samples/bigdemo/icons/list.xpm +27 -0
  83. data/samples/bigdemo/icons/mondrian.ico +0 -0
  84. data/samples/bigdemo/icons/mondrian.xpm +44 -0
  85. data/samples/bigdemo/icons/new.xpm +24 -0
  86. data/samples/bigdemo/icons/ogl.ico +0 -0
  87. data/samples/bigdemo/icons/ogl.xpm +45 -0
  88. data/samples/bigdemo/icons/open.xpm +26 -0
  89. data/samples/bigdemo/icons/paste.bmp +0 -0
  90. data/samples/bigdemo/icons/paste.xpm +38 -0
  91. data/samples/bigdemo/icons/pointy.png +0 -0
  92. data/samples/bigdemo/icons/preview.xpm +26 -0
  93. data/samples/bigdemo/icons/print.xpm +26 -0
  94. data/samples/bigdemo/icons/radio.bmp +0 -0
  95. data/samples/bigdemo/icons/radio.xpm +27 -0
  96. data/samples/bigdemo/icons/robert.xpm +415 -0
  97. data/samples/bigdemo/icons/ruby.png +0 -0
  98. data/samples/bigdemo/icons/sashtest.ico +0 -0
  99. data/samples/bigdemo/icons/save.xpm +25 -0
  100. data/samples/bigdemo/icons/smiles.bmp +0 -0
  101. data/samples/bigdemo/icons/smiles.xpm +39 -0
  102. data/samples/bigdemo/icons/smiley.ico +0 -0
  103. data/samples/bigdemo/icons/smiley.xpm +42 -0
  104. data/samples/bigdemo/icons/stattext.xpm +24 -0
  105. data/samples/bigdemo/icons/test2.bmp +0 -0
  106. data/samples/bigdemo/icons/test2.png +0 -0
  107. data/samples/bigdemo/icons/test2.xpm +79 -0
  108. data/samples/bigdemo/icons/text.bmp +0 -0
  109. data/samples/bigdemo/icons/text.xpm +27 -0
  110. data/samples/bigdemo/icons/tog1.bmp +0 -0
  111. data/samples/bigdemo/icons/tog1.xpm +38 -0
  112. data/samples/bigdemo/icons/tog2.bmp +0 -0
  113. data/samples/bigdemo/icons/tog2.xpm +38 -0
  114. data/samples/bigdemo/icons/wxwin.ico +0 -0
  115. data/samples/bigdemo/icons/wxwin16x16.png +0 -0
  116. data/samples/bigdemo/icons/wxwin16x16.xpm +25 -0
  117. data/samples/bigdemo/icons/wxwin32x32.png +0 -0
  118. data/samples/bigdemo/icons/wxwin48x48.png +0 -0
  119. data/samples/bigdemo/run.rb +90 -0
  120. data/samples/bigdemo/tips.txt +7 -0
  121. data/samples/bigdemo/utils.rb +12 -0
  122. data/samples/bigdemo/wxArtProvider.rbw +281 -0
  123. data/samples/bigdemo/wxBitmapButton.rbw +65 -0
  124. data/samples/bigdemo/wxButton.rbw +64 -0
  125. data/samples/bigdemo/wxCalendarCtrl.rbw +60 -0
  126. data/samples/bigdemo/wxCheckBox.rbw +50 -0
  127. data/samples/bigdemo/wxCheckListBox.rbw +75 -0
  128. data/samples/bigdemo/wxChoice.rbw +47 -0
  129. data/samples/bigdemo/wxChoicebook.rbw +78 -0
  130. data/samples/bigdemo/wxColourDialog.rbw +31 -0
  131. data/samples/bigdemo/wxComboBox.rbw +77 -0
  132. data/samples/bigdemo/wxCursor.rbw +136 -0
  133. data/samples/bigdemo/wxDialog.rbw +74 -0
  134. data/samples/bigdemo/wxDirDialog.rbw +29 -0
  135. data/samples/bigdemo/wxDragImage.rbw +70 -0
  136. data/samples/bigdemo/wxFileDialog.rbw +37 -0
  137. data/samples/bigdemo/wxFileDialog_Save.rbw +35 -0
  138. data/samples/bigdemo/wxFindReplaceDialog.rbw +82 -0
  139. data/samples/bigdemo/wxFontDialog.rbw +173 -0
  140. data/samples/bigdemo/wxFrame.rbw +53 -0
  141. data/samples/bigdemo/wxGauge.rbw +71 -0
  142. data/samples/bigdemo/wxGenericDirCtrl.rbw +74 -0
  143. data/samples/bigdemo/wxGrid.rbw +66 -0
  144. data/samples/bigdemo/wxHtmlHelpController.rbw +52 -0
  145. data/samples/bigdemo/wxListBox.rbw +140 -0
  146. data/samples/bigdemo/wxListCtrl_virtual.rbw +107 -0
  147. data/samples/bigdemo/wxMDIWindows.rbw +50 -0
  148. data/samples/bigdemo/wxMenu.rbw +236 -0
  149. data/samples/bigdemo/wxMessageDialog.rbw +27 -0
  150. data/samples/bigdemo/wxMiniFrame.rbw +70 -0
  151. data/samples/bigdemo/wxMultipleChoiceDialog.rbw +32 -0
  152. data/samples/bigdemo/wxNotebook.rbw +136 -0
  153. data/samples/bigdemo/wxProgressDialog.rbw +43 -0
  154. data/samples/bigdemo/wxRadioBox.rbw +72 -0
  155. data/samples/bigdemo/wxRadioButton.rbw +125 -0
  156. data/samples/bigdemo/wxSashWindow.rbw +141 -0
  157. data/samples/bigdemo/wxScrolledMessageDialog.rbw +57 -0
  158. data/samples/bigdemo/wxScrolledWindow.rbw +199 -0
  159. data/samples/bigdemo/wxSingleChoiceDialog.rbw +33 -0
  160. data/samples/bigdemo/wxSlider.rbw +42 -0
  161. data/samples/bigdemo/wxSpinButton.rbw +50 -0
  162. data/samples/bigdemo/wxSpinCtrl.rbw +51 -0
  163. data/samples/bigdemo/wxSplitterWindow.rbw +63 -0
  164. data/samples/bigdemo/wxStaticBitmap.rbw +51 -0
  165. data/samples/bigdemo/wxStaticText.rbw +55 -0
  166. data/samples/bigdemo/wxStatusBar.rbw +126 -0
  167. data/samples/bigdemo/wxTextCtrl.rbw +149 -0
  168. data/samples/bigdemo/wxTextEntryDialog.rbw +31 -0
  169. data/samples/bigdemo/wxToggleButton.rbw +49 -0
  170. data/samples/bigdemo/wxToolBar.rbw +131 -0
  171. data/samples/bigdemo/wxTreeCtrl.rbw +190 -0
  172. data/samples/calendar/calendar.rb +271 -0
  173. data/samples/caret/caret.rb +282 -0
  174. data/samples/caret/mondrian.xpm +44 -0
  175. data/samples/controls/controls.rb +1136 -0
  176. data/samples/controls/get_item_sample.rb +87 -0
  177. data/samples/controls/icons/choice.xpm +27 -0
  178. data/samples/controls/icons/combo.xpm +27 -0
  179. data/samples/controls/icons/gauge.xpm +27 -0
  180. data/samples/controls/icons/list.xpm +27 -0
  181. data/samples/controls/icons/radio.xpm +27 -0
  182. data/samples/controls/icons/stattext.xpm +24 -0
  183. data/samples/controls/icons/text.xpm +27 -0
  184. data/samples/controls/mondrian.ico +0 -0
  185. data/samples/controls/mondrian.xpm +44 -0
  186. data/samples/controls/test2.bmp +0 -0
  187. data/samples/dialogs/dialogs.rb +723 -0
  188. data/samples/dialogs/tips.txt +18 -0
  189. data/samples/drawing/graphics_drawing.rb +235 -0
  190. data/samples/drawing/images.rb +37 -0
  191. data/samples/drawing/paperclip.png +0 -0
  192. data/samples/etc/activation.rb +102 -0
  193. data/samples/etc/choice.rb +67 -0
  194. data/samples/etc/miniframe.rb +79 -0
  195. data/samples/etc/sash.rb +130 -0
  196. data/samples/etc/scrollwin.rb +110 -0
  197. data/samples/etc/system_settings.rb +252 -0
  198. data/samples/etc/threaded.rb +72 -0
  199. data/samples/etc/wizard.rb +74 -0
  200. data/samples/event/event.rb +182 -0
  201. data/samples/grid/grid.rb +198 -0
  202. data/samples/grid/gridtablebase.rb +134 -0
  203. data/samples/html/html.rb +262 -0
  204. data/samples/listbook/listbook.rb +174 -0
  205. data/samples/listbook/listbook.xrc +370 -0
  206. data/samples/mdi/mdi.rb +82 -0
  207. data/samples/media/mediactrl.rb +167 -0
  208. data/samples/minimal/minimal.rb +77 -0
  209. data/samples/minimal/mondrian.ico +0 -0
  210. data/samples/minimal/mondrian.png +0 -0
  211. data/samples/minimal/nothing.rb +16 -0
  212. data/samples/opengl/cube.rb +117 -0
  213. data/samples/printing/mondrian.ico +0 -0
  214. data/samples/printing/mondrian.xpm +44 -0
  215. data/samples/printing/printing.rb +310 -0
  216. data/samples/sockets/SocketPackets.rb +27 -0
  217. data/samples/sockets/res/message-new.png +0 -0
  218. data/samples/sockets/res/user.png +0 -0
  219. data/samples/sockets/wxClient.rb +395 -0
  220. data/samples/sockets/wxServer.rb +422 -0
  221. data/samples/sockets/wxSocketGUI.rb +97 -0
  222. data/samples/text/mondrian.ico +0 -0
  223. data/samples/text/mondrian.xpm +44 -0
  224. data/samples/text/scintilla.rb +169 -0
  225. data/samples/text/textctrl.rb +113 -0
  226. data/samples/text/unicode.rb +242 -0
  227. data/samples/text/utf8.txt +15 -0
  228. data/samples/treectrl/icon1.xpm +79 -0
  229. data/samples/treectrl/icon2.xpm +53 -0
  230. data/samples/treectrl/icon3.xpm +79 -0
  231. data/samples/treectrl/icon4.xpm +43 -0
  232. data/samples/treectrl/icon5.xpm +79 -0
  233. data/samples/treectrl/treectrl.rb +1174 -0
  234. data/samples/xrc/samples.xrc +46 -0
  235. data/samples/xrc/xrc_sample.rb +96 -0
  236. metadata +313 -0
@@ -0,0 +1,310 @@
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 MyCanvas < Wx::ScrolledWindow
11
+ #attr_accessor :frame
12
+
13
+ def initialize(parent,pos,size,style = Wx::RETAINED)
14
+ super(parent,-1,pos,size,style)
15
+ @frame = parent
16
+ set_background_colour(Wx::WHITE)
17
+ evt_mouse_events() {|e| on_event(e)}
18
+ end
19
+
20
+ def on_draw(dc)
21
+ @frame.draw(dc)
22
+ end
23
+
24
+ def on_event(event)
25
+ end
26
+ end
27
+
28
+ class MyPrintout < Wx::Printout
29
+ def initialize(title = "My printout")
30
+ super(title)
31
+ end
32
+
33
+ def on_print_page(page)
34
+ dc = get_dc
35
+ if dc
36
+ if page == 1
37
+ draw_page_one(dc)
38
+ elsif (page == 2)
39
+ draw_page_two(dc)
40
+ end
41
+ dc.set_device_origin(0, 0)
42
+ dc.set_user_scale(1.0, 1.0)
43
+
44
+ buf = "PAGE #{page}"
45
+ dc.draw_text(buf, 10, 10)
46
+
47
+ return true
48
+ else
49
+ return false
50
+ end
51
+ end
52
+
53
+ def on_begin_document(start_page,end_page)
54
+ go_ahead = super(start_page, end_page)
55
+ if (!go_ahead)
56
+ return false
57
+ end
58
+ return true
59
+ end
60
+
61
+ def has_page(page)
62
+ return (page == 1 || page == 2)
63
+ end
64
+
65
+ def get_page_info
66
+ min_page = 1
67
+ max_page = 2
68
+ sel_page_from = 1
69
+ sel_page_to = 2
70
+ [min_page,max_page,sel_page_from,sel_page_to]
71
+ end
72
+
73
+ def draw_page_one(dc)
74
+ # You might use THIS code if you were scaling
75
+ # graphics of known size to fit on the page.
76
+
77
+ # We know the graphic is 200x200. If we didn't know this,
78
+ # we'd need to calculate it.
79
+ max_x = 200
80
+ max_y = 200
81
+
82
+ # Let's have at least 50 device units margin
83
+ margin_x = 50
84
+ margin_y = 50
85
+
86
+ # Add the margin to the graphic size
87
+ max_x += (2*margin_x)
88
+ max_y += (2*margin_y)
89
+
90
+ # Get the size of the DC in pixels
91
+ size = dc.get_size
92
+ w = size.get_width
93
+ h = size.get_height
94
+
95
+ # Calculate a suitable scaling factor
96
+ scale_x=(w/max_x)
97
+ scale_y=(h/max_y)
98
+
99
+ # Use x or y scaling factor, whichever fits on the DC
100
+ #actualScale = Wx::min(scaleX,scaleY)
101
+ if scale_x < scale_y
102
+ actual_scale = scale_x
103
+ else
104
+ actual_scale = scale_y
105
+ end
106
+
107
+ # Calculate the position on the DC for centring the graphic
108
+ pos_x = ((w - (200*actual_scale))/2.0)
109
+ pos_y = ((h - (200*actual_scale))/2.0)
110
+
111
+ # Set the scale and origin
112
+ dc.set_user_scale(actual_scale, actual_scale)
113
+ dc.set_device_origin( pos_x.to_i, pos_y.to_i )
114
+
115
+ Wx::get_app.frame.draw(dc)
116
+ end
117
+
118
+ def draw_page_two(dc)
119
+ # You might use THIS code to set the printer DC to ROUGHLY reflect
120
+ # the screen text size. This page also draws lines of actual length
121
+ # 5cm on the page.
122
+
123
+ # Get the logical pixels per inch of screen and printer
124
+ ppi_screen_x, ppi_screen_y = get_ppi_screen
125
+ ppi_printer_x, ppi_printer_y = get_ppi_printer
126
+
127
+ # This scales the DC so that the printout roughly represents the
128
+ # the screen scaling. The text point size _should_ be the right size
129
+ # but in fact is too small for some reason. This is a detail that will
130
+ # need to be addressed at some point but can be fudged for the
131
+ # moment.
132
+ scale = ( ppi_printer_x.to_f / ppi_screen_x.to_f )
133
+
134
+ # Now we have to check in case our real page size is reduced
135
+ # (e.g. because we're drawing to a print preview memory DC)
136
+ page_width, page_height = get_page_size_pixels
137
+ size = dc.get_size
138
+ w = size.get_width
139
+ h = size.get_height
140
+
141
+ # If printer pageWidth == current DC width, then this doesn't
142
+ # change. But w might be the preview bitmap width, so scale down.
143
+ overall_scale = scale * (w/page_width)
144
+ dc.set_user_scale(overall_scale, overall_scale)
145
+
146
+ # Calculate conversion factor for converting millimetres into
147
+ # logical units.
148
+ # There are approx. 25.4 mm to the inch. There are ppi
149
+ # device units to the inch. Therefore 1 mm corresponds to
150
+ # ppi/25.4 device units. We also divide by the
151
+ # screen-to-printer scaling factor, because we need to
152
+ # unscale to pass logical units to DrawLine.
153
+
154
+ # Draw 50 mm by 50 mm L shape
155
+ log_units_factor = (ppi_printer_x/(scale*25.4))
156
+ log_units = (50*log_units_factor)
157
+ dc.set_pen(Wx::BLACK_PEN)
158
+ dc.draw_line(50, 250, (50.0 + log_units).to_i, 250)
159
+ dc.draw_line(50, 250, 50, (250.0 + log_units).to_i)
160
+
161
+ dc.set_background_mode(Wx::TRANSPARENT)
162
+ dc.set_brush(Wx::TRANSPARENT_BRUSH)
163
+
164
+ # GetTextExtent demo:
165
+ words = ["This ", "is ", "GetTextExtent ", "testing ", "string. ", "Enjoy ", "it!"]
166
+ w, h = 0,0
167
+ x = 200
168
+ y= 250
169
+ fnt = Wx::Font.new(15, Wx::SWISS, Wx::NORMAL, Wx::NORMAL)
170
+
171
+ dc.set_font(fnt)
172
+
173
+ words.each do |word|
174
+ w,h = dc.get_text_extent(word)
175
+ dc.draw_rectangle(x, y, w.to_i, h.to_i)
176
+ w,h = dc.get_text_extent(word)
177
+ dc.draw_text(word, x, y)
178
+ x += w
179
+ end
180
+
181
+ dc.set_font(Wx::get_app.test_font)
182
+
183
+ dc.draw_text("Some test text", 200, 300 )
184
+
185
+ left_margin = 20
186
+ right_margin = 20
187
+ top_margin = 20
188
+ bottom_margin = 20
189
+
190
+ page_width_mm, page_height_mm = get_page_size_mm
191
+
192
+ left_margin_logical = (log_units_factor*left_margin).to_i
193
+ top_margin_logical = (log_units_factor*top_margin).to_i
194
+ bottom_margin_logical = (log_units_factor*(page_height_mm - bottom_margin)).to_i
195
+ right_margin_logical = (log_units_factor*(page_width_mm - right_margin)).to_i
196
+
197
+ dc.set_pen(Wx::RED_PEN)
198
+ dc.draw_line( left_margin_logical, top_margin_logical,
199
+ right_margin_logical, top_margin_logical)
200
+ dc.draw_line( left_margin_logical, bottom_margin_logical,
201
+ right_margin_logical, bottom_margin_logical)
202
+
203
+ write_page_header(self, dc, "A header", log_units_factor)
204
+ end
205
+
206
+ # Writes a header on a page. Margin units are in millimetres.
207
+ def write_page_header(printout, dc, text, mm_to_logical)
208
+ page_width_mm, page_height_mm = printout.get_page_size_mm
209
+
210
+ left_margin = 10
211
+ top_margin = 10
212
+ right_margin = 10
213
+
214
+ left_margin_logical = (mm_to_logical*left_margin).to_i
215
+ top_margin_logical = (mm_to_logical*top_margin).to_i
216
+ right_margin_logical = (mm_to_logical*(page_width_mm - right_margin)).to_i
217
+
218
+ x_extent, y_extent= dc.get_text_extent(text)
219
+ x_pos = (((((page_width_mm - left_margin - right_margin)/2.0)+left_margin)*mm_to_logical) - (x_extent/2.0))
220
+ dc.draw_text(text, x_pos.to_i, top_margin_logical)
221
+
222
+ dc.set_pen(Wx::BLACK_PEN)
223
+ dc.draw_line( left_margin_logical, (top_margin_logical + y_extent).to_i,
224
+ right_margin_logical, (top_margin_logical + y_extent).to_i )
225
+
226
+ return true
227
+ end
228
+ end
229
+
230
+ class MyApp < Wx::App
231
+ attr_accessor :frame,:test_font,:print_data,:page_setup_data
232
+
233
+ def on_init
234
+ @test_font = Wx::Font.new(10, Wx::SWISS, Wx::NORMAL, Wx::NORMAL)
235
+
236
+ # Create the main frame window
237
+ @frame = MyFrame.new(nil, "wxRuby Printing Demo", Wx::Point.new(0, 0), Wx::Size.new(400, 400))
238
+
239
+ # Give it a status line
240
+ @frame.create_status_bar(2)
241
+
242
+
243
+ # Load icon and bitmap
244
+ if Wx::PLATFORM == "WXMSW"
245
+ icon_file = File.join(File.dirname(__FILE__), 'mondrian.ico')
246
+ @frame.set_icon( Wx::Icon.new(icon_file, Wx::BITMAP_TYPE_ICO) )
247
+ else
248
+ icon_file = File.join(File.dirname(__FILE__), 'mondrian.xpm')
249
+ @frame.set_icon( Wx::Icon.new(icon_file, Wx::BITMAP_TYPE_XPM) )
250
+ end
251
+
252
+ # Make a menubar
253
+ file_menu = Wx::Menu.new
254
+
255
+ file_menu.append(WXPRINT_PRINT, "&Print...","Print")
256
+ file_menu.append(WXPRINT_PAGE_SETUP, "Page Set&up...","Page setup")
257
+ file_menu.append(WXPRINT_PREVIEW, "Print Pre&view","Preview")
258
+
259
+ =begin
260
+ # Accelerators
261
+ wxAcceleratorEntry entries[1];
262
+ entries[0].Set(wxACCEL_CTRL, (int) 'V', WXPRINT_PREVIEW);
263
+ wxAcceleratorTable accel(1, entries);
264
+ frame->SetAcceleratorTable(accel);
265
+ =end
266
+
267
+ file_menu.append_separator()
268
+ file_menu.append(WXPRINT_ANGLEUP, "Angle up\tAlt-U","Raise rotated text angle")
269
+ file_menu.append(WXPRINT_ANGLEDOWN, "Angle down\tAlt-D","Lower rotated text angle")
270
+ file_menu.append_separator()
271
+ file_menu.append(WXPRINT_QUIT, "E&xit","Exit program")
272
+
273
+ help_menu = Wx::Menu.new
274
+ help_menu.append(WXPRINT_ABOUT, "&About","About this demo")
275
+
276
+ menu_bar = Wx::MenuBar.new
277
+
278
+ menu_bar.append(file_menu, "&File")
279
+ menu_bar.append(help_menu, "&Help")
280
+
281
+ # Associate the menu bar with the frame
282
+ @frame.set_menu_bar(menu_bar)
283
+
284
+ canvas = MyCanvas.new(@frame, Wx::Point.new(0, 0), Wx::Size.new(100, 100), Wx::RETAINED|Wx::HSCROLL|Wx::VSCROLL)
285
+
286
+ # Give it scrollbars: the virtual canvas is 20 * 50 = 1000 pixels in each direction
287
+ canvas.set_scrollbars(20, 20, 50, 50)
288
+
289
+ @frame.canvas = canvas
290
+
291
+ @frame.centre(Wx::BOTH)
292
+ @frame.show()
293
+
294
+ @frame.set_status_text("Printing demo")
295
+
296
+ set_top_window(@frame)
297
+
298
+ @print_data = Wx::PrintData.new
299
+ @page_setup_data = Wx::PageSetupDialogData.new
300
+
301
+ return true
302
+ end
303
+
304
+ def on_exit
305
+ return true
306
+ end
307
+ end
308
+
309
+
310
+ MyApp.new.main_loop()
@@ -0,0 +1,27 @@
1
+ # wxRuby2 Sample Code. Copyright (c) 2007-???? Mario J. Steele
2
+ # Freely reusable code: see SAMPLES-LICENSE.TXT for details
3
+
4
+ class Socket
5
+ # Socket#recv_packet()
6
+ #
7
+ # This method retrives 1kb of data from the socket. It uses
8
+ # IO#readpartial due to the fact, that IO#read() uses buffered IO,
9
+ # which can cause errors. Where as the IO#readpartial() will read up
10
+ # to the maximum of 1024 bytes from the socket, and return what it
11
+ # retrives.
12
+ def recv_packet()
13
+ self.readpartial(1024)
14
+ end
15
+
16
+ # Socket#send_packet()
17
+ #
18
+ # This method will send the packet, and ensure that a LF (0x0A) is at
19
+ # the end of the data to be sent, as this is used as the determination
20
+ # of the end of a packet.
21
+ def send_packet(msg)
22
+ if !msg.index("\n")
23
+ msg += "\n"
24
+ end
25
+ self.write(msg)
26
+ end
27
+ end
Binary file
Binary file