]> git.saurik.com Git - wxWidgets.git/blame - src/gtk/dcmemory.cpp
test for disabled scroll directions in kbd handler
[wxWidgets.git] / src / gtk / 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{
4bc67cc5
RR
46 m_selected = bitmap;
47 if (m_selected.Ok())
6f65e337 48 {
4bc67cc5
RR
49 if (m_selected.GetPixmap())
50 {
51 m_window = m_selected.GetPixmap();
52 }
53 else
54 {
55 m_window = m_selected.GetBitmap();
56 }
72cdf4c9 57
4bc67cc5 58 SetUpDC();
72cdf4c9 59
4bc67cc5 60 m_isMemDC = TRUE;
6f65e337
JS
61 }
62 else
72cdf4c9 63 {
4bc67cc5
RR
64 m_ok = FALSE;
65 m_window = (GdkWindow *) NULL;
6f65e337 66 }
ff7b1510 67}
c801d85f 68
41fbc841
RR
69void wxMemoryDC::SetPen( const wxPen &pen )
70{
71 if (m_selected.Ok() && m_selected.GetBitmap() && (*wxTRANSPARENT_PEN != pen))
72 {
73 if (*wxWHITE_PEN == pen)
74 wxWindowDC::SetPen( *wxBLACK_PEN );
75 else
76 wxWindowDC::SetPen( *wxWHITE_PEN );
77 }
78 else
79 {
80 wxWindowDC::SetPen( pen );
81 }
82}
83
84void wxMemoryDC::SetBrush( const wxBrush &brush )
85{
86 if (m_selected.Ok() && m_selected.GetBitmap() && (*wxTRANSPARENT_BRUSH != brush))
87 {
88 if (*wxWHITE_BRUSH == brush)
89 wxWindowDC::SetBrush( *wxBLACK_BRUSH );
90 else
91 wxWindowDC::SetBrush( *wxWHITE_BRUSH );
92 }
93 else
94 {
95 wxWindowDC::SetBrush( brush );
96 }
97}
98
99void wxMemoryDC::SetTextForeground( const wxColour &col )
100{
101 if (m_selected.Ok() && m_selected.GetBitmap())
102 {
103 if (col == *wxWHITE)
104 wxWindowDC::SetTextForeground( *wxBLACK );
105 else
106 wxWindowDC::SetTextForeground( *wxWHITE );
107 }
108 else
109 {
110 wxWindowDC::SetTextForeground( col );
111 }
112}
113
114void wxMemoryDC::SetTextBackground( const wxColour &col )
115{
116 if (m_selected.Ok() && m_selected.GetBitmap())
117 {
118 if (col == *wxWHITE)
119 wxWindowDC::SetTextBackground( *wxBLACK );
120 else
121 wxWindowDC::SetTextBackground( *wxWHITE );
122 }
123 else
124 {
125 wxWindowDC::SetTextBackground( col );
126 }
127}
128
4e4ea166 129void wxMemoryDC::DoGetSize( int *width, int *height ) const
c801d85f 130{
4bc67cc5
RR
131 if (m_selected.Ok())
132 {
133 if (width) (*width) = m_selected.GetWidth();
134 if (height) (*height) = m_selected.GetHeight();
135 }
136 else
137 {
138 if (width) (*width) = 0;
139 if (height) (*height) = 0;
140 }
ff7b1510 141}
c801d85f
KB
142
143