1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
21 #pragma implementation "window.h"
27 #include "wx/dcclient.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"
38 #include "wx/scrolwin.h"
39 #include "wx/module.h"
40 #include "wx/menuitem.h"
43 #if wxUSE_DRAG_AND_DROP
47 #include "wx/x11/private.h"
51 // ----------------------------------------------------------------------------
53 // ----------------------------------------------------------------------------
55 static const int SCROLL_MARGIN
= 4;
57 // ----------------------------------------------------------------------------
58 // global variables for this module
59 // ----------------------------------------------------------------------------
61 extern wxHashTable
*wxWidgetHashTable
;
62 static wxWindow
* g_captureWindow
= NULL
;
65 // ----------------------------------------------------------------------------
67 // ----------------------------------------------------------------------------
69 static void wxCanvasRepaintProc(Widget
, XtPointer
, XmDrawingAreaCallbackStruct
* cbs
);
70 static void wxCanvasInputEvent(Widget drawingArea
, XtPointer data
, XmDrawingAreaCallbackStruct
* cbs
);
71 static void wxCanvasMotionEvent(Widget
, XButtonEvent
* event
);
72 static void wxCanvasEnterLeave(Widget drawingArea
, XtPointer clientData
, XCrossingEvent
* event
);
73 static void wxScrollBarCallback(Widget widget
, XtPointer clientData
,
74 XmScrollBarCallbackStruct
*cbs
);
75 static void wxPanelItemEventHandler(Widget wid
,
76 XtPointer client_data
,
78 Boolean
*continueToDispatch
);
80 // ----------------------------------------------------------------------------
82 // ----------------------------------------------------------------------------
84 #define event_left_is_down(x) ((x)->xbutton.state & Button1Mask)
85 #define event_middle_is_down(x) ((x)->xbutton.state & Button2Mask)
86 #define event_right_is_down(x) ((x)->xbutton.state & Button3Mask)
88 // ----------------------------------------------------------------------------
90 // ----------------------------------------------------------------------------
92 IMPLEMENT_DYNAMIC_CLASS(wxWindowX11
, wxWindowBase
)
94 BEGIN_EVENT_TABLE(wxWindowX11
, wxWindowBase
)
95 EVT_SYS_COLOUR_CHANGED(wxWindowX11::OnSysColourChanged
)
96 EVT_IDLE(wxWindowX11::OnIdle
)
99 // ============================================================================
101 // ============================================================================
103 // ----------------------------------------------------------------------------
105 // ----------------------------------------------------------------------------
107 // ----------------------------------------------------------------------------
109 // ----------------------------------------------------------------------------
111 void wxWindowX11::Init()
113 // generic initializations first
117 m_needsRefresh
= TRUE
;
118 m_mainWidget
= (WXWidget
) 0;
122 m_button3Pressed
= FALSE
;
124 m_winCaptured
= FALSE
;
127 m_isBeingDeleted
= FALSE
;
133 m_drawingArea
= (WXWidget
) 0;
141 m_backingPixmap
= (WXPixmap
) 0;
150 m_canAddEventHandler
= FALSE
;
153 // real construction (Init() must have been called before!)
154 bool wxWindowX11::Create(wxWindow
*parent
, wxWindowID id
,
158 const wxString
& name
)
160 wxCHECK_MSG( parent
, FALSE
, "can't create wxWindow without parent" );
162 CreateBase(parent
, id
, pos
, size
, style
, wxDefaultValidator
, name
);
164 parent
->AddChild(this);
166 m_backgroundColour
= wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE
);
167 m_foregroundColour
= *wxBLACK
;
169 if (style
& wxSIMPLE_BORDER
)
171 } else if (style
& wxSUNKEN_BORDER
)
173 } else if (style
& wxRAISED_BORDER
)
177 // TODO: create XWindow
180 wxAddWindowToTable((Window
) m_drawingArea
, this);
181 wxAddWindowToTable((Window
) m_scrolledWindow
, this);
184 // Without this, the cursor may not be restored properly (e.g. in splitter
186 SetCursor(*wxSTANDARD_CURSOR
);
187 SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
));
188 SetSize(pos
.x
, pos
.y
, size
.x
, size
.y
);
194 wxWindowX11::~wxWindow()
196 if (g_captureWindow
== this)
197 g_captureWindow
= NULL
;
199 m_isBeingDeleted
= TRUE
;
201 // Motif-specific actions first
202 WXWindow wMain
= GetMainWindow();
205 // Removes event handlers
206 //DetachWidget(wMain);
212 m_parent
->RemoveChild( this );
217 // If m_drawingArea, we're a fully-fledged window with drawing area,
218 // scrollbars etc. (what wxCanvas used to be)
221 // Destroy children before destroying self
225 XFreePixmap (XtDisplay ((Widget
) GetMainWidget()), (Pixmap
) m_backingPixmap
);
227 Widget w
= (Widget
) m_drawingArea
;
228 wxDeleteWindowFromTable(w
);
233 m_drawingArea
= (WXWidget
) 0;
236 // Only if we're _really_ a canvas (not a dialog box/panel)
237 if (m_scrolledWindow
)
239 wxDeleteWindowFromTable((Widget
) m_scrolledWindow
);
244 wxDeleteWindowFromTable((Widget
) m_hScrollBar
);
245 XtUnmanageChild((Widget
) m_hScrollBar
);
249 wxDeleteWindowFromTable((Widget
) m_vScrollBar
);
250 XtUnmanageChild((Widget
) m_vScrollBar
);
254 XtDestroyWidget((Widget
) m_hScrollBar
);
256 XtDestroyWidget((Widget
) m_vScrollBar
);
258 UnmanageAndDestroy(m_scrolledWindow
);
262 XtDestroyWidget ((Widget
) m_borderWidget
);
263 m_borderWidget
= (WXWidget
) 0;
266 else // Why wasn't this here before? JACS 8/3/2000
271 // Destroy the window
275 // XtDestroyWidget((Widget) GetMainWidget());
276 SetMainWindow((WXWindow
) NULL
);
280 // ----------------------------------------------------------------------------
281 // scrollbar management
282 // ----------------------------------------------------------------------------
285 void wxWindowX11::CreateScrollbar(wxOrientation orientation
)
289 wxCHECK_RET( m_drawingArea
, "this window can't have scrollbars" );
291 XtVaSetValues((Widget
) m_scrolledWindow
, XmNresizePolicy
, XmRESIZE_NONE
, NULL
);
293 // Add scrollbars if required
294 if (orientation
== wxHORIZONTAL
)
296 Widget hScrollBar
= XtVaCreateManagedWidget ("hsb",
297 xmScrollBarWidgetClass
, (Widget
) m_scrolledWindow
,
298 XmNorientation
, XmHORIZONTAL
,
300 XtAddCallback (hScrollBar
, XmNvalueChangedCallback
, (XtCallbackProc
) wxScrollBarCallback
, (XtPointer
) XmHORIZONTAL
);
301 XtAddCallback (hScrollBar
, XmNdragCallback
, (XtCallbackProc
) wxScrollBarCallback
, (XtPointer
) XmHORIZONTAL
);
302 XtAddCallback (hScrollBar
, XmNincrementCallback
, (XtCallbackProc
) wxScrollBarCallback
, (XtPointer
) XmHORIZONTAL
);
303 XtAddCallback (hScrollBar
, XmNdecrementCallback
, (XtCallbackProc
) wxScrollBarCallback
, (XtPointer
) XmHORIZONTAL
);
304 XtAddCallback (hScrollBar
, XmNpageIncrementCallback
, (XtCallbackProc
) wxScrollBarCallback
, (XtPointer
) XmHORIZONTAL
);
305 XtAddCallback (hScrollBar
, XmNpageDecrementCallback
, (XtCallbackProc
) wxScrollBarCallback
, (XtPointer
) XmHORIZONTAL
);
306 XtAddCallback (hScrollBar
, XmNtoTopCallback
, (XtCallbackProc
) wxScrollBarCallback
, (XtPointer
) XmHORIZONTAL
);
307 XtAddCallback (hScrollBar
, XmNtoBottomCallback
, (XtCallbackProc
) wxScrollBarCallback
, (XtPointer
) XmHORIZONTAL
);
309 XtVaSetValues (hScrollBar
,
314 m_hScrollBar
= (WXWidget
) hScrollBar
;
316 wxColour backgroundColour
= wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE
);
317 DoChangeBackgroundColour(m_hScrollBar
, backgroundColour
, TRUE
);
319 XtRealizeWidget(hScrollBar
);
321 XtVaSetValues((Widget
) m_scrolledWindow
,
322 XmNhorizontalScrollBar
, (Widget
) m_hScrollBar
,
327 wxAddWindowToTable( hScrollBar
, this );
330 if (orientation
== wxVERTICAL
)
332 Widget vScrollBar
= XtVaCreateManagedWidget ("vsb",
333 xmScrollBarWidgetClass
, (Widget
) m_scrolledWindow
,
334 XmNorientation
, XmVERTICAL
,
336 XtAddCallback (vScrollBar
, XmNvalueChangedCallback
, (XtCallbackProc
) wxScrollBarCallback
, (XtPointer
) XmVERTICAL
);
337 XtAddCallback (vScrollBar
, XmNdragCallback
, (XtCallbackProc
) wxScrollBarCallback
, (XtPointer
) XmVERTICAL
);
338 XtAddCallback (vScrollBar
, XmNincrementCallback
, (XtCallbackProc
) wxScrollBarCallback
, (XtPointer
) XmVERTICAL
);
339 XtAddCallback (vScrollBar
, XmNdecrementCallback
, (XtCallbackProc
) wxScrollBarCallback
, (XtPointer
) XmVERTICAL
);
340 XtAddCallback (vScrollBar
, XmNpageIncrementCallback
, (XtCallbackProc
) wxScrollBarCallback
, (XtPointer
) XmVERTICAL
);
341 XtAddCallback (vScrollBar
, XmNpageDecrementCallback
, (XtCallbackProc
) wxScrollBarCallback
, (XtPointer
) XmVERTICAL
);
342 XtAddCallback (vScrollBar
, XmNtoTopCallback
, (XtCallbackProc
) wxScrollBarCallback
, (XtPointer
) XmVERTICAL
);
343 XtAddCallback (vScrollBar
, XmNtoBottomCallback
, (XtCallbackProc
) wxScrollBarCallback
, (XtPointer
) XmVERTICAL
);
345 XtVaSetValues (vScrollBar
,
350 m_vScrollBar
= (WXWidget
) vScrollBar
;
351 wxColour backgroundColour
= wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE
);
352 DoChangeBackgroundColour(m_vScrollBar
, backgroundColour
, TRUE
);
354 XtRealizeWidget(vScrollBar
);
356 XtVaSetValues((Widget
) m_scrolledWindow
,
357 XmNverticalScrollBar
, (Widget
) m_vScrollBar
,
362 wxAddWindowToTable( vScrollBar
, this );
365 XtVaSetValues((Widget
) m_scrolledWindow
, XmNresizePolicy
, XmRESIZE_ANY
, NULL
);
369 void wxWindowX11::DestroyScrollbar(wxOrientation orientation
)
373 wxCHECK_RET( m_drawingArea
, "this window can't have scrollbars" );
375 XtVaSetValues((Widget
) m_scrolledWindow
, XmNresizePolicy
, XmRESIZE_NONE
, NULL
);
376 // Add scrollbars if required
377 if (orientation
== wxHORIZONTAL
)
381 wxDeleteWindowFromTable((Widget
)m_hScrollBar
);
382 XtDestroyWidget((Widget
) m_hScrollBar
);
384 m_hScrollBar
= (WXWidget
) 0;
387 XtVaSetValues((Widget
) m_scrolledWindow
,
388 XmNhorizontalScrollBar
, (Widget
) 0,
393 if (orientation
== wxVERTICAL
)
397 wxDeleteWindowFromTable((Widget
)m_vScrollBar
);
398 XtDestroyWidget((Widget
) m_vScrollBar
);
400 m_vScrollBar
= (WXWidget
) 0;
403 XtVaSetValues((Widget
) m_scrolledWindow
,
404 XmNverticalScrollBar
, (Widget
) 0,
408 XtVaSetValues((Widget
) m_scrolledWindow
, XmNresizePolicy
, XmRESIZE_ANY
, NULL
);
412 // ---------------------------------------------------------------------------
414 // ---------------------------------------------------------------------------
416 void wxWindowX11::SetFocus()
420 Widget wMain
= (Widget
) GetMainWidget();
421 XmProcessTraversal(wMain
, XmTRAVERSE_CURRENT
);
422 XmProcessTraversal((Widget
) GetMainWidget(), XmTRAVERSE_CURRENT
);
426 // Get the window with the focus
427 wxWindow
*wxWindowBase::FindFocus()
434 // (1) Can there be multiple focussed widgets in an application?
435 // In which case we need to find the top-level window that's
437 // (2) The widget with the focus may not be in the widget table
438 // depending on which widgets I put in the table
439 wxWindow
*winFocus
= (wxWindow
*)NULL
;
440 for ( wxWindowList::Node
*node
= wxTopLevelWindows
.GetFirst();
442 node
= node
->GetNext() )
444 wxWindow
*win
= node
->GetData();
446 Widget w
= XmGetFocusWidget ((Widget
) win
->GetTopWidget());
448 if (w
!= (Widget
) NULL
)
450 winFocus
= wxGetWindowFromTable(w
);
460 bool wxWindowX11::Enable(bool enable
)
462 if ( !wxWindowBase::Enable(enable
) )
467 Widget wMain
= (Widget
)GetMainWidget();
470 XtSetSensitive(wMain
, enable
);
471 XmUpdateDisplay(wMain
);
478 bool wxWindowX11::Show(bool show
)
480 if ( !wxWindowBase::Show(show
) )
483 Window xwin
= (Window
) GetXWindow();
484 Display
*xdisp
= (Display
*) GetXDisplay();
486 XMapWindow(xdisp
, xwin
);
488 XUnmapWindow(xdisp
, xwin
);
493 // Raise the window to the top of the Z order
494 void wxWindowX11::Raise()
496 Window window
= GetTopWindow();
498 XRaiseWindow(wxGetDisplay(), window
);
501 // Lower the window to the bottom of the Z order
502 void wxWindowX11::Lower()
504 Window window
= GetTopWindow();
506 XLowerWindow(wxGetDisplay(), window
);
509 void wxWindowX11::SetTitle(const wxString
& title
)
512 // XtVaSetValues((Widget)GetMainWidget(), XmNtitle, title.c_str(), NULL);
515 wxString
wxWindowX11::GetTitle() const
518 return wxEmptyString
;
521 XtVaGetValues((Widget
)GetMainWidget(), XmNtitle
, &title
, NULL
);
523 return wxString(title
);
527 void wxWindowX11::DoCaptureMouse()
529 g_captureWindow
= this;
535 Widget wMain
= (Widget
)GetMainWidget();
537 XtAddGrab(wMain
, TRUE
, FALSE
);
540 m_winCaptured
= TRUE
;
543 void wxWindowX11::DoReleaseMouse()
545 g_captureWindow
= NULL
;
546 if ( !m_winCaptured
)
551 Widget wMain
= (Widget
)GetMainWidget();
556 m_winCaptured
= FALSE
;
559 bool wxWindowX11::SetFont(const wxFont
& font
)
561 if ( !wxWindowBase::SetFont(font
) )
572 bool wxWindowX11::SetCursor(const wxCursor
& cursor
)
574 if ( !wxWindowBase::SetCursor(cursor
) )
580 wxCursor
* cursor2
= NULL
;
582 cursor2
= & m_cursor
;
584 cursor2
= wxSTANDARD_CURSOR
;
586 WXDisplay
*dpy
= GetXDisplay();
587 WXCursor x_cursor
= cursor2
->GetXCursor(dpy
);
589 Window win
= (Window
) GetMainWindow();
590 XDefineCursor((Display
*) dpy
, win
, (Cursor
) x_cursor
);
595 // Coordinates relative to the window
596 void wxWindowX11::WarpPointer (int x
, int y
)
598 Window wClient
= (Window
) GetClientWindow();
600 XWarpPointer(wxGetDisplay(), None
, wClient
, 0, 0, 0, 0, x
, y
);
603 // ---------------------------------------------------------------------------
605 // ---------------------------------------------------------------------------
607 int wxWindowX11::GetScrollPos(int orient
) const
609 if (orient
== wxHORIZONTAL
)
615 // This now returns the whole range, not just the number of positions that we
617 int wxWindowX11::GetScrollRange(int WXUNUSED(orient
)) const
622 Widget scrollBar
= (Widget
)GetScrollbar((wxOrientation
)orient
);
623 wxCHECK_MSG( scrollBar
, 0, "no such scrollbar" );
626 XtVaGetValues(scrollBar
, XmNmaximum
, &range
, NULL
);
631 int wxWindowX11::GetScrollThumb(int orient
) const
637 Widget scrollBar
= (Widget
)GetScrollbar((wxOrientation
)orient
);
638 wxCHECK_MSG( scrollBar
, 0, "no such scrollbar" );
641 XtVaGetValues(scrollBar
, XmNsliderSize
, &thumb
, NULL
);
646 void wxWindowX11::SetScrollPos(int WXUNUSED(orient
), int WXUNUSED(pos
), bool WXUNUSED(refresh
))
651 Widget scrollBar
= (Widget
)GetScrollbar((wxOrientation
)orient
);
655 XtVaSetValues (scrollBar
, XmNvalue
, pos
, NULL
);
658 SetInternalScrollPos((wxOrientation
)orient
, pos
);
661 // New function that will replace some of the above.
662 void wxWindowX11::SetScrollbar(int WXUNUSED(orient
), int WXUNUSED(pos
), int WXUNUSED(thumbVisible
),
663 int WXUNUSED(range
), bool WXUNUSED(refresh
))
668 GetSize(& oldW
, & oldH
);
672 if (thumbVisible
== 0)
675 if (thumbVisible
> range
)
676 thumbVisible
= range
;
678 // Save the old state to see if it changed
679 WXWidget oldScrollBar
= GetScrollbar((wxOrientation
)orient
);
681 if (orient
== wxHORIZONTAL
)
683 if (thumbVisible
== range
)
686 DestroyScrollbar(wxHORIZONTAL
);
691 CreateScrollbar(wxHORIZONTAL
);
694 if (orient
== wxVERTICAL
)
696 if (thumbVisible
== range
)
699 DestroyScrollbar(wxVERTICAL
);
704 CreateScrollbar(wxVERTICAL
);
707 WXWidget newScrollBar
= GetScrollbar((wxOrientation
)orient
);
709 if (oldScrollBar
!= newScrollBar
)
711 // This is important! Without it, scrollbars misbehave badly.
712 XtUnrealizeWidget((Widget
) m_scrolledWindow
);
713 XmScrolledWindowSetAreas ((Widget
) m_scrolledWindow
, (Widget
) m_hScrollBar
, (Widget
) m_vScrollBar
, (Widget
) m_drawingArea
);
714 XtRealizeWidget((Widget
) m_scrolledWindow
);
715 XtManageChild((Widget
) m_scrolledWindow
);
720 XtVaSetValues((Widget
) newScrollBar
,
724 XmNsliderSize
, thumbVisible
,
728 SetInternalScrollPos((wxOrientation
)orient
, pos
);
731 GetSize(& newW
, & newH
);
733 // Adjusting scrollbars can resize the canvas accidentally
734 if (newW
!= oldW
|| newH
!= oldH
)
735 SetSize(-1, -1, oldW
, oldH
);
739 // Does a physical scroll
740 void wxWindowX11::ScrollWindow(int dx
, int dy
, const wxRect
*rect
)
745 // Use specified rectangle
746 x
= rect
->x
; y
= rect
->y
; w
= rect
->width
; h
= rect
->height
;
750 // Use whole client area
752 GetClientSize(& w
, & h
);
755 wxNode
*cnode
= m_children
.First();
758 wxWindow
*child
= (wxWindow
*) cnode
->Data();
761 child
->GetSize( &sx
, &sy
);
762 wxPoint
pos( child
->GetPosition() );
763 child
->SetSize( pos
.x
+ dx
, pos
.y
+ dy
, sx
, sy
, wxSIZE_ALLOW_MINUS_ONE
);
764 cnode
= cnode
->Next();
767 int x1
= (dx
>= 0) ? x
: x
- dx
;
768 int y1
= (dy
>= 0) ? y
: y
- dy
;
769 int w1
= w
- abs(dx
);
770 int h1
= h
- abs(dy
);
771 int x2
= (dx
>= 0) ? x
+ dx
: x
;
772 int y2
= (dy
>= 0) ? y
+ dy
: y
;
776 dc
.SetLogicalFunction (wxCOPY
);
778 Window window
= (Window
) GetMainWindow();
779 Display
* display
= wxGetDisplay();
781 XCopyArea(display
, window
, window
, (GC
) dc
.GetGC(),
782 x1
, y1
, w1
, h1
, x2
, y2
);
784 dc
.SetAutoSetting(TRUE
);
785 wxBrush
brush(GetBackgroundColour(), wxSOLID
);
786 dc
.SetBrush(brush
); // FIXME: needed?
788 // We'll add rectangles to the list of update rectangles according to which
789 // bits we've exposed.
794 wxRect
*rect
= new wxRect
;
800 XFillRectangle(display
, window
,
801 (GC
) dc
.GetGC(), rect
->x
, rect
->y
, rect
->width
, rect
->height
);
805 rect
->width
= rect
->width
;
806 rect
->height
= rect
->height
;
808 updateRects
.Append((wxObject
*) rect
);
812 wxRect
*rect
= new wxRect
;
814 rect
->x
= x
+ w
+ dx
;
819 XFillRectangle(display
, window
,
820 (GC
) dc
.GetGC(), rect
->x
, rect
->y
, rect
->width
,
825 rect
->width
= rect
->width
;
826 rect
->height
= rect
->height
;
828 updateRects
.Append((wxObject
*) rect
);
832 wxRect
*rect
= new wxRect
;
839 XFillRectangle(display
, window
,
840 (GC
) dc
.GetGC(), rect
->x
, rect
->y
, rect
->width
, rect
->height
);
844 rect
->width
= rect
->width
;
845 rect
->height
= rect
->height
;
847 updateRects
.Append((wxObject
*) rect
);
851 wxRect
*rect
= new wxRect
;
854 rect
->y
= y
+ h
+ dy
;
858 XFillRectangle(display
, window
,
859 (GC
) dc
.GetGC(), rect
->x
, rect
->y
, rect
->width
, rect
->height
);
863 rect
->width
= rect
->width
;
864 rect
->height
= rect
->height
;
866 updateRects
.Append((wxObject
*) rect
);
868 dc
.SetBrush(wxNullBrush
);
870 // Now send expose events
872 wxNode
* node
= updateRects
.First();
875 wxRect
* rect
= (wxRect
*) node
->Data();
879 event
.display
= display
;
880 event
.send_event
= True
;
881 event
.window
= window
;
885 event
.width
= rect
->width
;
886 event
.height
= rect
->height
;
890 XSendEvent(display
, window
, False
, ExposureMask
, (XEvent
*)&event
);
896 // Delete the update rects
897 node
= updateRects
.First();
900 wxRect
* rect
= (wxRect
*) node
->Data();
907 // XmUpdateDisplay((Widget) GetMainWidget());
910 // ---------------------------------------------------------------------------
912 // ---------------------------------------------------------------------------
914 #if wxUSE_DRAG_AND_DROP
916 void wxWindowX11::SetDropTarget(wxDropTarget
* WXUNUSED(pDropTarget
))
923 // Old style file-manager drag&drop
924 void wxWindowX11::DragAcceptFiles(bool WXUNUSED(accept
))
929 // ----------------------------------------------------------------------------
931 // ----------------------------------------------------------------------------
935 void wxWindowX11::DoSetToolTip(wxToolTip
* WXUNUSED(tooltip
))
940 #endif // wxUSE_TOOLTIPS
942 // ---------------------------------------------------------------------------
943 // moving and resizing
944 // ---------------------------------------------------------------------------
946 bool wxWindowX11::PreResize()
952 void wxWindowX11::DoGetSize(int *x
, int *y
) const
962 Widget widget
= (Widget
) GetTopWidget();
964 XtVaGetValues(widget
, XmNwidth
, &xx
, XmNheight
, &yy
, NULL
);
965 if(x
) *x
= xx
; if(y
) *y
= yy
;
969 void wxWindowX11::DoGetPosition(int *x
, int *y
) const
975 CanvasGetPosition(x
, y
);
978 Widget widget
= (Widget
) GetTopWidget();
980 XtVaGetValues(widget
, XmNx
, &xx
, XmNy
, &yy
, NULL
);
982 // We may be faking the client origin. So a window that's really at (0, 30)
983 // may appear (to wxWin apps) to be at (0, 0).
986 wxPoint
pt(GetParent()->GetClientAreaOrigin());
991 if(x
) *x
= xx
; if(y
) *y
= yy
;
995 void wxWindowX11::DoScreenToClient(int *x
, int *y
) const
997 Display
*display
= wxGetDisplay();
998 Window rootWindow
= RootWindowOfScreen(DefaultScreenOfDisplay(display
));
999 Window thisWindow
= (Window
) GetClientWindow();
1004 XTranslateCoordinates(display
, rootWindow
, thisWindow
, xx
, yy
, x
, y
, &childWindow
);
1007 void wxWindowX11::DoClientToScreen(int *x
, int *y
) const
1009 Display
*display
= wxGetDisplay();
1010 Window rootWindow
= RootWindowOfScreen(DefaultScreenOfDisplay(display
));
1011 Window thisWindow
= (Window
) GetClientWindow();
1016 XTranslateCoordinates(display
, thisWindow
, rootWindow
, xx
, yy
, x
, y
, &childWindow
);
1020 // Get size *available for subwindows* i.e. excluding menu bar etc.
1021 void wxWindowX11::DoGetClientSize(int *x
, int *y
) const
1025 Widget widget
= (Widget
) GetClientWidget();
1027 XtVaGetValues(widget
, XmNwidth
, &xx
, XmNheight
, &yy
, NULL
);
1028 if(x
) *x
= xx
; if(y
) *y
= yy
;
1032 void wxWindowX11::DoSetSize(int x
, int y
, int width
, int height
, int sizeFlags
)
1036 // A bit of optimization to help sort out the flickers.
1037 int oldX
, oldY
, oldW
, oldH
;
1038 GetSize(& oldW
, & oldH
);
1039 GetPosition(& oldX
, & oldY
);
1041 if ( !(sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
) )
1054 bool nothingChanged
= (x
== oldX
) && (y
== oldY
) &&
1055 (width
== oldW
) && (height
== oldH
);
1057 if (!wxNoOptimize::CanOptimize())
1059 nothingChanged
= FALSE
;
1062 if ( !nothingChanged
)
1066 CanvasSetSize(x
, y
, width
, height
, sizeFlags
);
1070 Widget widget
= (Widget
) GetTopWidget();
1074 bool managed
= XtIsManaged( widget
);
1076 XtUnmanageChild(widget
);
1080 AdjustForParentClientOrigin(xx
, yy
, sizeFlags
);
1082 DoMoveWindow(xx
, yy
, width
, height
);
1085 XtManageChild(widget
);
1091 void wxWindowX11::DoSetClientSize(int width
, int height
)
1097 CanvasSetClientSize(width
, height
);
1101 Widget widget
= (Widget
) GetTopWidget();
1104 XtVaSetValues(widget
, XmNwidth
, width
, NULL
);
1106 XtVaSetValues(widget
, XmNheight
, height
, NULL
);
1108 wxSizeEvent
sizeEvent(wxSize(width
, height
), GetId());
1109 sizeEvent
.SetEventObject(this);
1111 GetEventHandler()->ProcessEvent(sizeEvent
);
1115 // For implementation purposes - sometimes decorations make the client area
1117 wxPoint
wxWindowX11::GetClientAreaOrigin() const
1119 return wxPoint(0, 0);
1122 // Makes an adjustment to the window position (for example, a frame that has
1123 // a toolbar that it manages itself).
1124 void wxWindowX11::AdjustForParentClientOrigin(int& x
, int& y
, int sizeFlags
)
1126 if (((sizeFlags
& wxSIZE_NO_ADJUSTMENTS
) == 0) && GetParent())
1128 wxPoint
pt(GetParent()->GetClientAreaOrigin());
1129 x
+= pt
.x
; y
+= pt
.y
;
1133 void wxWindowX11::SetSizeHints(int minW
, int minH
, int maxW
, int maxH
, int incW
, int incH
)
1142 wxFrame
*frame
= wxDynamicCast(this, wxFrame
);
1145 // TODO what about dialogs?
1149 Widget widget
= (Widget
) frame
->GetShellWidget();
1152 XtVaSetValues(widget
, XmNminWidth
, minW
, NULL
);
1154 XtVaSetValues(widget
, XmNminHeight
, minH
, NULL
);
1156 XtVaSetValues(widget
, XmNmaxWidth
, maxW
, NULL
);
1158 XtVaSetValues(widget
, XmNmaxHeight
, maxH
, NULL
);
1160 XtVaSetValues(widget
, XmNwidthInc
, incW
, NULL
);
1162 XtVaSetValues(widget
, XmNheightInc
, incH
, NULL
);
1166 void wxWindowX11::DoMoveWindow(int x
, int y
, int width
, int height
)
1170 XtVaSetValues((Widget
)GetTopWidget(),
1179 // ---------------------------------------------------------------------------
1181 // ---------------------------------------------------------------------------
1183 int wxWindowX11::GetCharHeight() const
1185 wxCHECK_MSG( m_font
.Ok(), 0, "valid window font needed" );
1187 WXFontStructPtr pFontStruct
= m_font
.GetFontStruct(1.0, GetXDisplay());
1189 int direction
, ascent
, descent
;
1190 XCharStruct overall
;
1191 XTextExtents ((XFontStruct
*) pFontStruct
, "x", 1, &direction
, &ascent
,
1192 &descent
, &overall
);
1194 // return (overall.ascent + overall.descent);
1195 return (ascent
+ descent
);
1198 int wxWindowX11::GetCharWidth() const
1200 wxCHECK_MSG( m_font
.Ok(), 0, "valid window font needed" );
1202 WXFontStructPtr pFontStruct
= m_font
.GetFontStruct(1.0, GetXDisplay());
1204 int direction
, ascent
, descent
;
1205 XCharStruct overall
;
1206 XTextExtents ((XFontStruct
*) pFontStruct
, "x", 1, &direction
, &ascent
,
1207 &descent
, &overall
);
1209 return overall
.width
;
1212 void wxWindowX11::GetTextExtent(const wxString
& string
,
1214 int *descent
, int *externalLeading
,
1215 const wxFont
*theFont
) const
1217 wxFont
*fontToUse
= (wxFont
*)theFont
;
1219 fontToUse
= (wxFont
*) & m_font
;
1221 wxCHECK_RET( fontToUse
->Ok(), "valid window font needed" );
1223 WXFontStructPtr pFontStruct
= theFont
->GetFontStruct(1.0, GetXDisplay());
1225 int direction
, ascent
, descent2
;
1226 XCharStruct overall
;
1227 int slen
= string
.Len();
1231 XTextExtents16((XFontStruct
*) pFontStruct
, (XChar2b
*) (char*) (const char*) string
, slen
, &direction
,
1232 &ascent
, &descent2
, &overall
);
1235 XTextExtents((XFontStruct
*) pFontStruct
, string
, slen
,
1236 &direction
, &ascent
, &descent2
, &overall
);
1239 *x
= (overall
.width
);
1241 *y
= (ascent
+ descent2
);
1243 *descent
= descent2
;
1244 if (externalLeading
)
1245 *externalLeading
= 0;
1249 // ----------------------------------------------------------------------------
1251 // ----------------------------------------------------------------------------
1253 void wxWindowX11::Refresh(bool eraseBack
, const wxRect
*rect
)
1255 m_needsRefresh
= TRUE
;
1256 Display
*display
= wxGetDisplay();
1257 Window thisWindow
= (Widget
) GetMainWindow();
1259 XExposeEvent dummyEvent
;
1261 GetSize(&width
, &height
);
1263 dummyEvent
.type
= Expose
;
1264 dummyEvent
.display
= display
;
1265 dummyEvent
.send_event
= True
;
1266 dummyEvent
.window
= thisWindow
;
1269 dummyEvent
.x
= rect
->x
;
1270 dummyEvent
.y
= rect
->y
;
1271 dummyEvent
.width
= rect
->width
;
1272 dummyEvent
.height
= rect
->height
;
1278 dummyEvent
.width
= width
;
1279 dummyEvent
.height
= height
;
1281 dummyEvent
.count
= 0;
1285 wxClientDC
dc(this);
1286 wxBrush
backgroundBrush(GetBackgroundColour(), wxSOLID
);
1287 dc
.SetBackground(backgroundBrush
);
1294 XSendEvent(display
, thisWindow
, False
, ExposureMask
, (XEvent
*)&dummyEvent
);
1297 void wxWindowX11::Clear()
1299 wxClientDC
dc(this);
1300 wxBrush
brush(GetBackgroundColour(), wxSOLID
);
1301 dc
.SetBackground(brush
);
1305 void wxWindowX11::ClearUpdateRects()
1307 wxRectList::Node
* node
= m_updateRects
.GetFirst();
1310 wxRect
* rect
= node
->GetData();
1312 node
= node
->GetNext();
1315 m_updateRects
.Clear();
1318 void wxWindowX11::DoPaint()
1320 // Set an erase event first
1321 wxEraseEvent
eraseEvent(GetId());
1322 eraseEvent
.SetEventObject(this);
1323 GetEventHandler()->ProcessEvent(eraseEvent
);
1325 wxPaintEvent
event(GetId());
1326 event
.SetEventObject(this);
1327 GetEventHandler()->ProcessEvent(event
);
1329 m_needsRefresh
= FALSE
;
1332 // ----------------------------------------------------------------------------
1334 // ----------------------------------------------------------------------------
1336 // Responds to colour changes: passes event on to children.
1337 void wxWindowX11::OnSysColourChanged(wxSysColourChangedEvent
& event
)
1339 wxWindowList::Node
*node
= GetChildren().GetFirst();
1342 // Only propagate to non-top-level windows
1343 wxWindow
*win
= node
->GetData();
1344 if ( win
->GetParent() )
1346 wxSysColourChangedEvent event2
;
1347 event
.m_eventObject
= win
;
1348 win
->GetEventHandler()->ProcessEvent(event2
);
1351 node
= node
->GetNext();
1355 void wxWindowX11::OnIdle(wxIdleEvent
& WXUNUSED(event
))
1357 // This calls the UI-update mechanism (querying windows for
1358 // menu/toolbar/control state information)
1362 // ----------------------------------------------------------------------------
1364 // ----------------------------------------------------------------------------
1366 bool wxWindowX11::ProcessAccelerator(wxKeyEvent
& event
)
1368 if (!m_acceleratorTable
.Ok())
1371 int count
= m_acceleratorTable
.GetCount();
1372 wxAcceleratorEntry
* entries
= m_acceleratorTable
.GetEntries();
1374 for (i
= 0; i
< count
; i
++)
1376 wxAcceleratorEntry
* entry
= & (entries
[i
]);
1377 if (entry
->MatchesEvent(event
))
1379 // Bingo, we have a match. Now find a control that matches the
1380 // entry command id.
1382 // Need to go up to the top of the window hierarchy, since it might
1383 // be e.g. a menu item
1384 wxWindow
* parent
= this;
1385 while ( parent
&& !parent
->IsTopLevel() )
1386 parent
= parent
->GetParent();
1391 wxFrame
* frame
= wxDynamicCast(parent
, wxFrame
);
1394 // Try for a menu command
1395 if (frame
->GetMenuBar())
1397 wxMenuItem
* item
= frame
->GetMenuBar()->FindItem(entry
->GetCommand());
1400 wxCommandEvent
commandEvent(wxEVT_COMMAND_MENU_SELECTED
, entry
->GetCommand());
1401 commandEvent
.SetEventObject(frame
);
1403 // If ProcessEvent returns TRUE (it was handled), then
1404 // the calling code will skip the event handling.
1405 return frame
->GetEventHandler()->ProcessEvent(commandEvent
);
1410 // Find a child matching the command id
1411 wxWindow
* child
= parent
->FindWindow(entry
->GetCommand());
1417 // Now we process those kinds of windows that we can.
1418 // For now, only buttons.
1419 if ( wxDynamicCast(child
, wxButton
) )
1421 wxCommandEvent
commandEvent (wxEVT_COMMAND_BUTTON_CLICKED
, child
->GetId());
1422 commandEvent
.SetEventObject(child
);
1423 return child
->GetEventHandler()->ProcessEvent(commandEvent
);
1430 // We didn't match the key event against an accelerator.
1434 // ============================================================================
1435 // X11-specific stuff from here on
1436 // ============================================================================
1438 // ----------------------------------------------------------------------------
1439 // function which maintain the global hash table mapping Widgets to wxWindows
1440 // ----------------------------------------------------------------------------
1442 bool wxAddWindowToTable(Window w
, wxWindow
*win
)
1444 wxWindow
*oldItem
= NULL
;
1445 if ((oldItem
= (wxWindow
*)wxWidgetHashTable
->Get ((long) w
)))
1447 wxLogDebug("Widget table clash: new widget is %ld, %s",
1448 (long)w
, win
->GetClassInfo()->GetClassName());
1452 wxWidgetHashTable
->Put((long) w
, win
);
1454 wxLogTrace("widget", "XWindow 0x%08x <-> window %p (%s)",
1455 w
, win
, win
->GetClassInfo()->GetClassName());
1460 wxWindow
*wxGetWindowFromTable(Window w
)
1462 return (wxWindow
*)wxWidgetHashTable
->Get((long) w
);
1465 void wxDeleteWindowFromTable(Window w
)
1467 wxWidgetHashTable
->Delete((long)w
);
1470 // ----------------------------------------------------------------------------
1471 // add/remove window from the table
1472 // ----------------------------------------------------------------------------
1474 // Add to hash table, add event handler
1475 bool wxWindowX11::AttachWidget (wxWindow
* WXUNUSED(parent
), WXWindow mainWidget
,
1476 int x
, int y
, int width
, int height
)
1478 wxAddWindowToTable((Window
) mainWidget
, this);
1482 if (CanAddEventHandler())
1484 XtAddEventHandler((Widget
) mainWidget
,
1485 ButtonPressMask
| ButtonReleaseMask
| PointerMotionMask
, // | KeyPressMask,
1487 wxPanelItemEventHandler
,
1494 XtOverrideTranslations ((Widget
) mainWidget
,
1495 ptr
= XtParseTranslationTable ("<Configure>: resize()"));
1496 XtFree ((char *) ptr
);
1499 // Some widgets have a parent form widget, e.g. wxRadioBox
1502 if (!wxAddWindowToTable((Widget
) formWidget
, this))
1506 XtOverrideTranslations ((Widget
) formWidget
,
1507 ptr
= XtParseTranslationTable ("<Configure>: resize()"));
1508 XtFree ((char *) ptr
);
1516 SetSize (x
, y
, width
, height
);
1521 // Remove event handler, remove from hash table
1522 bool wxWindowX11::DetachWidget(WXWindow widget
)
1526 if (CanAddEventHandler())
1528 XtRemoveEventHandler((Widget
) widget
,
1529 ButtonPressMask
| ButtonReleaseMask
| PointerMotionMask
, // | KeyPressMask,
1531 wxPanelItemEventHandler
,
1536 wxDeleteWindowFromTable((Window
) widget
);
1540 // ----------------------------------------------------------------------------
1541 // X11-specific accessors
1542 // ----------------------------------------------------------------------------
1544 // Get the underlying X window
1545 WXWindow
wxWindowX11::GetXWindow() const
1547 return GetMainWindow();
1550 // Get the underlying X display
1551 WXDisplay
*wxWindowX11::GetXDisplay() const
1553 return wxGetDisplay();
1556 WXWindow
wxWindowX11::GetMainWindow() const
1559 return m_drawingArea
;
1561 return m_mainWidget
;
1564 WXWindow
wxWindowX11::GetClientWidget() const
1566 if (m_drawingArea
!= (WXWindow
) 0)
1567 return m_drawingArea
;
1569 return GetMainWindow();
1572 WXWindow
wxWindowX11::GetTopWindow() const
1574 return GetMainWindow();
1577 WXWindow
wxWindowX11::GetLabelWindow() const
1579 return GetMainWindow();
1582 // ----------------------------------------------------------------------------
1584 // ----------------------------------------------------------------------------
1589 // All widgets should have this as their resize proc.
1590 // OnSize sent to wxWindow via client data.
1591 void wxWidgetResizeProc(Widget w
, XConfigureEvent
*WXUNUSED(event
), String
WXUNUSED(args
)[], int *WXUNUSED(num_args
))
1593 wxWindow
*win
= wxGetWindowFromTable(w
);
1597 if (win
->PreResize())
1600 win
->GetSize(&width
, &height
);
1601 wxSizeEvent
sizeEvent(wxSize(width
, height
), win
->GetId());
1602 sizeEvent
.SetEventObject(win
);
1603 win
->GetEventHandler()->ProcessEvent(sizeEvent
);
1607 static void wxCanvasRepaintProc(Widget drawingArea
,
1608 XtPointer clientData
,
1609 XmDrawingAreaCallbackStruct
* cbs
)
1611 if (!wxGetWindowFromTable(drawingArea
))
1614 XEvent
* event
= cbs
->event
;
1615 wxWindow
* win
= (wxWindow
*) clientData
;
1617 switch (event
->type
)
1621 win
->AddUpdateRect(event
->xexpose
.x
, event
->xexpose
.y
,
1622 event
->xexpose
.width
, event
->xexpose
.height
);
1624 if (event
-> xexpose
.count
== 0)
1627 win
->ClearUpdateRects();
1634 // Unable to deal with Enter/Leave without a separate EventHandler (Motif 1.1.4)
1635 static void wxCanvasEnterLeave(Widget drawingArea
,
1636 XtPointer
WXUNUSED(clientData
),
1637 XCrossingEvent
* event
)
1639 XmDrawingAreaCallbackStruct cbs
;
1642 ((XCrossingEvent
&) ev
) = *event
;
1644 cbs
.reason
= XmCR_INPUT
;
1647 wxCanvasInputEvent(drawingArea
, (XtPointer
) NULL
, &cbs
);
1650 // Fix to make it work under Motif 1.0 (!)
1651 static void wxCanvasMotionEvent (Widget
WXUNUSED(drawingArea
), XButtonEvent
* WXUNUSED(event
))
1653 #if XmVersion <= 1000
1654 XmDrawingAreaCallbackStruct cbs
;
1657 ev
= *((XEvent
*) event
);
1658 cbs
.reason
= XmCR_INPUT
;
1661 wxCanvasInputEvent (drawingArea
, (XtPointer
) NULL
, &cbs
);
1662 #endif // XmVersion <= 1000
1665 static void wxCanvasInputEvent(Widget drawingArea
,
1666 XtPointer
WXUNUSED(data
),
1667 XmDrawingAreaCallbackStruct
* cbs
)
1669 wxWindow
*canvas
= wxGetWindowFromTable(drawingArea
);
1675 if (cbs
->reason
!= XmCR_INPUT
)
1678 local_event
= *(cbs
->event
); // We must keep a copy!
1680 switch (local_event
.xany
.type
)
1688 // FIXME: most of this mouse event code is more or less
1689 // duplicated in wxTranslateMouseEvent
1691 wxEventType eventType
= wxEVT_NULL
;
1693 if (local_event
.xany
.type
== EnterNotify
)
1695 //if (local_event.xcrossing.mode!=NotifyNormal)
1696 // return ; // Ignore grab events
1697 eventType
= wxEVT_ENTER_WINDOW
;
1698 // canvas->GetEventHandler()->OnSetFocus();
1700 else if (local_event
.xany
.type
== LeaveNotify
)
1702 //if (local_event.xcrossingr.mode!=NotifyNormal)
1703 // return ; // Ignore grab events
1704 eventType
= wxEVT_LEAVE_WINDOW
;
1705 // canvas->GetEventHandler()->OnKillFocus();
1707 else if (local_event
.xany
.type
== MotionNotify
)
1709 eventType
= wxEVT_MOTION
;
1712 else if (local_event
.xany
.type
== ButtonPress
)
1714 if (local_event
.xbutton
.button
== Button1
)
1716 eventType
= wxEVT_LEFT_DOWN
;
1717 canvas
->SetButton1(TRUE
);
1719 else if (local_event
.xbutton
.button
== Button2
)
1721 eventType
= wxEVT_MIDDLE_DOWN
;
1722 canvas
->SetButton2(TRUE
);
1724 else if (local_event
.xbutton
.button
== Button3
)
1726 eventType
= wxEVT_RIGHT_DOWN
;
1727 canvas
->SetButton3(TRUE
);
1730 else if (local_event
.xany
.type
== ButtonRelease
)
1732 if (local_event
.xbutton
.button
== Button1
)
1734 eventType
= wxEVT_LEFT_UP
;
1735 canvas
->SetButton1(FALSE
);
1737 else if (local_event
.xbutton
.button
== Button2
)
1739 eventType
= wxEVT_MIDDLE_UP
;
1740 canvas
->SetButton2(FALSE
);
1742 else if (local_event
.xbutton
.button
== Button3
)
1744 eventType
= wxEVT_RIGHT_UP
;
1745 canvas
->SetButton3(FALSE
);
1749 wxMouseEvent
wxevent (eventType
);
1751 wxevent
.m_leftDown
= ((eventType
== wxEVT_LEFT_DOWN
)
1752 || (event_left_is_down (&local_event
)
1753 && (eventType
!= wxEVT_LEFT_UP
)));
1754 wxevent
.m_middleDown
= ((eventType
== wxEVT_MIDDLE_DOWN
)
1755 || (event_middle_is_down (&local_event
)
1756 && (eventType
!= wxEVT_MIDDLE_UP
)));
1757 wxevent
.m_rightDown
= ((eventType
== wxEVT_RIGHT_DOWN
)
1758 || (event_right_is_down (&local_event
)
1759 && (eventType
!= wxEVT_RIGHT_UP
)));
1761 wxevent
.m_shiftDown
= local_event
.xbutton
.state
& ShiftMask
;
1762 wxevent
.m_controlDown
= local_event
.xbutton
.state
& ControlMask
;
1763 wxevent
.m_altDown
= local_event
.xbutton
.state
& Mod3Mask
;
1764 wxevent
.m_metaDown
= local_event
.xbutton
.state
& Mod1Mask
;
1765 wxevent
.SetTimestamp(local_event
.xbutton
.time
);
1767 if ( eventType
== wxEVT_MOTION
)
1769 if (local_event
.xmotion
.is_hint
== NotifyHint
)
1772 Display
*dpy
= XtDisplay (drawingArea
);
1774 XQueryPointer (dpy
, XtWindow (drawingArea
),
1776 &local_event
.xmotion
.x_root
,
1777 &local_event
.xmotion
.y_root
,
1778 &local_event
.xmotion
.x
,
1779 &local_event
.xmotion
.y
,
1780 &local_event
.xmotion
.state
);
1787 // Now check if we need to translate this event into a double click
1788 if (TRUE
) // canvas->doubleClickAllowed)
1790 if (wxevent
.ButtonDown())
1792 long dclickTime
= XtGetMultiClickTime((Display
*) wxGetDisplay());
1794 // get button and time-stamp
1796 if (wxevent
.LeftDown())
1798 else if (wxevent
.MiddleDown())
1800 else if (wxevent
.RightDown())
1802 long ts
= wxevent
.GetTimestamp();
1804 // check, if single or double click
1805 int buttonLast
= canvas
->GetLastClickedButton();
1806 long lastTS
= canvas
->GetLastClickTime();
1807 if ( buttonLast
&& buttonLast
== button
&& (ts
- lastTS
) < dclickTime
)
1810 canvas
->SetLastClick(0, ts
);
1812 wxEventType typeDouble
;
1813 if ( eventType
== wxEVT_LEFT_DOWN
)
1814 typeDouble
= wxEVT_LEFT_DCLICK
;
1815 else if ( eventType
== wxEVT_MIDDLE_DOWN
)
1816 typeDouble
= wxEVT_MIDDLE_DCLICK
;
1817 else if ( eventType
== wxEVT_RIGHT_DOWN
)
1818 typeDouble
= wxEVT_RIGHT_DCLICK
;
1820 typeDouble
= wxEVT_NULL
;
1822 if ( typeDouble
!= wxEVT_NULL
)
1824 wxevent
.SetEventType(typeDouble
);
1829 // not fast enough or different button
1830 canvas
->SetLastClick(button
, ts
);
1835 wxevent
.SetId(canvas
->GetId());
1836 wxevent
.SetEventObject(canvas
);
1837 wxevent
.m_x
= local_event
.xbutton
.x
;
1838 wxevent
.m_y
= local_event
.xbutton
.y
;
1839 canvas
->GetEventHandler()->ProcessEvent (wxevent
);
1841 if (eventType
== wxEVT_ENTER_WINDOW
||
1842 eventType
== wxEVT_LEAVE_WINDOW
||
1843 eventType
== wxEVT_MOTION
1853 XComposeStatus compose
;
1854 (void) XLookupString ((XKeyEvent
*) & local_event
, wxBuffer
, 20, &keySym
, &compose
);
1857 (void) XLookupString ((XKeyEvent
*) & local_event
, wxBuffer
, 20, &keySym
, NULL
);
1858 int id
= wxCharCodeXToWX (keySym
);
1860 wxEventType eventType
= wxEVT_CHAR
;
1862 wxKeyEvent
event (eventType
);
1864 if (local_event
.xkey
.state
& ShiftMask
)
1865 event
.m_shiftDown
= TRUE
;
1866 if (local_event
.xkey
.state
& ControlMask
)
1867 event
.m_controlDown
= TRUE
;
1868 if (local_event
.xkey
.state
& Mod3Mask
)
1869 event
.m_altDown
= TRUE
;
1870 if (local_event
.xkey
.state
& Mod1Mask
)
1871 event
.m_metaDown
= TRUE
;
1872 event
.SetEventObject(canvas
);
1873 event
.m_keyCode
= id
;
1874 event
.SetTimestamp(local_event
.xkey
.time
);
1878 // Implement wxFrame::OnCharHook by checking ancestor.
1879 wxWindow
*parent
= canvas
->GetParent();
1880 while (parent
&& !parent
->IsKindOf(CLASSINFO(wxFrame
)))
1881 parent
= parent
->GetParent();
1885 event
.SetEventType(wxEVT_CHAR_HOOK
);
1886 if (parent
->GetEventHandler()->ProcessEvent(event
))
1890 // For simplicity, OnKeyDown is the same as OnChar
1891 // TODO: filter modifier key presses from OnChar
1892 event
.SetEventType(wxEVT_KEY_DOWN
);
1894 // Only process OnChar if OnKeyDown didn't swallow it
1895 if (!canvas
->GetEventHandler()->ProcessEvent (event
))
1897 event
.SetEventType(wxEVT_CHAR
);
1898 canvas
->GetEventHandler()->ProcessEvent (event
);
1906 (void) XLookupString ((XKeyEvent
*) & local_event
, wxBuffer
, 20, &keySym
, NULL
);
1907 int id
= wxCharCodeXToWX (keySym
);
1909 wxKeyEvent
event (wxEVT_KEY_UP
);
1911 if (local_event
.xkey
.state
& ShiftMask
)
1912 event
.m_shiftDown
= TRUE
;
1913 if (local_event
.xkey
.state
& ControlMask
)
1914 event
.m_controlDown
= TRUE
;
1915 if (local_event
.xkey
.state
& Mod3Mask
)
1916 event
.m_altDown
= TRUE
;
1917 if (local_event
.xkey
.state
& Mod1Mask
)
1918 event
.m_metaDown
= TRUE
;
1919 event
.SetEventObject(canvas
);
1920 event
.m_keyCode
= id
;
1921 event
.SetTimestamp(local_event
.xkey
.time
);
1925 canvas
->GetEventHandler()->ProcessEvent (event
);
1931 if (local_event
.xfocus
.detail
!= NotifyPointer
)
1933 wxFocusEvent
event(wxEVT_SET_FOCUS
, canvas
->GetId());
1934 event
.SetEventObject(canvas
);
1935 canvas
->GetEventHandler()->ProcessEvent(event
);
1941 if (local_event
.xfocus
.detail
!= NotifyPointer
)
1943 wxFocusEvent
event(wxEVT_KILL_FOCUS
, canvas
->GetId());
1944 event
.SetEventObject(canvas
);
1945 canvas
->GetEventHandler()->ProcessEvent(event
);
1954 static void wxPanelItemEventHandler(Widget wid
,
1955 XtPointer
WXUNUSED(client_data
),
1957 Boolean
*continueToDispatch
)
1959 // Widget can be a label or the actual widget.
1961 wxWindow
*window
= wxGetWindowFromTable(wid
);
1964 wxMouseEvent
wxevent(0);
1965 if (wxTranslateMouseEvent(wxevent
, window
, wid
, event
))
1967 window
->GetEventHandler()->ProcessEvent(wxevent
);
1971 // TODO: probably the key to allowing default behaviour to happen. Say we
1972 // set a m_doDefault flag to FALSE at the start of this function. Then in
1973 // e.g. wxWindowX11::OnMouseEvent we can call Default() which sets this flag to
1974 // TRUE, indicating that default processing can happen. Thus, behaviour can
1975 // appear to be overridden just by adding an event handler and not calling
1976 // wxWindowX11::OnWhatever. ALSO, maybe we can use this instead of the current
1977 // way of handling drawing area events, to simplify things.
1978 *continueToDispatch
= True
;
1981 static void wxScrollBarCallback(Widget scrollbar
,
1982 XtPointer clientData
,
1983 XmScrollBarCallbackStruct
*cbs
)
1985 wxWindow
*win
= wxGetWindowFromTable(scrollbar
);
1986 int orientation
= (int) clientData
;
1988 wxEventType eventType
= wxEVT_NULL
;
1989 switch (cbs
->reason
)
1991 case XmCR_INCREMENT
:
1993 eventType
= wxEVT_SCROLLWIN_LINEDOWN
;
1996 case XmCR_DECREMENT
:
1998 eventType
= wxEVT_SCROLLWIN_LINEUP
;
2003 eventType
= wxEVT_SCROLLWIN_THUMBTRACK
;
2006 case XmCR_VALUE_CHANGED
:
2008 eventType
= wxEVT_SCROLLWIN_THUMBRELEASE
;
2011 case XmCR_PAGE_INCREMENT
:
2013 eventType
= wxEVT_SCROLLWIN_PAGEDOWN
;
2016 case XmCR_PAGE_DECREMENT
:
2018 eventType
= wxEVT_SCROLLWIN_PAGEUP
;
2023 eventType
= wxEVT_SCROLLWIN_TOP
;
2026 case XmCR_TO_BOTTOM
:
2028 eventType
= wxEVT_SCROLLWIN_BOTTOM
;
2033 // Should never get here
2034 wxFAIL_MSG("Unknown scroll event.");
2039 wxScrollWinEvent
event(eventType
,
2041 ((orientation
== XmHORIZONTAL
) ?
2042 wxHORIZONTAL
: wxVERTICAL
));
2043 event
.SetEventObject( win
);
2044 win
->GetEventHandler()->ProcessEvent(event
);
2047 // For repainting arbitrary windows
2048 void wxUniversalRepaintProc(Widget w
, XtPointer
WXUNUSED(c_data
), XEvent
*event
, char *)
2053 wxWindow
* win
= wxGetWindowFromTable(w
);
2057 switch(event
-> type
)
2061 window
= (Window
) win
-> GetXWindow();
2062 display
= (Display
*) win
-> GetXDisplay();
2064 if (event
-> xexpose
.count
== 0)
2068 win
->ClearUpdateRects();
2072 win
->AddUpdateRect(event
->xexpose
.x
, event
->xexpose
.y
,
2073 event
->xexpose
.width
, event
->xexpose
.height
);
2084 // ----------------------------------------------------------------------------
2085 // CanvaseXXXSize() functions
2086 // ----------------------------------------------------------------------------
2088 // SetSize, but as per old wxCanvas (with drawing widget etc.)
2089 void wxWindowX11::CanvasSetSize (int x
, int y
, int w
, int h
, int sizeFlags
)
2093 // A bit of optimization to help sort out the flickers.
2094 int oldX
, oldY
, oldW
, oldH
;
2095 GetSize(& oldW
, & oldH
);
2096 GetPosition(& oldX
, & oldY
);
2098 bool useOldPos
= FALSE
;
2099 bool useOldSize
= FALSE
;
2101 if ((x
== -1) && (x
== -1) && ((sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
) == 0))
2103 else if (x
== oldX
&& y
== oldY
)
2106 if ((w
== -1) && (h
== -1))
2108 else if (w
== oldW
&& h
== oldH
)
2111 if (!wxNoOptimize::CanOptimize())
2113 useOldSize
= FALSE
; useOldPos
= FALSE
;
2116 if (useOldPos
&& useOldSize
)
2119 Widget drawingArea
= (Widget
) m_drawingArea
;
2120 bool managed
= XtIsManaged(m_borderWidget
? (Widget
) m_borderWidget
: (Widget
) m_scrolledWindow
);
2123 XtUnmanageChild (m_borderWidget
? (Widget
) m_borderWidget
: (Widget
) m_scrolledWindow
);
2124 XtVaSetValues(drawingArea
, XmNresizePolicy
, XmRESIZE_ANY
, NULL
);
2126 int xx
= x
; int yy
= y
;
2127 AdjustForParentClientOrigin(xx
, yy
, sizeFlags
);
2131 if (x
> -1 || (sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
2133 XtVaSetValues (m_borderWidget
? (Widget
) m_borderWidget
: (Widget
) m_scrolledWindow
,
2137 if (y
> -1 || (sizeFlags
& wxSIZE_ALLOW_MINUS_ONE
))
2139 XtVaSetValues (m_borderWidget
? (Widget
) m_borderWidget
: (Widget
) m_scrolledWindow
,
2151 XtVaSetValues ((Widget
) m_borderWidget
, XmNwidth
, w
, NULL
);
2152 short thick
, margin
;
2153 XtVaGetValues ((Widget
) m_borderWidget
,
2154 XmNshadowThickness
, &thick
,
2155 XmNmarginWidth
, &margin
,
2157 w
-= 2 * (thick
+ margin
);
2160 XtVaSetValues ((Widget
) m_scrolledWindow
, XmNwidth
, w
, NULL
);
2164 XtVaGetValues ((Widget
) m_scrolledWindow
,
2165 XmNspacing
, &spacing
,
2166 XmNverticalScrollBar
, &sbar
,
2170 XtVaGetValues (sbar
, XmNwidth
, &wsbar
, NULL
);
2174 w
-= (spacing
+ wsbar
);
2177 XtVaSetValues(drawingArea
, XmNwidth
, w
, NULL
);
2184 XtVaSetValues ((Widget
) m_borderWidget
, XmNheight
, h
, NULL
);
2185 short thick
, margin
;
2186 XtVaGetValues ((Widget
) m_borderWidget
,
2187 XmNshadowThickness
, &thick
,
2188 XmNmarginHeight
, &margin
,
2190 h
-= 2 * (thick
+ margin
);
2193 XtVaSetValues ((Widget
) m_scrolledWindow
, XmNheight
, h
, NULL
);
2197 XtVaGetValues ((Widget
) m_scrolledWindow
,
2198 XmNspacing
, &spacing
,
2199 XmNhorizontalScrollBar
, &sbar
,
2203 XtVaGetValues (sbar
, XmNheight
, &wsbar
, NULL
);
2207 h
-= (spacing
+ wsbar
);
2210 XtVaSetValues(drawingArea
, XmNheight
, h
, NULL
);
2216 XtManageChild (m_borderWidget
? (Widget
) m_borderWidget
: (Widget
) m_scrolledWindow
);
2217 XtVaSetValues(drawingArea
, XmNresizePolicy
, XmRESIZE_NONE
, NULL
);
2222 void wxWindowX11::CanvasSetClientSize (int w
, int h
)
2226 Widget drawingArea
= (Widget
) m_drawingArea
;
2228 XtVaSetValues(drawingArea
, XmNresizePolicy
, XmRESIZE_ANY
, NULL
);
2231 XtVaSetValues(drawingArea
, XmNwidth
, w
, NULL
);
2233 XtVaSetValues(drawingArea
, XmNheight
, h
, NULL
);
2235 XtVaSetValues(drawingArea
, XmNresizePolicy
, XmRESIZE_NONE
, NULL
);
2239 void wxWindowX11::CanvasGetClientSize (int *w
, int *h
) const
2243 // Must return the same thing that was set via SetClientSize
2245 XtVaGetValues ((Widget
) m_drawingArea
, XmNwidth
, &xx
, XmNheight
, &yy
, NULL
);
2251 void wxWindowX11::CanvasGetSize (int *w
, int *h
) const
2256 if ((Widget
) m_borderWidget
)
2257 XtVaGetValues ((Widget
) m_borderWidget
, XmNwidth
, &xx
, XmNheight
, &yy
, NULL
);
2258 else if ((Widget
) m_scrolledWindow
)
2259 XtVaGetValues ((Widget
) m_scrolledWindow
, XmNwidth
, &xx
, XmNheight
, &yy
, NULL
);
2261 XtVaGetValues ((Widget
) m_drawingArea
, XmNwidth
, &xx
, XmNheight
, &yy
, NULL
);
2268 void wxWindowX11::CanvasGetPosition (int *x
, int *y
) const
2273 XtVaGetValues (m_borderWidget
? (Widget
) m_borderWidget
: (Widget
) m_scrolledWindow
, XmNx
, &xx
, XmNy
, &yy
, NULL
);
2275 // We may be faking the client origin.
2276 // So a window that's really at (0, 30) may appear
2277 // (to wxWin apps) to be at (0, 0).
2280 wxPoint
pt(GetParent()->GetClientAreaOrigin());
2290 // ----------------------------------------------------------------------------
2291 // TranslateXXXEvent() functions
2292 // ----------------------------------------------------------------------------
2294 bool wxTranslateMouseEvent(wxMouseEvent
& wxevent
, wxWindow
*win
, Widget widget
, XEvent
*xevent
)
2298 switch (xevent
->xany
.type
)
2300 case EnterNotify
: // never received here - yes ? MB
2301 case LeaveNotify
: // never received here - yes ? MB
2306 wxEventType eventType
= wxEVT_NULL
;
2308 // FIXME: this is never true I think - MB
2310 if (xevent
->xany
.type
== LeaveNotify
)
2312 win
->SetButton1(FALSE
);
2313 win
->SetButton2(FALSE
);
2314 win
->SetButton3(FALSE
);
2317 else if (xevent
->xany
.type
== MotionNotify
)
2319 eventType
= wxEVT_MOTION
;
2321 else if (xevent
->xany
.type
== ButtonPress
)
2323 wxevent
.SetTimestamp(xevent
->xbutton
.time
);
2325 if (xevent
->xbutton
.button
== Button1
)
2327 eventType
= wxEVT_LEFT_DOWN
;
2328 win
->SetButton1(TRUE
);
2331 else if (xevent
->xbutton
.button
== Button2
)
2333 eventType
= wxEVT_MIDDLE_DOWN
;
2334 win
->SetButton2(TRUE
);
2337 else if (xevent
->xbutton
.button
== Button3
)
2339 eventType
= wxEVT_RIGHT_DOWN
;
2340 win
->SetButton3(TRUE
);
2344 // check for a double click
2346 long dclickTime
= XtGetMultiClickTime((Display
*) wxGetDisplay());
2347 long ts
= wxevent
.GetTimestamp();
2349 int buttonLast
= win
->GetLastClickedButton();
2350 long lastTS
= win
->GetLastClickTime();
2351 if ( buttonLast
&& buttonLast
== button
&& (ts
- lastTS
) < dclickTime
)
2354 win
->SetLastClick(0, ts
);
2355 if ( eventType
== wxEVT_LEFT_DOWN
)
2356 eventType
= wxEVT_LEFT_DCLICK
;
2357 else if ( eventType
== wxEVT_MIDDLE_DOWN
)
2358 eventType
= wxEVT_MIDDLE_DCLICK
;
2359 else if ( eventType
== wxEVT_RIGHT_DOWN
)
2360 eventType
= wxEVT_RIGHT_DCLICK
;
2364 // not fast enough or different button
2365 win
->SetLastClick(button
, ts
);
2368 else if (xevent
->xany
.type
== ButtonRelease
)
2370 if (xevent
->xbutton
.button
== Button1
)
2372 eventType
= wxEVT_LEFT_UP
;
2373 win
->SetButton1(FALSE
);
2375 else if (xevent
->xbutton
.button
== Button2
)
2377 eventType
= wxEVT_MIDDLE_UP
;
2378 win
->SetButton2(FALSE
);
2380 else if (xevent
->xbutton
.button
== Button3
)
2382 eventType
= wxEVT_RIGHT_UP
;
2383 win
->SetButton3(FALSE
);
2392 wxevent
.SetEventType(eventType
);
2395 XtVaGetValues(widget
, XmNx
, &x1
, XmNy
, &y1
, NULL
);
2398 win
->GetPosition(&x2
, &y2
);
2400 // The button x/y must be translated to wxWindows
2401 // window space - the widget might be a label or button,
2405 if (widget
!= (Widget
)win
->GetMainWidget())
2411 wxevent
.m_x
= xevent
->xbutton
.x
+ dx
;
2412 wxevent
.m_y
= xevent
->xbutton
.y
+ dy
;
2414 wxevent
.m_leftDown
= ((eventType
== wxEVT_LEFT_DOWN
)
2415 || (event_left_is_down (xevent
)
2416 && (eventType
!= wxEVT_LEFT_UP
)));
2417 wxevent
.m_middleDown
= ((eventType
== wxEVT_MIDDLE_DOWN
)
2418 || (event_middle_is_down (xevent
)
2419 && (eventType
!= wxEVT_MIDDLE_UP
)));
2420 wxevent
.m_rightDown
= ((eventType
== wxEVT_RIGHT_DOWN
)
2421 || (event_right_is_down (xevent
)
2422 && (eventType
!= wxEVT_RIGHT_UP
)));
2424 wxevent
.m_shiftDown
= xevent
->xbutton
.state
& ShiftMask
;
2425 wxevent
.m_controlDown
= xevent
->xbutton
.state
& ControlMask
;
2426 wxevent
.m_altDown
= xevent
->xbutton
.state
& Mod3Mask
;
2427 wxevent
.m_metaDown
= xevent
->xbutton
.state
& Mod1Mask
;
2429 wxevent
.SetId(win
->GetId());
2430 wxevent
.SetEventObject(win
);
2439 bool wxTranslateKeyEvent(wxKeyEvent
& wxevent
, wxWindow
*win
, Window
WXUNUSED(win
), XEvent
*xevent
)
2441 switch (xevent
->xany
.type
)
2449 (void) XLookupString ((XKeyEvent
*) xevent
, buf
, 20, &keySym
, NULL
);
2450 int id
= wxCharCodeXToWX (keySym
);
2452 if (xevent
->xkey
.state
& ShiftMask
)
2453 wxevent
.m_shiftDown
= TRUE
;
2454 if (xevent
->xkey
.state
& ControlMask
)
2455 wxevent
.m_controlDown
= TRUE
;
2456 if (xevent
->xkey
.state
& Mod3Mask
)
2457 wxevent
.m_altDown
= TRUE
;
2458 if (xevent
->xkey
.state
& Mod1Mask
)
2459 wxevent
.m_metaDown
= TRUE
;
2460 wxevent
.SetEventObject(win
);
2461 wxevent
.m_keyCode
= id
;
2462 wxevent
.SetTimestamp(xevent
->xkey
.time
);
2464 wxevent
.m_x
= xevent
->xbutton
.x
;
2465 wxevent
.m_y
= xevent
->xbutton
.y
;
2479 // ----------------------------------------------------------------------------
2481 // ----------------------------------------------------------------------------
2485 #define YAllocColor XAllocColor
2486 XColor g_itemColors
[5];
2487 int wxComputeColours (Display
*display
, wxColour
* back
, wxColour
* fore
)
2490 static XmColorProc colorProc
;
2492 result
= wxNO_COLORS
;
2496 g_itemColors
[0].red
= (((long) back
->Red ()) << 8);
2497 g_itemColors
[0].green
= (((long) back
->Green ()) << 8);
2498 g_itemColors
[0].blue
= (((long) back
->Blue ()) << 8);
2499 g_itemColors
[0].flags
= DoRed
| DoGreen
| DoBlue
;
2500 if (colorProc
== (XmColorProc
) NULL
)
2502 // Get a ptr to the actual function
2503 colorProc
= XmSetColorCalculation ((XmColorProc
) NULL
);
2504 // And set it back to motif.
2505 XmSetColorCalculation (colorProc
);
2507 (*colorProc
) (&g_itemColors
[wxBACK_INDEX
],
2508 &g_itemColors
[wxFORE_INDEX
],
2509 &g_itemColors
[wxSELE_INDEX
],
2510 &g_itemColors
[wxTOPS_INDEX
],
2511 &g_itemColors
[wxBOTS_INDEX
]);
2512 result
= wxBACK_COLORS
;
2516 g_itemColors
[wxFORE_INDEX
].red
= (((long) fore
->Red ()) << 8);
2517 g_itemColors
[wxFORE_INDEX
].green
= (((long) fore
->Green ()) << 8);
2518 g_itemColors
[wxFORE_INDEX
].blue
= (((long) fore
->Blue ()) << 8);
2519 g_itemColors
[wxFORE_INDEX
].flags
= DoRed
| DoGreen
| DoBlue
;
2520 if (result
== wxNO_COLORS
)
2521 result
= wxFORE_COLORS
;
2524 Display
*dpy
= display
;
2525 Colormap cmap
= (Colormap
) wxTheApp
->GetMainColormap((WXDisplay
*) dpy
);
2529 /* 5 Colours to allocate */
2530 for (int i
= 0; i
< 5; i
++)
2531 if (!YAllocColor (dpy
, cmap
, &g_itemColors
[i
]))
2532 result
= wxNO_COLORS
;
2536 /* Only 1 colour to allocate */
2537 if (!YAllocColor (dpy
, cmap
, &g_itemColors
[wxFORE_INDEX
]))
2538 result
= wxNO_COLORS
;
2546 // Changes the foreground and background colours to be derived from the current
2547 // background colour. To change the foreground colour, you must call
2548 // SetForegroundColour explicitly.
2549 void wxWindowX11::ChangeBackgroundColour()
2553 WXWidget mainWidget
= GetMainWidget();
2555 DoChangeBackgroundColour(mainWidget
, m_backgroundColour
);
2559 void wxWindowX11::ChangeForegroundColour()
2563 WXWidget mainWidget
= GetMainWidget();
2565 DoChangeForegroundColour(mainWidget
, m_foregroundColour
);
2566 if ( m_scrolledWindow
&& mainWidget
!= m_scrolledWindow
)
2567 DoChangeForegroundColour(m_scrolledWindow
, m_foregroundColour
);
2571 // Change a widget's foreground and background colours.
2572 void wxWindowX11::DoChangeForegroundColour(WXWindow widget
, wxColour
& foregroundColour
)
2576 // When should we specify the foreground, if it's calculated
2577 // by wxComputeColours?
2578 // Solution: say we start with the default (computed) foreground colour.
2579 // If we call SetForegroundColour explicitly for a control or window,
2580 // then the foreground is changed.
2581 // Therefore SetBackgroundColour computes the foreground colour, and
2582 // SetForegroundColour changes the foreground colour. The ordering is
2585 Widget w
= (Widget
)widget
;
2588 XmNforeground
, foregroundColour
.AllocColour(XtDisplay(w
)),
2594 void wxWindowX11::DoChangeBackgroundColour(WXWindow widget
, wxColour
& backgroundColour
, bool changeArmColour
)
2598 wxComputeColours (XtDisplay((Widget
) widget
), & backgroundColour
,
2601 XtVaSetValues ((Widget
) widget
,
2602 XmNbackground
, g_itemColors
[wxBACK_INDEX
].pixel
,
2603 XmNtopShadowColor
, g_itemColors
[wxTOPS_INDEX
].pixel
,
2604 XmNbottomShadowColor
, g_itemColors
[wxBOTS_INDEX
].pixel
,
2605 XmNforeground
, g_itemColors
[wxFORE_INDEX
].pixel
,
2608 if (changeArmColour
)
2609 XtVaSetValues ((Widget
) widget
,
2610 XmNarmColor
, g_itemColors
[wxSELE_INDEX
].pixel
,
2615 bool wxWindowX11::SetBackgroundColour(const wxColour
& col
)
2617 if ( !wxWindowBase::SetBackgroundColour(col
) )
2620 ChangeBackgroundColour();
2625 bool wxWindowX11::SetForegroundColour(const wxColour
& col
)
2627 if ( !wxWindowBase::SetForegroundColour(col
) )
2630 ChangeForegroundColour();
2635 void wxWindowX11::ChangeFont(bool keepOriginalSize
)
2639 // Note that this causes the widget to be resized back
2640 // to its original size! We therefore have to set the size
2641 // back again. TODO: a better way in Motif?
2642 Widget w
= (Widget
) GetLabelWidget(); // Usually the main widget
2643 if (w
&& m_font
.Ok())
2645 int width
, height
, width1
, height1
;
2646 GetSize(& width
, & height
);
2648 // lesstif 0.87 hangs here
2649 #ifndef LESSTIF_VERSION
2651 XmNfontList
, (XmFontList
) m_font
.GetFontList(1.0, XtDisplay(w
)),
2655 GetSize(& width1
, & height1
);
2656 if (keepOriginalSize
&& (width
!= width1
|| height
!= height1
))
2658 SetSize(-1, -1, width
, height
);
2664 // ----------------------------------------------------------------------------
2666 // ----------------------------------------------------------------------------
2668 wxWindow
*wxGetActiveWindow()
2671 wxFAIL_MSG("Not implemented");
2676 wxWindow
*wxWindowBase::GetCapture()
2678 return (wxWindow
*)g_captureWindow
;
2682 // Find the wxWindow at the current mouse position, returning the mouse
2684 wxWindow
* wxFindWindowAtPointer(wxPoint
& pt
)
2686 return wxFindWindowAtPoint(wxGetMousePosition());
2689 // Get the current mouse position.
2690 wxPoint
wxGetMousePosition()
2692 Display
*display
= (Display
*) wxGetDisplay();
2693 Window rootWindow
= RootWindowOfScreen (DefaultScreenOfDisplay(display
));
2694 Window rootReturn
, childReturn
;
2695 int rootX
, rootY
, winX
, winY
;
2696 unsigned int maskReturn
;
2698 XQueryPointer (display
,
2702 &rootX
, &rootY
, &winX
, &winY
, &maskReturn
);
2703 return wxPoint(rootX
, rootY
);
2707 // ----------------------------------------------------------------------------
2708 // wxNoOptimize: switch off size optimization
2709 // ----------------------------------------------------------------------------
2711 int wxNoOptimize::ms_count
= 0;