-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLabel.cpp
More file actions
46 lines (37 loc) · 949 Bytes
/
Label.cpp
File metadata and controls
46 lines (37 loc) · 949 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//
// Label.cpp
// Copyright © 2003 William Sheldon Simms III
//
#include <cstring>
#include "Label.h"
#include "Prefs.h"
BEGIN_EVENT_TABLE(Label, wxWindow)
EVT_PAINT(Label::OnPaint)
END_EVENT_TABLE()
Label::Label (wxWindow * parent, const char * ltxt, wxFont * font)
: wxWindow(parent, -1)
{
text = ltxt;
SetThemeEnabled(TRUE);
Prefs * prefs = Prefs::GetPrefs();
if (font == 0)
SetFont(wxFont(prefs->LabelFontSize(), wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL));
else
SetFont(*font);
wxClientDC dc(this);
dc.SetFont(GetFont());
cwidth = dc.GetCharWidth();
cheight = dc.GetCharHeight();
int w, h, d;
dc.GetTextExtent(wxString::FromAscii(ltxt), &w, &h, &d);
wxSize csz;
csz.Set(w, h+d);
SetClientSize(csz);
SetMinClientSize(csz);
}
void Label::OnPaint (wxPaintEvent& WXUNUSED(event))
{
wxPaintDC dc(this);
dc.SetFont(GetFont());
dc.DrawText(wxString::FromAscii(text), 0, 0);
}