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$ | |
bd1e9c12 VZ |
8 | // Copyright: (c) wxWindows team |
9 | // Licence: wxWindows license | |
dbe94982 BM |
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__ | |
bd1e9c12 | 20 | #pragma hdrstop |
dbe94982 BM |
21 | #endif |
22 | ||
23 | #ifndef WX_PRECOMP | |
0c589ad0 | 24 | #include "wx/window.h" |
bd1e9c12 VZ |
25 | #endif |
26 | ||
dbf3cd7a | 27 | #ifdef __WXMSW__ |
0c589ad0 | 28 | #include "wx/msw/private.h" |
dbe94982 BM |
29 | #endif |
30 | ||
31 | #include "wx/dc.h" | |
32 | ||
cd9da200 VZ |
33 | void wxDCBase::DoDrawCheckMark(wxCoord x1, wxCoord y1, |
34 | wxCoord width, wxCoord height) | |
35 | { | |
36 | wxCHECK_RET( Ok(), wxT("invalid window dc") ); | |
37 | ||
38 | wxCoord x2 = x1 + width, | |
39 | y2 = y1 + height; | |
40 | ||
41 | // this is to yield width of 3 for width == height == 10 | |
42 | SetPen(wxPen(GetTextForeground(), (width + height + 1) / 7, wxSOLID)); | |
43 | ||
44 | // we're drawing a scaled version of wx/generic/tick.xpm here | |
45 | wxCoord x3 = x1 + (4*width) / 10, // x of the tick bottom | |
46 | y3 = y1 + height / 2; // y of the left tick branch | |
47 | DoDrawLine(x1, y3, x3, y2); | |
48 | DoDrawLine(x3, y2, x2, y1); | |
49 | ||
50 | CalcBoundingBox(x1, y1); | |
51 | CalcBoundingBox(x2, y2); | |
52 | } | |
53 | ||
72cdf4c9 | 54 | void wxDCBase::DrawLines(const wxList *list, wxCoord xoffset, wxCoord yoffset) |
dbe94982 BM |
55 | { |
56 | int n = list->Number(); | |
57 | wxPoint *points = new wxPoint[n]; | |
58 | ||
59 | int i = 0; | |
60 | for ( wxNode *node = list->First(); node; node = node->Next(), i++ ) | |
61 | { | |
62 | wxPoint *point = (wxPoint *)node->Data(); | |
63 | points[i].x = point->x; | |
64 | points[i].y = point->y; | |
65 | } | |
66 | ||
67 | DoDrawLines(n, points, xoffset, yoffset); | |
68 | ||
69 | delete [] points; | |
70 | } | |
71 | ||
72 | ||
73 | void wxDCBase::DrawPolygon(const wxList *list, | |
72cdf4c9 | 74 | wxCoord xoffset, wxCoord yoffset, |
dbe94982 BM |
75 | int fillStyle) |
76 | { | |
77 | int n = list->Number(); | |
78 | wxPoint *points = new wxPoint[n]; | |
79 | ||
80 | int i = 0; | |
81 | for ( wxNode *node = list->First(); node; node = node->Next(), i++ ) | |
82 | { | |
83 | wxPoint *point = (wxPoint *)node->Data(); | |
84 | points[i].x = point->x; | |
85 | points[i].y = point->y; | |
86 | } | |
87 | ||
88 | DoDrawPolygon(n, points, xoffset, yoffset, fillStyle); | |
89 | ||
90 | delete [] points; | |
91 | } | |
92 | ||
93 | ||
88ac883a | 94 | #if wxUSE_SPLINES |
dbe94982 BM |
95 | |
96 | // TODO: this API needs fixing (wxPointList, why (!const) "wxList *"?) | |
72cdf4c9 | 97 | void wxDCBase::DrawSpline(wxCoord x1, wxCoord y1, wxCoord x2, wxCoord y2, wxCoord x3, wxCoord y3) |
dbe94982 BM |
98 | { |
99 | wxList point_list; | |
100 | ||
101 | wxPoint *point1 = new wxPoint; | |
102 | point1->x = x1; point1->y = y1; | |
103 | point_list.Append((wxObject*)point1); | |
104 | ||
105 | wxPoint *point2 = new wxPoint; | |
106 | point2->x = x2; point2->y = y2; | |
107 | point_list.Append((wxObject*)point2); | |
108 | ||
109 | wxPoint *point3 = new wxPoint; | |
110 | point3->x = x3; point3->y = y3; | |
111 | point_list.Append((wxObject*)point3); | |
112 | ||
113 | DrawSpline(&point_list); | |
114 | ||
115 | for( wxNode *node = point_list.First(); node; node = node->Next() ) | |
116 | { | |
117 | wxPoint *p = (wxPoint *)node->Data(); | |
118 | delete p; | |
119 | } | |
120 | } | |
121 | ||
122 | void wxDCBase::DrawSpline(int n, wxPoint points[]) | |
123 | { | |
124 | wxList list; | |
125 | for (int i =0; i < n; i++) | |
126 | { | |
127 | list.Append((wxObject*)&points[i]); | |
128 | } | |
129 | ||
130 | DrawSpline(&list); | |
131 | } | |
132 | ||
88ac883a | 133 | #endif // wxUSE_SPLINES |