1 /////////////////////////////////////////////////////////////////////////////
2 // Name: src/generic/stattextg.cpp
3 // Purpose: wxGenericStaticText
4 // Author: Marcin Wojdyr
7 // Copyright: Marcin Wojdyr
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
11 #include "wx/wxprec.h"
21 #include "wx/validate.h"
24 #include "wx/generic/stattextg.h"
27 IMPLEMENT_DYNAMIC_CLASS(wxGenericStaticText
, wxStaticTextBase
)
30 bool wxGenericStaticText::Create(wxWindow
*parent
,
32 const wxString
&label
,
38 if ( !wxControl::Create(parent
, id
, pos
, size
, style
,
39 wxDefaultValidator
, name
) )
44 Connect(wxEVT_PAINT
, wxPaintEventHandler(wxGenericStaticText::OnPaint
));
48 void wxGenericStaticText::OnPaint(wxPaintEvent
& WXUNUSED(event
))
50 if ( m_label
.empty() )
55 wxRect rect
= GetClientRect();
59 wxSystemSettings::GetColour(wxSYS_COLOUR_BTNTEXT
));
61 else // paint disabled text
63 // draw shadow of the text
65 wxSystemSettings::GetColour(wxSYS_COLOUR_BTNHIGHLIGHT
));
66 wxRect rectShadow
= rect
;
67 rectShadow
.Offset(1, 1);
68 dc
.DrawLabel(m_label
, rectShadow
, GetAlignment(), m_mnemonic
);
70 wxSystemSettings::GetColour(wxSYS_COLOUR_BTNSHADOW
));
72 dc
.DrawLabel(m_label
, wxNullBitmap
, rect
, GetAlignment(), m_mnemonic
);
76 wxSize
wxGenericStaticText::DoGetBestClientSize() const
78 wxClientDC
dc(wxConstCast(this, wxGenericStaticText
));
79 wxCoord width
, height
;
80 dc
.GetMultiLineTextExtent(GetLabel(), &width
, &height
);
81 return wxSize(width
, height
);
84 wxSize
wxGenericStaticText::DoGetBestSize() const
86 wxSize ret
= DoGetBestClientSize();
92 void wxGenericStaticText::SetLabel(const wxString
& label
)
94 wxControl::SetLabel(label
);
95 DoSetLabel(GetEllipsizedLabelWithoutMarkup());
96 if ( !HasFlag(wxST_NO_AUTORESIZE
) && !IsEllipsized() )
101 void wxGenericStaticText::DoSetLabel(const wxString
& label
)
103 m_mnemonic
= FindAccelIndex(label
, &m_label
);
106 bool wxGenericStaticText::SetFont(const wxFont
&font
)
108 if ( !wxControl::SetFont(font
) )
110 if ( !HasFlag(wxST_NO_AUTORESIZE
) )
111 InvalidateBestSize();
116 void wxGenericStaticText::DoSetSize(int x
, int y
, int width
, int height
,
119 wxStaticTextBase::DoSetSize(x
, y
, width
, height
, sizeFlags
);
124 #endif // wxUSE_STATTEXT