From aa30d6c89637bdde41031da39dd43e709f8a14df Mon Sep 17 00:00:00 2001 From: Stefan Csomor Date: Wed, 19 Aug 2009 12:39:49 +0000 Subject: [PATCH] making sure an empty label is not reserving place above, fixes #11123 git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@61709 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/osx/cocoa/statbox.mm | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-) diff --git a/src/osx/cocoa/statbox.mm b/src/osx/cocoa/statbox.mm index c9dcb0cf58..d36fde1d35 100644 --- a/src/osx/cocoa/statbox.mm +++ b/src/osx/cocoa/statbox.mm @@ -30,6 +30,37 @@ @end +namespace +{ + class wxStaticBoxCocoaImpl : public wxWidgetCocoaImpl + { + public: + wxStaticBoxCocoaImpl(wxWindowMac *wxpeer, wxNSBox *v) + : wxWidgetCocoaImpl(wxpeer, v) + { + } + + virtual void SetLabel( const wxString& title, wxFontEncoding encoding ) + { + if (title.empty()) + [GetNSBox() setTitlePosition:NSNoTitle]; + else + [GetNSBox() setTitlePosition:NSAtTop]; + + wxWidgetCocoaImpl::SetLabel(title, encoding); + } + + private: + NSBox *GetNSBox() const + { + wxASSERT( [m_osxView isKindOfClass:[NSBox class]] ); + + return static_cast(m_osxView); + } + }; +} // anonymous namespace + + wxWidgetImplType* wxWidgetImpl::CreateGroupBox( wxWindowMac* wxpeer, wxWindowMac* WXUNUSED(parent), wxWindowID WXUNUSED(id), @@ -41,7 +72,7 @@ wxWidgetImplType* wxWidgetImpl::CreateGroupBox( wxWindowMac* wxpeer, { NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ; wxNSBox* v = [[wxNSBox alloc] initWithFrame:r]; - wxWidgetCocoaImpl* c = new wxWidgetCocoaImpl( wxpeer, v ); + wxStaticBoxCocoaImpl* c = new wxStaticBoxCocoaImpl( wxpeer, v ); c->SetFlipped(false); return c; } -- 2.45.2