]> git.saurik.com Git - wxWidgets.git/blame - src/motif/dcmemory.cpp
Add wxDataViewRendererBase::PrepareForItem() helper.
[wxWidgets.git] / src / motif / dcmemory.cpp
CommitLineData
4bb6408c 1/////////////////////////////////////////////////////////////////////////////
de6185e2 2// Name: src/motif/dcmemory.cpp
fce127d7 3// Purpose: wxMemoryDCImpl class
4bb6408c
JS
4// Author: Julian Smart
5// Modified by:
6// Created: 01/02/97
7// RCS-ID: $Id$
8// Copyright: (c) Julian Smart
ea76a6a5 9// Licence: wxWindows licence
4bb6408c
JS
10/////////////////////////////////////////////////////////////////////////////
11
1248b41f
MB
12// For compilers that support precompilation, includes "wx.h".
13#include "wx/wxprec.h"
14
de6185e2
WS
15#ifndef WX_PRECOMP
16 #include "wx/utils.h"
9eddec69 17 #include "wx/settings.h"
76c32e7b
JJ
18 #include "wx/dcmemory.h"
19 #include "wx/dcclient.h"
de6185e2
WS
20#endif
21
338dd992
JJ
22#ifdef __VMS__
23#pragma message disable nosimpint
24#endif
a4294b78 25#include <Xm/Xm.h>
338dd992
JJ
26#ifdef __VMS__
27#pragma message enable nosimpint
28#endif
a4294b78
JS
29
30#include "wx/motif/private.h"
fce127d7 31#include "wx/motif/dcmemory.h"
4bb6408c
JS
32
33//-----------------------------------------------------------------------------
fce127d7 34// wxMemoryDCImpl
4bb6408c
JS
35//-----------------------------------------------------------------------------
36
fce127d7 37IMPLEMENT_ABSTRACT_CLASS(wxMemoryDCImpl, wxWindowDCImpl)
4bb6408c 38
fce127d7 39void wxMemoryDCImpl::Init()
4bb6408c 40{
ea76a6a5 41 m_ok = true;
a4294b78 42 m_display = wxGetDisplay();
ea76a6a5 43
a4294b78 44 Display* display = (Display*) m_display;
ea76a6a5 45
a4294b78
JS
46 XGCValues gcvalues;
47 gcvalues.foreground = BlackPixel (display, DefaultScreen (display));
48 gcvalues.background = WhitePixel (display, DefaultScreen (display));
49 gcvalues.graphics_exposures = False;
66eca538 50 gcvalues.subwindow_mode = IncludeInferiors;
a4294b78
JS
51 gcvalues.line_width = 1;
52 m_gc = (WXGC) XCreateGC (display, RootWindow (display, DefaultScreen (display)),
66eca538 53 GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth | GCSubwindowMode,
2d120f83 54 &gcvalues);
ea76a6a5 55
3e0071d9 56 m_backgroundPixel = gcvalues.background;
ea76a6a5 57
c0ed460c
JS
58 SetBrush (* wxWHITE_BRUSH);
59 SetPen (* wxBLACK_PEN);
ea76a6a5 60 SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
e933b5bc 61}
4bb6408c 62
fce127d7
VZ
63wxMemoryDCImpl::wxMemoryDCImpl(wxMemoryDC *owner, wxDC* dc)
64 : wxWindowDCImpl(owner)
4bb6408c 65{
ea76a6a5 66 m_ok = true;
a4294b78 67 if (dc && dc->IsKindOf(CLASSINFO(wxWindowDC)))
fce127d7 68 m_display = ((wxWindowDCImpl *)dc->GetImpl())->GetDisplay();
a4294b78
JS
69 else
70 m_display = wxGetDisplay();
ea76a6a5 71
a4294b78 72 Display* display = (Display*) m_display;
ea76a6a5 73
a4294b78
JS
74 XGCValues gcvalues;
75 gcvalues.foreground = BlackPixel (display, DefaultScreen (display));
76 gcvalues.background = WhitePixel (display, DefaultScreen (display));
77 gcvalues.graphics_exposures = False;
66eca538 78 gcvalues.subwindow_mode = IncludeInferiors;
a4294b78
JS
79 gcvalues.line_width = 1;
80 m_gc = (WXGC) XCreateGC (display, RootWindow (display, DefaultScreen (display)),
66eca538 81 GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth | GCSubwindowMode,
2d120f83 82 &gcvalues);
ea76a6a5 83
3e0071d9 84 m_backgroundPixel = gcvalues.background;
ea76a6a5 85
c0ed460c
JS
86 SetBrush (* wxWHITE_BRUSH);
87 SetPen (* wxBLACK_PEN);
e933b5bc 88}
4bb6408c 89
fce127d7 90wxMemoryDCImpl::~wxMemoryDCImpl(void)
4bb6408c 91{
e933b5bc 92}
4bb6408c 93
fce127d7 94void wxMemoryDCImpl::DoSelect( const wxBitmap& bitmap )
4bb6408c 95{
2d120f83 96 m_bitmap = bitmap;
ea76a6a5 97
2d120f83
JS
98 if (m_gc)
99 XFreeGC((Display*) m_display, (GC) m_gc);
100 m_gc = (WXGC) NULL;
ea76a6a5 101
2d120f83
JS
102 if (m_bitmap.Ok() && (bitmap.GetDisplay() == m_display))
103 {
aae0472b 104 m_pixmap = m_bitmap.GetDrawable();
2d120f83 105 Display* display = (Display*) m_display;
ea76a6a5 106
2d120f83
JS
107 XGCValues gcvalues;
108 gcvalues.foreground = BlackPixel (display, DefaultScreen (display));
109 gcvalues.background = WhitePixel (display, DefaultScreen (display));
110 gcvalues.graphics_exposures = False;
66eca538 111 gcvalues.subwindow_mode = IncludeInferiors;
2d120f83 112 gcvalues.line_width = 1;
21342bba 113 m_gc = (WXGC) XCreateGC (display, (Drawable)m_pixmap/* RootWindow (display, DefaultScreen (display)) */,
66eca538 114 GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth | GCSubwindowMode,
2d120f83 115 &gcvalues);
ea76a6a5 116
3e0071d9 117 m_backgroundPixel = gcvalues.background;
ea76a6a5
WS
118 m_ok = true;
119
2d120f83
JS
120 SetBrush (* wxWHITE_BRUSH);
121 SetPen (* wxBLACK_PEN);
2d120f83
JS
122 }
123 else
124 {
96be256b 125 m_ok = false;
2d120f83
JS
126 m_pixmap = (WXPixmap) 0;
127 };
e933b5bc 128}
4bb6408c 129
fce127d7 130void wxMemoryDCImpl::DoGetSize( int *width, int *height ) const
4bb6408c 131{
2d120f83
JS
132 if (m_bitmap.Ok())
133 {
134 if (width) (*width) = m_bitmap.GetWidth();
135 if (height) (*height) = m_bitmap.GetHeight();
136 }
137 else
138 {
139 if (width) (*width) = 0;
140 if (height) (*height) = 0;
141 };
e933b5bc 142}