From d70e371cd99d35859b0514884163447fa793738a Mon Sep 17 00:00:00 2001 From: Vincent Sanders Date: Mon, 13 Jan 2014 11:38:35 +0000 Subject: move two more mandantory window operations to table --- amiga/gui.c | 7 ++++--- atari/gui.c | 11 ++++++++--- beos/window.cpp | 6 ++++-- cocoa/gui.m | 6 ++++-- desktop/browser.c | 4 ++-- desktop/gui.h | 31 ++++++++++++++++++++++++++++--- desktop/gui_factory.c | 7 +++++++ framebuffer/gui.c | 6 ++++-- gtk/window.c | 6 ++++-- monkey/browser.c | 7 ++++--- riscos/window.c | 7 ++++--- windows/gui.c | 6 ++++-- 12 files changed, 77 insertions(+), 27 deletions(-) diff --git a/amiga/gui.c b/amiga/gui.c index 7c3a72afe..c69b3f07a 100644 --- a/amiga/gui.c +++ b/amiga/gui.c @@ -4548,7 +4548,7 @@ static void gui_window_set_scroll(struct gui_window *g, int sx, int sy) // g->shared->new_content = false; } -void gui_window_get_dimensions(struct gui_window *g, int *width, int *height, +static void gui_window_get_dimensions(struct gui_window *g, int *width, int *height, bool scaled) { struct IBox *bbox; @@ -4566,7 +4566,7 @@ void gui_window_get_dimensions(struct gui_window *g, int *width, int *height, } } -void gui_window_update_extent(struct gui_window *g) +static void gui_window_update_extent(struct gui_window *g) { struct IBox *bbox, zbox; ULONG cur_tab = 0; @@ -5092,11 +5092,12 @@ static struct gui_window_table ami_window_table = { .update = gui_window_update_box, .get_scroll = gui_window_get_scroll, .set_scroll = gui_window_set_scroll, + .get_dimensions = gui_window_get_dimensions, + .update_extent = gui_window_update_extent, .set_icon = gui_window_set_icon, .set_title = gui_window_set_title, .set_url = gui_window_set_url, - .drag_start = gui_window_drag_start, .new_content = gui_window_new_content, .start_throbber = gui_window_start_throbber, diff --git a/atari/gui.c b/atari/gui.c index cb1b123bd..8357a0b0a 100644 --- a/atari/gui.c +++ b/atari/gui.c @@ -278,8 +278,11 @@ static void gui_window_destroy(struct gui_window *w) } } -void gui_window_get_dimensions(struct gui_window *w, int *width, int *height, - bool scaled) +static void +gui_window_get_dimensions(struct gui_window *w, + int *width, + int *height, + bool scaled) { if (w == NULL) return; @@ -423,7 +426,7 @@ static void gui_window_set_scroll(struct gui_window *w, int sx, int sy) so that we can adjust scroll info. We also have to call it when tab change occurs. */ -void gui_window_update_extent(struct gui_window *gw) +static void gui_window_update_extent(struct gui_window *gw) { if( gw->browser->bw->current_content != NULL ) { @@ -1075,6 +1078,8 @@ static struct gui_window_table atari_window_table = { .update = gui_window_update_box, .get_scroll = gui_window_get_scroll, .set_scroll = gui_window_set_scroll, + .get_dimensions = gui_window_get_dimensions, + .update_extent = gui_window_update_extent, .set_title = gui_window_set_title, .set_url = gui_window_set_url, diff --git a/beos/window.cpp b/beos/window.cpp index 5fd177bb7..cff33a35b 100644 --- a/beos/window.cpp +++ b/beos/window.cpp @@ -1087,7 +1087,7 @@ static void gui_window_set_scroll(struct gui_window *g, int sx, int sy) } -void gui_window_update_extent(struct gui_window *g) +static void gui_window_update_extent(struct gui_window *g) { //CALLED(); if (!g->bw->current_content) @@ -1347,7 +1347,7 @@ void gui_set_clipboard(const char *buffer, size_t length, } } -void gui_window_get_dimensions(struct gui_window *g, int *width, int *height, +static void gui_window_get_dimensions(struct gui_window *g, int *width, int *height, bool scaled) { if (g->view && g->view->LockLooper()) { @@ -1369,6 +1369,8 @@ static struct gui_window_table gui_window_table = { .update = gui_window_update_box, .get_scroll = gui_window_get_scroll, .set_scroll = gui_window_set_scroll, + .get_dimensions = gui_window_get_dimensions, + .update_extent = gui_window_update_extent, .new_content = gui_window_new_content, diff --git a/cocoa/gui.m b/cocoa/gui.m index d193fa9c9..f674a7cb0 100644 --- a/cocoa/gui.m +++ b/cocoa/gui.m @@ -135,7 +135,7 @@ static void gui_window_set_scroll(struct gui_window *g, int sx, int sy) [[(BrowserViewController *)g browserView] scrollPoint: cocoa_point( sx, sy )]; } -void gui_window_get_dimensions(struct gui_window *g, int *width, int *height, +static void gui_window_get_dimensions(struct gui_window *g, int *width, int *height, bool scaled) { NSCParameterAssert( width != NULL && height != NULL ); @@ -150,7 +150,7 @@ void gui_window_get_dimensions(struct gui_window *g, int *width, int *height, *height = cocoa_pt_to_px( NSHeight( frame ) ); } -void gui_window_update_extent(struct gui_window *g) +static void gui_window_update_extent(struct gui_window *g) { BrowserViewController * const window = (BrowserViewController *)g; @@ -303,6 +303,8 @@ static struct gui_window_table cocoa_window_table = { .update = gui_window_update_box, .get_scroll = gui_window_get_scroll, .set_scroll = gui_window_set_scroll, + .get_dimensions = gui_window_get_dimensions, + .update_extent = gui_window_update_extent, .set_title = gui_window_set_title, .set_url = gui_window_set_url, diff --git a/desktop/browser.c b/desktop/browser.c index 3a286eecf..5b34dd555 100644 --- a/desktop/browser.c +++ b/desktop/browser.c @@ -300,7 +300,7 @@ void browser_window_update_extent(struct browser_window *bw) { if (bw->window != NULL) /* Front end window */ - gui_window_update_extent(bw->window); + guit->window->update_extent(bw->window); else /* Core-managed browser window */ browser_window_handle_scrollbars(bw); @@ -1912,7 +1912,7 @@ void browser_window_get_dimensions(struct browser_window *bw, *height = bw->height; } else { /* Front end window */ - gui_window_get_dimensions(bw->window, width, height, scaled); + guit->window->get_dimensions(bw->window, width, height, scaled); } } diff --git a/desktop/gui.h b/desktop/gui.h index bf922737b..02012fa8f 100644 --- a/desktop/gui.h +++ b/desktop/gui.h @@ -82,6 +82,8 @@ struct gui_window_table { /** * Force a redraw of the entire contents of a window. * + * @todo this API should be merged with update. + * * \param g gui_window to redraw */ void (*redraw)(struct gui_window *g); @@ -113,6 +115,31 @@ struct gui_window_table { */ void (*set_scroll)(struct gui_window *g, int sx, int sy); + /** + * Find the current dimensions of a browser window's content area. + * + * @todo The implementations of this are buggy and its only + * used from frames code. + * + * \param g gui_window to measure + * \param width receives width of window + * \param height receives height of window + * \param scaled whether to return scaled values + */ + void (*get_dimensions)(struct gui_window *g, int *width, int *height, bool scaled); + + /** + * Update the extent of the inside of a browser window to that of the + * current content. + * + * @todo this is used to update scroll bars does it need + * renaming? some frontends (windows) do not even implement it. + * + * \param g gui_window to update the extent of + */ + void (*update_extent)(struct gui_window *g); + + /* Optional entries */ @@ -198,9 +225,7 @@ struct gui_table { extern struct gui_table *guit; /* the gui vtable */ -void gui_window_get_dimensions(struct gui_window *g, int *width, int *height, - bool scaled); -void gui_window_update_extent(struct gui_window *g); + 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, diff --git a/desktop/gui_factory.c b/desktop/gui_factory.c index a4cc1c9a9..62ec8c565 100644 --- a/desktop/gui_factory.c +++ b/desktop/gui_factory.c @@ -92,6 +92,13 @@ static nserror verify_window_register(struct gui_window_table *gwt) if (gwt->set_scroll == NULL) { return NSERROR_BAD_PARAMETER; } + if (gwt->get_dimensions == NULL) { + return NSERROR_BAD_PARAMETER; + } + if (gwt->update_extent == NULL) { + return NSERROR_BAD_PARAMETER; + } + /* fill in the optional entries with defaults */ if (gwt->set_title == NULL) { diff --git a/framebuffer/gui.c b/framebuffer/gui.c index 13d0421d1..cbf9fb9c5 100644 --- a/framebuffer/gui.c +++ b/framebuffer/gui.c @@ -1575,7 +1575,7 @@ gui_window_set_scroll(struct gui_window *gw, int sx, int sy) } -void +static void gui_window_get_dimensions(struct gui_window *g, int *width, int *height, @@ -1590,7 +1590,7 @@ gui_window_get_dimensions(struct gui_window *g, } } -void +static void gui_window_update_extent(struct gui_window *gw) { float scale = gw->bw->scale; @@ -1848,6 +1848,8 @@ static struct gui_window_table framebuffer_gui_window_table = { .update = gui_window_update_box, .get_scroll = gui_window_get_scroll, .set_scroll = gui_window_set_scroll, + .get_dimensions = gui_window_get_dimensions, + .update_extent = gui_window_update_extent, .set_url = gui_window_set_url, .start_throbber = gui_window_start_throbber, diff --git a/gtk/window.c b/gtk/window.c index e6da490e6..14b9f3f7b 100644 --- a/gtk/window.c +++ b/gtk/window.c @@ -988,7 +988,7 @@ static void gui_window_set_scroll(struct gui_window *g, int sx, int sy) gtk_adjustment_set_value(hadj, x); } -void gui_window_update_extent(struct gui_window *g) +static void gui_window_update_extent(struct gui_window *g) { if (!g->bw->current_content) return; @@ -1121,7 +1121,7 @@ void gui_drag_save_selection(struct gui_window *g, const char *selection) } -void gui_window_get_dimensions(struct gui_window *g, int *width, int *height, +static void gui_window_get_dimensions(struct gui_window *g, int *width, int *height, bool scaled) { GtkAllocation alloc; @@ -1179,6 +1179,8 @@ static struct gui_window_table gui_window_table = { .update = gui_window_update_box, .get_scroll = gui_window_get_scroll, .set_scroll = gui_window_set_scroll, + .get_dimensions = gui_window_get_dimensions, + .update_extent = gui_window_update_extent, .set_icon = gui_window_set_icon, diff --git a/monkey/browser.c b/monkey/browser.c index 706034cf2..51ff93e95 100644 --- a/monkey/browser.c +++ b/monkey/browser.c @@ -132,7 +132,7 @@ gui_window_redraw_window(struct gui_window *g) fprintf(stdout, "WINDOW REDRAW WIN %u\n", g->win_num); } -void +static void gui_window_get_dimensions(struct gui_window *g, int *width, int *height, bool scaled) { @@ -183,7 +183,7 @@ gui_window_update_box(struct gui_window *g, const struct rect *rect) } -void +static void gui_window_update_extent(struct gui_window *g) { if (!g->bw->current_content) @@ -570,11 +570,12 @@ static struct gui_window_table gui_window_table = { .update = gui_window_update_box, .get_scroll = gui_window_get_scroll, .set_scroll = gui_window_set_scroll, + .get_dimensions = gui_window_get_dimensions, + .update_extent = gui_window_update_extent, .set_title = gui_window_set_title, .set_url = gui_window_set_url, .set_icon = gui_window_set_icon, - .drag_start = gui_window_drag_start, .save_link = gui_window_save_link, .scroll_visible = gui_window_scroll_visible, diff --git a/riscos/window.c b/riscos/window.c index f722ab187..833bc2b3d 100644 --- a/riscos/window.c +++ b/riscos/window.c @@ -916,7 +916,7 @@ static void gui_window_scroll_visible(struct gui_window *g, int x0, int y0, int * \param scaled whether to return scaled values */ -void gui_window_get_dimensions(struct gui_window *g, int *width, int *height, bool scaled) +static void gui_window_get_dimensions(struct gui_window *g, int *width, int *height, bool scaled) { /* use the cached window sizes */ *width = g->old_width / 2; @@ -935,7 +935,7 @@ void gui_window_get_dimensions(struct gui_window *g, int *width, int *height, bo * \param g gui_window to update the extent of */ -void gui_window_update_extent(struct gui_window *g) +static void gui_window_update_extent(struct gui_window *g) { os_error *error; wimp_window_info info; @@ -5247,11 +5247,12 @@ static struct gui_window_table gui_window_table = { .update = gui_window_update_box, .get_scroll = gui_window_get_scroll, .set_scroll = gui_window_set_scroll, + .get_dimensions = gui_window_get_dimensions, + .update_extent = gui_window_update_extent, .set_icon = gui_window_set_icon, .set_title = gui_window_set_title, .set_url = gui_window_set_url, - .save_link = gui_window_save_link, .drag_start = gui_window_drag_start, .scroll_visible = gui_window_scroll_visible, diff --git a/windows/gui.c b/windows/gui.c index de6634ab7..cb68fa237 100644 --- a/windows/gui.c +++ b/windows/gui.c @@ -1546,7 +1546,7 @@ void gui_window_set_scroll(struct gui_window *w, int sx, int sy) } -void gui_window_get_dimensions(struct gui_window *w, int *width, int *height, +static void gui_window_get_dimensions(struct gui_window *w, int *width, int *height, bool scaled) { if (w == NULL) @@ -1558,7 +1558,7 @@ void gui_window_get_dimensions(struct gui_window *w, int *width, int *height, *height = w->height; } -void gui_window_update_extent(struct gui_window *w) +static void gui_window_update_extent(struct gui_window *w) { } @@ -1854,6 +1854,8 @@ static struct gui_window_table win32_window_table = { .update = gui_window_update_box, .get_scroll = gui_window_get_scroll, .set_scroll = gui_window_set_scroll, + .get_dimensions = gui_window_get_dimensions, + .update_extent = gui_window_update_extent, .set_title = gui_window_set_title, .set_url = gui_window_set_url, -- cgit v1.2.3