Fix and errant commented out line of code in DoGetPixel.
[wxWidgets.git] / src / os2 / dc.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: dc.cpp
3 // Purpose: wxDC class
4 // Author: David Webster
5 // Modified by:
6 // Created: 10/14/99
7 // RCS-ID: $Id$
8 // Copyright: (c) David Webster
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 // For compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
14
15 #ifndef WX_PRECOMP
16 #include "wx/window.h"
17 #include "wx/dc.h"
18 #include "wx/utils.h"
19 #include "wx/dialog.h"
20 #include "wx/app.h"
21 #include "wx/bitmap.h"
22 #include "wx/dcmemory.h"
23 #include "wx/log.h"
24 #include "wx/icon.h"
25 #endif
26
27 #include "wx/dcprint.h"
28
29 #include <string.h>
30 #include <math.h>
31
32 #include "wx/os2/private.h"
33
34 IMPLEMENT_ABSTRACT_CLASS(wxDC, wxObject)
35
36 // ---------------------------------------------------------------------------
37 // constants
38 // ---------------------------------------------------------------------------
39
40 static const int VIEWPORT_EXTENT = 1000;
41
42 static const int MM_POINTS = 9;
43 static const int MM_METRIC = 10;
44
45 // usually this is defined in math.h
46 #ifndef M_PI
47 static const double M_PI = 3.14159265358979323846;
48 #endif // M_PI
49
50 // ---------------------------------------------------------------------------
51 // private functions
52 // ---------------------------------------------------------------------------
53
54 // convert degrees to radians
55 static inline double DegToRad(double deg) { return (deg * M_PI) / 180.0; }
56
57 int SetTextColor(
58 HPS hPS
59 , int nForegroundColour
60 )
61 {
62 CHARBUNDLE vCbnd;
63
64 vCbnd.lColor = nForegroundColour;
65 ::GpiSetAttrs( hPS // presentation-space handle
66 ,PRIM_CHAR // Char primitive.
67 ,CBB_COLOR // sets color.
68 ,0 //
69 ,&vCbnd // buffer for attributes.
70 );
71 return 0;
72 }
73
74 int QueryTextBkColor(
75 HPS hPS
76 )
77 {
78 CHARBUNDLE vCbnd;
79
80 ::GpiQueryAttrs( hPS // presentation-space handle
81 ,PRIM_CHAR // Char primitive.
82 ,CBB_BACK_COLOR // Background color.
83 ,&vCbnd // buffer for attributes.
84 );
85 return vCbnd.lBackColor;
86 }
87
88
89 int SetTextBkColor(
90 HPS hPS
91 , int nBackgroundColour
92 )
93 {
94 CHARBUNDLE vCbnd;
95 int rc;
96
97 rc = QueryTextBkColor(hPS);
98
99 vCbnd.lBackColor = nBackgroundColour;
100 ::GpiSetAttrs(hPS, // presentation-space handle
101 PRIM_CHAR, // Char primitive.
102 CBB_BACK_COLOR, // sets color.
103 0,
104 &vCbnd // buffer for attributes.
105 );
106 return rc;
107 }
108
109 int SetBkMode(
110 HPS hPS
111 , int nBackgroundMode
112 )
113 {
114 if(nBackgroundMode == wxTRANSPARENT)
115 ::GpiSetBackMix( hPS
116 ,BM_LEAVEALONE
117 );
118 else
119 // the background of the primitive takes over whatever is underneath.
120 ::GpiSetBackMix( hPS
121 ,BM_OVERPAINT
122 );
123 return 0;
124 }
125
126 // ===========================================================================
127 // implementation
128 // ===========================================================================
129
130 // ---------------------------------------------------------------------------
131 // wxDC
132 // ---------------------------------------------------------------------------
133
134 wxDC::wxDC(void)
135 {
136 m_pCanvas = NULL;
137
138 m_hOldBitmap = 0;
139 m_hOldPen = 0;
140 m_hOldBrush = 0;
141 m_hOldFont = 0;
142 m_hOldPalette = 0;
143
144 m_bOwnsDC = FALSE;
145 m_hDC = 0;
146 m_nDCCount = 0;
147 m_hOldPS = NULL;
148 m_hPS = NULL;
149 m_bIsPaintTime = FALSE;// True at Paint Time
150 };
151
152 wxDC::~wxDC(void)
153 {
154 // TODO:
155 };
156
157 // This will select current objects out of the DC,
158 // which is what you have to do before deleting the
159 // DC.
160 void wxDC::SelectOldObjects(WXHDC dc)
161 {
162 if (dc)
163 {
164 if (m_hOldBitmap)
165 {
166 // ::SelectObject((HDC) dc, (HBITMAP) m_oldBitmap);
167 if (m_vSelectedBitmap.Ok())
168 {
169 m_vSelectedBitmap.SetSelectedInto(NULL);
170 }
171 }
172 m_hOldBitmap = 0;
173 if (m_hOldPen)
174 {
175 // ::SelectObject((HDC) dc, (HPEN) m_oldPen);
176 }
177 m_hOldPen = 0;
178 if (m_hOldBrush)
179 {
180 // ::SelectObject((HDC) dc, (HBRUSH) m_oldBrush);
181 }
182 m_hOldBrush = 0;
183 if (m_hOldFont)
184 {
185 // ::SelectObject((HDC) dc, (HFONT) m_oldFont);
186 }
187 m_hOldFont = 0;
188 if (m_hOldPalette)
189 {
190 // ::SelectPalette((HDC) dc, (HPALETTE) m_oldPalette, TRUE);
191 }
192 m_hOldPalette = 0;
193 }
194
195 m_brush = wxNullBrush;
196 m_pen = wxNullPen;
197 m_palette = wxNullPalette;
198 m_font = wxNullFont;
199 m_backgroundBrush = wxNullBrush;
200 m_vSelectedBitmap = wxNullBitmap;
201 }
202
203 // ---------------------------------------------------------------------------
204 // clipping
205 // ---------------------------------------------------------------------------
206
207 #define DO_SET_CLIPPING_BOX() \
208 { \
209 RECT rect; \
210 \
211 GetClipBox(GetHdc(), &rect); \
212 \
213 m_clipX1 = (wxCoord) XDEV2LOG(rect.left); \
214 m_clipY1 = (wxCoord) YDEV2LOG(rect.top); \
215 m_clipX2 = (wxCoord) XDEV2LOG(rect.right); \
216 m_clipY2 = (wxCoord) YDEV2LOG(rect.bottom); \
217 }
218
219 void wxDC::DoSetClippingRegion( wxCoord x, wxCoord y
220 ,wxCoord width, wxCoord height
221 )
222 {
223 // TODO
224 }
225
226 void wxDC::DoSetClippingRegionAsRegion(const wxRegion& region)
227 {
228 // TODO
229 }
230
231 void wxDC::DestroyClippingRegion(void)
232 {
233 // TODO:
234 };
235
236 // ---------------------------------------------------------------------------
237 // query capabilities
238 // ---------------------------------------------------------------------------
239
240 bool wxDC::CanDrawBitmap() const
241 {
242 return TRUE;
243 }
244
245 bool wxDC::CanGetTextExtent() const
246 {
247 // What sort of display is it?
248 int technology = 0; // TODO: ::GetDeviceCaps(GetHdc(), TECHNOLOGY);
249
250 // TODO: return (technology == DT_RASDISPLAY) || (technology == DT_RASPRINTER);
251 return FALSE;
252 }
253
254 int wxDC::GetDepth() const
255 {
256 // TODO:
257 return (1);
258 }
259
260 // ---------------------------------------------------------------------------
261 // drawing
262 // ---------------------------------------------------------------------------
263
264 void wxDC::Clear()
265 {
266 // TODO
267 }
268
269 void wxDC::DoFloodFill(
270 wxCoord vX
271 , wxCoord vY
272 , const wxColour& rCol
273 , int nStyle
274 )
275 {
276 POINTL vPtlPos;
277 LONG lColor;
278 LONG lOptions;
279
280 vPtlPos.x = vX; // Loads x-coordinate
281 vPtlPos.y = vY; // Loads y-coordinate
282 ::GpiMove(m_hPS, &vPtlPos); // Sets current position
283 lColor = rCol.GetPixel();
284 lOptions = FF_BOUNDARY;
285 if(wxFLOOD_SURFACE == nStyle)
286 lOptions = FF_SURFACE;
287
288 ::GpiFloodFill(m_hPS, lOptions, lColor);
289 }
290
291 bool wxDC::DoGetPixel(
292 wxCoord vX
293 , wxCoord vY
294 , wxColour* pCol
295 ) const
296 {
297 POINTL vPoint;
298 LONG lColor;
299
300 vPoint.x = vX;
301 vPoint.y = vY;
302 lColor = ::GpiSetPel(m_hPS, &vPoint);
303 *pCol = lColor;
304 if(lColor>= 0)
305 return(TRUE);
306 else
307 return(FALSE);
308 }
309
310 void wxDC::DoCrossHair(wxCoord x, wxCoord y)
311 {
312 // TODO
313 }
314
315 void wxDC::DoDrawLine(
316 wxCoord vX1
317 , wxCoord vY1
318 , wxCoord vX2
319 , wxCoord vY2
320 )
321 {
322 POINTL vPoint[2];
323
324 vPoint[0].x = vX1;
325 vPoint[0].y = vY1;
326 vPoint[1].x = vX2;
327 vPoint[1].y = vY2;
328 // ::GpiSetColor(m_hPS,CLR_RED); //DEbug
329 ::GpiMove(m_hPS, &vPoint[0]);
330 ::GpiLine(m_hPS, &vPoint[1]);
331 }
332
333 //////////////////////////////////////////////////////////////////////////////
334 // Draws an arc of a circle, centred on (xc, yc), with starting point (x1, y1)
335 // and ending at (x2, y2). The current pen is used for the outline and the
336 // current brush for filling the shape. The arc is drawn in an anticlockwise
337 // direction from the start point to the end point.
338 //////////////////////////////////////////////////////////////////////////////
339 void wxDC::DoDrawArc(
340 wxCoord vX1
341 , wxCoord vY1
342 , wxCoord vX2
343 , wxCoord vY2
344 , wxCoord vXc
345 , wxCoord vYc
346 )
347 {
348 POINTL vPtlPos;
349 POINTL vPtlArc[2]; // Structure for current position
350 int nDx;
351 int nDy;
352 double dRadius;
353 double dAngl1;
354 double dAngl2;
355 double dAnglmid;
356 wxCoord vXm;
357 wxCoord vYm;
358 ARCPARAMS vArcp; // Structure for arc parameters
359
360 if((vX1 == vXc && vY1 == vXc) || (vX2 == vXc && vY2 == vXc))
361 return; // Draw point ??
362 dRadius = 0.5 * ( hypot( (double)(vY1 - vYc)
363 ,(double)(vX1 - vXc)
364 ) +
365 hypot( (double)(vY2 - vYc)
366 ,(double)(vX2 - vXc)
367 )
368 );
369
370 dAngl1 = atan2( (double)(vY1 - vYc)
371 ,(double)(vX1 - vXc)
372 );
373 dAngl2 = atan2( (double)(vY2 - vYc)
374 ,(double)(vX2 - vXc)
375 );
376 if(dAngl2 < dAngl1)
377 dAngl2 += M_PI * 2;
378
379 //
380 // GpiPointArc can't draw full arc
381 //
382 if(dAngl2 == dAngl1 || (vX1 == vX2 && vY1 == vY2) )
383 {
384 //
385 // Medium point
386 //
387 dAnglmid = (dAngl1 + dAngl2)/2. + M_PI;
388 vXm = vXc + dRadius * cos(dAnglmid);
389 vYm = vYc + dRadius * sin(dAnglmid);
390 DoDrawArc( vX1
391 ,vY1
392 ,vXm
393 ,vYm
394 ,vXc
395 ,vYc
396 );
397 DoDrawArc( vXm
398 ,vYm
399 ,vX2
400 ,vY2
401 ,vXc
402 ,vYc
403 );
404 return;
405 }
406
407 //
408 // Medium point
409 //
410 dAnglmid = (dAngl1 + dAngl2)/2.;
411 vXm = vXc + dRadius * cos(dAnglmid);
412 vYm = vYc + dRadius * sin(dAnglmid);
413
414 //
415 // Ellipse main axis (r,q), (p,s) with center at (0,0) */
416 //
417 vArcp.lR = 0;
418 vArcp.lQ = 1;
419 vArcp.lP = 1;
420 vArcp.lS = 0;
421 ::GpiSetArcParams(m_hPS, &vArcp); // Sets parameters to default
422
423 vPtlPos.x = vX1; // Loads x-coordinate
424 vPtlPos.y = vY1; // Loads y-coordinate
425 ::GpiMove(m_hPS, &vPtlPos); // Sets current position
426 vPtlArc[0].x = vXm;
427 vPtlArc[0].y = vYm;
428 vPtlArc[1].x = vX2;
429 vPtlArc[1].y = vY2;
430 ::GpiPointArc(m_hPS, vPtlArc); // Draws the arc
431 }
432
433 void wxDC::DoDrawCheckMark(
434 wxCoord vX1
435 , wxCoord vY1
436 , wxCoord vWidth
437 , wxCoord vHeight
438 )
439 {
440 POINTL vPoint[2];
441
442 vPoint[0].x = vX1;
443 vPoint[0].y = vY1;
444 vPoint[1].x = vX1 + vWidth;
445 vPoint[1].y = vY1 + vHeight;
446
447 ::GpiMove(m_hPS, &vPoint[0]);
448 ::GpiBox( m_hPS // handle to a presentation space
449 ,DRO_OUTLINE // draw the box outline ? or ?
450 ,&vPoint[1] // address of the corner
451 ,0L // horizontal corner radius
452 ,0L // vertical corner radius
453 );
454 if(vWidth > 4 && vHeight > 4)
455 {
456 int nTmp;
457
458 vPoint[0].x += 2; vPoint[0].y += 2;
459 vPoint[1].x -= 2; vPoint[1].y -= 2;
460 ::GpiMove(m_hPS, &vPoint[0]);
461 ::GpiLine(m_hPS, &vPoint[1]);
462 nTmp = vPoint[0].x;
463 vPoint[0].x = vPoint[1].x;
464 vPoint[1].x = nTmp;
465 ::GpiMove(m_hPS, &vPoint[0]);
466 ::GpiLine(m_hPS, &vPoint[1]);
467 }
468 }
469
470 void wxDC::DoDrawPoint(
471 wxCoord vX
472 , wxCoord vY
473 )
474 {
475 POINTL vPoint;
476
477 vPoint.x = vX;
478 vPoint.y = vY;
479 ::GpiSetPel(m_hPS, &vPoint);
480 }
481
482 void wxDC::DoDrawPolygon(
483 int n
484 , wxPoint vPoints[]
485 , wxCoord vXoffset
486 , wxCoord vYoffset
487 , int nFillStyle
488 )
489 {
490 ULONG ulCount = 1; // Number of polygons.
491 POLYGON vPlgn; // polygon.
492 ULONG flOptions = 0L; // Drawing options.
493
494 //////////////////////////////////////////////////////////////////////////////
495 // This contains fields of option bits... to draw boundary lines as well as
496 // the area interior.
497 //
498 // Drawing boundary lines:
499 // POLYGON_NOBOUNDARY Does not draw boundary lines.
500 // POLYGON_BOUNDARY Draws boundary lines (the default).
501 //
502 // Construction of the area interior:
503 // POLYGON_ALTERNATE Constructs interior in alternate mode
504 // (the default).
505 // POLYGON_WINDING Constructs interior in winding mode.
506 //////////////////////////////////////////////////////////////////////////////
507
508 ULONG flModel = 0L; // Drawing model.
509
510 //////////////////////////////////////////////////////////////////////////////
511 // Drawing model.
512 // POLYGON_INCL Fill is inclusive of bottom right (the default).
513 // POLYGON_EXCL Fill is exclusive of bottom right.
514 // This is provided to aid migration from other graphics models.
515 //////////////////////////////////////////////////////////////////////////////
516
517 LONG lHits = 0L; // Correlation/error indicator.
518 POINTL vPoint;
519 int i;
520 int nIsTRANSPARENT = 0;
521 LONG lBorderColor = 0L;
522 LONG lColor = 0L;
523
524 lBorderColor = m_pen.GetColour().GetPixel();
525 lColor = m_brush.GetColour().GetPixel();
526 if(m_brush.GetStyle() == wxTRANSPARENT)
527 nIsTRANSPARENT = 1;
528
529 vPlgn.ulPoints = n;
530 vPlgn.aPointl = (POINTL*) calloc( n + 1
531 ,sizeof(POINTL)
532 ); // well, new will call malloc
533
534 for(i = 0; i < n; i++)
535 {
536 vPlgn.aPointl[i].x = vPoints[i].x; // +xoffset;
537 vPlgn.aPointl[i].y = vPoints[i].y; // +yoffset;
538 }
539 flModel = POLYGON_BOUNDARY;
540 if(nFillStyle == wxWINDING_RULE)
541 flModel |= POLYGON_WINDING;
542 else
543 flModel |= POLYGON_ALTERNATE;
544
545 vPoint.x = vXoffset;
546 vPoint.y = vYoffset;
547
548 ::GpiSetColor(m_hPS, lBorderColor);
549 ::GpiMove(m_hPS, &vPoint);
550 lHits = ::GpiPolygons(m_hPS, ulCount, &vPlgn, flOptions, flModel);
551 free(vPlgn.aPointl);
552 }
553
554 void wxDC::DoDrawLines(
555 int n
556 , wxPoint vPoints[]
557 , wxCoord vXoffset
558 , wxCoord vYoffset
559 )
560 {
561 int i;
562 POINTL vPoint;
563
564 vPoint.x = vPoints[0].x + vXoffset;
565 vPoint.y = vPoints[0].y + vYoffset;
566 ::GpiMove(m_hPS, &vPoint);
567
568 LONG lBorderColor = m_pen.GetColour().GetPixel();
569
570 ::GpiSetColor(m_hPS, lBorderColor);
571 for(i = 1; i < n; i++)
572 {
573 vPoint.x = vPoints[0].x + vXoffset;
574 vPoint.y = vPoints[0].y + vYoffset;
575 ::GpiLine(m_hPS, &vPoint);
576 }
577 }
578
579 void wxDC::DoDrawRectangle(
580 wxCoord vX
581 , wxCoord vY
582 , wxCoord vWidth
583 , wxCoord vHeight
584 )
585 {
586 POINTL vPoint[2];
587 LONG lControl;
588 LONG lColor;
589 LONG lBorderColor;
590 int nIsTRANSPARENT = 0;
591
592 vPoint[0].x = vX;
593 vPoint[0].y = vY;
594 vPoint[1].x = vX + vWidth;
595 vPoint[1].y = vY - vHeight; //mustdie !!! ??
596 ::GpiMove(m_hPS, &vPoint[0]);
597 lColor = m_brush.GetColour().GetPixel();
598 lBorderColor = m_pen.GetColour().GetPixel();
599 if (m_brush.GetStyle() == wxTRANSPARENT)
600 nIsTRANSPARENT = 1;
601 if(lColor == lBorderColor || nIsTRANSPARENT)
602 {
603 lControl = DRO_OUTLINEFILL; //DRO_FILL;
604 if(m_brush.GetStyle() == wxTRANSPARENT)
605 lControl = DRO_OUTLINE;
606
607 //EK ::GpiSetColor(m_hPS,lBorderColor);
608 ::GpiSetColor(m_hPS,CLR_GREEN);
609 ::GpiBox( m_hPS // handle to a presentation space
610 ,lControl // draw the box outline ? or ?
611 ,&vPoint[1] // address of the corner
612 ,0L // horizontal corner radius
613 ,0L // vertical corner radius
614 );
615 }
616 else
617 {
618 lControl = DRO_OUTLINE;
619 ::GpiSetColor( m_hPS
620 ,lBorderColor
621 );
622 ::GpiBox( m_hPS
623 ,lControl
624 ,&vPoint[1]
625 ,0L
626 ,0L
627 );
628 lControl = DRO_FILL;
629 ::GpiSetColor( m_hPS
630 ,lColor
631 );
632 ::GpiBox( m_hPS
633 ,lControl
634 ,&vPoint[1]
635 ,0L
636 ,0L
637 );
638 }
639 }
640
641 void wxDC::DoDrawRoundedRectangle(
642 wxCoord vX
643 , wxCoord vY
644 , wxCoord vWidth
645 , wxCoord vHeight
646 , double dRadius
647 )
648 {
649 POINTL vPoint[2];
650 LONG lControl;
651
652 vPoint[0].x = vX;
653 vPoint[0].y = vY;
654 vPoint[1].x = vX + vWidth;
655 vPoint[1].y = vY + vHeight;
656 ::GpiMove(m_hPS, &vPoint[0]);
657
658 lControl = DRO_OUTLINEFILL; //DRO_FILL;
659 if (m_brush.GetStyle() == wxTRANSPARENT)
660 lControl = DRO_OUTLINE;
661 ::GpiBox( m_hPS // handle to a presentation space
662 ,DRO_OUTLINE // draw the box outline ? or ?
663 ,&vPoint[1] // address of the corner
664 ,(LONG)dRadius // horizontal corner radius
665 ,(LONG)dRadius // vertical corner radius
666 );
667 }
668
669 // Draw Ellipse within box (x,y) - (x+width, y+height)
670 void wxDC::DoDrawEllipse(
671 wxCoord vX
672 , wxCoord vY
673 , wxCoord vWidth
674 , wxCoord vHeight
675 )
676 {
677 POINTL vPtlPos; // Structure for current position
678 FIXED vFxMult; // Multiplier for ellipse
679 ARCPARAMS vArcp; // Structure for arc parameters
680
681 vArcp.lR = 0;
682 vArcp.lQ = vHeight/2;
683 vArcp.lP = vWidth/2;
684 vArcp.lS = 0;
685 ::GpiSetArcParams( m_hPS
686 ,&vArcp
687 ); // Sets parameters to default
688 vPtlPos.x = vX + vWidth/2; // Loads x-coordinate
689 vPtlPos.y = vY + vHeight/2; // Loads y-coordinate
690 ::GpiMove( m_hPS
691 ,&vPtlPos
692 ); // Sets current position
693 vFxMult = MAKEFIXED(1, 0); /* Sets multiplier */
694
695 //
696 // DRO_FILL, DRO_OTLINEFILL - where to get
697 //
698 ::GpiFullArc( m_hPS
699 ,DRO_OUTLINE
700 ,vFxMult
701 ); // Draws full arc with center at current position
702 }
703
704 void wxDC::DoDrawEllipticArc(
705 wxCoord vX
706 , wxCoord vY
707 , wxCoord vWidth
708 , wxCoord vHeight
709 , double dSa
710 , double dEa
711 )
712 {
713 POINTL vPtlPos; // Structure for current position
714 FIXED vFxMult; // Multiplier for ellipse
715 ARCPARAMS vArcp; // Structure for arc parameters
716 FIXED vFSa;
717 FIXED vFSweepa; // Start angle, sweep angle
718 double dIntPart;
719 double dFractPart;
720 double dRadius;
721
722 dFractPart = modf(dSa,&dIntPart);
723 vFSa = MAKEFIXED((int)dIntPart, (int)(dFractPart * 0xffff) );
724 dFractPart = modf(dEa - dSa, &dIntPart);
725 vFSweepa = MAKEFIXED((int)dIntPart, (int)(dFractPart * 0xffff) );
726
727 //
728 // Ellipse main axis (r,q), (p,s) with center at (0,0)
729 //
730 vArcp.lR = 0;
731 vArcp.lQ = vHeight/2;
732 vArcp.lP = vWidth/2;
733 vArcp.lS = 0;
734 ::GpiSetArcParams(m_hPS, &vArcp); // Sets parameters to default
735 vPtlPos.x = vX + vWidth/2 * (1. + cos(DegToRad(dSa))); // Loads x-coordinate
736 vPtlPos.y = vY + vHeight/2 * (1. + sin(DegToRad(dSa))); // Loads y-coordinate
737 ::GpiMove(m_hPS, &vPtlPos); // Sets current position
738
739 //
740 // May be not to the center ?
741 //
742 vPtlPos.x = vX + vWidth/2 ; // Loads x-coordinate
743 vPtlPos.y = vY + vHeight/2; // Loads y-coordinate
744 vFxMult = MAKEFIXED(1, 0); // Sets multiplier
745
746 //
747 // DRO_FILL, DRO_OTLINEFILL - where to get
748 //
749 ::GpiPartialArc( m_hPS
750 ,&vPtlPos
751 ,vFxMult
752 ,vFSa
753 ,vFSweepa
754 );
755 }
756
757 void wxDC::DoDrawIcon(const wxIcon& icon, wxCoord x, wxCoord y)
758 {
759 // TODO:
760 }
761
762 void wxDC::DoDrawBitmap( const wxBitmap &bmp
763 ,wxCoord x, wxCoord y
764 ,bool useMask
765 )
766 {
767 // TODO
768 }
769
770 void wxDC::DoDrawText(
771 const wxString& rsText
772 , wxCoord vX
773 , wxCoord vY
774 )
775 {
776 DrawAnyText( rsText
777 ,vX
778 ,vY
779 );
780 }
781
782 void wxDC::DrawAnyText(
783 const wxString& rsText
784 , wxCoord vX
785 , wxCoord vY
786 )
787 {
788 int nOldBackground = 0;
789 POINTL vPtlStart;
790 LONG lHits;
791
792 //
793 // prepare for drawing the text
794 //
795
796 //
797 // Set text color attributes
798 //
799 if (m_textForegroundColour.Ok())
800 {
801 SetTextColor( m_hPS
802 ,(int)m_textForegroundColour.GetPixel()
803 );
804 }
805
806 if (m_textBackgroundColour.Ok())
807 {
808 nOldBackground = SetTextBkColor( m_hPS
809 ,(int)m_textBackgroundColour.GetPixel()
810 );
811 }
812 SetBkMode( m_hPS
813 ,m_backgroundMode
814 );
815 vPtlStart.x = vX;
816 vPtlStart.y = vY;
817
818 lHits = ::GpiCharStringAt( m_hPS
819 ,&vPtlStart
820 ,rsText.length()
821 ,(PCH)rsText.c_str()
822 );
823 if (lHits != GPI_OK)
824 {
825 wxLogLastError(wxT("TextOut"));
826 }
827
828 //
829 // Restore the old parameters (text foreground colour may be left because
830 // it never is set to anything else, but background should remain
831 // transparent even if we just drew an opaque string)
832 //
833 if (m_textBackgroundColour.Ok())
834 SetTextBkColor( m_hPS
835 ,nOldBackground
836 );
837 SetBkMode( m_hPS
838 ,wxTRANSPARENT
839 );
840 }
841
842 void wxDC::DoDrawRotatedText(
843 const wxString& rsText
844 , wxCoord vX
845 , wxCoord vY
846 , double dAngle
847 )
848 {
849 if (dAngle == 0.0)
850 {
851 DoDrawText( rsText
852 ,vX
853 ,vY
854 );
855 }
856
857 // TODO:
858 /*
859 if ( angle == 0.0 )
860 {
861 DoDrawText(text, x, y);
862 }
863 else
864 {
865 LOGFONT lf;
866 wxFillLogFont(&lf, &m_font);
867
868 // GDI wants the angle in tenth of degree
869 long angle10 = (long)(angle * 10);
870 lf.lfEscapement = angle10;
871 lf. lfOrientation = angle10;
872
873 HFONT hfont = ::CreateFontIndirect(&lf);
874 if ( !hfont )
875 {
876 wxLogLastError("CreateFont");
877 }
878 else
879 {
880 HFONT hfontOld = ::SelectObject(GetHdc(), hfont);
881
882 DrawAnyText(text, x, y);
883
884 (void)::SelectObject(GetHdc(), hfontOld);
885 }
886
887 // call the bounding box by adding all four vertices of the rectangle
888 // containing the text to it (simpler and probably not slower than
889 // determining which of them is really topmost/leftmost/...)
890 wxCoord w, h;
891 GetTextExtent(text, &w, &h);
892
893 double rad = DegToRad(angle);
894
895 // "upper left" and "upper right"
896 CalcBoundingBox(x, y);
897 CalcBoundingBox(x + w*cos(rad), y - h*sin(rad));
898 CalcBoundingBox(x + h*sin(rad), y + h*cos(rad));
899
900 // "bottom left" and "bottom right"
901 x += (wxCoord)(h*sin(rad));
902 y += (wxCoord)(h*cos(rad));
903 CalcBoundingBox(x, y);
904 CalcBoundingBox(x + h*sin(rad), y + h*cos(rad));
905 }
906 */
907 }
908
909 // ---------------------------------------------------------------------------
910 // set GDI objects
911 // ---------------------------------------------------------------------------
912
913 void wxDC::SetPalette(const wxPalette& palette)
914 {
915 // TODO
916 }
917
918 void wxDC::SetFont(
919 const wxFont& rFont
920 )
921 {
922 //
923 // Set the old object temporarily, in case the assignment deletes an object
924 // that's not yet selected out.
925 //
926 if (m_hOldFont)
927 {
928 // ::SelectObject(GetHdc(), (HFONT) m_hOldFont);
929 m_hOldFont = 0;
930 }
931
932 m_font = rFont;
933
934 if (!rFont.Ok())
935 {
936 if (m_hOldFont)
937 // ::SelectObject(GetHdc(), (HFONT) m_hOldFont);
938 m_hOldFont = 0;
939 }
940
941 if (m_font.Ok() && m_font.GetResourceHandle())
942 {
943 HFONT hFont = (HFONT)0; //::SelectObject(GetHdc(), (HFONT) m_font.GetResourceHandle());
944 if (hFont == (HFONT) NULL)
945 {
946 wxLogDebug(wxT("::SelectObject failed in wxDC::SetFont."));
947 }
948 if (!m_hOldFont)
949 m_hOldFont = (WXHFONT) hFont;
950 }
951 }
952
953 void wxDC::SetPen(
954 const wxPen& rPen
955 )
956 {
957 wxCHECK_RET( Ok(), wxT("invalid window dc") );
958
959 if (m_pen == rPen)
960 return;
961 m_pen = rPen;
962 if (!m_pen.Ok())
963 return;
964
965 int nWidth = m_pen.GetWidth();
966
967 if (nWidth <= 0)
968 {
969 nWidth = 1;
970 }
971 else
972 {
973 double dW = 0.5 +
974 ( fabs((double) XLOG2DEVREL(nWidth)) +
975 fabs((double) YLOG2DEVREL(nWidth))
976 ) / 2.0;
977 nWidth = (int)dW;
978 }
979 wxColour vColor = m_pen.GetColour();
980
981 ::GpiSetColor( m_hPS
982 ,vColor.GetPixel()
983 ); //DEbug ??
984
985 int nLinetype;
986 int nStyle = m_pen.GetStyle();
987
988 nLinetype = LINETYPE_DEFAULT;
989 switch(nStyle)
990 {
991 case wxDOT:
992 nLinetype = LINETYPE_DOT;
993 break;
994
995 case wxLONG_DASH:
996 nLinetype = LINETYPE_LONGDASH;
997 break;
998
999 case wxSHORT_DASH:
1000 nLinetype = LINETYPE_SHORTDASH;
1001 break;
1002
1003 case wxDOT_DASH:
1004 nLinetype = LINETYPE_DASHDOT;
1005 break;
1006
1007 case wxTRANSPARENT:
1008 nLinetype = LINETYPE_INVISIBLE;
1009 break;
1010
1011 case wxSOLID:
1012 nLinetype = LINETYPE_SOLID;
1013 break;
1014 }
1015 ::GpiSetLineType( m_hPS
1016 ,nLinetype
1017 );
1018
1019 nWidth = m_pen.GetWidth();
1020 ::GpiSetLineWidth( m_hPS
1021 ,MAKEFIXED( nWidth
1022 ,0
1023 )
1024 );
1025 }
1026
1027 void wxDC::SetBrush(
1028 const wxBrush& rBrush
1029 )
1030 {
1031 // TODO
1032 }
1033
1034 void wxDC::SetBackground(const wxBrush& brush)
1035 {
1036 // TODO
1037 }
1038
1039 void wxDC::SetBackgroundMode(
1040 int nMode
1041 )
1042 {
1043 m_backgroundMode = nMode;
1044 }
1045
1046 void wxDC::SetLogicalFunction(int function)
1047 {
1048 // TODO
1049 }
1050
1051 void wxDC::SetRop(WXHDC dc)
1052 {
1053 if (!dc || m_logicalFunction < 0)
1054 return;
1055
1056 int c_rop;
1057 // These may be wrong
1058 switch (m_logicalFunction)
1059 {
1060 // TODO: Figure this stuff out
1061 // case wxXOR: c_rop = R2_XORPEN; break;
1062 // case wxXOR: c_rop = R2_NOTXORPEN; break;
1063 // case wxINVERT: c_rop = R2_NOT; break;
1064 // case wxOR_REVERSE: c_rop = R2_MERGEPENNOT; break;
1065 // case wxAND_REVERSE: c_rop = R2_MASKPENNOT; break;
1066 // case wxCLEAR: c_rop = R2_WHITE; break;
1067 // case wxSET: c_rop = R2_BLACK; break;
1068 // case wxSRC_INVERT: c_rop = R2_NOTCOPYPEN; break;
1069 // case wxOR_INVERT: c_rop = R2_MERGENOTPEN; break;
1070 // case wxAND: c_rop = R2_MASKPEN; break;
1071 // case wxOR: c_rop = R2_MERGEPEN; break;
1072 // case wxAND_INVERT: c_rop = R2_MASKNOTPEN; break;
1073 // case wxEQUIV:
1074 // case wxNAND:
1075 // case wxCOPY:
1076 default:
1077 // c_rop = R2_COPYPEN;
1078 break;
1079 }
1080 // SetROP2((HDC) dc, c_rop);
1081 }
1082
1083 bool wxDC::StartDoc(const wxString& message)
1084 {
1085 // We might be previewing, so return TRUE to let it continue.
1086 return TRUE;
1087 }
1088
1089 void wxDC::EndDoc()
1090 {
1091 }
1092
1093 void wxDC::StartPage()
1094 {
1095 }
1096
1097 void wxDC::EndPage()
1098 {
1099 }
1100
1101 // ---------------------------------------------------------------------------
1102 // text metrics
1103 // ---------------------------------------------------------------------------
1104
1105 wxCoord wxDC::GetCharHeight() const
1106 {
1107 // TODO
1108 return(8);
1109 }
1110
1111 wxCoord wxDC::GetCharWidth() const
1112 {
1113 // TODO
1114 return(8);
1115 }
1116
1117 void wxDC::DoGetTextExtent(
1118 const wxString& rsString
1119 , wxCoord* pvX
1120 , wxCoord* pvY
1121 , wxCoord* pvDescent
1122 , wxCoord* pvExternalLeading
1123 , wxFont* pTheFont
1124 ) const
1125 {
1126 POINTL avPoint[TXTBOX_COUNT];
1127 POINTL vPtMin;
1128 POINTL vPtMax;
1129 int i;
1130 int l;
1131 FONTMETRICS vFM; // metrics structure
1132 BOOL bRc;
1133 char* pStr;
1134 ERRORID vErrorCode; // last error id code
1135 wxFont* pFontToUse = (wxFont*)pTheFont;
1136
1137 if (!pFontToUse)
1138 pFontToUse = (wxFont*)&m_font;
1139 l = rsString.length();
1140 pStr = (PCH) rsString.c_str();
1141
1142 //
1143 // In world coordinates.
1144 //
1145 bRc = ::GpiQueryTextBox( m_hPS
1146 ,l
1147 ,pStr
1148 ,TXTBOX_COUNT // return maximum information
1149 ,avPoint // array of coordinates points
1150 );
1151 if(!bRc)
1152 {
1153 vErrorCode = ::WinGetLastError(wxGetInstance());
1154 }
1155
1156 vPtMin.x = avPoint[0].x;
1157 vPtMax.x = avPoint[0].x;
1158 vPtMin.y = avPoint[0].y;
1159 vPtMax.y = avPoint[0].y;
1160 for (i = 1; i < 4; i++)
1161 {
1162 if(vPtMin.x > avPoint[i].x) vPtMin.x = avPoint[i].x;
1163 if(vPtMin.y > avPoint[i].y) vPtMin.y = avPoint[i].y;
1164 if(vPtMax.x < avPoint[i].x) vPtMax.x = avPoint[i].x;
1165 if(vPtMax.y < avPoint[i].y) vPtMax.y = avPoint[i].y;
1166 }
1167 ::GpiQueryFontMetrics( m_hPS
1168 ,sizeof(FONTMETRICS)
1169 ,&vFM
1170 );
1171
1172 if (pvX)
1173 *pvX = (wxCoord)(vPtMax.x - vPtMin.x + 1);
1174 if (pvY)
1175 *pvY = (wxCoord)(vPtMax.y - vPtMin.y + 1);
1176 if (pvDescent)
1177 *pvDescent = vFM.lMaxDescender;
1178 if (pvExternalLeading)
1179 *pvExternalLeading = vFM.lExternalLeading;
1180 }
1181
1182 void wxDC::SetMapMode( int mode )
1183 {
1184 // TODO:
1185 };
1186
1187 void wxDC::SetUserScale(double x, double y)
1188 {
1189 m_userScaleX = x;
1190 m_userScaleY = y;
1191
1192 SetMapMode(m_mappingMode);
1193 }
1194
1195 void wxDC::SetAxisOrientation(bool xLeftRight, bool yBottomUp)
1196 {
1197 m_signX = xLeftRight ? 1 : -1;
1198 m_signY = yBottomUp ? -1 : 1;
1199
1200 SetMapMode(m_mappingMode);
1201 }
1202
1203 void wxDC::SetSystemScale(double x, double y)
1204 {
1205 m_scaleX = x;
1206 m_scaleY = y;
1207
1208 SetMapMode(m_mappingMode);
1209 }
1210
1211 void wxDC::SetLogicalOrigin( wxCoord x, wxCoord y )
1212 {
1213 // TODO:
1214 };
1215
1216 void wxDC::SetDeviceOrigin( wxCoord x, wxCoord y )
1217 {
1218 // TODO:
1219 };
1220
1221 // ---------------------------------------------------------------------------
1222 // coordinates transformations
1223 // ---------------------------------------------------------------------------
1224
1225 wxCoord wxDCBase::DeviceToLogicalX(wxCoord x) const
1226 {
1227 return (wxCoord) (((x) - m_deviceOriginX)/(m_logicalScaleX*m_userScaleX*m_signX*m_scaleX) - m_logicalOriginX);
1228 }
1229
1230 wxCoord wxDCBase::DeviceToLogicalXRel(wxCoord x) const
1231 {
1232 return (wxCoord) ((x)/(m_logicalScaleX*m_userScaleX*m_signX*m_scaleX));
1233 }
1234
1235 wxCoord wxDCBase::DeviceToLogicalY(wxCoord y) const
1236 {
1237 return (wxCoord) (((y) - m_deviceOriginY)/(m_logicalScaleY*m_userScaleY*m_signY*m_scaleY) - m_logicalOriginY);
1238 }
1239
1240 wxCoord wxDCBase::DeviceToLogicalYRel(wxCoord y) const
1241 {
1242 return (wxCoord) ((y)/(m_logicalScaleY*m_userScaleY*m_signY*m_scaleY));
1243 }
1244
1245 wxCoord wxDCBase::LogicalToDeviceX(wxCoord x) const
1246 {
1247 return (wxCoord) ((x - m_logicalOriginX)*m_logicalScaleX*m_userScaleX*m_signX*m_scaleX + m_deviceOriginX);
1248 }
1249
1250 wxCoord wxDCBase::LogicalToDeviceXRel(wxCoord x) const
1251 {
1252 return (wxCoord) (x*m_logicalScaleX*m_userScaleX*m_signX*m_scaleX);
1253 }
1254
1255 wxCoord wxDCBase::LogicalToDeviceY(wxCoord y) const
1256 {
1257 return (wxCoord) ((y - m_logicalOriginY)*m_logicalScaleY*m_userScaleY*m_signY*m_scaleY + m_deviceOriginY);
1258 }
1259
1260 wxCoord wxDCBase::LogicalToDeviceYRel(wxCoord y) const
1261 {
1262 return (wxCoord) (y*m_logicalScaleY*m_userScaleY*m_signY*m_scaleY);
1263 }
1264
1265 // ---------------------------------------------------------------------------
1266 // bit blit
1267 // ---------------------------------------------------------------------------
1268
1269 bool wxDC::DoBlit( wxCoord xdest
1270 ,wxCoord ydest
1271 ,wxCoord width
1272 ,wxCoord height
1273 ,wxDC *source
1274 ,wxCoord xsrc
1275 ,wxCoord ysrc
1276 ,int rop
1277 ,bool useMask
1278 )
1279 {
1280 // TODO
1281 return(TRUE);
1282 }
1283
1284 void wxDC::DoGetSize( int* width, int* height ) const
1285 {
1286 // TODO:
1287 };
1288
1289 void wxDC::DoGetSizeMM( int* width, int* height ) const
1290 {
1291 // TODO:
1292 };
1293
1294 wxSize wxDC::GetPPI() const
1295 {
1296 int x = 1;
1297 int y = 1;
1298 // TODO:
1299 return (wxSize(x,y));
1300 }
1301
1302 void wxDC::SetLogicalScale( double x, double y )
1303 {
1304 // TODO:
1305 };
1306
1307 #if WXWIN_COMPATIBILITY
1308 void wxDC::DoGetTextExtent(const wxString& string, float *x, float *y,
1309 float *descent, float *externalLeading,
1310 wxFont *theFont, bool use16bit) const
1311 {
1312 wxCoord x1, y1, descent1, externalLeading1;
1313 GetTextExtent(string, & x1, & y1, & descent1, & externalLeading1, theFont, use16bit);
1314 *x = x1; *y = y1;
1315 if (descent)
1316 *descent = descent1;
1317 if (externalLeading)
1318 *externalLeading = externalLeading1;
1319 }
1320 #endif
1321
1322 // ---------------------------------------------------------------------------
1323 // spline drawing code
1324 // ---------------------------------------------------------------------------
1325
1326 #if wxUSE_SPLINES
1327
1328 class wxSpline: public wxObject
1329 {
1330 public:
1331 int type;
1332 wxList *points;
1333
1334 wxSpline(wxList *list);
1335 void DeletePoints();
1336
1337 // Doesn't delete points
1338 ~wxSpline();
1339 };
1340
1341 void wx_draw_open_spline(wxDC *dc, wxSpline *spline);
1342
1343 void wx_quadratic_spline(double a1, double b1, double a2, double b2,
1344 double a3, double b3, double a4, double b4);
1345 void wx_clear_stack();
1346 int wx_spline_pop(double *x1, double *y1, double *x2, double *y2, double *x3,
1347 double *y3, double *x4, double *y4);
1348 void wx_spline_push(double x1, double y1, double x2, double y2, double x3, double y3,
1349 double x4, double y4);
1350 static bool wx_spline_add_point(double x, double y);
1351 static void wx_spline_draw_point_array(wxDC *dc);
1352 wxSpline *wx_make_spline(int x1, int y1, int x2, int y2, int x3, int y3);
1353
1354 void wxDC::DoDrawSpline(wxList *list)
1355 {
1356 wxSpline spline(list);
1357
1358 wx_draw_open_spline(this, &spline);
1359 }
1360
1361 wxList wx_spline_point_list;
1362
1363 void wx_draw_open_spline(wxDC *dc, wxSpline *spline)
1364 {
1365 wxPoint *p;
1366 double cx1, cy1, cx2, cy2, cx3, cy3, cx4, cy4;
1367 double x1, y1, x2, y2;
1368
1369 wxNode *node = spline->points->First();
1370 p = (wxPoint *)node->Data();
1371
1372 x1 = p->x;
1373 y1 = p->y;
1374
1375 node = node->Next();
1376 p = (wxPoint *)node->Data();
1377
1378 x2 = p->x;
1379 y2 = p->y;
1380 cx1 = (double)((x1 + x2) / 2);
1381 cy1 = (double)((y1 + y2) / 2);
1382 cx2 = (double)((cx1 + x2) / 2);
1383 cy2 = (double)((cy1 + y2) / 2);
1384
1385 wx_spline_add_point(x1, y1);
1386
1387 while ((node = node->Next()) != NULL)
1388 {
1389 p = (wxPoint *)node->Data();
1390 x1 = x2;
1391 y1 = y2;
1392 x2 = p->x;
1393 y2 = p->y;
1394 cx4 = (double)(x1 + x2) / 2;
1395 cy4 = (double)(y1 + y2) / 2;
1396 cx3 = (double)(x1 + cx4) / 2;
1397 cy3 = (double)(y1 + cy4) / 2;
1398
1399 wx_quadratic_spline(cx1, cy1, cx2, cy2, cx3, cy3, cx4, cy4);
1400
1401 cx1 = cx4;
1402 cy1 = cy4;
1403 cx2 = (double)(cx1 + x2) / 2;
1404 cy2 = (double)(cy1 + y2) / 2;
1405 }
1406
1407 wx_spline_add_point((double)wx_round(cx1), (double)wx_round(cy1));
1408 wx_spline_add_point(x2, y2);
1409
1410 wx_spline_draw_point_array(dc);
1411
1412 }
1413
1414 /********************* CURVES FOR SPLINES *****************************
1415
1416 The following spline drawing routine is from
1417
1418 "An Algorithm for High-Speed Curve Generation"
1419 by George Merrill Chaikin,
1420 Computer Graphics and Image Processing, 3, Academic Press,
1421 1974, 346-349.
1422
1423 and
1424
1425 "On Chaikin's Algorithm" by R. F. Riesenfeld,
1426 Computer Graphics and Image Processing, 4, Academic Press,
1427 1975, 304-310.
1428
1429 ***********************************************************************/
1430
1431 #define half(z1, z2) ((z1+z2)/2.0)
1432 #define THRESHOLD 5
1433
1434 /* iterative version */
1435
1436 void wx_quadratic_spline(double a1, double b1, double a2, double b2, double a3, double b3, double a4,
1437 double b4)
1438 {
1439 register double xmid, ymid;
1440 double x1, y1, x2, y2, x3, y3, x4, y4;
1441
1442 wx_clear_stack();
1443 wx_spline_push(a1, b1, a2, b2, a3, b3, a4, b4);
1444
1445 while (wx_spline_pop(&x1, &y1, &x2, &y2, &x3, &y3, &x4, &y4)) {
1446 xmid = (double)half(x2, x3);
1447 ymid = (double)half(y2, y3);
1448 if (fabs(x1 - xmid) < THRESHOLD && fabs(y1 - ymid) < THRESHOLD &&
1449 fabs(xmid - x4) < THRESHOLD && fabs(ymid - y4) < THRESHOLD) {
1450 wx_spline_add_point((double)wx_round(x1), (double)wx_round(y1));
1451 wx_spline_add_point((double)wx_round(xmid), (double)wx_round(ymid));
1452 } else {
1453 wx_spline_push(xmid, ymid, (double)half(xmid, x3), (double)half(ymid, y3),
1454 (double)half(x3, x4), (double)half(y3, y4), x4, y4);
1455 wx_spline_push(x1, y1, (double)half(x1, x2), (double)half(y1, y2),
1456 (double)half(x2, xmid), (double)half(y2, ymid), xmid, ymid);
1457 }
1458 }
1459 }
1460
1461
1462 /* utilities used by spline drawing routines */
1463
1464
1465 typedef struct wx_spline_stack_struct {
1466 double x1, y1, x2, y2, x3, y3, x4, y4;
1467 }
1468 Stack;
1469
1470 #define SPLINE_STACK_DEPTH 20
1471 static Stack wx_spline_stack[SPLINE_STACK_DEPTH];
1472 static Stack *wx_stack_top;
1473 static int wx_stack_count;
1474
1475 void wx_clear_stack()
1476 {
1477 wx_stack_top = wx_spline_stack;
1478 wx_stack_count = 0;
1479 }
1480
1481 void wx_spline_push(double x1, double y1, double x2, double y2, double x3, double y3, double x4, double y4)
1482 {
1483 wx_stack_top->x1 = x1;
1484 wx_stack_top->y1 = y1;
1485 wx_stack_top->x2 = x2;
1486 wx_stack_top->y2 = y2;
1487 wx_stack_top->x3 = x3;
1488 wx_stack_top->y3 = y3;
1489 wx_stack_top->x4 = x4;
1490 wx_stack_top->y4 = y4;
1491 wx_stack_top++;
1492 wx_stack_count++;
1493 }
1494
1495 int wx_spline_pop(double *x1, double *y1, double *x2, double *y2,
1496 double *x3, double *y3, double *x4, double *y4)
1497 {
1498 if (wx_stack_count == 0)
1499 return (0);
1500 wx_stack_top--;
1501 wx_stack_count--;
1502 *x1 = wx_stack_top->x1;
1503 *y1 = wx_stack_top->y1;
1504 *x2 = wx_stack_top->x2;
1505 *y2 = wx_stack_top->y2;
1506 *x3 = wx_stack_top->x3;
1507 *y3 = wx_stack_top->y3;
1508 *x4 = wx_stack_top->x4;
1509 *y4 = wx_stack_top->y4;
1510 return (1);
1511 }
1512
1513 static bool wx_spline_add_point(double x, double y)
1514 {
1515 wxPoint *point = new wxPoint;
1516 point->x = (int) x;
1517 point->y = (int) y;
1518 wx_spline_point_list.Append((wxObject*)point);
1519 return TRUE;
1520 }
1521
1522 static void wx_spline_draw_point_array(wxDC *dc)
1523 {
1524 dc->DrawLines(&wx_spline_point_list, 0, 0);
1525 wxNode *node = wx_spline_point_list.First();
1526 while (node)
1527 {
1528 wxPoint *point = (wxPoint *)node->Data();
1529 delete point;
1530 delete node;
1531 node = wx_spline_point_list.First();
1532 }
1533 }
1534
1535 wxSpline::wxSpline(wxList *list)
1536 {
1537 points = list;
1538 }
1539
1540 wxSpline::~wxSpline()
1541 {
1542 }
1543
1544 void wxSpline::DeletePoints()
1545 {
1546 for(wxNode *node = points->First(); node; node = points->First())
1547 {
1548 wxPoint *point = (wxPoint *)node->Data();
1549 delete point;
1550 delete node;
1551 }
1552 delete points;
1553 }
1554
1555
1556 #endif // wxUSE_SPLINES
1557