]> git.saurik.com Git - wxWidgets.git/blob - src/cocoa/statbox.mm
Correct signature of HitTest()
[wxWidgets.git] / src / cocoa / statbox.mm
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/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
14 #include "wx/statbox.h"
15
16 #ifndef WX_PRECOMP
17 #include "wx/app.h"
18 #endif //WX_PRECOMP
19
20 #include "wx/cocoa/autorelease.h"
21 #include "wx/cocoa/string.h"
22
23 #import <AppKit/NSBox.h>
24 #import <Foundation/NSString.h>
25
26 IMPLEMENT_DYNAMIC_CLASS(wxStaticBox, wxControl)
27 BEGIN_EVENT_TABLE(wxStaticBox, wxStaticBoxBase)
28 END_EVENT_TABLE()
29 WX_IMPLEMENT_COCOA_OWNER(wxStaticBox,NSBox,NSView,NSView)
30
31 bool wxStaticBox::Create(wxWindow *parent, wxWindowID winid,
32 const wxString& title, const wxPoint& pos, const wxSize& size,
33 long style, const wxString& name)
34 {
35 wxAutoNSAutoreleasePool pool;
36 if(!CreateControl(parent,winid,pos,size,style,wxDefaultValidator,name))
37 return false;
38 m_cocoaNSView = NULL;
39 SetNSBox([[NSBox alloc] initWithFrame:MakeDefaultNSRect(size)]);
40 CocoaSetLabelForObject(title, GetNSBox());
41 if(m_parent)
42 m_parent->CocoaAddChild(this);
43 SetInitialFrameRect(pos,size);
44
45 return true;
46 }
47
48 wxStaticBox::~wxStaticBox()
49 {
50 DisassociateNSBox(GetNSBox());
51 }
52
53 void wxStaticBox::GetBordersForSizer(int *borderTop, int *borderOther) const
54 {
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;
65 }
66
67 void wxStaticBox::SetLabel(const wxString& label)
68 {
69 wxAutoNSAutoreleasePool pool;
70 CocoaSetLabelForObject(label, GetNSBox());
71 }
72
73 wxString wxStaticBox::GetLabel() const
74 {
75 wxAutoNSAutoreleasePool pool;
76 return wxStringWithNSString([GetNSBox() title]);
77 }