]> git.saurik.com Git - wxWidgets.git/blob - src/motif/dcmemory.cpp
added mouse event member into wxHtmlLinkInfo. wxHtmlWindow::OnLinkClicked now takes...
[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 #ifdef __GNUG__
13 #pragma implementation "dcmemory.h"
14 #endif
15
16 #include "wx/dcmemory.h"
17 #include "wx/settings.h"
18 #include "wx/utils.h"
19
20 #ifdef __VMS__
21 #pragma message disable nosimpint
22 #endif
23 #include <Xm/Xm.h>
24 #ifdef __VMS__
25 #pragma message enable nosimpint
26 #endif
27
28 #include "wx/motif/private.h"
29
30 //-----------------------------------------------------------------------------
31 // wxMemoryDC
32 //-----------------------------------------------------------------------------
33
34 IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC, wxWindowDC)
35
36 wxMemoryDC::wxMemoryDC(void)
37 {
38 m_ok = TRUE;
39 m_display = wxGetDisplay();
40
41 Display* display = (Display*) m_display;
42
43 XGCValues gcvalues;
44 gcvalues.foreground = BlackPixel (display, DefaultScreen (display));
45 gcvalues.background = WhitePixel (display, DefaultScreen (display));
46 gcvalues.graphics_exposures = False;
47 gcvalues.line_width = 1;
48 m_gc = (WXGC) XCreateGC (display, RootWindow (display, DefaultScreen (display)),
49 GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth,
50 &gcvalues);
51
52 m_backgroundPixel = (int) gcvalues.background;
53
54 // Get the current Font so we can set it back later
55 XGCValues valReturn;
56 XGetGCValues((Display*) m_display, (GC) m_gc, GCFont, &valReturn);
57 m_oldFont = (WXFont) valReturn.font;
58 SetBrush (* wxWHITE_BRUSH);
59 SetPen (* wxBLACK_PEN);
60 SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT));
61 };
62
63 wxMemoryDC::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.line_width = 1;
78 m_gc = (WXGC) XCreateGC (display, RootWindow (display, DefaultScreen (display)),
79 GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth,
80 &gcvalues);
81
82 m_backgroundPixel = (int) gcvalues.background;
83
84 // Get the current Font so we can set it back later
85 XGCValues valReturn;
86 XGetGCValues((Display*) m_display, (GC) m_gc, GCFont, &valReturn);
87 m_oldFont = (WXFont) valReturn.font;
88 SetBrush (* wxWHITE_BRUSH);
89 SetPen (* wxBLACK_PEN);
90 };
91
92 wxMemoryDC::~wxMemoryDC(void)
93 {
94 };
95
96 void wxMemoryDC::SelectObject( const wxBitmap& bitmap )
97 {
98 m_bitmap = bitmap;
99
100 if (m_gc)
101 XFreeGC((Display*) m_display, (GC) m_gc);
102 m_gc = (WXGC) NULL;
103
104 if (m_bitmap.Ok() && (bitmap.GetDisplay() == m_display))
105 {
106 m_pixmap = m_bitmap.GetPixmap();
107 Display* display = (Display*) m_display;
108
109 XGCValues gcvalues;
110 gcvalues.foreground = BlackPixel (display, DefaultScreen (display));
111 gcvalues.background = WhitePixel (display, DefaultScreen (display));
112 gcvalues.graphics_exposures = False;
113 gcvalues.line_width = 1;
114 m_gc = (WXGC) XCreateGC (display, RootWindow (display, DefaultScreen (display)),
115 GCForeground | GCBackground | GCGraphicsExposures | GCLineWidth,
116 &gcvalues);
117
118 m_backgroundPixel = (int) gcvalues.background;
119
120 // Get the current Font so we can set it back later
121 XGCValues valReturn;
122 XGetGCValues((Display*) m_display, (GC) m_gc, GCFont, &valReturn);
123 m_oldFont = (WXFont) valReturn.font;
124
125 bool oldOpt = GetOptimization();
126 SetOptimization(FALSE);
127
128 SetBrush (* wxWHITE_BRUSH);
129 SetPen (* wxBLACK_PEN);
130
131 SetOptimization(oldOpt);
132
133 m_ok = TRUE;
134 }
135 else
136 {
137 m_ok = FALSE;
138 m_pixmap = (WXPixmap) 0;
139 };
140 };
141
142 void wxMemoryDC::DoGetSize( int *width, int *height ) const
143 {
144 if (m_bitmap.Ok())
145 {
146 if (width) (*width) = m_bitmap.GetWidth();
147 if (height) (*height) = m_bitmap.GetHeight();
148 }
149 else
150 {
151 if (width) (*width) = 0;
152 if (height) (*height) = 0;
153 };
154 };
155
156