]> git.saurik.com Git - wxWidgets.git/blame - src/osx/cocoa/stattext.mm
fix wxDataObjectComposite::GetFormatCount and add some comments to explain the reason...
[wxWidgets.git] / src / osx / cocoa / stattext.mm
CommitLineData
f033830e
SC
1/////////////////////////////////////////////////////////////////////////////
2// Name: src/osx/cocoa/stattext.mm
3// Purpose: wxStaticText
4// Author: Stefan Csomor
5// Modified by:
6// Created: 04/01/98
7// RCS-ID: $Id: stattext.cpp 54845 2008-07-30 14:52:41Z SC $
8// Copyright: (c) Stefan Csomor
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#include "wx/wxprec.h"
13
14#if wxUSE_STATTEXT
15
16#include "wx/stattext.h"
17
18#ifndef WX_PRECOMP
19 #include "wx/app.h"
20 #include "wx/utils.h"
21 #include "wx/dc.h"
22 #include "wx/dcclient.h"
23 #include "wx/settings.h"
24#endif // WX_PRECOMP
25
f033830e
SC
26#include "wx/osx/private.h"
27
28#include <stdio.h>
29
30wxSize wxStaticText::DoGetBestSize() const
31{
4850cc8b 32Point bounds;
f033830e 33
4850cc8b
SC
34#if wxOSX_USE_ATSU_TEXT
35 OSStatus err = noErr;
36 wxCFStringRef str( m_label, GetFont().GetEncoding() );
37
38 SInt16 baseline;
39 if ( m_font.MacGetThemeFontID() != kThemeCurrentPortFont )
f033830e 40 {
4850cc8b
SC
41 err = GetThemeTextDimensions(
42 (!m_label.empty() ? (CFStringRef)str : CFSTR(" ")),
43 m_font.MacGetThemeFontID(), kThemeStateActive, false, &bounds, &baseline );
44 verify_noerr( err );
f033830e
SC
45 }
46 else
47#endif
48 {
4850cc8b
SC
49 wxClientDC dc(const_cast<wxStaticText*>(this));
50 wxCoord width, height ;
16747764 51 dc.GetMultiLineTextExtent( m_label , &width, &height);
4850cc8b
SC
52 // Some labels seem to have their last characters
53 // stripped out. Adding 4 pixels seems to be enough to fix this.
54 bounds.h = width+4;
55 bounds.v = height;
56 }
f033830e 57
4850cc8b
SC
58 if ( m_label.empty() )
59 bounds.h = 0;
f033830e 60
f033830e
SC
61 bounds.h += MacGetLeftBorderSize() + MacGetRightBorderSize();
62 bounds.v += MacGetTopBorderSize() + MacGetBottomBorderSize();
63
64 return wxSize( bounds.h, bounds.v );
65}
66
67// for wxST_ELLIPSIZE_* support:
68
69/*
70 FIXME: UpdateLabel() should be called on size events when wxST_ELLIPSIZE_START is set
71 to allow correct dynamic ellipsizing of the label
72*/
73
6e7a89af
FM
74wxWidgetImplType* wxWidgetImpl::CreateStaticText( wxWindowMac* wxpeer,
75 wxWindowMac* parent,
76 wxWindowID id,
f033830e 77 const wxString& label,
6e7a89af 78 const wxPoint& pos,
f033830e 79 const wxSize& size,
6e7a89af
FM
80 long style,
81 long extraStyle)
f033830e 82{
dbeddfb9 83 NSRect r = wxOSXGetFrameForControl( wxpeer, pos , size ) ;
f033830e 84 wxNSTextField* v = [[wxNSTextField alloc] initWithFrame:r];
f033830e
SC
85
86 [v setBezeled:NO];
87 [v setEditable:NO];
88 [v setDrawsBackground:NO];
6e7a89af 89
f033830e 90 wxWidgetCocoaImpl* c = new wxWidgetCocoaImpl( wxpeer, v );
f033830e
SC
91 return c;
92/*
93 Rect bounds = wxMacGetBoundsForControl( wxpeer, pos, size );
94
95 wxMacControl* peer = new wxMacControl( wxpeer );
96 OSStatus err = CreateStaticTextControl(
97 MAC_WXHWND(parent->MacGetTopLevelWindowRef()),
98 &bounds, NULL, NULL, peer->GetControlRefAddr() );
99 verify_noerr( err );
100
101 if ( ( style & wxST_ELLIPSIZE_END ) || ( style & wxST_ELLIPSIZE_MIDDLE ) )
102 {
103 TruncCode tCode = truncEnd;
104 if ( style & wxST_ELLIPSIZE_MIDDLE )
105 tCode = truncMiddle;
106
107 err = peer->SetData( kControlStaticTextTruncTag, tCode );
108 err = peer->SetData( kControlStaticTextIsMultilineTag, (Boolean)0 );
109 }
110 return peer;
111 */
112}
113
114#endif //if wxUSE_STATTEXT