wxruby3 0.9.0.pre.beta.9 → 0.9.0.pre.beta.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/ext/wxruby3/include/wxruby-ScaledDC.h +549 -0
  3. data/ext/wxruby3/swig/mark_free_impl.i +0 -34
  4. data/ext/wxruby3/swig/wx.i +1 -1
  5. data/lib/wx/core/bitmap.rb +7 -0
  6. data/lib/wx/core/choice.rb +3 -0
  7. data/lib/wx/core/combobox.rb +3 -0
  8. data/lib/wx/core/controlwithitems.rb +98 -2
  9. data/lib/wx/core/data_object.rb +74 -6
  10. data/lib/wx/core/icon.rb +7 -1
  11. data/lib/wx/core/imagelist.rb +11 -0
  12. data/lib/wx/core/listbox.rb +3 -0
  13. data/lib/wx/core/point.rb +21 -10
  14. data/lib/wx/core/real_point.rb +21 -10
  15. data/lib/wx/core/rect.rb +2 -2
  16. data/lib/wx/core/size.rb +12 -5
  17. data/lib/wx/doc/data_object.rb +104 -0
  18. data/lib/wx/doc/gdi_common.rb +33 -5
  19. data/lib/wx/doc/progress_dialog.rb +37 -0
  20. data/lib/wx/doc/scaled_dc.rb +16 -0
  21. data/lib/wx/global_const.rb +4 -3
  22. data/lib/wx/version.rb +1 -1
  23. data/rakelib/lib/config/mingw.rb +3 -0
  24. data/rakelib/lib/core/include/init.inc +2 -2
  25. data/rakelib/lib/core/package.rb +3 -3
  26. data/rakelib/lib/core/spec.rb +2 -0
  27. data/rakelib/lib/director/ctrl_with_items.rb +29 -17
  28. data/rakelib/lib/director/data_object.rb +94 -0
  29. data/rakelib/lib/director/data_object_simple_base.rb +123 -0
  30. data/rakelib/lib/director/derived_dc.rb +38 -0
  31. data/rakelib/lib/director/dialog.rb +29 -54
  32. data/rakelib/lib/director/image_list.rb +3 -1
  33. data/rakelib/lib/director/preview_frame.rb +41 -0
  34. data/rakelib/lib/director/print_data.rb +5 -7
  35. data/rakelib/lib/specs/interfaces.rb +2 -0
  36. data/rakelib/lib/typemap/data_object_data.rb +13 -4
  37. data/samples/dialogs/dialogs.rb +70 -50
  38. data/samples/drawing/maths_images.rb +1 -1
  39. data/samples/sampler/ext.rb +3 -3
  40. data/samples/sampler/stc_editor.rb +19 -19
  41. data/samples/sampler/txt_editor.rb +2 -2
  42. data/samples/treectrl/treectrl.rb +32 -30
  43. data/tests/lib/wxapp_runner.rb +64 -0
  44. data/tests/test_basic.rb +0 -5
  45. data/tests/test_clipboard.rb +114 -17
  46. data/tests/test_dialog.rb +2 -13
  47. data/tests/test_event_handling.rb +2 -13
  48. data/tests/test_events.rb +2 -6
  49. data/tests/test_geometry.rb +54 -17
  50. data/tests/test_intl.rb +2 -15
  51. data/tests/test_item_data.rb +69 -15
  52. data/tests/test_variant.rb +1 -15
  53. data/tests/testapp.rb +0 -5
  54. data/tests/testapp_noframe.rb +0 -5
  55. metadata +8 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ce9e7bb6763fb08e50024b77b709a9cc94032933960dbdaee1b3a5f90acad71d
4
- data.tar.gz: 3d39f6499828d222e038a1bd4880af58befe24f887d2d73534213107f024bf46
3
+ metadata.gz: b577d2fda2fffbd6d2ef1e8f53c6f2542c15e66e50a2d8b843ce7362a3ef5ba3
4
+ data.tar.gz: 49dbec57d8a01bee05d23d0c995d7e7ac00eeac589f33d4a9b18c47e703483d7
5
5
  SHA512:
