1 /////////////////////////////////////////////////////////////////////////////
2 // Name: cocoa/statbox.mm
3 // Purpose: wxStaticBox
4 // Author: David Elliott
8 // Copyright: (c) 2003 David Elliott
9 // Licence: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
12 #include "wx/wxprec.h"
15 #include "wx/statbox.h"
18 #include "wx/cocoa/autorelease.h"
19 #include "wx/cocoa/string.h"
21 #import <AppKit/NSBox.h>
22 #import <Foundation/NSString.h>
24 IMPLEMENT_DYNAMIC_CLASS(wxStaticBox, wxControl)
25 BEGIN_EVENT_TABLE(wxStaticBox, wxStaticBoxBase)
27 WX_IMPLEMENT_COCOA_OWNER(wxStaticBox,NSBox,NSView,NSView)
29 bool wxStaticBox::Create(wxWindow *parent, wxWindowID winid,
30 const wxString& title,
33 long style, const wxValidator& validator,
36 wxAutoNSAutoreleasePool pool;
37 if(!CreateControl(parent,winid,pos,size,style,validator,name))
40 SetNSBox([[NSBox alloc] initWithFrame:MakeDefaultNSRect(size)]);
41 [GetNSBox() setTitle:wxNSStringWithWxString(wxStripMenuCodes(title))];
43 m_parent->CocoaAddChild(this);
44 SetInitialFrameRect(pos,size);
49 wxStaticBox::~wxStaticBox()
51 DisassociateNSBox(GetNSBox());
54 void wxStaticBox::GetBordersForSizer(int *borderTop, int *borderOther) const
56 NSRect contentRect = [[GetNSBox() contentView] frame];
57 NSRect thisRect = [m_cocoaNSView frame];
58 *borderTop = (int)(thisRect.size.height - (contentRect.origin.y+contentRect.size.height));
59 *borderOther = (int)(thisRect.size.width - (contentRect.origin.x+contentRect.size.width));
60 int nextBorder = (int)contentRect.origin.y;
61 if(nextBorder > *borderOther)
62 *borderOther = nextBorder;
63 nextBorder = (int)contentRect.origin.x;
64 if(nextBorder > *borderOther)
65 *borderOther = nextBorder;