Add more stubs to the GWindow widget

This commit is contained in:
Pierre Pronchery 2020-04-12 07:20:09 +02:00
parent f9a1b20912
commit 75e3a2dfaf
2 changed files with 39 additions and 0 deletions

View File

@ -45,12 +45,16 @@ void gwindow_delete(GWindow * gwindow);
/* accessors */ /* accessors */
bool gwindow_get_decorated(GWindow * gwindow);
bool gwindow_get_modal(GWindow * gwindow);
bool gwindow_get_resizable(GWindow * gwindow); bool gwindow_get_resizable(GWindow * gwindow);
void gwindow_get_size(GWindow * gwindow, int * width, int * height);
char const * gwindow_get_title(GWindow * gwindow); char const * gwindow_get_title(GWindow * gwindow);
void gwindow_set_resizable(GWindow * gwindow, bool resizable); void gwindow_set_resizable(GWindow * gwindow, bool resizable);
void gwindow_set_title(GWindow * gwindow, char const * title); void gwindow_set_title(GWindow * gwindow, char const * title);
/* useful */ /* useful */
void gwindow_resize(GWindow * gwindow, int width, int height);
void gwindow_show(GWindow * gwindow); void gwindow_show(GWindow * gwindow);
#endif /* !GTOOLKIT_GWINDOW_H */ #endif /* !GTOOLKIT_GWINDOW_H */

View File

@ -44,6 +44,7 @@ struct _GWindow
/* GWindow */ /* GWindow */
char * title; char * title;
bool decorated;
bool fullscreen; bool fullscreen;
bool resizable; bool resizable;
int width; int width;
@ -69,6 +70,7 @@ GWindow * gwindow_new(void)
if((gwindow = malloc(sizeof(*gwindow))) == NULL) if((gwindow = malloc(sizeof(*gwindow))) == NULL)
return NULL; /* FIXME report */ return NULL; /* FIXME report */
gwindow->title = NULL; gwindow->title = NULL;
gwindow->decorated = true;
gwindow->fullscreen = false; gwindow->fullscreen = false;
gwindow->resizable = true; gwindow->resizable = true;
gwindow->width = -1; gwindow->width = -1;
@ -104,6 +106,20 @@ void gwindow_delete(GWindow * gwindow)
/* accessors */ /* accessors */
/* gwindow_get_decorated */
bool gwindow_get_decorated(GWindow * gwindow)
{
return gwindow->decorated;
}
/* gwindow_get_modal */
bool gwindow_get_modal(GWindow * gwindow)
{
return false;
}
/* gwindow_get_resizable */ /* gwindow_get_resizable */
bool gwindow_get_resizable(GWindow * gwindow) bool gwindow_get_resizable(GWindow * gwindow)
{ {
@ -111,6 +127,16 @@ bool gwindow_get_resizable(GWindow * gwindow)
} }
/* gwindow_get_size */
void gwindow_get_size(GWindow * gwindow, int * width, int * height)
{
if(width != NULL)
*width = gwindow->width;
if(height != NULL)
*height = gwindow->height;
}
/* gwindow_get_title */ /* gwindow_get_title */
char const * gwindow_get_title(GWindow * gwindow) char const * gwindow_get_title(GWindow * gwindow)
{ {
@ -181,6 +207,15 @@ void gwindow_event_expose(GWindow * gwindow, XExposeEvent * event)
} }
/* gwindow_resize */
void gwindow_resize(GWindow * gwindow, int width, int height)
{
gwindow->width = (width == -1 || width > 0) ? width : -1;
gwindow->height = (height == -1 || height > 0) ? height : -1;
/* FIXME actually resize the window */
}
/* gwindow_show */ /* gwindow_show */
void gwindow_show(GWindow * gwindow) void gwindow_show(GWindow * gwindow)
/* FIXME accept flags (focus...) */ /* FIXME accept flags (focus...) */