summaryrefslogtreecommitdiff
path: root/atari/toolbar.c
diff options
context:
space:
mode:
Diffstat (limited to 'atari/toolbar.c')
-rw-r--r--[-rwxr-xr-x]atari/toolbar.c1284
1 files changed, 703 insertions, 581 deletions
diff --git a/atari/toolbar.c b/atari/toolbar.c
index cf68194d6..0f032b2aa 100755..100644
--- a/atari/toolbar.c
+++ b/atari/toolbar.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2010 Ole Loots <ole@monochrom.net>
+ * Copyright 2012 Ole Loots <ole@monochrom.net>
*
* This file is part of NetSurf, http://www.netsurf-browser.org/
*
@@ -24,7 +24,6 @@
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
-#include <windom.h>
#include <assert.h>
#include <math.h>
@@ -43,14 +42,48 @@
#include "atari/clipboard.h"
#include "atari/gui.h"
#include "atari/toolbar.h"
-#include "atari/browser_win.h"
-#include "atari/browser.h"
+#include "atari/rootwin.h"
+
#include "atari/clipboard.h"
#include "atari/misc.h"
-#include "atari/global_evnt.h"
#include "atari/plot/plot.h"
#include "cflib.h"
-#include "atari/res/netsurf.rsh"
+#include "atari/res/netsurf.rsh"
+
+#include "desktop/textarea.h"
+#include "desktop/textinput.h"
+#include "content/hlcache.h"
+
+
+#define TB_BUTTON_WIDTH 32
+#define THROBBER_WIDTH 32
+#define THROBBER_MIN_INDEX 1
+#define THROBBER_MAX_INDEX 12
+#define THROBBER_INACTIVE_INDEX 13
+
+#define TOOLBAR_URL_MARGIN_LEFT 2
+#define TOOLBAR_URL_MARGIN_RIGHT 2
+#define TOOLBAR_URL_MARGIN_TOP 2
+#define TOOLBAR_URL_MARGIN_BOTTOM 2
+
+enum e_toolbar_button_states {
+ button_on = 0,
+ button_off = 1
+};
+#define TOOLBAR_BUTTON_NUM_STATES 2
+
+struct s_toolbar;
+
+struct s_tb_button
+{
+ short rsc_id;
+ void (*cb_click)(struct s_toolbar *tb);
+ hlcache_handle *icon[TOOLBAR_BUTTON_NUM_STATES];
+ struct s_toolbar *owner;
+ enum e_toolbar_button_states state;
+ short index;
+ GRECT area;
+};
extern char * option_homepage_url;
@@ -58,17 +91,14 @@ extern void * h_gem_rsrc;
extern struct gui_window * input_window;
extern long atari_plot_flags;
extern int atari_plot_vdi_handle;
+extern EVMULT_OUT aes_event_out;
-static OBJECT * toolbar_buttons = NULL;
+static OBJECT * aes_toolbar = NULL;
static OBJECT * throbber_form = NULL;
-static bool img_toolbar = false;
-static char * toolbar_image_folder = (char *)"default";
-static uint32_t toolbar_bg_color = 0xFFFFFF;
-static hlcache_handle * toolbar_image;
-static hlcache_handle * throbber_image;
-static bool toolbar_image_ready = false;
-static bool throbber_image_ready = false;
-
+static bool init = false;
+static int area_navigation_height = 0;
+static int area_search_height = 0;
+static int area_full_height = 0;
static plot_font_style_t font_style_url = {
.family = PLOT_FONT_FAMILY_SANS_SERIF,
@@ -77,454 +107,171 @@ static plot_font_style_t font_style_url = {
.flags = FONTF_NONE,
.background = 0xffffff,
.foreground = 0x0
- };
+ };
+
/* prototypes & order for button widgets: */
+
static struct s_tb_button tb_buttons[] =
{
{
TOOLBAR_BT_BACK,
- tb_back_click,
- 0,
+ toolbar_back_click,
{0,0},
- 0, 0, 0
+ 0, 0, 0, {0,0,0,0}
},
{
TOOLBAR_BT_HOME,
- tb_home_click,
- 0, {0,0}, 0, 0, 0
+ toolbar_home_click,
+ {0,0},
+ 0, 0, 0, {0,0,0,0}
},
{
TOOLBAR_BT_FORWARD,
- tb_forward_click,
- 0,
- {0,0},
- 0, 0, 0
+ toolbar_forward_click,
+ {0,0},
+ 0, 0, 0, {0,0,0,0}
},
{
TOOLBAR_BT_STOP,
- tb_stop_click,
- 0,
- {0,0},
- 0, 0, 0
+ toolbar_stop_click,
+ {0,0},
+ 0, 0, 0, {0,0,0,0}
},
{
TOOLBAR_BT_RELOAD,
- tb_reload_click,
- 0,
- {0,0},
- 0, 0, 0
+ toolbar_reload_click,
+ {0,0},
+ 0, 0, 0, {0,0,0,0}
},
- { 0, 0, 0, {0,0}, 0, 0, -1 }
+ { 0, 0, {0,0}, 0, -1, 0, {0,0,0,0}}
};
+// TODO: most of this struct can be deleted
struct s_toolbar_style {
int font_height_pt;
- int height;
- int icon_width;
- int icon_height;
- int button_hmargin;
- int button_vmargin;
- /* RRGGBBAA: */
- uint32_t icon_bgcolor;
};
static struct s_toolbar_style toolbar_styles[] =
{
/* small (18 px height) */
- { 9, 18, 16, 16, 0, 0, 0 },
+ {9},
/* medium (default - 26 px height) */
- {14, 26, 24, 24, 1, 4, 0 },
+ {14},
/* large ( 49 px height ) */
- {18, 34, 64, 64, 2, 0, 0 },
+ {18},
/* custom style: */
- {18, 34, 64, 64, 2, 0, 0 }
-};
+ {18}
+};
+
+static const struct redraw_context toolbar_rdrw_ctx = {
+ .interactive = true,
+ .background_images = true,
+ .plot = &atari_plotters
+ };
-static void tb_txt_request_redraw( void *data, int x, int y, int w, int h );
+static void tb_txt_request_redraw(void *data, int x, int y, int w, int h );
static nserror toolbar_icon_callback( hlcache_handle *handle,
const hlcache_event *event, void *pw );
+/**
+* Find a button for a specific resource ID
+*/
+static struct s_tb_button *find_button(struct s_toolbar *tb, int rsc_id)
+{
+ int i = 0;
+ while (i < tb->btcnt) {
+ if (tb->buttons[i].rsc_id == rsc_id) {
+ return(&tb->buttons[i]);
+ }
+ i++;
+ }
+ return(NULL);
+}
-void toolbar_init( void )
+/**
+* Callback for textarea redraw
+*/
+static void tb_txt_request_redraw(void *data, int x, int y, int w, int h)
{
- int i=0, n;
- short vdicolor[3];
- uint32_t rgbcolor;
-
- toolbar_image_folder = nsoption_charp(atari_image_toolbar_folder);
- toolbar_bg_color = (nsoption_colour(atari_toolbar_bg));
- img_toolbar = (nsoption_int( atari_image_toolbar ) > 0 ) ? true : false;
- if( img_toolbar ){
-
- char imgfile[PATH_MAX];
- const char * imgfiletmpl = "toolbar/%s/%s";
- while( tb_buttons[i].rsc_id != 0){
- tb_buttons[i].index = i;
- i++;
- }
- snprintf( imgfile, PATH_MAX-1, imgfiletmpl, toolbar_image_folder,
- "main.png" );
- toolbar_image = load_icon( imgfile,
- toolbar_icon_callback, NULL );
- snprintf( imgfile, PATH_MAX-1, imgfiletmpl, toolbar_image_folder,
- "throbber.png" );
- throbber_image = load_icon( imgfile,
- toolbar_icon_callback, NULL );
-
- } else {
- RsrcGaddr( h_gem_rsrc, R_TREE, TOOLBAR, &toolbar_buttons );
- toolbar_buttons->ob_x = 0;
- toolbar_buttons->ob_y = 0;
-
- RsrcGaddr( h_gem_rsrc, R_TREE, THROBBER , &throbber_form );
- throbber_form->ob_x = 0;
- throbber_form->ob_y = 0;
- }
- n = (sizeof( toolbar_styles ) / sizeof( struct s_toolbar_style ));
- for (i=0; i<n; i++) {
- toolbar_styles[i].icon_bgcolor = ABGR_TO_RGB(toolbar_bg_color);
+ GRECT area;
+ struct s_toolbar * tb = (struct s_toolbar *)data;
+
+ if (tb->attached == false) {
+ return;
}
-}
-void toolbar_exit( void )
-{
- if( toolbar_image )
- hlcache_handle_release( toolbar_image );
- if( throbber_image )
- hlcache_handle_release( throbber_image );
+ toolbar_get_grect(tb, TOOLBAR_AREA_URL, &area);
+ area.g_x += x;
+ area.g_y += y;
+ area.g_w = w;
+ area.g_h = h;
+ //dbg_grect("tb_txt_request_redraw", &area);
+ window_schedule_redraw_grect(tb->owner, &area);
+ return;
}
-/**
- * Callback for load_icon(). Should be removed once bitmaps get loaded directly
- * from disc
- */
-static nserror toolbar_icon_callback(hlcache_handle *handle,
- const hlcache_event *event, void *pw)
+static struct s_tb_button *button_init(struct s_toolbar *tb, OBJECT * tree, int index,
+ struct s_tb_button * instance)
{
- if( event->type == CONTENT_MSG_READY ){
- if( handle == toolbar_image ){
- toolbar_image_ready = true;
- if( input_window != NULL )
- tb_update_buttons( input_window, 0 );
- }
- else if( handle == throbber_image ){
- throbber_image_ready = true;
- }
- }
+ *instance = tb_buttons[index];
+ instance->owner = tb;
- return NSERROR_OK;
+ return(instance);
}
-
-
-static void __CDECL button_redraw( COMPONENT *c, long buff[8], void * data )
-{
-
- OBJECT *tree=NULL;
- LGRECT work,clip;
- GRECT todo,crect;
- struct s_tb_button *bt = (struct s_tb_button*)data;
- struct gui_window * gw = bt->gw;
- struct s_toolbar * tb = gw->root->toolbar;
- short pxy[4];
- int bmpx=0, bmpy=0, bmpw=0, bmph = 0, drawstate=0;
- struct bitmap * icon = NULL;
- struct rect icon_clip;
- GRECT icon_dim = {0,0,0,0};
- plot_style_t plot_style_background = {
- .fill_type = PLOT_OP_TYPE_SOLID,
- .fill_colour = toolbar_bg_color,
- .stroke_type = PLOT_OP_TYPE_NONE
- };
+static short __CDECL toolbar_url_userdraw(PARMBLK *parmblock)
+{
+ return(0);
+}
- mt_CompGetLGrect(&app, c, WF_WORKXYWH, &work);
- work.g_h = work.g_h - 1;
- clip = work;
-
- /* return if component and redraw region does not intersect: */
- if (!rc_lintersect( (LGRECT*)&buff[4], &clip)) {
- return;
- }
+void toolbar_init( void )
+{
+ static USERBLK userblk;
- drawstate = bt->state;
- if( img_toolbar ){
+ aes_toolbar = gemtk_obj_get_tree(TOOLBAR);
+ throbber_form = gemtk_obj_get_tree(THROBBER);
- if( toolbar_image_ready == false ){
- return;
- }
+ userblk.ub_code = toolbar_url_userdraw;
+ userblk.ub_parm = (long) aes_toolbar[TOOLBAR_AREA_URL].ob_spec.userblk;
+ aes_toolbar[TOOLBAR_AREA_URL].ob_spec.userblk = &userblk;
- icon = content_get_bitmap( toolbar_image );
- if( icon == NULL ){
- return;
- }
+ aes_toolbar[TOOLBAR_CB_SHOWALL].ob_state &= ~OS_SELECTED;
+ aes_toolbar[TOOLBAR_CB_CASESENSE].ob_state &= ~OS_SELECTED;
- bmpw = bitmap_get_width(icon);
- bmph = bitmap_get_height(icon);
- bmpx = 0;
- bmpy = 0;
- icon_clip.x0 = bmpx+(toolbar_styles[tb->style].icon_width*bt->index);
- icon_clip.y0 = bmpy+(toolbar_styles[tb->style].icon_height*drawstate);
- icon_clip.x1 = icon_clip.x0+toolbar_styles[tb->style].icon_width;
- icon_clip.y1 = icon_clip.y0+toolbar_styles[tb->style].icon_height;
- icon_dim.g_x = work.g_x-(toolbar_styles[tb->style].icon_width * bt->index)+toolbar_styles[tb->style].button_vmargin;
- icon_dim.g_y = work.g_y-(toolbar_styles[tb->style].icon_height * drawstate)+toolbar_styles[tb->style].button_hmargin;
- icon_dim.g_w = toolbar_styles[tb->style].icon_width*(bt->index+1);
- icon_dim.g_h = toolbar_styles[tb->style].icon_height*(drawstate+1);
- } else {
- /* Place the CICON into workarea: */
- tree = &toolbar_buttons[bt->rsc_id];
- if( tree == NULL )
- return;
- tree->ob_x = work.g_x;
- tree->ob_y = work.g_y + (work.g_h - tree->ob_height) / 2;
- if( drawstate == button_off ) {
- tree->ob_state |= OS_DISABLED;
- } else {
- tree->ob_state &= ~OS_DISABLED;
- }
- }
+ /* init default values: */
+ gemtk_obj_set_str_safe(aes_toolbar, TOOLBAR_TB_SRCH, (char*)"");
- /* Setup draw mode: */
- vsf_interior(atari_plot_vdi_handle , 1 );
- vswr_mode(atari_plot_vdi_handle, MD_REPLACE);
-
- /* go through the rectangle list, using classic AES methods. */
- /* Windom ComGetLGrect is buggy for WF_FIRST/NEXTXYWH */
- crect.g_x = clip.g_x;
- crect.g_y = clip.g_y;
- crect.g_w = clip.g_w;
- crect.g_h = clip.g_h;
- wind_get(gw->root->handle->handle, WF_FIRSTXYWH,
- &todo.g_x, &todo.g_y, &todo.g_w, &todo.g_h );
- 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,
- icon_dim.g_w, icon_dim.g_h);
- plot_clip( &icon_clip );
- atari_plotters.bitmap( bmpx, bmpy, bmpw, bmph, icon,
- toolbar_styles[tb->style].icon_bgcolor,
- BITMAPF_BUFFER_NATIVE );
- } else {
- objc_draw( tree, 0, 0, todo.g_x, todo.g_y, todo.g_w, todo.g_h );
- }
- vs_clip(atari_plot_vdi_handle, 0, (short*)&clip );
- }
- wind_get(gw->root->handle->handle, WF_NEXTXYWH,
- &todo.g_x, &todo.g_y, &todo.g_w, &todo.g_h );
- }
-}
+ area_full_height = aes_toolbar->ob_height;
+ area_search_height = aes_toolbar[TOOLBAR_AREA_SEARCH].ob_height;
+ area_navigation_height = aes_toolbar[TOOLBAR_AREA_NAVIGATION].ob_height;
+ init = true;
+}
-static void __CDECL button_click( COMPONENT *c, long buff[8], void * data )
-{
- struct s_tb_button * bt = (struct s_tb_button *)data;
- int i = 0;
- struct gui_window * gw = bt->gw;
- assert( gw );
- gw->root->toolbar->buttons[bt->index].cb_click( gw );
-}
-
-static struct s_tb_button * find_button( struct gui_window * gw, int rsc_id )
-{
- int i = 0;
- while( i < gw->root->toolbar->btcnt ) {
- if( gw->root->toolbar->buttons[i].rsc_id == rsc_id ) {
- return( &gw->root->toolbar->buttons[i] );
- }
- i++;
- }
-}
-
-
-static COMPONENT *button_init( CMP_TOOLBAR t, OBJECT * tree, int index,
- struct s_tb_button * instance )
+void toolbar_exit(void)
{
- int comp_width;
-
- *instance = tb_buttons[index];
- instance->gw = t->owner;
- comp_width = toolbar_styles[t->style].icon_width + \
- ( toolbar_styles[t->style].button_vmargin * 2 );
+}
- instance->comp = mt_CompCreate( &app, CLT_VERTICAL, comp_width, 0 );
- assert( instance->comp );
- instance->comp->bounds.max_width = comp_width;
- mt_CompEvntDataAttach( &app, instance->comp, WM_REDRAW, button_redraw,
- instance );
- mt_CompEvntDataAttach( &app, instance->comp, WM_XBUTTON, button_click,
- instance );
- return instance->comp;
-}
-
-
-static
-void __CDECL evnt_throbber_redraw( COMPONENT *c, long buff[8])
+struct s_toolbar *toolbar_create(struct s_gui_win_root *owner)
{
- LGRECT work, clip;
- int idx;
- short pxy[4];
- struct s_toolbar * tb;
- struct gui_window * gw = (struct gui_window *)mt_CompDataSearch(&app,
- c,
- CDT_OWNER );
- plot_style_t plot_style_background = {
- .fill_type = PLOT_OP_TYPE_SOLID,
- .fill_colour = toolbar_bg_color,
- .stroke_type = PLOT_OP_TYPE_NONE
- };
-
- tb = gw->root->toolbar;
- mt_CompGetLGrect(&app, c, WF_WORKXYWH, &work);
- clip = work;
- if ( !rc_lintersect( (LGRECT*)&buff[4], &clip ) ) return;
-
- vsf_interior(atari_plot_vdi_handle , 1 );
- pxy[0] = (short)buff[4];
- pxy[1] = (short)buff[5];
- 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 );
- }
-
- if( img_toolbar ){
+ int i;
+ GRECT url_area;
+ struct s_toolbar *t;
- int bmpx=0, bmpy=0, bmpw=0, bmph = 0, drawstate=0;
- struct rect icon_clip;
- struct bitmap * icon = NULL;
+ LOG((""));
- if( throbber_image_ready == false ){
- return;
- }
- icon = content_get_bitmap( throbber_image );
- if( icon == NULL ){
- return;
- }
-
- if( tb->throbber.running == false ) {
- idx = 0;
- }
- else {
- idx = tb->throbber.index;
- if( idx > tb->throbber.max_index ) {
- idx = tb->throbber.index = 1;
- }
- }
- bmpw = bitmap_get_width(icon);
- bmph = bitmap_get_height(icon);
- bmpx = 0;
- bmpy = 0;
-
- /*
- for some reason, adding
- toolbar_styles[tb->style].button_vmargin to the x pos of
- the plotter shifts the icon a bit to much.
- Maybe that's becasue the icon is inside an padded form.
- */
- plot_set_dimensions(
- work.g_x-(toolbar_styles[tb->style].icon_width * idx),
- work.g_y+toolbar_styles[tb->style].button_hmargin,
- toolbar_styles[tb->style].icon_width*(idx+1),
- toolbar_styles[tb->style].icon_height
- );
- icon_clip.x0 = bmpx+(toolbar_styles[tb->style].icon_width*idx);
- icon_clip.y0 = bmpy;
- icon_clip.x1 = icon_clip.x0+toolbar_styles[tb->style].icon_width;
- icon_clip.y1 = icon_clip.y0+toolbar_styles[tb->style].icon_height;
- plot_clip( &icon_clip );
- atari_plotters.bitmap( bmpx, bmpy, bmpw, bmph, icon,
- toolbar_styles[tb->style].icon_bgcolor,
- BITMAPF_BUFFER_NATIVE );
- }
- else {
- if( throbber_form != NULL ) {
- if( gw->root->toolbar->throbber.running == false ) {
- idx = THROBBER_INACTIVE_INDEX;
- } else {
- idx = gw->root->toolbar->throbber.index;
- if( idx > THROBBER_MAX_INDEX || idx < THROBBER_MIN_INDEX ) {
- idx = THROBBER_MIN_INDEX;
- }
- }
- throbber_form[idx].ob_x = work.g_x+1;
- throbber_form[idx].ob_y = work.g_y+4;
- mt_objc_draw( throbber_form, idx, 8, clip.g_x, clip.g_y, clip.g_w, clip.g_h, app.aes_global );
- }
- }
-
-}
-
-static
-void __CDECL evnt_url_redraw( COMPONENT *c, long buff[8], void * data)
-{
- LGRECT work, clip;
- struct gui_window * gw;
- short pxy[10];
- plot_style_t plot_style_background = {
- .fill_type = PLOT_OP_TYPE_SOLID,
- .fill_colour = toolbar_bg_color,
- .stroke_type = PLOT_OP_TYPE_NONE
- };
-
- CMP_TOOLBAR tb = (CMP_TOOLBAR)data;
- mt_CompGetLGrect(&app, tb->url.comp, WF_WORKXYWH, &work);
-
- // this last pixel is drawn by the root component of the toolbar:
- // it's the black border, so we leave it out:
- work.g_h--;
- clip = work;
- 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_style_background);
- // right margin:
- 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_style_background);
-
- // bottom margin:
- 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.
- clip.g_x -= work.g_x+TOOLBAR_URL_MARGIN_LEFT;
- clip.g_y -= work.g_y+TOOLBAR_URL_MARGIN_TOP;
- tb_txt_request_redraw( tb, clip.g_x, clip.g_y, clip.g_w, clip.g_h );
-}
+ assert(init == true);
+<<<<<<< HEAD
+ t = calloc(sizeof(struct s_toolbar), 1);
+=======
static
void __CDECL evnt_url_click( COMPONENT *c, long buff[8] )
{
@@ -584,8 +331,21 @@ void __CDECL evnt_url_click( COMPONENT *c, long buff[8] )
ApplWrite( _AESapid, WM_REDRAW, gw->root->handle->handle,
work.g_x, work.g_y, work.g_w, work.g_h );
}
+>>>>>>> master
+
+ assert(t);
+<<<<<<< HEAD
+ /* initialize the toolbar values: */
+ t->owner = owner;
+ t->style = 1;
+ t->search_visible = false;
+ t->visible = true;
+ t->reflow = true;
+ /* dublicate the form template: */
+ t->form = gemtk_obj_tree_copy(aes_toolbar);
+=======
void tb_adjust_size( struct gui_window * gw )
{
LGRECT work;
@@ -761,32 +521,31 @@ CMP_TOOLBAR tb_create( struct gui_window * gw )
t->owner = gw;
t->style = 1;
+>>>>>>> master
- /* create the root component: */
- t->comp = (COMPONENT*)mt_CompCreate(&app, CLT_HORIZONTAL,
- toolbar_styles[t->style].height, 0 );
- t->comp->rect.g_h = toolbar_styles[t->style].height;
- t->comp->bounds.max_height = toolbar_styles[t->style].height;
- mt_CompEvntDataAdd(&app, t->comp, WM_REDRAW, evnt_toolbar_redraw,
- gw, EV_BOT);
/* count buttons and add them as components: */
i = 0;
- while( tb_buttons[i].rsc_id > 0 ) {
+ while(tb_buttons[i].rsc_id > 0) {
i++;
}
t->btcnt = i;
- t->buttons = malloc( t->btcnt * sizeof(struct s_tb_button) );
- memset( t->buttons, 0, t->btcnt * sizeof(struct s_tb_button) );
- for( i=0; i < t->btcnt; i++ ) {
- button_init( t, toolbar_buttons, i, &t->buttons[i] );
- mt_CompAttach( &app, t->comp, t->buttons[i].comp );
+ t->buttons = malloc(t->btcnt * sizeof(struct s_tb_button));
+ memset(t->buttons, 0, t->btcnt * sizeof(struct s_tb_button));
+ for (i=0; i < t->btcnt; i++) {
+ button_init(t, aes_toolbar, i, &t->buttons[i]);
}
/* create the url widget: */
font_style_url.size =
toolbar_styles[t->style].font_height_pt * FONT_SIZE_SCALE;
+<<<<<<< HEAD
+ toolbar_get_grect(t, TOOLBAR_AREA_URL, &url_area);
+ url_area.g_h -= (TOOLBAR_URL_MARGIN_TOP + TOOLBAR_URL_MARGIN_BOTTOM);
+ t->url.textarea = textarea_create(300, url_area.g_h, 0, &font_style_url,
+ tb_txt_request_redraw, t);
+=======
int ta_height = toolbar_styles[t->style].height;
ta_height -= (TOOLBAR_URL_MARGIN_TOP + TOOLBAR_URL_MARGIN_BOTTOM);
textarea_setup ta_setup;
@@ -815,192 +574,395 @@ CMP_TOOLBAR tb_create( struct gui_window * gw )
mt_CompEvntAttach( &app, t->url.comp, WM_XBUTTON, evnt_url_click );
mt_CompDataAttach( &app, t->url.comp, CDT_OWNER, gw );
mt_CompAttach( &app, t->comp, t->url.comp );
+>>>>>>> master
/* create the throbber widget: */
- t->throbber.comp = (COMPONENT*)mt_CompCreate(&app, CLT_HORIZONTAL,
- toolbar_styles[t->style].height, 0);
- t->throbber.comp->rect.g_h = toolbar_styles[t->style].height;
- t->throbber.comp->rect.g_w = t->throbber.comp->bounds.max_width = \
- toolbar_styles[t->style].icon_width + \
- (2*toolbar_styles[t->style].button_vmargin );
- t->throbber.comp->bounds.max_height = toolbar_styles[t->style].height;
- if( img_toolbar == true ){
- t->throbber.index = 0;
- t->throbber.max_index = 8;
- } else {
- t->throbber.index = THROBBER_MIN_INDEX;
- t->throbber.max_index = THROBBER_MAX_INDEX;
- }
- t->throbber.running = false;
- mt_CompEvntAttach( &app, t->throbber.comp, WM_REDRAW, evnt_throbber_redraw );
- mt_CompDataAttach( &app, t->throbber.comp, CDT_OWNER, gw );
- mt_CompAttach( &app, t->comp, t->throbber.comp );
+ t->throbber.index = THROBBER_INACTIVE_INDEX;
+ t->throbber.max_index = THROBBER_MAX_INDEX;
+ t->throbber.running = false;
+
+ LOG(("created toolbar: %p, root: %p, textarea: %p, throbber: %p", t,
+ owner, t->url.textarea, t->throbber));
return( t );
-}
-
-
-void tb_destroy( CMP_TOOLBAR tb )
+}
+
+
+void toolbar_destroy(struct s_toolbar *tb)
{
- free( tb->buttons );
- textarea_destroy( tb->url.textarea );
- mt_CompDelete( &app, tb->comp);
- free( tb );
-}
-
-
-struct gui_window * tb_gui_window( CMP_TOOLBAR tb )
-{
- struct gui_window * gw;
- gw = window_list;
- while( gw != NULL ) {
- if( gw->root->toolbar == tb ) {
- LOG(("found tb gw: %p (tb: %p) for tb: %p", gw, gw->root->toolbar, tb ));
- return( gw );
- }
- else
- gw = gw->next;
- }
- return( NULL );
-}
-
-
-void tb_update_buttons( struct gui_window * gw, short button )
+ free(tb->buttons);
+ free(tb->form);
+
+ textarea_destroy(tb->url.textarea);
+
+ free(tb);
+}
+
+static int toolbar_calculate_height(struct s_toolbar *tb)
{
-
-#define FIRST_BUTTON TOOLBAR_BT_BACK
+ int r = 0;
+
+ if (tb->visible == false) {
+ return(0);
+ }
+
+ r += area_navigation_height;
+
+ if (tb->search_visible) {
+ r += area_search_height;
+ }
+
+ return(r);
+}
+
+static void toolbar_reflow(struct s_toolbar *tb)
+{
+ int i;
+
+ // position toolbar areas:
+ tb->form->ob_x = tb->area.g_x;
+ tb->form->ob_y = tb->area.g_y;
+ tb->form->ob_width = tb->area.g_w;
+ tb->form->ob_height = toolbar_calculate_height(tb);
+
+ // expand the "main" areas to the current width:
+ tb->form[TOOLBAR_AREA_NAVIGATION].ob_width = tb->area.g_w;
+ tb->form[TOOLBAR_AREA_SEARCH].ob_width = tb->area.g_w;
+
+ if (tb->search_visible) {
+ tb->form[TOOLBAR_AREA_SEARCH].ob_state &= ~OF_HIDETREE;
+ } else {
+ tb->form[TOOLBAR_AREA_SEARCH].ob_state |= OF_HIDETREE;
+
+ }
+
+ // align the throbber area at right edge:
+ tb->form[TOOLBAR_THROBBER_AREA].ob_x = tb->area.g_w
+ - tb->form[TOOLBAR_THROBBER_AREA].ob_width;
+
+ // align the search button:
+ tb->form[TOOLBAR_SEARCH_ALIGN_RIGHT].ob_x = tb->area.g_w
+ - tb->form[TOOLBAR_SEARCH_ALIGN_RIGHT].ob_width;
+
+ // center the URL area:
+ tb->form[TOOLBAR_AREA_URL].ob_width = tb->area.g_w
+ - (tb->form[TOOLBAR_AREA_BUTTONS].ob_width
+ + tb->form[TOOLBAR_THROBBER_AREA].ob_width + 1);
+
+
+ // position throbber image:
+ throbber_form[tb->throbber.index].ob_x = tb->area.g_x +
+ tb->form[TOOLBAR_THROBBER_AREA].ob_x;
+
+ throbber_form[tb->throbber.index].ob_x = tb->area.g_x
+ + tb->form[TOOLBAR_THROBBER_AREA].ob_x +
+ ((tb->form[TOOLBAR_THROBBER_AREA].ob_width
+ - throbber_form[tb->throbber.index].ob_width) >> 1);
+
+ throbber_form[tb->throbber.index].ob_y = tb->area.g_y +
+ ((tb->form[TOOLBAR_THROBBER_AREA].ob_height
+ - throbber_form[tb->throbber.index].ob_height) >> 1);
+
+ // set button states:
+ for (i=0; i < tb->btcnt; i++ ) {
+ if (tb->buttons[i].state == button_off) {
+ tb->form[tb->buttons[i].rsc_id].ob_state |= OS_DISABLED;
+ }
+ else if (tb->buttons[i].state == button_on) {
+ tb->form[tb->buttons[i].rsc_id].ob_state &= ~OS_DISABLED;
+ }
+ }
+ tb->reflow = false;
+ // TODO: iterate through all other toolbars and set reflow = true
+}
+
+void toolbar_redraw(struct s_toolbar *tb, GRECT *clip)
+{
+ GRECT area, area_ro;
+
+ if (tb->attached == false) {
+ return;
+ }
+
+ if(tb->reflow == true)
+ toolbar_reflow(tb);
+
+ //TODO: fix redraw under popup menu ... that not handled correctly somehow.
+
+ //dbg_grect("toolbar redraw clip", clip);
+
+ objc_draw_grect(tb->form,0,8,clip);
+ objc_draw_grect(&throbber_form[tb->throbber.index], 0, 1, clip);
+
+ toolbar_get_grect(tb, TOOLBAR_AREA_URL, &area_ro);
+ area = area_ro;
+
+ if (rc_intersect(clip, &area)) {
+
+ plot_set_dimensions(area_ro.g_x, area_ro.g_y, area_ro.g_w, area_ro.g_h);
+ struct rect r = {
+ .x0 = MAX(0,area.g_x - area_ro.g_x),
+ .y0 = MAX(0,area.g_y - area_ro.g_y),
+ .x1 = MAX(0,area.g_x - area_ro.g_x) + area.g_w,
+ .y1 = MAX(0,area.g_y - area_ro.g_y) + area.g_h
+ };
+ //dbg_rect("tb textarea clip: ", &r);
+ // TODO: let this be handled by an userdef object redraw function:
+ textarea_redraw(tb->url.textarea, 0, 0, &r, &toolbar_rdrw_ctx);
+ }
+}
+
+
+void toolbar_update_buttons(struct s_toolbar *tb, struct browser_window *bw,
+ short button)
+{
+ LOG((""));
struct s_tb_button * bt;
bool enable = false;
- if( button == TOOLBAR_BT_BACK || button <= 0 ){
- bt = &gw->root->toolbar->buttons[TOOLBAR_BT_BACK-FIRST_BUTTON];
- enable = browser_window_back_available(gw->browser->bw);
- if( enable ){
+ GRECT area;
+
+ assert(bw != NULL);
+
+ if (button == TOOLBAR_BT_BACK || button <= 0 ) {
+ bt = find_button(tb, TOOLBAR_BT_BACK);
+ enable = browser_window_back_available(bw);
+ if (enable) {
bt->state = button_on;
} else {
bt->state = button_off;
}
- mt_CompEvntRedraw( &app, bt->comp );
}
- if( button == TOOLBAR_BT_HOME || button <= 0 ){
- bt = &gw->root->toolbar->buttons[TOOLBAR_BT_HOME-FIRST_BUTTON];
- mt_CompEvntRedraw( &app, bt->comp );
+ if (button == TOOLBAR_BT_HOME || button <= 0 ) {
+
}
- if( button == TOOLBAR_BT_FORWARD || button <= 0 ){
- bt = &gw->root->toolbar->buttons[TOOLBAR_BT_FORWARD-FIRST_BUTTON];
- enable = browser_window_forward_available(gw->browser->bw);
- if( enable ){
+ if (button == TOOLBAR_BT_FORWARD || button <= 0 ) {
+ bt = find_button(tb, TOOLBAR_BT_FORWARD);
+ enable = browser_window_forward_available(bw);
+ if (enable) {
bt->state = button_on;
} else {
bt->state = button_off;
- }
- mt_CompEvntRedraw( &app, bt->comp );
+ }
}
- if( button == TOOLBAR_BT_RELOAD || button <= 0 ){
- bt = &gw->root->toolbar->buttons[TOOLBAR_BT_RELOAD-FIRST_BUTTON];
- enable = browser_window_reload_available(gw->browser->bw);
- if( enable ){
+ if (button == TOOLBAR_BT_RELOAD || button <= 0 ) {
+ bt = find_button(tb, TOOLBAR_BT_RELOAD);
+ enable = browser_window_reload_available(bw);
+ if (enable) {
bt->state = button_on;
} else {
bt->state = button_off;
}
- mt_CompEvntRedraw( &app, bt->comp );
}
- if( button == TOOLBAR_BT_STOP || button <= 0 ){
- bt = &gw->root->toolbar->buttons[TOOLBAR_BT_STOP-FIRST_BUTTON];
- enable = browser_window_stop_available(gw->browser->bw);
- if( enable ){
+ if (button == TOOLBAR_BT_STOP || button <= 0) {
+ bt = find_button(tb, TOOLBAR_BT_STOP);
+ enable = browser_window_stop_available(bw);
+ if (enable) {
bt->state = button_on;
} else {
bt->state = button_off;
}
- mt_CompEvntRedraw( &app, bt->comp );
}
-#undef FIRST_BUTON
-}
-
-
-
-void tb_url_set( struct gui_window * gw, char * text )
-{
- LGRECT work;
- int len = strlen(text);
- char * newtext;
- int newsize;
-
- if( gw->root->toolbar == NULL )
- return;
-
- if( gw->browser->attached == false )
- return;
-
- struct s_url_widget * url = &gw->root->toolbar->url;
-
- assert( gw != NULL );
- assert( gw->browser != NULL );
- assert( gw->root != NULL );
- assert( gw->browser->bw != NULL );
-
- textarea_set_text(url->textarea, text);
-
- mt_CompGetLGrect( &app, gw->root->toolbar->url.comp, WF_WORKXYWH, &work);
- work.g_w -= (TOOLBAR_URL_MARGIN_LEFT + TOOLBAR_URL_MARGIN_RIGHT);
- /* do not overwrite the black border, because of that, add 1 */
- work.g_h -= (TOOLBAR_URL_MARGIN_TOP + TOOLBAR_URL_MARGIN_BOTTOM+1);
- tb_txt_request_redraw( gw->root->toolbar, 0,0,work.g_w,work.g_h );
- tb_update_buttons( gw, TOOLBAR_BT_STOP );
- return;
-}
-
-
-/* -------------------------------------------------------------------------- */
-/* Public Module event handlers: */
-/* -------------------------------------------------------------------------- */
+ if (tb->attached) {
+ if (button > 0) {
+ toolbar_get_grect(tb, button, &area);
+ window_schedule_redraw_grect(tb->owner, &area);
+ }
+ else {
+ toolbar_get_grect(tb, TOOLBAR_AREA_BUTTONS, &area);
+ window_schedule_redraw_grect(tb->owner, &area);
+ }
+ }
+}
+
+void toolbar_set_width(struct s_toolbar *tb, short w)
+{
+ GRECT cur;
+
+ toolbar_get_grect(tb, 0, &cur);
+
+ if (w != cur.g_w) {
+
+ tb->area.g_w = w;
+
+ /* reflow now, just for url input calucation: */
+ toolbar_reflow(tb);
+ /* this will request an textarea redraw: */
+ textarea_set_dimensions(tb->url.textarea,
+ tb->form[TOOLBAR_AREA_URL].ob_width,
+ tb->form[TOOLBAR_AREA_URL].ob_height);
+ tb->reflow = true;
+ }
+}
+
+void toolbar_set_origin(struct s_toolbar *tb, short x, short y)
+{
+ GRECT cur;
+
+ toolbar_get_grect(tb, 0, &cur);
+
+ if (x != cur.g_x || y != cur.g_y) {
+ tb->area.g_x = x;
+ tb->area.g_y = y;
+ tb->reflow = true;
+ }
+}
+
+void toolbar_set_dimensions(struct s_toolbar *tb, GRECT *area)
+{
+ if (area->g_w != tb->area.g_w) {
+
+ tb->area = *area;
+
+ /* reflow now, just for url input calucation: */
+ toolbar_reflow(tb);
+ /* this will request an textarea redraw: */
+ textarea_set_dimensions(tb->url.textarea,
+ tb->form[TOOLBAR_AREA_URL].ob_width,
+ tb->form[TOOLBAR_AREA_URL].ob_height);
+ }
+ else {
+ tb->area = *area;
+ }
+ /* reflow for next redraw: */
+ /* TODO: that's only required because we do not reset others toolbars reflow
+ state on reflow */
+ tb->reflow = true;
+}
+
+
+void toolbar_set_url(struct s_toolbar *tb, const char * text)
+{
+ LOG((""));
+ textarea_set_text(tb->url.textarea, text);
+
+ if (tb->attached) {
+ GRECT area;
+ toolbar_get_grect(tb, TOOLBAR_AREA_URL, &area);
+ window_schedule_redraw_grect(tb->owner, &area);
+ struct gui_window * gw = window_get_active_gui_window(tb->owner);
+ assert(gw != NULL);
+ toolbar_update_buttons(tb, gw->browser->bw , 0);
+ }
+}
+
+void toolbar_set_throbber_state(struct s_toolbar *tb, bool active)
+{
+ GRECT throbber_area;
+
+ tb->throbber.running = active;
+ if (active) {
+ tb->throbber.index = THROBBER_MIN_INDEX;
+ } else {
+ tb->throbber.index = THROBBER_INACTIVE_INDEX;
+ }
+
+ tb->reflow = true;
+ toolbar_get_grect(tb, TOOLBAR_THROBBER_AREA, &throbber_area);
+ window_schedule_redraw_grect(tb->owner, &throbber_area);
+}
+
+void toolbar_set_visible(struct s_toolbar *tb, short area, bool visible)
+{
+ if (area == 0) {
+ if ((visible == false) && (tb->visible == true)) {
+ tb->visible = false;
+ tb->reflow = true;
+ } else if((visible == true) && (tb->visible == false)) {
+ tb->visible = false;
+ tb->reflow = true;
+ }
+ }
+ else if (area == TOOLBAR_AREA_SEARCH) {
+ tb->search_visible = visible;
+ tb->reflow = true;
+ }
+}
+
+void toolbar_set_reflow(struct s_toolbar *tb, bool do_reflow)
+{
+ tb->reflow = do_reflow;
+}
+
+void toolbar_set_attached(struct s_toolbar *tb, bool attached)
+{
+ tb->attached = attached;
+
+}
+
+void toolbar_throbber_progress(struct s_toolbar *tb)
+{
+ GRECT throbber_area;
+
+ assert(tb->throbber.running == true);
+
+ if(tb->throbber.running == false)
+ return;
+
+ tb->throbber.index++;
+ if(tb->throbber.index > THROBBER_MAX_INDEX)
+ tb->throbber.index = THROBBER_MIN_INDEX;
+
+ tb->reflow = true;
+ toolbar_get_grect(tb, TOOLBAR_THROBBER_AREA, &throbber_area);
+ window_schedule_redraw_grect(tb->owner, &throbber_area);
+}
+
+bool toolbar_text_input(struct s_toolbar *tb, char *text)
+{
+ bool handled = true;
+
+ LOG((""));
+
+ return(handled);
+}
+
+bool toolbar_key_input(struct s_toolbar *tb, short nkc)
+{
+
+ assert(tb!=NULL);
-bool tb_url_input( struct gui_window * gw, short nkc )
-{
- CMP_TOOLBAR tb = gw->root->toolbar;
- assert(tb!=NULL);
- LGRECT work;
- bool ret = false;
+ GRECT work;
+ bool ret = false;
+ struct gui_window *gw = window_get_active_gui_window(tb->owner);
assert( gw != NULL );
long ucs4;
- long ik = nkc_to_input_key( nkc, &ucs4 );
-
- if( ik == 0 ){
- if ( (nkc&0xFF) >= 9 ) {
- ret = textarea_keypress( tb->url.textarea, ucs4 );
+ long ik = nkc_to_input_key(nkc, &ucs4);
+
+ if (ik == 0) {
+ if ((nkc&0xFF) >= 9) {
+ ret = textarea_keypress(tb->url.textarea, ucs4);
}
}
- else if( ik == KEY_CR || ik == KEY_NL ){
+ else if (ik == KEY_CR || ik == KEY_NL) {
char tmp_url[PATH_MAX];
- if( textarea_get_text( tb->url.textarea, tmp_url, PATH_MAX) > 0 ) {
- window_set_focus( gw, BROWSER, gw->browser);
+ if ( textarea_get_text( tb->url.textarea, tmp_url, PATH_MAX) > 0 ) {
+ window_set_focus(tb->owner, BROWSER, gw->browser);
browser_window_go(gw->browser->bw, (const char*)&tmp_url, 0, true);
ret = true;
}
}
- else if( ik == KEY_COPY_SELECTION ){
+ else if (ik == KEY_COPY_SELECTION) {
// copy whole text
char * text;
int len;
len = textarea_get_text( tb->url.textarea, NULL, 0 );
text = malloc( len+1 );
- if( text ){
+ if (text){
textarea_get_text( tb->url.textarea, text, len+1 );
- scrap_txt_write( &app, text );
+ scrap_txt_write(text);
free( text );
}
}
- else if( ik == KEY_PASTE ){
- char * clip = scrap_txt_read( &app );
- if( clip != NULL ){
+ else if ( ik == KEY_PASTE) {
+ char * clip = scrap_txt_read();
+ if ( clip != NULL ){
int clip_length = strlen( clip );
if ( clip_length > 0 ) {
char *utf8;
@@ -1009,15 +971,15 @@ bool tb_url_input( struct gui_window * gw, short nkc )
* convert to UTF8 */
res = utf8_from_local_encoding( clip, clip_length, &utf8 );
if ( res == UTF8_CONVERT_OK ) {
- tb_url_set( gw, utf8 );
+ toolbar_set_url(tb, utf8);
free(utf8);
ret = true;
}
- free( clip );
}
+ free( clip );
}
}
- else if( ik == KEY_ESCAPE ) {
+ else if (ik == KEY_ESCAPE) {
textarea_keypress( tb->url.textarea, KEY_SELECT_ALL );
textarea_keypress( tb->url.textarea, KEY_DELETE_LEFT );
}
@@ -1025,57 +987,217 @@ bool tb_url_input( struct gui_window * gw, short nkc )
ret = textarea_keypress( tb->url.textarea, ik );
}
- return( ret );
-}
-
-void tb_back_click( struct gui_window * gw )
-{
- struct browser_window *bw = gw->browser->bw;
+ return( ret );
+}
+
+
+void toolbar_mouse_input(struct s_toolbar *tb, short obj, short button)
+{
+ LOG((""));
+ GRECT work;
+ short mx, my, mb, kstat;
+ int old;
+ OBJECT * toolbar_tree;
+ struct gui_window * gw;
+
+
+ if (obj==TOOLBAR_AREA_URL){
+
+ graf_mkstate(&mx, &my, &mb, &kstat);
+ toolbar_get_grect(tb, TOOLBAR_AREA_URL, &work);
+ mx -= work.g_x;
+ my -= work.g_y;
+
+ /* TODO: reset mouse state of browser window? */
+ /* select whole text when newly focused, otherwise set caret to
+ end of text */
+ if (!window_url_widget_has_focus(tb->owner)) {
+ window_set_focus(tb->owner, URL_WIDGET, (void*)&tb->url);
+ }
+ /* url widget has focus and mouse button is still pressed... */
+ else if (mb & 1) {
+
+ textarea_mouse_action(tb->url.textarea, BROWSER_MOUSE_DRAG_1,
+ mx, my );
+ short prev_x = mx;
+ short prev_y = my;
+ do {
+ if (abs(prev_x-mx) > 5 || abs(prev_y-my) > 5) {
+ textarea_mouse_action( tb->url.textarea,
+ BROWSER_MOUSE_HOLDING_1, mx, my );
+ prev_x = mx;
+ prev_y = my;
+ window_schedule_redraw_grect(tb->owner, &work);
+ window_process_redraws(tb->owner);
+ }
+ graf_mkstate( &mx, &my, &mb, &kstat );
+ mx = mx - (work.g_x + TOOLBAR_URL_MARGIN_LEFT);
+ my = my - (work.g_y + TOOLBAR_URL_MARGIN_TOP);
+ } while (mb & 1);
- if( history_back_available(bw->history) )
+ textarea_drag_end( tb->url.textarea, 0, mx, my);
+ }
+ else if (button & 2) {
+ // TODO: open a context popup
+ }
+ else {
+ /* when execution reaches here, mouse input is a click or dclick */
+ /* TODO: recognize click + shitoolbar_update_buttonsft key */
+ int mstate = BROWSER_MOUSE_PRESS_1;
+ if ((kstat & (K_LSHIFT|K_RSHIFT)) != 0) {
+ mstate = BROWSER_MOUSE_MOD_1;
+ }
+ if (aes_event_out.emo_mclicks == 2 ) {
+ textarea_mouse_action( tb->url.textarea,
+ BROWSER_MOUSE_DOUBLE_CLICK | BROWSER_MOUSE_CLICK_1, mx,
+ my);
+ toolbar_get_grect(tb, TOOLBAR_AREA_URL, &work);
+ window_schedule_redraw_grect(tb->owner, &work);
+ } else {
+ textarea_mouse_action(tb->url.textarea,
+ BROWSER_MOUSE_PRESS_1, mx, my );
+ }
+ }
+ }
+ else if(obj==TOOLBAR_TB_SRCH) {
+ window_set_focus(tb->owner, SEARCH_INPUT, NULL);
+ }
+ else if (obj==TOOLBAR_BT_SEARCH_FWD) {
+ gw = tb->owner->active_gui_window;
+ assert(gw->search);
+ nsatari_search_perform(gw->search, tb->form, SEARCH_FLAG_FORWARDS);
+ }
+ else if (obj==TOOLBAR_BT_SEARCH_BACK) {
+ gw = tb->owner->active_gui_window;
+ assert(gw->search);
+ nsatari_search_perform(gw->search, tb->form, 0);
+ }
+ else if (obj==TOOLBAR_BT_CLOSE_SEARCH) {
+ tb->form[TOOLBAR_BT_CLOSE_SEARCH].ob_state &= ~OS_SELECTED;
+ window_close_search(tb->owner);
+ }
+ else {
+ struct s_tb_button *bt = find_button(tb, obj);
+ if (bt != NULL && bt->state != button_off) {
+ bt->cb_click(tb);
+ struct gui_window * gw = window_get_active_gui_window(tb->owner);
+ toolbar_update_buttons(tb, gw->browser->bw, 0);
+ }
+
+ }
+}
+
+
+/**
+* Receive a specific region of the toolbar.
+* @param tb - the toolbar pointer
+* @param which - the area to retrieve: 0 to receive the workarea,
+ all other values must be
+ an resource ID of the TOOLBAR tree.
+* @param dst - GRECT pointer receiving the area.
+*/
+
+void toolbar_get_grect(struct s_toolbar *tb, short which, GRECT *dst)
+{
+ #define LAST_TOOLBAR_AREA TOOLBAR_AREA_SEARCH
+
+ if (tb->reflow == true) {
+ toolbar_reflow(tb);
+ }
+
+ objc_offset(tb->form, which, &dst->g_x, &dst->g_y);
+
+ dst->g_w = tb->form[which].ob_width;
+ dst->g_h = tb->form[which].ob_height;
+ //tb->form[which].ob_height;
+
+ //printf("Toolbar get grect (%d): ", which);
+ //dbg_grect("", dst);
+
+ #undef LAST_TOOLBAR_AREA
+}
+
+
+struct textarea *toolbar_get_textarea(struct s_toolbar *tb,
+ enum toolbar_textarea which)
+{
+ return(tb->url.textarea);
+}
+
+OBJECT *toolbar_get_form(struct s_toolbar *tb)
+{
+ return(tb->form);
+}
+
+
+/* public event handler */
+void toolbar_back_click(struct s_toolbar *tb)
+{
+ struct browser_window * bw;
+ struct gui_window * gw;
+
+ gw = window_get_active_gui_window(tb->owner);
+ assert(gw != NULL);
+ bw = gw->browser->bw;
+ assert(bw != NULL);
+
+ if( history_back_available(bw->history) )
history_back(bw, bw->history);
}
-void tb_reload_click( struct gui_window * gw )
+void toolbar_reload_click(struct s_toolbar *tb)
{
- browser_window_reload( gw->browser->bw, true );
+ struct browser_window * bw;
+ struct gui_window * gw;
+
+ gw = window_get_active_gui_window(tb->owner);
+ assert(gw != NULL);
+ bw = gw->browser->bw;
+ assert(bw != NULL);
+
+ browser_window_reload(bw, true);
}
-void tb_forward_click( struct gui_window * gw )
-{
- struct browser_window *bw = gw->browser->bw;
+void toolbar_forward_click(struct s_toolbar *tb)
+{
+ struct browser_window * bw;
+ struct gui_window * gw;
+
+ gw = window_get_active_gui_window(tb->owner);
+ assert(gw != NULL);
+ bw = gw->browser->bw;
+ assert(bw != NULL);
+
if (history_forward_available(bw->history))
history_forward(bw, bw->history);
}
-void tb_home_click( struct gui_window * gw )
+void toolbar_home_click(struct s_toolbar *tb)
{
- browser_window_go(gw->browser->bw, option_homepage_url, 0, true);
+ struct browser_window * bw;
+ struct gui_window * gw;
+
+ gw = window_get_active_gui_window(tb->owner);
+ assert(gw != NULL);
+ bw = gw->browser->bw;
+ assert(bw != NULL);
+ browser_window_go(bw, option_homepage_url, 0, true);
}
-void tb_stop_click( struct gui_window * gw )
+void toolbar_stop_click(struct s_toolbar *tb)
{
- browser_window_stop(gw->browser->bw);
-}
+ struct browser_window * bw;
+ struct gui_window * gw;
+ gw = window_get_active_gui_window(tb->owner);
+
+ assert(gw != NULL);
+
+ bw = gw->browser->bw;
+
+ assert(bw != NULL);
+
+ browser_window_stop(bw);
+}
-void tb_hide( struct gui_window * gw, short mode )
-{
- CMP_TOOLBAR tb = gw->root->toolbar;
- assert( tb != NULL );
- if( mode == 1 ){
- tb->hidden = true;
- tb->comp->rect.g_h = 0;
- tb->comp->bounds.max_height = 0;
-
- } else {
- tb->hidden = false;
- tb->comp->rect.g_h = toolbar_styles[tb->style].height;
- tb->comp->bounds.max_height = toolbar_styles[tb->style].height;
- }
- gw->browser->reformat_pending = true;
- browser_update_rects( gw );
- snd_rdw( gw->root->handle );
-}
-