move four more optional window operations to table

This commit is contained in:
Vincent Sanders 2014-01-13 14:51:27 +00:00
parent d70e371cd9
commit e82d83f184
17 changed files with 192 additions and 79 deletions

View File

@ -4613,7 +4613,7 @@ static void gui_window_update_extent(struct gui_window *g)
g->shared->new_content = true;
}
void gui_window_set_status(struct gui_window *g, const char *text)
static void gui_window_set_status(struct gui_window *g, const char *text)
{
ULONG cur_tab = 0;
char *utf8text;
@ -4768,7 +4768,7 @@ static uint32 ami_set_throbber_render_hook(struct Hook *hook, APTR space,
return 0;
}
void gui_window_place_caret(struct gui_window *g, int x, int y, int height,
static void gui_window_place_caret(struct gui_window *g, int x, int y, int height,
const struct rect *clip)
{
struct IBox *bbox;
@ -4805,7 +4805,7 @@ void gui_window_place_caret(struct gui_window *g, int x, int y, int height,
OnMenu(g->shared->win, AMI_MENU_PASTE);
}
void gui_window_remove_caret(struct gui_window *g)
static void gui_window_remove_caret(struct gui_window *g)
{
struct IBox *bbox;
int xs,ys;
@ -5098,8 +5098,14 @@ static struct gui_window_table ami_window_table = {
.set_icon = gui_window_set_icon,
.set_title = gui_window_set_title,
.set_url = gui_window_set_url,
.set_status = gui_window_set_status,
.place_caret = gui_window_place_caret,
.remove_caret = gui_window_remove_caret,
.drag_start = gui_window_drag_start,
.new_content = gui_window_new_content,
/* from theme */
.set_pointer = gui_window_set_pointer,
.start_throbber = gui_window_start_throbber,
.stop_throbber = gui_window_stop_throbber,

View File

@ -44,6 +44,6 @@ void ami_update_pointer(struct Window *win, gui_pointer_shape shape);
void gui_window_start_throbber(struct gui_window *g);
void gui_window_stop_throbber(struct gui_window *g);
void gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape);
#endif

View File

@ -612,7 +612,7 @@ static void gui_window_stop_throbber(struct gui_window *w)
}
/* Place caret in window */
void gui_window_place_caret(struct gui_window *w, int x, int y, int height,
static void gui_window_place_caret(struct gui_window *w, int x, int y, int height,
const struct rect *clip)
{
window_place_caret(w->root, 1, x, y, height, NULL);
@ -624,7 +624,7 @@ void gui_window_place_caret(struct gui_window *w, int x, int y, int height,
/**
* clear window caret
*/
void
static void
gui_window_remove_caret(struct gui_window *w)
{
if (w == NULL)
@ -1084,7 +1084,10 @@ static struct gui_window_table atari_window_table = {
.set_title = gui_window_set_title,
.set_url = gui_window_set_url,
.set_icon = gui_window_set_icon,
.set_status = gui_window_set_status,
.set_pointer = gui_window_set_pointer,
.place_caret = gui_window_place_caret,
.remove_caret = gui_window_remove_caret,
.new_content = gui_window_new_content,
.start_throbber = gui_window_start_throbber,
.stop_throbber = gui_window_stop_throbber,

View File

@ -163,6 +163,9 @@ extern struct gui_window *window_list;
void gui_set_input_gui_window(struct gui_window *gw);
struct gui_window *gui_get_input_window(void);
char *gui_window_get_url(struct gui_window *gw);
char * gui_window_get_title(struct gui_window *gw);
char *gui_window_get_title(struct gui_window *gw);
void gui_window_set_status(struct gui_window *w, const char *text);
void gui_window_set_pointer(struct gui_window *gw, gui_pointer_shape shape);
#endif

View File

@ -202,8 +202,9 @@ void nsbeos_scaffolding_popup_menu(nsbeos_scaffolding *g, BPoint where);
void gui_window_set_title(struct gui_window *_g, const char *title);
void gui_window_set_url(struct gui_window *_g, const char *url);
void gui_window_set_icon(struct gui_window *_g, hlcache_handle *icon);
void gui_window_set_status(struct gui_window *_g, const char *text);
void gui_window_start_throbber(struct gui_window* _g);
void gui_window_stop_throbber(struct gui_window* _g);
void gui_window_set_icon(struct gui_window *_g, hlcache_handle *icon);
#endif /* NETSURF_BEOS_SCAFFOLDING_H */

View File

@ -1169,7 +1169,7 @@ const uint8 kWatch2CursorBits[] = {
};
void gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape)
static void gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape)
{
BCursor *cursor = NULL;
bool allocated = false;
@ -1209,7 +1209,7 @@ void gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape)
delete cursor;
}
void gui_window_place_caret(struct gui_window *g, int x, int y, int height,
static void gui_window_place_caret(struct gui_window *g, int x, int y, int height,
const struct rect *clip)
{
//CALLED();
@ -1230,7 +1230,7 @@ void gui_window_place_caret(struct gui_window *g, int x, int y, int height,
g->view->UnlockLooper();
}
void gui_window_remove_caret(struct gui_window *g)
static void gui_window_remove_caret(struct gui_window *g)
{
int oh = g->careth;
@ -1373,11 +1373,15 @@ static struct gui_window_table gui_window_table = {
.update_extent = gui_window_update_extent,
.new_content = gui_window_new_content,
.set_pointer = gui_window_set_pointer,
.place_caret = gui_window_place_caret,
.remove_caret = gui_window_remove_caret,
/* from scaffold */
.set_icon = gui_window_set_icon,
.set_title = gui_window_set_title,
.set_url = gui_window_set_url,
.set_status = gui_window_set_status,
.start_throbber = gui_window_start_throbber,
.stop_throbber = gui_window_stop_throbber,
};

View File

@ -161,12 +161,12 @@ static void gui_window_update_extent(struct gui_window *g)
[[window browserView] setMinimumSize: cocoa_scaled_size( browser->scale, width, height )];
}
void gui_window_set_status(struct gui_window *g, const char *text)
static void gui_window_set_status(struct gui_window *g, const char *text)
{
[(BrowserViewController *)g setStatus: [NSString stringWithUTF8String: text]];
}
void gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape)
static void gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape)
{
switch (shape) {
case GUI_POINTER_DEFAULT:
@ -233,14 +233,14 @@ static void gui_window_set_icon(struct gui_window *g, hlcache_handle *icon)
[image release];
}
void gui_window_place_caret(struct gui_window *g, int x, int y, int height,
static void gui_window_place_caret(struct gui_window *g, int x, int y, int height,
const struct rect *clip)
{
[[(BrowserViewController *)g browserView] addCaretAt: cocoa_point( x, y )
height: cocoa_px_to_pt( height )];
}
void gui_window_remove_caret(struct gui_window *g)
static void gui_window_remove_caret(struct gui_window *g)
{
[[(BrowserViewController *)g browserView] removeCaret];
}
@ -309,7 +309,10 @@ static struct gui_window_table cocoa_window_table = {
.set_title = gui_window_set_title,
.set_url = gui_window_set_url,
.set_icon = gui_window_set_icon,
.set_status = gui_window_set_status,
.set_pointer = gui_window_set_pointer,
.place_caret = gui_window_place_caret,
.remove_caret = gui_window_remove_caret,
.new_content = gui_window_new_content,
.start_throbber = gui_window_start_throbber,
.stop_throbber = gui_window_stop_throbber,

View File

@ -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);
}

View File

@ -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,

View File

@ -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;
}

View File

@ -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);
}
}

View File

@ -1604,13 +1604,13 @@ gui_window_update_extent(struct gui_window *gw)
fbtk_get_height(gw->browser), 100);
}
void
static void
gui_window_set_status(struct gui_window *g, const char *text)
{
fbtk_set_text(g->status, text);
}
void
static void
gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape)
{
switch (shape) {
@ -1737,7 +1737,7 @@ gui_window_remove_caret_cb(fbtk_widget_t *widget)
}
}
void
static void
gui_window_place_caret(struct gui_window *g, int x, int y, int height,
const struct rect *clip)
{
@ -1755,7 +1755,7 @@ gui_window_place_caret(struct gui_window *g, int x, int y, int height,
y + height - bwidget->scrolly);
}
void
static void
gui_window_remove_caret(struct gui_window *g)
{
int c_x, c_y, c_h;
@ -1852,6 +1852,10 @@ static struct gui_window_table framebuffer_gui_window_table = {
.update_extent = gui_window_update_extent,
.set_url = gui_window_set_url,
.set_status = gui_window_set_status,
.set_pointer = gui_window_set_pointer,
.place_caret = gui_window_place_caret,
.remove_caret = gui_window_remove_caret,
.start_throbber = gui_window_start_throbber,
.stop_throbber = gui_window_stop_throbber,
};

View File

@ -916,7 +916,7 @@ static void nsgtk_redraw_caret(struct gui_window *g)
}
void gui_window_remove_caret(struct gui_window *g)
static void gui_window_remove_caret(struct gui_window *g)
{
int sx, sy;
int oh = g->careth;
@ -955,7 +955,7 @@ static void gui_window_update_box(struct gui_window *g, const struct rect *rect)
(rect->y1 - rect->y0) * g->bw->scale);
}
void gui_window_set_status(struct gui_window *g, const char *text)
static void gui_window_set_status(struct gui_window *g, const char *text)
{
assert(g);
assert(g->status_bar);
@ -1009,7 +1009,8 @@ static GdkCursor *nsgtk_create_menu_cursor(void)
return cursor;
}
void gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape)
static void gui_window_set_pointer(struct gui_window *g,
gui_pointer_shape shape)
{
GdkCursor *cursor = NULL;
GdkCursorType cursortype;
@ -1094,7 +1095,7 @@ 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,
static void gui_window_place_caret(struct gui_window *g, int x, int y, int height,
const struct rect *clip)
{
nsgtk_redraw_caret(g);
@ -1183,6 +1184,10 @@ static struct gui_window_table gui_window_table = {
.update_extent = gui_window_update_extent,
.set_icon = gui_window_set_icon,
.set_status = gui_window_set_status,
.set_pointer = gui_window_set_pointer,
.place_caret = gui_window_place_caret,
.remove_caret = gui_window_remove_caret,
/* from scaffold */
.set_title = gui_window_set_title,

View File

@ -195,13 +195,13 @@ gui_window_update_extent(struct gui_window *g)
content_get_height(g->bw->current_content));
}
void
static void
gui_window_set_status(struct gui_window *g, const char *text)
{
fprintf(stdout, "WINDOW SET_STATUS WIN %u STR %s\n", g->win_num, text);
}
void
static void
gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape)
{
const char *ptr_name = "UNKNOWN";
@ -348,7 +348,7 @@ void gui_set_clipboard(const char *buffer, size_t length,
{
}
void
static void
gui_window_place_caret(struct gui_window *g, int x, int y, int height,
const struct rect *clip)
{
@ -356,7 +356,7 @@ gui_window_place_caret(struct gui_window *g, int x, int y, int height,
g->win_num, x, y, height);
}
void
static void
gui_window_remove_caret(struct gui_window *g)
{
fprintf(stdout, "WINDOW REMOVE_CARET WIN %u\n", g->win_num);
@ -576,6 +576,10 @@ static struct gui_window_table gui_window_table = {
.set_title = gui_window_set_title,
.set_url = gui_window_set_url,
.set_icon = gui_window_set_icon,
.set_status = gui_window_set_status,
.set_pointer = gui_window_set_pointer,
.place_caret = gui_window_place_caret,
.remove_caret = gui_window_remove_caret,
.drag_start = gui_window_drag_start,
.save_link = gui_window_save_link,
.scroll_visible = gui_window_scroll_visible,

View File

@ -154,6 +154,7 @@ browser_mouse_state ro_gui_mouse_drag_state(wimp_mouse_state buttons,
bool ro_gui_shift_pressed(void);
bool ro_gui_ctrl_pressed(void);
bool ro_gui_alt_pressed(void);
void gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape);
/* in history.c */
void ro_gui_history_init(void);

View File

@ -372,6 +372,30 @@ void ro_gui_window_initialise(void)
* Interface With Core
*/
/**
* 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
*/
static void gui_window_place_caret(struct gui_window *g, int x, int y, int height,
const struct rect *clip)
{
os_error *error;
error = xwimp_set_caret_position(g->window, -1,
x * 2, -(y + height) * 2, height * 2, -1);
if (error) {
LOG(("xwimp_set_caret_position: 0x%x: %s",
error->errnum, error->errmess));
warn_user("WimpError", error->errmess);
}
}
/**
* Create and open a new browser window.
*
@ -987,7 +1011,7 @@ static void gui_window_update_extent(struct gui_window *g)
* \param text new status text
*/
void gui_window_set_status(struct gui_window *g, const char *text)
static void gui_window_set_status(struct gui_window *g, const char *text)
{
if (g->status_bar)
ro_gui_status_bar_set_text(g->status_bar, text);
@ -1097,29 +1121,6 @@ static void gui_window_set_icon(struct gui_window *g, hlcache_handle *icon)
ro_toolbar_set_site_favicon(g->toolbar, icon);
}
/**
* 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 gui_window_place_caret(struct gui_window *g, int x, int y, int height,
const struct rect *clip)
{
os_error *error;
error = xwimp_set_caret_position(g->window, -1,
x * 2, -(y + height) * 2, height * 2, -1);
if (error) {
LOG(("xwimp_set_caret_position: 0x%x: %s",
error->errnum, error->errmess));
warn_user("WimpError", error->errmess);
}
}
/**
@ -1128,7 +1129,7 @@ void gui_window_place_caret(struct gui_window *g, int x, int y, int height,
* \param g window with caret
*/
void gui_window_remove_caret(struct gui_window *g)
static void gui_window_remove_caret(struct gui_window *g)
{
wimp_caret caret;
os_error *error;
@ -5250,9 +5251,13 @@ static struct gui_window_table gui_window_table = {
.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,
.set_icon = gui_window_set_icon,
.set_status = gui_window_set_status,
.set_pointer = gui_window_set_pointer,
.place_caret = gui_window_place_caret,
.remove_caret = gui_window_remove_caret,
.save_link = gui_window_save_link,
.drag_start = gui_window_drag_start,
.scroll_visible = gui_window_scroll_visible,

View File

@ -1566,7 +1566,7 @@ static void gui_window_update_extent(struct gui_window *w)
/**
* set the status bar message
*/
void gui_window_set_status(struct gui_window *w, const char *text)
static void gui_window_set_status(struct gui_window *w, const char *text)
{
if (w == NULL)
return;
@ -1576,7 +1576,7 @@ void gui_window_set_status(struct gui_window *w, const char *text)
/**
* set the pointer shape
*/
void gui_window_set_pointer(struct gui_window *w, gui_pointer_shape shape)
static void gui_window_set_pointer(struct gui_window *w, gui_pointer_shape shape)
{
if (w == NULL)
return;
@ -1708,8 +1708,8 @@ static void gui_window_stop_throbber(struct gui_window *w)
/**
* place caret in window
*/
void gui_window_place_caret(struct gui_window *w, int x, int y, int height,
const struct rect *clip)
static void gui_window_place_caret(struct gui_window *w, int x, int y,
int height, const struct rect *clip)
{
if (w == NULL)
return;
@ -1722,8 +1722,7 @@ void gui_window_place_caret(struct gui_window *w, int x, int y, int height,
/**
* clear window caret
*/
void
gui_window_remove_caret(struct gui_window *w)
static void gui_window_remove_caret(struct gui_window *w)
{
if (w == NULL)
return;
@ -1859,7 +1858,10 @@ static struct gui_window_table win32_window_table = {
.set_title = gui_window_set_title,
.set_url = gui_window_set_url,
.set_status = gui_window_set_status,
.set_pointer = gui_window_set_pointer,
.place_caret = gui_window_place_caret,
.remove_caret = gui_window_remove_caret,
.start_throbber = gui_window_start_throbber,
.stop_throbber = gui_window_stop_throbber,
};