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