]> git.saurik.com Git - wxWidgets.git/blob - src/osx/cocoa/statbox.mm
The alignment controls are now left-aligned if the floating controls are not shown.
[wxWidgets.git] / src / osx / cocoa / statbox.mm
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/osx/cocoa/statbox.mm
3 // Purpose: wxStaticBox
4 // Author: Stefan Csomor
5 // Modified by:
6 // Created: 1998-01-01
7 // Copyright: (c) Stefan Csomor
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11 #include "wx/wxprec.h"
12
13 #if wxUSE_STATBOX
14
15 #include "wx/statbox.h"
16 #include "wx/osx/private.h"
17
18 @implementation wxNSBox
19
20 + (void)initialize
21 {
22 static BOOL initialized = NO;
23 if (!initialized)
24 {
25 initialized = YES;
26 wxOSXCocoaClassAddWXMethods( self );
27 }
28 }
29
30 @end
31
32 namespace
33 {
34 class wxStaticBoxCocoaImpl : public wxWidgetCocoaImpl
35 {
36 public:
37 wxStaticBoxCocoaImpl(wxWindowMac *wxpeer, wxNSBox *v)
38 : wxWidgetCocoaImpl(wxpeer, v)
39 {
40 }
41
42 virtual void SetLabel( const wxString& title, wxFontEncoding encoding )
43 {
44 if (title.empty())
45 [GetNSBox() setTitlePosition:NSNoTitle];
46 else
47 [GetNSBox() setTitlePosition:NSAtTop];
48
49 wxWidgetCocoaImpl::SetLabel(title, encoding);
50 }
51
52 private:
53 NSBox *GetNSBox() const
54 {
55 wxASSERT( [m_osxView isKindOfClass:[NSBox class]] );
56
57 return static_cast<NSBox*>(m_osxView);
58 }
59 };
60 } // anonymous namespace
61
62
63 wxWidgetImplType* wxWidgetImpl::CreateGroupBox( wxWindowMac* wxpeer,
64 wxWindowMac* WXUNUSED(parent),
65 wxWindowID WXUNUSED(id),
66 const wxString& WXUNUSED(label),
67 const wxPoint& pos,
68 const wxSize& size,
69 long WXUNUSED(style),
70 long WXUNUSED(extraStyle))
71 {
72 NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
73 wxNSBox* v = [[wxNSBox alloc] initWithFrame:r];
74 wxStaticBoxCocoaImpl* c = new wxStaticBoxCocoaImpl( wxpeer, v );
75 #if !wxOSX_USE_NATIVE_FLIPPED
76 c->SetFlipped(false);
77 #endif
78 return c;
79 }
80
81 #endif // wxUSE_STATBOX
82