]> git.saurik.com Git - wxWidgets.git/blame - src/motif/dcmemory.cpp
don't overwrite the existing local file if we failed to open it but it does exist
[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
fea35690 38void wxMemoryDC::Init()
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));
e933b5bc 60}
4bb6408c 61
a4294b78 62wxMemoryDC::wxMemoryDC( wxDC* dc )
4bb6408c 63{
ea76a6a5 64 m_ok = true;
a4294b78
JS
65 if (dc && dc->IsKindOf(CLASSINFO(wxWindowDC)))
66 m_display = ((wxWindowDC*)dc)->GetDisplay();
67 else
68 m_display = wxGetDisplay();
ea76a6a5 69
a4294b78 70 Display* display = (Display*) m_display;
ea76a6a5 71
a4294b78
JS
72 XGCValues gcvalues;
73 gcvalues.foreground = BlackPixel (display, DefaultScreen (display));
74 gcvalues.background = WhitePixel (display, DefaultScreen (display));
75 gcvalues.graphics_exposures = False;
66eca538 76 gcvalues.subwindow_mode = IncludeInferiors;
a4294b78
JS
77 gcvalues.line_width = 1;
78 m_gc = (WXGC) XCreateGC (display, RootWindow (display, DefaultScreen (display)),
66eca538 79 GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth | GCSubwindowMode,
2d120f83 80 &gcvalues);
ea76a6a5 81
3e0071d9 82 m_backgroundPixel = gcvalues.background;
ea76a6a5 83
c0ed460c
JS
84 SetBrush (* wxWHITE_BRUSH);
85 SetPen (* wxBLACK_PEN);
e933b5bc 86}
4bb6408c
JS
87
88wxMemoryDC::~wxMemoryDC(void)
89{
e933b5bc 90}
4bb6408c 91
fea35690 92void wxMemoryDC::DoSelect( const wxBitmap& bitmap )
4bb6408c 93{
2d120f83 94 m_bitmap = bitmap;
ea76a6a5 95
2d120f83
JS
96 if (m_gc)
97 XFreeGC((Display*) m_display, (GC) m_gc);
98 m_gc = (WXGC) NULL;
ea76a6a5 99
2d120f83
JS
100 if (m_bitmap.Ok() && (bitmap.GetDisplay() == m_display))
101 {
aae0472b 102 m_pixmap = m_bitmap.GetDrawable();
2d120f83 103 Display* display = (Display*) m_display;
ea76a6a5 104
2d120f83
JS
105 XGCValues gcvalues;
106 gcvalues.foreground = BlackPixel (display, DefaultScreen (display));
107 gcvalues.background = WhitePixel (display, DefaultScreen (display));
108 gcvalues.graphics_exposures = False;
66eca538 109 gcvalues.subwindow_mode = IncludeInferiors;
2d120f83 110 gcvalues.line_width = 1;
21342bba 111 m_gc = (WXGC) XCreateGC (display, (Drawable)m_pixmap/* RootWindow (display, DefaultScreen (display)) */,
66eca538 112 GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth | GCSubwindowMode,
2d120f83 113 &gcvalues);
ea76a6a5 114
3e0071d9 115 m_backgroundPixel = gcvalues.background;
ea76a6a5
WS
116 m_ok = true;
117
2d120f83
JS
118 SetBrush (* wxWHITE_BRUSH);
119 SetPen (* wxBLACK_PEN);
2d120f83
JS
120 }
121 else
122 {
96be256b 123 m_ok = false;
2d120f83
JS
124 m_pixmap = (WXPixmap) 0;
125 };
e933b5bc 126}
4bb6408c 127
96f201da 128void wxMemoryDC::DoGetSize( int *width, int *height ) const
4bb6408c 129{
2d120f83
JS
130 if (m_bitmap.Ok())
131 {
132 if (width) (*width) = m_bitmap.GetWidth();
133 if (height) (*height) = m_bitmap.GetHeight();
134 }
135 else
136 {
137 if (width) (*width) = 0;
138 if (height) (*height) = 0;
139 };
e933b5bc 140}