]>
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 | ||
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 | { | |
570aaadf | 42 | DisassociateNSBox(m_cocoaNSView); |
da0634c1 DE |
43 | } |
44 | ||
2ace5cf6 DE |
45 | void wxStaticBox::GetBordersForSizer(int *borderTop, int *borderOther) const |
46 | { | |
47 | NSRect contentRect = [[GetNSBox() contentView] frame]; | |
48 | NSRect thisRect = [m_cocoaNSView frame]; | |
dc483f61 VZ |
49 | *borderTop = (int)(thisRect.size.height - (contentRect.origin.y+contentRect.size.height)); |
50 | *borderOther = (int)(thisRect.size.width - (contentRect.origin.x+contentRect.size.width)); | |
51 | int nextBorder = (int)contentRect.origin.y; | |
2ace5cf6 DE |
52 | if(nextBorder > *borderOther) |
53 | *borderOther = nextBorder; | |
dc483f61 | 54 | nextBorder = (int)contentRect.origin.x; |
2ace5cf6 DE |
55 | if(nextBorder > *borderOther) |
56 | *borderOther = nextBorder; | |
57 | } | |
58 |