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