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 #include "wx/cocoa/autorelease.h"
17 #import <AppKit/NSBox.h>
18 #import <Foundation/NSString.h>
20 IMPLEMENT_DYNAMIC_CLASS(wxStaticBox, wxControl)
21 BEGIN_EVENT_TABLE(wxStaticBox, wxStaticBoxBase)
23 WX_IMPLEMENT_COCOA_OWNER(wxStaticBox,NSBox,NSView,NSView)
25 bool wxStaticBox::Create(wxWindow *parent, wxWindowID winid,
26 const wxString& title,
29 long style, const wxValidator& validator,
32 wxAutoNSAutoreleasePool pool;
33 if(!CreateControl(parent,winid,pos,size,style,validator,name))
36 SetNSBox([[NSBox alloc] initWithFrame:MakeDefaultNSRect(size)]);
37 [GetNSBox() setTitle:[NSString stringWithCString:title.c_str()]];
39 m_parent->CocoaAddChild(this);
40 SetInitialFrameRect(pos,size);
45 wxStaticBox::~wxStaticBox()
47 DisassociateNSBox(m_cocoaNSView);
50 void wxStaticBox::GetBordersForSizer(int *borderTop, int *borderOther) const
52 NSRect contentRect = [[GetNSBox() contentView] frame];
53 NSRect thisRect = [m_cocoaNSView frame];
54 *borderTop = (int)(thisRect.size.height - (contentRect.origin.y+contentRect.size.height));
55 *borderOther = (int)(thisRect.size.width - (contentRect.origin.x+contentRect.size.width));
56 int nextBorder = (int)contentRect.origin.y;
57 if(nextBorder > *borderOther)
58 *borderOther = nextBorder;
59 nextBorder = (int)contentRect.origin.x;
60 if(nextBorder > *borderOther)
61 *borderOther = nextBorder;