X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/c6212a0cb7e6285f62198a9411d91bbe8dc06e60..08670ea85abf4b4946a9ce64971b591d7b1ee30b:/src/osx/carbon/frame.cpp diff --git a/src/osx/carbon/frame.cpp b/src/osx/carbon/frame.cpp index cfa6446372..e7c53a27aa 100644 --- a/src/osx/carbon/frame.cpp +++ b/src/osx/carbon/frame.cpp @@ -29,10 +29,9 @@ BEGIN_EVENT_TABLE(wxFrame, wxFrameBase) EVT_ACTIVATE(wxFrame::OnActivate) EVT_SYS_COLOUR_CHANGED(wxFrame::OnSysColourChanged) + EVT_SIZE(wxFrame::OnSize) END_EVENT_TABLE() -IMPLEMENT_DYNAMIC_CLASS(wxFrame, wxTopLevelWindow) - #define WX_MAC_STATUSBAR_HEIGHT 18 // ---------------------------------------------------------------------------- @@ -52,7 +51,6 @@ bool wxFrame::Create(wxWindow *parent, long style, const wxString& name) { - if ( !wxTopLevelWindow::Create(parent, id, title, pos, size, style, name) ) return false; @@ -78,11 +76,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 ( toolbar->HasFlag(wxTB_TOP) ) { #if !wxOSX_USE_NATIVE_TOOLBAR pt.y += h; @@ -153,7 +151,7 @@ void wxFrame::OnSysColourChanged(wxSysColourChangedEvent& event) wxSysColourChangedEvent event2; event2.SetEventObject( m_frameStatusBar ); - m_frameStatusBar->ProcessEvent(event2); + m_frameStatusBar->GetEventHandler()->ProcessEvent(event2); } #endif // wxUSE_STATUSBAR @@ -218,22 +216,17 @@ void wxFrame::OnActivate(wxActivateEvent& event) } } -void wxFrame::HandleResized( double timestampsec ) -{ - // according to the other ports we handle this within the OS level - // resize event, not within a wxSizeEvent +void wxFrame::OnSize(wxSizeEvent& event) +{ PositionBars(); - - wxNonOwnedWindow::HandleResized( timestampsec ); + + event.Skip(); } #if wxUSE_MENUS void wxFrame::DetachMenuBar() { - if ( m_frameMenuBar ) - m_frameMenuBar->UnsetInvokingWindow(); - wxFrameBase::DetachMenuBar(); } @@ -257,7 +250,6 @@ void wxFrame::AttachMenuBar( wxMenuBar *menuBar ) if (m_frameMenuBar) { - m_frameMenuBar->SetInvokingWindow( this ); if (makeCurrent) m_frameMenuBar->MacInstallMenuBar(); } @@ -280,11 +272,16 @@ void wxFrame::DoGetClientSize(int *x, int *y) const int w, h; toolbar->GetSize(&w, &h); - if ( toolbar->GetWindowStyleFlag() & wxTB_VERTICAL ) + if ( toolbar->IsVertical() ) { if ( x ) *x -= w; } + else if ( toolbar->HasFlag( wxTB_BOTTOM ) ) + { + if ( y ) + *y -= h; + } else { #if !wxOSX_USE_NATIVE_TOOLBAR @@ -337,17 +334,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) @@ -362,7 +362,7 @@ void wxFrame::PositionToolBar() { int cw, ch; - GetSize( &cw , &ch ) ; + wxTopLevelWindow::DoGetClientSize( &cw , &ch ); int statusX = 0 ; int statusY = 0 ; @@ -370,31 +370,42 @@ void wxFrame::PositionToolBar() #if wxUSE_STATUSBAR if (GetStatusBar() && GetStatusBar()->IsShown()) { - GetStatusBar()->GetClientSize(&statusX, &statusY); + GetStatusBar()->GetSize(&statusX, &statusY); ch -= statusY; } #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; tx = ty = 0 ; GetToolBar()->GetSize(&tw, &th); - if (GetToolBar()->GetWindowStyleFlag() & wxTB_VERTICAL) + if (GetToolBar()->HasFlag(wxTB_LEFT)) + { + // Use the 'real' position. wxSIZE_NO_ADJUSTMENTS + // means, pretend we don't have toolbar/status bar, so we + // have the original client size. + GetToolBar()->SetSize(tx , ty , tw, ch , wxSIZE_NO_ADJUSTMENTS ); + } + else if (GetToolBar()->HasFlag(wxTB_RIGHT)) { // Use the 'real' position. wxSIZE_NO_ADJUSTMENTS // means, pretend we don't have toolbar/status bar, so we // have the original client size. + tx = cw - tw; GetToolBar()->SetSize(tx , ty , tw, ch , wxSIZE_NO_ADJUSTMENTS ); } - else if (GetToolBar()->GetWindowStyleFlag() & wxTB_BOTTOM) + else if (GetToolBar()->HasFlag(wxTB_BOTTOM)) { - //FIXME: this positions the tool bar almost correctly, but still it doesn't work right yet, - //as 1) the space for the 'old' top toolbar is still taken up, and 2) the toolbar - //doesn't extend it's width to the width of the frame. tx = 0; - ty = ch - (th + statusY); + ty = ch - th; GetToolBar()->SetSize(tx, ty, cw, th, wxSIZE_NO_ADJUSTMENTS ); } else