]> git.saurik.com Git - wxWidgets.git/blame - src/motif/dcmemory.cpp
Added a check for -lresolv in configure.in
[wxWidgets.git] / src / motif / dcmemory.cpp
CommitLineData
4bb6408c
JS
1/////////////////////////////////////////////////////////////////////////////
2// Name: 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#ifdef __GNUG__
13#pragma implementation "dcmemory.h"
14#endif
15
16#include "wx/dcmemory.h"
a4294b78
JS
17#include "wx/utils.h"
18
19#include <Xm/Xm.h>
20
21#include "wx/motif/private.h"
4bb6408c
JS
22
23//-----------------------------------------------------------------------------
24// wxMemoryDC
25//-----------------------------------------------------------------------------
26
16c1f7f3 27IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC, wxWindowDC)
4bb6408c
JS
28
29wxMemoryDC::wxMemoryDC(void)
30{
a4294b78
JS
31 m_ok = TRUE;
32 m_display = wxGetDisplay();
2d120f83 33
a4294b78 34 Display* display = (Display*) m_display;
2d120f83 35
a4294b78
JS
36 XGCValues gcvalues;
37 gcvalues.foreground = BlackPixel (display, DefaultScreen (display));
38 gcvalues.background = WhitePixel (display, DefaultScreen (display));
39 gcvalues.graphics_exposures = False;
40 gcvalues.line_width = 1;
41 m_gc = (WXGC) XCreateGC (display, RootWindow (display, DefaultScreen (display)),
42 GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth,
2d120f83
JS
43 &gcvalues);
44
a4294b78 45 m_backgroundPixel = (int) gcvalues.background;
2d120f83 46
a4294b78
JS
47 // Get the current Font so we can set it back later
48 XGCValues valReturn;
49 XGetGCValues((Display*) m_display, (GC) m_gc, GCFont, &valReturn);
50 m_oldFont = (WXFont) valReturn.font;
c0ed460c
JS
51 SetBrush (* wxWHITE_BRUSH);
52 SetPen (* wxBLACK_PEN);
4bb6408c
JS
53};
54
a4294b78 55wxMemoryDC::wxMemoryDC( wxDC* dc )
4bb6408c 56{
a4294b78
JS
57 m_ok = TRUE;
58 if (dc && dc->IsKindOf(CLASSINFO(wxWindowDC)))
59 m_display = ((wxWindowDC*)dc)->GetDisplay();
60 else
61 m_display = wxGetDisplay();
2d120f83 62
a4294b78 63 Display* display = (Display*) m_display;
2d120f83 64
a4294b78
JS
65 XGCValues gcvalues;
66 gcvalues.foreground = BlackPixel (display, DefaultScreen (display));
67 gcvalues.background = WhitePixel (display, DefaultScreen (display));
68 gcvalues.graphics_exposures = False;
69 gcvalues.line_width = 1;
70 m_gc = (WXGC) XCreateGC (display, RootWindow (display, DefaultScreen (display)),
71 GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth,
2d120f83
JS
72 &gcvalues);
73
a4294b78 74 m_backgroundPixel = (int) gcvalues.background;
2d120f83 75
a4294b78
JS
76 // Get the current Font so we can set it back later
77 XGCValues valReturn;
78 XGetGCValues((Display*) m_display, (GC) m_gc, GCFont, &valReturn);
79 m_oldFont = (WXFont) valReturn.font;
c0ed460c
JS
80 SetBrush (* wxWHITE_BRUSH);
81 SetPen (* wxBLACK_PEN);
4bb6408c
JS
82};
83
84wxMemoryDC::~wxMemoryDC(void)
85{
86};
87
88void wxMemoryDC::SelectObject( const wxBitmap& bitmap )
89{
2d120f83 90 m_bitmap = bitmap;
a4294b78 91
2d120f83
JS
92 if (m_gc)
93 XFreeGC((Display*) m_display, (GC) m_gc);
94 m_gc = (WXGC) NULL;
95
96 if (m_bitmap.Ok() && (bitmap.GetDisplay() == m_display))
97 {
98 m_pixmap = m_bitmap.GetPixmap();
99 Display* display = (Display*) m_display;
100
101 XGCValues gcvalues;
102 gcvalues.foreground = BlackPixel (display, DefaultScreen (display));
103 gcvalues.background = WhitePixel (display, DefaultScreen (display));
104 gcvalues.graphics_exposures = False;
105 gcvalues.line_width = 1;
106 m_gc = (WXGC) XCreateGC (display, RootWindow (display, DefaultScreen (display)),
107 GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth,
108 &gcvalues);
109
110 m_backgroundPixel = (int) gcvalues.background;
111
112 // Get the current Font so we can set it back later
113 XGCValues valReturn;
114 XGetGCValues((Display*) m_display, (GC) m_gc, GCFont, &valReturn);
115 m_oldFont = (WXFont) valReturn.font;
116
117 bool oldOpt = GetOptimization();
118 SetOptimization(FALSE);
119
120 SetBrush (* wxWHITE_BRUSH);
121 SetPen (* wxBLACK_PEN);
122
123 SetOptimization(oldOpt);
124
125 m_ok = TRUE;
126 }
127 else
128 {
129 m_ok = FALSE;
130 m_pixmap = (WXPixmap) 0;
131 };
4bb6408c
JS
132};
133
96f201da 134void wxMemoryDC::DoGetSize( int *width, int *height ) const
4bb6408c 135{
2d120f83
JS
136 if (m_bitmap.Ok())
137 {
138 if (width) (*width) = m_bitmap.GetWidth();
139 if (height) (*height) = m_bitmap.GetHeight();
140 }
141 else
142 {
143 if (width) (*width) = 0;
144 if (height) (*height) = 0;
145 };
4bb6408c
JS
146};
147
148