6
- metadata.gz: a2a56a03af8da3b6fe6dc57192cf151218cd6f6bf2dca613cdfccae1851451fc7ecb75080cb530050e30f438bee6c8990106795218e6cc5601a033517b92b445
7
- data.tar.gz: 02b8069fda0d2c3a0237747650f081b1824787d72c9aaad98ce8ef78cbd6cb5a1752bda5e98539ba092bc786854b86e26141fa935c3cd58817290931d0f7c836
6
+ metadata.gz: 67b9604ae977c9ebb9399de258c0c0452b560a7365325c2ef173e26ba5c97acb63b3de4c8f55a4494d3c2c474df7fde7f301ec81d151d7469576fbb0c6b7594d
7
+ data.tar.gz: 3ac00b5f4fac949aa8d757be43c092358f294007fda663b68f15094ac287c564469bbd9dd81ecaf3a003b30e13228e012c7e80a0ac3617833d50a290fcafb4a5
@@ -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
@@ -340,38 +340,4 @@ WXRUBY_EXPORT void GC_mark_wxEvent(void *ptr)
340
340
  std::wcout << "< GC_mark_wxEvent : " << ptr << std::endl;
341
341
  #endif
342
342
  }
343
-
344
- // Prevents Ruby's GC sweeping up items that are stored as client data
345
- // Checks whether the C++ object is still around first...
346
- WXRUBY_EXPORT void GC_mark_wxControlWithItems(void* ptr)
347
- {
348
- #ifdef __WXRB_DEBUG__
349
- if (wxRuby_TraceLevel()>1)
350
- std::wcout << "> GC_mark_wxControlWithItems : " << ptr << std::endl;
351
- #endif
352
-
353
- if ( GC_IsWindowDeleted(ptr) )
354
- return;
355
-
356
- GC_mark_wxWindow(ptr);
357
-
358
- wxControlWithItems* wx_cwi = (wxControlWithItems*) ptr;
359
- int count = wx_cwi->GetCount();
360
- if ( count == 0 )
361
- return; // Empty control
362
- if ( ! wx_cwi->HasClientObjectData() && ! wx_cwi->HasClientUntypedData() )
363
- return; // Control containing only strings
364
-
365
- for (int i = 0; i < count; ++i)
366
- {
367
- VALUE object = (VALUE) wx_cwi->GetClientData(i);
368
- if ( object && object != Qnil )
369
- rb_gc_mark(object);
370
- }
371
-
372
- #ifdef __WXRB_DEBUG__
373
- if (wxRuby_TraceLevel()>1)
374
- std::wcout << "< GC_mark_wxControlWithItems : " << ptr << std::endl;
375
- #endif
376
- }
377
343
  %}
@@ -263,7 +263,7 @@ const int wxrb_trace_level = 0;
263
263
  #ifdef __WXRB_DEBUG__
264
264
  WXRUBY_EXPORT int wxRuby_TraceLevel()
265
265
  {
266
- return _wxrb_trace_level;
266
+ return wxrb_trace_level;
267
267
  }
268
268
  #endif
269
269
  %}
@@ -25,6 +25,13 @@ class Wx::Bitmap
25
25
  new(img, depth)
26
26
  end
27
27
 
28
+ # Create a new bitmap from an icon
29
+ def self.from_icon(icon)
30
+ bmp = self.new
31
+ bmp.copy_from_icon(icon)
32
+ bmp
33
+ end
34
+
28
35
  # Ruby methods that switch class are conventionally named to_foo
29
36
  alias :to_image :convert_to_image
30
37
 
@@ -1,3 +1,6 @@
1
+
2
+ require_relative './controlwithitems'
3
+
1
4
  class Wx::Choice
2
5
  alias :get_item_data :get_client_data
3
6
  alias :set_item_data :set_client_data
@@ -1,3 +1,6 @@
1
+
2
+ require_relative './controlwithitems'
3
+
1
4
  class Wx::ComboBox
2
5
  alias :get_item_data :get_client_data
3
6
  alias :set_item_data :set_client_data