]> git.saurik.com Git - wxWidgets.git/blame - src/osx/stattext_osx.cpp
no need to test that the pointer is non-NULL before deleting it (closes #10070)
[wxWidgets.git] / src / osx / stattext_osx.cpp
CommitLineData
e53b3d16 1/////////////////////////////////////////////////////////////////////////////
524c47aa 2// Name: src/osx/carbon/stattext.cpp
e53b3d16
SC
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
26#include "wx/notebook.h"
27#include "wx/tabctrl.h"
28
29#include "wx/osx/private.h"
30
31#include <stdio.h>
32
33IMPLEMENT_DYNAMIC_CLASS(wxStaticText, wxControl)
34
35
36bool wxStaticText::Create( wxWindow *parent,
37 wxWindowID id,
38 const wxString& label,
39 const wxPoint& pos,
40 const wxSize& size,
41 long style,
42 const wxString& name )
43{
44 m_macIsUserPane = false;
45
46 if ( !wxControl::Create( parent, id, pos, size, style, wxDefaultValidator, name ) )
47 return false;
48
49 m_peer = wxWidgetImpl::CreateStaticText( this, parent, id, label, pos, size, style, GetExtraStyle() );
50
51 MacPostControlCreate( pos, size );
52
53 SetLabel(label);
54
55 return true;
56}
57
58void wxStaticText::SetLabel(const wxString& label)
59{
60 m_labelOrig = label;
61
62 // middle/end ellipsization is handled by the OS:
63 if ( HasFlag(wxST_ELLIPSIZE_END) || HasFlag(wxST_ELLIPSIZE_MIDDLE) )
64 {
65 // remove markup
66 wxString str(label);
67 if (HasFlag(wxST_MARKUP))
68 str = RemoveMarkup(label);
69
70 // and leave ellipsization to the OS
71 DoSetLabel(str);
72 }
73 else // not supported natively
74 {
75 DoSetLabel(GetEllipsizedLabelWithoutMarkup());
76 }
77
78 if ( !(GetWindowStyle() & wxST_NO_AUTORESIZE) &&
79 !IsEllipsized() ) // don't resize if we adjust to current size
80 {
81 InvalidateBestSize();
82 SetSize( GetBestSize() );
83 }
84
85 Refresh();
86
87 // we shouldn't need forced updates
88 // Update();
89}
90
91bool wxStaticText::SetFont(const wxFont& font)
92{
93 bool ret = wxControl::SetFont( font );
94
95 if ( ret )
96 {
97 if ( !(GetWindowStyle() & wxST_NO_AUTORESIZE) )
98 {
99 InvalidateBestSize();
100 SetSize( GetBestSize() );
101 }
102 }
103
104 return ret;
105}
106
107void wxStaticText::DoSetLabel(const wxString& label)
108{
109 m_labelOrig = label;
110 m_label = RemoveMnemonics(label);
111 m_peer->SetLabel(m_label , GetFont().GetEncoding() );
112}
113
114wxString wxStaticText::DoGetLabel() const
115{
116 return m_label;
117}
118
119/*
120 FIXME: UpdateLabel() should be called on size events when wxST_ELLIPSIZE_START is set
121 to allow correct dynamic ellipsizing of the label
122*/
123
124#endif //if wxUSE_STATTEXT