File: label.cc

package info (click to toggle)
din 5.2.1-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,152 kB
  • ctags: 2,490
  • sloc: cpp: 9,369; sh: 6,563; ansic: 2,977; tcl: 1,770; makefile: 285
file content (34 lines) | stat: -rw-r--r-- 620 bytes parent folder | download | duplicates (3)
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
#include "label.h"
#include "font.h"
#include "viewwin.h"

using namespace std;

extern int mousex, mouseyy;
extern viewport view;
extern int lmb;

label::label (const string& t) {
	set_text (t);
}

void label::set_text (const string& t) {
	text = t;
	int w = get_char_width (text), h = get_max_char_height (text);
	const box<int>& e = get_extents ();
	set_extents (e.left, e.bottom, e.left + w, e.bottom + h);
}

void label::draw () {
	widget::draw ();
	int x, y; get_pos (x, y);
	draw_string (text, x, y);
}

int label::handle_input () {
	return widget::handle_input ();
}

void label::update () {
	set_text (text);
}