wxruby3 0.9.0.pre.beta.10 → 0.9.0.pre.beta.13

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 (126) hide show
  1. checksums.yaml +4 -4
  2. data/INSTALL.md +85 -0
  3. data/README.md +2 -0
  4. data/assets/logo.png +0 -0
  5. data/assets/logo.svg +170 -0
  6. data/assets/logo.xcf +0 -0
  7. data/ext/wxruby3/include/wxruby-ScaledDC.h +549 -0
  8. data/ext/wxruby3/swig/wx.i +1 -1
  9. data/lib/wx/core/array_ext.rb +26 -0
  10. data/lib/wx/core/art_locator.rb +92 -0
  11. data/lib/wx/core/artprovider.rb +1 -1
  12. data/lib/wx/core/bitmap.rb +90 -53
  13. data/lib/wx/core/cursor.rb +12 -0
  14. data/lib/wx/core/data_object.rb +74 -6
  15. data/lib/wx/core/dataformat.rb +3 -1
  16. data/lib/wx/core/dc.rb +76 -52
  17. data/lib/wx/core/enum.rb +4 -0
  18. data/lib/wx/core/event.rb +38 -5
  19. data/lib/wx/core/evthandler.rb +64 -23
  20. data/lib/wx/core/icon.rb +50 -35
  21. data/lib/wx/core/id_helper.rb +32 -0
  22. data/lib/wx/core/image.rb +63 -53
  23. data/lib/wx/core/point.rb +35 -10
  24. data/lib/wx/core/real_point.rb +35 -10
  25. data/lib/wx/core/rect.rb +44 -9
  26. data/lib/wx/core/region_iterator.rb +37 -0
  27. data/lib/wx/core/size.rb +32 -5
  28. data/lib/wx/core/window.rb +8 -31
  29. data/lib/wx/doc/array_ext.rb +27 -0
  30. data/lib/wx/doc/art_locator.rb +57 -0
  31. data/lib/wx/doc/bitmap.rb +27 -0
  32. data/lib/wx/doc/clipboard.rb +12 -0
  33. data/lib/wx/doc/const.rb +77 -0
  34. data/lib/wx/doc/cursor.rb +16 -0
  35. data/lib/wx/doc/data_object.rb +103 -0
  36. data/lib/wx/doc/dc.rb +63 -46
  37. data/lib/wx/doc/event.rb +24 -0
  38. data/lib/wx/doc/events.rb +14 -0
  39. data/lib/wx/doc/evthandler.rb +24 -3
  40. data/lib/wx/doc/extra/00_starting.md +1 -1
  41. data/lib/wx/doc/extra/06_geometry.md +10 -4
  42. data/lib/wx/doc/extra/10_art.md +105 -0
  43. data/lib/wx/doc/gc_dc.rb +21 -0
  44. data/lib/wx/doc/gdi_common.rb +155 -6
  45. data/lib/wx/doc/graphics_context.rb +42 -0
  46. data/lib/wx/doc/icon.rb +18 -0
  47. data/lib/wx/doc/id_helper.rb +25 -0
  48. data/lib/wx/doc/image.rb +33 -0
  49. data/lib/wx/doc/region_iterator.rb +31 -0
  50. data/lib/wx/doc/scaled_dc.rb +17 -0
  51. data/lib/wx/doc/window.rb +18 -0
  52. data/lib/wx/global_const.rb +4 -3
  53. data/lib/wx/version.rb +1 -1
  54. data/lib/wx/wxruby/cmd/sampler.rb +3 -21
  55. data/rakelib/lib/config.rb +4 -4
  56. data/rakelib/lib/core/package.rb +6 -6
  57. data/rakelib/lib/core/spec.rb +2 -0
  58. data/rakelib/lib/director/art_provider.rb +2 -2
  59. data/rakelib/lib/director/busy_info.rb +9 -7
  60. data/rakelib/lib/director/clipboard.rb +1 -1
  61. data/rakelib/lib/director/colour_picker_ctrl.rb +1 -0
  62. data/rakelib/lib/director/data_object.rb +162 -0
  63. data/rakelib/lib/director/data_object_simple_base.rb +123 -0
  64. data/rakelib/lib/director/derived_dc.rb +134 -2
  65. data/rakelib/lib/director/dir_picker_ctrl.rb +1 -0
  66. data/rakelib/lib/director/event.rb +73 -8
  67. data/rakelib/lib/director/events.rb +19 -1
  68. data/rakelib/lib/director/file_picker_ctrl.rb +1 -0
  69. data/rakelib/lib/director/font_picker_ctrl.rb +1 -0
  70. data/rakelib/lib/director/gdicommon.rb +1 -3
  71. data/rakelib/lib/director/graphics_context.rb +89 -0
  72. data/rakelib/lib/director/help_controller.rb +2 -2
  73. data/rakelib/lib/director/html_data_object.rb +37 -0
  74. data/rakelib/lib/director/image.rb +55 -0
  75. data/rakelib/lib/director/region_iterator.rb +48 -0
  76. data/rakelib/lib/director/richtext_buffer.rb +1 -1
  77. data/rakelib/lib/director/richtext_buffer_data_object.rb +45 -0
  78. data/rakelib/lib/director/scroll_bar.rb +39 -0
  79. data/rakelib/lib/director/slider.rb +39 -0
  80. data/rakelib/lib/director/window.rb +36 -5
  81. data/rakelib/lib/director/window_disabler.rb +0 -7
  82. data/rakelib/lib/extractor/class.rb +1 -1
  83. data/rakelib/lib/extractor/function.rb +1 -1
  84. data/rakelib/lib/generate/doc.rb +26 -6
  85. data/rakelib/lib/specs/interfaces.rb +8 -1
  86. data/rakelib/lib/typemap/common.rb +1 -1
  87. data/rakelib/lib/typemap/data_object_data.rb +13 -4
  88. data/rakelib/lib/util/string.rb +29 -8
  89. data/samples/art/wxruby-128x128.png +0 -0
  90. data/samples/art/wxruby-256x256.png +0 -0
  91. data/samples/art/wxruby-64x64.png +0 -0
  92. data/samples/art/wxruby.ico +0 -0
  93. data/samples/art/wxruby.png +0 -0
  94. data/samples/drawing/graphics_drawing.rb +1 -2
  95. data/samples/propgrid/propgrid.rb +65 -65
  96. data/samples/sample.xpm +246 -470
  97. data/samples/treectrl/treectrl.rb +1 -1
  98. data/tests/art/my_art/sample.xpm +251 -0
  99. data/tests/art/sample3.xpm +251 -0
  100. data/tests/art/test_art/bitmap/sample.xpm +251 -0
  101. data/tests/art/test_art/bitmap/wxruby.bmp +0 -0
  102. data/tests/art/test_art/bitmap/wxruby.png +0 -0
  103. data/tests/art/test_art/bitmap/wxruby.xpm +251 -0
  104. data/tests/art/test_art/cursor/wxruby.bmp +0 -0
  105. data/tests/art/test_art/icon/sample.xpm +251 -0
  106. data/tests/art/test_art/icon/wxruby.ico +0 -0
  107. data/tests/art/test_art/icon/wxruby.png +0 -0
  108. data/tests/art/test_art/image/sample.xpm +251 -0
  109. data/tests/art/test_art/image/wxruby.jpg +0 -0
  110. data/tests/art/test_art/image/wxruby.png +0 -0
  111. data/tests/art/test_art/sample2.xpm +251 -0
  112. data/tests/lib/wxapp_runner.rb +64 -0
  113. data/tests/test_art.rb +91 -0
  114. data/tests/test_basic.rb +0 -5
  115. data/tests/test_clipboard.rb +149 -17
  116. data/tests/test_dc.rb +70 -0
  117. data/tests/test_dialog.rb +2 -13
  118. data/tests/test_event_handling.rb +2 -13
  119. data/tests/test_events.rb +14 -6
  120. data/tests/test_geometry.rb +67 -17
  121. data/tests/test_intl.rb +2 -15
  122. data/tests/test_item_data.rb +2 -15
  123. data/tests/test_variant.rb +1 -15
  124. data/tests/testapp.rb +0 -5
  125. data/tests/testapp_noframe.rb +0 -5
  126. metadata +56 -5
