]> git.saurik.com Git - wxWidgets.git/blame - src/gtk1/dcmemory.cpp
Fix best size computation for buttons without image and with empty label.
[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
10d30222 13#include "wx/gtk1/dcmemory.h"
c801d85f 14
071a2d78
RR
15#include <gdk/gdk.h>
16#include <gtk/gtk.h>
83624f79 17
c801d85f 18//-----------------------------------------------------------------------------
10d30222 19// wxMemoryDCImpl
c801d85f
KB
20//-----------------------------------------------------------------------------
21
10d30222 22IMPLEMENT_ABSTRACT_CLASS(wxMemoryDCImpl, wxWindowDCImpl)
c801d85f 23
10d30222 24void wxMemoryDCImpl::Init()
c801d85f 25{
f38924e8 26 m_ok = false;
72cdf4c9 27
4bc67cc5 28 m_cmap = gtk_widget_get_default_colormap();
ff7b1510 29}
c801d85f 30
10d30222
VZ
31wxMemoryDCImpl::wxMemoryDCImpl(wxMemoryDC *owner, wxDC *WXUNUSED(dc))
32 : wxWindowDCImpl(owner)
c801d85f 33{
fea35690 34 Init();
ff7b1510 35}
c801d85f 36
10d30222 37wxMemoryDCImpl::~wxMemoryDCImpl()
c801d85f 38{
ff7b1510 39}
c801d85f 40
10d30222 41void wxMemoryDCImpl::DoSelect( const wxBitmap& bitmap )
c801d85f 42{
3d2d8da1 43 Destroy();
fea35690 44
4bc67cc5
RR
45 m_selected = bitmap;
46 if (m_selected.Ok())
6f65e337 47 {
4bc67cc5
RR
48 if (m_selected.GetPixmap())
49 {
50 m_window = m_selected.GetPixmap();
51 }
52 else
53 {
54 m_window = m_selected.GetBitmap();
55 }
72cdf4c9 56
f38924e8 57 m_isMemDC = true;
809934d2
RR
58
59 SetUpDC();
6f65e337
JS
60 }
61 else
72cdf4c9 62 {
f38924e8 63 m_ok = false;
d3b9f782 64 m_window = NULL;
6f65e337 65 }
ff7b1510 66}
c801d85f 67
10d30222 68void wxMemoryDCImpl::SetPen( const wxPen& penOrig )
41fbc841 69{
8ab40c52
VZ
70 wxPen pen( penOrig );
71 if ( m_selected.Ok() &&
72 m_selected.GetBitmap() &&
73 (pen != *wxTRANSPARENT_PEN) )
41fbc841 74 {
8ab40c52 75 pen.SetColour( pen.GetColour() == *wxWHITE ? *wxBLACK : *wxWHITE );
41fbc841 76 }
8ab40c52 77
10d30222 78 wxWindowDCImpl::SetPen( pen );
41fbc841
RR
79}
80
10d30222 81void wxMemoryDCImpl::SetBrush( const wxBrush& brushOrig )
41fbc841 82{
8ab40c52
VZ
83 wxBrush brush( brushOrig );
84 if ( m_selected.Ok() &&
85 m_selected.GetBitmap() &&
86 (brush != *wxTRANSPARENT_BRUSH) )
41fbc841 87 {
8ab40c52 88 brush.SetColour( brush.GetColour() == *wxWHITE ? *wxBLACK : *wxWHITE);
41fbc841 89 }
8ab40c52 90
10d30222 91 wxWindowDCImpl::SetBrush( brush );
8ab40c52
VZ
92}
93
10d30222 94void wxMemoryDCImpl::SetBackground( const wxBrush& brushOrig )
8ab40c52
VZ
95{
96 wxBrush brush(brushOrig);
97
98 if ( m_selected.Ok() &&
99 m_selected.GetBitmap() &&
100 (brush != *wxTRANSPARENT_BRUSH) )
41fbc841 101 {
8ab40c52 102 brush.SetColour( brush.GetColour() == *wxWHITE ? *wxBLACK : *wxWHITE );
41fbc841 103 }
8ab40c52 104
10d30222 105 wxWindowDCImpl::SetBackground( brush );
41fbc841
RR
106}
107
10d30222 108void wxMemoryDCImpl::SetTextForeground( const wxColour& col )
41fbc841 109{
8ab40c52 110 if ( m_selected.Ok() && m_selected.GetBitmap() )
41fbc841 111 {
10d30222 112 wxWindowDCImpl::SetTextForeground( col == *wxWHITE ? *wxBLACK : *wxWHITE);
41fbc841
RR
113 }
114 else
115 {
10d30222 116 wxWindowDCImpl::SetTextForeground( col );
41fbc841
RR
117 }
118}
119
10d30222 120void wxMemoryDCImpl::SetTextBackground( const wxColour &col )
41fbc841
RR
121{
122 if (m_selected.Ok() && m_selected.GetBitmap())
123 {
10d30222 124 wxWindowDCImpl::SetTextBackground( col == *wxWHITE ? *wxBLACK : *wxWHITE );
41fbc841
RR
125 }
126 else
127 {
10d30222 128 wxWindowDCImpl::SetTextBackground( col );
41fbc841
RR
129 }
130}
131
10d30222 132void wxMemoryDCImpl::DoGetSize( int *width, int *height ) const
c801d85f 133{
4bc67cc5
RR
134 if (m_selected.Ok())
135 {
136 if (width) (*width) = m_selected.GetWidth();
137 if (height) (*height) = m_selected.GetHeight();
138 }
139 else
140 {
141 if (width) (*width) = 0;
142 if (height) (*height) = 0;
143 }
ff7b1510 144}