summaryrefslogtreecommitdiff
path: root/atari/toolbar.h
blob: 851609bc41cb20d28c26ff063229a1923b0709a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/*
 * Copyright 2010 Ole Loots <ole@monochrom.net>
 *
 * 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/>.
 */

#ifndef NS_ATARI_TOOLBAR_H
#define NS_ATARI_TOOLBAR_H

#define TB_BUTTON_WIDTH 32
#define TB_BUTTON_HEIGHT 21 /* includes 1px 3d effect */
#define TOOLBAR_HEIGHT 25
#define THROBBER_WIDTH 32
#define THROBBER_MIN_INDEX 1
#define THROBBER_MAX_INDEX 12
#define THROBBER_INACTIVE_INDEX 13
#define URLBOX_HEIGHT 21
/*
 URL Widget Block size: size of memory block to allocated
 when input takes more memory than currently allocated:
*/
#define URL_WIDGET_BSIZE 64
#define URL_WIDGET_MAX_MEM 60000

struct s_tb_button
{
	short rsc_id;
	void (*cb_click)(struct gui_window * gw);
	COMPONENT * comp;
};


struct s_url_widget
{
	short selection_len;	/* len & direction of selection */
	short caret_pos;	 	/* cursor pos */
	short char_size;	 	/* size of one character (width & hight) */
	short scrollx;  	 	/* current scroll position */
	bool redraw;		 	/* widget is only redrawn when this flag is set */
	char * text;			/* dynamicall allocated URL string */
	unsigned short allocated;
	unsigned short used; 	/* memory used by URL (strlen + 1) */
	COMPONENT * comp;
};

struct s_throbber_widget
{
	COMPONENT * comp;
	short index;
	short max_index;
	bool running;
};

struct s_toolbar
{
	COMPONENT * comp;
	struct gui_window * owner;
	struct s_url_widget url;
	struct s_throbber_widget throbber;
	GRECT btdim; /* size & location of buttons */
	struct s_tb_button * buttons;
	int btcnt;
};

CMP_TOOLBAR tb_create( struct gui_window * gw );
void tb_destroy( CMP_TOOLBAR tb );


static void __CDECL evnt_toolbar_redraw( COMPONENT *c, long buff[8], void *data );
//static void __CDECL evnt_toolbar_mbutton( COMPONENT *c, long buff[8], void *data );
static void __CDECL evnt_toolbar_resize( COMPONENT *c, long buff[8], void *data );

/* report click to toolbar, relative coords : */
void tb_click( struct gui_window * gw, short mx, short my, short mb, short kstat );
void tb_back_click( struct gui_window * gw );
void tb_reload_click( struct gui_window * gw );
void tb_forward_click( struct gui_window * gw );
void tb_home_click( struct gui_window * gw );
void tb_stop_click( struct gui_window * gw );

/* enable / disable buttons etc. */
void tb_update_buttons( struct gui_window * gw );
/* handles clicks on url widget: */
void tb_url_click( struct gui_window * gw, short mx, short my, short mb, short kstat );
/* handle keybd event while url widget has focus:*/
bool tb_url_input( struct gui_window * gw, short keycode );
/* place the caret and adjust scrolling position: */
void tb_url_place_caret( struct gui_window * gw, int steps, bool abs);
/* set the url: */
void tb_url_set( struct gui_window * gw, char * text );

struct gui_window * tb_gui_window( CMP_TOOLBAR tb );

#endif