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