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