wxruby3 0.9.0.pre.beta.10 → 0.9.0.pre.beta.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 392d24963cded73bac9b253b83e6206ed8c1841ea697d6ec0af4d54faaabd79a
4
- data.tar.gz: 9715c643d176e5da3c2540f84a2698d551a3cff4d6f28488644d5d9e3d929da3
3
+ metadata.gz: b577d2fda2fffbd6d2ef1e8f53c6f2542c15e66e50a2d8b843ce7362a3ef5ba3
4
+ data.tar.gz: 49dbec57d8a01bee05d23d0c995d7e7ac00eeac589f33d4a9b18c47e703483d7
5
5
  SHA512:
6
- metadata.gz: a833c65595d26722ada2368508ed654861f12bb5936fd3b65d29a5a72ce5dcbbc052930bc7a198e4aaba9547d0d3e73facd4a8f995f4cb65ea051c0817c47335
7
- data.tar.gz: f95957c8734b5f02f69977b8b937ec304946b4a8f171d40b25c8be7d70b4eae667878d541b76d49b4f2c8895bbebf191ac7e2b813877a3c67ff47f8687c7288f
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
@@ -1,10 +1,78 @@
1
- # Provide some default implementations of these to make life easier
2
- class Wx::DataObject
3
- def get_preferred_format(direction)
4
- get_all_formats(direction).first
1
+
2
+ module Wx
3
+
4
+ # Provide some default implementations of these to make life easier
5
+ class DataObject
6
+ def get_preferred_format(direction)
7
+ get_all_formats(direction).first
8
+ end
9
+
10
+ def get_format_count(direction)
11
+ get_all_formats(direction).size
12
+ end
5
13
  end
6
14
 
7
- def get_format_count(direction)
8
- get_all_formats(direction).size
15
+ class DataObjectSimple
16
+
17
+ # implement the overloads which do not require the format arg
18
+ # using pure Ruby
19
+
20
+ wx_get_data_size = instance_method :get_data_size
21
+ define_method :get_data_size do |format = nil|
22
+ wx_get_data_size.bind(self).call(format || self.get_format)
23
+ end
24
+
25
+ wx_get_data_here = instance_method :get_data_here
26
+ define_method :get_data_here do |format = nil|
27
+ wx_get_data_here.bind(self).call(format || self.get_format)
28
+ end
29
+
30
+ wx_set_data = instance_method :set_data
31
+ define_method :set_data do |*args|
32
+ if args.size>1
33
+ format, buf = args
34
+ else
35
+ format = nil
36
+ buf = args.first
37
+ end
38
+ wx_set_data.bind(self).call(format || self.get_format, buf)
39
+ end
40
+
9
41
  end
42
+
43
+ class DataObjectSimpleBase
44
+
45
+ # implement these in pure Ruby for optimization
46
+ def get_data_size(*)
47
+ self._get_data_size
48
+ end
49
+ def get_data_here(*)
50
+ self._get_data
51
+ end
52
+
53
+ def set_data(*args)
54
+ if args.size>1
55
+ _, buf = args
56
+ else
57
+ buf = args.first
58
+ end
59
+ self._set_data(buf)
60
+ end
61
+
62
+ def _get_data_size
63
+ (_get_data || '').bytesize
64
+ end
65
+ protected :_get_data_size
66
+
67
+ end
68
+
69
+ class TextDataObject
70
+
71
+ # override this to loose the extra terminating 0 we otherwise get
72
+ def get_data_here(*)
73
+ self.get_text
74
+ end
75
+
76
+ end
77
+
10
78
  end
data/lib/wx/core/point.rb CHANGED
@@ -1,4 +1,7 @@
1
1
  class Wx::Point
2
+
3
+ include Comparable
4
+
2
5
  # More informative output when converted to string
3
6
  def to_s
4
7
  "#<Wx::Point: (#{x}, #{y})>"
@@ -16,23 +19,26 @@ class Wx::Point
16
19
  alias :get_x :x
17
20
  alias :get_y :y
18
21
 
19
- # Compare point values
20
- def ==(other)
21
- if Wx::Point === other
22
+ # Correct comparison for Points - same if same x and y
23
+ def eql?(other)
24
+ if other.instance_of?(self.class)
22
25
  x == other.x and y == other.y
23
- elsif Array === other && other.size == 2
24
- to_ary == other
25
26
  else
26
- Kernel.raise TypeError, "Cannot compare Point to #{other}"
27
+ false
27
28
  end
28
29
  end
29
30
 
30
- # Correct comparison for Points - same if same x and y
31
- def eql?(other)
31
+ def hash
32
+ to_ary.hash
33
+ end
34
+
35
+ def <=>(other)
32
36
  if Wx::Point === other
33
- x == other.x and y == other.y
37
+ (x*y) <=> (other.x*other.y)
38
+ elsif Array === other && other.size == 2
39
+ (x*y) <=> (other.first.to_i*other.last.to_i)
34
40
  else
35
- false
41
+ nil
36
42
  end
37
43
  end
38
44
 
@@ -89,4 +95,9 @@ class Wx::Point
89
95
  end
90
96
  end
91
97
  end
98
+
99
+ def to_real_point
100
+ Wx::RealPoint.new(self.x.to_f, self.y.to_f)
101
+ end
102
+ alias :to_real :to_real_point
92
103
  end