]> git.saurik.com Git - wxWidgets.git/blob - src/cocoa/statbox.mm
improved deallocation fix for Visual C++ Multithreaded non DLL runtime
[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: wxWindows license
10 /////////////////////////////////////////////////////////////////////////////
11
12 #include "wx/app.h"
13 #include "wx/statbox.h"
14
15 #import <AppKit/NSBox.h>
16 #import <Foundation/NSString.h>
17
18 IMPLEMENT_DYNAMIC_CLASS(wxStaticBox, wxControl)
19 BEGIN_EVENT_TABLE(wxStaticBox, wxStaticBoxBase)
20 END_EVENT_TABLE()
21 WX_IMPLEMENT_COCOA_OWNER(wxStaticBox,NSBox,NSView,NSView)
22
23 bool wxStaticBox::Create(wxWindow *parent, wxWindowID winid,
24 const wxString& title,
25 const wxPoint& pos,
26 const wxSize& size,
27 long style, const wxValidator& validator,
28 const wxString& name)
29 {
30 if(!CreateControl(parent,winid,pos,size,style,validator,name))
31 return false;
32 m_cocoaNSView = NULL;
33 SetNSBox([[NSBox alloc] initWithFrame:NSMakeRect(0,0,30,30)]);
34 [GetNSBox() setTitle:[NSString stringWithCString:title.c_str()]];
35 if(m_parent)
36 m_parent->CocoaAddChild(this);
37 return true;
38 }
39
40 wxStaticBox::~wxStaticBox()
41 {
42 CocoaRemoveFromParent();
43 SetNSBox(NULL);
44 }
45
46 void wxStaticBox::GetBordersForSizer(int *borderTop, int *borderOther) const
47 {
48 NSRect contentRect = [[GetNSBox() contentView] frame];
49 NSRect thisRect = [m_cocoaNSView frame];
50 *borderTop = thisRect.size.height - (contentRect.origin.y+contentRect.size.height);
51 *borderOther = thisRect.size.width - (contentRect.origin.x+contentRect.size.width);
52 int nextBorder = contentRect.origin.y;
53 if(nextBorder > *borderOther)
54 *borderOther = nextBorder;
55 nextBorder = contentRect.origin.x;
56 if(nextBorder > *borderOther)
57 *borderOther = nextBorder;
58 }
59