From e82d83f1847ebc369a5f48a18217a8f5fecf3824 Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Mon, 13 Jan 2014 14:51:27 +0000 Subject: move four more optional window operations to table --- desktop/browser.c | 4 ++-- desktop/gui.h | 57 +++++++++++++++++++++++++++++++++++++++++++-------- desktop/gui_factory.c | 38 +++++++++++++++++++++++++++++++--- desktop/textinput.c | 7 ++++--- 4 files changed, 89 insertions(+), 17 deletions(-) (limited to 'desktop') diff --git a/desktop/browser.c b/desktop/browser.c index 5b34dd555..59cb4d44a 100644 --- a/desktop/browser.c +++ b/desktop/browser.c @@ -2193,7 +2193,7 @@ void browser_window_set_status(struct browser_window *bw, const char *text) } bw->status_miss++; - gui_window_set_status(bw->window, bw->status_text); + guit->window->set_status(bw->window, bw->status_text); } @@ -2235,7 +2235,7 @@ void browser_window_set_pointer(struct browser_window *bw, gui_shape = (gui_pointer_shape)shape; } - gui_window_set_pointer(root->window, gui_shape); + guit->window->set_pointer(root->window, gui_shape); } diff --git a/desktop/gui.h b/desktop/gui.h index 02012fa8f..3f533d224 100644 --- a/desktop/gui.h +++ b/desktop/gui.h @@ -143,12 +143,55 @@ struct gui_window_table { /* Optional entries */ - /** set the window title. */ + /** + * Set the title of a window. + * + * \param g window to update + * \param title new window title + */ void (*set_title)(struct gui_window *g, const char *title); /** set the navigation url. */ void (*set_url)(struct gui_window *g, const char *url); + /** set favicon */ + void (*set_icon)(struct gui_window *g, hlcache_handle *icon); + + + + /** + * Set the status bar of a browser window. + * + * \param g gui_window to update + * \param text new status text + */ + void (*set_status)(struct gui_window *g, const char *text); + + /** + * Change mouse pointer shape + */ + void (*set_pointer)(struct gui_window *g, gui_pointer_shape shape); + + /** + * Place the caret in a browser window. + * + * \param g window with caret + * \param x coordinates of caret + * \param y coordinates of caret + * \param height height of caret + * \param clip clip rectangle, or NULL if none + */ + void (*place_caret)(struct gui_window *g, int x, int y, int height, const struct rect *clip); + + /** + * Remove the caret, if present. + * + * \param g window with caret + */ + void (*remove_caret)(struct gui_window *g); + + + /** start the navigation throbber. */ void (*start_throbber)(struct gui_window *g); @@ -161,12 +204,13 @@ struct gui_window_table { /** save link operation */ void (*save_link)(struct gui_window *g, const char *url, const char *title); - /** set favicon */ - void (*set_icon)(struct gui_window *g, hlcache_handle *icon); - /** * Scrolls the specified area of a browser window into view. * + * @todo investigate if this can be merged with set_scroll + * which is what the default implementation used by most + * toolkits uses. + * * \param g gui_window to scroll * \param x0 left point to ensure visible * \param y0 bottom point to ensure visible @@ -226,11 +270,6 @@ struct gui_table { extern struct gui_table *guit; /* the gui vtable */ -void gui_window_set_status(struct gui_window *g, const char *text); -void gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape); -void gui_window_place_caret(struct gui_window *g, int x, int y, int height, - const struct rect *clip); -void gui_window_remove_caret(struct gui_window *g); struct gui_download_window *gui_download_window_create(download_context *ctx, diff --git a/desktop/gui_factory.c b/desktop/gui_factory.c index 62ec8c565..e03e7dae0 100644 --- a/desktop/gui_factory.c +++ b/desktop/gui_factory.c @@ -59,11 +59,31 @@ static void gui_default_window_new_content(struct gui_window *g) { } + static bool gui_default_window_scroll_start(struct gui_window *g) { return true; } +static void gui_default_window_set_pointer(struct gui_window *g, + gui_pointer_shape shape) +{ +} + +static void gui_default_window_set_status(struct gui_window *g, + const char *text) +{ +} + +static void gui_default_window_place_caret(struct gui_window *g, + int x, int y, int height, + const struct rect *clip) +{ +} + +static void gui_default_window_remove_caret(struct gui_window *g) +{ +} /** verify window table is valid */ static nserror verify_window_register(struct gui_window_table *gwt) @@ -107,6 +127,21 @@ static nserror verify_window_register(struct gui_window_table *gwt) if (gwt->set_url == NULL) { gwt->set_url = gui_default_window_set_url; } + if (gwt->set_icon == NULL) { + gwt->set_icon = gui_default_window_set_icon; + } + if (gwt->set_status == NULL) { + gwt->set_status = gui_default_window_set_status; + } + if (gwt->set_pointer == NULL) { + gwt->set_pointer = gui_default_window_set_pointer; + } + if (gwt->place_caret == NULL) { + gwt->place_caret = gui_default_window_place_caret; + } + if (gwt->remove_caret == NULL) { + gwt->remove_caret = gui_default_window_remove_caret; + } if (gwt->start_throbber == NULL) { gwt->start_throbber = gui_default_window_start_throbber; } @@ -119,9 +154,6 @@ static nserror verify_window_register(struct gui_window_table *gwt) 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; - } if (gwt->scroll_visible == NULL) { gwt->scroll_visible = gui_default_window_scroll_visible; } diff --git a/desktop/textinput.c b/desktop/textinput.c index e804829fa..95c321eaa 100644 --- a/desktop/textinput.c +++ b/desktop/textinput.c @@ -85,7 +85,7 @@ void browser_window_place_caret(struct browser_window *bw, int x, int y, /* TODO: intersect with bw viewport */ - gui_window_place_caret(root_bw->window, x, y, height * bw->scale, crp); + guit->window->place_caret(root_bw->window, x, y, height * bw->scale, crp); /* Set focus browser window */ root_bw->focus = bw; @@ -110,8 +110,9 @@ void browser_window_remove_caret(struct browser_window *bw, bool only_hide) else root_bw->can_edit = false; - if (root_bw->window) - gui_window_remove_caret(root_bw->window); + if (root_bw->window) { + guit->window->remove_caret(root_bw->window); + } } -- cgit v1.2.3