summaryrefslogtreecommitdiff
path: root/src/gui/label.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/label.cpp')
-rw-r--r--src/gui/label.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/gui/label.cpp b/src/gui/label.cpp
new file mode 100644
index 0000000..b5d6290
--- /dev/null
+++ b/src/gui/label.cpp
@@ -0,0 +1,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;
+}