]> git.saurik.com Git - wxWidgets.git/blame - src/osx/stattext_osx.cpp
Don't call wxSafeYield() from wxGenericListCtrl::EditLabel().
[wxWidgets.git] / src / osx / stattext_osx.cpp
CommitLineData
e53b3d16 1/////////////////////////////////////////////////////////////////////////////
80fdcdb9 2// Name: src/osx/stattext_osx.cpp
e53b3d16
SC
3// Purpose: wxStaticText
4// Author: Stefan Csomor
5// Modified by:
6// Created: 04/01/98
b5b208a1 7// RCS-ID: $Id$
e53b3d16
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
e53b3d16
SC
26#include "wx/osx/private.h"
27
28#include <stdio.h>
29
e53b3d16
SC
30
31bool wxStaticText::Create( wxWindow *parent,
32 wxWindowID id,
33 const wxString& label,
34 const wxPoint& pos,
35 const wxSize& size,
36 long style,
37 const wxString& name )
d15694e8
SC
38{
39 DontCreatePeer();
40
e53b3d16
SC
41 if ( !wxControl::Create( parent, id, pos, size, style, wxDefaultValidator, name ) )
42 return false;
43
22756322 44 SetPeer(wxWidgetImpl::CreateStaticText( this, parent, id, label, pos, size, style, GetExtraStyle() ));
e53b3d16
SC
45
46 MacPostControlCreate( pos, size );
47
48 SetLabel(label);
49
50 return true;
51}
52
53void wxStaticText::SetLabel(const wxString& label)
54{
55 m_labelOrig = label;
56
57 // middle/end ellipsization is handled by the OS:
03647350 58 if ( HasFlag(wxST_ELLIPSIZE_END) || HasFlag(wxST_ELLIPSIZE_MIDDLE)
f1c40652 59#if wxOSX_USE_COCOA // Cocoa has all three modes
03647350 60 || HasFlag(wxST_ELLIPSIZE_START)
f1c40652
SC
61#endif
62 )
e53b3d16 63 {
2318a5d7 64 // leave ellipsization to the OS
3da9cffc 65 DoSetLabel(GetLabel());
e53b3d16
SC
66 }
67 else // not supported natively
68 {
3da9cffc 69 DoSetLabel(GetEllipsizedLabel());
e53b3d16
SC
70 }
71
72 if ( !(GetWindowStyle() & wxST_NO_AUTORESIZE) &&
73 !IsEllipsized() ) // don't resize if we adjust to current size
74 {
75 InvalidateBestSize();
76 SetSize( GetBestSize() );
77 }
78
79 Refresh();
80
81 // we shouldn't need forced updates
82 // Update();
83}
84
85bool wxStaticText::SetFont(const wxFont& font)
86{
87 bool ret = wxControl::SetFont( font );
88
89 if ( ret )
90 {
91 if ( !(GetWindowStyle() & wxST_NO_AUTORESIZE) )
92 {
93 InvalidateBestSize();
94 SetSize( GetBestSize() );
95 }
96 }
97
98 return ret;
99}
100
101void wxStaticText::DoSetLabel(const wxString& label)
102{
e53b3d16 103 m_label = RemoveMnemonics(label);
22756322 104 GetPeer()->SetLabel(m_label , GetFont().GetEncoding() );
e53b3d16
SC
105}
106
f672c969
VZ
107#if wxUSE_MARKUP && wxOSX_USE_COCOA
108
109bool wxStaticText::DoSetLabelMarkup(const wxString& markup)
110{
111 if ( !wxStaticTextBase::DoSetLabelMarkup(markup) )
112 return false;
113
22756322 114 GetPeer()->SetLabelMarkup(markup);
f672c969
VZ
115
116 return true;
117}
118
119#endif // wxUSE_MARKUP && wxOSX_USE_COCOA
120
e53b3d16
SC
121wxString wxStaticText::DoGetLabel() const
122{
123 return m_label;
124}
125
126/*
127 FIXME: UpdateLabel() should be called on size events when wxST_ELLIPSIZE_START is set
128 to allow correct dynamic ellipsizing of the label
129*/
130
131#endif //if wxUSE_STATTEXT