1 /////////////////////////////////////////////////////////////////////////////
 
   2 // Name:        src/osx/cocoa/choice.mm
 
   4 // Author:      Stefan Csomor
 
   7 // Copyright:   (c) Stefan Csomor
 
   8 // Licence:     wxWindows licence
 
   9 /////////////////////////////////////////////////////////////////////////////
 
  11 #include "wx/wxprec.h"
 
  15 #include "wx/choice.h"
 
  19     #include "wx/dcclient.h"
 
  22 #include "wx/osx/private.h"
 
  24 @interface wxNSPopUpButton : NSPopUpButton
 
  30 @implementation wxNSPopUpButton
 
  34     static BOOL initialized = NO;
 
  38         wxOSXCocoaClassAddWXMethods( self );
 
  44    return [self indexOfSelectedItem];
 
  47 - (void) setIntValue: (int) v
 
  49     [self selectItemAtIndex:v];
 
  54 @interface NSView(PossibleSizeMethods)
 
  55 - (NSControlSize)controlSize;
 
  58 class wxChoiceCocoaImpl : public wxWidgetCocoaImpl
 
  61     wxChoiceCocoaImpl(wxWindowMac *wxpeer, wxNSPopUpButton *v)
 
  62     : wxWidgetCocoaImpl(wxpeer, v)
 
  66     void GetLayoutInset(int &left , int &top , int &right, int &bottom) const
 
  68         left = top = right = bottom = 0;
 
  69         NSControlSize size = NSRegularControlSize;
 
  70         if ( [m_osxView respondsToSelector:@selector(controlSize)] )
 
  71             size = [m_osxView controlSize];
 
  72         else if ([m_osxView respondsToSelector:@selector(cell)])
 
  74             id cell = [(id)m_osxView cell];
 
  75             if ([cell respondsToSelector:@selector(controlSize)])
 
  76                 size = [cell controlSize];
 
  81             case NSRegularControlSize:
 
  86             case NSSmallControlSize:
 
  91             case NSMiniControlSize:
 
 101 wxWidgetImplType* wxWidgetImpl::CreateChoice( wxWindowMac* wxpeer,
 
 102                                     wxWindowMac* WXUNUSED(parent),
 
 103                                     wxWindowID WXUNUSED(id),
 
 107                                     long WXUNUSED(style),
 
 108                                     long WXUNUSED(extraStyle))
 
 110     NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
 
 111     wxNSPopUpButton* v = [[wxNSPopUpButton alloc] initWithFrame:r pullsDown:NO];
 
 112     [v setMenu: menu->GetHMenu()];
 
 113     [v setAutoenablesItems:NO];
 
 114     wxWidgetCocoaImpl* c = new wxChoiceCocoaImpl( wxpeer, v );
 
 118 #endif // wxUSE_CHOICE