]> git.saurik.com Git - wxWidgets.git/blob - src/common/dcbase.cpp
114771cbb9ccfe6bcd29f2242d38e6d32512df07
[wxWidgets.git] / src / common / dcbase.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: dc.cpp
3 // Purpose: wxDC Class
4 // Author: Brian Macy
5 // Modified by:
6 // Created: 05/25/99
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart and Markus Holzem
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
11
12 #ifdef __GNUG__
13 #pragma implementation "dcbase.h"
14 #endif
15
16 // For compilers that support precompilation, includes "wx.h".
17 #include "wx/wxprec.h"
18
19 #ifdef __BORLANDC__
20 #pragma hdrstop
21 #endif
22
23 #ifndef WX_PRECOMP
24 #include "wx/window.h"
25 #include "wx/msw/private.h"
26 #endif
27
28 #include "wx/dc.h"
29
30 void wxDCBase::DrawLines(const wxList *list, long xoffset, long yoffset)
31 {
32 int n = list->Number();
33 wxPoint *points = new wxPoint[n];
34
35 int i = 0;
36 for ( wxNode *node = list->First(); node; node = node->Next(), i++ )
37 {
38 wxPoint *point = (wxPoint *)node->Data();
39 points[i].x = point->x;
40 points[i].y = point->y;
41 }
42
43 DoDrawLines(n, points, xoffset, yoffset);
44
45 delete [] points;
46 }
47
48
49 void wxDCBase::DrawPolygon(const wxList *list,
50 long xoffset, long yoffset,
51 int fillStyle)
52 {
53 int n = list->Number();
54 wxPoint *points = new wxPoint[n];
55
56 int i = 0;
57 for ( wxNode *node = list->First(); node; node = node->Next(), i++ )
58 {
59 wxPoint *point = (wxPoint *)node->Data();
60 points[i].x = point->x;
61 points[i].y = point->y;
62 }
63
64 DoDrawPolygon(n, points, xoffset, yoffset, fillStyle);
65
66 delete [] points;
67 }
68
69
70 #if wxUSE_SPLINES
71
72 // TODO: this API needs fixing (wxPointList, why (!const) "wxList *"?)
73 void wxDCBase::DrawSpline(long x1, long y1, long x2, long y2, long x3, long y3)
74 {
75 wxList point_list;
76
77 wxPoint *point1 = new wxPoint;
78 point1->x = x1; point1->y = y1;
79 point_list.Append((wxObject*)point1);
80
81 wxPoint *point2 = new wxPoint;
82 point2->x = x2; point2->y = y2;
83 point_list.Append((wxObject*)point2);
84
85 wxPoint *point3 = new wxPoint;
86 point3->x = x3; point3->y = y3;
87 point_list.Append((wxObject*)point3);
88
89 DrawSpline(&point_list);
90
91 for( wxNode *node = point_list.First(); node; node = node->Next() )
92 {
93 wxPoint *p = (wxPoint *)node->Data();
94 delete p;
95 }
96 }
97
98 void wxDCBase::DrawSpline(int n, wxPoint points[])
99 {
100 wxList list;
101 for (int i =0; i < n; i++)
102 {
103 list.Append((wxObject*)&points[i]);
104 }
105
106 DrawSpline(&list);
107 }
108
109 #endif // wxUSE_SPLINES