2011-01-06 00:02:22 +03:00
|
|
|
/*
|
2012-11-27 05:12:09 +04:00
|
|
|
* Copyright 2012 Ole Loots <ole@monochrom.net>
|
2011-01-06 00:02:22 +03:00
|
|
|
*
|
|
|
|
* This file is part of NetSurf, http://www.netsurf-browser.org/
|
|
|
|
*
|
|
|
|
* NetSurf is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; version 2 of the License.
|
|
|
|
*
|
|
|
|
* NetSurf is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <limits.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <stdbool.h>
|
|
|
|
#include <assert.h>
|
|
|
|
#include <math.h>
|
|
|
|
|
|
|
|
#include "utils/log.h"
|
|
|
|
#include "desktop/gui.h"
|
2013-07-10 14:55:42 +04:00
|
|
|
#include "desktop/local_history.h"
|
2011-01-06 00:02:22 +03:00
|
|
|
#include "desktop/netsurf.h"
|
|
|
|
#include "desktop/browser.h"
|
2012-08-22 20:03:46 +04:00
|
|
|
#include "desktop/browser_private.h"
|
2011-12-24 02:39:25 +04:00
|
|
|
#include "desktop/mouse.h"
|
|
|
|
#include "desktop/plot_style.h"
|
2012-04-11 03:12:13 +04:00
|
|
|
#include "desktop/plotters.h"
|
2012-04-25 00:32:53 +04:00
|
|
|
#include "desktop/tree.h"
|
2013-05-26 01:46:27 +04:00
|
|
|
#include "utils/nsoption.h"
|
2012-04-25 00:32:53 +04:00
|
|
|
#include "utils/utf8.h"
|
2011-01-06 00:02:22 +03:00
|
|
|
#include "atari/clipboard.h"
|
|
|
|
#include "atari/gui.h"
|
|
|
|
#include "atari/toolbar.h"
|
2012-11-19 02:22:43 +04:00
|
|
|
#include "atari/rootwin.h"
|
2012-12-06 04:38:49 +04:00
|
|
|
|
2011-01-06 00:02:22 +03:00
|
|
|
#include "atari/clipboard.h"
|
|
|
|
#include "atari/misc.h"
|
2012-07-14 00:19:04 +04:00
|
|
|
#include "atari/plot/plot.h"
|
2011-06-26 00:03:28 +04:00
|
|
|
#include "cflib.h"
|
2012-11-27 05:12:09 +04:00
|
|
|
#include "atari/res/netsurf.rsh"
|
|
|
|
|
|
|
|
#include "desktop/textarea.h"
|
|
|
|
#include "desktop/textinput.h"
|
|
|
|
#include "content/hlcache.h"
|
2012-12-06 04:38:49 +04:00
|
|
|
|
2012-11-27 05:12:09 +04:00
|
|
|
|
|
|
|
#define TB_BUTTON_WIDTH 32
|
|
|
|
#define THROBBER_WIDTH 32
|
|
|
|
#define THROBBER_MIN_INDEX 1
|
|
|
|
#define THROBBER_MAX_INDEX 12
|
|
|
|
#define THROBBER_INACTIVE_INDEX 13
|
|
|
|
|
|
|
|
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;
|
2012-11-30 06:20:52 +04:00
|
|
|
enum e_toolbar_button_states state;
|
2012-11-27 05:12:09 +04:00
|
|
|
short index;
|
|
|
|
GRECT area;
|
|
|
|
};
|
2011-12-24 02:39:25 +04:00
|
|
|
|
|
|
|
|
2012-07-27 04:52:34 +04:00
|
|
|
extern char * option_homepage_url;
|
2011-12-24 02:39:25 +04:00
|
|
|
extern void * h_gem_rsrc;
|
2012-06-03 21:06:11 +04:00
|
|
|
extern struct gui_window * input_window;
|
2012-07-14 00:19:04 +04:00
|
|
|
extern long atari_plot_flags;
|
|
|
|
extern int atari_plot_vdi_handle;
|
2012-11-30 06:20:52 +04:00
|
|
|
extern EVMULT_OUT aes_event_out;
|
2012-06-04 02:07:57 +04:00
|
|
|
|
2012-11-27 05:12:09 +04:00
|
|
|
static OBJECT * aes_toolbar = NULL;
|
2012-04-11 03:12:13 +04:00
|
|
|
static OBJECT * throbber_form = NULL;
|
2012-11-27 05:12:09 +04:00
|
|
|
static bool init = false;
|
2013-01-14 04:01:22 +04:00
|
|
|
static int area_navigation_height = 0;
|
|
|
|
static int area_search_height = 0;
|
|
|
|
static int area_full_height = 0;
|
2012-04-11 03:12:13 +04:00
|
|
|
|
|
|
|
static plot_font_style_t font_style_url = {
|
2011-12-24 02:39:25 +04:00
|
|
|
.family = PLOT_FONT_FAMILY_SANS_SERIF,
|
2012-04-11 03:12:13 +04:00
|
|
|
.size = 14*FONT_SIZE_SCALE,
|
2011-12-24 02:39:25 +04:00
|
|
|
.weight = 400,
|
|
|
|
.flags = FONTF_NONE,
|
|
|
|
.background = 0xffffff,
|
|
|
|
.foreground = 0x0
|
2012-11-27 05:12:09 +04:00
|
|
|
};
|
|
|
|
|
2012-04-11 03:12:13 +04:00
|
|
|
|
|
|
|
/* prototypes & order for button widgets: */
|
2012-11-27 05:12:09 +04:00
|
|
|
|
2011-01-06 00:02:22 +03:00
|
|
|
|
|
|
|
static struct s_tb_button tb_buttons[] =
|
|
|
|
{
|
2012-05-13 19:32:35 +04:00
|
|
|
{
|
|
|
|
TOOLBAR_BT_BACK,
|
2012-11-27 05:12:09 +04:00
|
|
|
toolbar_back_click,
|
2012-05-13 19:32:35 +04:00
|
|
|
{0,0},
|
2012-11-27 05:12:09 +04:00
|
|
|
0, 0, 0, {0,0,0,0}
|
2012-05-13 19:32:35 +04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
TOOLBAR_BT_HOME,
|
2012-11-27 05:12:09 +04:00
|
|
|
toolbar_home_click,
|
|
|
|
{0,0},
|
|
|
|
0, 0, 0, {0,0,0,0}
|
2012-05-13 19:32:35 +04:00
|
|
|
},
|
|
|
|
{
|
|
|
|
TOOLBAR_BT_FORWARD,
|
2012-11-27 05:12:09 +04:00
|
|
|
toolbar_forward_click,
|
|
|
|
{0,0},
|
|
|
|
0, 0, 0, {0,0,0,0}
|
2012-05-13 19:32:35 +04:00
|
|
|
},
|
|
|
|
{
|
2012-06-03 21:06:11 +04:00
|
|
|
TOOLBAR_BT_STOP,
|
2012-11-27 05:12:09 +04:00
|
|
|
toolbar_stop_click,
|
|
|
|
{0,0},
|
|
|
|
0, 0, 0, {0,0,0,0}
|
2012-05-13 19:32:35 +04:00
|
|
|
},
|
|
|
|
{
|
2012-06-03 21:06:11 +04:00
|
|
|
TOOLBAR_BT_RELOAD,
|
2012-11-27 05:12:09 +04:00
|
|
|
toolbar_reload_click,
|
|
|
|
{0,0},
|
|
|
|
0, 0, 0, {0,0,0,0}
|
2012-05-13 19:32:35 +04:00
|
|
|
},
|
2012-11-27 05:12:09 +04:00
|
|
|
{ 0, 0, {0,0}, 0, -1, 0, {0,0,0,0}}
|
2012-04-11 03:12:13 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
struct s_toolbar_style {
|
|
|
|
int font_height_pt;
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct s_toolbar_style toolbar_styles[] =
|
|
|
|
{
|
|
|
|
/* small (18 px height) */
|
2013-01-14 04:01:22 +04:00
|
|
|
{9},
|
2012-04-11 03:12:13 +04:00
|
|
|
/* medium (default - 26 px height) */
|
2013-01-14 04:01:22 +04:00
|
|
|
{14},
|
2012-04-11 03:12:13 +04:00
|
|
|
/* large ( 49 px height ) */
|
2013-01-14 04:01:22 +04:00
|
|
|
{18},
|
2012-04-13 00:18:53 +04:00
|
|
|
/* custom style: */
|
2013-01-14 04:01:22 +04:00
|
|
|
{18}
|
2012-11-29 05:01:13 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
static const struct redraw_context toolbar_rdrw_ctx = {
|
|
|
|
.interactive = true,
|
|
|
|
.background_images = true,
|
|
|
|
.plot = &atari_plotters
|
|
|
|
};
|
2011-12-24 02:39:25 +04:00
|
|
|
|
2012-11-27 05:12:09 +04:00
|
|
|
static void tb_txt_request_redraw(void *data, int x, int y, int w, int h );
|
2012-04-13 00:18:53 +04:00
|
|
|
static nserror toolbar_icon_callback( hlcache_handle *handle,
|
|
|
|
const hlcache_event *event, void *pw );
|
|
|
|
|
2012-11-30 06:20:52 +04:00
|
|
|
/**
|
|
|
|
* 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);
|
|
|
|
}
|
|
|
|
|
2012-11-27 05:12:09 +04:00
|
|
|
/**
|
|
|
|
* Callback for textarea redraw
|
|
|
|
*/
|
|
|
|
static void tb_txt_request_redraw(void *data, int x, int y, int w, int h)
|
2012-11-29 05:01:13 +04:00
|
|
|
{
|
|
|
|
|
|
|
|
GRECT area;
|
|
|
|
struct s_toolbar * tb = (struct s_toolbar *)data;
|
|
|
|
|
2012-11-30 06:20:52 +04:00
|
|
|
if (tb->attached == false) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-01-14 04:01:22 +04:00
|
|
|
toolbar_get_grect(tb, TOOLBAR_AREA_URL, &area);
|
2012-11-29 05:01:13 +04:00
|
|
|
area.g_x += x;
|
|
|
|
area.g_y += y;
|
|
|
|
area.g_w = w;
|
|
|
|
area.g_h = h;
|
2012-12-04 04:32:43 +04:00
|
|
|
//dbg_grect("tb_txt_request_redraw", &area);
|
2012-11-29 05:01:13 +04:00
|
|
|
window_schedule_redraw_grect(tb->owner, &area);
|
|
|
|
return;
|
2012-11-27 05:12:09 +04:00
|
|
|
}
|
|
|
|
|
2013-01-31 23:33:41 +04:00
|
|
|
static void tb_txt_callback(void *data, struct textarea_msg *msg)
|
|
|
|
{
|
|
|
|
switch (msg->type) {
|
|
|
|
|
|
|
|
case TEXTAREA_MSG_DRAG_REPORT:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TEXTAREA_MSG_REDRAW_REQUEST:
|
|
|
|
tb_txt_request_redraw(data,
|
|
|
|
msg->data.redraw.x0, msg->data.redraw.y0,
|
|
|
|
msg->data.redraw.x1 - msg->data.redraw.x0,
|
|
|
|
msg->data.redraw.y1 - msg->data.redraw.y0);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-11-27 05:12:09 +04:00
|
|
|
static struct s_tb_button *button_init(struct s_toolbar *tb, OBJECT * tree, int index,
|
|
|
|
struct s_tb_button * instance)
|
|
|
|
{
|
|
|
|
*instance = tb_buttons[index];
|
|
|
|
instance->owner = tb;
|
|
|
|
|
|
|
|
return(instance);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-01-22 04:21:24 +04:00
|
|
|
static short __CDECL toolbar_url_userdraw(PARMBLK *parmblock)
|
|
|
|
{
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
2012-04-11 03:12:13 +04:00
|
|
|
void toolbar_init( void )
|
|
|
|
{
|
2013-01-22 04:21:24 +04:00
|
|
|
static USERBLK userblk;
|
|
|
|
|
2013-01-22 05:33:27 +04:00
|
|
|
aes_toolbar = gemtk_obj_get_tree(TOOLBAR);
|
|
|
|
throbber_form = gemtk_obj_get_tree(THROBBER);
|
2013-01-14 04:01:22 +04:00
|
|
|
|
2013-01-22 04:21:24 +04:00
|
|
|
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;
|
|
|
|
|
2013-01-23 01:28:20 +04:00
|
|
|
aes_toolbar[TOOLBAR_CB_SHOWALL].ob_state &= ~OS_SELECTED;
|
|
|
|
aes_toolbar[TOOLBAR_CB_CASESENSE].ob_state &= ~OS_SELECTED;
|
|
|
|
|
|
|
|
/* init default values: */
|
|
|
|
gemtk_obj_set_str_safe(aes_toolbar, TOOLBAR_TB_SRCH, (char*)"");
|
|
|
|
|
2013-01-14 04:01:22 +04:00
|
|
|
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;
|
2012-04-13 00:18:53 +04:00
|
|
|
}
|
|
|
|
|
2012-04-11 03:12:13 +04:00
|
|
|
|
2012-11-27 05:12:09 +04:00
|
|
|
void toolbar_exit(void)
|
2012-06-03 21:06:11 +04:00
|
|
|
{
|
2013-01-14 04:01:22 +04:00
|
|
|
|
2012-04-11 03:12:13 +04:00
|
|
|
}
|
2012-06-04 01:37:18 +04:00
|
|
|
|
2012-06-03 21:06:11 +04:00
|
|
|
|
2012-11-27 05:12:09 +04:00
|
|
|
struct s_toolbar *toolbar_create(struct s_gui_win_root *owner)
|
2011-01-06 00:02:22 +03:00
|
|
|
{
|
2012-11-27 05:12:09 +04:00
|
|
|
int i;
|
2013-01-14 04:01:22 +04:00
|
|
|
struct s_toolbar *t;
|
|
|
|
|
|
|
|
LOG((""));
|
2012-04-11 03:12:13 +04:00
|
|
|
|
2013-01-14 04:01:22 +04:00
|
|
|
assert(init == true);
|
2011-01-06 00:02:22 +03:00
|
|
|
|
2013-09-21 22:20:49 +04:00
|
|
|
t = calloc(1, sizeof(struct s_toolbar));
|
2012-06-04 00:38:28 +04:00
|
|
|
|
2012-11-27 05:12:09 +04:00
|
|
|
assert(t);
|
2013-01-14 04:01:22 +04:00
|
|
|
|
|
|
|
/* initialize the toolbar values: */
|
2012-11-27 05:12:09 +04:00
|
|
|
t->owner = owner;
|
2013-01-14 04:01:22 +04:00
|
|
|
t->style = 1;
|
|
|
|
t->search_visible = false;
|
|
|
|
t->visible = true;
|
2013-01-23 01:28:20 +04:00
|
|
|
t->reflow = true;
|
|
|
|
|
|
|
|
/* dublicate the form template: */
|
|
|
|
t->form = gemtk_obj_tree_copy(aes_toolbar);
|
|
|
|
|
2011-01-06 00:02:22 +03:00
|
|
|
|
|
|
|
/* count buttons and add them as components: */
|
|
|
|
i = 0;
|
2012-11-27 05:12:09 +04:00
|
|
|
while(tb_buttons[i].rsc_id > 0) {
|
2011-01-06 00:02:22 +03:00
|
|
|
i++;
|
|
|
|
}
|
|
|
|
t->btcnt = i;
|
2012-11-27 05:12:09 +04:00
|
|
|
t->buttons = malloc(t->btcnt * sizeof(struct s_tb_button));
|
2013-01-22 04:21:24 +04:00
|
|
|
memset(t->buttons, 0, t->btcnt * sizeof(struct s_tb_button));
|
|
|
|
for (i=0; i < t->btcnt; i++) {
|
2012-11-27 05:12:09 +04:00
|
|
|
button_init(t, aes_toolbar, i, &t->buttons[i]);
|
2011-01-06 00:02:22 +03:00
|
|
|
}
|
|
|
|
|
2012-04-11 03:12:13 +04:00
|
|
|
/* create the url widget: */
|
|
|
|
font_style_url.size =
|
|
|
|
toolbar_styles[t->style].font_height_pt * FONT_SIZE_SCALE;
|
|
|
|
|
2013-02-27 00:55:40 +04:00
|
|
|
textarea_flags ta_flags = TEXTAREA_INTERNAL_CARET;
|
2013-01-31 23:33:41 +04:00
|
|
|
textarea_setup ta_setup;
|
|
|
|
ta_setup.width = 300;
|
2013-02-27 00:48:55 +04:00
|
|
|
ta_setup.height = t->form[TOOLBAR_AREA_URL].ob_height;
|
2013-01-31 23:33:41 +04:00
|
|
|
ta_setup.pad_top = 0;
|
|
|
|
ta_setup.pad_right = 4;
|
|
|
|
ta_setup.pad_bottom = 0;
|
|
|
|
ta_setup.pad_left = 4;
|
|
|
|
ta_setup.border_width = 1;
|
|
|
|
ta_setup.border_col = 0x000000;
|
|
|
|
ta_setup.selected_text = 0xffffff;
|
|
|
|
ta_setup.selected_bg = 0x000000;
|
|
|
|
ta_setup.text = font_style_url;
|
|
|
|
ta_setup.text.foreground = 0x000000;
|
|
|
|
ta_setup.text.background = 0xffffff;
|
2013-02-03 02:58:35 +04:00
|
|
|
t->url.textarea = textarea_create(ta_flags, &ta_setup,
|
|
|
|
tb_txt_callback, t);
|
2012-06-05 01:12:44 +04:00
|
|
|
|
2011-01-06 00:02:22 +03:00
|
|
|
/* create the throbber widget: */
|
2012-12-01 16:13:04 +04:00
|
|
|
t->throbber.index = THROBBER_INACTIVE_INDEX;
|
|
|
|
t->throbber.max_index = THROBBER_MAX_INDEX;
|
2012-11-27 05:12:09 +04:00
|
|
|
t->throbber.running = false;
|
|
|
|
|
|
|
|
LOG(("created toolbar: %p, root: %p, textarea: %p, throbber: %p", t,
|
|
|
|
owner, t->url.textarea, t->throbber));
|
2011-01-06 00:02:22 +03:00
|
|
|
return( t );
|
2012-11-27 05:12:09 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void toolbar_destroy(struct s_toolbar *tb)
|
2012-06-04 02:07:57 +04:00
|
|
|
{
|
2012-11-27 05:12:09 +04:00
|
|
|
free(tb->buttons);
|
2013-01-23 01:28:20 +04:00
|
|
|
free(tb->form);
|
|
|
|
|
2013-01-14 04:01:22 +04:00
|
|
|
textarea_destroy(tb->url.textarea);
|
2013-01-23 01:28:20 +04:00
|
|
|
|
2012-11-27 05:12:09 +04:00
|
|
|
free(tb);
|
|
|
|
}
|
|
|
|
|
2013-01-14 04:01:22 +04:00
|
|
|
static int toolbar_calculate_height(struct s_toolbar *tb)
|
|
|
|
{
|
|
|
|
int r = 0;
|
|
|
|
|
|
|
|
if (tb->visible == false) {
|
|
|
|
return(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
r += area_navigation_height;
|
|
|
|
|
|
|
|
if (tb->search_visible) {
|
|
|
|
r += area_search_height;
|
|
|
|
}
|
|
|
|
|
|
|
|
return(r);
|
|
|
|
}
|
|
|
|
|
2012-11-29 05:01:13 +04:00
|
|
|
static void toolbar_reflow(struct s_toolbar *tb)
|
2012-04-11 03:12:13 +04:00
|
|
|
{
|
2012-11-30 06:20:52 +04:00
|
|
|
int i;
|
2012-11-29 00:30:24 +04:00
|
|
|
|
|
|
|
// position toolbar areas:
|
2013-01-23 01:28:20 +04:00
|
|
|
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);
|
2013-01-14 04:01:22 +04:00
|
|
|
|
|
|
|
// expand the "main" areas to the current width:
|
2013-01-23 01:28:20 +04:00
|
|
|
tb->form[TOOLBAR_AREA_NAVIGATION].ob_width = tb->area.g_w;
|
|
|
|
tb->form[TOOLBAR_AREA_SEARCH].ob_width = tb->area.g_w;
|
2013-01-14 04:01:22 +04:00
|
|
|
|
|
|
|
if (tb->search_visible) {
|
2013-01-23 01:28:20 +04:00
|
|
|
tb->form[TOOLBAR_AREA_SEARCH].ob_state &= ~OF_HIDETREE;
|
2013-01-14 04:01:22 +04:00
|
|
|
} else {
|
2013-01-23 01:28:20 +04:00
|
|
|
tb->form[TOOLBAR_AREA_SEARCH].ob_state |= OF_HIDETREE;
|
2013-01-14 04:01:22 +04:00
|
|
|
|
|
|
|
}
|
2012-04-11 03:12:13 +04:00
|
|
|
|
2013-01-14 04:01:22 +04:00
|
|
|
// align the throbber area at right edge:
|
2013-01-23 01:28:20 +04:00
|
|
|
tb->form[TOOLBAR_THROBBER_AREA].ob_x = tb->area.g_w
|
|
|
|
- tb->form[TOOLBAR_THROBBER_AREA].ob_width;
|
2012-04-11 03:12:13 +04:00
|
|
|
|
2013-01-14 04:01:22 +04:00
|
|
|
// align the search button:
|
2013-01-23 01:28:20 +04:00
|
|
|
tb->form[TOOLBAR_SEARCH_ALIGN_RIGHT].ob_x = tb->area.g_w
|
|
|
|
- tb->form[TOOLBAR_SEARCH_ALIGN_RIGHT].ob_width;
|
2013-01-14 04:01:22 +04:00
|
|
|
|
|
|
|
// center the URL area:
|
2013-01-23 01:28:20 +04:00
|
|
|
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);
|
2012-11-29 05:01:13 +04:00
|
|
|
|
2012-04-11 03:12:13 +04:00
|
|
|
|
2012-11-27 05:12:09 +04:00
|
|
|
// position throbber image:
|
|
|
|
throbber_form[tb->throbber.index].ob_x = tb->area.g_x +
|
2013-01-23 01:28:20 +04:00
|
|
|
tb->form[TOOLBAR_THROBBER_AREA].ob_x;
|
2012-04-11 03:12:13 +04:00
|
|
|
|
2012-11-27 05:12:09 +04:00
|
|
|
throbber_form[tb->throbber.index].ob_x = tb->area.g_x
|
2013-01-23 01:28:20 +04:00
|
|
|
+ tb->form[TOOLBAR_THROBBER_AREA].ob_x +
|
|
|
|
((tb->form[TOOLBAR_THROBBER_AREA].ob_width
|
2012-11-27 05:12:09 +04:00
|
|
|
- throbber_form[tb->throbber.index].ob_width) >> 1);
|
|
|
|
|
|
|
|
throbber_form[tb->throbber.index].ob_y = tb->area.g_y +
|
2013-01-23 01:28:20 +04:00
|
|
|
((tb->form[TOOLBAR_THROBBER_AREA].ob_height
|
2012-11-27 05:12:09 +04:00
|
|
|
- throbber_form[tb->throbber.index].ob_height) >> 1);
|
|
|
|
|
2012-11-30 06:20:52 +04:00
|
|
|
// set button states:
|
|
|
|
for (i=0; i < tb->btcnt; i++ ) {
|
|
|
|
if (tb->buttons[i].state == button_off) {
|
2013-01-23 01:28:20 +04:00
|
|
|
tb->form[tb->buttons[i].rsc_id].ob_state |= OS_DISABLED;
|
2012-11-30 06:20:52 +04:00
|
|
|
}
|
|
|
|
else if (tb->buttons[i].state == button_on) {
|
2013-01-23 01:28:20 +04:00
|
|
|
tb->form[tb->buttons[i].rsc_id].ob_state &= ~OS_DISABLED;
|
2012-11-30 06:20:52 +04:00
|
|
|
}
|
|
|
|
}
|
2012-11-29 00:30:24 +04:00
|
|
|
tb->reflow = false;
|
2012-11-30 06:20:52 +04:00
|
|
|
// TODO: iterate through all other toolbars and set reflow = true
|
2012-11-29 00:30:24 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void toolbar_redraw(struct s_toolbar *tb, GRECT *clip)
|
|
|
|
{
|
2013-01-14 04:01:22 +04:00
|
|
|
GRECT area, area_ro;
|
2012-11-29 05:01:13 +04:00
|
|
|
|
2012-11-30 06:20:52 +04:00
|
|
|
if (tb->attached == false) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2012-11-29 00:30:24 +04:00
|
|
|
if(tb->reflow == true)
|
2012-11-29 05:01:13 +04:00
|
|
|
toolbar_reflow(tb);
|
|
|
|
|
2013-01-16 01:24:53 +04:00
|
|
|
//TODO: fix redraw under popup menu ... that not handled correctly somehow.
|
|
|
|
|
|
|
|
//dbg_grect("toolbar redraw clip", clip);
|
2012-11-27 05:12:09 +04:00
|
|
|
|
2013-09-21 07:29:04 +04:00
|
|
|
/* Redraw the AES objects: */
|
2013-01-23 01:28:20 +04:00
|
|
|
objc_draw_grect(tb->form,0,8,clip);
|
2012-11-29 00:30:24 +04:00
|
|
|
objc_draw_grect(&throbber_form[tb->throbber.index], 0, 1, clip);
|
2012-11-29 05:01:13 +04:00
|
|
|
|
2013-01-14 04:01:22 +04:00
|
|
|
toolbar_get_grect(tb, TOOLBAR_AREA_URL, &area_ro);
|
|
|
|
area = area_ro;
|
|
|
|
|
2012-11-29 05:01:13 +04:00
|
|
|
if (rc_intersect(clip, &area)) {
|
|
|
|
|
2013-01-14 04:01:22 +04:00
|
|
|
plot_set_dimensions(area_ro.g_x, area_ro.g_y, area_ro.g_w, area_ro.g_h);
|
2013-01-16 01:24:53 +04:00
|
|
|
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
|
|
|
|
};
|
2013-01-17 04:18:27 +04:00
|
|
|
//dbg_rect("tb textarea clip: ", &r);
|
2013-01-17 05:04:43 +04:00
|
|
|
// TODO: let this be handled by an userdef object redraw function:
|
2013-09-21 07:29:04 +04:00
|
|
|
/* Redraw the url input: */
|
2013-02-11 14:47:15 +04:00
|
|
|
textarea_redraw(tb->url.textarea, 0, 0, 0xffffff, 1.0, &r, &toolbar_rdrw_ctx);
|
2012-11-29 05:01:13 +04:00
|
|
|
}
|
2012-11-27 05:12:09 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void toolbar_update_buttons(struct s_toolbar *tb, struct browser_window *bw,
|
|
|
|
short button)
|
|
|
|
{
|
|
|
|
LOG((""));
|
2012-11-30 06:20:52 +04:00
|
|
|
|
|
|
|
struct s_tb_button * bt;
|
|
|
|
bool enable = false;
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-22 04:21:24 +04:00
|
|
|
if (button == TOOLBAR_BT_HOME || button <= 0 ) {
|
2012-11-30 06:20:52 +04:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-01-22 04:21:24 +04:00
|
|
|
if (button == TOOLBAR_BT_FORWARD || button <= 0 ) {
|
2012-11-30 06:20:52 +04:00
|
|
|
bt = find_button(tb, TOOLBAR_BT_FORWARD);
|
|
|
|
enable = browser_window_forward_available(bw);
|
|
|
|
if (enable) {
|
|
|
|
bt->state = button_on;
|
|
|
|
} else {
|
|
|
|
bt->state = button_off;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-22 04:21:24 +04:00
|
|
|
if (button == TOOLBAR_BT_RELOAD || button <= 0 ) {
|
2012-11-30 06:20:52 +04:00
|
|
|
bt = find_button(tb, TOOLBAR_BT_RELOAD);
|
|
|
|
enable = browser_window_reload_available(bw);
|
|
|
|
if (enable) {
|
|
|
|
bt->state = button_on;
|
|
|
|
} else {
|
|
|
|
bt->state = button_off;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tb->attached) {
|
|
|
|
if (button > 0) {
|
|
|
|
toolbar_get_grect(tb, button, &area);
|
|
|
|
window_schedule_redraw_grect(tb->owner, &area);
|
|
|
|
}
|
|
|
|
else {
|
2013-01-14 04:01:22 +04:00
|
|
|
toolbar_get_grect(tb, TOOLBAR_AREA_BUTTONS, &area);
|
2012-11-30 06:20:52 +04:00
|
|
|
window_schedule_redraw_grect(tb->owner, &area);
|
|
|
|
}
|
|
|
|
}
|
2012-11-27 05:12:09 +04:00
|
|
|
}
|
|
|
|
|
2013-01-15 04:31:35 +04:00
|
|
|
void toolbar_set_width(struct s_toolbar *tb, short w)
|
|
|
|
{
|
|
|
|
GRECT cur;
|
2012-11-27 05:12:09 +04:00
|
|
|
|
2013-01-15 04:31:35 +04:00
|
|
|
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,
|
2013-01-23 01:28:20 +04:00
|
|
|
tb->form[TOOLBAR_AREA_URL].ob_width,
|
|
|
|
tb->form[TOOLBAR_AREA_URL].ob_height);
|
2013-01-15 04:31:35 +04:00
|
|
|
tb->reflow = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void toolbar_set_origin(struct s_toolbar *tb, short x, short y)
|
2012-11-27 05:12:09 +04:00
|
|
|
{
|
2013-01-15 04:31:35 +04:00
|
|
|
GRECT cur;
|
|
|
|
|
|
|
|
toolbar_get_grect(tb, 0, &cur);
|
2012-11-30 06:20:52 +04:00
|
|
|
|
2013-01-15 04:31:35 +04:00
|
|
|
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) {
|
2013-01-14 04:01:22 +04:00
|
|
|
|
2012-11-30 06:20:52 +04:00
|
|
|
tb->area = *area;
|
2013-01-14 04:01:22 +04:00
|
|
|
|
2012-11-30 06:20:52 +04:00
|
|
|
/* reflow now, just for url input calucation: */
|
|
|
|
toolbar_reflow(tb);
|
|
|
|
/* this will request an textarea redraw: */
|
|
|
|
textarea_set_dimensions(tb->url.textarea,
|
2013-01-23 01:28:20 +04:00
|
|
|
tb->form[TOOLBAR_AREA_URL].ob_width,
|
2013-02-27 00:48:55 +04:00
|
|
|
tb->form[TOOLBAR_AREA_URL].ob_height-1);
|
2012-11-30 06:20:52 +04:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
tb->area = *area;
|
|
|
|
}
|
2013-01-14 04:01:22 +04:00
|
|
|
/* reflow for next redraw: */
|
|
|
|
/* TODO: that's only required because we do not reset others toolbars reflow
|
|
|
|
state on reflow */
|
2012-11-29 00:30:24 +04:00
|
|
|
tb->reflow = true;
|
2012-11-27 05:12:09 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void toolbar_set_url(struct s_toolbar *tb, const char * text)
|
|
|
|
{
|
|
|
|
LOG((""));
|
2012-11-29 05:01:13 +04:00
|
|
|
textarea_set_text(tb->url.textarea, text);
|
|
|
|
|
2013-09-21 07:29:04 +04:00
|
|
|
if (tb->attached && tb->visible) {
|
2012-11-30 06:20:52 +04:00
|
|
|
GRECT area;
|
2013-01-14 04:01:22 +04:00
|
|
|
toolbar_get_grect(tb, TOOLBAR_AREA_URL, &area);
|
2012-11-30 06:20:52 +04:00
|
|
|
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);
|
|
|
|
}
|
2012-11-29 05:01:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
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);
|
2012-11-27 05:12:09 +04:00
|
|
|
}
|
|
|
|
|
2013-01-14 04:01:22 +04:00
|
|
|
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;
|
2013-04-15 23:02:34 +04:00
|
|
|
OBJECT *frm = toolbar_get_form(tb);
|
|
|
|
if(visible == false){
|
|
|
|
frm[TOOLBAR_AREA_SEARCH].ob_flags |= OF_HIDETREE;
|
|
|
|
} else {
|
|
|
|
frm[TOOLBAR_AREA_SEARCH].ob_flags &= ~OF_HIDETREE;
|
|
|
|
}
|
2013-01-14 04:01:22 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void toolbar_set_reflow(struct s_toolbar *tb, bool do_reflow)
|
|
|
|
{
|
2013-01-22 04:21:24 +04:00
|
|
|
tb->reflow = do_reflow;
|
2013-01-14 04:01:22 +04:00
|
|
|
}
|
|
|
|
|
2012-11-30 06:20:52 +04:00
|
|
|
void toolbar_set_attached(struct s_toolbar *tb, bool attached)
|
|
|
|
{
|
|
|
|
tb->attached = attached;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2012-11-29 05:01:13 +04:00
|
|
|
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);
|
|
|
|
}
|
2012-11-27 05:12:09 +04:00
|
|
|
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
|
2013-01-31 22:22:35 +04:00
|
|
|
assert(tb!=NULL);
|
|
|
|
|
|
|
|
GRECT work;
|
2012-11-30 06:20:52 +04:00
|
|
|
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);
|
2013-01-31 22:22:35 +04:00
|
|
|
|
2012-11-30 06:20:52 +04:00
|
|
|
if (ik == 0) {
|
|
|
|
if ((nkc&0xFF) >= 9) {
|
|
|
|
ret = textarea_keypress(tb->url.textarea, ucs4);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (ik == KEY_CR || ik == KEY_NL) {
|
2013-02-14 19:09:28 +04:00
|
|
|
nsurl *url;
|
2012-11-30 06:20:52 +04:00
|
|
|
char tmp_url[PATH_MAX];
|
|
|
|
if ( textarea_get_text( tb->url.textarea, tmp_url, PATH_MAX) > 0 ) {
|
|
|
|
window_set_focus(tb->owner, BROWSER, gw->browser);
|
2013-02-14 19:09:28 +04:00
|
|
|
|
|
|
|
if (nsurl_create((const char*)&tmp_url, &url) != NSERROR_OK) {
|
|
|
|
warn_user("NoMemory", 0);
|
|
|
|
} else {
|
|
|
|
browser_window_navigate(gw->browser->bw,
|
|
|
|
url,
|
|
|
|
NULL,
|
2013-02-18 15:51:42 +04:00
|
|
|
BROWSER_WINDOW_HISTORY |
|
|
|
|
BROWSER_WINDOW_VERIFIABLE,
|
2013-02-14 19:09:28 +04:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
nsurl_unref(url);
|
|
|
|
}
|
|
|
|
|
2012-11-30 06:20:52 +04:00
|
|
|
ret = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
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){
|
|
|
|
textarea_get_text( tb->url.textarea, text, len+1 );
|
2012-12-31 06:37:43 +04:00
|
|
|
scrap_txt_write(text);
|
2012-11-30 06:20:52 +04:00
|
|
|
free( text );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if ( ik == KEY_PASTE) {
|
2012-12-31 06:37:43 +04:00
|
|
|
char * clip = scrap_txt_read();
|
2012-11-30 06:20:52 +04:00
|
|
|
if ( clip != NULL ){
|
|
|
|
int clip_length = strlen( clip );
|
|
|
|
if ( clip_length > 0 ) {
|
|
|
|
char *utf8;
|
|
|
|
utf8_convert_ret res;
|
|
|
|
/* Clipboard is in local encoding so
|
|
|
|
* convert to UTF8 */
|
|
|
|
res = utf8_from_local_encoding( clip, clip_length, &utf8 );
|
|
|
|
if ( res == UTF8_CONVERT_OK ) {
|
|
|
|
toolbar_set_url(tb, utf8);
|
|
|
|
free(utf8);
|
|
|
|
ret = true;
|
|
|
|
}
|
|
|
|
}
|
2012-12-31 06:37:43 +04:00
|
|
|
free( clip );
|
2012-11-30 06:20:52 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (ik == KEY_ESCAPE) {
|
|
|
|
textarea_keypress( tb->url.textarea, KEY_SELECT_ALL );
|
|
|
|
textarea_keypress( tb->url.textarea, KEY_DELETE_LEFT );
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
ret = textarea_keypress( tb->url.textarea, ik );
|
|
|
|
}
|
|
|
|
|
|
|
|
return( ret );
|
2012-11-27 05:12:09 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-01-11 00:07:36 +04:00
|
|
|
void toolbar_mouse_input(struct s_toolbar *tb, short obj, short button)
|
2012-11-27 05:12:09 +04:00
|
|
|
{
|
|
|
|
LOG((""));
|
2012-11-30 06:20:52 +04:00
|
|
|
GRECT work;
|
|
|
|
short mx, my, mb, kstat;
|
|
|
|
int old;
|
2013-01-16 06:21:35 +04:00
|
|
|
OBJECT * toolbar_tree;
|
|
|
|
struct gui_window * gw;
|
|
|
|
|
2012-11-30 06:20:52 +04:00
|
|
|
|
2013-01-14 04:01:22 +04:00
|
|
|
if (obj==TOOLBAR_AREA_URL){
|
2012-11-30 06:20:52 +04:00
|
|
|
|
2013-01-15 04:31:35 +04:00
|
|
|
graf_mkstate(&mx, &my, &mb, &kstat);
|
2013-01-14 04:01:22 +04:00
|
|
|
toolbar_get_grect(tb, TOOLBAR_AREA_URL, &work);
|
2012-11-30 06:20:52 +04:00
|
|
|
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)) {
|
2013-01-23 01:28:20 +04:00
|
|
|
window_set_focus(tb->owner, URL_WIDGET, (void*)&tb->url);
|
2013-01-11 00:07:36 +04:00
|
|
|
}
|
2012-11-30 06:20:52 +04:00
|
|
|
/* 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 );
|
2013-02-27 00:48:55 +04:00
|
|
|
mx = mx - (work.g_x);
|
|
|
|
my = my - (work.g_y);
|
2012-11-30 06:20:52 +04:00
|
|
|
} while (mb & 1);
|
2013-01-31 23:33:41 +04:00
|
|
|
|
|
|
|
textarea_mouse_action( tb->url.textarea, BROWSER_MOUSE_HOVER, mx,
|
|
|
|
my);
|
2012-11-30 06:20:52 +04:00
|
|
|
}
|
2013-01-23 01:28:20 +04:00
|
|
|
else if (button & 2) {
|
|
|
|
// TODO: open a context popup
|
|
|
|
}
|
2012-11-30 06:20:52 +04:00
|
|
|
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;
|
2013-01-23 01:28:20 +04:00
|
|
|
if ((kstat & (K_LSHIFT|K_RSHIFT)) != 0) {
|
2012-11-30 06:20:52 +04:00
|
|
|
mstate = BROWSER_MOUSE_MOD_1;
|
|
|
|
}
|
2013-01-23 01:28:20 +04:00
|
|
|
if (aes_event_out.emo_mclicks == 2 ) {
|
2012-11-30 06:20:52 +04:00
|
|
|
textarea_mouse_action( tb->url.textarea,
|
|
|
|
BROWSER_MOUSE_DOUBLE_CLICK | BROWSER_MOUSE_CLICK_1, mx,
|
|
|
|
my);
|
2013-01-14 04:01:22 +04:00
|
|
|
toolbar_get_grect(tb, TOOLBAR_AREA_URL, &work);
|
2012-11-30 06:20:52 +04:00
|
|
|
window_schedule_redraw_grect(tb->owner, &work);
|
|
|
|
} else {
|
|
|
|
textarea_mouse_action(tb->url.textarea,
|
|
|
|
BROWSER_MOUSE_PRESS_1, mx, my );
|
|
|
|
}
|
|
|
|
}
|
2013-01-23 01:28:20 +04:00
|
|
|
}
|
|
|
|
else if(obj==TOOLBAR_TB_SRCH) {
|
|
|
|
window_set_focus(tb->owner, SEARCH_INPUT, NULL);
|
2013-01-16 06:21:35 +04:00
|
|
|
}
|
|
|
|
else if (obj==TOOLBAR_BT_SEARCH_FWD) {
|
|
|
|
gw = tb->owner->active_gui_window;
|
|
|
|
assert(gw->search);
|
2013-01-23 01:28:20 +04:00
|
|
|
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);
|
2013-01-16 06:21:35 +04:00
|
|
|
}
|
|
|
|
else if (obj==TOOLBAR_BT_CLOSE_SEARCH) {
|
2013-01-23 01:28:20 +04:00
|
|
|
tb->form[TOOLBAR_BT_CLOSE_SEARCH].ob_state &= ~OS_SELECTED;
|
2013-01-16 06:21:35 +04:00
|
|
|
window_close_search(tb->owner);
|
|
|
|
}
|
|
|
|
else {
|
2012-11-30 06:20:52 +04:00
|
|
|
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);
|
2013-01-14 04:01:22 +04:00
|
|
|
toolbar_update_buttons(tb, gw->browser->bw, 0);
|
2012-11-30 06:20:52 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2012-11-27 05:12:09 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-11-29 05:01:13 +04:00
|
|
|
/**
|
|
|
|
* Receive a specific region of the toolbar.
|
|
|
|
* @param tb - the toolbar pointer
|
2013-01-14 04:01:22 +04:00
|
|
|
* @param which - the area to retrieve: 0 to receive the workarea,
|
|
|
|
all other values must be
|
|
|
|
an resource ID of the TOOLBAR tree.
|
2012-11-29 05:01:13 +04:00
|
|
|
* @param dst - GRECT pointer receiving the area.
|
|
|
|
*/
|
2012-11-27 05:12:09 +04:00
|
|
|
|
2012-11-29 05:01:13 +04:00
|
|
|
void toolbar_get_grect(struct s_toolbar *tb, short which, GRECT *dst)
|
2012-11-27 05:12:09 +04:00
|
|
|
{
|
2013-01-14 04:01:22 +04:00
|
|
|
#define LAST_TOOLBAR_AREA TOOLBAR_AREA_SEARCH
|
|
|
|
|
2012-11-29 05:01:13 +04:00
|
|
|
if (tb->reflow == true) {
|
|
|
|
toolbar_reflow(tb);
|
|
|
|
}
|
|
|
|
|
2013-01-23 01:28:20 +04:00
|
|
|
objc_offset(tb->form, which, &dst->g_x, &dst->g_y);
|
2013-01-14 04:01:22 +04:00
|
|
|
|
2013-01-23 01:28:20 +04:00
|
|
|
dst->g_w = tb->form[which].ob_width;
|
|
|
|
dst->g_h = tb->form[which].ob_height;
|
|
|
|
//tb->form[which].ob_height;
|
2013-01-14 04:01:22 +04:00
|
|
|
|
2013-01-15 04:54:54 +04:00
|
|
|
//printf("Toolbar get grect (%d): ", which);
|
|
|
|
//dbg_grect("", dst);
|
2012-11-27 05:12:09 +04:00
|
|
|
|
2013-01-14 04:01:22 +04:00
|
|
|
#undef LAST_TOOLBAR_AREA
|
2012-11-27 05:12:09 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-01-11 00:07:36 +04:00
|
|
|
struct textarea *toolbar_get_textarea(struct s_toolbar *tb,
|
2012-11-27 05:12:09 +04:00
|
|
|
enum toolbar_textarea which)
|
|
|
|
{
|
|
|
|
return(tb->url.textarea);
|
|
|
|
}
|
|
|
|
|
2013-01-23 01:28:20 +04:00
|
|
|
OBJECT *toolbar_get_form(struct s_toolbar *tb)
|
|
|
|
{
|
|
|
|
return(tb->form);
|
|
|
|
}
|
|
|
|
|
2012-11-27 05:12:09 +04:00
|
|
|
|
|
|
|
/* public event handler */
|
|
|
|
void toolbar_back_click(struct s_toolbar *tb)
|
|
|
|
{
|
2012-11-30 06:20:52 +04:00
|
|
|
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) )
|
2011-01-06 00:02:22 +03:00
|
|
|
history_back(bw, bw->history);
|
|
|
|
}
|
|
|
|
|
2012-11-27 05:12:09 +04:00
|
|
|
void toolbar_reload_click(struct s_toolbar *tb)
|
2012-04-13 00:18:53 +04:00
|
|
|
{
|
2012-11-30 06:20:52 +04:00
|
|
|
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);
|
2011-01-06 00:02:22 +03:00
|
|
|
}
|
|
|
|
|
2012-11-27 05:12:09 +04:00
|
|
|
void toolbar_forward_click(struct s_toolbar *tb)
|
|
|
|
{
|
2012-11-30 06:20:52 +04:00
|
|
|
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);
|
|
|
|
|
2011-01-06 00:02:22 +03:00
|
|
|
if (history_forward_available(bw->history))
|
|
|
|
history_forward(bw, bw->history);
|
|
|
|
}
|
|
|
|
|
2012-11-27 05:12:09 +04:00
|
|
|
void toolbar_home_click(struct s_toolbar *tb)
|
2012-04-13 00:18:53 +04:00
|
|
|
{
|
2013-02-14 19:09:28 +04:00
|
|
|
struct browser_window * bw;
|
|
|
|
struct gui_window * gw;
|
|
|
|
nsurl *url;
|
2012-11-27 05:12:09 +04:00
|
|
|
|
2013-02-14 19:09:28 +04:00
|
|
|
gw = window_get_active_gui_window(tb->owner);
|
|
|
|
assert(gw != NULL);
|
|
|
|
bw = gw->browser->bw;
|
|
|
|
assert(bw != NULL);
|
|
|
|
|
2013-04-11 03:30:34 +04:00
|
|
|
if(nsoption_charp(homepage_url) == NULL){
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-02-18 17:05:06 +04:00
|
|
|
if (nsurl_create(nsoption_charp(homepage_url), &url) != NSERROR_OK) {
|
2013-02-14 19:09:28 +04:00
|
|
|
warn_user("NoMemory", 0);
|
|
|
|
} else {
|
|
|
|
browser_window_navigate(bw,
|
|
|
|
url,
|
|
|
|
NULL,
|
2013-02-18 15:51:42 +04:00
|
|
|
BROWSER_WINDOW_HISTORY |
|
|
|
|
BROWSER_WINDOW_VERIFIABLE,
|
2013-02-14 19:09:28 +04:00
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL);
|
|
|
|
nsurl_unref(url);
|
|
|
|
}
|
2011-01-06 00:02:22 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-11-27 05:12:09 +04:00
|
|
|
void toolbar_stop_click(struct s_toolbar *tb)
|
2012-04-13 00:18:53 +04:00
|
|
|
{
|
2012-11-30 06:20:52 +04:00
|
|
|
struct browser_window * bw;
|
|
|
|
struct gui_window * gw;
|
|
|
|
|
|
|
|
gw = window_get_active_gui_window(tb->owner);
|
2013-01-14 04:01:22 +04:00
|
|
|
|
2012-11-30 06:20:52 +04:00
|
|
|
assert(gw != NULL);
|
2013-01-14 04:01:22 +04:00
|
|
|
|
2012-11-30 06:20:52 +04:00
|
|
|
bw = gw->browser->bw;
|
2013-01-14 04:01:22 +04:00
|
|
|
|
2012-11-30 06:20:52 +04:00
|
|
|
assert(bw != NULL);
|
|
|
|
|
|
|
|
browser_window_stop(bw);
|
2012-01-12 00:35:50 +04:00
|
|
|
}
|
|
|
|
|