]>
Commit | Line | Data |
---|---|---|
dbe94982 BM |
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/defs.h" | |
25 | #endif | |
26 | ||
27 | #include "wx/dc.h" | |
28 | ||
29 | void wxDCBase::DrawLines(const wxList *list, long xoffset, long yoffset) | |
30 | { | |
31 | int n = list->Number(); | |
32 | wxPoint *points = new wxPoint[n]; | |
33 | ||
34 | int i = 0; | |
35 | for ( wxNode *node = list->First(); node; node = node->Next(), i++ ) | |
36 | { | |
37 | wxPoint *point = (wxPoint *)node->Data(); | |
38 | points[i].x = point->x; | |
39 | points[i].y = point->y; | |
40 | } | |
41 | ||
42 | DoDrawLines(n, points, xoffset, yoffset); | |
43 | ||
44 | delete [] points; | |
45 | } | |
46 | ||
47 | ||
48 | void wxDCBase::DrawPolygon(const wxList *list, | |
49 | long xoffset, long yoffset, | |
50 | int fillStyle) | |
51 | { | |
52 | int n = list->Number(); | |
53 | wxPoint *points = new wxPoint[n]; | |
54 | ||
55 | int i = 0; | |
56 | for ( wxNode *node = list->First(); node; node = node->Next(), i++ ) | |
57 | { | |
58 | wxPoint *point = (wxPoint *)node->Data(); | |
59 | points[i].x = point->x; | |
60 | points[i].y = point->y; | |
61 | } | |
62 | ||
63 | DoDrawPolygon(n, points, xoffset, yoffset, fillStyle); | |
64 | ||
65 | delete [] points; | |
66 | } | |
67 | ||
68 | ||
88ac883a | 69 | #if wxUSE_SPLINES |
dbe94982 BM |
70 | |
71 | // TODO: this API needs fixing (wxPointList, why (!const) "wxList *"?) | |
72 | void wxDCBase::DrawSpline(long x1, long y1, long x2, long y2, long x3, long y3) | |
73 | { | |
74 | wxList point_list; | |
75 | ||
76 | wxPoint *point1 = new wxPoint; | |
77 | point1->x = x1; point1->y = y1; | |
78 | point_list.Append((wxObject*)point1); | |
79 | ||
80 | wxPoint *point2 = new wxPoint; | |
81 | point2->x = x2; point2->y = y2; | |
82 | point_list.Append((wxObject*)point2); | |
83 | ||
84 | wxPoint *point3 = new wxPoint; | |
85 | point3->x = x3; point3->y = y3; | |
86 | point_list.Append((wxObject*)point3); | |
87 | ||
88 | DrawSpline(&point_list); | |
89 | ||
90 | for( wxNode *node = point_list.First(); node; node = node->Next() ) | |
91 | { | |
92 | wxPoint *p = (wxPoint *)node->Data(); | |
93 | delete p; | |
94 | } | |
95 | } | |
96 | ||
97 | void wxDCBase::DrawSpline(int n, wxPoint points[]) | |
98 | { | |
99 | wxList list; | |
100 | for (int i =0; i < n; i++) | |
101 | { | |
102 | list.Append((wxObject*)&points[i]); | |
103 | } | |
104 | ||
105 | DrawSpline(&list); | |
106 | } | |
107 | ||
88ac883a | 108 | #endif // wxUSE_SPLINES |