]> git.saurik.com Git - wxWidgets.git/blame - src/gtk1/dcmemory.cpp
filter out garbage Windows sends us via LVN_ODCACHEHINT
[wxWidgets.git] / src / gtk1 / dcmemory.cpp
CommitLineData
c801d85f
KB
1/////////////////////////////////////////////////////////////////////////////
2// Name: dcmemory.cpp
3// Purpose:
4// Author: Robert Roebling
6f65e337 5// RCS-ID: $Id$
01111366 6// Copyright: (c) 1998 Robert Roebling
72cdf4c9 7// Licence: wxWindows licence
c801d85f
KB
8/////////////////////////////////////////////////////////////////////////////
9
10#ifdef __GNUG__
11#pragma implementation "dcmemory.h"
12#endif
13
14#include "wx/dcmemory.h"
15
071a2d78
RR
16#include <gdk/gdk.h>
17#include <gtk/gtk.h>
83624f79 18
c801d85f
KB
19//-----------------------------------------------------------------------------
20// wxMemoryDC
21//-----------------------------------------------------------------------------
22
ec758a20 23IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC,wxWindowDC)
c801d85f 24
4bc67cc5 25wxMemoryDC::wxMemoryDC() : wxWindowDC()
c801d85f 26{
4bc67cc5 27 m_ok = FALSE;
72cdf4c9 28
4bc67cc5 29 m_cmap = gtk_widget_get_default_colormap();
ff7b1510 30}
c801d85f 31
72cdf4c9 32wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) )
ec758a20 33 : wxWindowDC()
c801d85f 34{
4bc67cc5 35 m_ok = FALSE;
72cdf4c9 36
4bc67cc5 37 m_cmap = gtk_widget_get_default_colormap();
ff7b1510 38}
c801d85f 39
4bc67cc5 40wxMemoryDC::~wxMemoryDC()
c801d85f 41{
ff7b1510 42}
c801d85f
KB
43
44void wxMemoryDC::SelectObject( const wxBitmap& bitmap )
45{
3d2d8da1 46 Destroy();
4bc67cc5
RR
47 m_selected = bitmap;
48 if (m_selected.Ok())
6f65e337 49 {
4bc67cc5
RR
50 if (m_selected.GetPixmap())
51 {
52 m_window = m_selected.GetPixmap();
53 }
54 else
55 {
56 m_window = m_selected.GetBitmap();
57 }
72cdf4c9 58
4bc67cc5 59 m_isMemDC = TRUE;
809934d2
RR
60
61 SetUpDC();
6f65e337
JS
62 }
63 else
72cdf4c9 64 {
4bc67cc5
RR
65 m_ok = FALSE;
66 m_window = (GdkWindow *) NULL;
6f65e337 67 }
ff7b1510 68}
c801d85f 69
41fbc841
RR
70void wxMemoryDC::SetPen( const wxPen &pen )
71{
72 if (m_selected.Ok() && m_selected.GetBitmap() && (*wxTRANSPARENT_PEN != pen))
73 {
74 if (*wxWHITE_PEN == pen)
75 wxWindowDC::SetPen( *wxBLACK_PEN );
76 else
77 wxWindowDC::SetPen( *wxWHITE_PEN );
78 }
79 else
80 {
81 wxWindowDC::SetPen( pen );
82 }
83}
84
85void wxMemoryDC::SetBrush( const wxBrush &brush )
86{
87 if (m_selected.Ok() && m_selected.GetBitmap() && (*wxTRANSPARENT_BRUSH != brush))
88 {
89 if (*wxWHITE_BRUSH == brush)
90 wxWindowDC::SetBrush( *wxBLACK_BRUSH );
91 else
92 wxWindowDC::SetBrush( *wxWHITE_BRUSH );
93 }
94 else
95 {
96 wxWindowDC::SetBrush( brush );
97 }
98}
99
100void wxMemoryDC::SetTextForeground( const wxColour &col )
101{
102 if (m_selected.Ok() && m_selected.GetBitmap())
103 {
104 if (col == *wxWHITE)
105 wxWindowDC::SetTextForeground( *wxBLACK );
106 else
107 wxWindowDC::SetTextForeground( *wxWHITE );
108 }
109 else
110 {
111 wxWindowDC::SetTextForeground( col );
112 }
113}
114
115void wxMemoryDC::SetTextBackground( const wxColour &col )
116{
117 if (m_selected.Ok() && m_selected.GetBitmap())
118 {
119 if (col == *wxWHITE)
120 wxWindowDC::SetTextBackground( *wxBLACK );
121 else
122 wxWindowDC::SetTextBackground( *wxWHITE );
123 }
124 else
125 {
126 wxWindowDC::SetTextBackground( col );
127 }
128}
129
4e4ea166 130void wxMemoryDC::DoGetSize( int *width, int *height ) const
c801d85f 131{
4bc67cc5
RR
132 if (m_selected.Ok())
133 {
134 if (width) (*width) = m_selected.GetWidth();
135 if (height) (*height) = m_selected.GetHeight();
136 }
137 else
138 {
139 if (width) (*width) = 0;
140 if (height) (*height) = 0;
141 }
ff7b1510 142}
c801d85f
KB
143
144