1 /////////////////////////////////////////////////////////////////////////////
2 // Name: motif/frame.cpp
4 // Author: Julian Smart
8 // Copyright: (c) Julian Smart
9 // Licence: wxWindows licence
10 /////////////////////////////////////////////////////////////////////////////
12 // ============================================================================
14 // ============================================================================
16 // ----------------------------------------------------------------------------
18 // ----------------------------------------------------------------------------
21 #pragma implementation "frame.h"
26 #define XtDisplay XTDISPLAY
27 #define XtWindow XTWINDOW
28 #define XtScreen XTSCREEN
31 # include "wx/frame.h"
32 #include "wx/statusbr.h"
33 #include "wx/toolbar.h"
34 #include "wx/menuitem.h"
36 #include "wx/dcclient.h"
37 #include "wx/dialog.h"
38 #include "wx/settings.h"
44 #pragma message disable nosimpint
47 #if defined(__ultrix) || defined(__sgi)
52 #include <X11/Shell.h>
59 #include <Xm/MwmUtil.h>
60 #include <Xm/BulletinB.h>
63 #include <Xm/RowColumn.h>
65 #include <Xm/AtomMgr.h>
66 #include <Xm/LabelG.h>
69 #include <Xm/Protocols.h>
73 #pragma message enable nosimpint
76 #include "wx/motif/private.h"
77 #include "wx/unix/utilsx11.h"
79 // ----------------------------------------------------------------------------
81 // ----------------------------------------------------------------------------
83 static void wxFrameEventHandler(Widget wid
,
84 XtPointer
WXUNUSED(client_data
),
86 Boolean
* continueToDispatch
);
87 static void wxCloseFrameCallback(Widget
, XtPointer
, XmAnyCallbackStruct
*cbs
);
88 static void wxFrameFocusProc(Widget workArea
, XtPointer clientData
,
89 XmAnyCallbackStruct
*cbs
);
90 static void wxFrameMapProc(Widget frameShell
, XtPointer clientData
,
91 XCrossingEvent
* event
);
93 // ----------------------------------------------------------------------------
95 // ----------------------------------------------------------------------------
97 extern wxList wxModelessWindows
;
98 extern wxList wxPendingDelete
;
100 // TODO: this should be tidied so that any frame can be the
102 static bool wxTopLevelUsed
= FALSE
;
104 // ----------------------------------------------------------------------------
106 // ----------------------------------------------------------------------------
108 BEGIN_EVENT_TABLE(wxFrame
, wxFrameBase
)
109 EVT_ACTIVATE(wxFrame::OnActivate
)
110 EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged
)
113 IMPLEMENT_DYNAMIC_CLASS(wxFrame
, wxWindow
)
115 // ============================================================================
117 // ============================================================================
119 // ----------------------------------------------------------------------------
120 // frame construction
121 // ----------------------------------------------------------------------------
128 m_frameShell
= (WXWidget
) NULL
;
129 m_frameWidget
= (WXWidget
) NULL
;;
130 m_workArea
= (WXWidget
) NULL
;;
131 m_clientArea
= (WXWidget
) NULL
;;
132 m_visibleStatus
= TRUE
;
135 bool wxFrame::Create(wxWindow
*parent
,
137 const wxString
& title
,
141 const wxString
& name
)
144 parent
->AddChild(this);
146 wxTopLevelWindows
.Append(this);
148 wxModelessWindows
.Append(this);
152 m_windowStyle
= style
;
154 m_backgroundColour
= wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
);
155 m_foregroundColour
= *wxBLACK
;
156 m_font
= wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
);
161 m_windowId
= (int)NewControlId();
163 int x
= pos
.x
, y
= pos
.y
;
164 int width
= size
.x
, height
= size
.y
;
166 // Set reasonable values for position and size if defaults have been
169 // MB TODO: something better than these arbitrary values ?
170 // VZ should use X resources for this...
176 int displayW
, displayH
;
177 wxDisplaySize( &displayW
, &displayH
);
181 x
= (displayW
- width
) / 2;
186 y
= (displayH
- height
) / 2;
190 // VZ: what does this do??
193 // Change suggested by Matthew Flatt
194 m_frameShell
= (WXWidget
)XtAppCreateShell
197 wxTheApp
->GetClassName(),
198 topLevelShellWidgetClass
,
199 (Display
*) wxGetDisplay(),
206 m_frameShell
= wxTheApp
->GetTopLevelWidget();
207 wxTopLevelUsed
= TRUE
;
210 XtVaSetValues((Widget
) m_frameShell
,
211 // Allows menu to resize
212 XmNallowShellResize
, True
,
213 XmNdeleteResponse
, XmDO_NOTHING
,
214 XmNmappedWhenManaged
, False
,
215 XmNiconic
, (style
& wxICONIZE
) ? TRUE
: FALSE
,
218 if (!title
.IsEmpty())
219 XtVaSetValues((Widget
) m_frameShell
,
220 XmNtitle
, title
.c_str(),
223 m_frameWidget
= (WXWidget
) XtVaCreateManagedWidget("main_window",
224 xmMainWindowWidgetClass
, (Widget
) m_frameShell
,
225 XmNresizePolicy
, XmRESIZE_NONE
,
228 m_workArea
= (WXWidget
) XtVaCreateWidget("form",
229 xmFormWidgetClass
, (Widget
) m_frameWidget
,
230 XmNresizePolicy
, XmRESIZE_NONE
,
233 m_clientArea
= (WXWidget
) XtVaCreateWidget("client",
234 xmBulletinBoardWidgetClass
, (Widget
) m_workArea
,
237 XmNrightAttachment
, XmATTACH_FORM
,
238 XmNleftAttachment
, XmATTACH_FORM
,
239 XmNtopAttachment
, XmATTACH_FORM
,
240 XmNbottomAttachment
, XmATTACH_FORM
,
241 // XmNresizePolicy, XmRESIZE_ANY,
244 wxLogTrace(wxTRACE_Messages
,
245 "Created frame (0x%08x) with work area 0x%08x and client "
246 "area 0x%08x", m_frameWidget
, m_workArea
, m_clientArea
);
248 XtAddEventHandler((Widget
) m_clientArea
, ExposureMask
,FALSE
,
249 wxUniversalRepaintProc
, (XtPointer
) this);
251 XtAddEventHandler((Widget
) m_clientArea
,
252 ButtonPressMask
| ButtonReleaseMask
| PointerMotionMask
| KeyPressMask
,
257 XtVaSetValues((Widget
) m_frameWidget
,
258 XmNworkWindow
, (Widget
) m_workArea
,
261 XtManageChild((Widget
) m_clientArea
);
262 XtManageChild((Widget
) m_workArea
);
264 wxAddWindowToTable((Widget
) m_workArea
, this);
265 wxAddWindowToTable((Widget
) m_clientArea
, this);
269 XtOverrideTranslations((Widget
) m_workArea
,
270 ptr
= XtParseTranslationTable("<Configure>: resize()"));
274 XtAddCallback((Widget
) m_workArea
, XmNfocusCallback
,
275 (XtCallbackProc
)wxFrameFocusProc
, (XtPointer
)this);
277 /* Part of show-&-hide fix */
278 XtAddEventHandler((Widget
) m_frameShell
, StructureNotifyMask
,
279 False
, (XtEventHandler
)wxFrameMapProc
,
280 (XtPointer
)m_workArea
);
283 XtVaSetValues((Widget
) m_frameShell
, XmNx
, x
, NULL
);
285 XtVaSetValues((Widget
) m_frameShell
, XmNy
, y
, NULL
);
287 XtVaSetValues((Widget
) m_frameShell
, XmNwidth
, width
, NULL
);
289 XtVaSetValues((Widget
) m_frameShell
, XmNheight
, height
, NULL
);
291 m_mainWidget
= m_frameWidget
;
295 // This patch comes from Torsten Liermann lier@lier1.muc.de
296 if (XmIsMotifWMRunning( (Widget
) m_frameShell
))
299 if (style
& wxRESIZE_BORDER
)
300 decor
|= MWM_DECOR_RESIZEH
;
301 if (style
& wxSYSTEM_MENU
)
302 decor
|= MWM_DECOR_MENU
;
303 if ((style
& wxCAPTION
) ||
304 (style
& wxTINY_CAPTION_HORIZ
) ||
305 (style
& wxTINY_CAPTION_VERT
))
306 decor
|= MWM_DECOR_TITLE
;
307 if (style
& wxTHICK_FRAME
)
308 decor
|= MWM_DECOR_BORDER
;
309 if (style
& wxMINIMIZE_BOX
)
310 decor
|= MWM_DECOR_MINIMIZE
;
311 if (style
& wxMAXIMIZE_BOX
)
312 decor
|= MWM_DECOR_MAXIMIZE
;
313 XtVaSetValues((Widget
) m_frameShell
,XmNmwmDecorations
,decor
,NULL
);
315 // This allows non-Motif window managers to support at least the
316 // no-decorations case.
320 XtVaSetValues((Widget
) m_frameShell
,XmNoverrideRedirect
,TRUE
,NULL
);
322 XtRealizeWidget((Widget
) m_frameShell
);
324 // Intercept CLOSE messages from the window manager
325 Atom WM_DELETE_WINDOW
= XmInternAtom(XtDisplay((Widget
) m_frameShell
), "WM_DELETE_WINDOW", False
);
326 #if (XmREVISION > 1 || XmVERSION > 1)
327 XmAddWMProtocolCallback((Widget
) m_frameShell
, WM_DELETE_WINDOW
, (XtCallbackProc
) wxCloseFrameCallback
, (XtPointer
)this);
330 XmAddWMProtocolCallback((Widget
) m_frameShell
, WM_DELETE_WINDOW
, (XtCallbackProc
) wxCloseFrameCallback
, (caddr_t
)this);
332 XmAddWMProtocolCallback((Widget
) m_frameShell
, WM_DELETE_WINDOW
, (void (*)())wxCloseFrameCallback
, (caddr_t
)this);
336 ChangeBackgroundColour();
340 wxSizeEvent
sizeEvent(wxSize(width
, height
), GetId());
341 sizeEvent
.SetEventObject(this);
343 GetEventHandler()->ProcessEvent(sizeEvent
);
350 m_isBeingDeleted
= TRUE
;
354 XtRemoveEventHandler((Widget
) m_clientArea
, ExposureMask
, FALSE
,
355 wxUniversalRepaintProc
, (XtPointer
) this);
356 XtRemoveEventHandler((Widget
) m_clientArea
, ButtonPressMask
| ButtonReleaseMask
| PointerMotionMask
| KeyPressMask
,
358 wxFrameEventHandler
, (XtPointer
) this);
359 wxDeleteWindowFromTable((Widget
) m_clientArea
);
367 m_frameMenuBar
->DestroyMenuBar();
369 // Hack to stop core dump on Ultrix, OSF, for some strange reason.
370 #if MOTIF_MENUBAR_DELETE_FIX
371 GetMenuBar()->SetMainWidget((WXWidget
) NULL
);
373 delete m_frameMenuBar
;
374 m_frameMenuBar
= NULL
;
377 wxTopLevelWindows
.DeleteObject(this);
378 wxModelessWindows
.DeleteObject(this);
380 if (m_frameStatusBar
)
382 delete m_frameStatusBar
;
383 m_frameStatusBar
= NULL
;
390 wxDeleteWindowFromTable((Widget
) m_workArea
);
392 XtDestroyWidget ((Widget
) m_workArea
);
397 wxDeleteWindowFromTable((Widget
) m_frameWidget
);
398 XtDestroyWidget ((Widget
) m_frameWidget
);
402 XtDestroyWidget ((Widget
) m_frameShell
);
404 SetMainWidget((WXWidget
) NULL
);
406 /* Check if it's the last top-level window */
408 if (wxTheApp
&& (wxTopLevelWindows
.Number() == 0))
410 wxTheApp
->SetTopWindow(NULL
);
412 if (wxTheApp
->GetExitOnFrameDelete())
414 // Signal to the app that we're going to close
415 wxTheApp
->ExitMainLoop();
420 // Get size *available for subwindows* i.e. excluding menu bar, toolbar etc.
421 void wxFrame::DoGetClientSize(int *x
, int *y
) const
424 XtVaGetValues((Widget
) m_workArea
, XmNwidth
, &xx
, XmNheight
, &yy
, NULL
);
426 if (m_frameStatusBar
)
429 m_frameStatusBar
->GetSize(& sbw
, & sbh
);
436 m_frameToolBar
->GetSize(& tbw
, & tbh
);
437 if (m_frameToolBar
->GetWindowStyleFlag() & wxTB_VERTICAL
)
442 #endif // wxUSE_TOOLBAR
444 if (GetMenuBar() != (wxMenuBar*) NULL)
446 // it seems that if a frame holds a panel, the menu bar size
447 // gets automatically taken care of --- grano@cs.helsinki.fi 4.4.95
448 bool hasSubPanel = FALSE;
449 for(wxNode* node = GetChildren().First(); node; node = node->Next())
451 wxWindow *win = (wxWindow *)node->Data();
452 hasSubPanel = (win->IsKindOf(CLASSINFO(wxPanel)) && !win->IsKindOf(CLASSINFO(wxDialog)));
459 XtVaGetValues((Widget) GetMenuBarWidget(), XmNheight, &ys, NULL);
468 // Set the client size (i.e. leave the calculation of borders etc.
470 void wxFrame::DoSetClientSize(int width
, int height
)
472 // Calculate how large the new main window should be
473 // by finding the difference between the client area and the
474 // main window area, and adding on to the new client area
476 XtVaSetValues((Widget
) m_workArea
, XmNwidth
, width
, NULL
);
480 if (m_frameStatusBar
)
483 m_frameStatusBar
->GetSize(& sbw
, & sbh
);
490 m_frameToolBar
->GetSize(& tbw
, & tbh
);
491 if (m_frameToolBar
->GetWindowStyleFlag() & wxTB_VERTICAL
)
496 #endif // wxUSE_TOOLBAR
498 XtVaSetValues((Widget
) m_workArea
, XmNheight
, height
, NULL
);
502 wxSizeEvent
sizeEvent(wxSize(width
, height
), GetId());
503 sizeEvent
.SetEventObject(this);
505 GetEventHandler()->ProcessEvent(sizeEvent
);
509 void wxFrame::DoGetSize(int *width
, int *height
) const
512 XtVaGetValues((Widget
) m_frameShell
, XmNwidth
, &xx
, XmNheight
, &yy
, NULL
);
513 *width
= xx
; *height
= yy
;
516 void wxFrame::DoGetPosition(int *x
, int *y
) const
518 Window parent_window
= XtWindow((Widget
) m_frameShell
),
519 next_parent
= XtWindow((Widget
) m_frameShell
),
520 root
= RootWindowOfScreen(XtScreen((Widget
) m_frameShell
));
522 // search for the parent that is child of ROOT, because the WM may
523 // reparent twice and notify only the next parent (like FVWM)
524 while (next_parent
!= root
) {
525 Window
*theChildren
; unsigned int n
;
526 parent_window
= next_parent
;
527 XQueryTree(XtDisplay((Widget
) m_frameShell
), parent_window
, &root
,
528 &next_parent
, &theChildren
, &n
);
529 XFree(theChildren
); // not needed
531 int xx
, yy
; unsigned int dummy
;
532 XGetGeometry(XtDisplay((Widget
) m_frameShell
), parent_window
, &root
,
533 &xx
, &yy
, &dummy
, &dummy
, &dummy
, &dummy
);
538 void wxFrame::DoSetSize(int x
, int y
, int width
, int height
, int WXUNUSED(sizeFlags
))
541 XtVaSetValues((Widget
) m_frameShell
, XmNx
, x
, NULL
);
543 XtVaSetValues((Widget
) m_frameShell
, XmNy
, y
, NULL
);
545 XtVaSetValues((Widget
) m_frameWidget
, XmNwidth
, width
, NULL
);
547 XtVaSetValues((Widget
) m_frameWidget
, XmNheight
, height
, NULL
);
549 if (!(height
== -1 && width
== -1))
553 wxSizeEvent
sizeEvent(wxSize(width
, height
), GetId());
554 sizeEvent
.SetEventObject(this);
556 GetEventHandler()->ProcessEvent(sizeEvent
);
560 bool wxFrame::Show(bool show
)
563 return wxWindow::Show(show
);
565 m_visibleStatus
= show
; /* show-&-hide fix */
569 XtMapWidget((Widget
) m_frameShell
);
570 XRaiseWindow(XtDisplay((Widget
) m_frameShell
), XtWindow((Widget
) m_frameShell
));
572 XtUnmapWidget((Widget
) m_frameShell
);
573 // XmUpdateDisplay(wxTheApp->topLevel); // Experimental: may be responsible for crashes
578 void wxFrame::Iconize(bool iconize
)
584 XtVaSetValues((Widget
) m_frameShell
, XmNiconic
, (Boolean
)iconize
, NULL
);
587 void wxFrame::Restore()
590 XtVaSetValues((Widget
) m_frameShell
, XmNiconic
, FALSE
, NULL
);
593 void wxFrame::Maximize(bool maximize
)
601 bool wxFrame::IsIconized() const
607 XtVaGetValues((Widget
) m_frameShell
, XmNiconic
, &iconic
, NULL
);
612 bool wxFrame::IsMaximized() const
614 // No maximizing in Motif (?)
618 void wxFrame::SetTitle(const wxString
& title
)
620 if (title
== m_title
)
626 XtVaSetValues((Widget
) m_frameShell
,
627 XmNtitle
, title
.c_str(),
628 XmNiconName
, title
.c_str(),
632 void wxFrame::DoSetIcon(const wxIcon
& icon
)
637 if (!icon
.Ok() || !icon
.GetPixmap())
640 XtVaSetValues((Widget
) m_frameShell
, XtNiconPixmap
, icon
.GetPixmap(), NULL
);
643 void wxFrame::SetIcon(const wxIcon
& icon
)
645 SetIcons( wxIconBundle( icon
) );
648 void wxFrame::SetIcons(const wxIconBundle
& icons
)
650 wxFrameBase::SetIcons( icons
);
655 DoSetIcon( m_icons
.GetIcon( -1 ) );
656 wxSetIconsX11(GetXDisplay(),
657 (WXWindow
) XtWindow( (Widget
) m_frameShell
), icons
);
660 void wxFrame::PositionStatusBar()
662 if (!m_frameStatusBar
)
666 GetClientSize(&w
, &h
);
668 m_frameStatusBar
->GetSize(&sw
, &sh
);
670 // Since we wish the status bar to be directly under the client area,
671 // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS.
672 m_frameStatusBar
->SetSize(0, h
, w
, sh
);
675 WXWidget
wxFrame::GetMenuBarWidget() const
678 return GetMenuBar()->GetMainWidget();
680 return (WXWidget
) NULL
;
683 void wxFrame::SetMenuBar(wxMenuBar
*menuBar
)
687 m_frameMenuBar
= NULL
;
691 // Currently can't set it twice
692 // wxASSERT_MSG( (m_frameMenuBar == (wxMenuBar*) NULL), "Cannot set the menubar more than once");
696 m_frameMenuBar
->DestroyMenuBar();
697 delete m_frameMenuBar
;
700 m_frameMenuBar
= menuBar
;
701 m_frameMenuBar
->CreateMenuBar(this);
704 // Responds to colour changes, and passes event on to children.
705 void wxFrame::OnSysColourChanged(wxSysColourChangedEvent
& event
)
707 SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
));
710 if ( m_frameStatusBar
)
712 wxSysColourChangedEvent event2
;
713 event2
.SetEventObject( m_frameStatusBar
);
714 m_frameStatusBar
->ProcessEvent(event2
);
717 // Propagate the event to the non-top-level children
718 wxWindow::OnSysColourChanged(event
);
721 // Default activation behaviour - set the focus for the first child
723 void wxFrame::OnActivate(wxActivateEvent
& event
)
725 if (!event
.GetActive())
728 for(wxNode
*node
= GetChildren().First(); node
; node
= node
->Next())
730 // Find a child that's a subwindow, but not a dialog box.
731 wxWindow
*child
= (wxWindow
*)node
->Data();
732 if (!child
->IsKindOf(CLASSINFO(wxFrame
)) &&
733 !child
->IsKindOf(CLASSINFO(wxDialog
)))
743 wxToolBar
* wxFrame::CreateToolBar(long style
,
745 const wxString
& name
)
747 if ( wxFrameBase::CreateToolBar(style
, id
, name
) )
752 return m_frameToolBar
;
755 void wxFrame::PositionToolBar()
760 GetClientSize(& cw
, &ch
);
763 GetToolBar()->GetSize(& tw
, & th
);
765 if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL
)
767 // Use the 'real' position. wxSIZE_NO_ADJUSTMENTS
768 // means, pretend we don't have toolbar/status bar, so we
769 // have the original client size.
770 GetToolBar()->SetSize(0, 0, tw
, ch
+ th
, wxSIZE_NO_ADJUSTMENTS
);
774 // Use the 'real' position
775 GetToolBar()->SetSize(0, 0, cw
, th
, wxSIZE_NO_ADJUSTMENTS
);
779 #endif // wxUSE_TOOLBAR
781 void wxFrame::Raise()
783 Window parent_window
= XtWindow((Widget
) m_frameShell
),
784 next_parent
= XtWindow((Widget
) m_frameShell
),
785 root
= RootWindowOfScreen(XtScreen((Widget
) m_frameShell
));
786 // search for the parent that is child of ROOT, because the WM may
787 // reparent twice and notify only the next parent (like FVWM)
788 while (next_parent
!= root
) {
789 Window
*theChildren
; unsigned int n
;
790 parent_window
= next_parent
;
791 XQueryTree(XtDisplay((Widget
) m_frameShell
), parent_window
, &root
,
792 &next_parent
, &theChildren
, &n
);
793 XFree(theChildren
); // not needed
795 XRaiseWindow(XtDisplay((Widget
) m_frameShell
), parent_window
);
798 void wxFrame::Lower()
800 Window parent_window
= XtWindow((Widget
) m_frameShell
),
801 next_parent
= XtWindow((Widget
) m_frameShell
),
802 root
= RootWindowOfScreen(XtScreen((Widget
) m_frameShell
));
803 // search for the parent that is child of ROOT, because the WM may
804 // reparent twice and notify only the next parent (like FVWM)
805 while (next_parent
!= root
) {
806 Window
*theChildren
; unsigned int n
;
807 parent_window
= next_parent
;
808 XQueryTree(XtDisplay((Widget
) m_frameShell
), parent_window
, &root
,
809 &next_parent
, &theChildren
, &n
);
810 XFree(theChildren
); // not needed
812 XLowerWindow(XtDisplay((Widget
) m_frameShell
), parent_window
);
815 void wxFrameFocusProc(Widget
WXUNUSED(workArea
), XtPointer
WXUNUSED(clientData
),
816 XmAnyCallbackStruct
*WXUNUSED(cbs
))
818 // wxDebugMsg("focus proc from frame %ld\n",(long)frame);
820 // wxFrame *frame = (wxFrame *)clientData;
821 // frame->GetEventHandler()->OnSetFocus();
824 /* MATTEW: Used to insure that hide-&-show within an event cycle works */
825 static void wxFrameMapProc(Widget frameShell
, XtPointer clientData
,
826 XCrossingEvent
* event
)
828 wxFrame
*frame
= (wxFrame
*)wxGetWindowFromTable((Widget
)clientData
);
831 XEvent
*e
= (XEvent
*)event
;
833 if (e
->xany
.type
== MapNotify
)
836 XtVaSetValues(frameShell
, XmNiconic
, (Boolean
)False
, NULL
);
837 if (!frame
->GetVisibleStatus())
839 /* We really wanted this to be hidden! */
840 XtUnmapWidget((Widget
) frame
->GetShellWidget());
843 else if (e
->xany
.type
== UnmapNotify
)
845 XtVaSetValues(frameShell
, XmNiconic
, (Boolean
)True
, NULL
);
850 bool wxFrame::PreResize()
854 #endif // wxUSE_TOOLBAR
858 #endif // wxUSE_STATUSBAR
863 WXWidget
wxFrame::GetClientWidget() const
868 void wxFrame::ChangeFont(bool WXUNUSED(keepOriginalSize
))
873 void wxFrame::ChangeBackgroundColour()
875 if (GetClientWidget())
876 DoChangeBackgroundColour(GetClientWidget(), m_backgroundColour
);
879 void wxFrame::ChangeForegroundColour()
881 if (GetClientWidget())
882 DoChangeForegroundColour(GetClientWidget(), m_foregroundColour
);
885 void wxCloseFrameCallback(Widget
WXUNUSED(widget
), XtPointer client_data
, XmAnyCallbackStruct
*WXUNUSED(cbs
))
887 wxFrame
*frame
= (wxFrame
*)client_data
;
889 wxCloseEvent
closeEvent(wxEVT_CLOSE_WINDOW
, frame
->GetId());
890 closeEvent
.SetEventObject(frame
);
892 // May delete the frame (with delayed deletion)
893 frame
->GetEventHandler()->ProcessEvent(closeEvent
);
896 static void wxFrameEventHandler(Widget wid
,
897 XtPointer
WXUNUSED(client_data
),
899 Boolean
* continueToDispatch
)
901 wxFrame
*frame
= (wxFrame
*)wxGetWindowFromTable(wid
);
904 wxMouseEvent
wxevent(wxEVT_NULL
);
905 if (wxTranslateMouseEvent(wxevent
, frame
, wid
, event
))
907 wxevent
.SetEventObject(frame
);
908 wxevent
.SetId(frame
->GetId());
909 frame
->GetEventHandler()->ProcessEvent(wxevent
);
913 // An attempt to implement OnCharHook by calling OnCharHook first;
914 // if this returns TRUE, set continueToDispatch to False
915 // (don't continue processing).
916 // Otherwise set it to True and call OnChar.
917 wxKeyEvent
keyEvent(wxEVT_CHAR
);
918 if (wxTranslateKeyEvent(keyEvent
, frame
, wid
, event
))
920 keyEvent
.SetEventObject(frame
);
921 keyEvent
.SetId(frame
->GetId());
922 keyEvent
.SetEventType(wxEVT_CHAR_HOOK
);
923 if (frame
->GetEventHandler()->ProcessEvent(keyEvent
))
925 *continueToDispatch
= False
;
930 // For simplicity, OnKeyDown is the same as OnChar
931 // TODO: filter modifier key presses from OnChar
932 keyEvent
.SetEventType(wxEVT_KEY_DOWN
);
934 // Only process OnChar if OnKeyDown didn't swallow it
935 if (!frame
->GetEventHandler()->ProcessEvent (keyEvent
))
937 keyEvent
.SetEventType(wxEVT_CHAR
);
938 frame
->GetEventHandler()->ProcessEvent(keyEvent
);
944 *continueToDispatch
= True
;