]> git.saurik.com Git - wxWidgets.git/blame_incremental - src/motif/dcmemory.cpp
Minor header cleaning.
[wxWidgets.git] / src / motif / dcmemory.cpp
... / ...
CommitLineData
1/////////////////////////////////////////////////////////////////////////////
2// Name: src/motif/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#ifdef __VMS__
23#pragma message disable nosimpint
24#endif
25#include <Xm/Xm.h>
26#ifdef __VMS__
27#pragma message enable nosimpint
28#endif
29
30#include "wx/motif/private.h"
31
32//-----------------------------------------------------------------------------
33// wxMemoryDC
34//-----------------------------------------------------------------------------
35
36IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC, wxWindowDC)
37
38wxMemoryDC::wxMemoryDC( const wxBitmap& bitmap )
39{
40 m_ok = true;
41 m_display = wxGetDisplay();
42
43 Display* display = (Display*) m_display;
44
45 XGCValues gcvalues;
46 gcvalues.foreground = BlackPixel (display, DefaultScreen (display));
47 gcvalues.background = WhitePixel (display, DefaultScreen (display));
48 gcvalues.graphics_exposures = False;
49 gcvalues.subwindow_mode = IncludeInferiors;
50 gcvalues.line_width = 1;
51 m_gc = (WXGC) XCreateGC (display, RootWindow (display, DefaultScreen (display)),
52 GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth | GCSubwindowMode,
53 &gcvalues);
54
55 m_backgroundPixel = gcvalues.background;
56
57 SetBrush (* wxWHITE_BRUSH);
58 SetPen (* wxBLACK_PEN);
59 SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
60
61 if ( bitmap.IsOk() )
62 SelectObject(bitmap);
63}
64
65wxMemoryDC::wxMemoryDC( wxDC* dc )
66{
67 m_ok = true;
68 if (dc && dc->IsKindOf(CLASSINFO(wxWindowDC)))
69 m_display = ((wxWindowDC*)dc)->GetDisplay();
70 else
71 m_display = wxGetDisplay();
72
73 Display* display = (Display*) m_display;
74
75 XGCValues gcvalues;
76 gcvalues.foreground = BlackPixel (display, DefaultScreen (display));
77 gcvalues.background = WhitePixel (display, DefaultScreen (display));
78 gcvalues.graphics_exposures = False;
79 gcvalues.subwindow_mode = IncludeInferiors;
80 gcvalues.line_width = 1;
81 m_gc = (WXGC) XCreateGC (display, RootWindow (display, DefaultScreen (display)),
82 GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth | GCSubwindowMode,
83 &gcvalues);
84
85 m_backgroundPixel = gcvalues.background;
86
87 SetBrush (* wxWHITE_BRUSH);
88 SetPen (* wxBLACK_PEN);
89}
90
91wxMemoryDC::~wxMemoryDC(void)
92{
93}
94
95void wxMemoryDC::SelectObject( const wxBitmap& bitmap )
96{
97 m_bitmap = bitmap;
98
99 if (m_gc)
100 XFreeGC((Display*) m_display, (GC) m_gc);
101 m_gc = (WXGC) NULL;
102
103 if (m_bitmap.Ok() && (bitmap.GetDisplay() == m_display))
104 {
105 m_pixmap = m_bitmap.GetDrawable();
106 Display* display = (Display*) m_display;
107
108 XGCValues gcvalues;
109 gcvalues.foreground = BlackPixel (display, DefaultScreen (display));
110 gcvalues.background = WhitePixel (display, DefaultScreen (display));
111 gcvalues.graphics_exposures = False;
112 gcvalues.subwindow_mode = IncludeInferiors;
113 gcvalues.line_width = 1;
114 m_gc = (WXGC) XCreateGC (display, (Drawable)m_pixmap/* RootWindow (display, DefaultScreen (display)) */,
115 GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth | GCSubwindowMode,
116 &gcvalues);
117
118 m_backgroundPixel = gcvalues.background;
119 m_ok = true;
120
121 SetBrush (* wxWHITE_BRUSH);
122 SetPen (* wxBLACK_PEN);
123 }
124 else
125 {
126 m_ok = false;
127 m_pixmap = (WXPixmap) 0;
128 };
129}
130
131void wxMemoryDC::DoGetSize( int *width, int *height ) const
132{
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 };
143}