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
& 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::SetIcon(const wxIcon
& icon
)
639 if (!icon
.Ok() || !icon
.GetPixmap())
642 XtVaSetValues((Widget
) m_frameShell
, XtNiconPixmap
, icon
.GetPixmap(), NULL
);
645 void wxFrame::PositionStatusBar()
647 if (!m_frameStatusBar
)
651 GetClientSize(&w
, &h
);
653 m_frameStatusBar
->GetSize(&sw
, &sh
);
655 // Since we wish the status bar to be directly under the client area,
656 // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS.
657 m_frameStatusBar
->SetSize(0, h
, w
, sh
);
660 WXWidget
wxFrame::GetMenuBarWidget() const
663 return GetMenuBar()->GetMainWidget();
665 return (WXWidget
) NULL
;
668 void wxFrame::SetMenuBar(wxMenuBar
*menuBar
)
672 m_frameMenuBar
= NULL
;
676 // Currently can't set it twice
677 // wxASSERT_MSG( (m_frameMenuBar == (wxMenuBar*) NULL), "Cannot set the menubar more than once");
681 m_frameMenuBar
->DestroyMenuBar();
682 delete m_frameMenuBar
;
685 m_frameMenuBar
= menuBar
;
686 m_frameMenuBar
->CreateMenuBar(this);
689 // Responds to colour changes, and passes event on to children.
690 void wxFrame::OnSysColourChanged(wxSysColourChangedEvent
& event
)
692 SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
));
695 if ( m_frameStatusBar
)
697 wxSysColourChangedEvent event2
;
698 event2
.SetEventObject( m_frameStatusBar
);
699 m_frameStatusBar
->ProcessEvent(event2
);
702 // Propagate the event to the non-top-level children
703 wxWindow::OnSysColourChanged(event
);
706 // Default activation behaviour - set the focus for the first child
708 void wxFrame::OnActivate(wxActivateEvent
& event
)
710 if (!event
.GetActive())
713 for(wxNode
*node
= GetChildren().First(); node
; node
= node
->Next())
715 // Find a child that's a subwindow, but not a dialog box.
716 wxWindow
*child
= (wxWindow
*)node
->Data();
717 if (!child
->IsKindOf(CLASSINFO(wxFrame
)) &&
718 !child
->IsKindOf(CLASSINFO(wxDialog
)))
728 wxToolBar
* wxFrame::CreateToolBar(long style
,
730 const wxString
& name
)
732 if ( wxFrameBase::CreateToolBar(style
, id
, name
) )
737 return m_frameToolBar
;
740 void wxFrame::PositionToolBar()
745 GetClientSize(& cw
, &ch
);
748 GetToolBar()->GetSize(& tw
, & th
);
750 if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL
)
752 // Use the 'real' position. wxSIZE_NO_ADJUSTMENTS
753 // means, pretend we don't have toolbar/status bar, so we
754 // have the original client size.
755 GetToolBar()->SetSize(0, 0, tw
, ch
+ th
, wxSIZE_NO_ADJUSTMENTS
);
759 // Use the 'real' position
760 GetToolBar()->SetSize(0, 0, cw
, th
, wxSIZE_NO_ADJUSTMENTS
);
764 #endif // wxUSE_TOOLBAR
766 void wxFrame::Raise()
768 Window parent_window
= XtWindow((Widget
) m_frameShell
),
769 next_parent
= XtWindow((Widget
) m_frameShell
),
770 root
= RootWindowOfScreen(XtScreen((Widget
) m_frameShell
));
771 // search for the parent that is child of ROOT, because the WM may
772 // reparent twice and notify only the next parent (like FVWM)
773 while (next_parent
!= root
) {
774 Window
*theChildren
; unsigned int n
;
775 parent_window
= next_parent
;
776 XQueryTree(XtDisplay((Widget
) m_frameShell
), parent_window
, &root
,
777 &next_parent
, &theChildren
, &n
);
778 XFree(theChildren
); // not needed
780 XRaiseWindow(XtDisplay((Widget
) m_frameShell
), parent_window
);
783 void wxFrame::Lower()
785 Window parent_window
= XtWindow((Widget
) m_frameShell
),
786 next_parent
= XtWindow((Widget
) m_frameShell
),
787 root
= RootWindowOfScreen(XtScreen((Widget
) m_frameShell
));
788 // search for the parent that is child of ROOT, because the WM may
789 // reparent twice and notify only the next parent (like FVWM)
790 while (next_parent
!= root
) {
791 Window
*theChildren
; unsigned int n
;
792 parent_window
= next_parent
;
793 XQueryTree(XtDisplay((Widget
) m_frameShell
), parent_window
, &root
,
794 &next_parent
, &theChildren
, &n
);
795 XFree(theChildren
); // not needed
797 XLowerWindow(XtDisplay((Widget
) m_frameShell
), parent_window
);
800 void wxFrameFocusProc(Widget
WXUNUSED(workArea
), XtPointer
WXUNUSED(clientData
),
801 XmAnyCallbackStruct
*WXUNUSED(cbs
))
803 // wxDebugMsg("focus proc from frame %ld\n",(long)frame);
805 // wxFrame *frame = (wxFrame *)clientData;
806 // frame->GetEventHandler()->OnSetFocus();
809 /* MATTEW: Used to insure that hide-&-show within an event cycle works */
810 static void wxFrameMapProc(Widget frameShell
, XtPointer clientData
,
811 XCrossingEvent
* event
)
813 wxFrame
*frame
= (wxFrame
*)wxGetWindowFromTable((Widget
)clientData
);
816 XEvent
*e
= (XEvent
*)event
;
818 if (e
->xany
.type
== MapNotify
)
821 XtVaSetValues(frameShell
, XmNiconic
, (Boolean
)False
, NULL
);
822 if (!frame
->GetVisibleStatus())
824 /* We really wanted this to be hidden! */
825 XtUnmapWidget((Widget
) frame
->GetShellWidget());
828 else if (e
->xany
.type
== UnmapNotify
)
830 XtVaSetValues(frameShell
, XmNiconic
, (Boolean
)True
, NULL
);
835 bool wxFrame::PreResize()
839 #endif // wxUSE_TOOLBAR
843 #endif // wxUSE_STATUSBAR
848 WXWidget
wxFrame::GetClientWidget() const
853 void wxFrame::ChangeFont(bool WXUNUSED(keepOriginalSize
))
858 void wxFrame::ChangeBackgroundColour()
860 if (GetClientWidget())
861 DoChangeBackgroundColour(GetClientWidget(), m_backgroundColour
);
864 void wxFrame::ChangeForegroundColour()
866 if (GetClientWidget())
867 DoChangeForegroundColour(GetClientWidget(), m_foregroundColour
);
870 void wxCloseFrameCallback(Widget
WXUNUSED(widget
), XtPointer client_data
, XmAnyCallbackStruct
*WXUNUSED(cbs
))
872 wxFrame
*frame
= (wxFrame
*)client_data
;
874 wxCloseEvent
closeEvent(wxEVT_CLOSE_WINDOW
, frame
->GetId());
875 closeEvent
.SetEventObject(frame
);
877 // May delete the frame (with delayed deletion)
878 frame
->GetEventHandler()->ProcessEvent(closeEvent
);
881 static void wxFrameEventHandler(Widget wid
,
882 XtPointer
WXUNUSED(client_data
),
884 Boolean
* continueToDispatch
)
886 wxFrame
*frame
= (wxFrame
*)wxGetWindowFromTable(wid
);
889 wxMouseEvent
wxevent(wxEVT_NULL
);
890 if (wxTranslateMouseEvent(wxevent
, frame
, wid
, event
))
892 wxevent
.SetEventObject(frame
);
893 wxevent
.SetId(frame
->GetId());
894 frame
->GetEventHandler()->ProcessEvent(wxevent
);
898 // An attempt to implement OnCharHook by calling OnCharHook first;
899 // if this returns TRUE, set continueToDispatch to False
900 // (don't continue processing).
901 // Otherwise set it to True and call OnChar.
902 wxKeyEvent
keyEvent(wxEVT_CHAR
);
903 if (wxTranslateKeyEvent(keyEvent
, frame
, wid
, event
))
905 keyEvent
.SetEventObject(frame
);
906 keyEvent
.SetId(frame
->GetId());
907 keyEvent
.SetEventType(wxEVT_CHAR_HOOK
);
908 if (frame
->GetEventHandler()->ProcessEvent(keyEvent
))
910 *continueToDispatch
= False
;
915 // For simplicity, OnKeyDown is the same as OnChar
916 // TODO: filter modifier key presses from OnChar
917 keyEvent
.SetEventType(wxEVT_KEY_DOWN
);
919 // Only process OnChar if OnKeyDown didn't swallow it
920 if (!frame
->GetEventHandler()->ProcessEvent (keyEvent
))
922 keyEvent
.SetEventType(wxEVT_CHAR
);
923 frame
->GetEventHandler()->ProcessEvent(keyEvent
);
929 *continueToDispatch
= True
;