]> git.saurik.com Git - wxWidgets.git/blob - src/cocoa/statbox.mm
final sweep over docs - replace & with \&
[wxWidgets.git] / src / cocoa / statbox.mm
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: cocoa/statbox.mm
3 // Purpose: wxStaticBox
4 // Author: David Elliott
5 // Modified by:
6 // Created: 2003/02/15
7 // RCS-ID: $Id:
8 // Copyright: (c) 2003 David Elliott
9 // Licence: wxWidgets licence
10 /////////////////////////////////////////////////////////////////////////////
11
12 #include "wx/wxprec.h"
13 #ifndef WX_PRECOMP
14 #include "wx/app.h"
15 #include "wx/statbox.h"
16 #endif //WX_PRECOMP
17
18 #include "wx/cocoa/autorelease.h"
19 #include "wx/cocoa/string.h"
20
21 #import <AppKit/NSBox.h>
22 #import <Foundation/NSString.h>
23
24 IMPLEMENT_DYNAMIC_CLASS(wxStaticBox, wxControl)
25 BEGIN_EVENT_TABLE(wxStaticBox, wxStaticBoxBase)
26 END_EVENT_TABLE()
27 WX_IMPLEMENT_COCOA_OWNER(wxStaticBox,NSBox,NSView,NSView)
28
29 bool wxStaticBox::Create(wxWindow *parent, wxWindowID winid,
30 const wxString& title, const wxPoint& pos, const wxSize& size,
31 long style, const wxString& name)
32 {
33 wxAutoNSAutoreleasePool pool;
34 if(!CreateControl(parent,winid,pos,size,style,wxDefaultValidator,name))
35 return false;
36 m_cocoaNSView = NULL;
37 SetNSBox([[NSBox alloc] initWithFrame:MakeDefaultNSRect(size)]);
38 [GetNSBox() setTitle:wxNSStringWithWxString(wxStripMenuCodes(title))];
39 if(m_parent)
40 m_parent->CocoaAddChild(this);
41 SetInitialFrameRect(pos,size);
42
43 return true;
44 }
45
46 wxStaticBox::~wxStaticBox()
47 {
48 DisassociateNSBox(GetNSBox());
49 }
50
51 void wxStaticBox::GetBordersForSizer(int *borderTop, int *borderOther) const
52 {
53 NSRect contentRect = [[GetNSBox() contentView] frame];
54 NSRect thisRect = [m_cocoaNSView frame];
55 *borderTop = (int)(thisRect.size.height - (contentRect.origin.y+contentRect.size.height));
56 *borderOther = (int)(thisRect.size.width - (contentRect.origin.x+contentRect.size.width));
57 int nextBorder = (int)contentRect.origin.y;
58 if(nextBorder > *borderOther)
59 *borderOther = nextBorder;
60 nextBorder = (int)contentRect.origin.x;
61 if(nextBorder > *borderOther)
62 *borderOther = nextBorder;
63 }
64