@@ -0,0 +1,549 @@
1
+ /*
2
+ * WxRuby3 wxScaledDC class
3
+ * Derived from wxSFScaledDC class in wxShapeFramework library.
4
+ * Copyright (c) M.J.N. Corino, The Netherlands
5
+ */
6
+ /***************************************************************
7
+ * Name: ScaledDC.h
8
+ * Purpose: Defines scaled DC class
9
+ * Author: Michal Bližňák (michal.bliznak@tiscali.cz)
10
+ * Created: 2008-11-7
11
+ * Copyright: Michal Bližňák
12
+ * License: wxWidgets license (www.wxwidgets.org)
13
+ * Notes:
14
+ **************************************************************/
15
+
16
+ #ifndef _WXRUBY_SCALEDDC_H
17
+ #define _WXRUBY_SCALEDDC_H
18
+
19
+ #include <wx/graphics.h>
20
+ #include <wx/dc.h>
21
+ #include <math.h>
22
+ #include <wx/dcclient.h>
23
+
24
+ class wxDCImplWrapper : public wxDCImpl
25
+ {
26
+ public:
27
+ friend class wxScaledDC;
28
+
29
+ wxDCImplWrapper( wxDCImpl *orig, double scale ) : wxDCImpl( orig->GetOwner() )
30
+ {
31
+ m_pOrig = orig;
32
+ m_nScale = scale;
33
+ }
34
+ virtual ~wxDCImplWrapper()
35
+ {
36
+ }
37
+
38
+ wxDC *GetOwner() const { return m_pOrig->GetOwner(); }
39
+
40
+ wxWindow* GetWindow() const { return m_pOrig->GetWindow(); }
41
+
42
+ virtual bool IsOk() const { return m_pOrig->IsOk(); }
43
+
44
+ // query capabilities
45
+
46
+ virtual bool CanDrawBitmap() const { return m_pOrig->CanDrawBitmap(); }
47
+ virtual bool CanGetTextExtent() const { return m_pOrig->CanGetTextExtent(); }
48
+
49
+ // get Cairo context
50
+ virtual void* GetCairoContext() const
51
+ {
52
+ return m_pOrig->GetCairoContext();
53
+ }
54
+
55
+ // query dimension, colour deps, resolution
56
+
57
+ virtual void DoGetSize(int *width, int *height) const { m_pOrig->DoGetSize( width, height); }
58
+ void GetSize(int *width, int *height) const
59
+ {
60
+ DoGetSize(width, height);
61
+ return ;
62
+ }
63
+
64
+ wxSize GetSize() const
65
+ {
66
+ int w, h;
67
+ DoGetSize(&w, &h);
68
+ return wxSize(w, h);
69
+ }
70
+
71
+ virtual void DoGetSizeMM(int* width, int* height) const { m_pOrig->DoGetSizeMM( width, height); }
72
+
73
+ virtual int GetDepth() const { return m_pOrig->GetDepth(); }
74
+ virtual wxSize GetPPI() const { return m_pOrig->GetPPI(); }
75
+
76
+ // Right-To-Left (RTL) modes
77
+
78
+ virtual void SetLayoutDirection(wxLayoutDirection dir) { m_pOrig->SetLayoutDirection( dir ); }
79
+ virtual wxLayoutDirection GetLayoutDirection() const { return m_pOrig->GetLayoutDirection(); }
80
+
81
+ // page and document
82
+
83
+ virtual bool StartDoc(const wxString& message) { return m_pOrig->StartDoc( message ); }
84
+ virtual void EndDoc() { return m_pOrig->EndDoc(); }
85
+
86
+ virtual void StartPage() { m_pOrig->StartPage(); }
87
+ virtual void EndPage() { m_pOrig->EndPage(); }
88
+
89
+ // flushing the content of this dc immediately eg onto screen
90
+ virtual void Flush() { m_pOrig->Flush(); }
91
+
92
+ // bounding box
93
+
94
+ virtual void CalcBoundingBox(wxCoord x, wxCoord y) { m_pOrig->CalcBoundingBox( x, y); }
95
+
96
+ wxCoord MinX() const { return m_pOrig->MinX(); }
97
+ wxCoord MaxX() const { return m_pOrig->MaxX(); }
98
+ wxCoord MinY() const { return m_pOrig->MinY(); }
99
+ wxCoord MaxY() const { return m_pOrig->MaxY(); }
100
+
101
+ // setters and getters
102
+
103
+ virtual void SetFont(const wxFont& font) { m_pOrig->SetFont( font ); }
104
+ virtual const wxFont& GetFont() const { return m_pOrig->GetFont(); }
105
+
106
+ virtual void SetPen(const wxPen& pen) { m_pOrig->SetPen( pen ); }
107
+ virtual const wxPen& GetPen() const { return m_pOrig->GetPen(); }
108
+
109
+ virtual void SetBrush(const wxBrush& brush) { m_pOrig->SetBrush( brush ); }
110
+ virtual const wxBrush& GetBrush() const { return m_pOrig->GetBrush(); }
111
+
112
+ virtual void SetBackground(const wxBrush& brush) { m_pOrig->SetBackground( brush ); }
113
+ virtual const wxBrush& GetBackground() const { return m_pOrig->GetBackground(); }
114
+
115
+ virtual void SetBackgroundMode(int mode) { m_pOrig->SetBackgroundMode( mode ); }
116
+ virtual int GetBackgroundMode() const { return m_pOrig->GetBackgroundMode(); }
117
+
118
+ virtual void SetTextForeground(const wxColour& colour) { m_pOrig->SetTextForeground( colour ); }
119
+ virtual const wxColour& GetTextForeground() const { return m_pOrig->GetTextForeground(); }
120
+
121
+ virtual void SetTextBackground(const wxColour& colour) { m_pOrig->SetTextBackground( colour ); }
122
+ virtual const wxColour& GetTextBackground() const { return m_pOrig->GetTextBackground(); }
123
+
124
+ #if wxUSE_PALETTE
125
+ virtual void SetPalette(const wxPalette& palette) { m_pOrig->SetPalette( palette ); }
126
+ #endif // wxUSE_PALETTE
127
+
128
+ // inherit the DC attributes (font and colours) from the given window
129
+ //
130
+ // this is called automatically when a window, client or paint DC is
131
+ // created
132
+ virtual void InheritAttributes(wxWindow *win) { m_pOrig->InheritAttributes( win ); }
133
+
134
+
135
+ // logical functions
136
+
137
+ virtual void SetLogicalFunction(wxRasterOperationMode function) { m_pOrig->SetLogicalFunction( function ); }
138
+ virtual wxRasterOperationMode GetLogicalFunction() const { return m_pOrig->GetLogicalFunction(); }
139
+
140
+ // text measurement
141
+
142
+ virtual wxCoord GetCharHeight() const { return m_pOrig->GetCharHeight(); }
143
+ virtual wxCoord GetCharWidth() const { return m_pOrig->GetCharWidth(); }
144
+ virtual void DoGetTextExtent(const wxString& string,
145
+ wxCoord *x, wxCoord *y,
146
+ wxCoord *descent = NULL,
147
+ wxCoord *externalLeading = NULL,
148
+ const wxFont *theFont = NULL) const { m_pOrig->DoGetTextExtent( string, x, y, descent, externalLeading, theFont ); }
149
+ virtual void GetMultiLineTextExtent(const wxString& string,
150
+ wxCoord *width,
151
+ wxCoord *height,
152
+ wxCoord *heightLine = NULL,
153
+ const wxFont *font = NULL) const { m_pOrig->GetMultiLineTextExtent( string, width, height, heightLine, font ); }
154
+ virtual bool DoGetPartialTextExtents(const wxString& text, wxArrayInt& widths) const { return m_pOrig->DoGetPartialTextExtents( text, widths); }
155
+
156
+ // clearing
157
+
158
+ virtual void Clear() { m_pOrig->Clear(); }
159
+
160
+ // clipping
161
+
162
+ virtual void DoSetClippingRegion(wxCoord x, wxCoord y,
163
+ wxCoord width, wxCoord height) { m_pOrig->DoSetClippingRegion( x, y, width, height ); }
164
+
165
+ // NB: this function works with device coordinates, not the logical ones!
166
+ virtual void DoSetDeviceClippingRegion(const wxRegion& region) { m_pOrig->DoSetDeviceClippingRegion( region ); }
167
+
168
+ virtual bool DoGetClippingRect(wxRect& rect) const { return m_pOrig->DoGetClippingRect(rect); }
169
+
170
+ virtual void DestroyClippingRegion() { m_pOrig->DestroyClippingRegion(); }
171
+
172
+
173
+ // coordinates conversions and transforms
174
+
175
+ virtual wxCoord DeviceToLogicalX(wxCoord x) const { return m_pOrig->DeviceToLogicalX(x); }
176
+ virtual wxCoord DeviceToLogicalY(wxCoord y) const { return m_pOrig->DeviceToLogicalY(y); }
177
+ virtual wxCoord DeviceToLogicalXRel(wxCoord x) const { return m_pOrig->DeviceToLogicalXRel(x); }
178
+ virtual wxCoord DeviceToLogicalYRel(wxCoord y) const { return m_pOrig->DeviceToLogicalYRel(y); }
179
+ virtual wxCoord LogicalToDeviceX(wxCoord x) const { return m_pOrig->LogicalToDeviceX(x); }
180
+ virtual wxCoord LogicalToDeviceY(wxCoord y) const { return m_pOrig->LogicalToDeviceY(y); }
181
+ virtual wxCoord LogicalToDeviceXRel(wxCoord x) const { return m_pOrig->LogicalToDeviceXRel(x); }
182
+ virtual wxCoord LogicalToDeviceYRel(wxCoord y) const { return m_pOrig->LogicalToDeviceYRel(y); }
183
+
184
+ virtual void SetMapMode(wxMappingMode mode) { m_pOrig->SetMapMode(mode); }
185
+ virtual wxMappingMode GetMapMode() const { return m_pOrig->GetMapMode(); }
186
+
187
+ virtual void SetUserScale(double x, double y) { m_pOrig->SetUserScale( x, y ); }
188
+ virtual void GetUserScale(double *x, double *y) const { m_pOrig->GetUserScale( x, y ); }
189
+
190
+ virtual void SetLogicalScale(double x, double y) { m_pOrig->SetLogicalScale( x, y ); }
191
+ virtual void GetLogicalScale(double *x, double *y) const { m_pOrig->GetLogicalScale( x, y ); }
192
+
193
+ virtual void SetLogicalOrigin(wxCoord x, wxCoord y) { m_pOrig->SetLogicalOrigin( x, y ); }
194
+ virtual void DoGetLogicalOrigin(wxCoord *x, wxCoord *y) const { m_pOrig->DoGetLogicalOrigin( x, y); }
195
+
196
+ virtual void SetDeviceOrigin(wxCoord x, wxCoord y) { m_pOrig->SetDeviceOrigin( x, y ); }
197
+ virtual void DoGetDeviceOrigin(wxCoord *x, wxCoord *y) const { m_pOrig->DoGetDeviceOrigin( x, y ); }
198
+
199
+ virtual void SetDeviceLocalOrigin( wxCoord x, wxCoord y ) { m_pOrig->SetDeviceLocalOrigin( x, y ); }
200
+
201
+ virtual void ComputeScaleAndOrigin() { m_pOrig->ComputeScaleAndOrigin(); }
202
+
203
+ // this needs to overidden if the axis is inverted
204
+ virtual void SetAxisOrientation(bool xLeftRight, bool yBottomUp) { m_pOrig->SetAxisOrientation( xLeftRight, yBottomUp); }
205
+
206
+ // ---------------------------------------------------------
207
+ // the actual drawing API
208
+
209
+ virtual bool DoFloodFill(wxCoord x, wxCoord y, const wxColour& col,
210
+ wxFloodFillStyle style = wxFLOOD_SURFACE)
211
+ {
212
+ return m_pOrig->DoFloodFill( ScaleCoord(x), ScaleCoord(y), col, style );
213
+ }
214
+
215
+ virtual void DoGradientFillLinear(const wxRect& rect,
216
+ const wxColour& initialColour,
217
+ const wxColour& destColour,
218
+ wxDirection nDirection = wxEAST)
219
+ {
220
+ m_pOrig->DoGradientFillLinear( wxRect( ScaleInt(rect.x), ScaleInt(rect.y), ScaleInt(rect.width), ScaleInt(rect.height)),
221
+ initialColour, destColour, nDirection );
222
+ }
223
+
224
+ virtual void DoGradientFillConcentric(const wxRect& rect,
225
+ const wxColour& initialColour,
226
+ const wxColour& destColour,
227
+ const wxPoint& circleCenter)
228
+ {
229
+ m_pOrig->DoGradientFillConcentric( wxRect( ScaleInt(rect.x), ScaleInt(rect.y), ScaleInt(rect.width), ScaleInt(rect.height)),
230
+ initialColour, destColour,
231
+ wxPoint( ScaleInt(circleCenter.x), ScaleInt(circleCenter.y)) );
232
+ }
233
+
234
+ virtual bool DoGetPixel(wxCoord x, wxCoord y, wxColour *col) const
235
+ {
236
+ return m_pOrig->DoGetPixel( (wxCoord)ceil((double)x*m_nScale), (wxCoord)ceil((double)y*m_nScale), col );
237
+ }
238
+
239
+ virtual void DoDrawPoint(wxCoord x, wxCoord y)
240
+ {
241
+ m_pOrig->DoDrawPoint( ScaleCoord(x), ScaleCoord(y) );
242
+ }
243
+ virtual void DoDrawLine(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2)
244
+ {
245
+ m_pOrig->DoDrawLine( ScaleCoord(x1), ScaleCoord(y1), ScaleCoord(x2), ScaleCoord(y2) );
246
+ }
247
+
248
+ virtual void DoDrawArc(wxCoord x1, wxCoord y1,
249
+ wxCoord x2, wxCoord y2,
250
+ wxCoord xc, wxCoord yc)
251
+ {
252
+ m_pOrig->DoDrawArc( ScaleCoord(x1), ScaleCoord(y1),
253
+ ScaleCoord(x2), ScaleCoord(y2),
254
+ ScaleCoord(xc), ScaleCoord(yc) );
255
+ }
256
+
257
+ virtual void DoDrawCheckMark(wxCoord x, wxCoord y,
258
+ wxCoord width, wxCoord height)
259
+ {
260
+ m_pOrig->DoDrawCheckMark( ScaleCoord(x), ScaleCoord(y), ScaleCoord(width), ScaleCoord(height) );
261
+ }
262
+
263
+ virtual void DoDrawEllipticArc(wxCoord x, wxCoord y, wxCoord w, wxCoord h,
264
+ double sa, double ea)
265
+ {
266
+ m_pOrig->DoDrawEllipticArc( ScaleCoord(x), ScaleCoord(y), ScaleCoord(w), ScaleCoord(h), sa, ea );
267
+ }
268
+
269
+ virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height)
270
+ {
271
+ m_pOrig->DoDrawRectangle( ScaleCoord(x), ScaleCoord(y), ScaleCoord(width), ScaleCoord(height) );
272
+ }
273
+
274
+ virtual void DoDrawRoundedRectangle(wxCoord x, wxCoord y,
275
+ wxCoord width, wxCoord height,
276
+ double radius)
277
+ {
278
+ m_pOrig->DoDrawRoundedRectangle( ScaleCoord(x), ScaleCoord(y), ScaleCoord(width), ScaleCoord(height), radius*m_nScale );
279
+ }
280
+
281
+ virtual void DoDrawEllipse(wxCoord x, wxCoord y,
282
+ wxCoord width, wxCoord height)
283
+ {
284
+ m_pOrig->DoDrawEllipse( ScaleCoord(x), ScaleCoord(y), ScaleCoord(width), ScaleCoord(height) );
285
+ }
286
+
287
+ virtual void DoCrossHair(wxCoord x, wxCoord y)
288
+ {
289
+ m_pOrig->DoCrossHair( ScaleCoord(x), ScaleCoord(y) );
290
+ }
291
+
292
+ virtual void DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y)
293
+ {
294
+ m_pOrig->DoDrawIcon( icon, ScaleCoord(x), ScaleCoord(y) );
295
+ }
296
+
297
+ virtual void DoDrawBitmap(const wxBitmap &bmp, wxCoord x, wxCoord y,
298
+ bool useMask = false)
299
+ {
300
+ m_pOrig->DoDrawBitmap( bmp, ScaleCoord(x), ScaleCoord(y), useMask );
301
+ }
302
+
303
+ virtual void DoDrawText(const wxString& text, wxCoord x, wxCoord y)
304
+ {
305
+ wxFont font = GetFont();
306
+ wxFont prevfont = font;
307
+
308
+ if(font != wxNullFont)
309
+ {
310
+ font.SetPointSize(int(font.GetPointSize()*m_nScale));
311
+ SetFont(font);
312
+ }
313
+
314
+ m_pOrig->DoDrawText( text, ScaleCoord(x), ScaleCoord(y) );
315
+
316
+ SetFont(prevfont);
317
+ }
318
+
319
+ virtual void DoDrawRotatedText(const wxString& text,
320
+ wxCoord x, wxCoord y, double angle)
321
+ {
322
+ wxFont font = GetFont();
323
+ wxFont prevfont = font;
324
+
325
+ if(font != wxNullFont)
326
+ {
327
+ font.SetPointSize(int(font.GetPointSize()*m_nScale));
328
+ SetFont(font);
329
+ }
330
+
331
+ m_pOrig->DoDrawRotatedText( text, ScaleCoord(x), ScaleCoord(y), angle );
332
+
333
+ SetFont(prevfont);
334
+ }
335
+
336
+ virtual bool DoBlit(wxCoord xdest, wxCoord ydest,
337
+ wxCoord width, wxCoord height,
338
+ wxDC *source,
339
+ wxCoord xsrc, wxCoord ysrc,
340
+ wxRasterOperationMode rop = wxCOPY,
341
+ bool useMask = false,
342
+ wxCoord xsrcMask = wxDefaultCoord,
343
+ wxCoord ysrcMask = wxDefaultCoord)
344
+ {
345
+ return m_pOrig->DoBlit( ScaleCoord(xdest), ScaleCoord(ydest),
346
+ width, height, source, xsrc, ysrc, rop, useMask, xsrcMask, ysrcMask );
347
+ }
348
+
349
+ virtual bool DoStretchBlit(wxCoord xdest, wxCoord ydest,
350
+ wxCoord dstWidth, wxCoord dstHeight,
351
+ wxDC *source,
352
+ wxCoord xsrc, wxCoord ysrc,
353
+ wxCoord srcWidth, wxCoord srcHeight,
354
+ wxRasterOperationMode rop = wxCOPY,
355
+ bool useMask = false,
356
+ wxCoord xsrcMask = wxDefaultCoord,
357
+ wxCoord ysrcMask = wxDefaultCoord)
358
+ {
359
+ return m_pOrig->DoStretchBlit( ScaleCoord(xdest), ScaleCoord(ydest), ScaleCoord(dstWidth), ScaleCoord(dstHeight),
360
+ source, xsrc, ysrc, srcWidth, srcHeight, rop, useMask, xsrcMask, ysrcMask );
361
+ }
362
+
363
+ virtual wxBitmap DoGetAsBitmap(const wxRect *subrect) const
364
+ {
365
+ return m_pOrig->DoGetAsBitmap( subrect );
366
+ }
367
+
368
+ #if wxVERSION_NUMBER < 2905
369
+ virtual void DoDrawLines(int n, wxPoint points[],
370
+ #else
371
+ virtual void DoDrawLines(int n, const wxPoint points[],
372
+ #endif
373
+ wxCoord xoffset, wxCoord yoffset )
374
+ {
375
+ wxPoint *updPoints = new wxPoint[n];
376
+
377
+ for(int i = 0; i < n; i++)
378
+ {
379
+ (updPoints + i)->x = ScaleInt((points + i)->x);
380
+ (updPoints + i)->y = ScaleInt((points + i)->y);
381
+ }
382
+
383
+ m_pOrig->DoDrawLines( n, updPoints, ScaleCoord(xoffset), ScaleCoord(yoffset) );
384
+
385
+ delete [] updPoints;
386
+ }
387
+
388
+ virtual void DrawLines(const wxPointList *list,
389
+ wxCoord xoffset, wxCoord yoffset )
390
+ {
391
+ int i = 0;
392
+ wxPoint *pts = new wxPoint[list->GetCount()];
393
+
394
+ wxPointList::compatibility_iterator node = list->GetFirst();
395
+ while( node )
396
+ {
397
+ *(pts + i) = *node->GetData();
398
+ i++;
399
+ node = node->GetNext();
400
+ }
401
+
402
+ wxDCImplWrapper::DoDrawLines( i, pts, xoffset, yoffset );
403
+
404
+ delete [] pts;
405
+ }
406
+
407
+ #if wxVERSION_NUMBER < 2905
408
+ virtual void DoDrawPolygon(int n, wxPoint points[],
409
+ #else
410
+ virtual void DoDrawPolygon(int n, const wxPoint points[],
411
+ #endif
412
+ wxCoord xoffset, wxCoord yoffset,
413
+ wxPolygonFillMode fillStyle = wxODDEVEN_RULE)
414
+ {
415
+ wxPoint *updPoints = new wxPoint[n];
416
+
417
+ for(int i = 0; i < n; i++)
418
+ {
419
+ (updPoints + i)->x = ScaleInt((points + i)->x);
420
+ (updPoints + i)->y = ScaleInt((points + i)->y);
421
+ }
422
+
423
+ m_pOrig->DoDrawPolygon(n, updPoints, ScaleCoord(xoffset), ScaleCoord(yoffset), fillStyle);
424
+
425
+ delete [] updPoints;
426
+ }
427
+
428
+ virtual void DoDrawPolyPolygon(int n, const int count[], const wxPoint points[],
429
+ wxCoord xoffset, wxCoord yoffset,
430
+ wxPolygonFillMode fillStyle)
431
+ {
432
+ int nTotalPoints = 0;
433
+
434
+ for(int i = 0; i < n; i++)nTotalPoints += count[i];
435
+
436
+ wxPoint *updPoints = new wxPoint[nTotalPoints];
437
+
438
+ for(int i = 0; i < nTotalPoints; i++)
439
+ {
440
+ (updPoints + i)->x = ScaleInt((points + i)->x);
441
+ (updPoints + i)->y = ScaleInt((points + i)->y);
442
+ }
443
+
444
+ m_pOrig->DoDrawPolyPolygon(n, count, updPoints, ScaleCoord(xoffset), ScaleCoord(yoffset), fillStyle);
445
+
446
+ delete [] updPoints;
447
+ }
448
+
449
+ void DrawPolygon(const wxPointList *list,
450
+ wxCoord xoffset, wxCoord yoffset,
451
+ wxPolygonFillMode fillStyle )
452
+ {
453
+ int i = 0;
454
+ wxPoint *pts = new wxPoint[list->GetCount()];
455
+
456
+ wxPointList::compatibility_iterator node = list->GetFirst();
457
+ while( node )
458
+ {
459
+ *(pts + i) = *node->GetData();
460
+ i++;
461
+ node = node->GetNext();
462
+ }
463
+
464
+ wxDCImplWrapper::DoDrawPolygon( i, pts, xoffset, yoffset, fillStyle );
465
+
466
+ delete [] pts;
467
+ }
468
+
469
+
470
+ #if wxUSE_SPLINES
471
+ void DrawSpline(wxCoord x1, wxCoord y1,
472
+ wxCoord x2, wxCoord y2,
473
+ wxCoord x3, wxCoord y3);
474
+ void DrawSpline(int n, wxPoint points[]);
475
+ void DrawSpline(const wxPointList *points) { DoDrawSpline(points); }
476
+
477
+ virtual void DoDrawSpline(const wxPointList *points)
478
+ {
479
+ wxPoint *pPt;
480
+ wxPointList updPoints;
481
+
482
+ wxPointList::compatibility_iterator node = points->GetFirst();
483
+ while( node )
484
+ {
485
+ pPt = node->GetData();
486
+ updPoints.Append( new wxPoint( ScaleInt(pPt->x), ScaleInt(pPt->y)) );
487
+ node = node->GetNext();
488
+ }
489
+
490
+ m_pOrig->DoDrawSpline( &updPoints );
491
+
492
+ updPoints.DeleteContents( true );
493
+ updPoints.Clear();
494
+ }
495
+ #endif
496
+
497
+ // ---------------------------------------------------------
498
+ // wxMemoryDC Impl API
499
+
500
+ virtual void DoSelect(const wxBitmap& bmp) { m_pOrig->DoSelect( bmp ); }
501
+
502
+ virtual const wxBitmap& GetSelectedBitmap() const { return m_pOrig->GetSelectedBitmap(); }
503
+ virtual wxBitmap& GetSelectedBitmap() { return m_pOrig->GetSelectedBitmap(); }
504
+
505
+ // ---------------------------------------------------------
506
+ // wxPrinterDC Impl API
507
+
508
+ virtual wxRect GetPaperRect() const { return m_pOrig->GetPaperRect(); }
509
+
510
+ virtual int GetResolution() const { return m_pOrig->GetResolution(); }
511
+
512
+ protected:
513
+ /*! \brief Pointer to original DC implementation. */
514
+ wxDCImpl *m_pOrig;
515
+ /*! \brief Global graphics scale. */
516
+ double m_nScale;
517
+
518
+ /**
519
+ * \brief Scale given value.
520
+ * \param val Value to scale
521
+ * \return Scaled value
522
+ */
523
+ wxCoord ScaleCoord(wxCoord val){return (wxCoord)ceil((double)val*m_nScale);}
524
+
525
+ /**
526
+ * \brief Scale given value.
527
+ * \param val Value to scale
528
+ * \return Scaled value
529
+ */
530
+ wxCoord ScaleInt(int val){return (int)ceil((double)val*m_nScale);}
531
+ };
532
+
533
+ /*! \brief Class acts as a wrapper for given DC class and provides modified
534
+ * drawing functions cooperating with the shape canvas able to draw scaled graphics.
535
+ * All drawing operations performed by the shapes should be done via this class otherwise
536
+ * the global scalling capabilities provided by the shape canvas wont be available.
537
+ * \sa wxSFShapeCanvas
538
+ */
539
+ class wxScaledDC : public wxDC
540
+ {
541
+ public:
542
+ wxScaledDC(wxDC& target, double scale)
543
+ : wxDC(new wxDCImplWrapper(target.GetImpl(), scale))
544
+ {}
545
+ virtual ~wxScaledDC()
546
+ {}
547
+ };
548
+
549
+ #endif // _WXRUBY_SCALEDDC_H
@@ -235,7 +235,7 @@ WXRUBY_EXPORT VALUE wxRuby_WrapWxEventInRuby(wxEvent *wx_event)
235
235
  }
