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>
58 #include <Xm/MwmUtil.h>
59 #include <Xm/BulletinB.h>
62 #include <Xm/RowColumn.h>
64 #include <Xm/AtomMgr.h>
65 #include <Xm/LabelG.h>
68 #include <Xm/Protocols.h>
72 #pragma message enable nosimpint
75 #include "wx/motif/private.h"
77 // ----------------------------------------------------------------------------
79 // ----------------------------------------------------------------------------
81 static void wxFrameEventHandler(Widget wid
,
82 XtPointer
WXUNUSED(client_data
),
84 Boolean
* continueToDispatch
);
85 static void wxCloseFrameCallback(Widget
, XtPointer
, XmAnyCallbackStruct
*cbs
);
86 static void wxFrameFocusProc(Widget workArea
, XtPointer clientData
,
87 XmAnyCallbackStruct
*cbs
);
88 static void wxFrameMapProc(Widget frameShell
, XtPointer clientData
,
89 XCrossingEvent
* event
);
91 // ----------------------------------------------------------------------------
93 // ----------------------------------------------------------------------------
95 extern wxList wxModelessWindows
;
96 extern wxList wxPendingDelete
;
98 // TODO: this should be tidied so that any frame can be the
100 static bool wxTopLevelUsed
= FALSE
;
102 // ----------------------------------------------------------------------------
104 // ----------------------------------------------------------------------------
106 BEGIN_EVENT_TABLE(wxFrame
, wxFrameBase
)
107 EVT_ACTIVATE(wxFrame::OnActivate
)
108 EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged
)
111 IMPLEMENT_DYNAMIC_CLASS(wxFrame
, wxWindow
)
113 // ============================================================================
115 // ============================================================================
117 // ----------------------------------------------------------------------------
118 // frame construction
119 // ----------------------------------------------------------------------------
126 m_frameShell
= (WXWidget
) NULL
;
127 m_frameWidget
= (WXWidget
) NULL
;;
128 m_workArea
= (WXWidget
) NULL
;;
129 m_clientArea
= (WXWidget
) NULL
;;
130 m_visibleStatus
= TRUE
;
133 bool wxFrame::Create(wxWindow
*parent
,
135 const wxString
& title
,
139 const wxString
& name
)
142 parent
->AddChild(this);
144 wxTopLevelWindows
.Append(this);
146 wxModelessWindows
.Append(this);
150 m_windowStyle
= style
;
152 m_backgroundColour
= wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
);
153 m_foregroundColour
= *wxBLACK
;
154 m_font
= wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT
);
159 m_windowId
= (int)NewControlId();
161 int x
= pos
.x
, y
= pos
.y
;
162 int width
= size
.x
, height
= size
.y
;
164 // Set reasonable values for position and size if defaults have been
167 // MB TODO: something better than these arbitrary values ?
168 // VZ should use X resources for this...
174 int displayW
, displayH
;
175 wxDisplaySize( &displayW
, &displayH
);
179 x
= (displayW
- width
) / 2;
184 y
= (displayH
- height
) / 2;
188 // VZ: what does this do??
191 // Change suggested by Matthew Flatt
192 m_frameShell
= (WXWidget
)XtAppCreateShell
195 wxTheApp
->GetClassName(),
196 topLevelShellWidgetClass
,
197 (Display
*) wxGetDisplay(),
204 m_frameShell
= wxTheApp
->GetTopLevelWidget();
205 wxTopLevelUsed
= TRUE
;
208 XtVaSetValues((Widget
) m_frameShell
,
209 // Allows menu to resize
210 XmNallowShellResize
, True
,
211 XmNdeleteResponse
, XmDO_NOTHING
,
212 XmNmappedWhenManaged
, False
,
213 XmNiconic
, (style
& wxICONIZE
) ? TRUE
: FALSE
,
216 if (!title
.IsEmpty())
217 XtVaSetValues((Widget
) m_frameShell
,
218 XmNtitle
, title
.c_str(),
221 m_frameWidget
= (WXWidget
) XtVaCreateManagedWidget("main_window",
222 xmMainWindowWidgetClass
, (Widget
) m_frameShell
,
223 XmNresizePolicy
, XmRESIZE_NONE
,
226 m_workArea
= (WXWidget
) XtVaCreateWidget("form",
227 xmFormWidgetClass
, (Widget
) m_frameWidget
,
228 XmNresizePolicy
, XmRESIZE_NONE
,
231 m_clientArea
= (WXWidget
) XtVaCreateWidget("client",
232 xmBulletinBoardWidgetClass
, (Widget
) m_workArea
,
235 XmNrightAttachment
, XmATTACH_FORM
,
236 XmNleftAttachment
, XmATTACH_FORM
,
237 XmNtopAttachment
, XmATTACH_FORM
,
238 XmNbottomAttachment
, XmATTACH_FORM
,
239 // XmNresizePolicy, XmRESIZE_ANY,
242 wxLogTrace(wxTRACE_Messages
,
243 "Created frame (0x%08x) with work area 0x%08x and client "
244 "area 0x%08x", m_frameWidget
, m_workArea
, m_clientArea
);
246 XtAddEventHandler((Widget
) m_clientArea
, ExposureMask
,FALSE
,
247 wxUniversalRepaintProc
, (XtPointer
) this);
249 XtAddEventHandler((Widget
) m_clientArea
,
250 ButtonPressMask
| ButtonReleaseMask
| PointerMotionMask
| KeyPressMask
,
255 XtVaSetValues((Widget
) m_frameWidget
,
256 XmNworkWindow
, (Widget
) m_workArea
,
259 XtManageChild((Widget
) m_clientArea
);
260 XtManageChild((Widget
) m_workArea
);
262 wxAddWindowToTable((Widget
) m_workArea
, this);
263 wxAddWindowToTable((Widget
) m_clientArea
, this);
267 XtOverrideTranslations((Widget
) m_workArea
,
268 ptr
= XtParseTranslationTable("<Configure>: resize()"));
272 XtAddCallback((Widget
) m_workArea
, XmNfocusCallback
,
273 (XtCallbackProc
)wxFrameFocusProc
, (XtPointer
)this);
275 /* Part of show-&-hide fix */
276 XtAddEventHandler((Widget
) m_frameShell
, StructureNotifyMask
,
277 False
, (XtEventHandler
)wxFrameMapProc
,
278 (XtPointer
)m_workArea
);
281 XtVaSetValues((Widget
) m_frameShell
, XmNx
, x
, NULL
);
283 XtVaSetValues((Widget
) m_frameShell
, XmNy
, y
, NULL
);
285 XtVaSetValues((Widget
) m_frameShell
, XmNwidth
, width
, NULL
);
287 XtVaSetValues((Widget
) m_frameShell
, XmNheight
, height
, NULL
);
289 m_mainWidget
= m_frameWidget
;
293 // This patch comes from Torsten Liermann lier@lier1.muc.de
294 if (XmIsMotifWMRunning( (Widget
) m_frameShell
))
297 if (style
& wxRESIZE_BORDER
)
298 decor
|= MWM_DECOR_RESIZEH
;
299 if (style
& wxSYSTEM_MENU
)
300 decor
|= MWM_DECOR_MENU
;
301 if ((style
& wxCAPTION
) ||
302 (style
& wxTINY_CAPTION_HORIZ
) ||
303 (style
& wxTINY_CAPTION_VERT
))
304 decor
|= MWM_DECOR_TITLE
;
305 if (style
& wxTHICK_FRAME
)
306 decor
|= MWM_DECOR_BORDER
;
307 if (style
& wxMINIMIZE_BOX
)
308 decor
|= MWM_DECOR_MINIMIZE
;
309 if (style
& wxMAXIMIZE_BOX
)
310 decor
|= MWM_DECOR_MAXIMIZE
;
311 XtVaSetValues((Widget
) m_frameShell
,XmNmwmDecorations
,decor
,NULL
);
313 // This allows non-Motif window managers to support at least the
314 // no-decorations case.
318 XtVaSetValues((Widget
) m_frameShell
,XmNoverrideRedirect
,TRUE
,NULL
);
320 XtRealizeWidget((Widget
) m_frameShell
);
322 // Intercept CLOSE messages from the window manager
323 Atom WM_DELETE_WINDOW
= XmInternAtom(XtDisplay((Widget
) m_frameShell
), "WM_DELETE_WINDOW", False
);
324 #if (XmREVISION > 1 || XmVERSION > 1)
325 XmAddWMProtocolCallback((Widget
) m_frameShell
, WM_DELETE_WINDOW
, (XtCallbackProc
) wxCloseFrameCallback
, (XtPointer
)this);
328 XmAddWMProtocolCallback((Widget
) m_frameShell
, WM_DELETE_WINDOW
, (XtCallbackProc
) wxCloseFrameCallback
, (caddr_t
)this);
330 XmAddWMProtocolCallback((Widget
) m_frameShell
, WM_DELETE_WINDOW
, (void (*)())wxCloseFrameCallback
, (caddr_t
)this);
334 ChangeBackgroundColour();
338 wxSizeEvent
sizeEvent(wxSize(width
, height
), GetId());
339 sizeEvent
.SetEventObject(this);
341 GetEventHandler()->ProcessEvent(sizeEvent
);
348 m_isBeingDeleted
= TRUE
;
352 XtRemoveEventHandler((Widget
) m_clientArea
, ExposureMask
, FALSE
,
353 wxUniversalRepaintProc
, (XtPointer
) this);
354 XtRemoveEventHandler((Widget
) m_clientArea
, ButtonPressMask
| ButtonReleaseMask
| PointerMotionMask
| KeyPressMask
,
356 wxFrameEventHandler
, (XtPointer
) this);
357 wxDeleteWindowFromTable((Widget
) m_clientArea
);
365 m_frameMenuBar
->DestroyMenuBar();
367 // Hack to stop core dump on Ultrix, OSF, for some strange reason.
368 #if MOTIF_MENUBAR_DELETE_FIX
369 GetMenuBar()->SetMainWidget((WXWidget
) NULL
);
371 delete m_frameMenuBar
;
372 m_frameMenuBar
= NULL
;
375 wxTopLevelWindows
.DeleteObject(this);
376 wxModelessWindows
.DeleteObject(this);
378 if (m_frameStatusBar
)
380 delete m_frameStatusBar
;
381 m_frameStatusBar
= NULL
;
388 wxDeleteWindowFromTable((Widget
) m_workArea
);
390 XtDestroyWidget ((Widget
) m_workArea
);
395 wxDeleteWindowFromTable((Widget
) m_frameWidget
);
396 XtDestroyWidget ((Widget
) m_frameWidget
);
400 XtDestroyWidget ((Widget
) m_frameShell
);
402 SetMainWidget((WXWidget
) NULL
);
404 /* Check if it's the last top-level window */
406 if (wxTheApp
&& (wxTopLevelWindows
.Number() == 0))
408 wxTheApp
->SetTopWindow(NULL
);
410 if (wxTheApp
->GetExitOnFrameDelete())
412 // Signal to the app that we're going to close
413 wxTheApp
->ExitMainLoop();
418 // Get size *available for subwindows* i.e. excluding menu bar, toolbar etc.
419 void wxFrame::DoGetClientSize(int *x
, int *y
) const
422 XtVaGetValues((Widget
) m_workArea
, XmNwidth
, &xx
, XmNheight
, &yy
, NULL
);
424 if (m_frameStatusBar
)
427 m_frameStatusBar
->GetSize(& sbw
, & sbh
);
434 m_frameToolBar
->GetSize(& tbw
, & tbh
);
435 if (m_frameToolBar
->GetWindowStyleFlag() & wxTB_VERTICAL
)
440 #endif // wxUSE_TOOLBAR
442 if (GetMenuBar() != (wxMenuBar*) NULL)
444 // it seems that if a frame holds a panel, the menu bar size
445 // gets automatically taken care of --- grano@cs.helsinki.fi 4.4.95
446 bool hasSubPanel = FALSE;
447 for(wxNode* node = GetChildren().First(); node; node = node->Next())
449 wxWindow *win = (wxWindow *)node->Data();
450 hasSubPanel = (win->IsKindOf(CLASSINFO(wxPanel)) && !win->IsKindOf(CLASSINFO(wxDialog)));
457 XtVaGetValues((Widget) GetMenuBarWidget(), XmNheight, &ys, NULL);
466 // Set the client size (i.e. leave the calculation of borders etc.
468 void wxFrame::DoSetClientSize(int width
, int height
)
470 // Calculate how large the new main window should be
471 // by finding the difference between the client area and the
472 // main window area, and adding on to the new client area
474 XtVaSetValues((Widget
) m_workArea
, XmNwidth
, width
, NULL
);
478 if (m_frameStatusBar
)
481 m_frameStatusBar
->GetSize(& sbw
, & sbh
);
488 m_frameToolBar
->GetSize(& tbw
, & tbh
);
489 if (m_frameToolBar
->GetWindowStyleFlag() & wxTB_VERTICAL
)
494 #endif // wxUSE_TOOLBAR
496 XtVaSetValues((Widget
) m_workArea
, XmNheight
, height
, NULL
);
500 wxSizeEvent
sizeEvent(wxSize(width
, height
), GetId());
501 sizeEvent
.SetEventObject(this);
503 GetEventHandler()->ProcessEvent(sizeEvent
);
507 void wxFrame::DoGetSize(int *width
, int *height
) const
510 XtVaGetValues((Widget
) m_frameShell
, XmNwidth
, &xx
, XmNheight
, &yy
, NULL
);
511 *width
= xx
; *height
= yy
;
514 void wxFrame::DoGetPosition(int *x
, int *y
) const
516 Window parent_window
= XtWindow((Widget
) m_frameShell
),
517 next_parent
= XtWindow((Widget
) m_frameShell
),
518 root
= RootWindowOfScreen(XtScreen((Widget
) m_frameShell
));
520 // search for the parent that is child of ROOT, because the WM may
521 // reparent twice and notify only the next parent (like FVWM)
522 while (next_parent
!= root
) {
523 Window
*theChildren
; unsigned int n
;
524 parent_window
= next_parent
;
525 XQueryTree(XtDisplay((Widget
) m_frameShell
), parent_window
, &root
,
526 &next_parent
, &theChildren
, &n
);
527 XFree(theChildren
); // not needed
529 int xx
, yy
; unsigned int dummy
;
530 XGetGeometry(XtDisplay((Widget
) m_frameShell
), parent_window
, &root
,
531 &xx
, &yy
, &dummy
, &dummy
, &dummy
, &dummy
);
536 void wxFrame::DoSetSize(int x
, int y
, int width
, int height
, int WXUNUSED(sizeFlags
))
539 XtVaSetValues((Widget
) m_frameShell
, XmNx
, x
, NULL
);
541 XtVaSetValues((Widget
) m_frameShell
, XmNy
, y
, NULL
);
543 XtVaSetValues((Widget
) m_frameWidget
, XmNwidth
, width
, NULL
);
545 XtVaSetValues((Widget
) m_frameWidget
, XmNheight
, height
, NULL
);
547 if (!(height
== -1 && width
== -1))
551 wxSizeEvent
sizeEvent(wxSize(width
, height
), GetId());
552 sizeEvent
.SetEventObject(this);
554 GetEventHandler()->ProcessEvent(sizeEvent
);
558 bool wxFrame::Show(bool show
)
561 return wxWindow::Show(show
);
563 m_visibleStatus
= show
; /* show-&-hide fix */
567 XtMapWidget((Widget
) m_frameShell
);
568 XRaiseWindow(XtDisplay((Widget
) m_frameShell
), XtWindow((Widget
) m_frameShell
));
570 XtUnmapWidget((Widget
) m_frameShell
);
571 // XmUpdateDisplay(wxTheApp->topLevel); // Experimental: may be responsible for crashes
576 void wxFrame::Iconize(bool iconize
)
582 XtVaSetValues((Widget
) m_frameShell
, XmNiconic
, (Boolean
)iconize
, NULL
);
585 void wxFrame::Restore()
588 XtVaSetValues((Widget
) m_frameShell
, XmNiconic
, FALSE
, NULL
);
591 void wxFrame::Maximize(bool maximize
)
599 bool wxFrame::IsIconized() const
605 XtVaGetValues((Widget
) m_frameShell
, XmNiconic
, &iconic
, NULL
);
610 bool wxFrame::IsMaximized() const
612 // No maximizing in Motif (?)
616 void wxFrame::SetTitle(const wxString
& title
)
618 if (title
== m_title
)
624 XtVaSetValues((Widget
) m_frameShell
,
625 XmNtitle
, title
.c_str(),
626 XmNiconName
, title
.c_str(),
630 void wxFrame::SetIcon(const wxIcon
& icon
)
637 if (!icon
.Ok() || !icon
.GetPixmap())
640 XtVaSetValues((Widget
) m_frameShell
, XtNiconPixmap
, icon
.GetPixmap(), NULL
);
643 void wxFrame::PositionStatusBar()
645 if (!m_frameStatusBar
)
649 GetClientSize(&w
, &h
);
651 m_frameStatusBar
->GetSize(&sw
, &sh
);
653 // Since we wish the status bar to be directly under the client area,
654 // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS.
655 m_frameStatusBar
->SetSize(0, h
, w
, sh
);
658 WXWidget
wxFrame::GetMenuBarWidget() const
661 return GetMenuBar()->GetMainWidget();
663 return (WXWidget
) NULL
;
666 void wxFrame::SetMenuBar(wxMenuBar
*menuBar
)
670 m_frameMenuBar
= NULL
;
674 // Currently can't set it twice
675 // wxASSERT_MSG( (m_frameMenuBar == (wxMenuBar*) NULL), "Cannot set the menubar more than once");
679 m_frameMenuBar
->DestroyMenuBar();
680 delete m_frameMenuBar
;
683 m_frameMenuBar
= menuBar
;
684 m_frameMenuBar
->CreateMenuBar(this);
687 // Responds to colour changes, and passes event on to children.
688 void wxFrame::OnSysColourChanged(wxSysColourChangedEvent
& event
)
690 SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
));
693 if ( m_frameStatusBar
)
695 wxSysColourChangedEvent event2
;
696 event2
.SetEventObject( m_frameStatusBar
);
697 m_frameStatusBar
->ProcessEvent(event2
);
700 // Propagate the event to the non-top-level children
701 wxWindow::OnSysColourChanged(event
);
704 // Default activation behaviour - set the focus for the first child
706 void wxFrame::OnActivate(wxActivateEvent
& event
)
708 if (!event
.GetActive())
711 for(wxNode
*node
= GetChildren().First(); node
; node
= node
->Next())
713 // Find a child that's a subwindow, but not a dialog box.
714 wxWindow
*child
= (wxWindow
*)node
->Data();
715 if (!child
->IsKindOf(CLASSINFO(wxFrame
)) &&
716 !child
->IsKindOf(CLASSINFO(wxDialog
)))
726 wxToolBar
* wxFrame::CreateToolBar(long style
,
728 const wxString
& name
)
730 if ( wxFrameBase::CreateToolBar(style
, id
, name
) )
735 return m_frameToolBar
;
738 void wxFrame::PositionToolBar()
743 GetClientSize(& cw
, &ch
);
746 GetToolBar()->GetSize(& tw
, & th
);
748 if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL
)
750 // Use the 'real' position. wxSIZE_NO_ADJUSTMENTS
751 // means, pretend we don't have toolbar/status bar, so we
752 // have the original client size.
753 GetToolBar()->SetSize(0, 0, tw
, ch
+ th
, wxSIZE_NO_ADJUSTMENTS
);
757 // Use the 'real' position
758 GetToolBar()->SetSize(0, 0, cw
, th
, wxSIZE_NO_ADJUSTMENTS
);
762 #endif // wxUSE_TOOLBAR
764 void wxFrame::Raise()
766 Window parent_window
= XtWindow((Widget
) m_frameShell
),
767 next_parent
= XtWindow((Widget
) m_frameShell
),
768 root
= RootWindowOfScreen(XtScreen((Widget
) m_frameShell
));
769 // search for the parent that is child of ROOT, because the WM may
770 // reparent twice and notify only the next parent (like FVWM)
771 while (next_parent
!= root
) {
772 Window
*theChildren
; unsigned int n
;
773 parent_window
= next_parent
;
774 XQueryTree(XtDisplay((Widget
) m_frameShell
), parent_window
, &root
,
775 &next_parent
, &theChildren
, &n
);
776 XFree(theChildren
); // not needed
778 XRaiseWindow(XtDisplay((Widget
) m_frameShell
), parent_window
);
781 void wxFrame::Lower()
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 XLowerWindow(XtDisplay((Widget
) m_frameShell
), parent_window
);
798 void wxFrameFocusProc(Widget
WXUNUSED(workArea
), XtPointer
WXUNUSED(clientData
),
799 XmAnyCallbackStruct
*WXUNUSED(cbs
))
801 // wxDebugMsg("focus proc from frame %ld\n",(long)frame);
803 // wxFrame *frame = (wxFrame *)clientData;
804 // frame->GetEventHandler()->OnSetFocus();
807 /* MATTEW: Used to insure that hide-&-show within an event cycle works */
808 static void wxFrameMapProc(Widget frameShell
, XtPointer clientData
,
809 XCrossingEvent
* event
)
811 wxFrame
*frame
= (wxFrame
*)wxGetWindowFromTable((Widget
)clientData
);
814 XEvent
*e
= (XEvent
*)event
;
816 if (e
->xany
.type
== MapNotify
)
819 XtVaSetValues(frameShell
, XmNiconic
, (Boolean
)False
, NULL
);
820 if (!frame
->GetVisibleStatus())
822 /* We really wanted this to be hidden! */
823 XtUnmapWidget((Widget
) frame
->GetShellWidget());
826 else if (e
->xany
.type
== UnmapNotify
)
828 XtVaSetValues(frameShell
, XmNiconic
, (Boolean
)True
, NULL
);
833 bool wxFrame::PreResize()
837 #endif // wxUSE_TOOLBAR
841 #endif // wxUSE_STATUSBAR
846 WXWidget
wxFrame::GetClientWidget() const
851 void wxFrame::ChangeFont(bool WXUNUSED(keepOriginalSize
))
856 void wxFrame::ChangeBackgroundColour()
858 if (GetClientWidget())
859 DoChangeBackgroundColour(GetClientWidget(), m_backgroundColour
);
862 void wxFrame::ChangeForegroundColour()
864 if (GetClientWidget())
865 DoChangeForegroundColour(GetClientWidget(), m_foregroundColour
);
868 void wxCloseFrameCallback(Widget
WXUNUSED(widget
), XtPointer client_data
, XmAnyCallbackStruct
*WXUNUSED(cbs
))
870 wxFrame
*frame
= (wxFrame
*)client_data
;
872 wxCloseEvent
closeEvent(wxEVT_CLOSE_WINDOW
, frame
->GetId());
873 closeEvent
.SetEventObject(frame
);
875 // May delete the frame (with delayed deletion)
876 frame
->GetEventHandler()->ProcessEvent(closeEvent
);
879 static void wxFrameEventHandler(Widget wid
,
880 XtPointer
WXUNUSED(client_data
),
882 Boolean
* continueToDispatch
)
884 wxFrame
*frame
= (wxFrame
*)wxGetWindowFromTable(wid
);
887 wxMouseEvent
wxevent(wxEVT_NULL
);
888 if (wxTranslateMouseEvent(wxevent
, frame
, wid
, event
))
890 wxevent
.SetEventObject(frame
);
891 wxevent
.SetId(frame
->GetId());
892 frame
->GetEventHandler()->ProcessEvent(wxevent
);
896 // An attempt to implement OnCharHook by calling OnCharHook first;
897 // if this returns TRUE, set continueToDispatch to False
898 // (don't continue processing).
899 // Otherwise set it to True and call OnChar.
900 wxKeyEvent
keyEvent(wxEVT_CHAR
);
901 if (wxTranslateKeyEvent(keyEvent
, frame
, wid
, event
))
903 keyEvent
.SetEventObject(frame
);
904 keyEvent
.SetId(frame
->GetId());
905 keyEvent
.SetEventType(wxEVT_CHAR_HOOK
);
906 if (frame
->GetEventHandler()->ProcessEvent(keyEvent
))
908 *continueToDispatch
= False
;
913 // For simplicity, OnKeyDown is the same as OnChar
914 // TODO: filter modifier key presses from OnChar
915 keyEvent
.SetEventType(wxEVT_KEY_DOWN
);
917 // Only process OnChar if OnKeyDown didn't swallow it
918 if (!frame
->GetEventHandler()->ProcessEvent (keyEvent
))
920 keyEvent
.SetEventType(wxEVT_CHAR
);
921 frame
->GetEventHandler()->ProcessEvent(keyEvent
);
927 *continueToDispatch
= True
;