2014-01-11 06:20:30 -08:00
|
|
|
|
|
|
|
#include "desktop/gui.h"
|
|
|
|
#include "desktop/gui_factory.h"
|
|
|
|
|
|
|
|
struct gui_table *guit = NULL;
|
|
|
|
|
|
|
|
|
|
|
|
static void gui_default_quit(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-01-12 14:55:26 -08:00
|
|
|
static void gui_default_set_search_ico(hlcache_handle *ico)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-01-12 02:27:41 -08:00
|
|
|
static void gui_default_window_set_title(struct gui_window *g, const char *title)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gui_default_window_set_url(struct gui_window *g, const char *url)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gui_default_window_start_throbber(struct gui_window *g)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static void gui_default_window_stop_throbber(struct gui_window *g)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-01-12 14:55:26 -08:00
|
|
|
static bool gui_default_window_drag_start(struct gui_window *g,
|
|
|
|
gui_drag_type type,
|
|
|
|
const struct rect *rect)
|
2014-01-12 09:07:34 -08:00
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-01-12 14:55:26 -08:00
|
|
|
static void gui_default_window_save_link(struct gui_window *g,
|
|
|
|
const char *url,
|
|
|
|
const char *title)
|
2014-01-12 09:07:34 -08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-01-12 14:55:26 -08:00
|
|
|
static void gui_default_window_set_icon(struct gui_window *g,
|
|
|
|
hlcache_handle *icon)
|
2014-01-12 09:07:34 -08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2014-01-12 14:55:26 -08:00
|
|
|
static void gui_default_window_scroll_visible(struct gui_window *g,
|
|
|
|
int x0, int y0,
|
|
|
|
int x1, int y1)
|
2014-01-12 09:07:34 -08:00
|
|
|
{
|
2014-01-12 17:08:15 -08:00
|
|
|
guit->window->set_scroll(g, x0, y0);
|
2014-01-12 09:07:34 -08:00
|
|
|
}
|
|
|
|
|
2014-01-12 14:55:26 -08:00
|
|
|
static void gui_default_window_new_content(struct gui_window *g)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
static bool gui_default_window_scroll_start(struct gui_window *g)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-01-12 09:07:34 -08:00
|
|
|
/** verify window table is valid */
|
|
|
|
static nserror verify_window_register(struct gui_window_table *gwt)
|
|
|
|
{
|
|
|
|
/* check table is present */
|
|
|
|
if (gwt == NULL) {
|
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* check the mandantory fields are set */
|
|
|
|
if (gwt->create == NULL) {
|
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
}
|
|
|
|
if (gwt->destroy == NULL) {
|
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
}
|
2014-01-12 15:50:54 -08:00
|
|
|
if (gwt->redraw == NULL) {
|
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
}
|
|
|
|
if (gwt->update == NULL) {
|
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
}
|
2014-01-12 17:08:15 -08:00
|
|
|
if (gwt->get_scroll == NULL) {
|
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
}
|
|
|
|
if (gwt->set_scroll == NULL) {
|
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
}
|
2014-01-12 09:07:34 -08:00
|
|
|
|
|
|
|
/* fill in the optional entries with defaults */
|
|
|
|
if (gwt->set_title == NULL) {
|
|
|
|
gwt->set_title = gui_default_window_set_title;
|
|
|
|
}
|
|
|
|
if (gwt->set_url == NULL) {
|
|
|
|
gwt->set_url = gui_default_window_set_url;
|
|
|
|
}
|
|
|
|
if (gwt->start_throbber == NULL) {
|
|
|
|
gwt->start_throbber = gui_default_window_start_throbber;
|
|
|
|
}
|
|
|
|
if (gwt->stop_throbber == NULL) {
|
|
|
|
gwt->stop_throbber = gui_default_window_stop_throbber;
|
|
|
|
}
|
|
|
|
if (gwt->drag_start == NULL) {
|
|
|
|
gwt->drag_start = gui_default_window_drag_start;
|
|
|
|
}
|
|
|
|
if (gwt->save_link == NULL) {
|
|
|
|
gwt->save_link = gui_default_window_save_link;
|
|
|
|
}
|
|
|
|
if (gwt->set_icon == NULL) {
|
|
|
|
gwt->set_icon = gui_default_window_set_icon;
|
|
|
|
}
|
2014-01-12 14:55:26 -08:00
|
|
|
if (gwt->scroll_visible == NULL) {
|
|
|
|
gwt->scroll_visible = gui_default_window_scroll_visible;
|
|
|
|
}
|
|
|
|
if (gwt->new_content == NULL) {
|
|
|
|
gwt->new_content = gui_default_window_new_content;
|
|
|
|
}
|
|
|
|
if (gwt->scroll_start == NULL) {
|
|
|
|
gwt->scroll_start = gui_default_window_scroll_start;
|
|
|
|
}
|
2014-01-12 09:07:34 -08:00
|
|
|
|
|
|
|
return NSERROR_OK;
|
|
|
|
}
|
|
|
|
|
2014-01-11 06:20:30 -08:00
|
|
|
nserror gui_factory_register(struct gui_table *gt)
|
|
|
|
{
|
2014-01-12 09:07:34 -08:00
|
|
|
nserror err;
|
|
|
|
|
2014-01-11 06:20:30 -08:00
|
|
|
/* ensure not already initialised */
|
|
|
|
if (guit != NULL) {
|
|
|
|
return NSERROR_INIT_FAILED;
|
|
|
|
}
|
|
|
|
|
2014-01-12 09:07:34 -08:00
|
|
|
/* check table is present */
|
|
|
|
if (gt == NULL) {
|
2014-01-11 06:20:30 -08:00
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
}
|
2014-01-12 09:07:34 -08:00
|
|
|
|
|
|
|
/* check subtables */
|
|
|
|
err = verify_window_register(gt->window);
|
|
|
|
if (err != NSERROR_OK) {
|
|
|
|
return err;
|
2014-01-11 14:34:12 -08:00
|
|
|
}
|
2014-01-12 09:07:34 -08:00
|
|
|
|
|
|
|
/* check the mandantory fields are set */
|
|
|
|
if (gt->poll == NULL) {
|
2014-01-11 14:34:12 -08:00
|
|
|
return NSERROR_BAD_PARAMETER;
|
|
|
|
}
|
|
|
|
|
2014-01-11 06:20:30 -08:00
|
|
|
/* fill in the optional entries with defaults */
|
|
|
|
if (gt->quit == NULL) {
|
2014-01-12 02:27:41 -08:00
|
|
|
gt->quit = gui_default_quit;
|
|
|
|
}
|
2014-01-12 09:07:34 -08:00
|
|
|
if (gt->set_search_ico == NULL) {
|
|
|
|
gt->set_search_ico = gui_default_set_search_ico;
|
2014-01-11 06:20:30 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
guit = gt;
|
|
|
|
|
|
|
|
return NSERROR_OK;
|
|
|
|
}
|