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
;
388 delete m_frameToolBar
;
389 m_frameToolBar
= NULL
;
396 wxDeleteWindowFromTable((Widget
) m_workArea
);
398 XtDestroyWidget ((Widget
) m_workArea
);
401 // We need to destroy the base class icons here before we stop
402 // the event loop. This is a hack until we have a real top level
403 // window (which would be responsible for killing the event loop).
404 m_icons
.m_icons
.Empty();
408 wxDeleteWindowFromTable((Widget
) m_frameWidget
);
409 XtDestroyWidget ((Widget
) m_frameWidget
);
413 XtDestroyWidget ((Widget
) m_frameShell
);
415 SetMainWidget((WXWidget
) NULL
);
417 /* Check if it's the last top-level window */
419 if (wxTheApp
&& (wxTopLevelWindows
.Number() == 0))
421 wxTheApp
->SetTopWindow(NULL
);
423 if (wxTheApp
->GetExitOnFrameDelete())
425 // Signal to the app that we're going to close
426 wxTheApp
->ExitMainLoop();
431 // Get size *available for subwindows* i.e. excluding menu bar, toolbar etc.
432 void wxFrame::DoGetClientSize(int *x
, int *y
) const
435 XtVaGetValues((Widget
) m_workArea
, XmNwidth
, &xx
, XmNheight
, &yy
, NULL
);
437 if (m_frameStatusBar
)
440 m_frameStatusBar
->GetSize(& sbw
, & sbh
);
447 m_frameToolBar
->GetSize(& tbw
, & tbh
);
448 if (m_frameToolBar
->GetWindowStyleFlag() & wxTB_VERTICAL
)
453 #endif // wxUSE_TOOLBAR
455 if (GetMenuBar() != (wxMenuBar*) NULL)
457 // it seems that if a frame holds a panel, the menu bar size
458 // gets automatically taken care of --- grano@cs.helsinki.fi 4.4.95
459 bool hasSubPanel = FALSE;
460 for(wxNode* node = GetChildren().First(); node; node = node->Next())
462 wxWindow *win = (wxWindow *)node->Data();
463 hasSubPanel = (win->IsKindOf(CLASSINFO(wxPanel)) && !win->IsKindOf(CLASSINFO(wxDialog)));
470 XtVaGetValues((Widget) GetMenuBarWidget(), XmNheight, &ys, NULL);
479 // Set the client size (i.e. leave the calculation of borders etc.
481 void wxFrame::DoSetClientSize(int width
, int height
)
483 // Calculate how large the new main window should be
484 // by finding the difference between the client area and the
485 // main window area, and adding on to the new client area
487 XtVaSetValues((Widget
) m_workArea
, XmNwidth
, width
, NULL
);
491 if (m_frameStatusBar
)
494 m_frameStatusBar
->GetSize(& sbw
, & sbh
);
501 m_frameToolBar
->GetSize(& tbw
, & tbh
);
502 if (m_frameToolBar
->GetWindowStyleFlag() & wxTB_VERTICAL
)
507 #endif // wxUSE_TOOLBAR
509 XtVaSetValues((Widget
) m_workArea
, XmNheight
, height
, NULL
);
513 wxSizeEvent
sizeEvent(wxSize(width
, height
), GetId());
514 sizeEvent
.SetEventObject(this);
516 GetEventHandler()->ProcessEvent(sizeEvent
);
520 void wxFrame::DoGetSize(int *width
, int *height
) const
523 XtVaGetValues((Widget
) m_frameShell
, XmNwidth
, &xx
, XmNheight
, &yy
, NULL
);
524 *width
= xx
; *height
= yy
;
527 void wxFrame::DoGetPosition(int *x
, int *y
) const
529 Window parent_window
= XtWindow((Widget
) m_frameShell
),
530 next_parent
= XtWindow((Widget
) m_frameShell
),
531 root
= RootWindowOfScreen(XtScreen((Widget
) m_frameShell
));
533 // search for the parent that is child of ROOT, because the WM may
534 // reparent twice and notify only the next parent (like FVWM)
535 while (next_parent
!= root
) {
536 Window
*theChildren
; unsigned int n
;
537 parent_window
= next_parent
;
538 XQueryTree(XtDisplay((Widget
) m_frameShell
), parent_window
, &root
,
539 &next_parent
, &theChildren
, &n
);
540 XFree(theChildren
); // not needed
542 int xx
, yy
; unsigned int dummy
;
543 XGetGeometry(XtDisplay((Widget
) m_frameShell
), parent_window
, &root
,
544 &xx
, &yy
, &dummy
, &dummy
, &dummy
, &dummy
);
549 void wxFrame::DoSetSize(int x
, int y
, int width
, int height
, int WXUNUSED(sizeFlags
))
552 XtVaSetValues((Widget
) m_frameShell
, XmNx
, x
, NULL
);
554 XtVaSetValues((Widget
) m_frameShell
, XmNy
, y
, NULL
);
556 XtVaSetValues((Widget
) m_frameWidget
, XmNwidth
, width
, NULL
);
558 XtVaSetValues((Widget
) m_frameWidget
, XmNheight
, height
, NULL
);
560 if (!(height
== -1 && width
== -1))
564 wxSizeEvent
sizeEvent(wxSize(width
, height
), GetId());
565 sizeEvent
.SetEventObject(this);
567 GetEventHandler()->ProcessEvent(sizeEvent
);
571 bool wxFrame::Show(bool show
)
574 return wxWindow::Show(show
);
576 m_visibleStatus
= show
; /* show-&-hide fix */
580 XtMapWidget((Widget
) m_frameShell
);
581 XRaiseWindow(XtDisplay((Widget
) m_frameShell
), XtWindow((Widget
) m_frameShell
));
583 XtUnmapWidget((Widget
) m_frameShell
);
584 // XmUpdateDisplay(wxTheApp->topLevel); // Experimental: may be responsible for crashes
589 void wxFrame::Iconize(bool iconize
)
595 XtVaSetValues((Widget
) m_frameShell
, XmNiconic
, (Boolean
)iconize
, NULL
);
598 void wxFrame::Restore()
601 XtVaSetValues((Widget
) m_frameShell
, XmNiconic
, FALSE
, NULL
);
604 void wxFrame::Maximize(bool maximize
)
612 bool wxFrame::IsIconized() const
618 XtVaGetValues((Widget
) m_frameShell
, XmNiconic
, &iconic
, NULL
);
623 bool wxFrame::IsMaximized() const
625 // No maximizing in Motif (?)
629 void wxFrame::SetTitle(const wxString
& title
)
631 if (title
== m_title
)
637 XtVaSetValues((Widget
) m_frameShell
,
638 XmNtitle
, title
.c_str(),
639 XmNiconName
, title
.c_str(),
643 void wxFrame::DoSetIcon(const wxIcon
& icon
)
648 if (!icon
.Ok() || !icon
.GetPixmap())
651 XtVaSetValues((Widget
) m_frameShell
, XtNiconPixmap
, icon
.GetPixmap(), NULL
);
654 void wxFrame::SetIcon(const wxIcon
& icon
)
656 SetIcons( wxIconBundle( icon
) );
659 void wxFrame::SetIcons(const wxIconBundle
& icons
)
661 wxFrameBase::SetIcons( icons
);
666 DoSetIcon( m_icons
.GetIcon( -1 ) );
667 wxSetIconsX11(GetXDisplay(),
668 (WXWindow
) XtWindow( (Widget
) m_frameShell
), icons
);
671 void wxFrame::PositionStatusBar()
673 if (!m_frameStatusBar
)
677 GetClientSize(&w
, &h
);
679 m_frameStatusBar
->GetSize(&sw
, &sh
);
681 // Since we wish the status bar to be directly under the client area,
682 // we use the adjusted sizes without using wxSIZE_NO_ADJUSTMENTS.
683 m_frameStatusBar
->SetSize(0, h
, w
, sh
);
686 WXWidget
wxFrame::GetMenuBarWidget() const
689 return GetMenuBar()->GetMainWidget();
691 return (WXWidget
) NULL
;
694 void wxFrame::SetMenuBar(wxMenuBar
*menuBar
)
698 m_frameMenuBar
= NULL
;
702 // Currently can't set it twice
703 // wxASSERT_MSG( (m_frameMenuBar == (wxMenuBar*) NULL), "Cannot set the menubar more than once");
707 m_frameMenuBar
->DestroyMenuBar();
708 delete m_frameMenuBar
;
711 m_frameMenuBar
= menuBar
;
712 m_frameMenuBar
->CreateMenuBar(this);
715 // Responds to colour changes, and passes event on to children.
716 void wxFrame::OnSysColourChanged(wxSysColourChangedEvent
& event
)
718 SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE
));
721 if ( m_frameStatusBar
)
723 wxSysColourChangedEvent event2
;
724 event2
.SetEventObject( m_frameStatusBar
);
725 m_frameStatusBar
->ProcessEvent(event2
);
728 // Propagate the event to the non-top-level children
729 wxWindow::OnSysColourChanged(event
);
732 // Default activation behaviour - set the focus for the first child
734 void wxFrame::OnActivate(wxActivateEvent
& event
)
736 if (!event
.GetActive())
739 for(wxNode
*node
= GetChildren().First(); node
; node
= node
->Next())
741 // Find a child that's a subwindow, but not a dialog box.
742 wxWindow
*child
= (wxWindow
*)node
->Data();
743 if (!child
->IsKindOf(CLASSINFO(wxFrame
)) &&
744 !child
->IsKindOf(CLASSINFO(wxDialog
)))
754 wxToolBar
* wxFrame::CreateToolBar(long style
,
756 const wxString
& name
)
758 if ( wxFrameBase::CreateToolBar(style
, id
, name
) )
763 return m_frameToolBar
;
766 void wxFrame::PositionToolBar()
771 GetClientSize(& cw
, &ch
);
774 GetToolBar()->GetSize(& tw
, & th
);
776 if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL
)
778 // Use the 'real' position. wxSIZE_NO_ADJUSTMENTS
779 // means, pretend we don't have toolbar/status bar, so we
780 // have the original client size.
781 GetToolBar()->SetSize(0, 0, tw
, ch
+ th
, wxSIZE_NO_ADJUSTMENTS
);
785 // Use the 'real' position
786 GetToolBar()->SetSize(0, 0, cw
, th
, wxSIZE_NO_ADJUSTMENTS
);
790 #endif // wxUSE_TOOLBAR
792 void wxFrame::Raise()
794 Window parent_window
= XtWindow((Widget
) m_frameShell
),
795 next_parent
= XtWindow((Widget
) m_frameShell
),
796 root
= RootWindowOfScreen(XtScreen((Widget
) m_frameShell
));
797 // search for the parent that is child of ROOT, because the WM may
798 // reparent twice and notify only the next parent (like FVWM)
799 while (next_parent
!= root
) {
800 Window
*theChildren
; unsigned int n
;
801 parent_window
= next_parent
;
802 XQueryTree(XtDisplay((Widget
) m_frameShell
), parent_window
, &root
,
803 &next_parent
, &theChildren
, &n
);
804 XFree(theChildren
); // not needed
806 XRaiseWindow(XtDisplay((Widget
) m_frameShell
), parent_window
);
809 void wxFrame::Lower()
811 Window parent_window
= XtWindow((Widget
) m_frameShell
),
812 next_parent
= XtWindow((Widget
) m_frameShell
),
813 root
= RootWindowOfScreen(XtScreen((Widget
) m_frameShell
));
814 // search for the parent that is child of ROOT, because the WM may
815 // reparent twice and notify only the next parent (like FVWM)
816 while (next_parent
!= root
) {
817 Window
*theChildren
; unsigned int n
;
818 parent_window
= next_parent
;
819 XQueryTree(XtDisplay((Widget
) m_frameShell
), parent_window
, &root
,
820 &next_parent
, &theChildren
, &n
);
821 XFree(theChildren
); // not needed
823 XLowerWindow(XtDisplay((Widget
) m_frameShell
), parent_window
);
826 void wxFrameFocusProc(Widget
WXUNUSED(workArea
), XtPointer
WXUNUSED(clientData
),
827 XmAnyCallbackStruct
*WXUNUSED(cbs
))
829 // wxDebugMsg("focus proc from frame %ld\n",(long)frame);
831 // wxFrame *frame = (wxFrame *)clientData;
832 // frame->GetEventHandler()->OnSetFocus();
835 /* MATTEW: Used to insure that hide-&-show within an event cycle works */
836 static void wxFrameMapProc(Widget frameShell
, XtPointer clientData
,
837 XCrossingEvent
* event
)
839 wxFrame
*frame
= (wxFrame
*)wxGetWindowFromTable((Widget
)clientData
);
842 XEvent
*e
= (XEvent
*)event
;
844 if (e
->xany
.type
== MapNotify
)
847 XtVaSetValues(frameShell
, XmNiconic
, (Boolean
)False
, NULL
);
848 if (!frame
->GetVisibleStatus())
850 /* We really wanted this to be hidden! */
851 XtUnmapWidget((Widget
) frame
->GetShellWidget());
854 else if (e
->xany
.type
== UnmapNotify
)
856 XtVaSetValues(frameShell
, XmNiconic
, (Boolean
)True
, NULL
);
861 bool wxFrame::PreResize()
865 #endif // wxUSE_TOOLBAR
869 #endif // wxUSE_STATUSBAR
874 WXWidget
wxFrame::GetClientWidget() const
879 void wxFrame::ChangeFont(bool WXUNUSED(keepOriginalSize
))
884 void wxFrame::ChangeBackgroundColour()
886 if (GetClientWidget())
887 DoChangeBackgroundColour(GetClientWidget(), m_backgroundColour
);
890 void wxFrame::ChangeForegroundColour()
892 if (GetClientWidget())
893 DoChangeForegroundColour(GetClientWidget(), m_foregroundColour
);
896 void wxCloseFrameCallback(Widget
WXUNUSED(widget
), XtPointer client_data
, XmAnyCallbackStruct
*WXUNUSED(cbs
))
898 wxFrame
*frame
= (wxFrame
*)client_data
;
900 wxCloseEvent
closeEvent(wxEVT_CLOSE_WINDOW
, frame
->GetId());
901 closeEvent
.SetEventObject(frame
);
903 // May delete the frame (with delayed deletion)
904 frame
->GetEventHandler()->ProcessEvent(closeEvent
);
907 static void wxFrameEventHandler(Widget wid
,
908 XtPointer
WXUNUSED(client_data
),
910 Boolean
* continueToDispatch
)
912 wxFrame
*frame
= (wxFrame
*)wxGetWindowFromTable(wid
);
915 wxMouseEvent
wxevent(wxEVT_NULL
);
916 if (wxTranslateMouseEvent(wxevent
, frame
, wid
, event
))
918 wxevent
.SetEventObject(frame
);
919 wxevent
.SetId(frame
->GetId());
920 frame
->GetEventHandler()->ProcessEvent(wxevent
);
924 // An attempt to implement OnCharHook by calling OnCharHook first;
925 // if this returns TRUE, set continueToDispatch to False
926 // (don't continue processing).
927 // Otherwise set it to True and call OnChar.
928 wxKeyEvent
keyEvent(wxEVT_CHAR
);
929 if (wxTranslateKeyEvent(keyEvent
, frame
, wid
, event
))
931 keyEvent
.SetEventObject(frame
);
932 keyEvent
.SetId(frame
->GetId());
933 keyEvent
.SetEventType(wxEVT_CHAR_HOOK
);
934 if (frame
->GetEventHandler()->ProcessEvent(keyEvent
))
936 *continueToDispatch
= False
;
941 // For simplicity, OnKeyDown is the same as OnChar
942 // TODO: filter modifier key presses from OnChar
943 keyEvent
.SetEventType(wxEVT_KEY_DOWN
);
945 // Only process OnChar if OnKeyDown didn't swallow it
946 if (!frame
->GetEventHandler()->ProcessEvent (keyEvent
))
948 keyEvent
.SetEventType(wxEVT_CHAR
);
949 frame
->GetEventHandler()->ProcessEvent(keyEvent
);
955 *continueToDispatch
= True
;