]> git.saurik.com Git - wxWidgets.git/blob - src/mgl/dcmemory.cpp
More small fixes
[wxWidgets.git] / src / mgl / dcmemory.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: dcmemory.cpp
3 // Purpose:
4 // Author: Robert Roebling, Vaclav Slavik
5 // RCS-ID: $Id$
6 // Copyright: (c) 1998 Robert Roebling, 2001 Vaclav Slavik
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
9
10 #ifdef __GNUG__
11 #pragma implementation "dcmemory.h"
12 #endif
13
14 // For compilers that support precompilation, includes "wx.h".
15 #include "wx/wxprec.h"
16
17 #ifdef __BORLANDC__
18 #pragma hdrstop
19 #endif
20
21 #include "wx/dcmemory.h"
22
23
24 //-----------------------------------------------------------------------------
25 // wxMemoryDC
26 //-----------------------------------------------------------------------------
27
28 IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC,wxWindowDC)
29
30 wxMemoryDC::wxMemoryDC() : wxDC()
31 {
32 m_isMemDC = TRUE;
33 }
34
35 wxMemoryDC::wxMemoryDC(wxDC *WXUNUSED(dc)) : wxDC()
36 {
37 m_isMemDC = TRUE;
38 }
39
40 wxMemoryDC::~wxMemoryDC()
41 {
42 }
43
44 void wxMemoryDC::SelectObject(const wxBitmap& bitmap)
45 {
46 SetMGLDC(NULL, TRUE);
47 m_selected = bitmap;
48
49 if ( bitmap.Ok() )
50 SetMGLDC(m_selected.CreateTmpDC(), TRUE);
51 }
52
53 void wxMemoryDC::SetPen(const wxPen &pen)
54 {
55 wxCHECK_RET( Ok(), wxT("invalid dc") );
56
57 if ( GetDepth() == 1 && *wxTRANSPARENT_PEN != pen )
58 {
59 if ( *wxWHITE_PEN == pen )
60 wxDC::SetPen(*wxBLACK_PEN);
61 else
62 wxDC::SetPen(*wxWHITE_PEN);
63 }
64 else
65 {
66 wxDC::SetPen(pen);
67 }
68 }
69
70 void wxMemoryDC::SetBrush(const wxBrush &brush)
71 {
72 wxCHECK_RET( Ok(), wxT("invalid dc") );
73
74 if ( GetDepth() == 1 && *wxTRANSPARENT_BRUSH != brush )
75 {
76 if ( *wxWHITE_BRUSH == brush )
77 wxDC::SetBrush(*wxBLACK_BRUSH);
78 else
79 wxDC::SetBrush(*wxWHITE_BRUSH);
80 }
81 else
82 {
83 wxDC::SetBrush(brush);
84 }
85 }
86
87 void wxMemoryDC::SetTextForeground(const wxColour &col)
88 {
89 wxCHECK_RET( Ok(), wxT("invalid dc") );
90
91 if ( GetDepth() == 1 )
92 {
93 if ( col == *wxWHITE )
94 wxDC::SetTextForeground(*wxBLACK);
95 else
96 wxDC::SetTextForeground(*wxWHITE);
97 }
98 else
99 {
100 wxDC::SetTextForeground(col);
101 }
102 }
103
104 void wxMemoryDC::SetTextBackground(const wxColour &col)
105 {
106 wxCHECK_RET( Ok(), wxT("invalid dc") );
107
108 if ( GetDepth() == 1 )
109 {
110 if ( col == *wxWHITE )
111 wxDC::SetTextBackground(*wxBLACK);
112 else
113 wxDC::SetTextBackground(*wxWHITE);
114 }
115 else
116 {
117 wxDC::SetTextBackground(col);
118 }
119 }