]>
Commit | Line | Data |
---|---|---|
da0634c1 DE |
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 | ||
7fc77f30 DE |
15 | #include "wx/cocoa/autorelease.h" |
16 | ||
da0634c1 DE |
17 | #import <AppKit/NSBox.h> |
18 | #import <Foundation/NSString.h> | |
19 | ||
20 | IMPLEMENT_DYNAMIC_CLASS(wxStaticBox, wxControl) | |
21 | BEGIN_EVENT_TABLE(wxStaticBox, wxStaticBoxBase) | |
22 | END_EVENT_TABLE() | |
23 | WX_IMPLEMENT_COCOA_OWNER(wxStaticBox,NSBox,NSView,NSView) | |
24 | ||
25 | bool wxStaticBox::Create(wxWindow *parent, wxWindowID winid, | |
26 | const wxString& title, | |
27 | const wxPoint& pos, | |
28 | const wxSize& size, | |
29 | long style, const wxValidator& validator, | |
30 | const wxString& name) | |
31 | { | |
7fc77f30 | 32 | wxAutoNSAutoreleasePool pool; |
da0634c1 DE |
33 | if(!CreateControl(parent,winid,pos,size,style,validator,name)) |
34 | return false; | |
35 | m_cocoaNSView = NULL; | |
8d656ea9 | 36 | SetNSBox([[NSBox alloc] initWithFrame:MakeDefaultNSRect(size)]); |
da0634c1 DE |
37 | [GetNSBox() setTitle:[NSString stringWithCString:title.c_str()]]; |
38 | if(m_parent) | |
39 | m_parent->CocoaAddChild(this); | |
8d656ea9 DE |
40 | SetInitialFrameRect(pos,size); |
41 | ||
da0634c1 DE |
42 | return true; |
43 | } | |
44 | ||
45 | wxStaticBox::~wxStaticBox() | |
46 | { | |
570aaadf | 47 | DisassociateNSBox(m_cocoaNSView); |
da0634c1 DE |
48 | } |
49 | ||
2ace5cf6 DE |
50 | void wxStaticBox::GetBordersForSizer(int *borderTop, int *borderOther) const |
51 | { | |
52 | NSRect contentRect = [[GetNSBox() contentView] frame]; | |
53 | NSRect thisRect = [m_cocoaNSView frame]; | |
dc483f61 VZ |
54 | *borderTop = (int)(thisRect.size.height - (contentRect.origin.y+contentRect.size.height)); |
55 | *borderOther = (int)(thisRect.size.width - (contentRect.origin.x+contentRect.size.width)); | |
56 | int nextBorder = (int)contentRect.origin.y; | |
2ace5cf6 DE |
57 | if(nextBorder > *borderOther) |
58 | *borderOther = nextBorder; | |
dc483f61 | 59 | nextBorder = (int)contentRect.origin.x; |
2ace5cf6 DE |
60 | if(nextBorder > *borderOther) |
61 | *borderOther = nextBorder; | |
62 | } | |
63 |