Include wx/utils.h according to precompiled headers of wx/wx.h (with other minor...
[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 #endif
20
21 #include "wx/settings.h"
22
23 #include "wx/x11/private.h"
24
25 IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC,wxWindowDC)
26
27 wxMemoryDC::wxMemoryDC() : 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
37 wxMemoryDC::wxMemoryDC( wxDC *WXUNUSED(dc) )
38 : wxWindowDC()
39 {
40 m_ok = false;
41
42 m_display = (WXDisplay *) wxGlobalDisplay();
43
44 int screen = DefaultScreen( wxGlobalDisplay() );
45 m_cmap = (WXColormap) DefaultColormap( wxGlobalDisplay(), screen );
46 }
47
48 wxMemoryDC::~wxMemoryDC()
49 {
50 }
51
52 void wxMemoryDC::SelectObject( const wxBitmap& bitmap )
53 {
54 Destroy();
55
56 m_selected = bitmap;
57 if (m_selected.Ok())
58 {
59 if (m_selected.GetPixmap())
60 {
61 m_window = (WXWindow) m_selected.GetPixmap();
62 }
63 else
64 {
65 m_window = m_selected.GetBitmap();
66 }
67
68 m_isMemDC = true;
69
70 SetUpDC();
71 }
72 else
73 {
74 m_ok = false;
75 m_window = NULL;
76 }
77 }
78
79 void wxMemoryDC::DoGetSize( int *width, int *height ) const
80 {
81 if (m_selected.Ok())
82 {
83 if (width) (*width) = m_selected.GetWidth();
84 if (height) (*height) = m_selected.GetHeight();
85 }
86 else
87 {
88 if (width) (*width) = 0;
89 if (height) (*height) = 0;
90 }
91 }