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