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