1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/cocoa/statbox.mm
3 // Purpose: wxStaticBox
4 // Author: David Elliott
8 // Copyright: (c) 2003 David Elliott
9 // Licence: wxWidgets licence
10 /////////////////////////////////////////////////////////////////////////////
12 #include "wx/wxprec.h"
14 #include "wx/statbox.h"
20 #include "wx/cocoa/autorelease.h"
21 #include "wx/cocoa/string.h"
23 #import <AppKit/NSBox.h>
24 #import <Foundation/NSString.h>
26 IMPLEMENT_DYNAMIC_CLASS(wxStaticBox, wxControl)
27 BEGIN_EVENT_TABLE(wxStaticBox, wxStaticBoxBase)
29 WX_IMPLEMENT_COCOA_OWNER(wxStaticBox,NSBox,NSView,NSView)
31 bool wxStaticBox::Create(wxWindow *parent, wxWindowID winid,
32 const wxString& title, const wxPoint& pos, const wxSize& size,
33 long style, const wxString& name)
35 wxAutoNSAutoreleasePool pool;
36 if(!CreateControl(parent,winid,pos,size,style,wxDefaultValidator,name))
39 SetNSBox([[NSBox alloc] initWithFrame:MakeDefaultNSRect(size)]);
40 [GetNSBox() setTitle:wxNSStringWithWxString(GetLabelText(title))];
42 m_parent->CocoaAddChild(this);
43 SetInitialFrameRect(pos,size);
48 wxStaticBox::~wxStaticBox()
50 DisassociateNSBox(GetNSBox());
53 void wxStaticBox::GetBordersForSizer(int *borderTop, int *borderOther) const
55 NSRect contentRect = [[GetNSBox() contentView] frame];
56 NSRect thisRect = [m_cocoaNSView frame];
57 *borderTop = (int)(thisRect.size.height - (contentRect.origin.y+contentRect.size.height));
58 *borderOther = (int)(thisRect.size.width - (contentRect.origin.x+contentRect.size.width));
59 int nextBorder = (int)contentRect.origin.y;
60 if(nextBorder > *borderOther)
61 *borderOther = nextBorder;
62 nextBorder = (int)contentRect.origin.x;
63 if(nextBorder > *borderOther)
64 *borderOther = nextBorder;