]> git.saurik.com Git - wxWidgets.git/blame - src/mgl/dcmemory.cpp
X error handler should be extern C (SunCC warning fix)
[wxWidgets.git] / src / mgl / dcmemory.cpp
CommitLineData
32b8ec41
VZ
1/////////////////////////////////////////////////////////////////////////////
2// Name: dcmemory.cpp
3// Purpose:
4// Author: Robert Roebling, Vaclav Slavik
5// RCS-ID: $Id$
8f7b34a8
VS
6// Copyright: (c) 1998 Robert Roebling,
7// 2001 SciTech Software, Inc. (www.scitechsoft.com)
65571936 8// Licence: wxWindows licence
32b8ec41
VZ
9/////////////////////////////////////////////////////////////////////////////
10
14f355c2 11#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
32b8ec41
VZ
12#pragma implementation "dcmemory.h"
13#endif
14
15// For compilers that support precompilation, includes "wx.h".
16#include "wx/wxprec.h"
17
18#ifdef __BORLANDC__
19 #pragma hdrstop
20#endif
21
22#include "wx/dcmemory.h"
23
24
25//-----------------------------------------------------------------------------
26// wxMemoryDC
27//-----------------------------------------------------------------------------
28
29IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC,wxWindowDC)
30
31wxMemoryDC::wxMemoryDC() : wxDC()
32{
33 m_isMemDC = TRUE;
34}
35
36wxMemoryDC::wxMemoryDC(wxDC *WXUNUSED(dc)) : wxDC()
37{
38 m_isMemDC = TRUE;
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}