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