]>
Commit | Line | Data |
---|---|---|
0e320a79 DW |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: dc.cpp | |
3 | // Purpose: wxDC class | |
4 | // Author: AUTHOR | |
5 | // Modified by: | |
6 | // Created: 01/02/97 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) AUTHOR | |
9 | // Licence: wxWindows licence | |
10 | ///////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifdef __GNUG__ | |
13 | #pragma implementation "dc.h" | |
14 | #endif | |
15 | ||
16 | #include "wx/dc.h" | |
17 | ||
18 | #if !USE_SHARED_LIBRARY | |
19 | IMPLEMENT_ABSTRACT_CLASS(wxDC, wxObject) | |
20 | #endif | |
21 | ||
22 | //----------------------------------------------------------------------------- | |
23 | // constants | |
24 | //----------------------------------------------------------------------------- | |
25 | ||
26 | #define mm2inches 0.0393700787402 | |
27 | #define inches2mm 25.4 | |
28 | #define mm2twips 56.6929133859 | |
29 | #define twips2mm 0.0176388888889 | |
30 | #define mm2pt 2.83464566929 | |
31 | #define pt2mm 0.352777777778 | |
32 | ||
1408104d DW |
33 | //----------------------------------------------------------------------------- |
34 | // wxDCBase | |
35 | //----------------------------------------------------------------------------- | |
36 | ||
37 | long wxDCBase::DeviceToLogicalX(long x) const | |
38 | { | |
c3d43472 DW |
39 | long new_x = x - m_deviceOriginX; |
40 | if (new_x > 0) | |
41 | return (long)((double)(new_x) / m_scaleX + 0.5) * m_signX + m_logicalOriginX; | |
42 | else | |
43 | return (long)((double)(new_x) / m_scaleX - 0.5) * m_signX + m_logicalOriginX; | |
1408104d DW |
44 | }; |
45 | ||
46 | long wxDCBase::DeviceToLogicalY(long y) const | |
47 | { | |
c3d43472 DW |
48 | long new_y = y - m_deviceOriginY; |
49 | if (new_y > 0) | |
50 | return (long)((double)(new_y) / m_scaleY + 0.5) * m_signY + m_logicalOriginY; | |
51 | else | |
52 | return (long)((double)(new_y) / m_scaleY - 0.5) * m_signY + m_logicalOriginY; | |
1408104d DW |
53 | }; |
54 | ||
55 | long wxDCBase::DeviceToLogicalXRel(long x) const | |
56 | { | |
c3d43472 DW |
57 | if (x > 0) |
58 | return (long)((double)(x) / m_scaleX + 0.5); | |
59 | else | |
60 | return (long)((double)(x) / m_scaleX - 0.5); | |
1408104d DW |
61 | }; |
62 | ||
63 | long wxDCBase::DeviceToLogicalYRel(long y) const | |
64 | { | |
c3d43472 DW |
65 | if (y > 0) |
66 | return (long)((double)(y) / m_scaleY + 0.5); | |
67 | else | |
68 | return (long)((double)(y) / m_scaleY - 0.5); | |
1408104d DW |
69 | }; |
70 | ||
71 | long wxDCBase::LogicalToDeviceX(long x) const | |
72 | { | |
c3d43472 DW |
73 | long new_x = x - m_logicalOriginX; |
74 | if (new_x > 0) | |
75 | return (long)((double)(new_x) * m_scaleX + 0.5) * m_signX + m_deviceOriginX; | |
76 | else | |
77 | return (long)((double)(new_x) * m_scaleX - 0.5) * m_signX + m_deviceOriginX; | |
1408104d DW |
78 | }; |
79 | ||
80 | long wxDCBase::LogicalToDeviceY(long y) const | |
81 | { | |
c3d43472 DW |
82 | long new_y = y - m_logicalOriginY; |
83 | if (new_y > 0) | |
84 | return (long)((double)(new_y) * m_scaleY + 0.5) * m_signY + m_deviceOriginY; | |
85 | else | |
86 | return (long)((double)(new_y) * m_scaleY - 0.5) * m_signY + m_deviceOriginY; | |
1408104d DW |
87 | }; |
88 | ||
89 | long wxDCBase::LogicalToDeviceXRel(long x) const | |
90 | { | |
c3d43472 DW |
91 | if (x > 0) |
92 | return (long)((double)(x) * m_scaleX + 0.5); | |
93 | else | |
94 | return (long)((double)(x) * m_scaleX - 0.5); | |
1408104d DW |
95 | }; |
96 | ||
97 | long wxDCBase::LogicalToDeviceYRel(long y) const | |
98 | { | |
c3d43472 DW |
99 | if (y > 0) |
100 | return (long)((double)(y) * m_scaleY + 0.5); | |
101 | else | |
102 | return (long)((double)(y) * m_scaleY - 0.5); | |
1408104d DW |
103 | }; |
104 | ||
0e320a79 DW |
105 | //----------------------------------------------------------------------------- |
106 | // wxDC | |
107 | //----------------------------------------------------------------------------- | |
108 | ||
109 | wxDC::wxDC(void) | |
110 | { | |
ce44c50e | 111 | m_canvas = NULL; |
c3d43472 DW |
112 | |
113 | m_oldBitmap = 0; | |
114 | m_oldPen = 0; | |
115 | m_oldBrush = 0; | |
116 | m_oldFont = 0; | |
117 | m_oldPalette = 0; | |
ce44c50e DW |
118 | |
119 | m_bOwnsDC = FALSE; | |
c3d43472 DW |
120 | m_hDC = 0; |
121 | m_hDCCount = 0; | |
0e320a79 DW |
122 | }; |
123 | ||
124 | wxDC::~wxDC(void) | |
125 | { | |
c3d43472 | 126 | // TODO: |
0e320a79 DW |
127 | }; |
128 | ||
0e320a79 DW |
129 | void wxDC::DestroyClippingRegion(void) |
130 | { | |
c3d43472 | 131 | // TODO: |
0e320a79 DW |
132 | }; |
133 | ||
c3d43472 | 134 | void wxDC::DoGetSize( int* width, int* height ) const |
0e320a79 | 135 | { |
c3d43472 | 136 | // TODO: |
0e320a79 DW |
137 | }; |
138 | ||
c3d43472 | 139 | void wxDC::DoGetSizeMM( int* width, int* height ) const |
0e320a79 | 140 | { |
c3d43472 | 141 | // TODO: |
0e320a79 DW |
142 | }; |
143 | ||
0e320a79 DW |
144 | void wxDC::SetMapMode( int mode ) |
145 | { | |
c3d43472 | 146 | // TODO: |
0e320a79 DW |
147 | }; |
148 | ||
149 | void wxDC::SetUserScale( double x, double y ) | |
150 | { | |
c3d43472 DW |
151 | m_userScaleX = x; |
152 | m_userScaleY = y; | |
0e320a79 | 153 | |
c3d43472 | 154 | SetMapMode(m_mappingMode); |
0e320a79 DW |
155 | }; |
156 | ||
157 | void wxDC::SetLogicalScale( double x, double y ) | |
158 | { | |
c3d43472 | 159 | // TODO: |
0e320a79 DW |
160 | }; |
161 | ||
0e320a79 DW |
162 | void wxDC::SetLogicalOrigin( long x, long y ) |
163 | { | |
c3d43472 | 164 | // TODO: |
0e320a79 DW |
165 | }; |
166 | ||
0e320a79 DW |
167 | void wxDC::SetDeviceOrigin( long x, long y ) |
168 | { | |
c3d43472 | 169 | // TODO: |
0e320a79 DW |
170 | }; |
171 | ||
0e320a79 DW |
172 | void wxDC::SetInternalDeviceOrigin( long x, long y ) |
173 | { | |
c3d43472 | 174 | // TODO: |
0e320a79 DW |
175 | }; |
176 | ||
177 | void wxDC::GetInternalDeviceOrigin( long *x, long *y ) | |
178 | { | |
c3d43472 | 179 | // TODO: |
0e320a79 DW |
180 | }; |
181 | ||
182 | void wxDC::SetAxisOrientation( bool xLeftRight, bool yBottomUp ) | |
183 | { | |
c3d43472 | 184 | // TODO: |
0e320a79 DW |
185 | }; |
186 | ||
1408104d DW |
187 | |
188 | int wxDC::GetDepth() const | |
0e320a79 | 189 | { |
1408104d DW |
190 | // TODO: |
191 | return (1); | |
192 | } | |
0e320a79 | 193 | |
1408104d | 194 | wxSize wxDC::GetPPI() const |
0e320a79 | 195 | { |
c3d43472 DW |
196 | int x = 1; |
197 | int y = 1; | |
1408104d | 198 | // TODO: |
c3d43472 | 199 | return (wxSize(x,y)); |
1408104d DW |
200 | } |
201 | void wxDC::GetTextExtent( const wxString& string | |
202 | ,long* x | |
203 | ,long* y | |
204 | ,long* decent | |
205 | ,long* externalLeading | |
206 | ,wxFont* theFont | |
207 | ) const | |
208 | { | |
209 | // TODO: | |
210 | } | |
0e320a79 | 211 | |
c3d43472 | 212 | long wxDC::GetCharWidth() const |
0e320a79 | 213 | { |
1408104d DW |
214 | // TODO |
215 | return(1); | |
216 | } | |
0e320a79 | 217 | |
c3d43472 | 218 | long wxDC::GetCharHeight() const |
0e320a79 | 219 | { |
1408104d DW |
220 | // TODO |
221 | return(1); | |
222 | } | |
0e320a79 | 223 | |
1408104d | 224 | void wxDC::Clear() |
0e320a79 | 225 | { |
1408104d DW |
226 | // TODO |
227 | } | |
0e320a79 | 228 | |
1408104d | 229 | void wxDC::SetFont(const wxFont& font) |
0e320a79 | 230 | { |
1408104d DW |
231 | // TODO |
232 | } | |
0e320a79 | 233 | |
1408104d | 234 | void wxDC::SetPen(const wxPen& pen) |
0e320a79 | 235 | { |
1408104d DW |
236 | // TODO |
237 | } | |
238 | void wxDC::SetBrush(const wxBrush& brush) | |
239 | { | |
240 | // TODO | |
241 | } | |
0e320a79 | 242 | |
1408104d | 243 | void wxDC::SetBackground(const wxBrush& brush) |
0e320a79 | 244 | { |
1408104d DW |
245 | // TODO |
246 | } | |
247 | ||
248 | void wxDC::SetLogicalFunction(int function) | |
0e320a79 | 249 | { |
1408104d DW |
250 | // TODO |
251 | } | |
252 | ||
253 | void wxDC::SetBackgroundMode(int mode) | |
254 | { | |
255 | // TODO | |
256 | } | |
257 | ||
258 | void wxDC::SetPalette(const wxPalette& palette) | |
259 | { | |
260 | // TODO | |
261 | } | |
262 | ||
263 | void wxDC::DoFloodFill( long x | |
264 | ,long y | |
265 | ,const wxColour& col | |
c3d43472 | 266 | ,int style |
1408104d DW |
267 | ) |
268 | { | |
269 | // TODO | |
270 | } | |
271 | ||
272 | bool wxDC::DoGetPixel(long x, long y, wxColour *col) const | |
273 | { | |
274 | // TODO | |
275 | return(TRUE); | |
276 | } | |
277 | ||
278 | void wxDC::DoDrawPoint(long x, long y) | |
279 | { | |
280 | // TODO | |
281 | } | |
282 | ||
283 | void wxDC::DoDrawLine(long x1, long y1, long x2, long y2) | |
284 | { | |
285 | // TODO | |
286 | } | |
287 | ||
288 | void wxDC::DoDrawArc( long x1, long y1 | |
289 | ,long x2, long y2 | |
290 | ,long xc, long yc | |
291 | ) | |
292 | { | |
293 | // TODO | |
294 | } | |
295 | ||
296 | void wxDC::DoDrawEllipticArc( long x | |
297 | ,long y | |
298 | ,long w | |
299 | ,long h | |
300 | ,double sa | |
301 | ,double ea | |
302 | ) | |
303 | { | |
304 | // TODO | |
305 | } | |
306 | ||
307 | void wxDC::DoDrawRectangle(long x, long y, long width, long height) | |
308 | { | |
309 | // TODO | |
310 | } | |
311 | ||
312 | void wxDC::DoDrawRoundedRectangle( long x, long y | |
313 | ,long width, long height | |
314 | ,double radius | |
315 | ) | |
316 | { | |
317 | // TODO | |
318 | } | |
319 | ||
320 | void wxDC::DoDrawEllipse(long x, long y, long width, long height) | |
321 | { | |
322 | // TODO | |
323 | } | |
324 | ||
325 | void wxDC::DoCrossHair(long x, long y) | |
326 | { | |
327 | // TODO | |
328 | } | |
329 | ||
330 | void wxDC::DoDrawIcon(const wxIcon& icon, long x, long y) | |
331 | { | |
332 | // TODO | |
333 | } | |
334 | ||
335 | void wxDC::DoDrawBitmap( const wxBitmap &bmp | |
336 | ,long x, long y | |
c3d43472 | 337 | ,bool useMask |
1408104d DW |
338 | ) |
339 | { | |
340 | // TODO | |
341 | } | |
342 | ||
343 | void wxDC::DoDrawText(const wxString& text, long x, long y) | |
344 | { | |
345 | // TODO | |
346 | } | |
347 | ||
348 | bool wxDC::DoBlit( long xdest | |
349 | ,long ydest | |
350 | ,long width | |
351 | ,long height | |
352 | ,wxDC *source | |
353 | ,long xsrc | |
354 | ,long ysrc | |
c3d43472 DW |
355 | ,int rop |
356 | ,bool useMask | |
1408104d DW |
357 | ) |
358 | { | |
359 | // TODO | |
360 | return(TRUE); | |
361 | } | |
362 | ||
1408104d DW |
363 | void wxDC::DoDrawLines( int n, wxPoint points[] |
364 | ,long xoffset, long yoffset | |
365 | ) | |
366 | { | |
367 | // TODO | |
368 | } | |
369 | ||
370 | void wxDC::DoDrawPolygon(int n, wxPoint points[] | |
371 | ,long xoffset, long yoffset | |
c3d43472 | 372 | ,int fillStyle |
1408104d DW |
373 | ) |
374 | { | |
375 | // TODO | |
376 | } | |
377 | ||
378 | void wxDC::DoSetClippingRegionAsRegion(const wxRegion& region) | |
379 | { | |
380 | // TODO | |
381 | } | |
382 | ||
383 | void wxDC::DoSetClippingRegion( long x, long y | |
384 | ,long width, long height | |
385 | ) | |
386 | { | |
387 | // TODO | |
388 | } | |
389 | ||
390 | #if wxUSE_SPLINES | |
391 | void wxDC::DoDrawSpline(wxList *points) | |
392 | { | |
393 | // TODO | |
394 | } | |
395 | #endif | |
396 | ||
ce44c50e DW |
397 | void wxDC::SetRop(WXHDC dc) |
398 | { | |
399 | if (!dc || m_logicalFunction < 0) | |
400 | return; | |
401 | ||
402 | int c_rop; | |
403 | // These may be wrong | |
404 | switch (m_logicalFunction) | |
405 | { | |
406 | // TODO: Figure this stuff out | |
407 | // case wxXOR: c_rop = R2_XORPEN; break; | |
408 | // case wxXOR: c_rop = R2_NOTXORPEN; break; | |
409 | // case wxINVERT: c_rop = R2_NOT; break; | |
410 | // case wxOR_REVERSE: c_rop = R2_MERGEPENNOT; break; | |
411 | // case wxAND_REVERSE: c_rop = R2_MASKPENNOT; break; | |
412 | // case wxCLEAR: c_rop = R2_WHITE; break; | |
413 | // case wxSET: c_rop = R2_BLACK; break; | |
414 | // case wxSRC_INVERT: c_rop = R2_NOTCOPYPEN; break; | |
415 | // case wxOR_INVERT: c_rop = R2_MERGENOTPEN; break; | |
416 | // case wxAND: c_rop = R2_MASKPEN; break; | |
417 | // case wxOR: c_rop = R2_MERGEPEN; break; | |
418 | // case wxAND_INVERT: c_rop = R2_MASKNOTPEN; break; | |
419 | // case wxEQUIV: | |
420 | // case wxNAND: | |
421 | // case wxCOPY: | |
422 | default: | |
423 | // c_rop = R2_COPYPEN; | |
424 | break; | |
425 | } | |
426 | // SetROP2((HDC) dc, c_rop); | |
427 | } | |
428 | ||
429 | void wxDC::DoClipping(WXHDC dc) | |
430 | { | |
431 | if (m_clipping && dc) | |
432 | { | |
433 | // TODO: | |
434 | // IntersectClipRect((HDC) dc, XLOG2DEV(m_clipX1), YLOG2DEV(m_clipY1), | |
435 | // XLOG2DEV(m_clipX2), YLOG2DEV(m_clipY2)); | |
436 | } | |
437 | } | |
438 | ||
439 | // This will select current objects out of the DC, | |
440 | // which is what you have to do before deleting the | |
441 | // DC. | |
442 | void wxDC::SelectOldObjects(WXHDC dc) | |
443 | { | |
444 | if (dc) | |
445 | { | |
446 | if (m_oldBitmap) | |
447 | { | |
448 | // ::SelectObject((HDC) dc, (HBITMAP) m_oldBitmap); | |
449 | if (m_selectedBitmap.Ok()) | |
450 | { | |
451 | m_selectedBitmap.SetSelectedInto(NULL); | |
452 | } | |
453 | } | |
454 | m_oldBitmap = 0; | |
455 | if (m_oldPen) | |
456 | { | |
457 | // ::SelectObject((HDC) dc, (HPEN) m_oldPen); | |
458 | } | |
459 | m_oldPen = 0; | |
460 | if (m_oldBrush) | |
461 | { | |
462 | // ::SelectObject((HDC) dc, (HBRUSH) m_oldBrush); | |
463 | } | |
464 | m_oldBrush = 0; | |
465 | if (m_oldFont) | |
466 | { | |
467 | // ::SelectObject((HDC) dc, (HFONT) m_oldFont); | |
468 | } | |
469 | m_oldFont = 0; | |
470 | if (m_oldPalette) | |
471 | { | |
472 | // ::SelectPalette((HDC) dc, (HPALETTE) m_oldPalette, TRUE); | |
473 | } | |
474 | m_oldPalette = 0; | |
475 | } | |
476 | ||
477 | m_brush = wxNullBrush; | |
478 | m_pen = wxNullPen; | |
479 | m_palette = wxNullPalette; | |
480 | m_font = wxNullFont; | |
481 | m_backgroundBrush = wxNullBrush; | |
482 | m_selectedBitmap = wxNullBitmap; | |
483 | } | |
484 | ||
1408104d DW |
485 | // |
486 | // Private functions | |
487 | // | |
0e320a79 | 488 | |
0e320a79 | 489 |