]>
Commit | Line | Data |
---|---|---|
1 | ///////////////////////////////////////////////////////////////////////////// | |
2 | // Name: src/x11/dcmemory.cpp | |
3 | // Purpose: wxMemoryDC class | |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 01/02/97 | |
7 | // Copyright: (c) Julian Smart | |
8 | // Licence: wxWindows licence | |
9 | ///////////////////////////////////////////////////////////////////////////// | |
10 | ||
11 | // for compilers that support precompilation, includes "wx.h". | |
12 | #include "wx/wxprec.h" | |
13 | ||
14 | #include "wx/dcmemory.h" | |
15 | ||
16 | #ifndef WX_PRECOMP | |
17 | #include "wx/utils.h" | |
18 | #include "wx/settings.h" | |
19 | #endif | |
20 | ||
21 | #include "wx/x11/private.h" | |
22 | #include "wx/x11/dcmemory.h" | |
23 | ||
24 | IMPLEMENT_ABSTRACT_CLASS(wxMemoryDCImpl,wxWindowDCImpl) | |
25 | ||
26 | wxMemoryDCImpl::wxMemoryDCImpl( wxDC *owner ) | |
27 | : wxWindowDCImpl( owner ) | |
28 | { | |
29 | Init(); | |
30 | } | |
31 | ||
32 | wxMemoryDCImpl::wxMemoryDCImpl( wxDC *owner, wxBitmap& bitmap ) | |
33 | : wxWindowDCImpl( owner ) | |
34 | { | |
35 | Init(); | |
36 | DoSelect(bitmap); | |
37 | } | |
38 | ||
39 | wxMemoryDCImpl::wxMemoryDCImpl( wxDC* owner, wxDC *WXUNUSED(dc) ) | |
40 | : wxWindowDCImpl( owner ) | |
41 | { | |
42 | Init(); | |
43 | } | |
44 | ||
45 | void wxMemoryDCImpl::Init() | |
46 | { | |
47 | m_ok = false; | |
48 | ||
49 | m_display = (WXDisplay *) wxGlobalDisplay(); | |
50 | ||
51 | int screen = DefaultScreen( wxGlobalDisplay() ); | |
52 | m_cmap = (WXColormap) DefaultColormap( wxGlobalDisplay(), screen ); | |
53 | } | |
54 | ||
55 | wxMemoryDCImpl::~wxMemoryDCImpl() | |
56 | { | |
57 | } | |
58 | ||
59 | void wxMemoryDCImpl::DoSelect( const wxBitmap& bitmap ) | |
60 | { | |
61 | Destroy(); | |
62 | ||
63 | m_selected = bitmap; | |
64 | if (m_selected.IsOk()) | |
65 | { | |
66 | if (m_selected.GetPixmap()) | |
67 | { | |
68 | m_x11window = (WXWindow) m_selected.GetPixmap(); | |
69 | } | |
70 | else | |
71 | { | |
72 | m_x11window = m_selected.GetBitmap(); | |
73 | } | |
74 | ||
75 | m_isMemDC = true; | |
76 | ||
77 | SetUpDC(); | |
78 | } | |
79 | else | |
80 | { | |
81 | m_ok = false; | |
82 | m_x11window = NULL; | |
83 | } | |
84 | } | |
85 | ||
86 | void wxMemoryDCImpl::DoGetSize( int *width, int *height ) const | |
87 | { | |
88 | if (m_selected.IsOk()) | |
89 | { | |
90 | if (width) (*width) = m_selected.GetWidth(); | |
91 | if (height) (*height) = m_selected.GetHeight(); | |
92 | } | |
93 | else | |
94 | { | |
95 | if (width) (*width) = 0; | |
96 | if (height) (*height) = 0; | |
97 | } | |
98 | } | |
99 | ||
100 | const wxBitmap& wxMemoryDCImpl::GetSelectedBitmap() const | |
101 | { | |
102 | return m_selected; | |
103 | } | |
104 | ||
105 | wxBitmap& wxMemoryDCImpl::GetSelectedBitmap() | |
106 | { | |
107 | return m_selected; | |
108 | } |