]> git.saurik.com Git - wxWidgets.git/blame - src/motif/dcmemory.cpp
added possibility to throw different objects and crash directly from the main frame...
[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
ea76a6a5 9// Licence: wxWindows licence
4bb6408c
JS
10/////////////////////////////////////////////////////////////////////////////
11
14f355c2 12#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
4bb6408c
JS
13#pragma implementation "dcmemory.h"
14#endif
15
1248b41f
MB
16// For compilers that support precompilation, includes "wx.h".
17#include "wx/wxprec.h"
18
4bb6408c 19#include "wx/dcmemory.h"
0ba1a6f3 20#include "wx/settings.h"
a4294b78
JS
21#include "wx/utils.h"
22
338dd992
JJ
23#ifdef __VMS__
24#pragma message disable nosimpint
25#endif
a4294b78 26#include <Xm/Xm.h>
338dd992
JJ
27#ifdef __VMS__
28#pragma message enable nosimpint
29#endif
a4294b78
JS
30
31#include "wx/motif/private.h"
4bb6408c
JS
32
33//-----------------------------------------------------------------------------
34// wxMemoryDC
35//-----------------------------------------------------------------------------
36
16c1f7f3 37IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC, wxWindowDC)
4bb6408c
JS
38
39wxMemoryDC::wxMemoryDC(void)
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
a4294b78 56 m_backgroundPixel = (int) gcvalues.background;
ea76a6a5 57
a4294b78
JS
58 // Get the current Font so we can set it back later
59 XGCValues valReturn;
60 XGetGCValues((Display*) m_display, (GC) m_gc, GCFont, &valReturn);
61 m_oldFont = (WXFont) valReturn.font;
c0ed460c
JS
62 SetBrush (* wxWHITE_BRUSH);
63 SetPen (* wxBLACK_PEN);
ea76a6a5 64 SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
4bb6408c
JS
65};
66
a4294b78 67wxMemoryDC::wxMemoryDC( wxDC* dc )
4bb6408c 68{
ea76a6a5 69 m_ok = true;
a4294b78
JS
70 if (dc && dc->IsKindOf(CLASSINFO(wxWindowDC)))
71 m_display = ((wxWindowDC*)dc)->GetDisplay();
72 else
73 m_display = wxGetDisplay();
ea76a6a5 74
a4294b78 75 Display* display = (Display*) m_display;
ea76a6a5 76
a4294b78
JS
77 XGCValues gcvalues;
78 gcvalues.foreground = BlackPixel (display, DefaultScreen (display));
79 gcvalues.background = WhitePixel (display, DefaultScreen (display));
80 gcvalues.graphics_exposures = False;
66eca538 81 gcvalues.subwindow_mode = IncludeInferiors;
a4294b78
JS
82 gcvalues.line_width = 1;
83 m_gc = (WXGC) XCreateGC (display, RootWindow (display, DefaultScreen (display)),
66eca538 84 GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth | GCSubwindowMode,
2d120f83 85 &gcvalues);
ea76a6a5 86
a4294b78 87 m_backgroundPixel = (int) gcvalues.background;
ea76a6a5 88
a4294b78
JS
89 // Get the current Font so we can set it back later
90 XGCValues valReturn;
91 XGetGCValues((Display*) m_display, (GC) m_gc, GCFont, &valReturn);
92 m_oldFont = (WXFont) valReturn.font;
c0ed460c
JS
93 SetBrush (* wxWHITE_BRUSH);
94 SetPen (* wxBLACK_PEN);
4bb6408c
JS
95};
96
97wxMemoryDC::~wxMemoryDC(void)
98{
99};
100
101void wxMemoryDC::SelectObject( const wxBitmap& bitmap )
102{
2d120f83 103 m_bitmap = bitmap;
ea76a6a5 104
2d120f83
JS
105 if (m_gc)
106 XFreeGC((Display*) m_display, (GC) m_gc);
107 m_gc = (WXGC) NULL;
ea76a6a5 108
2d120f83
JS
109 if (m_bitmap.Ok() && (bitmap.GetDisplay() == m_display))
110 {
aae0472b 111 m_pixmap = m_bitmap.GetDrawable();
2d120f83 112 Display* display = (Display*) m_display;
ea76a6a5 113
2d120f83
JS
114 XGCValues gcvalues;
115 gcvalues.foreground = BlackPixel (display, DefaultScreen (display));
116 gcvalues.background = WhitePixel (display, DefaultScreen (display));
117 gcvalues.graphics_exposures = False;
66eca538 118 gcvalues.subwindow_mode = IncludeInferiors;
2d120f83 119 gcvalues.line_width = 1;
21342bba 120 m_gc = (WXGC) XCreateGC (display, (Drawable)m_pixmap/* RootWindow (display, DefaultScreen (display)) */,
66eca538 121 GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth | GCSubwindowMode,
2d120f83 122 &gcvalues);
ea76a6a5 123
2d120f83 124 m_backgroundPixel = (int) gcvalues.background;
ea76a6a5
WS
125 m_ok = true;
126
2d120f83
JS
127 // Get the current Font so we can set it back later
128 XGCValues valReturn;
129 XGetGCValues((Display*) m_display, (GC) m_gc, GCFont, &valReturn);
130 m_oldFont = (WXFont) valReturn.font;
ea76a6a5 131
2d120f83
JS
132 SetBrush (* wxWHITE_BRUSH);
133 SetPen (* wxBLACK_PEN);
2d120f83
JS
134 }
135 else
136 {
96be256b 137 m_ok = false;
2d120f83
JS
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