X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/292e5e1f17af67a5885f1fdaa8c45a8a5a2a3ca5..6178debcd342963974dbdce6ac2ddb2fbe89e42a:/src/osx/carbon/frame.cpp diff --git a/src/osx/carbon/frame.cpp b/src/osx/carbon/frame.cpp index 515da910a2..92ee6a94f5 100644 --- a/src/osx/carbon/frame.cpp +++ b/src/osx/carbon/frame.cpp @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: src/mac/carbon/frame.cpp +// Name: src/osx/carbon/frame.cpp // Purpose: wxFrame // Author: Stefan Csomor // Modified by: @@ -24,14 +24,11 @@ #include "wx/menuitem.h" #endif // WX_PRECOMP -#include "wx/osx/uma.h" +#include "wx/osx/private.h" BEGIN_EVENT_TABLE(wxFrame, wxFrameBase) EVT_ACTIVATE(wxFrame::OnActivate) - // EVT_MENU_HIGHLIGHT_ALL(wxFrame::OnMenuHighlight) EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged) -// EVT_IDLE(wxFrame::OnIdle) -// EVT_CLOSE(wxFrame::OnCloseWindow) END_EVENT_TABLE() IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxTopLevelWindow) @@ -64,7 +61,8 @@ bool wxFrame::Create(wxWindow *parent, wxFrame::~wxFrame() { - m_isBeingDeleted = true; + SendDestroyEvent(); + DeleteAllBars(); } @@ -80,11 +78,11 @@ wxPoint wxFrame::GetClientAreaOrigin() const int w, h; toolbar->GetSize(&w, &h); - if ( toolbar->GetWindowStyleFlag() & wxTB_VERTICAL ) + if ( toolbar->HasFlag(wxTB_LEFT) ) { pt.x += w; } - else + else if ( HasFlag(wxTB_TOP) ) { #if !wxOSX_USE_NATIVE_TOOLBAR pt.y += h; @@ -101,7 +99,10 @@ bool wxFrame::Enable(bool enable) if ( !wxWindow::Enable(enable) ) return false; - if ( m_frameMenuBar && m_frameMenuBar == wxMenuBar::MacGetInstalledMenuBar() ) +#if wxUSE_MENUS + // we should always enable/disable the menubar, even if we are not current, otherwise + // we might miss some state change later (happened eg in the docview sample after PrintPreview) + if ( m_frameMenuBar /*&& m_frameMenuBar == wxMenuBar::MacGetInstalledMenuBar()*/) { int iMaxMenu = m_frameMenuBar->GetMenuCount(); for ( int i = 0 ; i < iMaxMenu ; ++ i ) @@ -109,7 +110,7 @@ bool wxFrame::Enable(bool enable) m_frameMenuBar->EnableTop( i , enable ) ; } } - +#endif return true; } @@ -152,7 +153,7 @@ void wxFrame::OnSysColourChanged(wxSysColourChangedEvent& event) wxSysColourChangedEvent event2; event2.SetEventObject( m_frameStatusBar ); - m_frameStatusBar->ProcessEvent(event2); + m_frameStatusBar->GetEventHandler()->ProcessEvent(event2); } #endif // wxUSE_STATUSBAR @@ -198,6 +199,7 @@ void wxFrame::OnActivate(wxActivateEvent& event) wxSetFocusToChild(parent, &m_winLastFocused); +#if wxUSE_MENUS if (m_frameMenuBar != NULL) { m_frameMenuBar->MacInstallMenuBar(); @@ -212,20 +214,33 @@ void wxFrame::OnActivate(wxActivateEvent& event) tlf->GetMenuBar()->MacInstallMenuBar(); } } +#endif } } -void wxFrame::DetachMenuBar() +void wxFrame::HandleResized( double timestampsec ) { - if ( m_frameMenuBar ) - m_frameMenuBar->UnsetInvokingWindow(); + // according to the other ports we handle this within the OS level + // resize event, not within a wxSizeEvent + + PositionBars(); + + wxNonOwnedWindow::HandleResized( timestampsec ); +} +#if wxUSE_MENUS +void wxFrame::DetachMenuBar() +{ wxFrameBase::DetachMenuBar(); } void wxFrame::AttachMenuBar( wxMenuBar *menuBar ) { +#if wxOSX_USE_CARBON wxFrame* tlf = wxDynamicCast( wxNonOwnedWindow::GetFromWXWindow( (WXWindow) FrontNonFloatingWindow() ) , wxFrame ); +#else + wxFrame* tlf = (wxFrame*) wxTheApp->GetTopWindow(); +#endif bool makeCurrent = false; // if this is already the current menubar or we are the frontmost window @@ -239,11 +254,11 @@ void wxFrame::AttachMenuBar( wxMenuBar *menuBar ) if (m_frameMenuBar) { - m_frameMenuBar->SetInvokingWindow( this ); if (makeCurrent) m_frameMenuBar->MacInstallMenuBar(); } } +#endif void wxFrame::DoGetClientSize(int *x, int *y) const { @@ -318,17 +333,20 @@ void wxFrame::SetToolBar(wxToolBar *toolbar) if ( m_frameToolBar == toolbar ) return ; +#ifndef __WXOSX_IPHONE__ #if wxOSX_USE_NATIVE_TOOLBAR if ( m_frameToolBar ) m_frameToolBar->MacInstallNativeToolbar( false ) ; #endif - +#endif m_frameToolBar = toolbar ; +#ifndef __WXOSX_IPHONE__ #if wxOSX_USE_NATIVE_TOOLBAR if ( toolbar ) toolbar->MacInstallNativeToolbar( true ) ; #endif +#endif } wxToolBar* wxFrame::CreateToolBar(long style, wxWindowID id, const wxString& name) @@ -344,7 +362,7 @@ void wxFrame::PositionToolBar() int cw, ch; GetSize( &cw , &ch ) ; - + int statusX = 0 ; int statusY = 0 ; @@ -356,6 +374,12 @@ void wxFrame::PositionToolBar() } #endif +#ifdef __WXOSX_IPHONE__ + // TODO integrate this in a better way, on iphone the status bar is not a child of the content view + // but the toolbar is + ch -= 20; +#endif + if (GetToolBar()) { int tx, ty, tw, th;