]>
Commit | Line | Data |
---|---|---|
4bb6408c JS |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: windows.cpp | |
3 | // Purpose: wxWindow | |
4 | // Author: Julian Smart | |
5 | // Modified by: | |
6 | // Created: 17/09/98 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) Julian Smart | |
34636400 | 9 | // Licence: wxWindows licence |
4bb6408c JS |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
34636400 VZ |
12 | // ============================================================================ |
13 | // declarations | |
14 | // ============================================================================ | |
15 | ||
16 | // ---------------------------------------------------------------------------- | |
17 | // headers | |
18 | // ---------------------------------------------------------------------------- | |
19 | ||
4bb6408c | 20 | #ifdef __GNUG__ |
34636400 | 21 | #pragma implementation "window.h" |
4bb6408c JS |
22 | #endif |
23 | ||
24 | #include "wx/setup.h" | |
25 | #include "wx/menu.h" | |
26 | #include "wx/dc.h" | |
27 | #include "wx/dcclient.h" | |
28 | #include "wx/utils.h" | |
29 | #include "wx/app.h" | |
30 | #include "wx/panel.h" | |
31 | #include "wx/layout.h" | |
32 | #include "wx/dialog.h" | |
33 | #include "wx/listbox.h" | |
34 | #include "wx/button.h" | |
35 | #include "wx/settings.h" | |
36 | #include "wx/msgdlg.h" | |
37 | #include "wx/frame.h" | |
a91b47e8 | 38 | #include "wx/scrolwin.h" |
33caefb3 | 39 | #include "wx/module.h" |
4bb6408c JS |
40 | #include "wx/menuitem.h" |
41 | #include "wx/log.h" | |
42 | ||
47d67540 | 43 | #if wxUSE_DRAG_AND_DROP |
34636400 | 44 | #include "wx/dnd.h" |
4bb6408c JS |
45 | #endif |
46 | ||
338dd992 JJ |
47 | #ifdef __VMS__ |
48 | #pragma message disable nosimpint | |
49 | #endif | |
4bb6408c | 50 | #include <Xm/Xm.h> |
50414e24 JS |
51 | |
52 | #include <Xm/DrawingA.h> | |
53 | #include <Xm/ScrolledW.h> | |
54 | #include <Xm/ScrollBar.h> | |
55 | #include <Xm/Frame.h> | |
56 | #include <Xm/Label.h> | |
ee31c392 | 57 | #include <Xm/RowColumn.h> // for XmMenuPosition |
338dd992 JJ |
58 | #ifdef __VMS__ |
59 | #pragma message enable nosimpint | |
60 | #endif | |
50414e24 | 61 | |
4bb6408c JS |
62 | #include "wx/motif/private.h" |
63 | ||
64 | #include <string.h> | |
65 | ||
34636400 VZ |
66 | // ---------------------------------------------------------------------------- |
67 | // constants | |
68 | // ---------------------------------------------------------------------------- | |
69 | ||
70 | static const int SCROLL_MARGIN = 4; | |
71 | ||
72 | // ---------------------------------------------------------------------------- | |
73 | // global variables for this module | |
74 | // ---------------------------------------------------------------------------- | |
75 | ||
33caefb3 | 76 | extern wxHashTable *wxWidgetHashTable; |
34636400 VZ |
77 | |
78 | // ---------------------------------------------------------------------------- | |
79 | // private functions | |
80 | // ---------------------------------------------------------------------------- | |
81 | ||
82 | static void wxCanvasRepaintProc(Widget, XtPointer, XmDrawingAreaCallbackStruct * cbs); | |
83 | static void wxCanvasInputEvent(Widget drawingArea, XtPointer data, XmDrawingAreaCallbackStruct * cbs); | |
84 | static void wxCanvasMotionEvent(Widget, XButtonEvent * event); | |
85 | static void wxCanvasEnterLeave(Widget drawingArea, XtPointer clientData, XCrossingEvent * event); | |
8aa04e8b | 86 | static void wxScrollBarCallback(Widget widget, XtPointer clientData, |
311227c3 | 87 | XmScrollBarCallbackStruct *cbs); |
34636400 VZ |
88 | static void wxPanelItemEventHandler(Widget wid, |
89 | XtPointer client_data, | |
90 | XEvent* event, | |
91 | Boolean *continueToDispatch); | |
92 | ||
93 | // unused for now | |
94 | #if 0 | |
95 | ||
96 | // Helper function for 16-bit fonts | |
97 | static int str16len(const char *s) | |
98 | { | |
99 | int count = 0; | |
100 | ||
101 | while (s[0] && s[1]) { | |
102 | count++; | |
103 | s += 2; | |
104 | } | |
105 | ||
106 | return count; | |
107 | } | |
108 | ||
109 | #endif // 0 | |
110 | ||
111 | // ---------------------------------------------------------------------------- | |
112 | // macros | |
113 | // ---------------------------------------------------------------------------- | |
50414e24 JS |
114 | |
115 | #define event_left_is_down(x) ((x)->xbutton.state & Button1Mask) | |
116 | #define event_middle_is_down(x) ((x)->xbutton.state & Button2Mask) | |
117 | #define event_right_is_down(x) ((x)->xbutton.state & Button3Mask) | |
118 | ||
34636400 VZ |
119 | // ---------------------------------------------------------------------------- |
120 | // event tables | |
121 | // ---------------------------------------------------------------------------- | |
4bb6408c | 122 | |
8e877c19 | 123 | IMPLEMENT_DYNAMIC_CLASS(wxWindow, wxWindowBase) |
4bb6408c | 124 | |
8e877c19 | 125 | BEGIN_EVENT_TABLE(wxWindow, wxWindowBase) |
34636400 VZ |
126 | EVT_SYS_COLOUR_CHANGED(wxWindow::OnSysColourChanged) |
127 | EVT_IDLE(wxWindow::OnIdle) | |
128 | END_EVENT_TABLE() | |
4bb6408c | 129 | |
34636400 VZ |
130 | // ============================================================================ |
131 | // implementation | |
132 | // ============================================================================ | |
4bb6408c | 133 | |
34636400 VZ |
134 | // ---------------------------------------------------------------------------- |
135 | // helper functions | |
136 | // ---------------------------------------------------------------------------- | |
4bb6408c | 137 | |
34636400 | 138 | void wxWindow::UnmanageAndDestroy(WXWidget widget) |
4bb6408c | 139 | { |
34636400 VZ |
140 | Widget w = (Widget)widget; |
141 | if ( w ) | |
4bb6408c | 142 | { |
34636400 VZ |
143 | XtUnmanageChild(w); |
144 | XtDestroyWidget(w); | |
4bb6408c | 145 | } |
4bb6408c JS |
146 | } |
147 | ||
34636400 | 148 | bool wxWindow::MapOrUnmap(WXWidget widget, bool map) |
4bb6408c | 149 | { |
34636400 VZ |
150 | Widget w = (Widget)widget; |
151 | if ( !w ) | |
152 | return FALSE; | |
153 | ||
154 | if ( map ) | |
155 | XtMapWidget(w); | |
156 | else | |
157 | XtUnmapWidget(w); | |
158 | ||
4bb6408c JS |
159 | return TRUE; |
160 | } | |
161 | ||
34636400 VZ |
162 | // ---------------------------------------------------------------------------- |
163 | // constructors | |
164 | // ---------------------------------------------------------------------------- | |
165 | ||
166 | void wxWindow::Init() | |
4bb6408c | 167 | { |
34636400 VZ |
168 | // generic initializations first |
169 | InitBase(); | |
170 | ||
50414e24 | 171 | // Motif-specific |
a91b47e8 | 172 | m_needsRefresh = TRUE; |
50414e24 | 173 | m_mainWidget = (WXWidget) 0; |
34636400 VZ |
174 | |
175 | m_button1Pressed = | |
176 | m_button2Pressed = | |
50414e24 | 177 | m_button3Pressed = FALSE; |
34636400 | 178 | |
50414e24 | 179 | m_winCaptured = FALSE; |
34636400 | 180 | |
50414e24 | 181 | m_isShown = TRUE; |
3ab377bd MB |
182 | m_isBeingDeleted = FALSE; |
183 | ||
34636400 VZ |
184 | m_hScrollBar = |
185 | m_vScrollBar = | |
186 | m_borderWidget = | |
187 | m_scrolledWindow = | |
50414e24 | 188 | m_drawingArea = (WXWidget) 0; |
34636400 VZ |
189 | |
190 | m_hScroll = | |
50414e24 | 191 | m_vScroll = FALSE; |
34636400 VZ |
192 | |
193 | m_scrollPosX = | |
194 | m_scrollPosY = 0; | |
195 | ||
50414e24 | 196 | m_backingPixmap = (WXPixmap) 0; |
34636400 | 197 | m_pixmapWidth = |
50414e24 | 198 | m_pixmapHeight = 0; |
34636400 VZ |
199 | |
200 | m_pixmapOffsetX = | |
50414e24 | 201 | m_pixmapOffsetY = 0; |
34636400 VZ |
202 | |
203 | m_lastTS = 0; | |
204 | m_lastButton = 0; | |
205 | m_canAddEventHandler = FALSE; | |
206 | } | |
207 | ||
208 | // real construction (Init() must have been called before!) | |
209 | bool wxWindow::Create(wxWindow *parent, wxWindowID id, | |
210 | const wxPoint& pos, | |
211 | const wxSize& size, | |
212 | long style, | |
213 | const wxString& name) | |
214 | { | |
215 | wxCHECK_MSG( parent, FALSE, "can't create wxWindow without parent" ); | |
216 | ||
813c20a6 | 217 | CreateBase(parent, id, pos, size, style, wxDefaultValidator, name); |
34636400 VZ |
218 | |
219 | parent->AddChild(this); | |
220 | ||
221 | m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE); | |
4bb6408c | 222 | m_foregroundColour = *wxBLACK; |
34636400 | 223 | |
50414e24 JS |
224 | //// TODO: we should probably optimize by only creating a |
225 | //// a drawing area if we have one or more scrollbars (wxVSCROLL/wxHSCROLL). | |
226 | //// But for now, let's simplify things by always creating the | |
227 | //// drawing area, since otherwise the translations are different. | |
34636400 | 228 | |
2d120f83 | 229 | // New translations for getting mouse motion feedback |
34636400 VZ |
230 | static const String translations = |
231 | "<Btn1Motion>: wxCanvasMotionEvent() DrawingAreaInput() ManagerGadgetButtonMotion()\n\ | |
2d120f83 JS |
232 | <Btn2Motion>: wxCanvasMotionEvent() DrawingAreaInput() ManagerGadgetButtonMotion()\n\ |
233 | <Btn3Motion>: wxCanvasMotionEvent() DrawingAreaInput() ManagerGadgetButtonMotion()\n\ | |
234 | <BtnMotion>: wxCanvasMotionEvent() DrawingAreaInput() ManagerGadgetButtonMotion()\n\ | |
235 | <Btn1Down>: DrawingAreaInput() ManagerGadgetArm()\n\ | |
236 | <Btn2Down>: DrawingAreaInput() ManagerGadgetArm()\n\ | |
237 | <Btn3Down>: DrawingAreaInput() ManagerGadgetArm()\n\ | |
238 | <Btn1Up>: DrawingAreaInput() ManagerGadgetActivate()\n\ | |
239 | <Btn2Up>: DrawingAreaInput() ManagerGadgetActivate()\n\ | |
240 | <Btn3Up>: DrawingAreaInput() ManagerGadgetActivate()\n\ | |
241 | <Motion>: wxCanvasMotionEvent() DrawingAreaInput()\n\ | |
242 | <EnterWindow>: wxCanvasMotionEvent() DrawingAreaInput()\n\ | |
243 | <LeaveWindow>: wxCanvasMotionEvent() DrawingAreaInput()\n\ | |
244 | <Key>: DrawingAreaInput()"; | |
34636400 | 245 | |
2d120f83 JS |
246 | XtActionsRec actions[1]; |
247 | actions[0].string = "wxCanvasMotionEvent"; | |
248 | actions[0].proc = (XtActionProc) wxCanvasMotionEvent; | |
249 | XtAppAddActions ((XtAppContext) wxTheApp->GetAppContext(), actions, 1); | |
34636400 VZ |
250 | |
251 | Widget parentWidget = (Widget) parent->GetClientWidget(); | |
76db86e7 RR |
252 | |
253 | if (style & wxSIMPLE_BORDER) | |
254 | { | |
255 | m_borderWidget = (WXWidget)XtVaCreateManagedWidget | |
256 | ( | |
257 | "canvasBorder", | |
258 | xmFrameWidgetClass, parentWidget, | |
259 | XmNshadowType, XmSHADOW_IN, | |
260 | XmNshadowThickness, 1, | |
261 | NULL | |
262 | ); | |
263 | } else if (style & wxSUNKEN_BORDER) | |
34636400 VZ |
264 | { |
265 | m_borderWidget = (WXWidget)XtVaCreateManagedWidget | |
266 | ( | |
267 | "canvasBorder", | |
268 | xmFrameWidgetClass, parentWidget, | |
269 | XmNshadowType, XmSHADOW_IN, | |
270 | NULL | |
271 | ); | |
76db86e7 RR |
272 | } else if (style & wxRAISED_BORDER) |
273 | { | |
274 | m_borderWidget = (WXWidget)XtVaCreateManagedWidget | |
275 | ( | |
276 | "canvasBorder", | |
277 | xmFrameWidgetClass, parentWidget, | |
278 | XmNshadowType, XmSHADOW_OUT, | |
279 | NULL | |
280 | ); | |
34636400 VZ |
281 | } |
282 | ||
283 | m_scrolledWindow = (WXWidget)XtVaCreateManagedWidget | |
284 | ( | |
285 | "scrolledWindow", | |
286 | xmScrolledWindowWidgetClass, | |
287 | m_borderWidget ? (Widget) m_borderWidget | |
288 | : parentWidget, | |
289 | XmNresizePolicy, XmRESIZE_NONE, | |
290 | XmNspacing, 0, | |
291 | XmNscrollingPolicy, XmAPPLICATION_DEFINED, | |
292 | //XmNscrollBarDisplayPolicy, XmAS_NEEDED, | |
293 | NULL | |
294 | ); | |
295 | ||
296 | XtTranslations ptr = XtParseTranslationTable(translations); | |
297 | m_drawingArea = (WXWidget)XtVaCreateWidget | |
298 | ( | |
299 | name, | |
300 | xmDrawingAreaWidgetClass, (Widget) m_scrolledWindow, | |
301 | XmNunitType, XmPIXELS, | |
302 | // XmNresizePolicy, XmRESIZE_ANY, | |
303 | XmNresizePolicy, XmRESIZE_NONE, | |
304 | XmNmarginHeight, 0, | |
305 | XmNmarginWidth, 0, | |
306 | XmNtranslations, ptr, | |
307 | NULL | |
308 | ); | |
309 | XtFree((char *) ptr); | |
310 | ||
311 | #if 0 | |
312 | if (GetWindowStyleFlag() & wxOVERRIDE_KEY_TRANSLATIONS) | |
313 | { | |
2d120f83 JS |
314 | ptr = XtParseTranslationTable ("<Key>: DrawingAreaInput()"); |
315 | XtOverrideTranslations ((Widget) m_drawingArea, ptr); | |
316 | XtFree ((char *) ptr); | |
34636400 VZ |
317 | } |
318 | #endif // 0 | |
319 | ||
2d120f83 JS |
320 | wxAddWindowToTable((Widget) m_drawingArea, this); |
321 | wxAddWindowToTable((Widget) m_scrolledWindow, this); | |
34636400 VZ |
322 | |
323 | // This order is very important in Motif 1.2.1 | |
2d120f83 JS |
324 | XtRealizeWidget ((Widget) m_scrolledWindow); |
325 | XtRealizeWidget ((Widget) m_drawingArea); | |
326 | XtManageChild ((Widget) m_drawingArea); | |
34636400 VZ |
327 | |
328 | ptr = XtParseTranslationTable("<Configure>: resize()"); | |
329 | XtOverrideTranslations((Widget) m_drawingArea, ptr); | |
50414e24 | 330 | XtFree ((char *) ptr); |
34636400 | 331 | |
2d120f83 JS |
332 | XtAddCallback ((Widget) m_drawingArea, XmNexposeCallback, (XtCallbackProc) wxCanvasRepaintProc, (XtPointer) this); |
333 | XtAddCallback ((Widget) m_drawingArea, XmNinputCallback, (XtCallbackProc) wxCanvasInputEvent, (XtPointer) this); | |
34636400 VZ |
334 | |
335 | // TODO? | |
336 | #if 0 | |
2d120f83 JS |
337 | display = XtDisplay (scrolledWindow); |
338 | xwindow = XtWindow (drawingArea); | |
34636400 VZ |
339 | #endif // 0 |
340 | ||
341 | XtAddEventHandler( | |
342 | (Widget)m_drawingArea, | |
343 | PointerMotionHintMask | EnterWindowMask | | |
344 | LeaveWindowMask | FocusChangeMask, | |
345 | False, | |
346 | (XtEventHandler) wxCanvasEnterLeave, | |
347 | (XtPointer) this | |
348 | ); | |
349 | ||
350 | // Scrolled widget needs to have its colour changed or we get a little blue | |
351 | // square where the scrollbars abutt | |
2d120f83 JS |
352 | wxColour backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE); |
353 | DoChangeBackgroundColour(m_scrolledWindow, backgroundColour, TRUE); | |
354 | DoChangeBackgroundColour(m_drawingArea, backgroundColour, TRUE); | |
34636400 VZ |
355 | |
356 | XmScrolledWindowSetAreas( | |
357 | (Widget)m_scrolledWindow, | |
358 | (Widget) 0, (Widget) 0, | |
359 | (Widget) m_drawingArea); | |
360 | ||
361 | #if 0 | |
2d120f83 | 362 | if (m_hScrollBar) |
34636400 | 363 | XtRealizeWidget ((Widget) m_hScrollBar); |
2d120f83 | 364 | if (m_vScrollBar) |
34636400 VZ |
365 | XtRealizeWidget ((Widget) m_vScrollBar); |
366 | #endif // 0 | |
367 | ||
368 | // Without this, the cursor may not be restored properly (e.g. in splitter | |
369 | // sample). | |
2d120f83 JS |
370 | SetCursor(*wxSTANDARD_CURSOR); |
371 | SetFont(wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT)); | |
372 | SetSize(pos.x, pos.y, size.x, size.y); | |
34636400 | 373 | |
2d120f83 | 374 | return TRUE; |
88150e60 JS |
375 | } |
376 | ||
34636400 VZ |
377 | // Destructor |
378 | wxWindow::~wxWindow() | |
379 | { | |
3ab377bd MB |
380 | m_isBeingDeleted = TRUE; |
381 | ||
34636400 VZ |
382 | // Motif-specific actions first |
383 | WXWidget wMain = GetMainWidget(); | |
384 | if ( wMain ) | |
385 | { | |
386 | // Removes event handlers | |
387 | DetachWidget(wMain); | |
388 | } | |
389 | ||
390 | ClearUpdateRects(); | |
391 | ||
ee31c392 VZ |
392 | if ( m_parent ) |
393 | m_parent->RemoveChild( this ); | |
394 | ||
34636400 VZ |
395 | // If m_drawingArea, we're a fully-fledged window with drawing area, |
396 | // scrollbars etc. (what wxCanvas used to be) | |
397 | if ( m_drawingArea ) | |
398 | { | |
399 | // Destroy children before destroying self | |
400 | DestroyChildren(); | |
401 | ||
402 | if (m_backingPixmap) | |
403 | XFreePixmap (XtDisplay ((Widget) GetMainWidget()), (Pixmap) m_backingPixmap); | |
404 | ||
405 | Widget w = (Widget) m_drawingArea; | |
406 | wxDeleteWindowFromTable(w); | |
407 | ||
408 | if (w) | |
409 | { | |
410 | XtDestroyWidget(w); | |
411 | } | |
412 | ||
413 | m_mainWidget = (WXWidget) 0; | |
414 | ||
415 | // Only if we're _really_ a canvas (not a dialog box/panel) | |
416 | if (m_scrolledWindow) | |
417 | { | |
418 | wxDeleteWindowFromTable((Widget) m_scrolledWindow); | |
419 | } | |
420 | ||
311227c3 MB |
421 | if (m_hScrollBar) |
422 | { | |
423 | wxDeleteWindowFromTable((Widget) m_hScrollBar); | |
424 | } | |
425 | if (m_vScrollBar) | |
426 | { | |
427 | wxDeleteWindowFromTable((Widget) m_vScrollBar); | |
428 | } | |
429 | ||
34636400 VZ |
430 | UnmanageAndDestroy(m_hScrollBar); |
431 | UnmanageAndDestroy(m_vScrollBar); | |
432 | UnmanageAndDestroy(m_scrolledWindow); | |
433 | ||
434 | if (m_borderWidget) | |
435 | { | |
436 | XtDestroyWidget ((Widget) m_borderWidget); | |
437 | m_borderWidget = (WXWidget) 0; | |
438 | } | |
439 | } | |
440 | ||
441 | // Destroy the window | |
442 | if (GetMainWidget()) | |
443 | { | |
444 | // If this line (XtDestroyWidget) causes a crash, you may comment it out. | |
445 | // Child widgets will get destroyed automatically when a frame | |
446 | // or dialog is destroyed, but before that you may get some memory | |
447 | // leaks and potential layout problems if you delete and then add | |
448 | // child windows. | |
449 | XtDestroyWidget((Widget) GetMainWidget()); | |
450 | SetMainWidget((WXWidget) NULL); | |
451 | } | |
452 | } | |
453 | ||
454 | // ---------------------------------------------------------------------------- | |
455 | // scrollbar management | |
456 | // ---------------------------------------------------------------------------- | |
457 | ||
88150e60 | 458 | // Helper function |
af0bb3b1 | 459 | void wxWindow::CreateScrollbar(wxOrientation orientation) |
88150e60 | 460 | { |
34636400 VZ |
461 | wxCHECK_RET( m_drawingArea, "this window can't have scrollbars" ); |
462 | ||
2d120f83 | 463 | XtVaSetValues((Widget) m_scrolledWindow, XmNresizePolicy, XmRESIZE_NONE, NULL); |
34636400 | 464 | |
2d120f83 JS |
465 | // Add scrollbars if required |
466 | if (orientation == wxHORIZONTAL) | |
467 | { | |
468 | Widget hScrollBar = XtVaCreateManagedWidget ("hsb", | |
469 | xmScrollBarWidgetClass, (Widget) m_scrolledWindow, | |
470 | XmNorientation, XmHORIZONTAL, | |
471 | NULL); | |
34636400 | 472 | // XtAddCallback (hScrollBar, XmNvalueChangedCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmHORIZONTAL); |
2d120f83 JS |
473 | XtAddCallback (hScrollBar, XmNdragCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmHORIZONTAL); |
474 | XtAddCallback (hScrollBar, XmNincrementCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmHORIZONTAL); | |
475 | XtAddCallback (hScrollBar, XmNdecrementCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmHORIZONTAL); | |
476 | XtAddCallback (hScrollBar, XmNpageIncrementCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmHORIZONTAL); | |
477 | XtAddCallback (hScrollBar, XmNpageDecrementCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmHORIZONTAL); | |
478 | XtAddCallback (hScrollBar, XmNtoTopCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmHORIZONTAL); | |
479 | XtAddCallback (hScrollBar, XmNtoBottomCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmHORIZONTAL); | |
34636400 | 480 | |
2d120f83 JS |
481 | XtVaSetValues (hScrollBar, |
482 | XmNincrement, 1, | |
483 | XmNvalue, 0, | |
484 | NULL); | |
34636400 | 485 | |
2d120f83 | 486 | m_hScrollBar = (WXWidget) hScrollBar; |
34636400 | 487 | |
2d120f83 JS |
488 | wxColour backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE); |
489 | DoChangeBackgroundColour(m_hScrollBar, backgroundColour, TRUE); | |
34636400 | 490 | |
2d120f83 | 491 | XtRealizeWidget(hScrollBar); |
34636400 | 492 | |
2d120f83 JS |
493 | XtVaSetValues((Widget) m_scrolledWindow, |
494 | XmNhorizontalScrollBar, (Widget) m_hScrollBar, | |
495 | NULL); | |
34636400 | 496 | |
2d120f83 | 497 | m_hScroll = TRUE; |
311227c3 MB |
498 | |
499 | wxAddWindowToTable( hScrollBar, this ); | |
2d120f83 | 500 | } |
34636400 | 501 | |
2d120f83 JS |
502 | if (orientation == wxVERTICAL) |
503 | { | |
504 | Widget vScrollBar = XtVaCreateManagedWidget ("vsb", | |
505 | xmScrollBarWidgetClass, (Widget) m_scrolledWindow, | |
506 | XmNorientation, XmVERTICAL, | |
507 | NULL); | |
34636400 | 508 | // XtAddCallback (vScrollBar, XmNvalueChangedCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmVERTICAL); |
2d120f83 JS |
509 | XtAddCallback (vScrollBar, XmNdragCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmVERTICAL); |
510 | XtAddCallback (vScrollBar, XmNincrementCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmVERTICAL); | |
511 | XtAddCallback (vScrollBar, XmNdecrementCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmVERTICAL); | |
512 | XtAddCallback (vScrollBar, XmNpageIncrementCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmVERTICAL); | |
513 | XtAddCallback (vScrollBar, XmNpageDecrementCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmVERTICAL); | |
514 | XtAddCallback (vScrollBar, XmNtoTopCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmVERTICAL); | |
515 | XtAddCallback (vScrollBar, XmNtoBottomCallback, (XtCallbackProc) wxScrollBarCallback, (XtPointer) XmVERTICAL); | |
34636400 | 516 | |
2d120f83 JS |
517 | XtVaSetValues (vScrollBar, |
518 | XmNincrement, 1, | |
519 | XmNvalue, 0, | |
520 | NULL); | |
34636400 | 521 | |
2d120f83 JS |
522 | m_vScrollBar = (WXWidget) vScrollBar; |
523 | wxColour backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE); | |
524 | DoChangeBackgroundColour(m_vScrollBar, backgroundColour, TRUE); | |
34636400 | 525 | |
2d120f83 | 526 | XtRealizeWidget(vScrollBar); |
34636400 | 527 | |
2d120f83 JS |
528 | XtVaSetValues((Widget) m_scrolledWindow, |
529 | XmNverticalScrollBar, (Widget) m_vScrollBar, | |
530 | NULL); | |
34636400 | 531 | |
2d120f83 | 532 | m_vScroll = TRUE; |
311227c3 MB |
533 | |
534 | wxAddWindowToTable( vScrollBar, this ); | |
2d120f83 | 535 | } |
34636400 | 536 | |
2d120f83 | 537 | XtVaSetValues((Widget) m_scrolledWindow, XmNresizePolicy, XmRESIZE_ANY, NULL); |
88150e60 | 538 | } |
34636400 | 539 | |
af0bb3b1 | 540 | void wxWindow::DestroyScrollbar(wxOrientation orientation) |
88150e60 | 541 | { |
34636400 VZ |
542 | wxCHECK_RET( m_drawingArea, "this window can't have scrollbars" ); |
543 | ||
2d120f83 JS |
544 | XtVaSetValues((Widget) m_scrolledWindow, XmNresizePolicy, XmRESIZE_NONE, NULL); |
545 | // Add scrollbars if required | |
546 | if (orientation == wxHORIZONTAL) | |
547 | { | |
548 | if (m_hScrollBar) | |
549 | { | |
311227c3 | 550 | wxDeleteWindowFromTable((Widget)m_hScrollBar); |
2d120f83 JS |
551 | XtDestroyWidget((Widget) m_hScrollBar); |
552 | } | |
553 | m_hScrollBar = (WXWidget) 0; | |
554 | m_hScroll = FALSE; | |
34636400 | 555 | |
2d120f83 JS |
556 | XtVaSetValues((Widget) m_scrolledWindow, |
557 | XmNhorizontalScrollBar, (Widget) 0, | |
558 | NULL); | |
34636400 | 559 | |
2d120f83 | 560 | } |
34636400 | 561 | |
2d120f83 JS |
562 | if (orientation == wxVERTICAL) |
563 | { | |
564 | if (m_vScrollBar) | |
565 | { | |
311227c3 | 566 | wxDeleteWindowFromTable((Widget)m_vScrollBar); |
2d120f83 JS |
567 | XtDestroyWidget((Widget) m_vScrollBar); |
568 | } | |
569 | m_vScrollBar = (WXWidget) 0; | |
570 | m_vScroll = TRUE; | |
34636400 | 571 | |
2d120f83 JS |
572 | XtVaSetValues((Widget) m_scrolledWindow, |
573 | XmNverticalScrollBar, (Widget) 0, | |
574 | NULL); | |
34636400 | 575 | |
2d120f83 JS |
576 | } |
577 | XtVaSetValues((Widget) m_scrolledWindow, XmNresizePolicy, XmRESIZE_ANY, NULL); | |
4bb6408c JS |
578 | } |
579 | ||
34636400 VZ |
580 | // --------------------------------------------------------------------------- |
581 | // basic operations | |
582 | // --------------------------------------------------------------------------- | |
583 | ||
4bb6408c JS |
584 | void wxWindow::SetFocus() |
585 | { | |
34636400 VZ |
586 | Widget wMain = (Widget) GetMainWidget(); |
587 | XmProcessTraversal(wMain, XmTRAVERSE_CURRENT); | |
2d120f83 | 588 | XmProcessTraversal((Widget) GetMainWidget(), XmTRAVERSE_CURRENT); |
4bb6408c JS |
589 | } |
590 | ||
34636400 | 591 | // Get the window with the focus |
af0bb3b1 | 592 | wxWindow *wxWindowBase::FindFocus() |
4bb6408c | 593 | { |
34636400 VZ |
594 | // TODO Problems: |
595 | // (1) Can there be multiple focussed widgets in an application? | |
596 | // In which case we need to find the top-level window that's | |
597 | // currently active. | |
598 | // (2) The widget with the focus may not be in the widget table | |
599 | // depending on which widgets I put in the table | |
600 | wxWindow *winFocus = (wxWindow *)NULL; | |
601 | for ( wxWindowList::Node *node = wxTopLevelWindows.GetFirst(); | |
602 | node; | |
603 | node = node->GetNext() ) | |
2d120f83 | 604 | { |
34636400 VZ |
605 | wxWindow *win = node->GetData(); |
606 | ||
607 | Widget w = XmGetFocusWidget ((Widget) win->GetTopWidget()); | |
608 | ||
609 | if (w != (Widget) NULL) | |
610 | { | |
611 | winFocus = wxGetWindowFromTable(w); | |
612 | if ( winFocus ) | |
613 | break; | |
614 | } | |
2d120f83 | 615 | } |
4bb6408c | 616 | |
34636400 | 617 | return winFocus; |
4bb6408c JS |
618 | } |
619 | ||
af0bb3b1 | 620 | bool wxWindow::Enable(bool enable) |
4bb6408c | 621 | { |
34636400 VZ |
622 | if ( !wxWindowBase::Enable(enable) ) |
623 | return FALSE; | |
4bb6408c | 624 | |
af0bb3b1 | 625 | Widget wMain = (Widget)GetMainWidget(); |
34636400 VZ |
626 | if ( wMain ) |
627 | { | |
628 | XtSetSensitive(wMain, enable); | |
629 | XmUpdateDisplay(wMain); | |
630 | } | |
631 | ||
632 | return TRUE; | |
4bb6408c JS |
633 | } |
634 | ||
34636400 | 635 | bool wxWindow::Show(bool show) |
4bb6408c | 636 | { |
34636400 VZ |
637 | if ( !wxWindowBase::Show(show) ) |
638 | return FALSE; | |
639 | ||
640 | if (m_borderWidget || m_scrolledWindow) | |
2d120f83 | 641 | { |
34636400 VZ |
642 | MapOrUnmap(m_drawingArea, show); |
643 | MapOrUnmap(m_borderWidget ? m_borderWidget : m_scrolledWindow, show); | |
2d120f83 JS |
644 | } |
645 | else | |
34636400 VZ |
646 | { |
647 | if ( !MapOrUnmap(GetTopWidget(), show) ) | |
648 | MapOrUnmap(GetMainWidget(), show); | |
649 | } | |
650 | ||
651 | #if 0 | |
652 | Window xwin = (Window) GetXWindow(); | |
653 | Display *xdisp = (Display*) GetXDisplay(); | |
654 | if (show) | |
655 | XMapWindow(xdisp, xwin); | |
656 | else | |
657 | XUnmapWindow(xdisp, xwin); | |
658 | #endif | |
4bb6408c | 659 | |
34636400 VZ |
660 | return TRUE; |
661 | } | |
4bb6408c | 662 | |
34636400 VZ |
663 | // Raise the window to the top of the Z order |
664 | void wxWindow::Raise() | |
4bb6408c | 665 | { |
34636400 VZ |
666 | Widget wTop = (Widget) GetTopWidget(); |
667 | Window window = XtWindow(wTop); | |
668 | XRaiseWindow(XtDisplay(wTop), window); | |
4bb6408c JS |
669 | } |
670 | ||
34636400 VZ |
671 | // Lower the window to the bottom of the Z order |
672 | void wxWindow::Lower() | |
673 | { | |
674 | Widget wTop = (Widget) GetTopWidget(); | |
675 | Window window = XtWindow(wTop); | |
676 | XLowerWindow(XtDisplay(wTop), window); | |
677 | } | |
4bb6408c | 678 | |
af0bb3b1 | 679 | void wxWindow::SetTitle(const wxString& title) |
4bb6408c | 680 | { |
af0bb3b1 | 681 | XtVaSetValues((Widget)GetMainWidget(), XmNtitle, title.c_str(), NULL); |
4bb6408c JS |
682 | } |
683 | ||
34636400 | 684 | wxString wxWindow::GetTitle() const |
4bb6408c | 685 | { |
af0bb3b1 VZ |
686 | char *title; |
687 | XtVaGetValues((Widget)GetMainWidget(), XmNtitle, &title, NULL); | |
688 | ||
689 | return wxString(title); | |
4bb6408c JS |
690 | } |
691 | ||
34636400 | 692 | void wxWindow::CaptureMouse() |
4bb6408c | 693 | { |
34636400 | 694 | if ( m_winCaptured ) |
a4294b78 | 695 | return; |
34636400 | 696 | |
af0bb3b1 | 697 | Widget wMain = (Widget)GetMainWidget(); |
34636400 VZ |
698 | if ( wMain ) |
699 | XtAddGrab(wMain, TRUE, FALSE); | |
700 | ||
701 | m_winCaptured = TRUE; | |
4bb6408c JS |
702 | } |
703 | ||
34636400 | 704 | void wxWindow::ReleaseMouse() |
4bb6408c | 705 | { |
34636400 VZ |
706 | if ( !m_winCaptured ) |
707 | return; | |
708 | ||
af0bb3b1 | 709 | Widget wMain = (Widget)GetMainWidget(); |
34636400 VZ |
710 | if ( wMain ) |
711 | XtRemoveGrab(wMain); | |
712 | ||
713 | m_winCaptured = FALSE; | |
4bb6408c JS |
714 | } |
715 | ||
34636400 | 716 | bool wxWindow::SetFont(const wxFont& font) |
4bb6408c | 717 | { |
34636400 VZ |
718 | if ( !wxWindowBase::SetFont(font) ) |
719 | { | |
720 | // nothing to do | |
721 | return FALSE; | |
722 | } | |
723 | ||
724 | ChangeFont(); | |
725 | ||
726 | return TRUE; | |
4bb6408c JS |
727 | } |
728 | ||
34636400 | 729 | bool wxWindow::SetCursor(const wxCursor& cursor) |
4bb6408c | 730 | { |
34636400 | 731 | if ( !wxWindowBase::SetCursor(cursor) ) |
2d120f83 | 732 | { |
34636400 VZ |
733 | // no change |
734 | return FALSE; | |
2d120f83 | 735 | } |
4bb6408c | 736 | |
34636400 | 737 | wxASSERT_MSG( m_cursor.Ok(), |
223d09f6 | 738 | wxT("cursor must be valid after call to the base version")); |
4bb6408c | 739 | |
34636400 VZ |
740 | WXDisplay *dpy = GetXDisplay(); |
741 | WXCursor x_cursor = m_cursor.GetXCursor(dpy); | |
742 | ||
743 | Widget w = (Widget) GetMainWidget(); | |
744 | Window win = XtWindow(w); | |
745 | XDefineCursor((Display*) dpy, win, (Cursor) x_cursor); | |
af0bb3b1 VZ |
746 | |
747 | return TRUE; | |
34636400 VZ |
748 | } |
749 | ||
750 | // Coordinates relative to the window | |
751 | void wxWindow::WarpPointer (int x, int y) | |
4bb6408c | 752 | { |
34636400 VZ |
753 | Widget wClient = (Widget)GetClientWidget(); |
754 | ||
755 | XWarpPointer(XtDisplay(wClient), None, XtWindow(wClient), 0, 0, 0, 0, x, y); | |
4bb6408c JS |
756 | } |
757 | ||
34636400 VZ |
758 | // --------------------------------------------------------------------------- |
759 | // scrolling stuff | |
760 | // --------------------------------------------------------------------------- | |
761 | ||
762 | int wxWindow::GetScrollPos(int orient) const | |
4bb6408c | 763 | { |
34636400 VZ |
764 | if (orient == wxHORIZONTAL) |
765 | return m_scrollPosX; | |
766 | else | |
767 | return m_scrollPosY; | |
768 | ||
769 | #if 0 | |
770 | Widget scrollBar = (Widget) ((orient == wxHORIZONTAL) ? m_hScrollBar : m_vScrollBar); | |
771 | if (scrollBar) | |
2d120f83 | 772 | { |
34636400 VZ |
773 | int pos; |
774 | XtVaGetValues(scrollBar, XmNvalue, &pos, NULL); | |
775 | return pos; | |
2d120f83 | 776 | } |
34636400 VZ |
777 | else |
778 | return 0; | |
779 | #endif // 0 | |
2d120f83 | 780 | } |
7fe7d506 | 781 | |
34636400 VZ |
782 | // This now returns the whole range, not just the number of positions that we |
783 | // can scroll. | |
784 | int wxWindow::GetScrollRange(int orient) const | |
2d120f83 | 785 | { |
af0bb3b1 | 786 | Widget scrollBar = (Widget)GetScrollbar((wxOrientation)orient); |
34636400 VZ |
787 | wxCHECK_MSG( scrollBar, 0, "no such scrollbar" ); |
788 | ||
789 | int range; | |
790 | XtVaGetValues(scrollBar, XmNmaximum, &range, NULL); | |
791 | return range; | |
2d120f83 | 792 | } |
4bb6408c | 793 | |
34636400 | 794 | int wxWindow::GetScrollThumb(int orient) const |
4bb6408c | 795 | { |
af0bb3b1 | 796 | Widget scrollBar = (Widget)GetScrollbar((wxOrientation)orient); |
34636400 VZ |
797 | wxCHECK_MSG( scrollBar, 0, "no such scrollbar" ); |
798 | ||
799 | int thumb; | |
800 | XtVaGetValues(scrollBar, XmNsliderSize, &thumb, NULL); | |
801 | return thumb; | |
4bb6408c JS |
802 | } |
803 | ||
34636400 | 804 | void wxWindow::SetScrollPos(int orient, int pos, bool WXUNUSED(refresh)) |
4bb6408c | 805 | { |
af0bb3b1 | 806 | Widget scrollBar = (Widget)GetScrollbar((wxOrientation)orient); |
34636400 VZ |
807 | |
808 | if ( scrollBar ) | |
4bb6408c | 809 | { |
34636400 | 810 | XtVaSetValues (scrollBar, XmNvalue, pos, NULL); |
4bb6408c | 811 | } |
34636400 | 812 | |
af0bb3b1 | 813 | SetInternalScrollPos((wxOrientation)orient, pos); |
4bb6408c JS |
814 | } |
815 | ||
34636400 VZ |
816 | // New function that will replace some of the above. |
817 | void wxWindow::SetScrollbar(int orient, int pos, int thumbVisible, | |
818 | int range, bool WXUNUSED(refresh)) | |
4bb6408c | 819 | { |
34636400 VZ |
820 | int oldW, oldH; |
821 | GetSize(& oldW, & oldH); | |
822 | ||
823 | if (range == 0) | |
824 | range = 1; | |
825 | if (thumbVisible == 0) | |
826 | thumbVisible = 1; | |
827 | ||
828 | if (thumbVisible > range) | |
829 | thumbVisible = range; | |
830 | ||
831 | // Save the old state to see if it changed | |
af0bb3b1 | 832 | WXWidget oldScrollBar = GetScrollbar((wxOrientation)orient); |
34636400 VZ |
833 | |
834 | if (orient == wxHORIZONTAL) | |
50414e24 | 835 | { |
34636400 | 836 | if (thumbVisible == range) |
2d120f83 | 837 | { |
34636400 VZ |
838 | if (m_hScrollBar) |
839 | DestroyScrollbar(wxHORIZONTAL); | |
2d120f83 JS |
840 | } |
841 | else | |
842 | { | |
34636400 VZ |
843 | if (!m_hScrollBar) |
844 | CreateScrollbar(wxHORIZONTAL); | |
2d120f83 | 845 | } |
50414e24 | 846 | } |
34636400 | 847 | if (orient == wxVERTICAL) |
50414e24 | 848 | { |
34636400 | 849 | if (thumbVisible == range) |
2d120f83 | 850 | { |
34636400 VZ |
851 | if (m_vScrollBar) |
852 | DestroyScrollbar(wxVERTICAL); | |
2d120f83 JS |
853 | } |
854 | else | |
855 | { | |
34636400 VZ |
856 | if (!m_vScrollBar) |
857 | CreateScrollbar(wxVERTICAL); | |
2d120f83 | 858 | } |
50414e24 | 859 | } |
af0bb3b1 | 860 | WXWidget newScrollBar = GetScrollbar((wxOrientation)orient); |
4bb6408c | 861 | |
88150e60 | 862 | if (oldScrollBar != newScrollBar) |
28ab302b | 863 | { |
34636400 | 864 | // This is important! Without it, scrollbars misbehave badly. |
2d120f83 JS |
865 | XtUnrealizeWidget((Widget) m_scrolledWindow); |
866 | XmScrolledWindowSetAreas ((Widget) m_scrolledWindow, (Widget) m_hScrollBar, (Widget) m_vScrollBar, (Widget) m_drawingArea); | |
867 | XtRealizeWidget((Widget) m_scrolledWindow); | |
868 | XtManageChild((Widget) m_scrolledWindow); | |
28ab302b | 869 | } |
34636400 | 870 | |
88150e60 | 871 | if (newScrollBar) |
34636400 | 872 | { |
2d120f83 JS |
873 | XtVaSetValues((Widget) newScrollBar, |
874 | XmNvalue, pos, | |
875 | XmNminimum, 0, | |
876 | XmNmaximum, range, | |
877 | XmNsliderSize, thumbVisible, | |
878 | NULL); | |
34636400 VZ |
879 | } |
880 | ||
af0bb3b1 | 881 | SetInternalScrollPos((wxOrientation)orient, pos); |
34636400 | 882 | |
88150e60 JS |
883 | int newW, newH; |
884 | GetSize(& newW, & newH); | |
34636400 | 885 | |
88150e60 JS |
886 | // Adjusting scrollbars can resize the canvas accidentally |
887 | if (newW != oldW || newH != oldH) | |
888 | SetSize(-1, -1, oldW, oldH); | |
4bb6408c JS |
889 | } |
890 | ||
891 | // Does a physical scroll | |
16e93305 | 892 | void wxWindow::ScrollWindow(int dx, int dy, const wxRect *rect) |
4bb6408c | 893 | { |
2d120f83 JS |
894 | int x, y, w, h; |
895 | if (rect) | |
896 | { | |
897 | // Use specified rectangle | |
898 | x = rect->x; y = rect->y; w = rect->width; h = rect->height; | |
899 | } | |
900 | else | |
901 | { | |
902 | // Use whole client area | |
903 | x = 0; y = 0; | |
904 | GetClientSize(& w, & h); | |
905 | } | |
34636400 | 906 | |
76db86e7 RR |
907 | wxNode *cnode = m_children.First(); |
908 | while (cnode) | |
909 | { | |
910 | wxWindow *child = (wxWindow*) cnode->Data(); | |
911 | int sx = 0; | |
912 | int sy = 0; | |
913 | child->GetSize( &sx, &sy ); | |
914 | wxPoint pos( child->GetPosition() ); | |
915 | child->SetSize( pos.x + dx, pos.y + dy, sx, sy, wxSIZE_ALLOW_MINUS_ONE ); | |
916 | cnode = cnode->Next(); | |
917 | } | |
918 | ||
34636400 | 919 | int x1 = (dx >= 0) ? x : x - dx; |
2d120f83 JS |
920 | int y1 = (dy >= 0) ? y : y - dy; |
921 | int w1 = w - abs(dx); | |
922 | int h1 = h - abs(dy); | |
923 | int x2 = (dx >= 0) ? x + dx : x; | |
924 | int y2 = (dy >= 0) ? y + dy : y; | |
34636400 | 925 | |
2d120f83 | 926 | wxClientDC dc(this); |
34636400 | 927 | |
2d120f83 | 928 | dc.SetLogicalFunction (wxCOPY); |
34636400 | 929 | |
2d120f83 JS |
930 | Widget widget = (Widget) GetMainWidget(); |
931 | Window window = XtWindow(widget); | |
932 | Display* display = XtDisplay(widget); | |
34636400 VZ |
933 | |
934 | XCopyArea(display, window, window, (GC) dc.GetGC(), | |
935 | x1, y1, w1, h1, x2, y2); | |
936 | ||
2d120f83 JS |
937 | dc.SetAutoSetting(TRUE); |
938 | wxBrush brush(GetBackgroundColour(), wxSOLID); | |
34636400 VZ |
939 | dc.SetBrush(brush); // FIXME: needed? |
940 | ||
941 | // We'll add rectangles to the list of update rectangles according to which | |
942 | // bits we've exposed. | |
2d120f83 | 943 | wxList updateRects; |
34636400 | 944 | |
2d120f83 JS |
945 | if (dx > 0) |
946 | { | |
947 | wxRect *rect = new wxRect; | |
948 | rect->x = x; | |
949 | rect->y = y; | |
950 | rect->width = dx; | |
951 | rect->height = h; | |
34636400 | 952 | |
2d120f83 JS |
953 | XFillRectangle(display, window, |
954 | (GC) dc.GetGC(), rect->x, rect->y, rect->width, rect->height); | |
34636400 | 955 | |
2d120f83 JS |
956 | rect->x = rect->x; |
957 | rect->y = rect->y; | |
958 | rect->width = rect->width; | |
959 | rect->height = rect->height; | |
34636400 | 960 | |
2d120f83 JS |
961 | updateRects.Append((wxObject*) rect); |
962 | } | |
963 | else if (dx < 0) | |
964 | { | |
965 | wxRect *rect = new wxRect; | |
34636400 | 966 | |
2d120f83 JS |
967 | rect->x = x + w + dx; |
968 | rect->y = y; | |
969 | rect->width = -dx; | |
970 | rect->height = h; | |
34636400 | 971 | |
2d120f83 JS |
972 | XFillRectangle(display, window, |
973 | (GC) dc.GetGC(), rect->x, rect->y, rect->width, | |
974 | rect->height); | |
34636400 | 975 | |
2d120f83 JS |
976 | rect->x = rect->x; |
977 | rect->y = rect->y; | |
978 | rect->width = rect->width; | |
979 | rect->height = rect->height; | |
34636400 | 980 | |
2d120f83 JS |
981 | updateRects.Append((wxObject*) rect); |
982 | } | |
983 | if (dy > 0) | |
984 | { | |
985 | wxRect *rect = new wxRect; | |
34636400 | 986 | |
2d120f83 JS |
987 | rect->x = x; |
988 | rect->y = y; | |
989 | rect->width = w; | |
990 | rect->height = dy; | |
34636400 | 991 | |
2d120f83 JS |
992 | XFillRectangle(display, window, |
993 | (GC) dc.GetGC(), rect->x, rect->y, rect->width, rect->height); | |
34636400 | 994 | |
2d120f83 JS |
995 | rect->x = rect->x; |
996 | rect->y = rect->y; | |
997 | rect->width = rect->width; | |
998 | rect->height = rect->height; | |
34636400 | 999 | |
2d120f83 JS |
1000 | updateRects.Append((wxObject*) rect); |
1001 | } | |
1002 | else if (dy < 0) | |
1003 | { | |
1004 | wxRect *rect = new wxRect; | |
34636400 | 1005 | |
2d120f83 JS |
1006 | rect->x = x; |
1007 | rect->y = y + h + dy; | |
1008 | rect->width = w; | |
1009 | rect->height = -dy; | |
34636400 | 1010 | |
2d120f83 JS |
1011 | XFillRectangle(display, window, |
1012 | (GC) dc.GetGC(), rect->x, rect->y, rect->width, rect->height); | |
34636400 | 1013 | |
2d120f83 JS |
1014 | rect->x = rect->x; |
1015 | rect->y = rect->y; | |
1016 | rect->width = rect->width; | |
1017 | rect->height = rect->height; | |
34636400 | 1018 | |
2d120f83 JS |
1019 | updateRects.Append((wxObject*) rect); |
1020 | } | |
1021 | dc.SetBrush(wxNullBrush); | |
34636400 | 1022 | |
2d120f83 | 1023 | // Now send expose events |
34636400 | 1024 | |
2d120f83 JS |
1025 | wxNode* node = updateRects.First(); |
1026 | while (node) | |
1027 | { | |
1028 | wxRect* rect = (wxRect*) node->Data(); | |
1029 | XExposeEvent event; | |
34636400 | 1030 | |
2d120f83 JS |
1031 | event.type = Expose; |
1032 | event.display = display; | |
1033 | event.send_event = True; | |
1034 | event.window = window; | |
34636400 | 1035 | |
2d120f83 JS |
1036 | event.x = rect->x; |
1037 | event.y = rect->y; | |
1038 | event.width = rect->width; | |
1039 | event.height = rect->height; | |
34636400 | 1040 | |
2d120f83 | 1041 | event.count = 0; |
34636400 | 1042 | |
2d120f83 | 1043 | XSendEvent(display, window, False, ExposureMask, (XEvent *)&event); |
34636400 | 1044 | |
2d120f83 | 1045 | node = node->Next(); |
34636400 | 1046 | |
2d120f83 | 1047 | } |
34636400 | 1048 | |
2d120f83 JS |
1049 | // Delete the update rects |
1050 | node = updateRects.First(); | |
1051 | while (node) | |
1052 | { | |
1053 | wxRect* rect = (wxRect*) node->Data(); | |
1054 | delete rect; | |
1055 | node = node->Next(); | |
1056 | } | |
a91b47e8 JS |
1057 | |
1058 | XmUpdateDisplay((Widget) GetMainWidget()); | |
4bb6408c JS |
1059 | } |
1060 | ||
34636400 VZ |
1061 | // --------------------------------------------------------------------------- |
1062 | // drag and drop | |
1063 | // --------------------------------------------------------------------------- | |
4ce81a75 | 1064 | |
34636400 | 1065 | #if wxUSE_DRAG_AND_DROP |
4ce81a75 | 1066 | |
34636400 | 1067 | void wxWindow::SetDropTarget(wxDropTarget * WXUNUSED(pDropTarget)) |
4ce81a75 | 1068 | { |
34636400 | 1069 | // TODO |
4bb6408c JS |
1070 | } |
1071 | ||
34636400 VZ |
1072 | #endif |
1073 | ||
1074 | // Old style file-manager drag&drop | |
1075 | void wxWindow::DragAcceptFiles(bool WXUNUSED(accept)) | |
4bb6408c | 1076 | { |
34636400 | 1077 | // TODO |
4bb6408c JS |
1078 | } |
1079 | ||
34636400 VZ |
1080 | // ---------------------------------------------------------------------------- |
1081 | // tooltips | |
1082 | // ---------------------------------------------------------------------------- | |
1083 | ||
1084 | #if wxUSE_TOOLTIPS | |
1085 | ||
1086 | void wxWindow::DoSetToolTip(wxToolTip * WXUNUSED(tooltip)) | |
4bb6408c | 1087 | { |
34636400 | 1088 | // TODO |
4bb6408c JS |
1089 | } |
1090 | ||
34636400 VZ |
1091 | #endif // wxUSE_TOOLTIPS |
1092 | ||
ee31c392 VZ |
1093 | // ---------------------------------------------------------------------------- |
1094 | // popup menus | |
1095 | // ---------------------------------------------------------------------------- | |
1096 | ||
1097 | bool wxWindow::DoPopupMenu(wxMenu *menu, int x, int y) | |
1098 | { | |
1099 | Widget widget = (Widget) GetMainWidget(); | |
1100 | ||
1101 | /* The menuId field seems to be usused, so we'll use it to | |
1102 | indicate whether a menu is popped up or not: | |
1103 | 0: Not currently created as a popup | |
1104 | -1: Created as a popup, but not active | |
1105 | 1: Active popup. | |
1106 | */ | |
1107 | ||
1108 | if (menu->GetParent() && (menu->GetId() != -1)) | |
1109 | return FALSE; | |
1110 | ||
1111 | if (menu->GetMainWidget()) { | |
1112 | menu->DestroyMenu(TRUE); | |
1113 | } | |
1114 | ||
1115 | menu->SetId(1); /* Mark as popped-up */ | |
1116 | menu->CreateMenu(NULL, widget, menu); | |
1117 | menu->SetInvokingWindow(this); | |
1118 | ||
1119 | menu->UpdateUI(); | |
1120 | ||
1121 | // menu->SetParent(parent); | |
1122 | // parent->children->Append(menu); // Store menu for later deletion | |
1123 | ||
1124 | Widget menuWidget = (Widget) menu->GetMainWidget(); | |
1125 | ||
1126 | int rootX = 0; | |
1127 | int rootY = 0; | |
1128 | ||
1129 | int deviceX = x; | |
1130 | int deviceY = y; | |
1131 | /* | |
1132 | if (this->IsKindOf(CLASSINFO(wxCanvas))) | |
1133 | { | |
1134 | wxCanvas *canvas = (wxCanvas *) this; | |
1135 | deviceX = canvas->GetDC ()->LogicalToDeviceX (x); | |
1136 | deviceY = canvas->GetDC ()->LogicalToDeviceY (y); | |
1137 | } | |
1138 | */ | |
1139 | ||
1140 | Display *display = XtDisplay (widget); | |
1141 | Window rootWindow = RootWindowOfScreen (XtScreen((Widget)widget)); | |
1142 | Window thisWindow = XtWindow (widget); | |
1143 | Window childWindow; | |
1144 | XTranslateCoordinates (display, thisWindow, rootWindow, (int) deviceX, (int) deviceY, | |
1145 | &rootX, &rootY, &childWindow); | |
1146 | ||
1147 | XButtonPressedEvent event; | |
1148 | event.type = ButtonPress; | |
1149 | event.button = 1; | |
1150 | ||
1151 | event.x = deviceX; | |
1152 | event.y = deviceY; | |
1153 | ||
1154 | event.x_root = rootX; | |
1155 | event.y_root = rootY; | |
1156 | ||
1157 | XmMenuPosition (menuWidget, &event); | |
1158 | XtManageChild (menuWidget); | |
1159 | ||
1160 | return TRUE; | |
1161 | } | |
1162 | ||
34636400 VZ |
1163 | // --------------------------------------------------------------------------- |
1164 | // moving and resizing | |
1165 | // --------------------------------------------------------------------------- | |
4bb6408c | 1166 | |
34636400 | 1167 | bool wxWindow::PreResize() |
4bb6408c | 1168 | { |
2d120f83 | 1169 | return TRUE; |
4bb6408c JS |
1170 | } |
1171 | ||
34636400 | 1172 | // Get total size |
af0bb3b1 | 1173 | void wxWindow::DoGetSize(int *x, int *y) const |
4bb6408c | 1174 | { |
34636400 | 1175 | if (m_drawingArea) |
2d120f83 | 1176 | { |
34636400 VZ |
1177 | CanvasGetSize(x, y); |
1178 | return; | |
2d120f83 | 1179 | } |
34636400 VZ |
1180 | |
1181 | Widget widget = (Widget) GetTopWidget(); | |
1182 | Dimension xx, yy; | |
1183 | XtVaGetValues(widget, XmNwidth, &xx, XmNheight, &yy, NULL); | |
1184 | *x = xx; *y = yy; | |
4bb6408c JS |
1185 | } |
1186 | ||
af0bb3b1 | 1187 | void wxWindow::DoGetPosition(int *x, int *y) const |
4bb6408c | 1188 | { |
34636400 | 1189 | if (m_drawingArea) |
2d120f83 | 1190 | { |
34636400 VZ |
1191 | CanvasGetPosition(x, y); |
1192 | return; | |
2d120f83 | 1193 | } |
34636400 VZ |
1194 | Widget widget = (Widget) GetTopWidget(); |
1195 | Position xx, yy; | |
1196 | XtVaGetValues(widget, XmNx, &xx, XmNy, &yy, NULL); | |
b59bf2db | 1197 | |
34636400 VZ |
1198 | // We may be faking the client origin. So a window that's really at (0, 30) |
1199 | // may appear (to wxWin apps) to be at (0, 0). | |
1200 | if (GetParent()) | |
b59bf2db | 1201 | { |
34636400 VZ |
1202 | wxPoint pt(GetParent()->GetClientAreaOrigin()); |
1203 | xx -= pt.x; | |
1204 | yy -= pt.y; | |
b59bf2db | 1205 | } |
34636400 VZ |
1206 | |
1207 | *x = xx; *y = yy; | |
4bb6408c JS |
1208 | } |
1209 | ||
af0bb3b1 | 1210 | void wxWindow::DoScreenToClient(int *x, int *y) const |
4bb6408c | 1211 | { |
34636400 VZ |
1212 | Widget widget = (Widget) GetClientWidget(); |
1213 | Display *display = XtDisplay((Widget) GetMainWidget()); | |
1214 | Window rootWindow = RootWindowOfScreen(XtScreen(widget)); | |
1215 | Window thisWindow = XtWindow(widget); | |
1216 | ||
1217 | Window childWindow; | |
1218 | int xx = *x; | |
1219 | int yy = *y; | |
1220 | XTranslateCoordinates(display, rootWindow, thisWindow, xx, yy, x, y, &childWindow); | |
4bb6408c JS |
1221 | } |
1222 | ||
af0bb3b1 | 1223 | void wxWindow::DoClientToScreen(int *x, int *y) const |
4bb6408c | 1224 | { |
34636400 VZ |
1225 | Widget widget = (Widget) GetClientWidget(); |
1226 | Display *display = XtDisplay(widget); | |
1227 | Window rootWindow = RootWindowOfScreen(XtScreen(widget)); | |
1228 | Window thisWindow = XtWindow(widget); | |
1229 | ||
1230 | Window childWindow; | |
1231 | int xx = *x; | |
1232 | int yy = *y; | |
1233 | XTranslateCoordinates(display, thisWindow, rootWindow, xx, yy, x, y, &childWindow); | |
4bb6408c JS |
1234 | } |
1235 | ||
34636400 VZ |
1236 | |
1237 | // Get size *available for subwindows* i.e. excluding menu bar etc. | |
af0bb3b1 | 1238 | void wxWindow::DoGetClientSize(int *x, int *y) const |
4fabb575 | 1239 | { |
34636400 VZ |
1240 | Widget widget = (Widget) GetClientWidget(); |
1241 | Dimension xx, yy; | |
1242 | XtVaGetValues(widget, XmNwidth, &xx, XmNheight, &yy, NULL); | |
1243 | *x = xx; *y = yy; | |
4fabb575 JS |
1244 | } |
1245 | ||
34636400 | 1246 | void wxWindow::DoSetSize(int x, int y, int width, int height, int sizeFlags) |
4bb6408c | 1247 | { |
34636400 VZ |
1248 | // A bit of optimization to help sort out the flickers. |
1249 | int oldX, oldY, oldW, oldH; | |
1250 | GetSize(& oldW, & oldH); | |
1251 | GetPosition(& oldX, & oldY); | |
1252 | ||
9d9b7755 VZ |
1253 | if ( !(sizeFlags & wxSIZE_ALLOW_MINUS_ONE) ) |
1254 | { | |
1255 | if ( x == -1 ) | |
1256 | x = oldX; | |
1257 | if ( y == -1 ) | |
1258 | y = oldY; | |
1259 | } | |
34636400 | 1260 | |
9d9b7755 VZ |
1261 | if ( width == -1 ) |
1262 | width = oldW; | |
1263 | if ( height == -1 ) | |
1264 | height = oldH; | |
34636400 | 1265 | |
9d9b7755 VZ |
1266 | bool nothingChanged = (x == oldX) && (y == oldY) && |
1267 | (width == oldW) && (height == oldH); | |
34636400 VZ |
1268 | |
1269 | if (!wxNoOptimize::CanOptimize()) | |
02800301 | 1270 | { |
9d9b7755 | 1271 | nothingChanged = FALSE; |
34636400 VZ |
1272 | } |
1273 | ||
9d9b7755 | 1274 | if ( !nothingChanged ) |
34636400 | 1275 | { |
9d9b7755 VZ |
1276 | if (m_drawingArea) |
1277 | { | |
1278 | CanvasSetSize(x, y, width, height, sizeFlags); | |
1279 | return; | |
1280 | } | |
34636400 | 1281 | |
9d9b7755 VZ |
1282 | Widget widget = (Widget) GetTopWidget(); |
1283 | if (!widget) | |
1284 | return; | |
34636400 | 1285 | |
9d9b7755 VZ |
1286 | bool managed = XtIsManaged( widget ); |
1287 | if (managed) | |
1288 | XtUnmanageChild(widget); | |
34636400 | 1289 | |
9d9b7755 VZ |
1290 | int xx = x; |
1291 | int yy = y; | |
1292 | AdjustForParentClientOrigin(xx, yy, sizeFlags); | |
1293 | ||
1294 | DoMoveWindow(xx, yy, width, height); | |
34636400 | 1295 | |
9d9b7755 VZ |
1296 | if (managed) |
1297 | XtManageChild(widget); | |
34636400 | 1298 | |
9d9b7755 VZ |
1299 | // How about this bit. Maybe we don't need to generate size events |
1300 | // all the time -- they'll be generated when the window is sized anyway. | |
02800301 | 1301 | #if 0 |
9d9b7755 VZ |
1302 | wxSizeEvent sizeEvent(wxSize(width, height), GetId()); |
1303 | sizeEvent.SetEventObject(this); | |
34636400 | 1304 | |
9d9b7755 | 1305 | GetEventHandler()->ProcessEvent(sizeEvent); |
34636400 | 1306 | #endif // 0 |
9d9b7755 | 1307 | } |
4bb6408c JS |
1308 | } |
1309 | ||
34636400 | 1310 | void wxWindow::DoSetClientSize(int width, int height) |
4bb6408c | 1311 | { |
34636400 | 1312 | if (m_drawingArea) |
4bb6408c | 1313 | { |
34636400 VZ |
1314 | CanvasSetClientSize(width, height); |
1315 | return; | |
4bb6408c | 1316 | } |
34636400 VZ |
1317 | |
1318 | Widget widget = (Widget) GetTopWidget(); | |
1319 | ||
1320 | if (width > -1) | |
1321 | XtVaSetValues(widget, XmNwidth, width, NULL); | |
1322 | if (height > -1) | |
1323 | XtVaSetValues(widget, XmNheight, height, NULL); | |
1324 | ||
1325 | wxSizeEvent sizeEvent(wxSize(width, height), GetId()); | |
1326 | sizeEvent.SetEventObject(this); | |
1327 | ||
1328 | GetEventHandler()->ProcessEvent(sizeEvent); | |
4bb6408c JS |
1329 | } |
1330 | ||
34636400 VZ |
1331 | // For implementation purposes - sometimes decorations make the client area |
1332 | // smaller | |
1333 | wxPoint wxWindow::GetClientAreaOrigin() const | |
02e8b2f9 | 1334 | { |
34636400 | 1335 | return wxPoint(0, 0); |
02e8b2f9 JS |
1336 | } |
1337 | ||
34636400 VZ |
1338 | // Makes an adjustment to the window position (for example, a frame that has |
1339 | // a toolbar that it manages itself). | |
1340 | void wxWindow::AdjustForParentClientOrigin(int& x, int& y, int sizeFlags) | |
4bb6408c | 1341 | { |
34636400 | 1342 | if (((sizeFlags & wxSIZE_NO_ADJUSTMENTS) == 0) && GetParent()) |
2d120f83 | 1343 | { |
34636400 VZ |
1344 | wxPoint pt(GetParent()->GetClientAreaOrigin()); |
1345 | x += pt.x; y += pt.y; | |
2d120f83 | 1346 | } |
4bb6408c JS |
1347 | } |
1348 | ||
34636400 | 1349 | void wxWindow::SetSizeHints(int minW, int minH, int maxW, int maxH, int incW, int incH) |
4bb6408c | 1350 | { |
34636400 VZ |
1351 | m_minWidth = minW; |
1352 | m_minHeight = minH; | |
1353 | m_maxWidth = maxW; | |
1354 | m_maxHeight = maxH; | |
1355 | ||
1356 | wxFrame *frame = wxDynamicCast(this, wxFrame); | |
1357 | if ( !frame ) | |
2d120f83 | 1358 | { |
34636400 VZ |
1359 | // TODO what about dialogs? |
1360 | return; | |
2d120f83 | 1361 | } |
4bb6408c | 1362 | |
34636400 VZ |
1363 | Widget widget = (Widget) frame->GetShellWidget(); |
1364 | ||
1365 | if (minW > -1) | |
1366 | XtVaSetValues(widget, XmNminWidth, minW, NULL); | |
1367 | if (minH > -1) | |
1368 | XtVaSetValues(widget, XmNminHeight, minH, NULL); | |
1369 | if (maxW > -1) | |
1370 | XtVaSetValues(widget, XmNmaxWidth, maxW, NULL); | |
1371 | if (maxH > -1) | |
1372 | XtVaSetValues(widget, XmNmaxHeight, maxH, NULL); | |
1373 | if (incW > -1) | |
1374 | XtVaSetValues(widget, XmNwidthInc, incW, NULL); | |
1375 | if (incH > -1) | |
1376 | XtVaSetValues(widget, XmNheightInc, incH, NULL); | |
4bb6408c JS |
1377 | } |
1378 | ||
9d9b7755 VZ |
1379 | void wxWindow::DoMoveWindow(int x, int y, int width, int height) |
1380 | { | |
0148fe1e VZ |
1381 | XtVaSetValues((Widget)GetTopWidget(), |
1382 | XmNx, x, | |
1383 | XmNy, y, | |
9d9b7755 VZ |
1384 | XmNwidth, width, |
1385 | XmNheight, height, | |
1386 | NULL); | |
1387 | } | |
1388 | ||
34636400 VZ |
1389 | // --------------------------------------------------------------------------- |
1390 | // text metrics | |
1391 | // --------------------------------------------------------------------------- | |
1392 | ||
1393 | int wxWindow::GetCharHeight() const | |
4bb6408c | 1394 | { |
af0bb3b1 | 1395 | wxCHECK_MSG( m_font.Ok(), 0, "valid window font needed" ); |
34636400 | 1396 | |
af0bb3b1 | 1397 | WXFontStructPtr pFontStruct = m_font.GetFontStruct(1.0, GetXDisplay()); |
34636400 VZ |
1398 | |
1399 | int direction, ascent, descent; | |
1400 | XCharStruct overall; | |
1401 | XTextExtents ((XFontStruct*) pFontStruct, "x", 1, &direction, &ascent, | |
1402 | &descent, &overall); | |
1403 | ||
1404 | // return (overall.ascent + overall.descent); | |
1405 | return (ascent + descent); | |
4bb6408c JS |
1406 | } |
1407 | ||
34636400 | 1408 | int wxWindow::GetCharWidth() const |
4bb6408c | 1409 | { |
af0bb3b1 | 1410 | wxCHECK_MSG( m_font.Ok(), 0, "valid window font needed" ); |
34636400 | 1411 | |
af0bb3b1 | 1412 | WXFontStructPtr pFontStruct = m_font.GetFontStruct(1.0, GetXDisplay()); |
34636400 VZ |
1413 | |
1414 | int direction, ascent, descent; | |
1415 | XCharStruct overall; | |
1416 | XTextExtents ((XFontStruct*) pFontStruct, "x", 1, &direction, &ascent, | |
1417 | &descent, &overall); | |
1418 | ||
1419 | return overall.width; | |
4bb6408c JS |
1420 | } |
1421 | ||
34636400 VZ |
1422 | void wxWindow::GetTextExtent(const wxString& string, |
1423 | int *x, int *y, | |
1424 | int *descent, int *externalLeading, | |
1425 | const wxFont *theFont) const | |
4bb6408c | 1426 | { |
34636400 VZ |
1427 | wxFont *fontToUse = (wxFont *)theFont; |
1428 | if (!fontToUse) | |
af0bb3b1 | 1429 | fontToUse = (wxFont *) & m_font; |
34636400 | 1430 | |
af0bb3b1 | 1431 | wxCHECK_RET( fontToUse->Ok(), "valid window font needed" ); |
8e877c19 | 1432 | |
34636400 VZ |
1433 | WXFontStructPtr pFontStruct = theFont->GetFontStruct(1.0, GetXDisplay()); |
1434 | ||
1435 | int direction, ascent, descent2; | |
1436 | XCharStruct overall; | |
8e877c19 | 1437 | int slen = string.Len(); |
34636400 VZ |
1438 | |
1439 | #if 0 | |
1440 | if (use16) | |
1441 | XTextExtents16((XFontStruct*) pFontStruct, (XChar2b *) (char*) (const char*) string, slen, &direction, | |
1442 | &ascent, &descent2, &overall); | |
1443 | #endif | |
1444 | ||
1445 | XTextExtents((XFontStruct*) pFontStruct, string, slen, | |
1446 | &direction, &ascent, &descent2, &overall); | |
1447 | ||
1448 | if ( x ) | |
1449 | *x = (overall.width); | |
1450 | if ( y ) | |
1451 | *y = (ascent + descent2); | |
1452 | if (descent) | |
1453 | *descent = descent2; | |
1454 | if (externalLeading) | |
1455 | *externalLeading = 0; | |
8e877c19 | 1456 | |
4bb6408c JS |
1457 | } |
1458 | ||
34636400 VZ |
1459 | // ---------------------------------------------------------------------------- |
1460 | // painting | |
1461 | // ---------------------------------------------------------------------------- | |
4bb6408c | 1462 | |
34636400 | 1463 | void wxWindow::Refresh(bool eraseBack, const wxRect *rect) |
4bb6408c | 1464 | { |
34636400 VZ |
1465 | m_needsRefresh = TRUE; |
1466 | Display *display = XtDisplay((Widget) GetMainWidget()); | |
1467 | Window thisWindow = XtWindow((Widget) GetMainWidget()); | |
1468 | ||
1469 | XExposeEvent dummyEvent; | |
1470 | int width, height; | |
1471 | GetSize(&width, &height); | |
1472 | ||
1473 | dummyEvent.type = Expose; | |
1474 | dummyEvent.display = display; | |
1475 | dummyEvent.send_event = True; | |
1476 | dummyEvent.window = thisWindow; | |
1477 | if (rect) | |
2d120f83 | 1478 | { |
34636400 VZ |
1479 | dummyEvent.x = rect->x; |
1480 | dummyEvent.y = rect->y; | |
1481 | dummyEvent.width = rect->width; | |
1482 | dummyEvent.height = rect->height; | |
2d120f83 JS |
1483 | } |
1484 | else | |
1485 | { | |
34636400 VZ |
1486 | dummyEvent.x = 0; |
1487 | dummyEvent.y = 0; | |
1488 | dummyEvent.width = width; | |
1489 | dummyEvent.height = height; | |
2d120f83 | 1490 | } |
34636400 | 1491 | dummyEvent.count = 0; |
4bb6408c | 1492 | |
34636400 | 1493 | if (eraseBack) |
2d120f83 | 1494 | { |
34636400 VZ |
1495 | wxClientDC dc(this); |
1496 | wxBrush backgroundBrush(GetBackgroundColour(), wxSOLID); | |
1497 | dc.SetBackground(backgroundBrush); | |
1498 | if (rect) | |
1499 | dc.Clear(*rect); | |
1500 | else | |
1501 | dc.Clear(); | |
2d120f83 | 1502 | } |
4bb6408c | 1503 | |
34636400 | 1504 | XSendEvent(display, thisWindow, False, ExposureMask, (XEvent *)&dummyEvent); |
4bb6408c JS |
1505 | } |
1506 | ||
34636400 | 1507 | void wxWindow::Clear() |
4bb6408c | 1508 | { |
34636400 VZ |
1509 | wxClientDC dc(this); |
1510 | wxBrush brush(GetBackgroundColour(), wxSOLID); | |
1511 | dc.SetBackground(brush); | |
1512 | dc.Clear(); | |
4bb6408c JS |
1513 | } |
1514 | ||
34636400 | 1515 | void wxWindow::ClearUpdateRects() |
4bb6408c | 1516 | { |
af0bb3b1 | 1517 | wxRectList::Node* node = m_updateRects.GetFirst(); |
2d120f83 JS |
1518 | while (node) |
1519 | { | |
af0bb3b1 | 1520 | wxRect* rect = node->GetData(); |
34636400 | 1521 | delete rect; |
af0bb3b1 | 1522 | node = node->GetNext(); |
2d120f83 | 1523 | } |
af0bb3b1 | 1524 | |
34636400 | 1525 | m_updateRects.Clear(); |
4bb6408c JS |
1526 | } |
1527 | ||
34636400 | 1528 | void wxWindow::DoPaint() |
4bb6408c | 1529 | { |
34636400 VZ |
1530 | //TODO : make a temporary gc so we can do the XCopyArea below |
1531 | if (m_backingPixmap && !m_needsRefresh) | |
4bb6408c | 1532 | { |
34636400 | 1533 | wxPaintDC dc(this); |
4bb6408c | 1534 | |
34636400 | 1535 | GC tempGC = (GC) dc.GetBackingGC(); |
4bb6408c | 1536 | |
34636400 | 1537 | Widget widget = (Widget) GetMainWidget(); |
4bb6408c | 1538 | |
34636400 VZ |
1539 | int scrollPosX = 0; |
1540 | int scrollPosY = 0; | |
4bb6408c | 1541 | |
34636400 VZ |
1542 | // We have to test whether it's a wxScrolledWindow (hack!) because |
1543 | // otherwise we don't know how many pixels have been scrolled. We might | |
1544 | // solve this in the future by defining virtual wxWindow functions to get | |
1545 | // the scroll position in pixels. Or, each kind of scrolled window has to | |
1546 | // implement backing stores itself, using generic wxWindows code. | |
1547 | wxScrolledWindow* scrolledWindow = wxDynamicCast(this, wxScrolledWindow); | |
1548 | if ( scrolledWindow ) | |
1549 | { | |
1550 | int x, y; | |
1551 | scrolledWindow->CalcScrolledPosition(0, 0, &x, &y); | |
1552 | ||
1553 | scrollPosX = - x; | |
1554 | scrollPosY = - y; | |
1555 | } | |
1556 | ||
1557 | // TODO: This could be optimized further by only copying the areas in the | |
1558 | // current update region. | |
1559 | ||
1560 | // Only blit the part visible in the client area. The backing pixmap | |
1561 | // always starts at 0, 0 but we may be looking at only a portion of it. | |
1562 | wxSize clientArea = GetClientSize(); | |
1563 | int toBlitX = m_pixmapWidth - scrollPosX; | |
1564 | int toBlitY = m_pixmapHeight - scrollPosY; | |
1565 | ||
1566 | // Copy whichever is samller, the amount of pixmap we have to copy, | |
1567 | // or the size of the client area. | |
1568 | toBlitX = wxMin(toBlitX, clientArea.x); | |
1569 | toBlitY = wxMin(toBlitY, clientArea.y); | |
1570 | ||
1571 | // Make sure we're not negative | |
1572 | toBlitX = wxMax(0, toBlitX); | |
1573 | toBlitY = wxMax(0, toBlitY); | |
1574 | ||
1575 | XCopyArea | |
1576 | ( | |
1577 | XtDisplay(widget), | |
1578 | (Pixmap) m_backingPixmap, | |
1579 | XtWindow (widget), | |
1580 | tempGC, | |
1581 | scrollPosX, scrollPosY, // Start at the scroll position | |
1582 | toBlitX, toBlitY, // How much of the pixmap to copy | |
1583 | 0, 0 // Destination | |
1584 | ); | |
1585 | } | |
1586 | else | |
4bb6408c | 1587 | { |
34636400 VZ |
1588 | // Set an erase event first |
1589 | wxEraseEvent eraseEvent(GetId()); | |
1590 | eraseEvent.SetEventObject(this); | |
1591 | GetEventHandler()->ProcessEvent(eraseEvent); | |
1592 | ||
1593 | wxPaintEvent event(GetId()); | |
1594 | event.SetEventObject(this); | |
1595 | GetEventHandler()->ProcessEvent(event); | |
1596 | ||
1597 | m_needsRefresh = FALSE; | |
4bb6408c | 1598 | } |
4bb6408c JS |
1599 | } |
1600 | ||
34636400 VZ |
1601 | // ---------------------------------------------------------------------------- |
1602 | // event handlers | |
1603 | // ---------------------------------------------------------------------------- | |
1604 | ||
1605 | // Responds to colour changes: passes event on to children. | |
1606 | void wxWindow::OnSysColourChanged(wxSysColourChangedEvent& event) | |
4bb6408c | 1607 | { |
34636400 VZ |
1608 | wxWindowList::Node *node = GetChildren().GetFirst(); |
1609 | while ( node ) | |
4bb6408c | 1610 | { |
34636400 VZ |
1611 | // Only propagate to non-top-level windows |
1612 | wxWindow *win = node->GetData(); | |
1613 | if ( win->GetParent() ) | |
2d120f83 | 1614 | { |
34636400 VZ |
1615 | wxSysColourChangedEvent event2; |
1616 | event.m_eventObject = win; | |
1617 | win->GetEventHandler()->ProcessEvent(event2); | |
2d120f83 | 1618 | } |
4bb6408c | 1619 | |
34636400 | 1620 | node = node->GetNext(); |
2d120f83 | 1621 | } |
4bb6408c JS |
1622 | } |
1623 | ||
af111fc3 | 1624 | void wxWindow::OnIdle(wxIdleEvent& WXUNUSED(event)) |
4bb6408c | 1625 | { |
34636400 VZ |
1626 | // This calls the UI-update mechanism (querying windows for |
1627 | // menu/toolbar/control state information) | |
1628 | UpdateWindowUI(); | |
4bb6408c JS |
1629 | } |
1630 | ||
34636400 VZ |
1631 | // ---------------------------------------------------------------------------- |
1632 | // accelerators | |
1633 | // ---------------------------------------------------------------------------- | |
4bb6408c | 1634 | |
34636400 | 1635 | bool wxWindow::ProcessAccelerator(wxKeyEvent& event) |
4bb6408c | 1636 | { |
34636400 VZ |
1637 | if (!m_acceleratorTable.Ok()) |
1638 | return FALSE; | |
4bb6408c | 1639 | |
34636400 VZ |
1640 | int count = m_acceleratorTable.GetCount(); |
1641 | wxAcceleratorEntry* entries = m_acceleratorTable.GetEntries(); | |
1642 | int i; | |
1643 | for (i = 0; i < count; i++) | |
2d120f83 | 1644 | { |
34636400 VZ |
1645 | wxAcceleratorEntry* entry = & (entries[i]); |
1646 | if (entry->MatchesEvent(event)) | |
1647 | { | |
1648 | // Bingo, we have a match. Now find a control that matches the entry | |
1649 | // command id. | |
4bb6408c | 1650 | |
34636400 VZ |
1651 | // Need to go up to the top of the window hierarchy, since it might |
1652 | // be e.g. a menu item | |
1653 | wxWindow* parent = this; | |
1654 | while ( parent && !parent->IsTopLevel() ) | |
1655 | parent = parent->GetParent(); | |
4bb6408c | 1656 | |
34636400 VZ |
1657 | if (!parent) |
1658 | return FALSE; | |
4bb6408c | 1659 | |
34636400 VZ |
1660 | wxFrame* frame = wxDynamicCast(parent, wxFrame); |
1661 | if ( frame ) | |
1662 | { | |
1663 | // Try for a menu command | |
1664 | if (frame->GetMenuBar()) | |
1665 | { | |
c71830c3 | 1666 | wxMenuItem* item = frame->GetMenuBar()->FindItem(entry->GetCommand()); |
34636400 VZ |
1667 | if (item) |
1668 | { | |
1669 | wxCommandEvent commandEvent(wxEVT_COMMAND_MENU_SELECTED, entry->GetCommand()); | |
1670 | commandEvent.SetEventObject(frame); | |
4bb6408c | 1671 | |
34636400 VZ |
1672 | // If ProcessEvent returns TRUE (it was handled), then |
1673 | // the calling code will skip the event handling. | |
1674 | return frame->GetEventHandler()->ProcessEvent(commandEvent); | |
1675 | } | |
1676 | } | |
1677 | } | |
3dd4e4e0 | 1678 | |
34636400 VZ |
1679 | // Find a child matching the command id |
1680 | wxWindow* child = parent->FindWindow(entry->GetCommand()); | |
3dd4e4e0 | 1681 | |
34636400 VZ |
1682 | // No such child |
1683 | if (!child) | |
1684 | return FALSE; | |
3dd4e4e0 | 1685 | |
34636400 VZ |
1686 | // Now we process those kinds of windows that we can. |
1687 | // For now, only buttons. | |
1688 | if ( wxDynamicCast(child, wxButton) ) | |
1689 | { | |
1690 | wxCommandEvent commandEvent (wxEVT_COMMAND_BUTTON_CLICKED, child->GetId()); | |
1691 | commandEvent.SetEventObject(child); | |
1692 | return child->GetEventHandler()->ProcessEvent(commandEvent); | |
1693 | } | |
3dd4e4e0 | 1694 | |
34636400 VZ |
1695 | return FALSE; |
1696 | } // matches event | |
1697 | }// for | |
4bb6408c | 1698 | |
34636400 VZ |
1699 | // We didn't match the key event against an accelerator. |
1700 | return FALSE; | |
4bb6408c JS |
1701 | } |
1702 | ||
34636400 VZ |
1703 | // ============================================================================ |
1704 | // Motif-specific stuff from here on | |
1705 | // ============================================================================ | |
1706 | ||
1707 | // ---------------------------------------------------------------------------- | |
1708 | // function which maintain the global hash table mapping Widgets to wxWindows | |
1709 | // ---------------------------------------------------------------------------- | |
1710 | ||
1711 | bool wxAddWindowToTable(Widget w, wxWindow *win) | |
4bb6408c | 1712 | { |
34636400 | 1713 | wxWindow *oldItem = NULL; |
33caefb3 | 1714 | if ((oldItem = (wxWindow *)wxWidgetHashTable->Get ((long) w))) |
2d120f83 | 1715 | { |
34636400 VZ |
1716 | wxLogDebug("Widget table clash: new widget is %ld, %s", |
1717 | (long)w, win->GetClassInfo()->GetClassName()); | |
1718 | return FALSE; | |
2d120f83 | 1719 | } |
4bb6408c | 1720 | |
33caefb3 | 1721 | wxWidgetHashTable->Put((long) w, win); |
4bb6408c | 1722 | |
e838cc14 | 1723 | wxLogTrace("widget", "Widget 0x%08x <-> window %p (%s)", |
31528cd3 VZ |
1724 | w, win, win->GetClassInfo()->GetClassName()); |
1725 | ||
34636400 | 1726 | return TRUE; |
4bb6408c JS |
1727 | } |
1728 | ||
34636400 | 1729 | wxWindow *wxGetWindowFromTable(Widget w) |
4bb6408c | 1730 | { |
33caefb3 | 1731 | return (wxWindow *)wxWidgetHashTable->Get((long) w); |
4bb6408c JS |
1732 | } |
1733 | ||
34636400 | 1734 | void wxDeleteWindowFromTable(Widget w) |
4bb6408c | 1735 | { |
33caefb3 | 1736 | wxWidgetHashTable->Delete((long)w); |
4bb6408c JS |
1737 | } |
1738 | ||
34636400 VZ |
1739 | // ---------------------------------------------------------------------------- |
1740 | // add/remove window from the table | |
1741 | // ---------------------------------------------------------------------------- | |
4bb6408c | 1742 | |
34636400 | 1743 | // Add to hash table, add event handler |
af111fc3 | 1744 | bool wxWindow::AttachWidget (wxWindow* WXUNUSED(parent), WXWidget mainWidget, |
34636400 | 1745 | WXWidget formWidget, int x, int y, int width, int height) |
4bb6408c | 1746 | { |
34636400 VZ |
1747 | wxAddWindowToTable((Widget) mainWidget, this); |
1748 | if (CanAddEventHandler()) | |
1749 | { | |
1750 | XtAddEventHandler((Widget) mainWidget, | |
1751 | ButtonPressMask | ButtonReleaseMask | PointerMotionMask, // | KeyPressMask, | |
1752 | False, | |
1753 | wxPanelItemEventHandler, | |
1754 | (XtPointer) this); | |
1755 | } | |
4bb6408c | 1756 | |
34636400 VZ |
1757 | if (!formWidget) |
1758 | { | |
1759 | XtTranslations ptr; | |
1760 | XtOverrideTranslations ((Widget) mainWidget, | |
1761 | ptr = XtParseTranslationTable ("<Configure>: resize()")); | |
1762 | XtFree ((char *) ptr); | |
1763 | } | |
4bb6408c | 1764 | |
34636400 VZ |
1765 | // Some widgets have a parent form widget, e.g. wxRadioBox |
1766 | if (formWidget) | |
1767 | { | |
1768 | if (!wxAddWindowToTable((Widget) formWidget, this)) | |
1769 | return FALSE; | |
4bb6408c | 1770 | |
34636400 VZ |
1771 | XtTranslations ptr; |
1772 | XtOverrideTranslations ((Widget) formWidget, | |
1773 | ptr = XtParseTranslationTable ("<Configure>: resize()")); | |
1774 | XtFree ((char *) ptr); | |
1775 | } | |
4bb6408c | 1776 | |
34636400 VZ |
1777 | if (x == -1) |
1778 | x = 0; | |
1779 | if (y == -1) | |
1780 | y = 0; | |
1781 | SetSize (x, y, width, height); | |
4bb6408c | 1782 | |
34636400 | 1783 | return TRUE; |
4bb6408c JS |
1784 | } |
1785 | ||
34636400 VZ |
1786 | // Remove event handler, remove from hash table |
1787 | bool wxWindow::DetachWidget(WXWidget widget) | |
4bb6408c | 1788 | { |
34636400 | 1789 | if (CanAddEventHandler()) |
4bb6408c | 1790 | { |
34636400 VZ |
1791 | XtRemoveEventHandler((Widget) widget, |
1792 | ButtonPressMask | ButtonReleaseMask | PointerMotionMask, // | KeyPressMask, | |
1793 | False, | |
1794 | wxPanelItemEventHandler, | |
1795 | (XtPointer)this); | |
4bb6408c | 1796 | } |
4bb6408c | 1797 | |
34636400 | 1798 | wxDeleteWindowFromTable((Widget) widget); |
2d120f83 | 1799 | return TRUE; |
4bb6408c JS |
1800 | } |
1801 | ||
34636400 VZ |
1802 | // ---------------------------------------------------------------------------- |
1803 | // Motif-specific accessors | |
1804 | // ---------------------------------------------------------------------------- | |
2d120f83 | 1805 | |
34636400 | 1806 | // Get the underlying X window |
4bb6408c JS |
1807 | WXWindow wxWindow::GetXWindow() const |
1808 | { | |
af0bb3b1 | 1809 | Widget wMain = (Widget)GetMainWidget(); |
34636400 VZ |
1810 | if ( wMain ) |
1811 | return (WXWindow) XtWindow(wMain); | |
ad813b00 JS |
1812 | else |
1813 | return (WXWindow) 0; | |
4bb6408c JS |
1814 | } |
1815 | ||
34636400 | 1816 | // Get the underlying X display |
4bb6408c JS |
1817 | WXDisplay *wxWindow::GetXDisplay() const |
1818 | { | |
af0bb3b1 | 1819 | Widget wMain = (Widget)GetMainWidget(); |
34636400 VZ |
1820 | if ( wMain ) |
1821 | return (WXDisplay*) XtDisplay(wMain); | |
ad813b00 JS |
1822 | else |
1823 | return (WXDisplay*) NULL; | |
4bb6408c JS |
1824 | } |
1825 | ||
1826 | WXWidget wxWindow::GetMainWidget() const | |
1827 | { | |
50414e24 | 1828 | if (m_drawingArea) |
2d120f83 | 1829 | return m_drawingArea; |
50414e24 | 1830 | else |
2d120f83 | 1831 | return m_mainWidget; |
50414e24 JS |
1832 | } |
1833 | ||
1834 | WXWidget wxWindow::GetClientWidget() const | |
1835 | { | |
1836 | if (m_drawingArea != (WXWidget) 0) | |
1837 | return m_drawingArea; | |
1838 | else | |
02e8b2f9 JS |
1839 | return GetMainWidget(); |
1840 | } | |
1841 | ||
1842 | WXWidget wxWindow::GetTopWidget() const | |
1843 | { | |
1844 | return GetMainWidget(); | |
4bb6408c JS |
1845 | } |
1846 | ||
34636400 VZ |
1847 | WXWidget wxWindow::GetLabelWidget() const |
1848 | { | |
1849 | return GetMainWidget(); | |
1850 | } | |
1851 | ||
1852 | // ---------------------------------------------------------------------------- | |
1853 | // Motif callbacks | |
1854 | // ---------------------------------------------------------------------------- | |
1855 | ||
1856 | // All widgets should have this as their resize proc. | |
1857 | // OnSize sent to wxWindow via client data. | |
af111fc3 | 1858 | void wxWidgetResizeProc(Widget w, XConfigureEvent *WXUNUSED(event), String WXUNUSED(args)[], int *WXUNUSED(num_args)) |
34636400 VZ |
1859 | { |
1860 | wxWindow *win = wxGetWindowFromTable(w); | |
1861 | if (!win) | |
1862 | return; | |
1863 | ||
1864 | if (win->PreResize()) | |
1865 | { | |
1866 | int width, height; | |
1867 | win->GetSize(&width, &height); | |
1868 | wxSizeEvent sizeEvent(wxSize(width, height), win->GetId()); | |
1869 | sizeEvent.SetEventObject(win); | |
1870 | win->GetEventHandler()->ProcessEvent(sizeEvent); | |
1871 | } | |
1872 | } | |
1873 | ||
1874 | static void wxCanvasRepaintProc(Widget drawingArea, | |
1875 | XtPointer clientData, | |
1876 | XmDrawingAreaCallbackStruct * cbs) | |
50414e24 | 1877 | { |
34636400 | 1878 | if (!wxGetWindowFromTable(drawingArea)) |
2d120f83 | 1879 | return; |
34636400 | 1880 | |
50414e24 | 1881 | XEvent * event = cbs->event; |
55acd85e | 1882 | wxWindow * win = (wxWindow *) clientData; |
34636400 | 1883 | |
50414e24 JS |
1884 | switch (event->type) |
1885 | { | |
2d120f83 | 1886 | case Expose: |
55acd85e | 1887 | { |
6970c7b9 MB |
1888 | win->AddUpdateRect(event->xexpose.x, event->xexpose.y, |
1889 | event->xexpose.width, event->xexpose.height); | |
1890 | ||
55acd85e JS |
1891 | if (event -> xexpose.count == 0) |
1892 | { | |
a91b47e8 | 1893 | win->DoPaint(); |
55acd85e JS |
1894 | win->ClearUpdateRects(); |
1895 | } | |
1896 | break; | |
1897 | } | |
50414e24 | 1898 | } |
50414e24 JS |
1899 | } |
1900 | ||
1901 | // Unable to deal with Enter/Leave without a separate EventHandler (Motif 1.1.4) | |
34636400 | 1902 | static void wxCanvasEnterLeave(Widget drawingArea, |
af111fc3 | 1903 | XtPointer WXUNUSED(clientData), |
34636400 | 1904 | XCrossingEvent * event) |
50414e24 | 1905 | { |
2d120f83 JS |
1906 | XmDrawingAreaCallbackStruct cbs; |
1907 | XEvent ev; | |
34636400 | 1908 | |
2d120f83 | 1909 | ((XCrossingEvent &) ev) = *event; |
34636400 | 1910 | |
2d120f83 JS |
1911 | cbs.reason = XmCR_INPUT; |
1912 | cbs.event = &ev; | |
34636400 VZ |
1913 | |
1914 | wxCanvasInputEvent(drawingArea, (XtPointer) NULL, &cbs); | |
50414e24 JS |
1915 | } |
1916 | ||
1917 | // Fix to make it work under Motif 1.0 (!) | |
af111fc3 | 1918 | static void wxCanvasMotionEvent (Widget WXUNUSED(drawingArea), XButtonEvent * WXUNUSED(event)) |
50414e24 | 1919 | { |
34636400 | 1920 | #if XmVersion <= 1000 |
2d120f83 JS |
1921 | XmDrawingAreaCallbackStruct cbs; |
1922 | XEvent ev; | |
34636400 | 1923 | |
2d120f83 JS |
1924 | ev = *((XEvent *) event); |
1925 | cbs.reason = XmCR_INPUT; | |
1926 | cbs.event = &ev; | |
34636400 | 1927 | |
2d120f83 | 1928 | wxCanvasInputEvent (drawingArea, (XtPointer) NULL, &cbs); |
34636400 | 1929 | #endif // XmVersion <= 1000 |
50414e24 JS |
1930 | } |
1931 | ||
34636400 | 1932 | static void wxCanvasInputEvent(Widget drawingArea, |
af111fc3 | 1933 | XtPointer WXUNUSED(data), |
34636400 | 1934 | XmDrawingAreaCallbackStruct * cbs) |
50414e24 | 1935 | { |
34636400 | 1936 | wxWindow *canvas = wxGetWindowFromTable(drawingArea); |
2d120f83 | 1937 | XEvent local_event; |
34636400 | 1938 | |
2d120f83 | 1939 | if (canvas==NULL) |
34636400 VZ |
1940 | return; |
1941 | ||
2d120f83 JS |
1942 | if (cbs->reason != XmCR_INPUT) |
1943 | return; | |
34636400 VZ |
1944 | |
1945 | local_event = *(cbs->event); // We must keep a copy! | |
1946 | ||
2d120f83 | 1947 | switch (local_event.xany.type) |
50414e24 JS |
1948 | { |
1949 | case EnterNotify: | |
1950 | case LeaveNotify: | |
1951 | case ButtonPress: | |
1952 | case ButtonRelease: | |
1953 | case MotionNotify: | |
2d120f83 | 1954 | { |
1e8abce5 MB |
1955 | // FIXME: most of this mouse event code is more or less |
1956 | // duplicated in wxTranslateMouseEvent | |
1957 | // | |
2d120f83 | 1958 | wxEventType eventType = wxEVT_NULL; |
34636400 | 1959 | |
2d120f83 JS |
1960 | if (local_event.xany.type == EnterNotify) |
1961 | { | |
1962 | //if (local_event.xcrossing.mode!=NotifyNormal) | |
1963 | // return ; // Ignore grab events | |
1964 | eventType = wxEVT_ENTER_WINDOW; | |
1965 | // canvas->GetEventHandler()->OnSetFocus(); | |
1966 | } | |
1967 | else if (local_event.xany.type == LeaveNotify) | |
1968 | { | |
1e8abce5 | 1969 | //if (local_event.xcrossingr.mode!=NotifyNormal) |
2d120f83 JS |
1970 | // return ; // Ignore grab events |
1971 | eventType = wxEVT_LEAVE_WINDOW; | |
1972 | // canvas->GetEventHandler()->OnKillFocus(); | |
1973 | } | |
1974 | else if (local_event.xany.type == MotionNotify) | |
1975 | { | |
1976 | eventType = wxEVT_MOTION; | |
2d120f83 | 1977 | } |
34636400 | 1978 | |
2d120f83 JS |
1979 | else if (local_event.xany.type == ButtonPress) |
1980 | { | |
1981 | if (local_event.xbutton.button == Button1) | |
1982 | { | |
1983 | eventType = wxEVT_LEFT_DOWN; | |
af0bb3b1 | 1984 | canvas->SetButton1(TRUE); |
2d120f83 JS |
1985 | } |
1986 | else if (local_event.xbutton.button == Button2) | |
1987 | { | |
1988 | eventType = wxEVT_MIDDLE_DOWN; | |
af0bb3b1 | 1989 | canvas->SetButton2(TRUE); |
2d120f83 JS |
1990 | } |
1991 | else if (local_event.xbutton.button == Button3) | |
1992 | { | |
1993 | eventType = wxEVT_RIGHT_DOWN; | |
af0bb3b1 | 1994 | canvas->SetButton3(TRUE); |
2d120f83 JS |
1995 | } |
1996 | } | |
1997 | else if (local_event.xany.type == ButtonRelease) | |
1998 | { | |
1999 | if (local_event.xbutton.button == Button1) | |
2000 | { | |
2001 | eventType = wxEVT_LEFT_UP; | |
af0bb3b1 | 2002 | canvas->SetButton1(FALSE); |
2d120f83 JS |
2003 | } |
2004 | else if (local_event.xbutton.button == Button2) | |
2005 | { | |
2006 | eventType = wxEVT_MIDDLE_UP; | |
af0bb3b1 | 2007 | canvas->SetButton2(FALSE); |
2d120f83 JS |
2008 | } |
2009 | else if (local_event.xbutton.button == Button3) | |
2010 | { | |
2011 | eventType = wxEVT_RIGHT_UP; | |
af0bb3b1 | 2012 | canvas->SetButton3(FALSE); |
2d120f83 JS |
2013 | } |
2014 | } | |
34636400 | 2015 | |
2d120f83 | 2016 | wxMouseEvent wxevent (eventType); |
34636400 | 2017 | |
2d120f83 | 2018 | wxevent.m_leftDown = ((eventType == wxEVT_LEFT_DOWN) |
34636400 | 2019 | || (event_left_is_down (&local_event) |
2d120f83 JS |
2020 | && (eventType != wxEVT_LEFT_UP))); |
2021 | wxevent.m_middleDown = ((eventType == wxEVT_MIDDLE_DOWN) | |
34636400 | 2022 | || (event_middle_is_down (&local_event) |
2d120f83 JS |
2023 | && (eventType != wxEVT_MIDDLE_UP))); |
2024 | wxevent.m_rightDown = ((eventType == wxEVT_RIGHT_DOWN) | |
34636400 | 2025 | || (event_right_is_down (&local_event) |
2d120f83 | 2026 | && (eventType != wxEVT_RIGHT_UP))); |
34636400 | 2027 | |
2d120f83 JS |
2028 | wxevent.m_shiftDown = local_event.xbutton.state & ShiftMask; |
2029 | wxevent.m_controlDown = local_event.xbutton.state & ControlMask; | |
2030 | wxevent.m_altDown = local_event.xbutton.state & Mod3Mask; | |
2031 | wxevent.m_metaDown = local_event.xbutton.state & Mod1Mask; | |
2032 | wxevent.SetTimestamp(local_event.xbutton.time); | |
34636400 | 2033 | |
a16a9bf3 | 2034 | if ( eventType == wxEVT_MOTION ) |
1afe597e VZ |
2035 | { |
2036 | if (local_event.xmotion.is_hint == NotifyHint) | |
2037 | { | |
2038 | Window root, child; | |
2039 | Display *dpy = XtDisplay (drawingArea); | |
2040 | ||
2041 | XQueryPointer (dpy, XtWindow (drawingArea), | |
2042 | &root, &child, | |
2043 | &local_event.xmotion.x_root, | |
2044 | &local_event.xmotion.y_root, | |
2045 | &local_event.xmotion.x, | |
2046 | &local_event.xmotion.y, | |
2047 | &local_event.xmotion.state); | |
2048 | } | |
2049 | else | |
2050 | { | |
2051 | } | |
2052 | } | |
2053 | ||
2d120f83 JS |
2054 | // Now check if we need to translate this event into a double click |
2055 | if (TRUE) // canvas->doubleClickAllowed) | |
2056 | { | |
2057 | if (wxevent.ButtonDown()) | |
2058 | { | |
34636400 VZ |
2059 | long dclickTime = XtGetMultiClickTime((Display*) wxGetDisplay()); |
2060 | ||
2d120f83 JS |
2061 | // get button and time-stamp |
2062 | int button = 0; | |
af0bb3b1 VZ |
2063 | if (wxevent.LeftDown()) |
2064 | button = 1; | |
2065 | else if (wxevent.MiddleDown()) | |
2066 | button = 2; | |
2067 | else if (wxevent.RightDown()) | |
2068 | button = 3; | |
2d120f83 | 2069 | long ts = wxevent.GetTimestamp(); |
af0bb3b1 | 2070 | |
2d120f83 | 2071 | // check, if single or double click |
af0bb3b1 VZ |
2072 | int buttonLast = canvas->GetLastClickedButton(); |
2073 | long lastTS = canvas->GetLastClickTime(); | |
2074 | if ( buttonLast && buttonLast == button && (ts - lastTS) < dclickTime ) | |
2d120f83 JS |
2075 | { |
2076 | // I have a dclick | |
af0bb3b1 | 2077 | canvas->SetLastClick(0, ts); |
2d120f83 JS |
2078 | switch ( eventType ) |
2079 | { | |
2080 | case wxEVT_LEFT_DOWN: | |
2081 | wxevent.SetEventType(wxEVT_LEFT_DCLICK); | |
2082 | break; | |
2083 | case wxEVT_MIDDLE_DOWN: | |
2084 | wxevent.SetEventType(wxEVT_MIDDLE_DCLICK); | |
2085 | break; | |
2086 | case wxEVT_RIGHT_DOWN: | |
2087 | wxevent.SetEventType(wxEVT_RIGHT_DCLICK); | |
2088 | break; | |
34636400 | 2089 | |
2d120f83 JS |
2090 | default : |
2091 | break; | |
2092 | } | |
34636400 | 2093 | |
2d120f83 JS |
2094 | } |
2095 | else | |
2096 | { | |
2097 | // not fast enough or different button | |
af0bb3b1 | 2098 | canvas->SetLastClick(button, ts); |
2d120f83 JS |
2099 | } |
2100 | } | |
2101 | } | |
34636400 | 2102 | |
2d120f83 JS |
2103 | wxevent.SetId(canvas->GetId()); |
2104 | wxevent.SetEventObject(canvas); | |
2105 | wxevent.m_x = local_event.xbutton.x; | |
2106 | wxevent.m_y = local_event.xbutton.y; | |
2107 | canvas->GetEventHandler()->ProcessEvent (wxevent); | |
34636400 | 2108 | #if 0 |
2d120f83 | 2109 | if (eventType == wxEVT_ENTER_WINDOW || |
34636400 VZ |
2110 | eventType == wxEVT_LEAVE_WINDOW || |
2111 | eventType == wxEVT_MOTION | |
2112 | ) | |
2113 | return; | |
2114 | #endif // 0 | |
2d120f83 | 2115 | break; |
50414e24 JS |
2116 | } |
2117 | case KeyPress: | |
50414e24 | 2118 | { |
2d120f83 | 2119 | KeySym keySym; |
34636400 VZ |
2120 | #if 0 |
2121 | XComposeStatus compose; | |
2122 | (void) XLookupString ((XKeyEvent *) & local_event, wxBuffer, 20, &keySym, &compose); | |
2123 | #endif // 0 | |
2124 | ||
2d120f83 JS |
2125 | (void) XLookupString ((XKeyEvent *) & local_event, wxBuffer, 20, &keySym, NULL); |
2126 | int id = wxCharCodeXToWX (keySym); | |
2127 | ||
2128 | wxEventType eventType = wxEVT_CHAR; | |
50414e24 | 2129 | |
2d120f83 | 2130 | wxKeyEvent event (eventType); |
34636400 | 2131 | |
2d120f83 JS |
2132 | if (local_event.xkey.state & ShiftMask) |
2133 | event.m_shiftDown = TRUE; | |
2134 | if (local_event.xkey.state & ControlMask) | |
2135 | event.m_controlDown = TRUE; | |
2136 | if (local_event.xkey.state & Mod3Mask) | |
2137 | event.m_altDown = TRUE; | |
2138 | if (local_event.xkey.state & Mod1Mask) | |
2139 | event.m_metaDown = TRUE; | |
2140 | event.SetEventObject(canvas); | |
2141 | event.m_keyCode = id; | |
2142 | event.SetTimestamp(local_event.xkey.time); | |
34636400 | 2143 | |
2d120f83 JS |
2144 | if (id > -1) |
2145 | { | |
2146 | // Implement wxFrame::OnCharHook by checking ancestor. | |
2147 | wxWindow *parent = canvas->GetParent(); | |
2148 | while (parent && !parent->IsKindOf(CLASSINFO(wxFrame))) | |
2149 | parent = parent->GetParent(); | |
34636400 | 2150 | |
2d120f83 JS |
2151 | if (parent) |
2152 | { | |
2153 | event.SetEventType(wxEVT_CHAR_HOOK); | |
2154 | if (parent->GetEventHandler()->ProcessEvent(event)) | |
2155 | return; | |
2d120f83 | 2156 | } |
a91b47e8 JS |
2157 | |
2158 | // For simplicity, OnKeyDown is the same as OnChar | |
2159 | // TODO: filter modifier key presses from OnChar | |
2160 | event.SetEventType(wxEVT_KEY_DOWN); | |
2161 | ||
2162 | // Only process OnChar if OnKeyDown didn't swallow it | |
2163 | if (!canvas->GetEventHandler()->ProcessEvent (event)) | |
2164 | { | |
2165 | event.SetEventType(wxEVT_CHAR); | |
2166 | canvas->GetEventHandler()->ProcessEvent (event); | |
34636400 | 2167 | } |
2d120f83 JS |
2168 | } |
2169 | break; | |
2170 | } | |
2171 | case KeyRelease: | |
2172 | { | |
2173 | KeySym keySym; | |
2174 | (void) XLookupString ((XKeyEvent *) & local_event, wxBuffer, 20, &keySym, NULL); | |
2175 | int id = wxCharCodeXToWX (keySym); | |
34636400 | 2176 | |
2d120f83 | 2177 | wxKeyEvent event (wxEVT_KEY_UP); |
34636400 | 2178 | |
2d120f83 JS |
2179 | if (local_event.xkey.state & ShiftMask) |
2180 | event.m_shiftDown = TRUE; | |
2181 | if (local_event.xkey.state & ControlMask) | |
2182 | event.m_controlDown = TRUE; | |
2183 | if (local_event.xkey.state & Mod3Mask) | |
2184 | event.m_altDown = TRUE; | |
2185 | if (local_event.xkey.state & Mod1Mask) | |
2186 | event.m_metaDown = TRUE; | |
2187 | event.SetEventObject(canvas); | |
2188 | event.m_keyCode = id; | |
2189 | event.SetTimestamp(local_event.xkey.time); | |
34636400 | 2190 | |
2d120f83 JS |
2191 | if (id > -1) |
2192 | { | |
2193 | canvas->GetEventHandler()->ProcessEvent (event); | |
2194 | } | |
2195 | break; | |
50414e24 | 2196 | } |
50414e24 | 2197 | case FocusIn: |
2d120f83 JS |
2198 | { |
2199 | if (local_event.xfocus.detail != NotifyPointer) | |
2200 | { | |
2201 | wxFocusEvent event(wxEVT_SET_FOCUS, canvas->GetId()); | |
2202 | event.SetEventObject(canvas); | |
2203 | canvas->GetEventHandler()->ProcessEvent(event); | |
2204 | } | |
2205 | break; | |
50414e24 | 2206 | } |
50414e24 | 2207 | case FocusOut: |
2d120f83 JS |
2208 | { |
2209 | if (local_event.xfocus.detail != NotifyPointer) | |
2210 | { | |
2211 | wxFocusEvent event(wxEVT_KILL_FOCUS, canvas->GetId()); | |
2212 | event.SetEventObject(canvas); | |
2213 | canvas->GetEventHandler()->ProcessEvent(event); | |
2214 | } | |
2215 | break; | |
2216 | } | |
50414e24 | 2217 | default: |
2d120f83 | 2218 | break; |
50414e24 JS |
2219 | } |
2220 | } | |
2221 | ||
34636400 | 2222 | static void wxPanelItemEventHandler(Widget wid, |
af111fc3 | 2223 | XtPointer WXUNUSED(client_data), |
34636400 VZ |
2224 | XEvent* event, |
2225 | Boolean *continueToDispatch) | |
50414e24 | 2226 | { |
34636400 | 2227 | // Widget can be a label or the actual widget. |
a91b47e8 | 2228 | |
af0bb3b1 | 2229 | wxWindow *window = wxGetWindowFromTable(wid); |
34636400 VZ |
2230 | if (window) |
2231 | { | |
2232 | wxMouseEvent wxevent(0); | |
2233 | if (wxTranslateMouseEvent(wxevent, window, wid, event)) | |
2234 | { | |
2235 | window->GetEventHandler()->ProcessEvent(wxevent); | |
2236 | } | |
2237 | } | |
a91b47e8 | 2238 | |
34636400 VZ |
2239 | // TODO: probably the key to allowing default behaviour to happen. Say we |
2240 | // set a m_doDefault flag to FALSE at the start of this function. Then in | |
2241 | // e.g. wxWindow::OnMouseEvent we can call Default() which sets this flag to | |
2242 | // TRUE, indicating that default processing can happen. Thus, behaviour can | |
2243 | // appear to be overridden just by adding an event handler and not calling | |
2244 | // wxWindow::OnWhatever. ALSO, maybe we can use this instead of the current | |
2245 | // way of handling drawing area events, to simplify things. | |
2246 | *continueToDispatch = True; | |
2247 | } | |
a91b47e8 | 2248 | |
34636400 VZ |
2249 | static void wxScrollBarCallback(Widget scrollbar, |
2250 | XtPointer clientData, | |
311227c3 | 2251 | XmScrollBarCallbackStruct *cbs) |
34636400 | 2252 | { |
34636400 VZ |
2253 | wxWindow *win = wxGetWindowFromTable(scrollbar); |
2254 | int orientation = (int) clientData; | |
a91b47e8 | 2255 | |
34636400 VZ |
2256 | wxEventType eventType = wxEVT_NULL; |
2257 | switch (cbs->reason) | |
2258 | { | |
2259 | case XmCR_INCREMENT: | |
2260 | { | |
311227c3 | 2261 | eventType = wxEVT_SCROLLWIN_LINEDOWN; |
34636400 VZ |
2262 | break; |
2263 | } | |
2264 | case XmCR_DECREMENT: | |
2265 | { | |
311227c3 | 2266 | eventType = wxEVT_SCROLLWIN_LINEUP; |
34636400 VZ |
2267 | break; |
2268 | } | |
2269 | case XmCR_DRAG: | |
2270 | { | |
311227c3 | 2271 | eventType = wxEVT_SCROLLWIN_THUMBTRACK; |
34636400 VZ |
2272 | break; |
2273 | } | |
2274 | case XmCR_VALUE_CHANGED: | |
2275 | { | |
2276 | // TODO: Should this be intercepted too, or will it cause | |
2277 | // duplicate events? | |
311227c3 | 2278 | eventType = wxEVT_SCROLLWIN_THUMBTRACK; |
34636400 VZ |
2279 | break; |
2280 | } | |
2281 | case XmCR_PAGE_INCREMENT: | |
2282 | { | |
311227c3 | 2283 | eventType = wxEVT_SCROLLWIN_PAGEDOWN; |
34636400 VZ |
2284 | break; |
2285 | } | |
2286 | case XmCR_PAGE_DECREMENT: | |
2287 | { | |
311227c3 | 2288 | eventType = wxEVT_SCROLLWIN_PAGEUP; |
34636400 VZ |
2289 | break; |
2290 | } | |
2291 | case XmCR_TO_TOP: | |
2292 | { | |
311227c3 | 2293 | eventType = wxEVT_SCROLLWIN_TOP; |
34636400 VZ |
2294 | break; |
2295 | } | |
2296 | case XmCR_TO_BOTTOM: | |
2297 | { | |
311227c3 | 2298 | eventType = wxEVT_SCROLLWIN_BOTTOM; |
34636400 VZ |
2299 | break; |
2300 | } | |
2301 | default: | |
2302 | { | |
2303 | // Should never get here | |
2304 | wxFAIL_MSG("Unknown scroll event."); | |
2305 | break; | |
2306 | } | |
2307 | } | |
a91b47e8 | 2308 | |
311227c3 MB |
2309 | wxScrollWinEvent event(eventType, |
2310 | cbs->value, | |
2311 | ((orientation == XmHORIZONTAL) ? | |
2312 | wxHORIZONTAL : wxVERTICAL)); | |
2313 | event.SetEventObject( win ); | |
34636400 VZ |
2314 | win->GetEventHandler()->ProcessEvent(event); |
2315 | } | |
a91b47e8 | 2316 | |
34636400 VZ |
2317 | // For repainting arbitrary windows |
2318 | void wxUniversalRepaintProc(Widget w, XtPointer WXUNUSED(c_data), XEvent *event, char *) | |
2319 | { | |
2320 | Window window; | |
2321 | Display *display; | |
a91b47e8 | 2322 | |
34636400 VZ |
2323 | wxWindow* win = wxGetWindowFromTable(w); |
2324 | if (!win) | |
2325 | return; | |
a91b47e8 | 2326 | |
34636400 | 2327 | switch(event -> type) |
50414e24 | 2328 | { |
af0bb3b1 | 2329 | case Expose: |
34636400 VZ |
2330 | { |
2331 | window = (Window) win -> GetXWindow(); | |
2332 | display = (Display *) win -> GetXDisplay(); | |
a91b47e8 | 2333 | |
34636400 VZ |
2334 | if (event -> xexpose.count == 0) |
2335 | { | |
2336 | win->DoPaint(); | |
2337 | ||
2338 | win->ClearUpdateRects(); | |
2339 | } | |
af0bb3b1 VZ |
2340 | else |
2341 | { | |
2342 | win->AddUpdateRect(event->xexpose.x, event->xexpose.y, | |
2343 | event->xexpose.width, event->xexpose.height); | |
2344 | } | |
2345 | ||
34636400 VZ |
2346 | break; |
2347 | } | |
50414e24 JS |
2348 | } |
2349 | } | |
2350 | ||
34636400 VZ |
2351 | // ---------------------------------------------------------------------------- |
2352 | // CanvaseXXXSize() functions | |
2353 | // ---------------------------------------------------------------------------- | |
2354 | ||
50414e24 JS |
2355 | // SetSize, but as per old wxCanvas (with drawing widget etc.) |
2356 | void wxWindow::CanvasSetSize (int x, int y, int w, int h, int sizeFlags) | |
2357 | { | |
2d120f83 JS |
2358 | // A bit of optimization to help sort out the flickers. |
2359 | int oldX, oldY, oldW, oldH; | |
2360 | GetSize(& oldW, & oldH); | |
2361 | GetPosition(& oldX, & oldY); | |
34636400 | 2362 | |
2d120f83 JS |
2363 | bool useOldPos = FALSE; |
2364 | bool useOldSize = FALSE; | |
34636400 | 2365 | |
2d120f83 JS |
2366 | if ((x == -1) && (x == -1) && ((sizeFlags & wxSIZE_ALLOW_MINUS_ONE) == 0)) |
2367 | useOldPos = TRUE; | |
2368 | else if (x == oldX && y == oldY) | |
2369 | useOldPos = TRUE; | |
34636400 | 2370 | |
2d120f83 JS |
2371 | if ((w == -1) && (h == -1)) |
2372 | useOldSize = TRUE; | |
2373 | else if (w == oldW && h == oldH) | |
2374 | useOldSize = TRUE; | |
34636400 | 2375 | |
2d120f83 | 2376 | if (!wxNoOptimize::CanOptimize()) |
50414e24 | 2377 | { |
2d120f83 | 2378 | useOldSize = FALSE; useOldPos = FALSE; |
50414e24 | 2379 | } |
34636400 | 2380 | |
2d120f83 JS |
2381 | if (useOldPos && useOldSize) |
2382 | return; | |
34636400 | 2383 | |
2d120f83 JS |
2384 | Widget drawingArea = (Widget) m_drawingArea; |
2385 | bool managed = XtIsManaged(m_borderWidget ? (Widget) m_borderWidget : (Widget) m_scrolledWindow); | |
34636400 | 2386 | |
2d120f83 JS |
2387 | if (managed) |
2388 | XtUnmanageChild (m_borderWidget ? (Widget) m_borderWidget : (Widget) m_scrolledWindow); | |
af0bb3b1 | 2389 | XtVaSetValues(drawingArea, XmNresizePolicy, XmRESIZE_ANY, NULL); |
34636400 | 2390 | |
2d120f83 JS |
2391 | int xx = x; int yy = y; |
2392 | AdjustForParentClientOrigin(xx, yy, sizeFlags); | |
34636400 | 2393 | |
2d120f83 | 2394 | if (!useOldPos) |
50414e24 | 2395 | { |
2d120f83 JS |
2396 | if (x > -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) |
2397 | { | |
2398 | XtVaSetValues (m_borderWidget ? (Widget) m_borderWidget : (Widget) m_scrolledWindow, | |
2399 | XmNx, xx, NULL); | |
2400 | } | |
34636400 | 2401 | |
2d120f83 JS |
2402 | if (y > -1 || (sizeFlags & wxSIZE_ALLOW_MINUS_ONE)) |
2403 | { | |
2404 | XtVaSetValues (m_borderWidget ? (Widget) m_borderWidget : (Widget) m_scrolledWindow, | |
2405 | XmNy, yy, NULL); | |
2406 | } | |
50414e24 | 2407 | } |
34636400 | 2408 | |
2d120f83 | 2409 | if (!useOldSize) |
50414e24 | 2410 | { |
34636400 | 2411 | |
2d120f83 JS |
2412 | if (w > -1) |
2413 | { | |
2414 | if (m_borderWidget) | |
2415 | { | |
2416 | XtVaSetValues ((Widget) m_borderWidget, XmNwidth, w, NULL); | |
2417 | short thick, margin; | |
2418 | XtVaGetValues ((Widget) m_borderWidget, | |
2419 | XmNshadowThickness, &thick, | |
2420 | XmNmarginWidth, &margin, | |
2421 | NULL); | |
2422 | w -= 2 * (thick + margin); | |
2423 | } | |
34636400 | 2424 | |
2d120f83 | 2425 | XtVaSetValues ((Widget) m_scrolledWindow, XmNwidth, w, NULL); |
34636400 | 2426 | |
2d120f83 JS |
2427 | Dimension spacing; |
2428 | Widget sbar; | |
2429 | XtVaGetValues ((Widget) m_scrolledWindow, | |
2430 | XmNspacing, &spacing, | |
2431 | XmNverticalScrollBar, &sbar, | |
2432 | NULL); | |
2433 | Dimension wsbar; | |
2434 | if (sbar) | |
2435 | XtVaGetValues (sbar, XmNwidth, &wsbar, NULL); | |
2436 | else | |
2437 | wsbar = 0; | |
34636400 | 2438 | |
2d120f83 | 2439 | w -= (spacing + wsbar); |
34636400 | 2440 | |
af0bb3b1 VZ |
2441 | #if 0 |
2442 | XtVaSetValues(drawingArea, XmNwidth, w, NULL); | |
2443 | #endif // 0 | |
2d120f83 JS |
2444 | } |
2445 | if (h > -1) | |
2446 | { | |
2447 | if (m_borderWidget) | |
2448 | { | |
2449 | XtVaSetValues ((Widget) m_borderWidget, XmNheight, h, NULL); | |
2450 | short thick, margin; | |
2451 | XtVaGetValues ((Widget) m_borderWidget, | |
2452 | XmNshadowThickness, &thick, | |
2453 | XmNmarginHeight, &margin, | |
2454 | NULL); | |
2455 | h -= 2 * (thick + margin); | |
2456 | } | |
34636400 | 2457 | |
2d120f83 | 2458 | XtVaSetValues ((Widget) m_scrolledWindow, XmNheight, h, NULL); |
34636400 | 2459 | |
2d120f83 JS |
2460 | Dimension spacing; |
2461 | Widget sbar; | |
2462 | XtVaGetValues ((Widget) m_scrolledWindow, | |
2463 | XmNspacing, &spacing, | |
2464 | XmNhorizontalScrollBar, &sbar, | |
2465 | NULL); | |
2466 | Dimension wsbar; | |
2467 | if (sbar) | |
2468 | XtVaGetValues (sbar, XmNheight, &wsbar, NULL); | |
2469 | else | |
2470 | wsbar = 0; | |
34636400 | 2471 | |
2d120f83 | 2472 | h -= (spacing + wsbar); |
34636400 | 2473 | |
af0bb3b1 VZ |
2474 | #if 0 |
2475 | XtVaSetValues(drawingArea, XmNheight, h, NULL); | |
2476 | #endif // 0 | |
2d120f83 | 2477 | } |
50414e24 | 2478 | } |
34636400 | 2479 | |
2d120f83 JS |
2480 | if (managed) |
2481 | XtManageChild (m_borderWidget ? (Widget) m_borderWidget : (Widget) m_scrolledWindow); | |
af0bb3b1 | 2482 | XtVaSetValues(drawingArea, XmNresizePolicy, XmRESIZE_NONE, NULL); |
34636400 VZ |
2483 | |
2484 | #if 0 | |
2d120f83 JS |
2485 | int ww, hh; |
2486 | GetClientSize (&ww, &hh); | |
2487 | wxSizeEvent sizeEvent(wxSize(ww, hh), GetId()); | |
2488 | sizeEvent.SetEventObject(this); | |
34636400 | 2489 | |
af0bb3b1 | 2490 | GetEventHandler()->ProcessEvent(sizeEvent); |
34636400 | 2491 | #endif // 0 |
50414e24 JS |
2492 | } |
2493 | ||
2494 | void wxWindow::CanvasSetClientSize (int w, int h) | |
2495 | { | |
2d120f83 | 2496 | Widget drawingArea = (Widget) m_drawingArea; |
34636400 | 2497 | |
af0bb3b1 | 2498 | XtVaSetValues(drawingArea, XmNresizePolicy, XmRESIZE_ANY, NULL); |
34636400 | 2499 | |
2d120f83 | 2500 | if (w > -1) |
af0bb3b1 | 2501 | XtVaSetValues(drawingArea, XmNwidth, w, NULL); |
2d120f83 | 2502 | if (h > -1) |
af0bb3b1 | 2503 | XtVaSetValues(drawingArea, XmNheight, h, NULL); |
50414e24 | 2504 | |
34636400 VZ |
2505 | #if 0 |
2506 | // TODO: is this necessary? | |
2507 | allowRepainting = FALSE; | |
02e8b2f9 | 2508 | |
34636400 VZ |
2509 | XSync (XtDisplay (drawingArea), FALSE); |
2510 | XEvent event; | |
2511 | while (XtAppPending (wxTheApp->appContext)) | |
2512 | { | |
2513 | XFlush (XtDisplay (drawingArea)); | |
2514 | XtAppNextEvent (wxTheApp->appContext, &event); | |
2515 | XtDispatchEvent (&event); | |
02e8b2f9 | 2516 | } |
34636400 VZ |
2517 | #endif // 0 |
2518 | ||
af0bb3b1 | 2519 | XtVaSetValues(drawingArea, XmNresizePolicy, XmRESIZE_NONE, NULL); |
34636400 VZ |
2520 | |
2521 | #if 0 | |
af0bb3b1 VZ |
2522 | allowRepainting = TRUE; |
2523 | DoRefresh (); | |
34636400 | 2524 | |
af0bb3b1 VZ |
2525 | wxSizeEvent sizeEvent(wxSize(w, h), GetId()); |
2526 | sizeEvent.SetEventObject(this); | |
34636400 | 2527 | |
af0bb3b1 | 2528 | GetEventHandler()->ProcessEvent(sizeEvent); |
34636400 | 2529 | #endif // 0 |
02e8b2f9 JS |
2530 | } |
2531 | ||
34636400 | 2532 | void wxWindow::CanvasGetClientSize (int *w, int *h) const |
02e8b2f9 | 2533 | { |
34636400 VZ |
2534 | // Must return the same thing that was set via SetClientSize |
2535 | Dimension xx, yy; | |
2536 | XtVaGetValues ((Widget) m_drawingArea, XmNwidth, &xx, XmNheight, &yy, NULL); | |
2537 | *w = xx; | |
2538 | *h = yy; | |
02e8b2f9 JS |
2539 | } |
2540 | ||
34636400 | 2541 | void wxWindow::CanvasGetSize (int *w, int *h) const |
02e8b2f9 | 2542 | { |
34636400 VZ |
2543 | Dimension xx, yy; |
2544 | if ((Widget) m_borderWidget) | |
2545 | XtVaGetValues ((Widget) m_borderWidget, XmNwidth, &xx, XmNheight, &yy, NULL); | |
2546 | else if ((Widget) m_scrolledWindow) | |
2547 | XtVaGetValues ((Widget) m_scrolledWindow, XmNwidth, &xx, XmNheight, &yy, NULL); | |
2548 | else | |
2549 | XtVaGetValues ((Widget) m_drawingArea, XmNwidth, &xx, XmNheight, &yy, NULL); | |
2550 | ||
2551 | *w = xx; | |
2552 | *h = yy; | |
02e8b2f9 JS |
2553 | } |
2554 | ||
34636400 | 2555 | void wxWindow::CanvasGetPosition (int *x, int *y) const |
47bc1060 | 2556 | { |
34636400 VZ |
2557 | Position xx, yy; |
2558 | XtVaGetValues (m_borderWidget ? (Widget) m_borderWidget : (Widget) m_scrolledWindow, XmNx, &xx, XmNy, &yy, NULL); | |
2559 | ||
2560 | // We may be faking the client origin. | |
2561 | // So a window that's really at (0, 30) may appear | |
2562 | // (to wxWin apps) to be at (0, 0). | |
2563 | if (GetParent()) | |
47bc1060 | 2564 | { |
34636400 VZ |
2565 | wxPoint pt(GetParent()->GetClientAreaOrigin()); |
2566 | xx -= pt.x; | |
2567 | yy -= pt.y; | |
47bc1060 | 2568 | } |
34636400 VZ |
2569 | |
2570 | *x = xx; | |
2571 | *y = yy; | |
47bc1060 JS |
2572 | } |
2573 | ||
34636400 VZ |
2574 | // ---------------------------------------------------------------------------- |
2575 | // TranslateXXXEvent() functions | |
2576 | // ---------------------------------------------------------------------------- | |
2577 | ||
02e8b2f9 JS |
2578 | bool wxTranslateMouseEvent(wxMouseEvent& wxevent, wxWindow *win, Widget widget, XEvent *xevent) |
2579 | { | |
2d120f83 JS |
2580 | switch (xevent->xany.type) |
2581 | { | |
1e8abce5 MB |
2582 | case EnterNotify: // never received here - yes ? MB |
2583 | case LeaveNotify: // never received here - yes ? MB | |
2584 | case ButtonPress: | |
2585 | case ButtonRelease: | |
2586 | case MotionNotify: | |
02e8b2f9 | 2587 | { |
2d120f83 | 2588 | wxEventType eventType = wxEVT_NULL; |
34636400 | 2589 | |
1e8abce5 MB |
2590 | // FIXME: this is never true I think - MB |
2591 | // | |
2d120f83 JS |
2592 | if (xevent->xany.type == LeaveNotify) |
2593 | { | |
af0bb3b1 VZ |
2594 | win->SetButton1(FALSE); |
2595 | win->SetButton2(FALSE); | |
2596 | win->SetButton3(FALSE); | |
2d120f83 JS |
2597 | return FALSE; |
2598 | } | |
2599 | else if (xevent->xany.type == MotionNotify) | |
2600 | { | |
2601 | eventType = wxEVT_MOTION; | |
2602 | } | |
2603 | else if (xevent->xany.type == ButtonPress) | |
2604 | { | |
1e8abce5 MB |
2605 | wxevent.SetTimestamp(xevent->xbutton.time); |
2606 | int button = 0; | |
2d120f83 JS |
2607 | if (xevent->xbutton.button == Button1) |
2608 | { | |
2609 | eventType = wxEVT_LEFT_DOWN; | |
af0bb3b1 | 2610 | win->SetButton1(TRUE); |
1e8abce5 | 2611 | button = 1; |
2d120f83 JS |
2612 | } |
2613 | else if (xevent->xbutton.button == Button2) | |
2614 | { | |
2615 | eventType = wxEVT_MIDDLE_DOWN; | |
af0bb3b1 | 2616 | win->SetButton2(TRUE); |
1e8abce5 | 2617 | button = 2; |
2d120f83 JS |
2618 | } |
2619 | else if (xevent->xbutton.button == Button3) | |
2620 | { | |
2621 | eventType = wxEVT_RIGHT_DOWN; | |
af0bb3b1 | 2622 | win->SetButton3(TRUE); |
1e8abce5 MB |
2623 | button = 3; |
2624 | } | |
2625 | ||
2626 | // check for a double click | |
2627 | // | |
2628 | long dclickTime = XtGetMultiClickTime((Display*) wxGetDisplay()); | |
2629 | long ts = wxevent.GetTimestamp(); | |
2630 | ||
2631 | int buttonLast = win->GetLastClickedButton(); | |
2632 | long lastTS = win->GetLastClickTime(); | |
2633 | if ( buttonLast && buttonLast == button && (ts - lastTS) < dclickTime ) | |
2634 | { | |
2635 | // I have a dclick | |
2636 | win->SetLastClick(0, ts); | |
2637 | switch ( eventType ) | |
2638 | { | |
2639 | case wxEVT_LEFT_DOWN: | |
2640 | eventType = wxEVT_LEFT_DCLICK; | |
2641 | break; | |
2642 | case wxEVT_MIDDLE_DOWN: | |
2643 | eventType = wxEVT_MIDDLE_DCLICK; | |
2644 | break; | |
2645 | case wxEVT_RIGHT_DOWN: | |
2646 | eventType = wxEVT_RIGHT_DCLICK; | |
2647 | break; | |
2648 | ||
2649 | default : | |
2650 | break; | |
2651 | } | |
2652 | ||
2653 | } | |
2654 | else | |
2655 | { | |
2656 | // not fast enough or different button | |
2657 | win->SetLastClick(button, ts); | |
2d120f83 JS |
2658 | } |
2659 | } | |
2660 | else if (xevent->xany.type == ButtonRelease) | |
2661 | { | |
2662 | if (xevent->xbutton.button == Button1) | |
2663 | { | |
2664 | eventType = wxEVT_LEFT_UP; | |
af0bb3b1 | 2665 | win->SetButton1(FALSE); |
2d120f83 JS |
2666 | } |
2667 | else if (xevent->xbutton.button == Button2) | |
2668 | { | |
2669 | eventType = wxEVT_MIDDLE_UP; | |
af0bb3b1 | 2670 | win->SetButton2(FALSE); |
2d120f83 JS |
2671 | } |
2672 | else if (xevent->xbutton.button == Button3) | |
2673 | { | |
2674 | eventType = wxEVT_RIGHT_UP; | |
af0bb3b1 | 2675 | win->SetButton3(FALSE); |
2d120f83 JS |
2676 | } |
2677 | else return FALSE; | |
2678 | } | |
af0bb3b1 VZ |
2679 | else |
2680 | { | |
2681 | return FALSE; | |
2682 | } | |
34636400 | 2683 | |
2d120f83 | 2684 | wxevent.SetEventType(eventType); |
34636400 | 2685 | |
2d120f83 JS |
2686 | Position x1, y1; |
2687 | XtVaGetValues(widget, XmNx, &x1, XmNy, &y1, NULL); | |
34636400 | 2688 | |
2d120f83 JS |
2689 | int x2, y2; |
2690 | win->GetPosition(&x2, &y2); | |
34636400 | 2691 | |
2d120f83 JS |
2692 | // The button x/y must be translated to wxWindows |
2693 | // window space - the widget might be a label or button, | |
2694 | // within a form. | |
2695 | int dx = 0; | |
2696 | int dy = 0; | |
2697 | if (widget != (Widget)win->GetMainWidget()) | |
2698 | { | |
2699 | dx = x1; | |
2700 | dy = y1; | |
2701 | } | |
34636400 | 2702 | |
2d120f83 JS |
2703 | wxevent.m_x = xevent->xbutton.x + dx; |
2704 | wxevent.m_y = xevent->xbutton.y + dy; | |
34636400 | 2705 | |
2d120f83 | 2706 | wxevent.m_leftDown = ((eventType == wxEVT_LEFT_DOWN) |
34636400 | 2707 | || (event_left_is_down (xevent) |
2d120f83 JS |
2708 | && (eventType != wxEVT_LEFT_UP))); |
2709 | wxevent.m_middleDown = ((eventType == wxEVT_MIDDLE_DOWN) | |
34636400 | 2710 | || (event_middle_is_down (xevent) |
2d120f83 JS |
2711 | && (eventType != wxEVT_MIDDLE_UP))); |
2712 | wxevent.m_rightDown = ((eventType == wxEVT_RIGHT_DOWN) | |
34636400 | 2713 | || (event_right_is_down (xevent) |
2d120f83 | 2714 | && (eventType != wxEVT_RIGHT_UP))); |
34636400 | 2715 | |
2d120f83 JS |
2716 | wxevent.m_shiftDown = xevent->xbutton.state & ShiftMask; |
2717 | wxevent.m_controlDown = xevent->xbutton.state & ControlMask; | |
1e8abce5 MB |
2718 | wxevent.m_altDown = xevent->xbutton.state & Mod3Mask; |
2719 | wxevent.m_metaDown = xevent->xbutton.state & Mod1Mask; | |
2720 | ||
2721 | wxevent.SetId(win->GetId()); | |
2722 | wxevent.SetEventObject(win); | |
2723 | ||
2d120f83 JS |
2724 | return TRUE; |
2725 | } | |
02e8b2f9 | 2726 | } |
2d120f83 | 2727 | return FALSE; |
02e8b2f9 JS |
2728 | } |
2729 | ||
af111fc3 | 2730 | bool wxTranslateKeyEvent(wxKeyEvent& wxevent, wxWindow *win, Widget WXUNUSED(widget), XEvent *xevent) |
02e8b2f9 | 2731 | { |
2d120f83 JS |
2732 | switch (xevent->xany.type) |
2733 | { | |
02e8b2f9 | 2734 | case KeyPress: |
4a041f2f | 2735 | case KeyRelease: |
2d120f83 JS |
2736 | { |
2737 | char buf[20]; | |
34636400 | 2738 | |
2d120f83 | 2739 | KeySym keySym; |
34636400 VZ |
2740 | #if 0 |
2741 | XComposeStatus compose; | |
2742 | (void) XLookupString ((XKeyEvent *) xevent, buf, 20, &keySym, &compose); | |
2743 | #endif // 0 | |
2d120f83 JS |
2744 | (void) XLookupString ((XKeyEvent *) xevent, buf, 20, &keySym, NULL); |
2745 | int id = wxCharCodeXToWX (keySym); | |
34636400 | 2746 | |
2d120f83 JS |
2747 | if (xevent->xkey.state & ShiftMask) |
2748 | wxevent.m_shiftDown = TRUE; | |
2749 | if (xevent->xkey.state & ControlMask) | |
2750 | wxevent.m_controlDown = TRUE; | |
2751 | if (xevent->xkey.state & Mod3Mask) | |
2752 | wxevent.m_altDown = TRUE; | |
2753 | if (xevent->xkey.state & Mod1Mask) | |
2754 | wxevent.m_metaDown = TRUE; | |
2755 | wxevent.SetEventObject(win); | |
2756 | wxevent.m_keyCode = id; | |
2757 | wxevent.SetTimestamp(xevent->xkey.time); | |
34636400 | 2758 | |
2d120f83 JS |
2759 | wxevent.m_x = xevent->xbutton.x; |
2760 | wxevent.m_y = xevent->xbutton.y; | |
34636400 | 2761 | |
2d120f83 JS |
2762 | if (id > -1) |
2763 | return TRUE; | |
2764 | else | |
2765 | return FALSE; | |
2766 | break; | |
2767 | } | |
02e8b2f9 | 2768 | default: |
2d120f83 JS |
2769 | break; |
2770 | } | |
2771 | return FALSE; | |
02e8b2f9 JS |
2772 | } |
2773 | ||
34636400 VZ |
2774 | // ---------------------------------------------------------------------------- |
2775 | // Colour stuff | |
2776 | // ---------------------------------------------------------------------------- | |
2777 | ||
02e8b2f9 | 2778 | #define YAllocColor XAllocColor |
0d57be45 JS |
2779 | XColor g_itemColors[5]; |
2780 | int wxComputeColours (Display *display, wxColour * back, wxColour * fore) | |
02e8b2f9 | 2781 | { |
2d120f83 JS |
2782 | int result; |
2783 | static XmColorProc colorProc; | |
34636400 | 2784 | |
2d120f83 | 2785 | result = wxNO_COLORS; |
34636400 | 2786 | |
2d120f83 | 2787 | if (back) |
02e8b2f9 | 2788 | { |
2d120f83 JS |
2789 | g_itemColors[0].red = (((long) back->Red ()) << 8); |
2790 | g_itemColors[0].green = (((long) back->Green ()) << 8); | |
2791 | g_itemColors[0].blue = (((long) back->Blue ()) << 8); | |
2792 | g_itemColors[0].flags = DoRed | DoGreen | DoBlue; | |
2793 | if (colorProc == (XmColorProc) NULL) | |
2794 | { | |
2795 | // Get a ptr to the actual function | |
2796 | colorProc = XmSetColorCalculation ((XmColorProc) NULL); | |
2797 | // And set it back to motif. | |
2798 | XmSetColorCalculation (colorProc); | |
2799 | } | |
2800 | (*colorProc) (&g_itemColors[wxBACK_INDEX], | |
2801 | &g_itemColors[wxFORE_INDEX], | |
2802 | &g_itemColors[wxSELE_INDEX], | |
2803 | &g_itemColors[wxTOPS_INDEX], | |
2804 | &g_itemColors[wxBOTS_INDEX]); | |
2805 | result = wxBACK_COLORS; | |
02e8b2f9 | 2806 | } |
2d120f83 | 2807 | if (fore) |
02e8b2f9 | 2808 | { |
2d120f83 JS |
2809 | g_itemColors[wxFORE_INDEX].red = (((long) fore->Red ()) << 8); |
2810 | g_itemColors[wxFORE_INDEX].green = (((long) fore->Green ()) << 8); | |
2811 | g_itemColors[wxFORE_INDEX].blue = (((long) fore->Blue ()) << 8); | |
2812 | g_itemColors[wxFORE_INDEX].flags = DoRed | DoGreen | DoBlue; | |
2813 | if (result == wxNO_COLORS) | |
2814 | result = wxFORE_COLORS; | |
02e8b2f9 | 2815 | } |
34636400 | 2816 | |
2d120f83 JS |
2817 | Display *dpy = display; |
2818 | Colormap cmap = (Colormap) wxTheApp->GetMainColormap((WXDisplay*) dpy); | |
34636400 | 2819 | |
2d120f83 | 2820 | if (back) |
02e8b2f9 | 2821 | { |
2d120f83 JS |
2822 | /* 5 Colours to allocate */ |
2823 | for (int i = 0; i < 5; i++) | |
2824 | if (!YAllocColor (dpy, cmap, &g_itemColors[i])) | |
2825 | result = wxNO_COLORS; | |
02e8b2f9 | 2826 | } |
2d120f83 | 2827 | else if (fore) |
02e8b2f9 | 2828 | { |
2d120f83 JS |
2829 | /* Only 1 colour to allocate */ |
2830 | if (!YAllocColor (dpy, cmap, &g_itemColors[wxFORE_INDEX])) | |
2831 | result = wxNO_COLORS; | |
02e8b2f9 | 2832 | } |
34636400 | 2833 | |
2d120f83 | 2834 | return (result); |
34636400 | 2835 | |
02e8b2f9 JS |
2836 | } |
2837 | ||
34636400 VZ |
2838 | // Changes the foreground and background colours to be derived from the current |
2839 | // background colour. To change the foreground colour, you must call | |
2840 | // SetForegroundColour explicitly. | |
0d57be45 | 2841 | void wxWindow::ChangeBackgroundColour() |
02e8b2f9 | 2842 | { |
34636400 VZ |
2843 | WXWidget mainWidget = GetMainWidget(); |
2844 | if ( mainWidget ) | |
2845 | DoChangeBackgroundColour(mainWidget, m_backgroundColour); | |
2846 | ||
b412f9be JS |
2847 | // This not necessary |
2848 | #if 0 | |
34636400 | 2849 | |
88150e60 | 2850 | if (m_scrolledWindow && (GetMainWidget() != m_scrolledWindow)) |
b412f9be | 2851 | { |
88150e60 | 2852 | DoChangeBackgroundColour(m_scrolledWindow, m_backgroundColour); |
b412f9be JS |
2853 | // Have to set the scrollbar colours back since |
2854 | // the scrolled window seemed to change them | |
34636400 VZ |
2855 | wxColour backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE); |
2856 | ||
b412f9be | 2857 | if (m_hScrollBar) |
2d120f83 | 2858 | DoChangeBackgroundColour(m_hScrollBar, backgroundColour); |
b412f9be | 2859 | if (m_vScrollBar) |
2d120f83 | 2860 | DoChangeBackgroundColour(m_vScrollBar, backgroundColour); |
b412f9be JS |
2861 | } |
2862 | #endif | |
0d57be45 | 2863 | } |
02e8b2f9 | 2864 | |
0d57be45 JS |
2865 | void wxWindow::ChangeForegroundColour() |
2866 | { | |
34636400 VZ |
2867 | WXWidget mainWidget = GetMainWidget(); |
2868 | if ( mainWidget ) | |
2869 | DoChangeForegroundColour(mainWidget, m_foregroundColour); | |
2870 | if ( m_scrolledWindow && mainWidget != m_scrolledWindow ) | |
88150e60 | 2871 | DoChangeForegroundColour(m_scrolledWindow, m_foregroundColour); |
0d57be45 | 2872 | } |
02e8b2f9 | 2873 | |
0d57be45 | 2874 | // Change a widget's foreground and background colours. |
0d57be45 JS |
2875 | void wxWindow::DoChangeForegroundColour(WXWidget widget, wxColour& foregroundColour) |
2876 | { | |
2d120f83 JS |
2877 | // When should we specify the foreground, if it's calculated |
2878 | // by wxComputeColours? | |
2879 | // Solution: say we start with the default (computed) foreground colour. | |
2880 | // If we call SetForegroundColour explicitly for a control or window, | |
2881 | // then the foreground is changed. | |
2882 | // Therefore SetBackgroundColour computes the foreground colour, and | |
2883 | // SetForegroundColour changes the foreground colour. The ordering is | |
2884 | // important. | |
34636400 VZ |
2885 | |
2886 | Widget w = (Widget)widget; | |
2887 | XtVaSetValues( | |
2888 | w, | |
2889 | XmNforeground, foregroundColour.AllocColour(XtDisplay(w)), | |
2890 | NULL | |
2891 | ); | |
0d57be45 JS |
2892 | } |
2893 | ||
2894 | void wxWindow::DoChangeBackgroundColour(WXWidget widget, wxColour& backgroundColour, bool changeArmColour) | |
2895 | { | |
2d120f83 JS |
2896 | wxComputeColours (XtDisplay((Widget) widget), & backgroundColour, |
2897 | (wxColour*) NULL); | |
34636400 | 2898 | |
0d57be45 | 2899 | XtVaSetValues ((Widget) widget, |
2d120f83 JS |
2900 | XmNbackground, g_itemColors[wxBACK_INDEX].pixel, |
2901 | XmNtopShadowColor, g_itemColors[wxTOPS_INDEX].pixel, | |
2902 | XmNbottomShadowColor, g_itemColors[wxBOTS_INDEX].pixel, | |
2903 | XmNforeground, g_itemColors[wxFORE_INDEX].pixel, | |
2904 | NULL); | |
34636400 | 2905 | |
2d120f83 JS |
2906 | if (changeArmColour) |
2907 | XtVaSetValues ((Widget) widget, | |
2908 | XmNarmColor, g_itemColors[wxSELE_INDEX].pixel, | |
2909 | NULL); | |
02e8b2f9 JS |
2910 | } |
2911 | ||
af0bb3b1 | 2912 | bool wxWindow::SetBackgroundColour(const wxColour& col) |
02e8b2f9 | 2913 | { |
af0bb3b1 VZ |
2914 | if ( !wxWindowBase::SetBackgroundColour(col) ) |
2915 | return FALSE; | |
2916 | ||
0d57be45 | 2917 | ChangeBackgroundColour(); |
af0bb3b1 VZ |
2918 | |
2919 | return TRUE; | |
0d57be45 JS |
2920 | } |
2921 | ||
af0bb3b1 | 2922 | bool wxWindow::SetForegroundColour(const wxColour& col) |
0d57be45 | 2923 | { |
af0bb3b1 VZ |
2924 | if ( !wxWindowBase::SetForegroundColour(col) ) |
2925 | return FALSE; | |
2926 | ||
0d57be45 | 2927 | ChangeForegroundColour(); |
af0bb3b1 VZ |
2928 | |
2929 | return TRUE; | |
0d57be45 JS |
2930 | } |
2931 | ||
4b5f3fe6 | 2932 | void wxWindow::ChangeFont(bool keepOriginalSize) |
0d57be45 JS |
2933 | { |
2934 | // Note that this causes the widget to be resized back | |
2935 | // to its original size! We therefore have to set the size | |
2936 | // back again. TODO: a better way in Motif? | |
0d57be45 | 2937 | Widget w = (Widget) GetLabelWidget(); // Usually the main widget |
af0bb3b1 | 2938 | if (w && m_font.Ok()) |
0d57be45 JS |
2939 | { |
2940 | int width, height, width1, height1; | |
2941 | GetSize(& width, & height); | |
34636400 | 2942 | |
2d120f83 | 2943 | // lesstif 0.87 hangs here |
34636400 | 2944 | #ifndef LESSTIF_VERSION |
0d57be45 | 2945 | XtVaSetValues (w, |
af0bb3b1 | 2946 | XmNfontList, (XmFontList) m_font.GetFontList(1.0, XtDisplay(w)), |
2d120f83 | 2947 | NULL); |
32c69f2c | 2948 | #endif |
34636400 | 2949 | |
0d57be45 | 2950 | GetSize(& width1, & height1); |
4b5f3fe6 | 2951 | if (keepOriginalSize && (width != width1 || height != height1)) |
0d57be45 JS |
2952 | { |
2953 | SetSize(-1, -1, width, height); | |
2954 | } | |
2955 | } | |
02e8b2f9 | 2956 | } |
0d57be45 | 2957 | |
34636400 VZ |
2958 | // ---------------------------------------------------------------------------- |
2959 | // global functions | |
2960 | // ---------------------------------------------------------------------------- | |
0d57be45 | 2961 | |
34636400 | 2962 | wxWindow *wxGetActiveWindow() |
1f112209 JS |
2963 | { |
2964 | // TODO | |
34636400 | 2965 | return NULL; |
1f112209 JS |
2966 | } |
2967 | ||
34636400 VZ |
2968 | // ---------------------------------------------------------------------------- |
2969 | // wxNoOptimize: switch off size optimization | |
2970 | // ---------------------------------------------------------------------------- | |
88150e60 | 2971 | |
af0bb3b1 | 2972 | int wxNoOptimize::ms_count = 0; |
311227c3 MB |
2973 | |
2974 | ||
2975 | ||
2976 |