1 /*!********************************************************************
2 
3   Audacity: A Digital Audio Editor
4 
5   @file auStaticText.cpp
6 
7   Paul Licameli split from Theme.cpp
8 
9 *//*****************************************************************//**
10 
11 \class auStaticText
12 \brief is like wxStaticText, except it can be themed.  wxStaticText
13 can't be.
14 
15 *//*****************************************************************/
16 #include "auStaticText.h"
17 
18 #include "AllThemeResources.h"
19 #include "Theme.h"
20 
21 #include <wx/dcclient.h>
22 
BEGIN_EVENT_TABLE(auStaticText,wxWindow)23 BEGIN_EVENT_TABLE(auStaticText, wxWindow)
24     EVT_PAINT(auStaticText::OnPaint)
25     EVT_ERASE_BACKGROUND(auStaticText::OnErase)
26 END_EVENT_TABLE()
27 
28 
29 auStaticText::auStaticText(wxWindow* parent, wxString textIn) :
30  wxWindow(parent, wxID_ANY)
31 {
32    int textWidth, textHeight;
33 
34    int fontSize = 11;
35    #ifdef __WXMSW__
36       fontSize = 9;
37    #endif
38    wxFont font(fontSize, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
39    GetTextExtent(textIn, &textWidth, &textHeight, NULL, NULL, &font);
40 
41    SetFont( font );
42    SetMinSize( wxSize(textWidth, textHeight) );
43    SetBackgroundColour( theTheme.Colour( clrMedium));
44    SetForegroundColour( theTheme.Colour( clrTrackPanelText));
45    SetName(textIn);
46    SetLabel(textIn);
47 }
48 
OnPaint(wxPaintEvent & WXUNUSED (evt))49 void auStaticText::OnPaint(wxPaintEvent & WXUNUSED(evt))
50 {
51    wxPaintDC dc(this);
52    //dc.SetTextForeground( theTheme.Colour( clrTrackPanelText));
53    dc.Clear();
54    dc.DrawText( GetLabel(), 0,0);
55 }
56