forked from aseprite/aseprite
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlabel.cpp
More file actions
48 lines (38 loc) · 850 Bytes
/
label.cpp
File metadata and controls
48 lines (38 loc) · 850 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
47
48
// Aseprite UI Library
// Copyright (C) 2001-2015 David Capello
//
// This file is released under the terms of the MIT license.
// Read LICENSE.txt for more information.
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "she/font.h"
#include "ui/label.h"
#include "ui/message.h"
#include "ui/size_hint_event.h"
#include "ui/theme.h"
namespace ui {
Label::Label(const std::string& text)
: Widget(kLabelWidget)
{
setAlign(LEFT | MIDDLE);
setText(text);
initTheme();
}
void Label::onSizeHint(SizeHintEvent& ev)
{
gfx::Size sz(0, 0);
if (hasText()) {
// Labels are not UIString
sz.w = font()->textLength(text().c_str());
sz.h = textHeight();
}
sz.w += border().width();
sz.h += border().height();
ev.setSizeHint(sz);
}
void Label::onPaint(PaintEvent& ev)
{
theme()->paintLabel(ev);
}
} // namespace ui