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
|
#include "base.h"
#include <stdarg.h>
#include <stdio.h>
void gui_label_draw_fn( void* ptr ) {
GUI_LABEL* label = (GUI_LABEL*)ptr;
I32 x = gui_relx( label );
I32 y = gui_rely( label );
gui_draw_get_str_bounds( &label->w, &label->h, FNT_JPN12, label->name );
label->xbound = label->w;
label->ybound = label->h;
gui_draw_str( x, y, ALIGN_L, FNT_JPN12, ui_clr.txt, label->name );
}
GUI_LABEL* gui_label( I32 x, I32 y, const char* title, ... ) {
if( !gui_check_target() ) return 0;
char buf[GUI_NAME_LEN];
va_list args;
va_start( args, title );
vsprintf( buf, title, args );
va_end( args );
GUI_LABEL* label = new GUI_LABEL;
label->x = x;
label->y = y;
label->draw_fn = gui_label_draw_fn;
strcpy( label->name, buf );
gui_draw_get_str_bounds( &label->w, &label->h, FNT_JPN12, label->name );
label->xbound = label->w;
label->ybound = label->h;
label->parent = gui_get_view();
label->parent->children.push( label );
return label;
}
|