]> git.saurik.com Git - wxWidgets.git/blob - src/cocoa/statbox.mm
re-enable using our own resize grip with GTK3, themes can (and do) disable the native...
[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: wxWindows 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 BEGIN_EVENT_TABLE(wxStaticBox, wxStaticBoxBase)
27 END_EVENT_TABLE()
28 WX_IMPLEMENT_COCOA_OWNER(wxStaticBox,NSBox,NSView,NSView)
29
30 bool wxStaticBox::Create(wxWindow *parent, wxWindowID winid,
31 const wxString& title, const wxPoint& pos, const wxSize& size,
32 long style, const wxString& name)
33 {
34 wxAutoNSAutoreleasePool pool;
35 if(!CreateControl(parent,winid,pos,size,style,wxDefaultValidator,name))
36 return false;
37 m_cocoaNSView = NULL;
38 SetNSBox([[NSBox alloc] initWithFrame:MakeDefaultNSRect(size)]);
39 CocoaSetLabelForObject(title, GetNSBox());
40 if(m_parent)
41 m_parent->CocoaAddChild(this);
42 SetInitialFrameRect(pos,size);
43
44 return true;
45 }
46
47 wxStaticBox::~wxStaticBox()
48 {
49 DisassociateNSBox(GetNSBox());
50 }
51
52 void wxStaticBox::GetBordersForSizer(int *borderTop, int *borderOther) const
53 {
54 NSRect contentRect = [[GetNSBox() contentView] frame];
55 NSRect thisRect = [m_cocoaNSView frame];
56 *borderTop = (int)(thisRect.size.height - (contentRect.origin.y+contentRect.size.height));
57 *borderOther = (int)(thisRect.size.width - (contentRect.origin.x+contentRect.size.width));
58 int nextBorder = (int)contentRect.origin.y;
59 if(nextBorder > *borderOther)
60 *borderOther = nextBorder;
61 nextBorder = (int)contentRect.origin.x;
62 if(nextBorder > *borderOther)
63 *borderOther = nextBorder;
64 }
65
66 void wxStaticBox::SetLabel(const wxString& label)
67 {
68 wxAutoNSAutoreleasePool pool;
69 CocoaSetLabelForObject(label, GetNSBox());
70 }
71
72 wxString wxStaticBox::GetLabel() const
73 {
74 wxAutoNSAutoreleasePool pool;
75 return wxStringWithNSString([GetNSBox() title]);
76 }