1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
21 #pragma implementation "window.h"
25 #define XtDisplay XTDISPLAY
26 #define XtWindow XTWINDOW
27 #define XtScreen XTSCREEN
33 #include "wx/dcclient.h"
36 #include "wx/layout.h"
37 #include "wx/button.h"
38 #include "wx/settings.h"
40 #include "wx/scrolwin.h"
41 #include "wx/module.h"
42 #include "wx/menuitem.h"
44 #include "wx/evtloop.h"
47 #if wxUSE_DRAG_AND_DROP
51 // DoSetSizeIntr and DoMoveWindowIntr
53 // under Motif composite controls (such as wxCalendarCtrl or generic wxSpinCtrl
54 // did nott work and/or segfaulted because
55 // 1) wxWindow::Create calls SetSize,
56 // which results in a call to DoSetSize much earlier than in the other ports
57 // 2) if wxWindow::Create is called (wxControl::Create calls it)
58 // then DoSetSize is never called, causing layout problems in composite
62 // 1) don't call SetSize, DoSetSize, DoMoveWindow, DoGetPosition,
63 // DoSetPosition directly or indirectly from wxWindow::Create
64 // 2) call DoMoveWindow from DoSetSize, allowing controls to override it
67 #pragma message disable nosimpint
71 #include <Xm/DrawingA.h>
72 #include <Xm/ScrolledW.h>
73 #include <Xm/ScrollBar.h>
76 #include <Xm/RowColumn.h> // for XmMenuPosition
78 #pragma message enable nosimpint
81 #include "wx/motif/private.h"
85 // ----------------------------------------------------------------------------
87 // ----------------------------------------------------------------------------
89 static const int SCROLL_MARGIN
= 4;
91 // ----------------------------------------------------------------------------
92 // global variables for this module
93 // ----------------------------------------------------------------------------
95 extern wxHashTable
*wxWidgetHashTable
;
96 static wxWindow
* g_captureWindow
= NULL
;
99 // ----------------------------------------------------------------------------
101 // ----------------------------------------------------------------------------
103 static void wxCanvasRepaintProc(Widget
, XtPointer
, XmDrawingAreaCallbackStruct
* cbs
);
104 static void wxCanvasInputEvent(Widget drawingArea
, XtPointer data
, XmDrawingAreaCallbackStruct
* cbs
);
105 static void wxCanvasMotionEvent(Widget
, XButtonEvent
* event
);
106 static void wxCanvasEnterLeave(Widget drawingArea
, XtPointer clientData
, XCrossingEvent
* event
);
107 static void wxScrollBarCallback(Widget widget
, XtPointer clientData
,
108 XmScrollBarCallbackStruct
*cbs
);
109 static void wxPanelItemEventHandler(Widget wid
,
110 XtPointer client_data
,
112 Boolean
*continueToDispatch
);
117 // Helper function for 16-bit fonts
118 static int str16len(const char *s
)
122 while (s
[0] && s
[1]) {
132 // ----------------------------------------------------------------------------
134 // ----------------------------------------------------------------------------
136 #define event_left_is_down(x) ((x)->xbutton.state & Button1Mask)
137 #define event_middle_is_down(x) ((x)->xbutton.state & Button2Mask)
138 #define event_right_is_down(x) ((x)->xbutton.state & Button3Mask)
140 // ----------------------------------------------------------------------------
142 // ----------------------------------------------------------------------------
144 IMPLEMENT_DYNAMIC_CLASS(wxWindow
, wxWindowBase
)
146 BEGIN_EVENT_TABLE(wxWindow
, wxWindowBase
)
147 EVT_SYS_COLOUR_CHANGED(wxWindow::OnSysColourChanged
)
148 EVT_IDLE(wxWindow::OnIdle
)
151 // ============================================================================
153 // ============================================================================
155 // ----------------------------------------------------------------------------
157 // ----------------------------------------------------------------------------
159 void wxWindow::UnmanageAndDestroy(WXWidget widget
)
161 Widget w
= (Widget
)widget
;
169 bool wxWindow::MapOrUnmap(WXWidget widget
, bool domap
)
171 Widget w
= (Widget
)widget
;
175 // Rationale: a lot of common operations (including but not
176 // limited to moving, resizing and appending items to a listbox)
177 // unmamange the widget, do their work, then manage it again.
178 // This means that, for example adding an item to a listbox will show it,
179 // or that most controls are shown every time they are moved or resized!
180 XtSetMappedWhenManaged( w
, domap
);
182 // if the widget is not unmanaged, it still intercepts
183 // mouse events, even if it is not mapped (and hence invisible)
198 // ----------------------------------------------------------------------------
200 // ----------------------------------------------------------------------------
202 void wxWindow::Init()
204 // generic initializations first
208 m_needsRefresh
= TRUE
;
209 m_mainWidget
= (WXWidget
) 0;
211 m_winCaptured
= FALSE
;
214 m_isBeingDeleted
= FALSE
;
220 m_drawingArea
= (WXWidget
) 0;
225 m_backingPixmap
= (WXPixmap
) 0;
236 // real construction (Init() must have been called before!)
237 bool wxWindow::Create(wxWindow
*parent
, wxWindowID id
,
241 const wxString
& name
)
243 wxCHECK_MSG( parent
, FALSE
, "can't create wxWindow without parent" );
245 CreateBase(parent
, id
, pos
, size
, style
, wxDefaultValidator
, name
);
247 parent
->AddChild(this);
249 m_backgroundColour
= wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE
);
250 m_foregroundColour
= *wxBLACK
;
252 //// TODO: we should probably optimize by only creating a
253 //// a drawing area if we have one or more scrollbars (wxVSCROLL/wxHSCROLL).
254 //// But for now, let's simplify things by always creating the
255 //// drawing area, since otherwise the translations are different.
257 // New translations for getting mouse motion feedback
258 static const String translations
=
259 "<Btn1Motion>: wxCanvasMotionEvent() DrawingAreaInput() ManagerGadgetButtonMotion()\n\
260 <Btn2Motion>: wxCanvasMotionEvent() DrawingAreaInput() ManagerGadgetButtonMotion()\n\
261 <Btn3Motion>: wxCanvasMotionEvent() DrawingAreaInput() ManagerGadgetButtonMotion()\n\
262 <BtnMotion>: wxCanvasMotionEvent() DrawingAreaInput() ManagerGadgetButtonMotion()\n\
263 <Btn1Down>: DrawingAreaInput() ManagerGadgetArm()\n\
264 <Btn2Down>: DrawingAreaInput() ManagerGadgetArm()\n\
265 <Btn3Down>: DrawingAreaInput() ManagerGadgetArm()\n\
266 <Btn1Up>: DrawingAreaInput() ManagerGadgetActivate()\n\
267 <Btn2Up>: DrawingAreaInput() ManagerGadgetActivate()\n\
268 <Btn3Up>: DrawingAreaInput() ManagerGadgetActivate()\n\
269 <Motion>: wxCanvasMotionEvent() DrawingAreaInput()\n\
270 <EnterWindow>: wxCanvasMotionEvent() DrawingAreaInput()\n\
271 <LeaveWindow>: wxCanvasMotionEvent() DrawingAreaInput()\n\
272 <Key>: DrawingAreaInput()";
274 XtActionsRec actions
[1];
275 actions
[0].string
= "wxCanvasMotionEvent";
276 actions
[0].proc
= (XtActionProc
) wxCanvasMotionEvent
;
277 XtAppAddActions ((XtAppContext
) wxTheApp
->GetAppContext(), actions
, 1);
279 Widget parentWidget
= (Widget
) parent
->GetClientWidget();
280 m_borderWidget
= wxCreateBorderWidget( (WXWidget
)parentWidget
, style
);
282 m_scrolledWindow
= (WXWidget
)XtVaCreateManagedWidget
285 xmScrolledWindowWidgetClass
,
286 m_borderWidget
? (Widget
) m_borderWidget
288 XmNresizePolicy
, XmRESIZE_NONE
,
290 XmNscrollingPolicy
, XmAPPLICATION_DEFINED
,
291 //XmNscrollBarDisplayPolicy, XmAS_NEEDED,
295 XtTranslations ptr
= XtParseTranslationTable(translations
);
296 m_drawingArea
= (WXWidget
)XtVaCreateWidget
299 xmDrawingAreaWidgetClass
, (Widget
) m_scrolledWindow
,
300 XmNunitType
, XmPIXELS
,
301 // XmNresizePolicy, XmRESIZE_ANY,
302 XmNresizePolicy
, XmRESIZE_NONE
,
305 XmNtranslations
, ptr
,
308 XtFree((char *) ptr
);
311 if (GetWindowStyleFlag() & wxOVERRIDE_KEY_TRANSLATIONS
)
313 ptr
= XtParseTranslationTable ("<Key>: DrawingAreaInput()");
314 XtOverrideTranslations ((Widget
) m_drawingArea
, ptr
);
315 XtFree ((char *) ptr
);
319 wxAddWindowToTable((Widget
) m_drawingArea
, this);
320 wxAddWindowToTable((Widget
) m_scrolledWindow
, this);
322 // This order is very important in Motif 1.2.1
323 XtRealizeWidget ((Widget
) m_scrolledWindow
);
324 XtRealizeWidget ((Widget
) m_drawingArea
);
325 XtManageChild ((Widget
) m_drawingArea
);
327 ptr
= XtParseTranslationTable("<Configure>: resize()");
328 XtOverrideTranslations((Widget
) m_drawingArea
, ptr
);
329 XtFree ((char *) ptr
);
331 XtAddCallback ((Widget
) m_drawingArea
, XmNexposeCallback
, (XtCallbackProc
) wxCanvasRepaintProc
, (XtPointer
) this);
332 XtAddCallback ((Widget
) m_drawingArea
, XmNinputCallback
, (XtCallbackProc
) wxCanvasInputEvent
, (XtPointer
) this);
335 (Widget
)m_drawingArea
,
336 PointerMotionHintMask
| EnterWindowMask
|
337 LeaveWindowMask
| FocusChangeMask
,
339 (XtEventHandler
) wxCanvasEnterLeave
,
343 // Scrolled widget needs to have its colour changed or we get a little blue
344 // square where the scrollbars abutt
345 wxColour backgroundColour
= wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE
);
346 wxDoChangeBackgroundColour(m_scrolledWindow
, backgroundColour
, TRUE
);
347 wxDoChangeBackgroundColour(m_drawingArea
, backgroundColour
, TRUE
);
349 XmScrolledWindowSetAreas(
350 (Widget
)m_scrolledWindow
,
351 (Widget
) 0, (Widget
) 0,
352 (Widget
) m_drawingArea
);
354 // Without this, the cursor may not be restored properly (e.g. in splitter
356 SetCursor(*wxSTANDARD_CURSOR
);
357 SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
));
358 DoSetSizeIntr(pos
.x
, pos
.y
, size
.x
,size
.y
, wxSIZE_AUTO
, TRUE
);
363 wxWindow::~wxWindow()
365 if (g_captureWindow
== this)
366 g_captureWindow
= NULL
;
368 m_isBeingDeleted
= TRUE
;
370 // Motif-specific actions first
371 WXWidget wMain
= GetMainWidget();
374 // Removes event handlers
381 m_parent
->RemoveChild( this );
383 // If m_drawingArea, we're a fully-fledged window with drawing area,
384 // scrollbars etc. (what wxCanvas used to be)
387 // Destroy children before destroying self
391 XFreePixmap (XtDisplay ((Widget
) GetMainWidget()), (Pixmap
) m_backingPixmap
);
393 Widget w
= (Widget
) m_drawingArea
;
394 wxDeleteWindowFromTable(w
);
399 m_drawingArea
= (WXWidget
) 0;
402 // Only if we're _really_ a canvas (not a dialog box/panel)
403 if (m_scrolledWindow
)
405 wxDeleteWindowFromTable((Widget
) m_scrolledWindow
);
410 wxDeleteWindowFromTable((Widget
) m_hScrollBar
);
411 XtUnmanageChild((Widget
) m_hScrollBar
);
415 wxDeleteWindowFromTable((Widget
) m_vScrollBar
);
416 XtUnmanageChild((Widget
) m_vScrollBar
);
420 XtDestroyWidget((Widget
) m_hScrollBar
);
422 XtDestroyWidget((Widget
) m_vScrollBar
);
424 UnmanageAndDestroy(m_scrolledWindow
);
428 XtDestroyWidget ((Widget
) m_borderWidget
);
429 m_borderWidget
= (WXWidget
) 0;
432 else // Why wasn't this here before? JACS 8/3/2000
436 // Destroy the window
439 // If this line (XtDestroyWidget) causes a crash, you may comment it out.
440 // Child widgets will get destroyed automatically when a frame
441 // or dialog is destroyed, but before that you may get some memory
442 // leaks and potential layout problems if you delete and then add
445 // GRG, Feb/2000: commented this out when adding support for
446 // wxSCROLL[WIN]_THUMBRELEASE events. Also it was reported
447 // that this call crashed wxMotif under OS/2, so it seems
448 // that leaving it out is the right thing to do.
449 // SN, Feb/2000: newgrid/griddemo shows why it is needed :-(
450 XtDestroyWidget((Widget
) GetMainWidget());
451 SetMainWidget((WXWidget
) NULL
);
455 // ----------------------------------------------------------------------------
456 // scrollbar management
457 // ----------------------------------------------------------------------------
460 void wxWindow::CreateScrollbar(wxOrientation orientation
)
462 wxCHECK_RET( m_drawingArea
, "this window can't have scrollbars" );
464 XtVaSetValues((Widget
) m_scrolledWindow
, XmNresizePolicy
, XmRESIZE_NONE
, NULL
);
466 // Add scrollbars if required
467 if (orientation
== wxHORIZONTAL
)
469 Widget hScrollBar
= XtVaCreateManagedWidget ("hsb",
470 xmScrollBarWidgetClass
, (Widget
) m_scrolledWindow
,
471 XmNorientation
, XmHORIZONTAL
,
473 XtAddCallback (hScrollBar
, XmNvalueChangedCallback
, (XtCallbackProc
) wxScrollBarCallback
, (XtPointer
) XmHORIZONTAL
);
474 XtAddCallback (hScrollBar
, XmNdragCallback
, (XtCallbackProc
) wxScrollBarCallback
, (XtPointer
) XmHORIZONTAL
);
475 XtAddCallback (hScrollBar
, XmNincrementCallback
, (XtCallbackProc
) wxScrollBarCallback
, (XtPointer
) XmHORIZONTAL
);
476 XtAddCallback (hScrollBar
, XmNdecrementCallback
, (XtCallbackProc
) wxScrollBarCallback
, (XtPointer
) XmHORIZONTAL
);
477 XtAddCallback (hScrollBar
, XmNpageIncrementCallback
, (XtCallbackProc
) wxScrollBarCallback
, (XtPointer
) XmHORIZONTAL
);
478 XtAddCallback (hScrollBar
, XmNpageDecrementCallback
, (XtCallbackProc
) wxScrollBarCallback
, (XtPointer
) XmHORIZONTAL
);
479 XtAddCallback (hScrollBar
, XmNtoTopCallback
, (XtCallbackProc
) wxScrollBarCallback
, (XtPointer
) XmHORIZONTAL
);
480 XtAddCallback (hScrollBar
, XmNtoBottomCallback
, (XtCallbackProc
) wxScrollBarCallback
, (XtPointer
) XmHORIZONTAL
);
482 XtVaSetValues (hScrollBar
,
487 m_hScrollBar
= (WXWidget
) hScrollBar
;
489 wxColour backgroundColour
= wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE
);
490 wxDoChangeBackgroundColour(m_hScrollBar
, backgroundColour
, TRUE
);
492 XtRealizeWidget(hScrollBar
);
494 XtVaSetValues((Widget
) m_scrolledWindow
,
495 XmNhorizontalScrollBar
, (Widget
) m_hScrollBar
,
498 wxAddWindowToTable( hScrollBar
, this );
501 if (orientation
== wxVERTICAL
)
503 Widget vScrollBar
= XtVaCreateManagedWidget ("vsb",
504 xmScrollBarWidgetClass
, (Widget
) m_scrolledWindow
,
505 XmNorientation
, XmVERTICAL
,
507 XtAddCallback (vScrollBar
, XmNvalueChangedCallback
, (XtCallbackProc
) wxScrollBarCallback
, (XtPointer
) XmVERTICAL
);
508 XtAddCallback (vScrollBar
, XmNdragCallback
, (XtCallbackProc
) wxScrollBarCallback
, (XtPointer
) XmVERTICAL
);
509 XtAddCallback (vScrollBar
, XmNincrementCallback
, (XtCallbackProc
) wxScrollBarCallback
, (XtPointer
) XmVERTICAL
);
510 XtAddCallback (vScrollBar
, XmNdecrementCallback
, (XtCallbackProc
) wxScrollBarCallback
, (XtPointer
) XmVERTICAL
);
511 XtAddCallback (vScrollBar
, XmNpageIncrementCallback
, (XtCallbackProc
) wxScrollBarCallback
, (XtPointer
) XmVERTICAL
);
512 XtAddCallback (vScrollBar
, XmNpageDecrementCallback
, (XtCallbackProc
) wxScrollBarCallback
, (XtPointer
) XmVERTICAL
);
513 XtAddCallback (vScrollBar
, XmNtoTopCallback
, (XtCallbackProc
) wxScrollBarCallback
, (XtPointer
) XmVERTICAL
);
514 XtAddCallback (vScrollBar
, XmNtoBottomCallback
, (XtCallbackProc
) wxScrollBarCallback
, (XtPointer
) XmVERTICAL
);
516 XtVaSetValues (vScrollBar
,
521 m_vScrollBar
= (WXWidget
) vScrollBar
;
522 wxColour backgroundColour
= wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE
);
523 wxDoChangeBackgroundColour(m_vScrollBar
, backgroundColour
, TRUE
);
525 XtRealizeWidget(vScrollBar
);
527 XtVaSetValues((Widget
) m_scrolledWindow
,
528 XmNverticalScrollBar
, (Widget
) m_vScrollBar
,
531 wxAddWindowToTable( vScrollBar
, this );
534 XtVaSetValues((Widget
) m_scrolledWindow
, XmNresizePolicy
, XmRESIZE_ANY
, NULL
);
537 void wxWindow::DestroyScrollbar(wxOrientation orientation
)
539 wxCHECK_RET( m_drawingArea
, "this window can't have scrollbars" );
541 XtVaSetValues((Widget
) m_scrolledWindow
, XmNresizePolicy
, XmRESIZE_NONE
, NULL
);
542 // Add scrollbars if required
543 if (orientation
== wxHORIZONTAL
)
547 wxDeleteWindowFromTable((Widget
)m_hScrollBar
);
548 XtDestroyWidget((Widget
) m_hScrollBar
);
550 m_hScrollBar
= (WXWidget
) 0;
552 XtVaSetValues((Widget
) m_scrolledWindow
,
553 XmNhorizontalScrollBar
, (Widget
) 0,
558 if (orientation
== wxVERTICAL
)
562 wxDeleteWindowFromTable((Widget
)m_vScrollBar
);
563 XtDestroyWidget((Widget
) m_vScrollBar
);
565 m_vScrollBar
= (WXWidget
) 0;
567 XtVaSetValues((Widget
) m_scrolledWindow
,
568 XmNverticalScrollBar
, (Widget
) 0,
572 XtVaSetValues((Widget
) m_scrolledWindow
, XmNresizePolicy
, XmRESIZE_ANY
, NULL
);
575 // ---------------------------------------------------------------------------
577 // ---------------------------------------------------------------------------
579 void wxWindow::SetFocus()
581 Widget wMain
= (Widget
) GetMainWidget();
582 XmProcessTraversal(wMain
, XmTRAVERSE_CURRENT
);
583 XmProcessTraversal((Widget
) GetMainWidget(), XmTRAVERSE_CURRENT
);
586 // Get the window with the focus
587 wxWindow
*wxWindowBase::FindFocus()
590 // (1) Can there be multiple focussed widgets in an application?
591 // In which case we need to find the top-level window that's
593 // (2) The widget with the focus may not be in the widget table
594 // depending on which widgets I put in the table
595 wxWindow
*winFocus
= (wxWindow
*)NULL
;
596 for ( wxWindowList::Node
*node
= wxTopLevelWindows
.GetFirst();
598 node
= node
->GetNext() )
600 wxWindow
*win
= node
->GetData();
602 Widget w
= XmGetFocusWidget ((Widget
) win
->GetTopWidget());
604 if (w
!= (Widget
) NULL
)
606 winFocus
= wxGetWindowFromTable(w
);
615 bool wxWindow::Enable(bool enable
)
617 if ( !wxWindowBase::Enable(enable
) )
620 Widget wMain
= (Widget
)GetMainWidget();
623 XtSetSensitive(wMain
, enable
);
624 XmUpdateDisplay(wMain
);
630 bool wxWindow::Show(bool show
)
632 if ( !wxWindowBase::Show(show
) )
635 if (m_borderWidget
|| m_scrolledWindow
)
637 MapOrUnmap(m_borderWidget
? m_borderWidget
: m_scrolledWindow
, show
);
638 // MapOrUnmap(m_drawingArea, show);
642 if ( !MapOrUnmap(GetTopWidget(), show
) )
643 MapOrUnmap(GetMainWidget(), show
);
649 // Raise the window to the top of the Z order
650 void wxWindow::Raise()
652 Widget wTop
= (Widget
) GetTopWidget();
653 Window window
= XtWindow(wTop
);
654 XRaiseWindow(XtDisplay(wTop
), window
);
657 // Lower the window to the bottom of the Z order
658 void wxWindow::Lower()
660 Widget wTop
= (Widget
) GetTopWidget();
661 Window window
= XtWindow(wTop
);
662 XLowerWindow(XtDisplay(wTop
), window
);
665 void wxWindow::SetTitle(const wxString
& title
)
667 XtVaSetValues((Widget
)GetMainWidget(), XmNtitle
, title
.c_str(), NULL
);
670 wxString
wxWindow::GetTitle() const
673 XtVaGetValues((Widget
)GetMainWidget(), XmNtitle
, &title
, NULL
);
675 return wxString(title
);
678 void wxWindow::DoCaptureMouse()
680 g_captureWindow
= this;
684 Widget wMain
= (Widget
)GetMainWidget();
686 XtAddGrab(wMain
, TRUE
, FALSE
);
688 m_winCaptured
= TRUE
;
691 void wxWindow::DoReleaseMouse()
693 g_captureWindow
= NULL
;
694 if ( !m_winCaptured
)
697 Widget wMain
= (Widget
)GetMainWidget();
701 m_winCaptured
= FALSE
;
704 bool wxWindow::SetFont(const wxFont
& font
)
706 if ( !wxWindowBase::SetFont(font
) )
717 bool wxWindow::SetCursor(const wxCursor
& cursor
)
719 if ( !wxWindowBase::SetCursor(cursor
) )
725 // wxASSERT_MSG( m_cursor.Ok(),
726 // wxT("cursor must be valid after call to the base version"));
727 wxCursor
* cursor2
= NULL
;
729 cursor2
= & m_cursor
;
731 cursor2
= wxSTANDARD_CURSOR
;
733 WXDisplay
*dpy
= GetXDisplay();
734 WXCursor x_cursor
= cursor2
->GetXCursor(dpy
);
736 Widget w
= (Widget
) GetMainWidget();
737 Window win
= XtWindow(w
);
738 XDefineCursor((Display
*) dpy
, win
, (Cursor
) x_cursor
);
743 // Coordinates relative to the window
744 void wxWindow::WarpPointer (int x
, int y
)
746 Widget wClient
= (Widget
)GetClientWidget();
748 XWarpPointer(XtDisplay(wClient
), None
, XtWindow(wClient
), 0, 0, 0, 0, x
, y
);
751 // ---------------------------------------------------------------------------
753 // ---------------------------------------------------------------------------
755 int wxWindow::GetScrollPos(int orient
) const
757 if (orient
== wxHORIZONTAL
)
763 Widget scrollBar
= (Widget
) ((orient
== wxHORIZONTAL
) ? m_hScrollBar
: m_vScrollBar
);
767 XtVaGetValues(scrollBar
, XmNvalue
, &pos
, NULL
);
775 // This now returns the whole range, not just the number of positions that we
777 int wxWindow::GetScrollRange(int orient
) const
779 Widget scrollBar
= (Widget
)GetScrollbar((wxOrientation
)orient
);
780 wxCHECK_MSG( scrollBar
, 0, "no such scrollbar" );
784 XtVaGetValues(scrollBar
, XmNmaximum
, &range
, NULL
);
788 int wxWindow::GetScrollThumb(int orient
) const
790 Widget scrollBar
= (Widget
)GetScrollbar((wxOrientation
)orient
);
791 wxCHECK_MSG( scrollBar
, 0, "no such scrollbar" );
794 XtVaGetValues(scrollBar
, XmNsliderSize
, &thumb
, NULL
);
798 void wxWindow::SetScrollPos(int orient
, int pos
, bool WXUNUSED(refresh
))
800 Widget scrollBar
= (Widget
)GetScrollbar((wxOrientation
)orient
);
804 XtVaSetValues (scrollBar
, XmNvalue
, pos
, NULL
);
807 SetInternalScrollPos((wxOrientation
)orient
, pos
);
810 // New function that will replace some of the above.
811 void wxWindow::SetScrollbar(int orient
, int pos
, int thumbVisible
,
812 int range
, bool WXUNUSED(refresh
))
815 GetSize(& oldW
, & oldH
);
819 if (thumbVisible
== 0)
822 if (thumbVisible
> range
)
823 thumbVisible
= range
;
825 // Save the old state to see if it changed
826 WXWidget oldScrollBar
= GetScrollbar((wxOrientation
)orient
);
828 if (orient
== wxHORIZONTAL
)
830 if (thumbVisible
== range
)
833 DestroyScrollbar(wxHORIZONTAL
);
838 CreateScrollbar(wxHORIZONTAL
);
841 if (orient
== wxVERTICAL
)
843 if (thumbVisible
== range
)
846 DestroyScrollbar(wxVERTICAL
);
851 CreateScrollbar(wxVERTICAL
);
854 WXWidget newScrollBar
= GetScrollbar((wxOrientation
)orient
);
856 if (oldScrollBar
!= newScrollBar
)
858 // This is important! Without it, scrollbars misbehave badly.
859 XtUnrealizeWidget((Widget
) m_scrolledWindow
);
860 XmScrolledWindowSetAreas ((Widget
) m_scrolledWindow
, (Widget
) m_hScrollBar
, (Widget
) m_vScrollBar
, (Widget
) m_drawingArea
);
861 XtRealizeWidget((Widget
) m_scrolledWindow
);
862 XtManageChild((Widget
) m_scrolledWindow
);
867 XtVaSetValues((Widget
) newScrollBar
,
871 XmNsliderSize
, thumbVisible
,
875 SetInternalScrollPos((wxOrientation
)orient
, pos
);
878 GetSize(& newW
, & newH
);
880 // Adjusting scrollbars can resize the canvas accidentally
881 if (newW
!= oldW
|| newH
!= oldH
)
882 SetSize(-1, -1, oldW
, oldH
);
885 // Does a physical scroll
886 void wxWindow::ScrollWindow(int dx
, int dy
, const wxRect
*rect
)
891 // Use specified rectangle
892 x
= rect
->x
; y
= rect
->y
; w
= rect
->width
; h
= rect
->height
;
896 // Use whole client area
898 GetClientSize(& w
, & h
);
901 int x1
= (dx
>= 0) ? x
: x
- dx
;
902 int y1
= (dy
>= 0) ? y
: y
- dy
;
903 int w1
= w
- abs(dx
);
904 int h1
= h
- abs(dy
);
905 int x2
= (dx
>= 0) ? x
+ dx
: x
;
906 int y2
= (dy
>= 0) ? y
+ dy
: y
;
910 dc
.SetLogicalFunction (wxCOPY
);
912 Widget widget
= (Widget
) GetMainWidget();
913 Window window
= XtWindow(widget
);
914 Display
* display
= XtDisplay(widget
);
916 XCopyArea(display
, window
, window
, (GC
) dc
.GetGC(),
917 x1
, y1
, w1
, h1
, x2
, y2
);
919 dc
.SetAutoSetting(TRUE
);
920 wxBrush
brush(GetBackgroundColour(), wxSOLID
);
921 dc
.SetBrush(brush
); // FIXME: needed?
923 wxWindowList::Node
*cnode
= m_children
.GetFirst();
926 wxWindow
*child
= cnode
->GetData();
929 child
->GetSize( &sx
, &sy
);
930 wxPoint
pos( child
->GetPosition() );
931 child
->SetSize( pos
.x
+ dx
, pos
.y
+ dy
, sx
, sy
, wxSIZE_ALLOW_MINUS_ONE
);
932 cnode
= cnode
->GetNext();
935 // We'll add rectangles to the list of update rectangles according to which
936 // bits we've exposed.
941 wxRect
*rect
= new wxRect
;
947 XFillRectangle(display
, window
,
948 (GC
) dc
.GetGC(), rect
->x
, rect
->y
, rect
->width
, rect
->height
);
952 rect
->width
= rect
->width
;
953 rect
->height
= rect
->height
;
955 updateRects
.Append((wxObject
*) rect
);
959 wxRect
*rect
= new wxRect
;
961 rect
->x
= x
+ w
+ dx
;
966 XFillRectangle(display
, window
,
967 (GC
) dc
.GetGC(), rect
->x
, rect
->y
, rect
->width
,
972 rect
->width
= rect
->width
;
973 rect
->height
= rect
->height
;
975 updateRects
.Append((wxObject
*) rect
);
979 wxRect
*rect
= new wxRect
;
986 XFillRectangle(display
, window
,
987 (GC
) dc
.GetGC(), rect
->x
, rect
->y
, rect
->width
, rect
->height
);
991 rect
->width
= rect
->width
;
992 rect
->height
= rect
->height
;
994 updateRects
.Append((wxObject
*) rect
);
998 wxRect
*rect
= new wxRect
;
1001 rect
->y
= y
+ h
+ dy
;
1005 XFillRectangle(display
, window
,
1006 (GC
) dc
.GetGC(), rect
->x
, rect
->y
, rect
->width
, rect
->height
);
1010 rect
->width
= rect
->width
;
1011 rect
->height
= rect
->height
;
1013 updateRects
.Append((wxObject
*) rect
);
1015 dc
.SetBrush(wxNullBrush
);
1017 // Now send expose events
1019 wxList::Node
* node
= updateRects
.GetFirst();
1022 wxRect
* rect
= (wxRect
*) node
->GetData();
1025 event
.type
= Expose
;
1026 event
.display
= display
;
1027 event
.send_event
= True
;
1028 event
.window
= window
;
1032 event
.width
= rect
->width
;
1033 event
.height
= rect
->height
;
1037 XSendEvent(display
, window
, False
, ExposureMask
, (XEvent
*)&event
);
1039 node
= node
->GetNext();
1043 // Delete the update rects
1044 node
= updateRects
.GetFirst();
1047 wxRect
* rect
= (wxRect
*) node
->GetData();
1049 node
= node
->GetNext();
1052 XmUpdateDisplay((Widget
) GetMainWidget());
1055 // ---------------------------------------------------------------------------
1057 // ---------------------------------------------------------------------------
1059 #if wxUSE_DRAG_AND_DROP
1061 void wxWindow::SetDropTarget(wxDropTarget
* WXUNUSED(pDropTarget
))
1068 // Old style file-manager drag&drop
1069 void wxWindow::DragAcceptFiles(bool WXUNUSED(accept
))
1074 // ----------------------------------------------------------------------------
1076 // ----------------------------------------------------------------------------
1080 void wxWindow::DoSetToolTip(wxToolTip
* WXUNUSED(tooltip
))
1085 #endif // wxUSE_TOOLTIPS
1087 // ----------------------------------------------------------------------------
1089 // ----------------------------------------------------------------------------
1093 bool wxWindow::DoPopupMenu(wxMenu
*menu
, int x
, int y
)
1095 Widget widget
= (Widget
) GetMainWidget();
1097 /* The menuId field seems to be usused, so we'll use it to
1098 indicate whether a menu is popped up or not:
1099 0: Not currently created as a popup
1100 -1: Created as a popup, but not active
1104 if (menu
->GetParent() && (menu
->GetId() != -1))
1107 if (menu
->GetMainWidget())
1109 menu
->DestroyMenu(TRUE
);
1112 menu
->SetId(1); /* Mark as popped-up */
1113 menu
->CreateMenu(NULL
, widget
, menu
);
1114 menu
->SetInvokingWindow(this);
1118 // menu->SetParent(parent);
1119 // parent->children->Append(menu); // Store menu for later deletion
1121 Widget menuWidget
= (Widget
) menu
->GetMainWidget();
1129 if (this->IsKindOf(CLASSINFO(wxCanvas)))
1131 wxCanvas *canvas = (wxCanvas *) this;
1132 deviceX = canvas->GetDC ()->LogicalToDeviceX (x);
1133 deviceY = canvas->GetDC ()->LogicalToDeviceY (y);
1137 Display
*display
= XtDisplay (widget
);
1138 Window rootWindow
= RootWindowOfScreen (XtScreen((Widget
)widget
));
1139 Window thisWindow
= XtWindow (widget
);
1141 XTranslateCoordinates (display
, thisWindow
, rootWindow
, (int) deviceX
, (int) deviceY
,
1142 &rootX
, &rootY
, &childWindow
);
1144 XButtonPressedEvent event
;
1145 event
.type
= ButtonPress
;
1151 event
.x_root
= rootX
;
1152 event
.y_root
= rootY
;
1154 XmMenuPosition (menuWidget
, &event
);
1155 XtManageChild (menuWidget
);
1157 // The ID of a pop-up menu is 1 when active, and is set to 0 by the
1158 // idle-time destroy routine.
1159 // Waiting until this ID changes causes this function to block until
1160 // the menu has been dismissed and the widgets cleaned up.
1161 // In other words, once this routine returns, it is safe to delete
1163 // Ian Brown <ian.brown@printsoft.de>
1165 wxEventLoop evtLoop
;
1167 while (menu
->GetId() == 1)
1169 wxDoEventLoopIteration( evtLoop
);
1177 // ---------------------------------------------------------------------------
1178 // moving and resizing
1179 // ---------------------------------------------------------------------------
1181 bool wxWindow::PreResize()
1187 void wxWindow::DoGetSize(int *x
, int *y
) const
1189 Widget widget
= (Widget
)( !m_drawingArea
? GetTopWidget() :
1190 ( m_borderWidget
? m_borderWidget
:
1191 m_scrolledWindow
? m_scrolledWindow
:
1195 XtVaGetValues( widget
,
1203 void wxWindow::DoGetPosition(int *x
, int *y
) const
1205 Widget widget
= (Widget
)
1207 ( m_borderWidget
? m_borderWidget
: m_scrolledWindow
) :
1211 XtVaGetValues(widget
, XmNx
, &xx
, XmNy
, &yy
, NULL
);
1213 // We may be faking the client origin. So a window that's really at (0, 30)
1214 // may appear (to wxWin apps) to be at (0, 0).
1217 wxPoint
pt(GetParent()->GetClientAreaOrigin());
1226 void wxWindow::DoScreenToClient(int *x
, int *y
) const
1228 Widget widget
= (Widget
) GetClientWidget();
1229 Display
*display
= XtDisplay((Widget
) GetMainWidget());
1230 Window rootWindow
= RootWindowOfScreen(XtScreen(widget
));
1231 Window thisWindow
= XtWindow(widget
);
1236 XTranslateCoordinates(display
, rootWindow
, thisWindow
, xx
, yy
, x
, y
, &childWindow
);
1239 void wxWindow::DoClientToScreen(int *x
, int *y
) const
1241 Widget widget
= (Widget
) GetClientWidget();
1242 Display
*display
= XtDisplay(widget
);
1243 Window rootWindow
= RootWindowOfScreen(XtScreen(widget
));
1244 Window thisWindow
= XtWindow(widget
);
1249 XTranslateCoordinates(display
, thisWindow
, rootWindow
, xx
, yy
, x
, y
, &childWindow
);
1253 // Get size *available for subwindows* i.e. excluding menu bar etc.
1254 void wxWindow::DoGetClientSize(int *x
, int *y
) const
1256 Widget widget
= (Widget
) GetClientWidget();
1258 XtVaGetValues(widget
, XmNwidth
, &xx
, XmNheight
, &yy
, NULL
);
1259 if(x
) *x
= xx
; if(y
) *y
= yy
;
1262 void wxWindow::DoSetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
1264 DoSetSizeIntr(x
, y
, width
, height
, sizeFlags
, FALSE
);
1267 void wxWindow::DoSetSizeIntr(int x
, int y
, int width
, int height
,
1268 int sizeFlags
, bool fromCtor
)
1270 // A bit of optimization to help sort out the flickers.
1271 int oldX
= -1, oldY
= -1, oldW
= -1, oldH
= -1;
1274 GetSize(& oldW
, & oldH
);
1275 GetPosition(& oldX
, & oldY
);
1278 if ( !(sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
) )
1286 wxSize
size(-1, -1);
1289 if ( ( sizeFlags
& wxSIZE_AUTO_WIDTH
) && !fromCtor
)
1291 size
= DoGetBestSize();
1302 if( ( sizeFlags
& wxSIZE_AUTO_HEIGHT
) && !fromCtor
)
1304 if( size
.x
== -1 ) size
= DoGetBestSize();
1313 if ( x
!= oldX
|| y
!= oldY
|| width
!= oldW
|| height
!= oldH
1314 || !wxNoOptimize::CanOptimize() )
1320 if (x
> -1 || (sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
1323 if (y
> -1 || (sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
1327 flags
|= wxMOVE_WIDTH
;
1330 flags
|= wxMOVE_HEIGHT
;
1332 int xx
= x
; int yy
= y
;
1333 AdjustForParentClientOrigin(xx
, yy
, sizeFlags
);
1335 DoMoveWindow( xx
, yy
, width
, height
);
1337 DoMoveWindowIntr( xx
, yy
, width
, height
, flags
);
1342 Widget widget
= (Widget
) GetTopWidget();
1346 bool managed
= XtIsManaged( widget
);
1348 XtUnmanageChild(widget
);
1352 AdjustForParentClientOrigin(xx
, yy
, sizeFlags
);
1354 DoMoveWindow(xx
, yy
, width
, height
);
1357 XtManageChild(widget
);
1361 void wxWindow::DoSetClientSize(int width
, int height
)
1365 Widget drawingArea
= (Widget
) m_drawingArea
;
1367 XtVaSetValues(drawingArea
, XmNresizePolicy
, XmRESIZE_ANY
, NULL
);
1370 XtVaSetValues(drawingArea
, XmNwidth
, width
, NULL
);
1372 XtVaSetValues(drawingArea
, XmNheight
, height
, NULL
);
1374 XtVaSetValues(drawingArea
, XmNresizePolicy
, XmRESIZE_NONE
, NULL
);
1378 Widget widget
= (Widget
) GetTopWidget();
1381 XtVaSetValues(widget
, XmNwidth
, width
, NULL
);
1383 XtVaSetValues(widget
, XmNheight
, height
, NULL
);
1386 // For implementation purposes - sometimes decorations make the client area
1388 wxPoint
wxWindow::GetClientAreaOrigin() const
1390 return wxPoint(0, 0);
1393 void wxWindow::DoMoveWindowIntr(int xx
, int yy
, int w
, int h
,
1398 Widget drawingArea
= (Widget
) m_drawingArea
;
1399 Widget borderOrScrolled
= m_borderWidget
?
1400 (Widget
) m_borderWidget
:
1401 (Widget
) m_scrolledWindow
;
1403 bool managed
= XtIsManaged(borderOrScrolled
);
1405 XtUnmanageChild (borderOrScrolled
);
1406 XtVaSetValues(drawingArea
, XmNresizePolicy
, XmRESIZE_ANY
, NULL
);
1408 if (flags
& wxMOVE_X
)
1409 XtVaSetValues (borderOrScrolled
,
1412 if (flags
& wxMOVE_Y
)
1413 XtVaSetValues (borderOrScrolled
,
1417 if (flags
& wxMOVE_WIDTH
)
1421 XtVaSetValues ((Widget
) m_borderWidget
, XmNwidth
, w
, NULL
);
1422 short thick
, margin
;
1423 XtVaGetValues ((Widget
) m_borderWidget
,
1424 XmNshadowThickness
, &thick
,
1425 XmNmarginWidth
, &margin
,
1427 w
-= 2 * (thick
+ margin
);
1430 XtVaSetValues ((Widget
) m_scrolledWindow
, XmNwidth
, w
, NULL
);
1433 if (flags
& wxMOVE_HEIGHT
)
1437 XtVaSetValues ((Widget
) m_borderWidget
, XmNheight
, h
, NULL
);
1438 short thick
, margin
;
1439 XtVaGetValues ((Widget
) m_borderWidget
,
1440 XmNshadowThickness
, &thick
,
1441 XmNmarginHeight
, &margin
,
1443 h
-= 2 * (thick
+ margin
);
1446 XtVaSetValues ((Widget
) m_scrolledWindow
, XmNheight
, h
, NULL
);
1450 XtManageChild (borderOrScrolled
);
1451 XtVaSetValues(drawingArea
, XmNresizePolicy
, XmRESIZE_NONE
, NULL
);
1458 XtVaSetValues((Widget
)GetTopWidget(),
1467 void wxWindow::DoMoveWindow(int x
, int y
, int width
, int height
)
1469 DoMoveWindowIntr (x
, y
, width
, height
,
1470 wxMOVE_X
|wxMOVE_Y
|wxMOVE_WIDTH
|wxMOVE_HEIGHT
);
1473 // ---------------------------------------------------------------------------
1475 // ---------------------------------------------------------------------------
1477 int wxWindow::GetCharHeight() const
1479 wxCHECK_MSG( m_font
.Ok(), 0, "valid window font needed" );
1481 WXFontStructPtr pFontStruct
= m_font
.GetFontStruct(1.0, GetXDisplay());
1483 int direction
, ascent
, descent
;
1484 XCharStruct overall
;
1485 XTextExtents ((XFontStruct
*) pFontStruct
, "x", 1, &direction
, &ascent
,
1486 &descent
, &overall
);
1488 // return (overall.ascent + overall.descent);
1489 return (ascent
+ descent
);
1492 int wxWindow::GetCharWidth() const
1494 wxCHECK_MSG( m_font
.Ok(), 0, "valid window font needed" );
1496 WXFontStructPtr pFontStruct
= m_font
.GetFontStruct(1.0, GetXDisplay());
1498 int direction
, ascent
, descent
;
1499 XCharStruct overall
;
1500 XTextExtents ((XFontStruct
*) pFontStruct
, "x", 1, &direction
, &ascent
,
1501 &descent
, &overall
);
1503 return overall
.width
;
1506 void wxWindow::GetTextExtent(const wxString
& string
,
1508 int *descent
, int *externalLeading
,
1509 const wxFont
*theFont
) const
1511 wxFont
*fontToUse
= (wxFont
*)theFont
;
1513 fontToUse
= (wxFont
*) & m_font
;
1515 wxCHECK_RET( fontToUse
->Ok(), "valid window font needed" );
1517 WXFontStructPtr pFontStruct
= fontToUse
->GetFontStruct(1.0, GetXDisplay());
1519 int direction
, ascent
, descent2
;
1520 XCharStruct overall
;
1521 int slen
= string
.Len();
1525 XTextExtents16((XFontStruct
*) pFontStruct
, (XChar2b
*) (char*) (const char*) string
, slen
, &direction
,
1526 &ascent
, &descent2
, &overall
);
1529 XTextExtents((XFontStruct
*) pFontStruct
, string
, slen
,
1530 &direction
, &ascent
, &descent2
, &overall
);
1533 *x
= (overall
.width
);
1535 *y
= (ascent
+ descent2
);
1537 *descent
= descent2
;
1538 if (externalLeading
)
1539 *externalLeading
= 0;
1543 // ----------------------------------------------------------------------------
1545 // ----------------------------------------------------------------------------
1547 void wxWindow::Refresh(bool eraseBack
, const wxRect
*rect
)
1549 m_needsRefresh
= TRUE
;
1550 Display
*display
= XtDisplay((Widget
) GetMainWidget());
1551 Window thisWindow
= XtWindow((Widget
) GetMainWidget());
1553 XExposeEvent dummyEvent
;
1555 GetSize(&width
, &height
);
1557 dummyEvent
.type
= Expose
;
1558 dummyEvent
.display
= display
;
1559 dummyEvent
.send_event
= True
;
1560 dummyEvent
.window
= thisWindow
;
1563 dummyEvent
.x
= rect
->x
;
1564 dummyEvent
.y
= rect
->y
;
1565 dummyEvent
.width
= rect
->width
;
1566 dummyEvent
.height
= rect
->height
;
1572 dummyEvent
.width
= width
;
1573 dummyEvent
.height
= height
;
1575 dummyEvent
.count
= 0;
1579 wxClientDC
dc(this);
1580 wxBrush
backgroundBrush(GetBackgroundColour(), wxSOLID
);
1581 dc
.SetBackground(backgroundBrush
);
1588 XSendEvent(display
, thisWindow
, False
, ExposureMask
, (XEvent
*)&dummyEvent
);
1591 void wxWindow::Clear()
1593 wxClientDC
dc(this);
1594 wxBrush
brush(GetBackgroundColour(), wxSOLID
);
1595 dc
.SetBackground(brush
);
1599 void wxWindow::ClearUpdateRects()
1601 wxRectList::Node
* node
= m_updateRects
.GetFirst();
1604 wxRect
* rect
= node
->GetData();
1606 node
= node
->GetNext();
1609 m_updateRects
.Clear();
1612 void wxWindow::DoPaint()
1614 //TODO : make a temporary gc so we can do the XCopyArea below
1615 if (m_backingPixmap
&& !m_needsRefresh
)
1619 GC tempGC
= (GC
) dc
.GetBackingGC();
1621 Widget widget
= (Widget
) GetMainWidget();
1626 // We have to test whether it's a wxScrolledWindow (hack!) because
1627 // otherwise we don't know how many pixels have been scrolled. We might
1628 // solve this in the future by defining virtual wxWindow functions to get
1629 // the scroll position in pixels. Or, each kind of scrolled window has to
1630 // implement backing stores itself, using generic wxWindows code.
1631 wxScrolledWindow
* scrolledWindow
= wxDynamicCast(this, wxScrolledWindow
);
1632 if ( scrolledWindow
)
1635 scrolledWindow
->CalcScrolledPosition(0, 0, &x
, &y
);
1641 // TODO: This could be optimized further by only copying the areas in the
1642 // current update region.
1644 // Only blit the part visible in the client area. The backing pixmap
1645 // always starts at 0, 0 but we may be looking at only a portion of it.
1646 wxSize clientArea
= GetClientSize();
1647 int toBlitX
= m_pixmapWidth
- scrollPosX
;
1648 int toBlitY
= m_pixmapHeight
- scrollPosY
;
1650 // Copy whichever is samller, the amount of pixmap we have to copy,
1651 // or the size of the client area.
1652 toBlitX
= wxMin(toBlitX
, clientArea
.x
);
1653 toBlitY
= wxMin(toBlitY
, clientArea
.y
);
1655 // Make sure we're not negative
1656 toBlitX
= wxMax(0, toBlitX
);
1657 toBlitY
= wxMax(0, toBlitY
);
1662 (Pixmap
) m_backingPixmap
,
1665 scrollPosX
, scrollPosY
, // Start at the scroll position
1666 toBlitX
, toBlitY
, // How much of the pixmap to copy
1672 wxWindowDC
dc(this);
1673 // Set an erase event first
1674 wxEraseEvent
eraseEvent(GetId(), &dc
);
1675 eraseEvent
.SetEventObject(this);
1676 GetEventHandler()->ProcessEvent(eraseEvent
);
1678 wxPaintEvent
event(GetId());
1679 event
.SetEventObject(this);
1680 GetEventHandler()->ProcessEvent(event
);
1682 m_needsRefresh
= FALSE
;
1686 // ----------------------------------------------------------------------------
1688 // ----------------------------------------------------------------------------
1690 // Responds to colour changes: passes event on to children.
1691 void wxWindow::OnSysColourChanged(wxSysColourChangedEvent
& event
)
1693 wxWindowList::Node
*node
= GetChildren().GetFirst();
1696 // Only propagate to non-top-level windows
1697 wxWindow
*win
= node
->GetData();
1698 if ( win
->GetParent() )
1700 wxSysColourChangedEvent event2
;
1701 event
.m_eventObject
= win
;
1702 win
->GetEventHandler()->ProcessEvent(event2
);
1705 node
= node
->GetNext();
1709 void wxWindow::OnIdle(wxIdleEvent
& WXUNUSED(event
))
1711 // This calls the UI-update mechanism (querying windows for
1712 // menu/toolbar/control state information)
1716 // ----------------------------------------------------------------------------
1718 // ----------------------------------------------------------------------------
1720 bool wxWindow::ProcessAccelerator(wxKeyEvent
& event
)
1723 if (!m_acceleratorTable
.Ok())
1726 int count
= m_acceleratorTable
.GetCount();
1727 wxAcceleratorEntry
* entries
= m_acceleratorTable
.GetEntries();
1729 for (i
= 0; i
< count
; i
++)
1731 wxAcceleratorEntry
* entry
= & (entries
[i
]);
1732 if (entry
->MatchesEvent(event
))
1734 // Bingo, we have a match. Now find a control that matches the
1735 // entry command id.
1737 // Need to go up to the top of the window hierarchy, since it might
1738 // be e.g. a menu item
1739 wxWindow
* parent
= this;
1740 while ( parent
&& !parent
->IsTopLevel() )
1741 parent
= parent
->GetParent();
1746 wxFrame
* frame
= wxDynamicCast(parent
, wxFrame
);
1750 // Try for a menu command
1751 if (frame
->GetMenuBar())
1753 wxMenuItem
* item
= frame
->GetMenuBar()->FindItem(entry
->GetCommand());
1756 wxCommandEvent
commandEvent(wxEVT_COMMAND_MENU_SELECTED
, entry
->GetCommand());
1757 commandEvent
.SetEventObject(frame
);
1759 // If ProcessEvent returns TRUE (it was handled), then
1760 // the calling code will skip the event handling.
1761 return frame
->GetEventHandler()->ProcessEvent(commandEvent
);
1767 // Find a child matching the command id
1768 wxWindow
* child
= parent
->FindWindow(entry
->GetCommand());
1774 // Now we process those kinds of windows that we can.
1775 // For now, only buttons.
1776 if ( wxDynamicCast(child
, wxButton
) )
1778 wxCommandEvent
commandEvent (wxEVT_COMMAND_BUTTON_CLICKED
, child
->GetId());
1779 commandEvent
.SetEventObject(child
);
1780 return child
->GetEventHandler()->ProcessEvent(commandEvent
);
1788 // We didn't match the key event against an accelerator.
1792 // ============================================================================
1793 // Motif-specific stuff from here on
1794 // ============================================================================
1796 // ----------------------------------------------------------------------------
1797 // function which maintain the global hash table mapping Widgets to wxWindows
1798 // ----------------------------------------------------------------------------
1800 bool wxAddWindowToTable(Widget w
, wxWindow
*win
)
1802 wxWindow
*oldItem
= NULL
;
1803 if ((oldItem
= (wxWindow
*)wxWidgetHashTable
->Get ((long) w
)))
1805 wxLogDebug("Widget table clash: new widget is %ld, %s",
1806 (long)w
, win
->GetClassInfo()->GetClassName());
1810 wxWidgetHashTable
->Put((long) w
, win
);
1812 wxLogTrace("widget", "Widget 0x%p <-> window %p (%s)",
1813 (WXWidget
)w
, win
, win
->GetClassInfo()->GetClassName());
1818 wxWindow
*wxGetWindowFromTable(Widget w
)
1820 return (wxWindow
*)wxWidgetHashTable
->Get((long) w
);
1823 void wxDeleteWindowFromTable(Widget w
)
1825 wxLogTrace("widget", "Widget 0x%p", (WXWidget
)w
);
1827 wxWidgetHashTable
->Delete((long)w
);
1830 // ----------------------------------------------------------------------------
1831 // add/remove window from the table
1832 // ----------------------------------------------------------------------------
1834 // Add to hash table, add event handler
1835 bool wxWindow::AttachWidget (wxWindow
* WXUNUSED(parent
), WXWidget mainWidget
,
1836 WXWidget formWidget
, int x
, int y
, int width
, int height
)
1838 wxAddWindowToTable((Widget
) mainWidget
, this);
1839 XtAddEventHandler( (Widget
) mainWidget
,
1840 ButtonPressMask
| ButtonReleaseMask
1841 | PointerMotionMask
,
1843 wxPanelItemEventHandler
,
1849 XtOverrideTranslations ((Widget
) mainWidget
,
1850 ptr
= XtParseTranslationTable ("<Configure>: resize()"));
1851 XtFree ((char *) ptr
);
1854 // Some widgets have a parent form widget, e.g. wxRadioBox
1857 if (!wxAddWindowToTable((Widget
) formWidget
, this))
1861 XtOverrideTranslations ((Widget
) formWidget
,
1862 ptr
= XtParseTranslationTable ("<Configure>: resize()"));
1863 XtFree ((char *) ptr
);
1870 SetSize (x
, y
, width
, height
);
1875 // Remove event handler, remove from hash table
1876 bool wxWindow::DetachWidget(WXWidget widget
)
1878 XtRemoveEventHandler( (Widget
) widget
,
1879 ButtonPressMask
| ButtonReleaseMask
1880 | PointerMotionMask
,
1882 wxPanelItemEventHandler
,
1885 wxDeleteWindowFromTable((Widget
) widget
);
1889 // ----------------------------------------------------------------------------
1890 // Motif-specific accessors
1891 // ----------------------------------------------------------------------------
1893 // Get the underlying X window
1894 WXWindow
wxWindow::GetXWindow() const
1896 Widget wMain
= (Widget
)GetMainWidget();
1898 return (WXWindow
) XtWindow(wMain
);
1900 return (WXWindow
) 0;
1903 // Get the underlying X display
1904 WXDisplay
*wxWindow::GetXDisplay() const
1906 Widget wMain
= (Widget
)GetMainWidget();
1908 return (WXDisplay
*) XtDisplay(wMain
);
1910 return (WXDisplay
*) NULL
;
1913 WXWidget
wxWindow::GetMainWidget() const
1916 return m_drawingArea
;
1918 return m_mainWidget
;
1921 WXWidget
wxWindow::GetClientWidget() const
1923 if (m_drawingArea
!= (WXWidget
) 0)
1924 return m_drawingArea
;
1926 return GetMainWidget();
1929 WXWidget
wxWindow::GetTopWidget() const
1931 return GetMainWidget();
1934 WXWidget
wxWindow::GetLabelWidget() const
1936 return GetMainWidget();
1939 // ----------------------------------------------------------------------------
1941 // ----------------------------------------------------------------------------
1943 // All widgets should have this as their resize proc.
1944 // OnSize sent to wxWindow via client data.
1945 void wxWidgetResizeProc(Widget w
, XConfigureEvent
*WXUNUSED(event
),
1946 String
WXUNUSED(args
)[], int *WXUNUSED(num_args
))
1948 wxWindow
*win
= wxGetWindowFromTable(w
);
1952 if (win
->PreResize())
1955 win
->GetSize(&width
, &height
);
1956 wxSizeEvent
sizeEvent(wxSize(width
, height
), win
->GetId());
1957 sizeEvent
.SetEventObject(win
);
1958 win
->GetEventHandler()->ProcessEvent(sizeEvent
);
1962 static void wxCanvasRepaintProc(Widget drawingArea
,
1963 XtPointer clientData
,
1964 XmDrawingAreaCallbackStruct
* cbs
)
1966 if (!wxGetWindowFromTable(drawingArea
))
1969 XEvent
* event
= cbs
->event
;
1970 wxWindow
* win
= (wxWindow
*) clientData
;
1972 switch (event
->type
)
1976 win
->AddUpdateRect(event
->xexpose
.x
, event
->xexpose
.y
,
1977 event
->xexpose
.width
, event
->xexpose
.height
);
1979 if (event
-> xexpose
.count
== 0)
1982 win
->ClearUpdateRects();
1989 // Unable to deal with Enter/Leave without a separate EventHandler (Motif 1.1.4)
1990 static void wxCanvasEnterLeave(Widget drawingArea
,
1991 XtPointer
WXUNUSED(clientData
),
1992 XCrossingEvent
* event
)
1994 XmDrawingAreaCallbackStruct cbs
;
1997 ((XCrossingEvent
&) ev
) = *event
;
1999 cbs
.reason
= XmCR_INPUT
;
2002 wxCanvasInputEvent(drawingArea
, (XtPointer
) NULL
, &cbs
);
2005 // Fix to make it work under Motif 1.0 (!)
2006 static void wxCanvasMotionEvent (Widget
WXUNUSED(drawingArea
),
2007 XButtonEvent
*WXUNUSED(event
))
2009 #if XmVersion <= 1000
2010 XmDrawingAreaCallbackStruct cbs
;
2013 ev
= *((XEvent
*) event
);
2014 cbs
.reason
= XmCR_INPUT
;
2017 wxCanvasInputEvent (drawingArea
, (XtPointer
) NULL
, &cbs
);
2018 #endif // XmVersion <= 1000
2021 static void wxCanvasInputEvent(Widget drawingArea
,
2022 XtPointer
WXUNUSED(data
),
2023 XmDrawingAreaCallbackStruct
* cbs
)
2025 wxWindow
*canvas
= wxGetWindowFromTable(drawingArea
);
2031 if (cbs
->reason
!= XmCR_INPUT
)
2034 local_event
= *(cbs
->event
); // We must keep a copy!
2036 switch (local_event
.xany
.type
)
2044 wxMouseEvent wxevent
;
2045 if(wxTranslateMouseEvent(wxevent
, canvas
, drawingArea
, &local_event
))
2047 canvas
->GetEventHandler()->ProcessEvent(wxevent
);
2053 wxKeyEvent
event (wxEVT_CHAR
);
2054 if (wxTranslateKeyEvent (event
, canvas
, (Widget
) 0, &local_event
))
2056 // Implement wxFrame::OnCharHook by checking ancestor.
2057 wxWindow
*parent
= canvas
;
2058 while (parent
&& !parent
->IsTopLevel())
2059 parent
= parent
->GetParent();
2063 event
.SetEventType(wxEVT_CHAR_HOOK
);
2064 if (parent
->GetEventHandler()->ProcessEvent(event
))
2068 // For simplicity, OnKeyDown is the same as OnChar
2069 // TODO: filter modifier key presses from OnChar
2070 event
.SetEventType(wxEVT_KEY_DOWN
);
2072 // Only process OnChar if OnKeyDown didn't swallow it
2073 if (!canvas
->GetEventHandler()->ProcessEvent (event
))
2075 event
.SetEventType(wxEVT_CHAR
);
2076 canvas
->GetEventHandler()->ProcessEvent (event
);
2083 wxKeyEvent
event (wxEVT_KEY_UP
);
2084 if (wxTranslateKeyEvent (event
, canvas
, (Widget
) 0, &local_event
))
2086 canvas
->GetEventHandler()->ProcessEvent (event
);
2092 if (local_event
.xfocus
.detail
!= NotifyPointer
)
2094 wxFocusEvent
event(wxEVT_SET_FOCUS
, canvas
->GetId());
2095 event
.SetEventObject(canvas
);
2096 canvas
->GetEventHandler()->ProcessEvent(event
);
2102 if (local_event
.xfocus
.detail
!= NotifyPointer
)
2104 wxFocusEvent
event(wxEVT_KILL_FOCUS
, canvas
->GetId());
2105 event
.SetEventObject(canvas
);
2106 canvas
->GetEventHandler()->ProcessEvent(event
);
2115 static void wxPanelItemEventHandler(Widget wid
,
2116 XtPointer
WXUNUSED(client_data
),
2118 Boolean
*continueToDispatch
)
2120 // Widget can be a label or the actual widget.
2122 wxWindow
*window
= wxGetWindowFromTable(wid
);
2125 wxMouseEvent
wxevent(0);
2126 if (wxTranslateMouseEvent(wxevent
, window
, wid
, event
))
2128 window
->GetEventHandler()->ProcessEvent(wxevent
);
2132 // TODO: probably the key to allowing default behaviour to happen. Say we
2133 // set a m_doDefault flag to FALSE at the start of this function. Then in
2134 // e.g. wxWindow::OnMouseEvent we can call Default() which sets this flag to
2135 // TRUE, indicating that default processing can happen. Thus, behaviour can
2136 // appear to be overridden just by adding an event handler and not calling
2137 // wxWindow::OnWhatever. ALSO, maybe we can use this instead of the current
2138 // way of handling drawing area events, to simplify things.
2139 *continueToDispatch
= True
;
2142 static void wxScrollBarCallback(Widget scrollbar
,
2143 XtPointer clientData
,
2144 XmScrollBarCallbackStruct
*cbs
)
2146 wxWindow
*win
= wxGetWindowFromTable(scrollbar
);
2147 int orientation
= (int) clientData
;
2149 wxEventType eventType
= wxEVT_NULL
;
2150 switch (cbs
->reason
)
2152 case XmCR_INCREMENT
:
2154 eventType
= wxEVT_SCROLLWIN_LINEDOWN
;
2157 case XmCR_DECREMENT
:
2159 eventType
= wxEVT_SCROLLWIN_LINEUP
;
2164 eventType
= wxEVT_SCROLLWIN_THUMBTRACK
;
2167 case XmCR_VALUE_CHANGED
:
2169 eventType
= wxEVT_SCROLLWIN_THUMBRELEASE
;
2172 case XmCR_PAGE_INCREMENT
:
2174 eventType
= wxEVT_SCROLLWIN_PAGEDOWN
;
2177 case XmCR_PAGE_DECREMENT
:
2179 eventType
= wxEVT_SCROLLWIN_PAGEUP
;
2184 eventType
= wxEVT_SCROLLWIN_TOP
;
2187 case XmCR_TO_BOTTOM
:
2189 eventType
= wxEVT_SCROLLWIN_BOTTOM
;
2194 // Should never get here
2195 wxFAIL_MSG("Unknown scroll event.");
2200 wxScrollWinEvent
event(eventType
,
2202 ((orientation
== XmHORIZONTAL
) ?
2203 wxHORIZONTAL
: wxVERTICAL
));
2204 event
.SetEventObject( win
);
2205 win
->GetEventHandler()->ProcessEvent(event
);
2208 // For repainting arbitrary windows
2209 void wxUniversalRepaintProc(Widget w
, XtPointer
WXUNUSED(c_data
), XEvent
*event
, char *)
2214 wxWindow
* win
= wxGetWindowFromTable(w
);
2218 switch(event
-> type
)
2222 window
= (Window
) win
-> GetXWindow();
2223 display
= (Display
*) win
-> GetXDisplay();
2225 if (event
-> xexpose
.count
== 0)
2229 win
->ClearUpdateRects();
2233 win
->AddUpdateRect(event
->xexpose
.x
, event
->xexpose
.y
,
2234 event
->xexpose
.width
, event
->xexpose
.height
);
2242 // ----------------------------------------------------------------------------
2243 // TranslateXXXEvent() functions
2244 // ----------------------------------------------------------------------------
2246 bool wxTranslateMouseEvent(wxMouseEvent
& wxevent
, wxWindow
*win
,
2247 Widget widget
, XEvent
*xevent
)
2249 switch (xevent
->xany
.type
)
2254 fprintf(stderr
, "Widget 0x%p <-> window %p (%s), %s\n",
2255 (WXWidget
)widget
, win
, win
->GetClassInfo()->GetClassName(),
2256 (xevent
->xany
.type
== EnterNotify
? "ENTER" : "LEAVE"));
2262 wxEventType eventType
= wxEVT_NULL
;
2264 if (xevent
->xany
.type
== LeaveNotify
)
2266 eventType
= wxEVT_LEAVE_WINDOW
;
2268 if (xevent
->xany
.type
== EnterNotify
)
2270 eventType
= wxEVT_ENTER_WINDOW
;
2272 else if (xevent
->xany
.type
== MotionNotify
)
2274 eventType
= wxEVT_MOTION
;
2276 else if (xevent
->xany
.type
== ButtonPress
)
2278 wxevent
.SetTimestamp(xevent
->xbutton
.time
);
2280 if (xevent
->xbutton
.button
== Button1
)
2282 eventType
= wxEVT_LEFT_DOWN
;
2285 else if (xevent
->xbutton
.button
== Button2
)
2287 eventType
= wxEVT_MIDDLE_DOWN
;
2290 else if (xevent
->xbutton
.button
== Button3
)
2292 eventType
= wxEVT_RIGHT_DOWN
;
2296 // check for a double click
2298 long dclickTime
= XtGetMultiClickTime(xevent
->xany
.display
);
2299 long ts
= wxevent
.GetTimestamp();
2301 int buttonLast
= win
->GetLastClickedButton();
2302 long lastTS
= win
->GetLastClickTime();
2303 if ( buttonLast
&& buttonLast
== button
&&
2304 (ts
- lastTS
) < dclickTime
)
2307 win
->SetLastClick(0, ts
);
2308 if ( eventType
== wxEVT_LEFT_DOWN
)
2309 eventType
= wxEVT_LEFT_DCLICK
;
2310 else if ( eventType
== wxEVT_MIDDLE_DOWN
)
2311 eventType
= wxEVT_MIDDLE_DCLICK
;
2312 else if ( eventType
== wxEVT_RIGHT_DOWN
)
2313 eventType
= wxEVT_RIGHT_DCLICK
;
2317 // not fast enough or different button
2318 win
->SetLastClick(button
, ts
);
2321 else if (xevent
->xany
.type
== ButtonRelease
)
2323 if (xevent
->xbutton
.button
== Button1
)
2325 eventType
= wxEVT_LEFT_UP
;
2327 else if (xevent
->xbutton
.button
== Button2
)
2329 eventType
= wxEVT_MIDDLE_UP
;
2331 else if (xevent
->xbutton
.button
== Button3
)
2333 eventType
= wxEVT_RIGHT_UP
;
2343 wxevent
.SetEventType(eventType
);
2346 XtVaGetValues(widget
, XmNx
, &x1
, XmNy
, &y1
, NULL
);
2349 win
->GetPosition(&x2
, &y2
);
2351 // The button x/y must be translated to wxWindows
2352 // window space - the widget might be a label or button,
2356 if (widget
!= (Widget
)win
->GetMainWidget())
2362 wxevent
.m_x
= xevent
->xbutton
.x
+ dx
;
2363 wxevent
.m_y
= xevent
->xbutton
.y
+ dy
;
2365 wxevent
.m_leftDown
= ((eventType
== wxEVT_LEFT_DOWN
)
2366 || (event_left_is_down (xevent
)
2367 && (eventType
!= wxEVT_LEFT_UP
)));
2368 wxevent
.m_middleDown
= ((eventType
== wxEVT_MIDDLE_DOWN
)
2369 || (event_middle_is_down (xevent
)
2370 && (eventType
!= wxEVT_MIDDLE_UP
)));
2371 wxevent
.m_rightDown
= ((eventType
== wxEVT_RIGHT_DOWN
)
2372 || (event_right_is_down (xevent
)
2373 && (eventType
!= wxEVT_RIGHT_UP
)));
2375 wxevent
.m_shiftDown
= xevent
->xbutton
.state
& ShiftMask
;
2376 wxevent
.m_controlDown
= xevent
->xbutton
.state
& ControlMask
;
2377 wxevent
.m_altDown
= xevent
->xbutton
.state
& Mod3Mask
;
2378 wxevent
.m_metaDown
= xevent
->xbutton
.state
& Mod1Mask
;
2380 wxevent
.SetId(win
->GetId());
2381 wxevent
.SetEventObject(win
);
2389 bool wxTranslateKeyEvent(wxKeyEvent
& wxevent
, wxWindow
*win
,
2390 Widget
WXUNUSED(widget
), XEvent
*xevent
)
2392 switch (xevent
->xany
.type
)
2400 (void) XLookupString((XKeyEvent
*)xevent
, buf
, 20, &keySym
, NULL
);
2401 int id
= wxCharCodeXToWX (keySym
);
2402 // id may be WXK_xxx code - these are outside ASCII range, so we
2403 // can't just use toupper() on id
2404 if (id
>= 'a' && id
<= 'z')
2407 if (xevent
->xkey
.state
& ShiftMask
)
2408 wxevent
.m_shiftDown
= TRUE
;
2409 if (xevent
->xkey
.state
& ControlMask
)
2410 wxevent
.m_controlDown
= TRUE
;
2411 if (xevent
->xkey
.state
& Mod3Mask
)
2412 wxevent
.m_altDown
= TRUE
;
2413 if (xevent
->xkey
.state
& Mod1Mask
)
2414 wxevent
.m_metaDown
= TRUE
;
2415 wxevent
.SetEventObject(win
);
2416 wxevent
.m_keyCode
= id
;
2417 wxevent
.SetTimestamp(xevent
->xkey
.time
);
2419 wxevent
.m_x
= xevent
->xbutton
.x
;
2420 wxevent
.m_y
= xevent
->xbutton
.y
;
2434 // ----------------------------------------------------------------------------
2436 // ----------------------------------------------------------------------------
2438 #define YAllocColor XAllocColor
2439 XColor g_itemColors
[5];
2440 int wxComputeColours (Display
*display
, wxColour
* back
, wxColour
* fore
)
2443 static XmColorProc colorProc
;
2445 result
= wxNO_COLORS
;
2449 g_itemColors
[0].red
= (((long) back
->Red ()) << 8);
2450 g_itemColors
[0].green
= (((long) back
->Green ()) << 8);
2451 g_itemColors
[0].blue
= (((long) back
->Blue ()) << 8);
2452 g_itemColors
[0].flags
= DoRed
| DoGreen
| DoBlue
;
2453 if (colorProc
== (XmColorProc
) NULL
)
2455 // Get a ptr to the actual function
2456 colorProc
= XmSetColorCalculation ((XmColorProc
) NULL
);
2457 // And set it back to motif.
2458 XmSetColorCalculation (colorProc
);
2460 (*colorProc
) (&g_itemColors
[wxBACK_INDEX
],
2461 &g_itemColors
[wxFORE_INDEX
],
2462 &g_itemColors
[wxSELE_INDEX
],
2463 &g_itemColors
[wxTOPS_INDEX
],
2464 &g_itemColors
[wxBOTS_INDEX
]);
2465 result
= wxBACK_COLORS
;
2469 g_itemColors
[wxFORE_INDEX
].red
= (((long) fore
->Red ()) << 8);
2470 g_itemColors
[wxFORE_INDEX
].green
= (((long) fore
->Green ()) << 8);
2471 g_itemColors
[wxFORE_INDEX
].blue
= (((long) fore
->Blue ()) << 8);
2472 g_itemColors
[wxFORE_INDEX
].flags
= DoRed
| DoGreen
| DoBlue
;
2473 if (result
== wxNO_COLORS
)
2474 result
= wxFORE_COLORS
;
2477 Display
*dpy
= display
;
2478 Colormap cmap
= (Colormap
) wxTheApp
->GetMainColormap((WXDisplay
*) dpy
);
2482 /* 5 Colours to allocate */
2483 for (int i
= 0; i
< 5; i
++)
2484 if (!YAllocColor (dpy
, cmap
, &g_itemColors
[i
]))
2485 result
= wxNO_COLORS
;
2489 /* Only 1 colour to allocate */
2490 if (!YAllocColor (dpy
, cmap
, &g_itemColors
[wxFORE_INDEX
]))
2491 result
= wxNO_COLORS
;
2497 // Changes the foreground and background colours to be derived from the current
2498 // background colour. To change the foreground colour, you must call
2499 // SetForegroundColour explicitly.
2500 void wxWindow::ChangeBackgroundColour()
2502 WXWidget mainWidget
= GetMainWidget();
2504 wxDoChangeBackgroundColour(mainWidget
, m_backgroundColour
);
2507 void wxWindow::ChangeForegroundColour()
2509 WXWidget mainWidget
= GetMainWidget();
2511 wxDoChangeForegroundColour(mainWidget
, m_foregroundColour
);
2512 if ( m_scrolledWindow
&& mainWidget
!= m_scrolledWindow
)
2513 wxDoChangeForegroundColour(m_scrolledWindow
, m_foregroundColour
);
2516 bool wxWindow::SetBackgroundColour(const wxColour
& col
)
2518 if ( !wxWindowBase::SetBackgroundColour(col
) )
2521 ChangeBackgroundColour();
2526 bool wxWindow::SetForegroundColour(const wxColour
& col
)
2528 if ( !wxWindowBase::SetForegroundColour(col
) )
2531 ChangeForegroundColour();
2536 void wxWindow::ChangeFont(bool keepOriginalSize
)
2538 // Note that this causes the widget to be resized back
2539 // to its original size! We therefore have to set the size
2540 // back again. TODO: a better way in Motif?
2541 Widget w
= (Widget
) GetLabelWidget(); // Usually the main widget
2542 if (w
&& m_font
.Ok())
2544 int width
, height
, width1
, height1
;
2545 GetSize(& width
, & height
);
2547 wxDoChangeFont( GetLabelWidget(), m_font
);
2549 GetSize(& width1
, & height1
);
2550 if (keepOriginalSize
&& (width
!= width1
|| height
!= height1
))
2552 SetSize(-1, -1, width
, height
);
2557 // ----------------------------------------------------------------------------
2559 // ----------------------------------------------------------------------------
2561 wxWindow
*wxGetActiveWindow()
2564 wxFAIL_MSG("Not implemented");
2569 wxWindow
*wxWindowBase::GetCapture()
2571 return (wxWindow
*)g_captureWindow
;
2575 // Find the wxWindow at the current mouse position, returning the mouse
2577 wxWindow
* wxFindWindowAtPointer(wxPoint
& pt
)
2579 return wxFindWindowAtPoint(wxGetMousePosition());
2582 // Get the current mouse position.
2583 wxPoint
wxGetMousePosition()
2585 Display
*display
= wxGlobalDisplay();
2586 Window rootWindow
= RootWindowOfScreen (DefaultScreenOfDisplay(display
));
2587 Window rootReturn
, childReturn
;
2588 int rootX
, rootY
, winX
, winY
;
2589 unsigned int maskReturn
;
2591 XQueryPointer (display
,
2595 &rootX
, &rootY
, &winX
, &winY
, &maskReturn
);
2596 return wxPoint(rootX
, rootY
);
2600 // ----------------------------------------------------------------------------
2601 // wxNoOptimize: switch off size optimization
2602 // ----------------------------------------------------------------------------
2604 int wxNoOptimize::ms_count
= 0;