]>
Commit | Line | Data |
---|---|---|
da0634c1 | 1 | ///////////////////////////////////////////////////////////////////////////// |
876cd6f7 | 2 | // Name: src/cocoa/statbox.mm |
da0634c1 DE |
3 | // Purpose: wxStaticBox |
4 | // Author: David Elliott | |
5 | // Modified by: | |
6 | // Created: 2003/02/15 | |
876cd6f7 | 7 | // RCS-ID: $Id$ |
da0634c1 | 8 | // Copyright: (c) 2003 David Elliott |
526954c5 | 9 | // Licence: wxWindows licence |
da0634c1 DE |
10 | ///////////////////////////////////////////////////////////////////////////// |
11 | ||
449c5673 | 12 | #include "wx/wxprec.h" |
876cd6f7 WS |
13 | |
14 | #include "wx/statbox.h" | |
15 | ||
449c5673 DE |
16 | #ifndef WX_PRECOMP |
17 | #include "wx/app.h" | |
449c5673 | 18 | #endif //WX_PRECOMP |
da0634c1 | 19 | |
7fc77f30 | 20 | #include "wx/cocoa/autorelease.h" |
f9c135f5 | 21 | #include "wx/cocoa/string.h" |
7fc77f30 | 22 | |
da0634c1 DE |
23 | #import <AppKit/NSBox.h> |
24 | #import <Foundation/NSString.h> | |
25 | ||
da0634c1 DE |
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, | |
a1f4186e DE |
31 | const wxString& title, const wxPoint& pos, const wxSize& size, |
32 | long style, const wxString& name) | |
da0634c1 | 33 | { |
7fc77f30 | 34 | wxAutoNSAutoreleasePool pool; |
a1f4186e | 35 | if(!CreateControl(parent,winid,pos,size,style,wxDefaultValidator,name)) |
da0634c1 DE |
36 | return false; |
37 | m_cocoaNSView = NULL; | |
8d656ea9 | 38 | SetNSBox([[NSBox alloc] initWithFrame:MakeDefaultNSRect(size)]); |
525007cf | 39 | CocoaSetLabelForObject(title, GetNSBox()); |
da0634c1 DE |
40 | if(m_parent) |
41 | m_parent->CocoaAddChild(this); | |
8d656ea9 DE |
42 | SetInitialFrameRect(pos,size); |
43 | ||
da0634c1 DE |
44 | return true; |
45 | } | |
46 | ||
47 | wxStaticBox::~wxStaticBox() | |
48 | { | |
911e17c6 | 49 | DisassociateNSBox(GetNSBox()); |
da0634c1 DE |
50 | } |
51 | ||
2ace5cf6 DE |
52 | void wxStaticBox::GetBordersForSizer(int *borderTop, int *borderOther) const |
53 | { | |
54 | NSRect contentRect = [[GetNSBox() contentView] frame]; | |
55 | NSRect thisRect = [m_cocoaNSView frame]; | |
dc483f61 VZ |
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; | |
2ace5cf6 DE |
59 | if(nextBorder > *borderOther) |
60 | *borderOther = nextBorder; | |
dc483f61 | 61 | nextBorder = (int)contentRect.origin.x; |
2ace5cf6 DE |
62 | if(nextBorder > *borderOther) |
63 | *borderOther = nextBorder; | |
64 | } | |
aa67a27a VZ |
65 | |
66 | void wxStaticBox::SetLabel(const wxString& label) | |
67 | { | |
68 | wxAutoNSAutoreleasePool pool; | |
525007cf | 69 | CocoaSetLabelForObject(label, GetNSBox()); |
aa67a27a VZ |
70 | } |
71 | ||
72 | wxString wxStaticBox::GetLabel() const | |
73 | { | |
74 | wxAutoNSAutoreleasePool pool; | |
75 | return wxStringWithNSString([GetNSBox() title]); | |
76 | } |