]> git.saurik.com Git - wxWidgets.git/blob - src/os2/dc.cpp
Updated install.txt, added double-inclusion guard, corrected a GnuWin32 thing
[wxWidgets.git] / src / os2 / dc.cpp
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
33 //-----------------------------------------------------------------------------
34 // wxDCBase
35 //-----------------------------------------------------------------------------
36
37 long wxDCBase::DeviceToLogicalX(long x) const
38 {
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;
44 };
45
46 long wxDCBase::DeviceToLogicalY(long y) const
47 {
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;
53 };
54
55 long wxDCBase::DeviceToLogicalXRel(long x) const
56 {
57 if (x > 0)
58 return (long)((double)(x) / m_scaleX + 0.5);
59 else
60 return (long)((double)(x) / m_scaleX - 0.5);
61 };
62
63 long wxDCBase::DeviceToLogicalYRel(long y) const
64 {
65 if (y > 0)
66 return (long)((double)(y) / m_scaleY + 0.5);
67 else
68 return (long)((double)(y) / m_scaleY - 0.5);
69 };
70
71 long wxDCBase::LogicalToDeviceX(long x) const
72 {
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;
78 };
79
80 long wxDCBase::LogicalToDeviceY(long y) const
81 {
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;
87 };
88
89 long wxDCBase::LogicalToDeviceXRel(long x) const
90 {
91 if (x > 0)
92 return (long)((double)(x) * m_scaleX + 0.5);
93 else
94 return (long)((double)(x) * m_scaleX - 0.5);
95 };
96
97 long wxDCBase::LogicalToDeviceYRel(long y) const
98 {
99 if (y > 0)
100 return (long)((double)(y) * m_scaleY + 0.5);
101 else
102 return (long)((double)(y) * m_scaleY - 0.5);
103 };
104
105 //-----------------------------------------------------------------------------
106 // wxDC
107 //-----------------------------------------------------------------------------
108
109 wxDC::wxDC(void)
110 {
111 m_canvas = NULL;
112
113 m_oldBitmap = 0;
114 m_oldPen = 0;
115 m_oldBrush = 0;
116 m_oldFont = 0;
117 m_oldPalette = 0;
118
119 m_bOwnsDC = FALSE;
120 m_hDC = 0;
121 m_hDCCount = 0;
122 };
123
124 wxDC::~wxDC(void)
125 {
126 // TODO:
127 };
128
129 void wxDC::DestroyClippingRegion(void)
130 {
131 // TODO:
132 };
133
134 void wxDC::DoGetSize( int* width, int* height ) const
135 {
136 // TODO:
137 };
138
139 void wxDC::DoGetSizeMM( int* width, int* height ) const
140 {
141 // TODO:
142 };
143
144 void wxDC::SetMapMode( int mode )
145 {
146 // TODO:
147 };
148
149 void wxDC::SetUserScale( double x, double y )
150 {
151 m_userScaleX = x;
152 m_userScaleY = y;
153
154 SetMapMode(m_mappingMode);
155 };
156
157 void wxDC::SetLogicalScale( double x, double y )
158 {
159 // TODO:
160 };
161
162 void wxDC::SetLogicalOrigin( long x, long y )
163 {
164 // TODO:
165 };
166
167 void wxDC::SetDeviceOrigin( long x, long y )
168 {
169 // TODO:
170 };
171
172 void wxDC::SetInternalDeviceOrigin( long x, long y )
173 {
174 // TODO:
175 };
176
177 void wxDC::GetInternalDeviceOrigin( long *x, long *y )
178 {
179 // TODO:
180 };
181
182 void wxDC::SetAxisOrientation( bool xLeftRight, bool yBottomUp )
183 {
184 // TODO:
185 };
186
187
188 int wxDC::GetDepth() const
189 {
190 // TODO:
191 return (1);
192 }
193
194 wxSize wxDC::GetPPI() const
195 {
196 int x = 1;
197 int y = 1;
198 // TODO:
199 return (wxSize(x,y));
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 }
211
212 long wxDC::GetCharWidth() const
213 {
214 // TODO
215 return(1);
216 }
217
218 long wxDC::GetCharHeight() const
219 {
220 // TODO
221 return(1);
222 }
223
224 void wxDC::Clear()
225 {
226 // TODO
227 }
228
229 void wxDC::SetFont(const wxFont& font)
230 {
231 // TODO
232 }
233
234 void wxDC::SetPen(const wxPen& pen)
235 {
236 // TODO
237 }
238 void wxDC::SetBrush(const wxBrush& brush)
239 {
240 // TODO
241 }
242
243 void wxDC::SetBackground(const wxBrush& brush)
244 {
245 // TODO
246 }
247
248 void wxDC::SetLogicalFunction(int function)
249 {
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
266 ,int style
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
337 ,bool useMask
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
355 ,int rop
356 ,bool useMask
357 )
358 {
359 // TODO
360 return(TRUE);
361 }
362
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
372 ,int fillStyle
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
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
485 //
486 // Private functions
487 //
488
489