From: David Elliott Date: Tue, 8 Jul 2003 15:09:15 +0000 (+0000) Subject: Position the status bar properly X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/a58a6614646ea85d5cceb26f88e61a4a5a460149 Position the status bar properly git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@21759 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/cocoa/frame.h b/include/wx/cocoa/frame.h index 5c3a64c870..d20f4ed16f 100644 --- a/include/wx/cocoa/frame.h +++ b/include/wx/cocoa/frame.h @@ -14,6 +14,7 @@ class WXDLLEXPORT wxMenuBar; class WXDLLEXPORT wxMenuItem; +class WXDLLEXPORT wxStatusBar; class WXDLLEXPORT wxFrame: public wxFrameBase { @@ -68,6 +69,14 @@ public: // get the origin of the client area (which may be different from (0, 0) // if the frame has a toolbar) in client coordinates virtual wxPoint GetClientAreaOrigin() const; + +protected: + // Catch the Cocoa size event + virtual void Cocoa_FrameChanged(void); + void PositionStatusBar(); + // override base class virtuals + virtual void DoGetClientSize(int *width, int *height) const; + virtual void DoSetClientSize(int width, int height); }; #endif // _WX_COCOA_FRAME_H_ diff --git a/src/cocoa/frame.mm b/src/cocoa/frame.mm index 36e77191d4..3ab4609843 100644 --- a/src/cocoa/frame.mm +++ b/src/cocoa/frame.mm @@ -14,6 +14,7 @@ #include "wx/menuitem.h" #include "wx/app.h" #include "wx/log.h" +#include "wx/statusbr.h" #import #import @@ -78,8 +79,48 @@ bool wxFrame::Show(bool show) return ret; } +void wxFrame::Cocoa_FrameChanged(void) +{ + PositionStatusBar(); + wxFrameBase::Cocoa_FrameChanged(); +} + wxPoint wxFrame::GetClientAreaOrigin() const { return wxPoint(0,0); } +void wxFrame::DoGetClientSize(int *width, int *height) const +{ + wxFrameBase::DoGetClientSize(width,height); + if(height) + { + if(m_frameStatusBar && m_frameStatusBar->IsShown()) + *height -= m_frameStatusBar->GetSize().y; + } +} + +void wxFrame::DoSetClientSize(int width, int height) +{ + if(m_frameStatusBar && m_frameStatusBar->IsShown()) + height += m_frameStatusBar->GetSize().y; + wxFrameBase::DoSetClientSize(width,height); +} + +void wxFrame::PositionStatusBar() +{ + if( !m_frameStatusBar || !m_frameStatusBar->IsShown() ) + return; + + // Get the client size. Since it excludes the StatusBar area we want + // the top of the status bar to be directly under it (thus located at h) + // The width of the statusbar should then match the client width + int w, h; + GetClientSize(&w, &h); + + int sh; + m_frameStatusBar->GetSize(NULL, &sh); + + m_frameStatusBar->SetSize(0, h, w, sh); +} +