X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1c4f8f8d180afa03110f52eb95f9b083088f5c03..e7e91e03584a8e2582e7efd32a06f9f79ef65a52:/src/motif/frame.cpp?ds=sidebyside diff --git a/src/motif/frame.cpp b/src/motif/frame.cpp index 6f3126fefd..5092f9fa1a 100644 --- a/src/motif/frame.cpp +++ b/src/motif/frame.cpp @@ -21,7 +21,14 @@ #pragma implementation "frame.h" #endif -#include "wx/frame.h" + +#ifdef __VMS +#define XtDisplay XTDISPLAY +#define XtWindow XTWINDOW +#define XtScreen XTSCREEN +#endif + +# include "wx/frame.h" #include "wx/statusbr.h" #include "wx/toolbar.h" #include "wx/menuitem.h" @@ -31,6 +38,7 @@ #include "wx/settings.h" #include "wx/app.h" #include "wx/utils.h" +#include "wx/log.h" #ifdef __VMS__ #pragma message disable nosimpint @@ -42,6 +50,7 @@ #include #include +#include #if XmVersion >= 1002 #include #else @@ -65,11 +74,16 @@ #endif #include "wx/motif/private.h" +#include "wx/unix/utilsx11.h" // ---------------------------------------------------------------------------- // private functions // ---------------------------------------------------------------------------- +static void wxFrameEventHandler(Widget wid, + XtPointer WXUNUSED(client_data), + XEvent* event, + Boolean* continueToDispatch); static void wxCloseFrameCallback(Widget, XtPointer, XmAnyCallbackStruct *cbs); static void wxFrameFocusProc(Widget workArea, XtPointer clientData, XmAnyCallbackStruct *cbs); @@ -91,14 +105,12 @@ static bool wxTopLevelUsed = FALSE; // wxWin macros // ---------------------------------------------------------------------------- -#if !USE_SHARED_LIBRARY BEGIN_EVENT_TABLE(wxFrame, wxFrameBase) EVT_ACTIVATE(wxFrame::OnActivate) EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged) END_EVENT_TABLE() IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxWindow) -#endif // ============================================================================ // implementation @@ -129,7 +141,7 @@ bool wxFrame::Create(wxWindow *parent, const wxString& name) { if ( parent ) - AddChild(this); + parent->AddChild(this); else wxTopLevelWindows.Append(this); @@ -139,9 +151,9 @@ bool wxFrame::Create(wxWindow *parent, m_windowStyle = style; - m_backgroundColour = wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE); + m_backgroundColour = wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE); m_foregroundColour = *wxBLACK; - m_font = wxSystemSettings::GetSystemFont(wxSYS_DEFAULT_GUI_FONT); + m_font = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT); if ( id > -1 ) m_windowId = id; @@ -236,6 +248,12 @@ bool wxFrame::Create(wxWindow *parent, XtAddEventHandler((Widget) m_clientArea, ExposureMask,FALSE, wxUniversalRepaintProc, (XtPointer) this); + XtAddEventHandler((Widget) m_clientArea, + ButtonPressMask | ButtonReleaseMask | PointerMotionMask | KeyPressMask, + FALSE, + wxFrameEventHandler, + (XtPointer)this); + XtVaSetValues((Widget) m_frameWidget, XmNworkWindow, (Widget) m_workArea, NULL); @@ -244,6 +262,7 @@ bool wxFrame::Create(wxWindow *parent, XtManageChild((Widget) m_workArea); wxAddWindowToTable((Widget) m_workArea, this); + wxAddWindowToTable((Widget) m_clientArea, this); XtTranslations ptr; @@ -287,8 +306,6 @@ bool wxFrame::Create(wxWindow *parent, decor |= MWM_DECOR_TITLE; if (style & wxTHICK_FRAME) decor |= MWM_DECOR_BORDER; - if (style & wxTHICK_FRAME) - decor |= MWM_DECOR_BORDER; if (style & wxMINIMIZE_BOX) decor |= MWM_DECOR_MINIMIZE; if (style & wxMAXIMIZE_BOX) @@ -333,8 +350,14 @@ wxFrame::~wxFrame() m_isBeingDeleted = TRUE; if (m_clientArea) + { XtRemoveEventHandler((Widget) m_clientArea, ExposureMask, FALSE, wxUniversalRepaintProc, (XtPointer) this); + XtRemoveEventHandler((Widget) m_clientArea, ButtonPressMask | ButtonReleaseMask | PointerMotionMask | KeyPressMask, + FALSE, + wxFrameEventHandler, (XtPointer) this); + wxDeleteWindowFromTable((Widget) m_clientArea); + } if (GetMainWidget()) Show(FALSE); @@ -606,10 +629,8 @@ void wxFrame::SetTitle(const wxString& title) NULL); } -void wxFrame::SetIcon(const wxIcon& icon) +void wxFrame::DoSetIcon(const wxIcon& icon) { - m_icon = icon; - if (!m_frameShell) return; @@ -619,6 +640,23 @@ void wxFrame::SetIcon(const wxIcon& icon) XtVaSetValues((Widget) m_frameShell, XtNiconPixmap, icon.GetPixmap(), NULL); } +void wxFrame::SetIcon(const wxIcon& icon) +{ + SetIcons( wxIconBundle( icon ) ); +} + +void wxFrame::SetIcons(const wxIconBundle& icons) +{ + wxFrameBase::SetIcons( icons ); + + if (!m_frameShell) + return; + + DoSetIcon( m_icons.GetIcon( -1 ) ); + wxSetIconsX11(GetXDisplay(), + (WXWindow) XtWindow( (Widget) m_frameShell ), icons); +} + void wxFrame::PositionStatusBar() { if (!m_frameStatusBar) @@ -666,7 +704,7 @@ void wxFrame::SetMenuBar(wxMenuBar *menuBar) // Responds to colour changes, and passes event on to children. void wxFrame::OnSysColourChanged(wxSysColourChangedEvent& event) { - SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_APPWORKSPACE)); + SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_APPWORKSPACE)); Refresh(); if ( m_frameStatusBar ) @@ -855,3 +893,53 @@ void wxCloseFrameCallback(Widget WXUNUSED(widget), XtPointer client_data, XmAnyC frame->GetEventHandler()->ProcessEvent(closeEvent); } +static void wxFrameEventHandler(Widget wid, + XtPointer WXUNUSED(client_data), + XEvent* event, + Boolean* continueToDispatch) +{ + wxFrame *frame = (wxFrame *)wxGetWindowFromTable(wid); + if (frame) + { + wxMouseEvent wxevent(wxEVT_NULL); + if (wxTranslateMouseEvent(wxevent, frame, wid, event)) + { + wxevent.SetEventObject(frame); + wxevent.SetId(frame->GetId()); + frame->GetEventHandler()->ProcessEvent(wxevent); + } + else + { + // An attempt to implement OnCharHook by calling OnCharHook first; + // if this returns TRUE, set continueToDispatch to False + // (don't continue processing). + // Otherwise set it to True and call OnChar. + wxKeyEvent keyEvent(wxEVT_CHAR); + if (wxTranslateKeyEvent(keyEvent, frame, wid, event)) + { + keyEvent.SetEventObject(frame); + keyEvent.SetId(frame->GetId()); + keyEvent.SetEventType(wxEVT_CHAR_HOOK); + if (frame->GetEventHandler()->ProcessEvent(keyEvent)) + { + *continueToDispatch = False; + return; + } + else + { + // For simplicity, OnKeyDown is the same as OnChar + // TODO: filter modifier key presses from OnChar + keyEvent.SetEventType(wxEVT_KEY_DOWN); + + // Only process OnChar if OnKeyDown didn't swallow it + if (!frame->GetEventHandler()->ProcessEvent (keyEvent)) + { + keyEvent.SetEventType(wxEVT_CHAR); + frame->GetEventHandler()->ProcessEvent(keyEvent); + } + } + } + } + } + *continueToDispatch = True; +}