From: Stefan Csomor Date: Mon, 14 Feb 2011 19:13:04 +0000 (+0000) Subject: support framelayout for choice X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/026e7dcba01e53e4adfbc4d3156be4325d7aeefb?ds=inline support framelayout for choice git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@66888 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/osx/cocoa/choice.mm b/src/osx/cocoa/choice.mm index d08572479a..98e43fced1 100644 --- a/src/osx/cocoa/choice.mm +++ b/src/osx/cocoa/choice.mm @@ -52,6 +52,53 @@ @end +@interface NSView(PossibleSizeMethods) +- (NSControlSize)controlSize; +@end + +class wxChoiceCocoaImpl : public wxWidgetCocoaImpl +{ +public: + wxChoiceCocoaImpl(wxWindowMac *wxpeer, wxNSPopUpButton *v) + : wxWidgetCocoaImpl(wxpeer, v) + { + } + + void GetLayoutInset(int &left , int &top , int &right, int &bottom) const + { + left = top = right = bottom = 0; + NSControlSize size = NSRegularControlSize; + if ( [m_osxView respondsToSelector:@selector(controlSize)] ) + size = [m_osxView controlSize]; + else if ([m_osxView respondsToSelector:@selector(cell)]) + { + id cell = [(id)m_osxView cell]; + if ([cell respondsToSelector:@selector(controlSize)]) + size = [cell controlSize]; + } + + switch( size ) + { + case NSRegularControlSize: + left = right = 3; + top = 2; + bottom = 4; + break; + case NSSmallControlSize: + left = right = 3; + top = 1; + bottom = 4; + break; + case NSMiniControlSize: + left = 1; + right = 2; + top = 0; + bottom = 0; + break; + } + } +}; + wxWidgetImplType* wxWidgetImpl::CreateChoice( wxWindowMac* wxpeer, wxWindowMac* WXUNUSED(parent), wxWindowID WXUNUSED(id), @@ -65,7 +112,7 @@ wxWidgetImplType* wxWidgetImpl::CreateChoice( wxWindowMac* wxpeer, wxNSPopUpButton* v = [[wxNSPopUpButton alloc] initWithFrame:r pullsDown:NO]; [v setMenu: menu->GetHMenu()]; [v setAutoenablesItems:NO]; - wxWidgetCocoaImpl* c = new wxWidgetCocoaImpl( wxpeer, v ); + wxWidgetCocoaImpl* c = new wxChoiceCocoaImpl( wxpeer, v ); return c; }