14
static void labelDraw(newtComponent co);
15
static void labelDestroy(newtComponent co);
17
static struct componentOps labelOps = {
19
newtDefaultEventHandler,
21
newtDefaultPlaceHandler,
22
newtDefaultMappedHandler,
25
newtComponent newtLabel(int left, int top, const char * text) {
29
co = malloc(sizeof(*co));
30
la = malloc(sizeof(struct label));
32
co->destroyCallback = NULL;
37
co->width = wstrlen(text, -1);
43
la->length = strlen(text);
44
la->text = strdup(text);
45
la->cs = COLORSET_LABEL;
50
void newtLabelSetText(newtComponent co, const char * text) {
52
struct label * la = co->data;
54
co->width = wstrlen(text,-1);
55
newLength = strlen(text);
56
if (newLength <= la->length) {
57
memset(la->text, ' ', la->length);
58
memcpy(la->text, text, newLength);
61
la->text = strdup(text);
62
la->length = newLength;
68
void newtLabelSetColors(newtComponent co, int colorset) {
69
struct label * la = co->data;
75
static void labelDraw(newtComponent co) {
76
struct label * la = co->data;
78
if (!co->isMapped) return;
80
SLsmg_set_color(la->cs);
82
newtGotorc(co->top, co->left);
83
/* BIDI: need to check if nstring is really needed.
84
* Where it is used? */
85
write_nstring_int(la->text, co->width, NULL);
88
static void labelDestroy(newtComponent co) {
89
struct label * la = co->data;