Commit 062f7fad authored by Cedric Roux's avatar Cedric Roux

add clear function to the gui

parent 3e334165
......@@ -132,6 +132,7 @@ static void dirty_event(struct gui *g, int id)
if (win == NULL)
{ WARN("widget id %d not contained in a window\n", id); return; }
g->xwin = win->x;
w->clear(g, w);
w->paint(g, w);
g->xwin = NULL;
g->repainted = 1;
......
......@@ -46,6 +46,7 @@ struct widget {
void (*allocate)(gui *g, widget *this, int x, int y, int width, int height);
void (*hints)(gui *g, widget *this, int *width, int *height);
void (*paint)(gui *g, widget *this);
void (*clear)(gui *g, widget *this);
};
struct widget_list {
......
......@@ -6,6 +6,7 @@
#include <stdarg.h>
#include <string.h>
static void default_clear(gui *gui, widget *_this);
static void default_repack(gui *gui, widget *_this);
static void default_allocate(
gui *gui, widget *_this, int x, int y, int width, int height);
......@@ -41,6 +42,7 @@ widget *new_widget(struct gui *g, enum widget_type type, int size)
ret = calloc(1, size);
if (ret == NULL) OOM;
ret->clear = default_clear;
ret->repack = default_repack;
ret->add_child = default_add_child;
ret->allocate = default_allocate;
......@@ -120,6 +122,14 @@ repack:
/* default functions */
/*************************************************************************/
static void default_clear(gui *_gui, widget *_this)
{
struct gui *g = _gui;
struct widget *this = _this;
x_fill_rectangle(g->x, g->xwin, BACKGROUND_COLOR,
this->x, this->y, this->width, this->height);
}
static void default_repack(gui *gui, widget *_this)
{
struct widget *this = _this;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment