1 /////////////////////////////////////////////////////////////////////////////
2 // Name: cocoa/statbox.mm
3 // Purpose: wxStaticBox
4 // Author: David Elliott
8 // Copyright: (c) 2003 David Elliott
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
13 #include "wx/statbox.h"
15 #import <AppKit/NSBox.h>
16 #import <Foundation/NSString.h>
18 IMPLEMENT_DYNAMIC_CLASS(wxStaticBox, wxControl)
19 BEGIN_EVENT_TABLE(wxStaticBox, wxStaticBoxBase)
21 WX_IMPLEMENT_COCOA_OWNER(wxStaticBox,NSBox,NSView,NSView)
23 bool wxStaticBox::Create(wxWindow *parent, wxWindowID winid,
24 const wxString& title,
27 long style, const wxValidator& validator,
30 if(!CreateControl(parent,winid,pos,size,style,validator,name))
33 SetNSBox([[NSBox alloc] initWithFrame:NSMakeRect(0,0,30,30)]);
34 [GetNSBox() setTitle:[NSString stringWithCString:title.c_str()]];
36 m_parent->CocoaAddChild(this);
40 wxStaticBox::~wxStaticBox()
42 CocoaRemoveFromParent();
46 void wxStaticBox::GetBordersForSizer(int *borderTop, int *borderOther) const
48 NSRect contentRect = [[GetNSBox() contentView] frame];
49 NSRect thisRect = [m_cocoaNSView frame];
50 *borderTop = (int)(thisRect.size.height - (contentRect.origin.y+contentRect.size.height));
51 *borderOther = (int)(thisRect.size.width - (contentRect.origin.x+contentRect.size.width));
52 int nextBorder = (int)contentRect.origin.y;
53 if(nextBorder > *borderOther)
54 *borderOther = nextBorder;
55 nextBorder = (int)contentRect.origin.x;
56 if(nextBorder > *borderOther)
57 *borderOther = nextBorder;