]> git.saurik.com Git - wxWidgets.git/blame - src/motif/dcmemory.cpp
Minor header cleaning.
[wxWidgets.git] / src / motif / dcmemory.cpp
CommitLineData
4bb6408c 1/////////////////////////////////////////////////////////////////////////////
de6185e2 2// Name: src/motif/dcmemory.cpp
4bb6408c
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
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
4bb6408c 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
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"
4bb6408c
JS
31
32//-----------------------------------------------------------------------------
33// wxMemoryDC
34//-----------------------------------------------------------------------------
35
16c1f7f3 36IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC, wxWindowDC)
4bb6408c 37
432efcb0 38wxMemoryDC::wxMemoryDC( const wxBitmap& bitmap )
4bb6408c 39{
ea76a6a5 40 m_ok = true;
a4294b78 41 m_display = wxGetDisplay();
ea76a6a5 42
a4294b78 43 Display* display = (Display*) m_display;
ea76a6a5 44
a4294b78
JS
45 XGCValues gcvalues;
46 gcvalues.foreground = BlackPixel (display, DefaultScreen (display));
47 gcvalues.background = WhitePixel (display, DefaultScreen (display));
48 gcvalues.graphics_exposures = False;
66eca538 49 gcvalues.subwindow_mode = IncludeInferiors;
a4294b78
JS
50 gcvalues.line_width = 1;
51 m_gc = (WXGC) XCreateGC (display, RootWindow (display, DefaultScreen (display)),
66eca538 52 GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth | GCSubwindowMode,
2d120f83 53 &gcvalues);
ea76a6a5 54
3e0071d9 55 m_backgroundPixel = gcvalues.background;
ea76a6a5 56
c0ed460c
JS
57 SetBrush (* wxWHITE_BRUSH);
58 SetPen (* wxBLACK_PEN);
ea76a6a5 59 SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
432efcb0
RD
60
61 if ( bitmap.IsOk() )
62 SelectObject(bitmap);
e933b5bc 63}
4bb6408c 64
a4294b78 65wxMemoryDC::wxMemoryDC( wxDC* dc )
4bb6408c 66{
ea76a6a5 67 m_ok = true;
a4294b78
JS
68 if (dc && dc->IsKindOf(CLASSINFO(wxWindowDC)))
69 m_display = ((wxWindowDC*)dc)->GetDisplay();
70 else
71 m_display = wxGetDisplay();
ea76a6a5 72
a4294b78 73 Display* display = (Display*) m_display;
ea76a6a5 74
a4294b78
JS
75 XGCValues gcvalues;
76 gcvalues.foreground = BlackPixel (display, DefaultScreen (display));
77 gcvalues.background = WhitePixel (display, DefaultScreen (display));
78 gcvalues.graphics_exposures = False;
66eca538 79 gcvalues.subwindow_mode = IncludeInferiors;
a4294b78
JS
80 gcvalues.line_width = 1;
81 m_gc = (WXGC) XCreateGC (display, RootWindow (display, DefaultScreen (display)),
66eca538 82 GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth | GCSubwindowMode,
2d120f83 83 &gcvalues);
ea76a6a5 84
3e0071d9 85 m_backgroundPixel = gcvalues.background;
ea76a6a5 86
c0ed460c
JS
87 SetBrush (* wxWHITE_BRUSH);
88 SetPen (* wxBLACK_PEN);
e933b5bc 89}
4bb6408c
JS
90
91wxMemoryDC::~wxMemoryDC(void)
92{
e933b5bc 93}
4bb6408c
JS
94
95void wxMemoryDC::SelectObject( const wxBitmap& bitmap )
96{
2d120f83 97 m_bitmap = bitmap;
ea76a6a5 98
2d120f83
JS
99 if (m_gc)
100 XFreeGC((Display*) m_display, (GC) m_gc);
101 m_gc = (WXGC) NULL;
ea76a6a5 102
2d120f83
JS
103 if (m_bitmap.Ok() && (bitmap.GetDisplay() == m_display))
104 {
aae0472b 105 m_pixmap = m_bitmap.GetDrawable();
2d120f83 106 Display* display = (Display*) m_display;
ea76a6a5 107
2d120f83
JS
108 XGCValues gcvalues;
109 gcvalues.foreground = BlackPixel (display, DefaultScreen (display));
110 gcvalues.background = WhitePixel (display, DefaultScreen (display));
111 gcvalues.graphics_exposures = False;
66eca538 112 gcvalues.subwindow_mode = IncludeInferiors;
2d120f83 113 gcvalues.line_width = 1;
21342bba 114 m_gc = (WXGC) XCreateGC (display, (Drawable)m_pixmap/* RootWindow (display, DefaultScreen (display)) */,
66eca538 115 GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth | GCSubwindowMode,
2d120f83 116 &gcvalues);
ea76a6a5 117
3e0071d9 118 m_backgroundPixel = gcvalues.background;
ea76a6a5
WS
119 m_ok = true;
120
2d120f83
JS
121 SetBrush (* wxWHITE_BRUSH);
122 SetPen (* wxBLACK_PEN);
2d120f83
JS
123 }
124 else
125 {
96be256b 126 m_ok = false;
2d120f83
JS
127 m_pixmap = (WXPixmap) 0;
128 };
e933b5bc 129}
4bb6408c 130
96f201da 131void wxMemoryDC::DoGetSize( int *width, int *height ) const
4bb6408c 132{
2d120f83
JS
133 if (m_bitmap.Ok())
134 {
135 if (width) (*width) = m_bitmap.GetWidth();
136 if (height) (*height) = m_bitmap.GetHeight();
137 }
138 else
139 {
140 if (width) (*width) = 0;
141 if (height) (*height) = 0;
142 };
e933b5bc 143}