236
236
 
237
237
  // No existing Ruby instance found, so a transitory event object; wrap
238
- // without mark or free functions as Wx will deals with deletion
238
+ // without mark or free functions as Wx will deal with deletion
239
239
  rb_event = Data_Wrap_Struct(rb_event_class, 0, 0, 0);
240
240
  DATA_PTR(rb_event) = wx_event;
241
241
  // do not forget to mark the instance with the mangled swig type name
@@ -0,0 +1,26 @@
1
+
2
+ module Wx
3
+
4
+ # Mixin module providing Array extensions.
5
+ module ArrayExt
6
+
7
+ def to_size
8
+ w, h = self
9
+ Wx::Size.new(w || Wx::DEFAULT_COORD, h || Wx::DEFAULT_COORD)
10
+ end
11
+
12
+ def to_point
13
+ x, y = self
14
+ Wx::Point.new(x || Wx::DEFAULT_COORD, y || Wx::DEFAULT_COORD)
15
+ end
16
+
17
+ def to_real_point
18
+ x, y = self
19
+ Wx::RealPoint.new(x || Wx::DEFAULT_COORD, y || Wx::DEFAULT_COORD)
20
+ end
21
+
22
+ end
23
+
24
+ # extend standard Array class
25
+ ::Array.include(Wx::ArrayExt)
26
+ end
@@ -0,0 +1,92 @@
1
+
2
+ module Wx
3
+
4
+ module ArtLocator
5
+
6
+ ART_FOLDER = 'art'
7
+
8
+ class << self
9
+
10
+ # This is not put in a constants as cannot retrieve image handler info
11
+ # before an app has started
12
+ def art_extensions(art_type)
13
+ unless @art_extensions
14
+ @art_extensions = {
15
+ icon: if Wx::PLATFORM == 'WXMSW'
16
+ %w[ico xpm]
17
+ elsif Wx::PLATFORM == 'WXGTK'
18
+ (%w[xpm]+Image.extensions).uniq
19
+ else
20
+ (%w[xbm xpm]+Image.extensions).uniq
21
+ end,
22
+ bitmap: if Wx::PLATFORM == 'WXMSW'
23
+ (%w[bmp xpm]+Image.extensions).uniq
24
+ elsif Wx::PLATFORM == 'WXGTK'
25
+ (%w[xpm]+Image.extensions).uniq
26
+ else
27
+ (%w[xbm xpm]+Image.extensions).uniq
28
+ end,
29
+ cursor: if Wx::PLATFORM == 'WXMSW'
30
+ %w[cur ico bmp]
31
+ elsif Wx::PLATFORM == 'WXGTK'
32
+ []
33
+ else
34
+ %w[xbm]
35
+ end,
36
+ image: Image.extensions
37
+ }
38
+ end
39
+ @art_extensions[(art_type || :image).to_sym] || []
40
+ end
41
+ private :art_extensions
42
+
43
+ def art_folder
44
+ @art_folder ||= ART_FOLDER
45
+ end
46
+
47
+ def art_folder=(name)
48
+ @art_folder = name ? name.to_s : ART_FOLDER
49
+ end
50
+
51
+ def search_paths
52
+ @search_paths ||= []
53
+ end
54
+ private :search_paths
55
+
56
+ def add_search_path(*paths)
57
+ paths.flatten.each { |p| paths << s.to_s unless paths.include?(s.to_s) }
58
+ end
59
+ alias :add_search_paths :add_search_path
60
+
61
+ def _find_art(art_name, art_type, art_path, art_section, bmp_type)
62
+ art_paths = [art_path, File.join(art_path, art_folder)]
63
+ art_paths << File.join(art_paths.last, art_section) if art_section
64
+ art_paths << File.join(art_paths.last, art_type.to_s) if art_type
65
+ art_paths.reverse_each do |sp|
66
+ (bmp_type ? (Image.handler_extensions[bmp_type] || []) : art_extensions(art_type)).each do |ext|
67
+ fp = File.join(sp, "#{art_name}.#{ext}")
68
+ return fp if File.file?(fp)
69
+ end
70
+ end
71
+ nil
72
+ end
73
+ private :_find_art
74
+
75
+ def find_art(art_name, art_type: nil, art_path: nil, art_section: nil, bmp_type: nil)
76
+ unless art_path
77
+ caller_path = caller_locations(1).first.absolute_path
78
+ art_path = File.dirname(caller_path)
79
+ art_section ||= File.basename(caller_path, '.*')
80
+ end
81
+ bmp_type = nil if bmp_type == Wx::BitmapType::BITMAP_TYPE_ANY
82
+ unless fp = _find_art(art_name.to_s, art_type, art_path, art_section, bmp_type)
83
+ search_paths.find { |sp| fp = _find_art(art_name.to_s, art_type, sp, art_section, bmp_type) }
84
+ end
85
+ fp
86
+ end
87
+
88
+ end
89
+
90
+ end
91
+
92
+ end
@@ -24,7 +24,7 @@ class Wx::ArtProvider
24
24
 
25
25
  wx_delete = instance_method(:delete)
26
26
  define_method(:delete) do | art_prov |
27
- wx_push.bind(self).call(art_prov)
27
+ wx_delete.bind(self).call(art_prov)
28
28
  @__art_provs.delete(art_prov)
29
29
  end
30
30
  end