summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2017-06-24 21:38:38 +0200
committerAndreas Baumann <mail@andreasbaumann.cc>2017-06-24 21:38:38 +0200
commit36e1daa2518c7ffc941160e0ecb71e84b462aaa4 (patch)
tree384a632c4a50e2d9524922dcd800d0161b5d933d /src/gui
parente74065e71667d8df1529f8ca32e14f3e54119ea1 (diff)
downloadabaos-36e1daa2518c7ffc941160e0ecb71e84b462aaa4.tar.gz
abaos-36e1daa2518c7ffc941160e0ecb71e84b462aaa4.tar.bz2
font is shown as a text widget now
fixed setting of vtable in derived classes still some local to screen coordinate calculation problem in text widget
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/composite_widget.c5
-rw-r--r--src/gui/text_widget.c9
2 files changed, 8 insertions, 6 deletions
diff --git a/src/gui/composite_widget.c b/src/gui/composite_widget.c
index 9f2d1c1..e71bac6 100644
--- a/src/gui/composite_widget.c
+++ b/src/gui/composite_widget.c
@@ -28,6 +28,7 @@ void composite_widget_init( composite_widget_t *widget, widget_t *parent, const
widget->focused_child = NULL;
memset( widget->children, 0, MAX_NOF_WIDGET_CHILDREN * sizeof( widget_t * ) );
+ widget->base.vtable = (widget_vtable_t *)&composite_widget_vtable;
widget->vtable = &composite_widget_vtable;
}
@@ -35,7 +36,7 @@ void composite_widget_draw( void *obj, graphics_context_t *context )
{
composite_widget_t *widget = obj;
- widget->base.vtable->draw( obj, context );
+ widget_draw( obj, context );
for( int i = widget->nof_children - 1; i >= 0; i-- ) {
widget_t *child = widget->children[i];
@@ -49,7 +50,7 @@ void composite_widget_get_focus( void *obj, widget_t *widget )
o->focused_child = widget;
- o->base.vtable->get_focus( o, widget );
+ widget_get_focus( o, widget );
}
void composite_widget_add_child( void *obj, widget_t *child )
diff --git a/src/gui/text_widget.c b/src/gui/text_widget.c
index fbb3754..6071fd1 100644
--- a/src/gui/text_widget.c
+++ b/src/gui/text_widget.c
@@ -28,6 +28,7 @@ void text_widget_init( text_widget_t *widget, widget_t *parent, const int x, con
// maybe with memory manager in place we can do this with a strdup
widget->s = s;
+ widget->base.vtable = (widget_vtable_t *)&text_widget_vtable;
widget->vtable = &text_widget_vtable;
}
@@ -35,16 +36,16 @@ void text_widget_draw( void *obj, graphics_context_t *context )
{
text_widget_t *widget = obj;
- widget->base.vtable->draw( obj, context );
+ widget_draw( obj, context );
int x = 0;
int y = 0;
widget->base.vtable->model_to_screen( widget, &x, &y );
- for( char c = widget->s[0]; c != '\0'; c++ ) {
- vga_draw_char( context, c, x, y, widget->base.background_color,
- VGA_COLOR_WHITE );
+ for( const char *p = widget->s; *p != '\0'; p++ ) {
+ vga_draw_char( context, *p, x, y, widget->base.background_color,
+ VGA_COLOR_WHITE );
x += 9;
if( x >= widget->base.w - 9 ) {
y += 16;