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