]> git.saurik.com Git - wxWidgets.git/blame - src/x11/dcmemory.cpp
non-pch build fix
[wxWidgets.git] / src / x11 / dcmemory.cpp
CommitLineData
83df96d6 1/////////////////////////////////////////////////////////////////////////////
de6185e2 2// Name: src/x11/dcmemory.cpp
83df96d6
JS
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
de6185e2 9// Licence: wxWindows licence
83df96d6
JS
10/////////////////////////////////////////////////////////////////////////////
11
de6185e2
WS
12// for compilers that support precompilation, includes "wx.h".
13#include "wx/wxprec.h"
14
83df96d6 15#include "wx/dcmemory.h"
de6185e2
WS
16
17#ifndef WX_PRECOMP
18 #include "wx/utils.h"
9eddec69 19 #include "wx/settings.h"
de6185e2
WS
20#endif
21
7266b672 22#include "wx/x11/private.h"
2b77c3fc 23#include "wx/x11/dcmemory.h"
83df96d6 24
2b77c3fc 25IMPLEMENT_ABSTRACT_CLASS(wxMemoryDCImpl,wxWindowDCImpl)
83df96d6 26
2b77c3fc
RR
27wxMemoryDCImpl::wxMemoryDCImpl( wxDC *owner )
28 : wxWindowDCImpl( owner )
03647350 29{
2b77c3fc
RR
30 Init();
31}
32
33wxMemoryDCImpl::wxMemoryDCImpl( wxDC *owner, wxBitmap& bitmap )
34 : wxWindowDCImpl( owner )
03647350
VZ
35{
36 Init();
2b77c3fc
RR
37 DoSelect(bitmap);
38}
39
40wxMemoryDCImpl::wxMemoryDCImpl( wxDC* owner, wxDC *WXUNUSED(dc) )
41 : wxWindowDCImpl( owner )
42{
43 Init();
44}
45
46void wxMemoryDCImpl::Init()
83df96d6 47{
de6185e2
WS
48 m_ok = false;
49
3cd0b8c5
RR
50 m_display = (WXDisplay *) wxGlobalDisplay();
51
52 int screen = DefaultScreen( wxGlobalDisplay() );
53 m_cmap = (WXColormap) DefaultColormap( wxGlobalDisplay(), screen );
54}
83df96d6 55
2b77c3fc 56wxMemoryDCImpl::~wxMemoryDCImpl()
83df96d6 57{
3cd0b8c5 58}
83df96d6 59
2b77c3fc 60void wxMemoryDCImpl::DoSelect( const wxBitmap& bitmap )
83df96d6 61{
3cd0b8c5 62 Destroy();
de6185e2 63
3cd0b8c5
RR
64 m_selected = bitmap;
65 if (m_selected.Ok())
83df96d6 66 {
3cd0b8c5
RR
67 if (m_selected.GetPixmap())
68 {
2b77c3fc 69 m_x11window = (WXWindow) m_selected.GetPixmap();
3cd0b8c5
RR
70 }
71 else
72 {
2b77c3fc 73 m_x11window = m_selected.GetBitmap();
3cd0b8c5
RR
74 }
75
de6185e2 76 m_isMemDC = true;
3cd0b8c5
RR
77
78 SetUpDC();
83df96d6
JS
79 }
80 else
81 {
de6185e2 82 m_ok = false;
2b77c3fc 83 m_x11window = NULL;
3cd0b8c5
RR
84 }
85}
83df96d6 86
2b77c3fc 87void wxMemoryDCImpl::DoGetSize( int *width, int *height ) const
83df96d6 88{
3cd0b8c5 89 if (m_selected.Ok())
83df96d6 90 {
3cd0b8c5
RR
91 if (width) (*width) = m_selected.GetWidth();
92 if (height) (*height) = m_selected.GetHeight();
83df96d6
JS
93 }
94 else
95 {
96 if (width) (*width) = 0;
97 if (height) (*height) = 0;
3cd0b8c5
RR
98 }
99}
2b77c3fc
RR
100
101const wxBitmap& wxMemoryDCImpl::GetSelectedBitmap() const
102{
103 return m_selected;
104}
105
106wxBitmap& wxMemoryDCImpl::GetSelectedBitmap()
107{
108 return m_selected;
109}