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