]> git.saurik.com Git - wxWidgets.git/blame - src/mgl/dcmemory.cpp
Better place for coordinate mirroring and removal
[wxWidgets.git] / src / mgl / dcmemory.cpp
CommitLineData
32b8ec41 1/////////////////////////////////////////////////////////////////////////////
f38924e8 2// Name: src/mgl/dcmemory.cpp
32b8ec41
VZ
3// Purpose:
4// Author: Robert Roebling, Vaclav Slavik
5// RCS-ID: $Id$
f38924e8 6// Copyright: (c) 1998 Robert Roebling,
8f7b34a8 7// 2001 SciTech Software, Inc. (www.scitechsoft.com)
65571936 8// Licence: wxWindows licence
32b8ec41
VZ
9/////////////////////////////////////////////////////////////////////////////
10
32b8ec41
VZ
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
25IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC,wxWindowDC)
26
432efcb0
RD
27wxMemoryDC::wxMemoryDC( const wxBitmap& bitmap )
28 : wxDC()
32b8ec41 29{
f38924e8 30 m_isMemDC = true;
432efcb0
RD
31
32 if ( bitmap.IsOk() )
33 SelectObject(bitmap);
32b8ec41
VZ
34}
35
36wxMemoryDC::wxMemoryDC(wxDC *WXUNUSED(dc)) : wxDC()
37{
f38924e8 38 m_isMemDC = true;
32b8ec41
VZ
39}
40
41wxMemoryDC::~wxMemoryDC()
42{
43}
44
45void wxMemoryDC::SelectObject(const wxBitmap& bitmap)
46{
32b8ec41 47 if ( bitmap.Ok() )
65d48d09
VS
48 {
49 m_selected = bitmap;
32b8ec41 50 SetMGLDC(m_selected.CreateTmpDC(), TRUE);
65d48d09 51 }
32b8ec41
VZ
52}
53
54void 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
71void 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
88void 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
105void 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}