]> git.saurik.com Git - wxWidgets.git/blob - src/x11/dcmemory.cpp
Use widget->allocation instead of querying the
[wxWidgets.git] / src / x11 / dcmemory.cpp
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/x11/dcmemory.cpp
3 // Purpose: wxMemoryDC class
4 // Author: Julian Smart
5 // Modified by:
6 // Created: 01/02/97
7 // RCS-ID: $Id$
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 // for compilers that support precompilation, includes "wx.h".
13 #include "wx/wxprec.h"
14
15 #include "wx/dcmemory.h"
16
17 #ifndef WX_PRECOMP
18 #include "wx/utils.h"
19 #include "wx/settings.h"
20 #endif
21
22 #include "wx/x11/private.h"
23
24 IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC,wxWindowDC)
25
26 wxMemoryDC::wxMemoryDC( const wxBitmap& bitmap )
27 : wxWindowDC()
28 {
29 m_ok = false;
30
31 m_display = (WXDisplay *) wxGlobalDisplay();
32
33 int screen = DefaultScreen( wxGlobalDisplay() );
34 m_cmap = (WXColormap) DefaultColormap( wxGlobalDisplay(), screen );
35
36 if ( bitmap.IsOk() )
37 SelectObject(bitmap);
38 }
39
40 wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) )
41 : wxWindowDC()
42 {
43 m_ok = false;
44
45 m_display = (WXDisplay *) wxGlobalDisplay();
46
47 int screen = DefaultScreen( wxGlobalDisplay() );
48 m_cmap = (WXColormap) DefaultColormap( wxGlobalDisplay(), screen );
49 }
50
51 wxMemoryDC::~wxMemoryDC()
52 {
53 }
54
55 void wxMemoryDC::SelectObject( const wxBitmap& bitmap )
56 {
57 Destroy();
58
59 m_selected = bitmap;
60 if (m_selected.Ok())
61 {
62 if (m_selected.GetPixmap())
63 {
64 m_window = (WXWindow) m_selected.GetPixmap();
65 }
66 else
67 {
68 m_window = m_selected.GetBitmap();
69 }
70
71 m_isMemDC = true;
72
73 SetUpDC();
74 }
75 else
76 {
77 m_ok = false;
78 m_window = NULL;
79 }
80 }
81
82 void wxMemoryDC::DoGetSize( int *width, int *height ) const
83 {
84 if (m_selected.Ok())
85 {
86 if (width) (*width) = m_selected.GetWidth();
87 if (height) (*height) = m_selected.GetHeight();
88 }
89 else
90 {
91 if (width) (*width) = 0;
92 if (height) (*height) = 0;
93 }
94 }