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