From 329fba581a38035ebc6b4f29af4f0a17841a3aef Mon Sep 17 00:00:00 2001 From: Ole Loots Date: Fri, 27 Jul 2012 02:52:34 +0200 Subject: Handle "Save window size" menu event. --- atari/global_evnt.c | 28 +++++++++++++++++++++++---- atari/gui.c | 54 ++++++++++++++++++++++++++++++++++------------------- atari/toolbar.c | 30 ++++++++++++++--------------- 3 files changed, 74 insertions(+), 38 deletions(-) diff --git a/atari/global_evnt.c b/atari/global_evnt.c index 24e65b511..f002f3f5a 100755 --- a/atari/global_evnt.c +++ b/atari/global_evnt.c @@ -52,7 +52,6 @@ #include "atari/settings.h" #include "cflib.h" -extern const char * cfg_homepage_url; extern struct gui_window *input_window; extern OBJECT * h_gem_menu; extern int mouse_click_time[3]; @@ -60,7 +59,14 @@ extern int mouse_hold_start[3]; extern browser_mouse_state bmstate; extern short last_drag_x; extern short last_drag_y; -extern bool html_redraw_debug; +extern bool html_redraw_debug; + +extern const char * option_homepage_url; +extern int option_window_width; +extern int option_window_height; +extern int option_window_x; +extern int option_window_y; +extern char options[PATH_MAX]; /* Zero based resource tree ids: */ #define T_ABOUT 0 @@ -96,7 +102,7 @@ static void __CDECL menu_about(WINDOW *win, int item, int title, void *data) static void __CDECL menu_new_win(WINDOW *win, int item, int title, void *data) { LOG(("%s", __FUNCTION__)); - browser_window_create(cfg_homepage_url, 0, 0, true, false); + browser_window_create(option_homepage_url, 0, 0, true, false); } static void __CDECL menu_open_url(WINDOW *win, int item, int title, void *data) @@ -257,7 +263,21 @@ static void __CDECL menu_toolbars(WINDOW *win, int item, int title, void *data) static void __CDECL menu_savewin(WINDOW *win, int item, int title, void *data) { - LOG(("%s", __FUNCTION__)); + LOG(("%s", __FUNCTION__)); + if (input_window && input_window->browser) { + GRECT rect; + wind_get_grect(input_window->root->handle->handle, WF_CURRXYWH, &rect); + option_window_width = rect.g_w; + option_window_height = rect.g_h; + option_window_x = rect.g_x; + option_window_y = rect.g_y; + nsoption_set_int(window_width, rect.g_w); + nsoption_set_int(window_height, rect.g_h); + nsoption_set_int(window_x, rect.g_x); + nsoption_set_int(window_y, rect.g_y); + nsoption_write((const char*)&options); + } + } static void __CDECL menu_debug_render(WINDOW *win, int item, int title, void *data) diff --git a/atari/gui.c b/atari/gui.c index 07d948313..a2dde6744 100755 --- a/atari/gui.c +++ b/atari/gui.c @@ -91,11 +91,13 @@ bool rendering = false; /* Comandline / Options: */ -int cfg_width; -int cfg_height; +int option_window_width; +int option_window_height; +int option_window_x; +int option_window_y; /* Defaults to option_homepage_url, commandline options overwrites that value */ -const char * cfg_homepage_url; +const char * option_homepage_url; /* path to choices file: */ char options[PATH_MAX]; @@ -173,8 +175,8 @@ gui_create_browser_window(struct browser_window *bw, window_create(gw, bw, WIDGET_STATUSBAR|WIDGET_TOOLBAR|WIDGET_RESIZE|WIDGET_SCROLL ); if( gw->root->handle ) { GRECT pos = { - app.w/2-(cfg_width/2), (app.h/2)-(cfg_height/2)+16, - cfg_width, cfg_height + option_window_x, option_window_y, + option_window_width, option_window_height }; window_open( gw , pos ); /* Recalculate windows browser area now */ @@ -841,37 +843,51 @@ void gui_quit(void) static bool process_cmdline(int argc, char** argv) { - int opt; + int opt; + bool set_default_dimensions = true; LOG(("argc %d, argv %p", argc, argv)); if ((nsoption_int(window_width) != 0) && (nsoption_int(window_height) != 0)) { - cfg_width = nsoption_int(window_width); - cfg_height = nsoption_int(window_height); - } else { + + option_window_width = nsoption_int(window_width); + option_window_height = nsoption_int(window_height); + option_window_x = nsoption_int(window_x); + option_window_y = nsoption_int(window_y); + + if (option_window_width <= app.w && option_window_height < app.h) { + set_default_dimensions = false; + } + } + + if (set_default_dimensions) { if( sys_type() == SYS_TOS ){ /* on single tasking OS, start as fulled window: */ - cfg_width = app.w; - cfg_height = app.h; + option_window_width = app.w; + option_window_height = app.h-20; + option_window_x = app.w/2-(option_window_width/2); + option_window_y = (app.h/2)-(option_window_height/2); } else { - cfg_width = 600; - cfg_height = 360; + option_window_width = 600; + option_window_height = 360; + option_window_x = 10; + option_window_y = 30; } } if (nsoption_charp(homepage_url) != NULL) - cfg_homepage_url = nsoption_charp(homepage_url); + option_homepage_url = nsoption_charp(homepage_url); else - cfg_homepage_url = NETSURF_HOMEPAGE; + option_homepage_url = NETSURF_HOMEPAGE; while((opt = getopt(argc, argv, "w:h:")) != -1) { switch (opt) { case 'w': - cfg_width = atoi(optarg); + option_window_width = atoi(optarg); break; case 'h': - cfg_height = atoi(optarg); + option_window_height = atoi(optarg); break; default: @@ -883,7 +899,7 @@ process_cmdline(int argc, char** argv) } if (optind < argc) { - cfg_homepage_url = argv[optind]; + option_homepage_url = argv[optind]; } return true; } @@ -1014,7 +1030,7 @@ int main(int argc, char** argv) netsurf_init(&argc, &argv, options, messages); gui_init(argc, argv); gui_init2(argc, argv); - browser_window_create(cfg_homepage_url, 0, 0, true, false); + browser_window_create(option_homepage_url, 0, 0, true, false); graf_mouse( ARROW , NULL); netsurf_main_loop(); netsurf_exit(); diff --git a/atari/toolbar.c b/atari/toolbar.c index ab88a6b2e..b6dc468ba 100755 --- a/atari/toolbar.c +++ b/atari/toolbar.c @@ -52,7 +52,7 @@ #include "atari/res/netsurf.rsh" -extern char * cfg_homepage_url; +extern char * option_homepage_url; extern void * h_gem_rsrc; extern struct gui_window * input_window; extern long atari_plot_flags; @@ -302,19 +302,19 @@ static void __CDECL button_redraw( COMPONENT *c, long buff[8], void * data ) while( (todo.g_w > 0) && (todo.g_h > 0) ){ if (rc_intersect(&crect, &todo )) { - + struct rect bgclip = {0,0,todo.g_w, todo.g_h}; pxy[0] = todo.g_x; pxy[1] = todo.g_y; pxy[2] = todo.g_w + todo.g_x-1; pxy[3] = todo.g_h + todo.g_y-1; - + vs_clip(atari_plot_vdi_handle, 1, (short*)&pxy ); plot_set_dimensions(todo.g_x, todo.g_y, todo.g_w, todo.g_h); plot_rectangle(0, 0, crect.g_w, crect.g_h, &plot_style_background); - + if( img_toolbar == true ){ - plot_set_dimensions(icon_dim.g_x, icon_dim.g_y, + plot_set_dimensions(icon_dim.g_x, icon_dim.g_y, icon_dim.g_w, icon_dim.g_h); plot_clip( &icon_clip ); atari_plotters.bitmap( bmpx, bmpy, bmpw, bmph, icon, @@ -403,11 +403,11 @@ void __CDECL evnt_throbber_redraw( COMPONENT *c, long buff[8]) pxy[2] = (short)buff[4] + buff[6]-1; pxy[3] = (short)buff[5] + buff[7]-2; vs_clip(atari_plot_vdi_handle, 1, (short*)&pxy ); - + if (app.nplanes > 2 ) { plot_set_dimensions(work.g_x, work.g_y, work.g_w, work.g_h); plot_rectangle( 0, 0, work.g_w, work.g_h, &plot_style_background); - } + } else { vsf_color(atari_plot_vdi_handle, WHITE ); v_bar(atari_plot_vdi_handle, (short*)&pxy ); @@ -502,20 +502,20 @@ void __CDECL evnt_url_redraw( COMPONENT *c, long buff[8], void * data) if ( !rc_lintersect( (LGRECT*)&buff[4], &clip ) ) return; plot_set_dimensions(work.g_x, work.g_y, work.g_w, work.g_h); - + //left margin: - plot_rectangle(0, 0, TOOLBAR_URL_MARGIN_LEFT, work.g_h, + plot_rectangle(0, 0, TOOLBAR_URL_MARGIN_LEFT, work.g_h, &plot_style_background); // right margin: - plot_rectangle(work.g_w-TOOLBAR_URL_MARGIN_RIGHT, 0, work.g_w, work.g_h, + plot_rectangle(work.g_w-TOOLBAR_URL_MARGIN_RIGHT, 0, work.g_w, work.g_h, &plot_style_background); // top margin: - plot_rectangle(0, 0, work.g_w, TOOLBAR_URL_MARGIN_TOP, + plot_rectangle(0, 0, work.g_w, TOOLBAR_URL_MARGIN_TOP, &plot_style_background); // bottom margin: - plot_rectangle(0, work.g_h-TOOLBAR_URL_MARGIN_BOTTOM, work.g_w, work.g_h, + plot_rectangle(0, work.g_h-TOOLBAR_URL_MARGIN_BOTTOM, work.g_w, work.g_h, &plot_style_background); // TBD: request redraw of textarea for specific region. @@ -612,7 +612,7 @@ static void __CDECL evnt_toolbar_redraw( COMPONENT *c, long buff[8], void *data clip = work; if( !rc_lintersect( (LGRECT*)&buff[4], &clip ) ) return; if( work.g_y + work.g_h != clip.g_y + clip.g_h ) return; - + vswr_mode(atari_plot_vdi_handle, MD_REPLACE ); vsl_color(atari_plot_vdi_handle, BLACK ); vsl_type(atari_plot_vdi_handle, 1 ); @@ -1019,13 +1019,13 @@ void tb_forward_click( struct gui_window * gw ) void tb_home_click( struct gui_window * gw ) { - browser_window_go(gw->browser->bw, cfg_homepage_url, 0, true); + browser_window_go(gw->browser->bw, option_homepage_url, 0, true); } void tb_stop_click( struct gui_window * gw ) { - browser_window_stop( gw->browser->bw ); + browser_window_stop(gw->browser->bw); } -- cgit v1.2.3