]> git.saurik.com Git - wxWidgets.git/blob - src/x11/dcmemory.cpp
Move menu messages handling from wxFrame to wxTLW in wxMSW.
[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 #include "wx/x11/dcmemory.h"
24
25 IMPLEMENT_ABSTRACT_CLASS(wxMemoryDCImpl,wxWindowDCImpl)
26
27 wxMemoryDCImpl::wxMemoryDCImpl( wxDC *owner )
28 : wxWindowDCImpl( owner )
29 {
30 Init();
31 }
32
33 wxMemoryDCImpl::wxMemoryDCImpl( wxDC *owner, wxBitmap& bitmap )
34 : wxWindowDCImpl( owner )
35 {
36 Init();
37 DoSelect(bitmap);
38 }
39
40 wxMemoryDCImpl::wxMemoryDCImpl( wxDC* owner, wxDC *WXUNUSED(dc) )
41 : wxWindowDCImpl( owner )
42 {
43 Init();
44 }
45
46 void wxMemoryDCImpl::Init()
47 {
48 m_ok = false;
49
50 m_display = (WXDisplay *) wxGlobalDisplay();
51
52 int screen = DefaultScreen( wxGlobalDisplay() );
53 m_cmap = (WXColormap) DefaultColormap( wxGlobalDisplay(), screen );
54 }
55
56 wxMemoryDCImpl::~wxMemoryDCImpl()
57 {
58 }
59
60 void wxMemoryDCImpl::DoSelect( const wxBitmap& bitmap )
61 {
62 Destroy();
63
64 m_selected = bitmap;
65 if (m_selected.IsOk())
66 {
67 if (m_selected.GetPixmap())
68 {
69 m_x11window = (WXWindow) m_selected.GetPixmap();
70 }
71 else
72 {
73 m_x11window = m_selected.GetBitmap();
74 }
75
76 m_isMemDC = true;
77
78 SetUpDC();
79 }
80 else
81 {
82 m_ok = false;
83 m_x11window = NULL;
84 }
85 }
86
87 void wxMemoryDCImpl::DoGetSize( int *width, int *height ) const
88 {
89 if (m_selected.IsOk())
90 {
91 if (width) (*width) = m_selected.GetWidth();
92 if (height) (*height) = m_selected.GetHeight();
93 }
94 else
95 {
96 if (width) (*width) = 0;
97 if (height) (*height) = 0;
98 }
99 }
100
101 const wxBitmap& wxMemoryDCImpl::GetSelectedBitmap() const
102 {
103 return m_selected;
104 }
105
106 wxBitmap& wxMemoryDCImpl::GetSelectedBitmap()
107 {
108 return m_selected;
109 }