]> git.saurik.com Git - wxWidgets.git/blame - src/cocoa/statbox.mm
Globally replace _T() with wxT().
[wxWidgets.git] / src / cocoa / statbox.mm
CommitLineData
da0634c1 1/////////////////////////////////////////////////////////////////////////////
876cd6f7 2// Name: src/cocoa/statbox.mm
da0634c1
DE
3// Purpose: wxStaticBox
4// Author: David Elliott
5// Modified by:
6// Created: 2003/02/15
876cd6f7 7// RCS-ID: $Id$
da0634c1 8// Copyright: (c) 2003 David Elliott
876cd6f7 9// Licence: wxWidgets licence
da0634c1
DE
10/////////////////////////////////////////////////////////////////////////////
11
449c5673 12#include "wx/wxprec.h"
876cd6f7
WS
13
14#include "wx/statbox.h"
15
449c5673
DE
16#ifndef WX_PRECOMP
17 #include "wx/app.h"
449c5673 18#endif //WX_PRECOMP
da0634c1 19
7fc77f30 20#include "wx/cocoa/autorelease.h"
f9c135f5 21#include "wx/cocoa/string.h"
7fc77f30 22
da0634c1
DE
23#import <AppKit/NSBox.h>
24#import <Foundation/NSString.h>
25
26IMPLEMENT_DYNAMIC_CLASS(wxStaticBox, wxControl)
27BEGIN_EVENT_TABLE(wxStaticBox, wxStaticBoxBase)
28END_EVENT_TABLE()
29WX_IMPLEMENT_COCOA_OWNER(wxStaticBox,NSBox,NSView,NSView)
30
31bool wxStaticBox::Create(wxWindow *parent, wxWindowID winid,
a1f4186e
DE
32 const wxString& title, const wxPoint& pos, const wxSize& size,
33 long style, const wxString& name)
da0634c1 34{
7fc77f30 35 wxAutoNSAutoreleasePool pool;
a1f4186e 36 if(!CreateControl(parent,winid,pos,size,style,wxDefaultValidator,name))
da0634c1
DE
37 return false;
38 m_cocoaNSView = NULL;
8d656ea9 39 SetNSBox([[NSBox alloc] initWithFrame:MakeDefaultNSRect(size)]);
525007cf 40 CocoaSetLabelForObject(title, GetNSBox());
da0634c1
DE
41 if(m_parent)
42 m_parent->CocoaAddChild(this);
8d656ea9
DE
43 SetInitialFrameRect(pos,size);
44
da0634c1
DE
45 return true;
46}
47
48wxStaticBox::~wxStaticBox()
49{
911e17c6 50 DisassociateNSBox(GetNSBox());
da0634c1
DE
51}
52
2ace5cf6
DE
53void wxStaticBox::GetBordersForSizer(int *borderTop, int *borderOther) const
54{
55 NSRect contentRect = [[GetNSBox() contentView] frame];
56 NSRect thisRect = [m_cocoaNSView frame];
dc483f61
VZ
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;
2ace5cf6
DE
60 if(nextBorder > *borderOther)
61 *borderOther = nextBorder;
dc483f61 62 nextBorder = (int)contentRect.origin.x;
2ace5cf6
DE
63 if(nextBorder > *borderOther)
64 *borderOther = nextBorder;
65}
aa67a27a
VZ
66
67void wxStaticBox::SetLabel(const wxString& label)
68{
69 wxAutoNSAutoreleasePool pool;
525007cf 70 CocoaSetLabelForObject(label, GetNSBox());
aa67a27a
VZ
71}
72
73wxString wxStaticBox::GetLabel() const
74{
75 wxAutoNSAutoreleasePool pool;
76 return wxStringWithNSString([GetNSBox() title]);
77}