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