]> git.saurik.com Git - wxWidgets.git/blame - src/motif/dcmemory.cpp
use wxDiskspaceSize_t which is long and not wxLongLong if wxUSE_LONGLONG==0 (part...
[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
1248b41f
MB
12// For compilers that support precompilation, includes "wx.h".
13#include "wx/wxprec.h"
14
4bb6408c 15#include "wx/dcmemory.h"
0ba1a6f3 16#include "wx/settings.h"
a4294b78
JS
17#include "wx/utils.h"
18
338dd992
JJ
19#ifdef __VMS__
20#pragma message disable nosimpint
21#endif
a4294b78 22#include <Xm/Xm.h>
338dd992
JJ
23#ifdef __VMS__
24#pragma message enable nosimpint
25#endif
a4294b78
JS
26
27#include "wx/motif/private.h"
4bb6408c
JS
28
29//-----------------------------------------------------------------------------
30// wxMemoryDC
31//-----------------------------------------------------------------------------
32
16c1f7f3 33IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC, wxWindowDC)
4bb6408c
JS
34
35wxMemoryDC::wxMemoryDC(void)
36{
ea76a6a5 37 m_ok = true;
a4294b78 38 m_display = wxGetDisplay();
ea76a6a5 39
a4294b78 40 Display* display = (Display*) m_display;
ea76a6a5 41
a4294b78
JS
42 XGCValues gcvalues;
43 gcvalues.foreground = BlackPixel (display, DefaultScreen (display));
44 gcvalues.background = WhitePixel (display, DefaultScreen (display));
45 gcvalues.graphics_exposures = False;
66eca538 46 gcvalues.subwindow_mode = IncludeInferiors;
a4294b78
JS
47 gcvalues.line_width = 1;
48 m_gc = (WXGC) XCreateGC (display, RootWindow (display, DefaultScreen (display)),
66eca538 49 GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth | GCSubwindowMode,
2d120f83 50 &gcvalues);
ea76a6a5 51
a4294b78 52 m_backgroundPixel = (int) gcvalues.background;
ea76a6a5 53
c0ed460c
JS
54 SetBrush (* wxWHITE_BRUSH);
55 SetPen (* wxBLACK_PEN);
ea76a6a5 56 SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
e933b5bc 57}
4bb6408c 58
a4294b78 59wxMemoryDC::wxMemoryDC( wxDC* dc )
4bb6408c 60{
ea76a6a5 61 m_ok = true;
a4294b78
JS
62 if (dc && dc->IsKindOf(CLASSINFO(wxWindowDC)))
63 m_display = ((wxWindowDC*)dc)->GetDisplay();
64 else
65 m_display = wxGetDisplay();
ea76a6a5 66
a4294b78 67 Display* display = (Display*) m_display;
ea76a6a5 68
a4294b78
JS
69 XGCValues gcvalues;
70 gcvalues.foreground = BlackPixel (display, DefaultScreen (display));
71 gcvalues.background = WhitePixel (display, DefaultScreen (display));
72 gcvalues.graphics_exposures = False;
66eca538 73 gcvalues.subwindow_mode = IncludeInferiors;
a4294b78
JS
74 gcvalues.line_width = 1;
75 m_gc = (WXGC) XCreateGC (display, RootWindow (display, DefaultScreen (display)),
66eca538 76 GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth | GCSubwindowMode,
2d120f83 77 &gcvalues);
ea76a6a5 78
a4294b78 79 m_backgroundPixel = (int) gcvalues.background;
ea76a6a5 80
c0ed460c
JS
81 SetBrush (* wxWHITE_BRUSH);
82 SetPen (* wxBLACK_PEN);
e933b5bc 83}
4bb6408c
JS
84
85wxMemoryDC::~wxMemoryDC(void)
86{
e933b5bc 87}
4bb6408c
JS
88
89void wxMemoryDC::SelectObject( const wxBitmap& bitmap )
90{
2d120f83 91 m_bitmap = bitmap;
ea76a6a5 92
2d120f83
JS
93 if (m_gc)
94 XFreeGC((Display*) m_display, (GC) m_gc);
95 m_gc = (WXGC) NULL;
ea76a6a5 96
2d120f83
JS
97 if (m_bitmap.Ok() && (bitmap.GetDisplay() == m_display))
98 {
aae0472b 99 m_pixmap = m_bitmap.GetDrawable();
2d120f83 100 Display* display = (Display*) m_display;
ea76a6a5 101
2d120f83
JS
102 XGCValues gcvalues;
103 gcvalues.foreground = BlackPixel (display, DefaultScreen (display));
104 gcvalues.background = WhitePixel (display, DefaultScreen (display));
105 gcvalues.graphics_exposures = False;
66eca538 106 gcvalues.subwindow_mode = IncludeInferiors;
2d120f83 107 gcvalues.line_width = 1;
21342bba 108 m_gc = (WXGC) XCreateGC (display, (Drawable)m_pixmap/* RootWindow (display, DefaultScreen (display)) */,
66eca538 109 GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth | GCSubwindowMode,
2d120f83 110 &gcvalues);
ea76a6a5 111
2d120f83 112 m_backgroundPixel = (int) gcvalues.background;
ea76a6a5
WS
113 m_ok = true;
114
2d120f83
JS
115 SetBrush (* wxWHITE_BRUSH);
116 SetPen (* wxBLACK_PEN);
2d120f83
JS
117 }
118 else
119 {
96be256b 120 m_ok = false;
2d120f83
JS
121 m_pixmap = (WXPixmap) 0;
122 };
e933b5bc 123}
4bb6408c 124
96f201da 125void wxMemoryDC::DoGetSize( int *width, int *height ) const
4bb6408c 126{
2d120f83
JS
127 if (m_bitmap.Ok())
128 {
129 if (width) (*width) = m_bitmap.GetWidth();
130 if (height) (*height) = m_bitmap.GetHeight();
131 }
132 else
133 {
134 if (width) (*width) = 0;
135 if (height) (*height) = 0;
136 };
e933b5bc 137}
4bb6408c
JS
138
139