forked from smcameron/space-nerds-in-space
-
Notifications
You must be signed in to change notification settings - Fork 0
/
snis_label.c
44 lines (37 loc) · 817 Bytes
/
snis_label.c
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
#include <stdlib.h>
#include <string.h>
#include <gtk/gtk.h>
#include "snis_font.h"
#include "snis_typeface.h"
#include "snis_graph.h"
#define DEFINE_LABEL_GLOBALS
#include "snis_label.h"
#undef DEFINE_LABEL_GLOBALS
struct label {
int x, y;
char label[20];
int color;
int font;
};
struct label *snis_label_init(int x, int y,
char *label, int color, int font)
{
struct label *l;
l = malloc(sizeof(*l));
l->x = x;
l->y = y;
strncpy(l->label, label, sizeof(l->label) - 1);
l->label[sizeof(l->label) - 1] = '\0';
l->color = color;
l->font = font;
return l;
}
void snis_label_draw(GtkWidget *w, GdkGC *gc, struct label *l)
{
sng_set_foreground(l->color);
sng_abs_xy_draw_string(w, gc, l->label, l->font, l->x, l->y);
}
void snis_label_set_color(struct label *l, int color)
{
l->color = color;
}