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"
20 #import <AppKit/NSBox.h>
21 #import <Foundation/NSString.h>
23 IMPLEMENT_DYNAMIC_CLASS(wxStaticBox, wxControl)
24 BEGIN_EVENT_TABLE(wxStaticBox, wxStaticBoxBase)
26 WX_IMPLEMENT_COCOA_OWNER(wxStaticBox,NSBox,NSView,NSView)
28 bool wxStaticBox::Create(wxWindow *parent, wxWindowID winid,
29 const wxString& title,
32 long style, const wxValidator& validator,
35 wxAutoNSAutoreleasePool pool;
36 if(!CreateControl(parent,winid,pos,size,style,validator,name))
39 SetNSBox([[NSBox alloc] initWithFrame:MakeDefaultNSRect(size)]);
40 [GetNSBox() setTitle:[NSString stringWithCString:title.c_str()]];
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;