r13849 mono - in /trunk/netsurf/atari: browser_win.c global_evnt.c gui.c gui.h
by netsurf@semichrome.net
Author: mono
Date: Tue Apr 10 18:12:49 2012
New Revision: 13849
URL: http://source.netsurf-browser.org?rev=13849&view=rev
Log:
Init toolbar.
Modified:
trunk/netsurf/atari/browser_win.c
trunk/netsurf/atari/global_evnt.c
trunk/netsurf/atari/gui.c
trunk/netsurf/atari/gui.h
Modified: trunk/netsurf/atari/browser_win.c
URL: http://source.netsurf-browser.org/trunk/netsurf/atari/browser_win.c?rev=1...
==============================================================================
--- trunk/netsurf/atari/browser_win.c (original)
+++ trunk/netsurf/atari/browser_win.c Tue Apr 10 18:12:49 2012
@@ -235,10 +235,10 @@
if( gw->root->statusbar != NULL ){
gw->root->statusbar->attached = true;
}
- tb_adjust_size( gw );
+ tb_adjust_size( gw );
/*TBD: get already present content and set size? */
input_window = gw;
- window_set_focus( gw, BROWSER, gw->browser );
+ window_set_focus( gw, BROWSER, gw->browser );
}
@@ -246,7 +246,7 @@
/* update back forward buttons (see tb_update_buttons (bug) ) */
void window_update_back_forward( struct gui_window * gw)
{
- tb_update_buttons( gw );
+ tb_update_buttons( gw, -1 );
}
void window_set_stauts( struct gui_window * gw , char * text )
Modified: trunk/netsurf/atari/global_evnt.c
URL: http://source.netsurf-browser.org/trunk/netsurf/atari/global_evnt.c?rev=1...
==============================================================================
--- trunk/netsurf/atari/global_evnt.c (original)
+++ trunk/netsurf/atari/global_evnt.c Tue Apr 10 18:12:49 2012
@@ -496,26 +496,24 @@
}
sascii = keybd2ascii( evnt.keybd, K_LSHIFT);
while( menu_evnt_tbl[i].rid != -1 && done == false) {
- if(menu_evnt_tbl[i].nsid[0] != 0 ) {
- if( kstate == menu_evnt_tbl[i].accel.mod && menu_evnt_tbl[i].accel.ascii != 0) {
- if( menu_evnt_tbl[i].accel.ascii == sascii) {
- menu_evnt_tbl[i].menu_func( NULL, menu_evnt_tbl[i].rid, MAINMENU, buff);
- done = true;
- break;
- }
- } else {
- /* the accel code hides in the keycode: */
- if( menu_evnt_tbl[i].accel.keycode != 0) {
- if( menu_evnt_tbl[i].accel.keycode == (nkc & 0xFF) &&
- kstate == menu_evnt_tbl[i].accel.mod &&
- menu_evnt_tbl[i].menu_func != NULL) {
- menu_evnt_tbl[i].menu_func( NULL,
- menu_evnt_tbl[i].rid,
- MAINMENU, buff
- );
- done = true;
- break;
- }
+ if( kstate == menu_evnt_tbl[i].accel.mod && menu_evnt_tbl[i].accel.ascii != 0) {
+ if( menu_evnt_tbl[i].accel.ascii == sascii) {
+ menu_evnt_tbl[i].menu_func( NULL, menu_evnt_tbl[i].rid, MAINMENU, buff);
+ done = true;
+ break;
+ }
+ } else {
+ /* the accel code hides in the keycode: */
+ if( menu_evnt_tbl[i].accel.keycode != 0) {
+ if( menu_evnt_tbl[i].accel.keycode == (nkc & 0xFF) &&
+ kstate == menu_evnt_tbl[i].accel.mod &&
+ menu_evnt_tbl[i].menu_func != NULL) {
+ menu_evnt_tbl[i].menu_func( NULL,
+ menu_evnt_tbl[i].rid,
+ MAINMENU, buff
+ );
+ done = true;
+ break;
}
}
}
Modified: trunk/netsurf/atari/gui.c
URL: http://source.netsurf-browser.org/trunk/netsurf/atari/gui.c?rev=13849&r1=...
==============================================================================
--- trunk/netsurf/atari/gui.c (original)
+++ trunk/netsurf/atari/gui.c Tue Apr 10 18:12:49 2012
@@ -178,7 +178,7 @@
window_open( gw , pos );
/* Recalculate windows browser area now */
browser_update_rects( gw );
- tb_update_buttons( gw );
+ tb_update_buttons( gw, -1 );
input_window = gw;
/* TODO:... this line: placeholder to create a local history widget ... */
}
@@ -989,7 +989,8 @@
menu_register( _AESapid, (char*)" NetSurf ");
}
tree_set_icon_dir( nsoption_charp(tree_icons_path) );
- hotlist_init();
+ hotlist_init();
+ toolbar_init();
}
/* #define WITH_DBG_LOGFILE 1 */
Modified: trunk/netsurf/atari/gui.h
URL: http://source.netsurf-browser.org/trunk/netsurf/atari/gui.h?rev=13849&r1=...
==============================================================================
--- trunk/netsurf/atari/gui.h (original)
+++ trunk/netsurf/atari/gui.h Tue Apr 10 18:12:49 2012
@@ -76,9 +76,9 @@
#define CDT_OWNER 0x03UL
#define CDT_ICON 0x04UL
#define CDT_ICON_TYPE 0x05UL
-#define CDT_ICON_TYPE_NONE 0x00UL
-#define CDT_ICON_TYPE_OBJECT 0x01UL
-#define CDT_ICON_TYPE_BITMAP 0x02UL
+# define CDT_ICON_TYPE_NONE 0x00UL
+# define CDT_ICON_TYPE_OBJECT 0x01UL
+# define CDT_ICON_TYPE_BITMAP 0x02UL
struct gui_window;
11 years, 7 months
r13848 mono - in /trunk/netsurf/atari: options.h toolbar.c toolbar.h
by netsurf@semichrome.net
Author: mono
Date: Tue Apr 10 18:12:13 2012
New Revision: 13848
URL: http://source.netsurf-browser.org?rev=13848&view=rev
Log:
Initial support for (truecolor) image toolbar ( toolbar icons loaded from image file, not from resource ).
Modified:
trunk/netsurf/atari/options.h
trunk/netsurf/atari/toolbar.c
trunk/netsurf/atari/toolbar.h
Modified: trunk/netsurf/atari/options.h
URL: http://source.netsurf-browser.org/trunk/netsurf/atari/options.h?rev=13848...
==============================================================================
--- trunk/netsurf/atari/options.h (original)
+++ trunk/netsurf/atari/options.h Tue Apr 10 18:12:13 2012
@@ -24,54 +24,57 @@
#define NS_ATARI_OPTIONS_H_
-#define NSOPTION_EXTRA_DEFINE \
- char *atari_screen_driver; \
- char *atari_font_driver; \
- int atari_font_monochrom; \
- int atari_dither; \
- int atari_transparency; \
- char *atari_face_sans_serif; /* default sans face */ \
- char *atari_face_sans_serif_bold; /* bold sans face */ \
- char *atari_face_sans_serif_italic; /* bold sans face */ \
+#define NSOPTION_EXTRA_DEFINE \
+ char *atari_screen_driver; \
+ char *atari_font_driver; \
+ int atari_font_monochrom; \
+ int atari_dither; \
+ int atari_transparency; \
+ int atari_image_toolbar; \
+ char *atari_face_sans_serif; /* default sans face */ \
+ char *atari_face_sans_serif_bold; /* bold sans face */ \
+ char *atari_face_sans_serif_italic; /* bold sans face */ \
char *atari_face_sans_serif_italic_bold; /* bold sans face */ \
- char *atari_face_monospace; /* monospace face */ \
- char *atari_face_monospace_bold; /* monospace face */ \
- char *atari_face_serif; /* serif face */ \
- char *atari_face_serif_bold; /* bold serif face */ \
- char *atari_face_cursive; \
- char *atari_face_fantasy; \
- char *atari_editor; \
- char *downloads_path; \
- char *url_file; \
- char *hotlist_file; \
+ char *atari_face_monospace; /* monospace face */ \
+ char *atari_face_monospace_bold; /* monospace face */ \
+ char *atari_face_serif; /* serif face */ \
+ char *atari_face_serif_bold; /* bold serif face */ \
+ char *atari_face_cursive; \
+ char *atari_face_fantasy; \
+ char *atari_editor; \
+ char *downloads_path; \
+ char *url_file; \
+ char *hotlist_file; \
char *tree_icons_path
#define NSOPTION_EXTRA_DEFAULTS \
- .atari_screen_driver = (char*)"vdi", \
+ .atari_screen_driver = (char*)"vdi", \
.atari_font_driver = (char*)"vdi", \
- .atari_font_monochrom = 0, \
- .atari_dither = 1, \
+ .atari_font_monochrom = 0, \
+ .atari_dither = 1, \
.atari_transparency = 1, \
- .atari_face_sans_serif = NULL, \
- .atari_face_sans_serif_bold = NULL, \
- .atari_face_sans_serif_italic = NULL, \
- .atari_face_sans_serif_italic_bold = NULL, \
- .atari_face_monospace = NULL, \
- .atari_face_monospace_bold = NULL, \
+ .atari_image_toolbar = 0, \
+ .atari_face_sans_serif = NULL, \
+ .atari_face_sans_serif_bold = NULL, \
+ .atari_face_sans_serif_italic = NULL, \
+ .atari_face_sans_serif_italic_bold = NULL, \
+ .atari_face_monospace = NULL, \
+ .atari_face_monospace_bold = NULL, \
.atari_face_serif = NULL, \
- .atari_face_serif_bold = NULL, \
+ .atari_face_serif_bold = NULL, \
.atari_face_cursive = NULL, \
.atari_face_fantasy = NULL, \
.atari_editor = (char*)"", \
- .downloads_path = (char*)"", \
- .url_file = (char*)"url.db", \
- .hotlist_file = (char*)"hotlist", \
+ .downloads_path = (char*)"", \
+ .url_file = (char*)"url.db", \
+ .hotlist_file = (char*)"hotlist", \
.tree_icons_path = (char*)"./res/icons"
#define NSOPTION_EXTRA_TABLE \
{ "atari_screen_driver", OPTION_STRING, &nsoptions.atari_screen_driver },\
{ "atari_font_driver", OPTION_STRING, &nsoptions.atari_font_driver },\
{ "atari_font_monochrom", OPTION_INTEGER, &nsoptions.atari_font_monochrom },\
+ { "atari_image_toolbar", OPTION_INTEGER, &nsoptions.atari_image_toolbar },\
{ "atari_transparency", OPTION_INTEGER, &nsoptions.atari_transparency },\
{ "atari_dither", OPTION_INTEGER, &nsoptions.atari_dither },\
{ "atari_editor", OPTION_STRING, &nsoptions.atari_editor },\
Modified: trunk/netsurf/atari/toolbar.c
URL: http://source.netsurf-browser.org/trunk/netsurf/atari/toolbar.c?rev=13848...
==============================================================================
--- trunk/netsurf/atari/toolbar.c (original)
+++ trunk/netsurf/atari/toolbar.c Tue Apr 10 18:12:13 2012
@@ -35,7 +35,8 @@
#include "desktop/browser.h"
#include "desktop/mouse.h"
#include "desktop/plot_style.h"
-#include "desktop/plotters.h"
+#include "desktop/plotters.h"
+#include "desktop/tree.h"
#include "atari/clipboard.h"
#include "atari/gui.h"
#include "atari/toolbar.h"
@@ -54,65 +55,126 @@
extern short vdih;
extern void * h_gem_rsrc;
extern GEM_PLOTTER plotter;
-static OBJECT * throbber_form = NULL;
-
-static const plot_font_style_t font_style_url = {
+static OBJECT * throbber_form = NULL;
+static bool img_toolbar = false;
+
+
+static plot_font_style_t font_style_url = {
.family = PLOT_FONT_FAMILY_SANS_SERIF,
- .size = TOOLBAR_URL_TEXT_SIZE_PT*FONT_SIZE_SCALE,
+ .size = 14*FONT_SIZE_SCALE,
.weight = 400,
.flags = FONTF_NONE,
.background = 0xffffff,
.foreground = 0x0
- };
-
-/* prototypes & order for button widgets: */
+ };
+
+/* prototypes & order for button widgets: */
+
static struct s_tb_button tb_buttons[] =
{
- { TOOLBAR_BT_BACK, tb_back_click, NULL },
- { TOOLBAR_BT_HOME, tb_home_click, NULL },
- { TOOLBAR_BT_FORWARD, tb_forward_click, NULL },
- { TOOLBAR_BT_RELOAD, tb_reload_click, NULL },
- { TOOLBAR_BT_STOP, tb_stop_click, NULL },
- { 0, NULL, NULL }
+ { TOOLBAR_BT_BACK, tb_back_click, "back.png", 0, 0, 0, 0, 0 },
+ { TOOLBAR_BT_HOME, tb_home_click, "home.png", 0, 0, 0, 0, 0 },
+ { TOOLBAR_BT_FORWARD, tb_forward_click, "forward.png", 0, 0, 0, 0, 0 },
+ { TOOLBAR_BT_RELOAD, tb_reload_click, "reload.png", 0, 0, 0, 0, 0 },
+ { TOOLBAR_BT_STOP, tb_stop_click, "stop.png", 0, 0, 0, 0, 0 },
+ { 0, 0, 0, 0, 0, 0, 0, -1 }
+};
+
+struct s_toolbar_style {
+ int font_height_pt;
+ int height;
+ int button_width;
+ int button_margin;
+ short bgcolor;
+};
+
+static struct s_toolbar_style toolbar_styles[] =
+{
+ /* small (18 px height) */
+ { 9, 18, 16, 0, LWHITE},
+ /* medium (default - 26 px height) */
+ {14, 26, 24, 1, LWHITE},
+ /* large ( 49 px height ) */
+ {18, 34, 64, 2, LWHITE}
};
-static void tb_txt_request_redraw(void *data, int x, int y, int w, int h);
-
-static void __CDECL button_redraw( COMPONENT *c, long buff[8])
-{
- OBJECT *tree = (OBJECT*)mt_CompDataSearch( &app, c, CDT_OBJECT );
- struct gui_window * gw = mt_CompDataSearch( &app, c, CDT_OWNER );
+static void tb_txt_request_redraw(void *data, int x, int y, int w, int h);
+
+void toolbar_init( void )
+{
+ img_toolbar = (nsoption_int( atari_image_toolbar ) > 0 ) ? true : false;
+}
+
+/**
+ * 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)
+{
+ if ( event->type != CONTENT_MSG_READY ){
+ return( NSERROR_OK );
+ }
+ struct s_tb_button * bt = (struct s_tb_button *)pw;
+ struct gui_window * gw = (struct gui_window *)bt->gw;
+ mt_CompEvntRedraw( &app, bt->comp );
+ return NSERROR_OK;
+}
+
+
+static void __CDECL button_redraw( COMPONENT *c, long buff[8], void * data )
+{
+
+ OBJECT *tree;
LGRECT work,clip;
- GRECT todo,crect;
- short pxy[4];
-
- mt_CompGetLGrect(&app, c, WF_WORKXYWH, &work);
+ 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, bmpy, bmpw, bmph;
+ struct bitmap * icon;
+ bool draw_bitmap = false;
+
+ 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;
- }
- /* clip contains intersecting part: */
- pxy[0] = clip.g_x;
- pxy[1] = clip.g_y;
- pxy[2] = clip.g_w + clip.g_x;
- pxy[3] = clip.g_h + clip.g_y;
-
- vs_clip( vdih, 1, (short*)&pxy );
-
- tree->ob_x = work.g_x+1;
- tree->ob_y = work.g_y+2;
- tree->ob_width = work.g_w;
- tree->ob_height = work.g_h;
+ }
+
+ if( img_toolbar ){
+ if( bt->icon != NULL && bt->iconfile != NULL ){
+ draw_bitmap = true;
+ }
+ }
+
+ if( draw_bitmap == false ){
+ /* Place the CICON into workarea: */
+ tree = bt->aes_object;
+ if( tree == NULL )
+ return;
+ tree->ob_x = work.g_x;
+ tree->ob_y = work.g_y + (work.g_h - tree->ob_height) / 2;
+ } else {
+ icon = content_get_bitmap(bt->icon);
+ /* Check if icon content is available: */
+ /* ( It may isn't loaded yet ) */
+ if( icon == NULL )
+ return;
+ bmpw = bitmap_get_width(icon);
+ bmph = toolbar_styles[tb->style].height - (toolbar_styles[tb->style].button_margin*2);
+ bmpx = toolbar_styles[tb->style].button_margin;
+ bmpy = toolbar_styles[tb->style].button_margin;
+ }
+
+ /* Setup draw mode: */
vsf_interior( vdih , 1 );
- vsf_color( vdih, LWHITE );
- pxy[0] = (short)buff[4];
- pxy[1] = (short)buff[5];
- pxy[2] = (short)buff[4] + buff[6];
- pxy[3] = MIN( (short)buff[5] + buff[7], work.g_y + work.g_h - 2);
- vswr_mode( vdih, MD_REPLACE);
- v_bar( vdih, (short*)&pxy );
-
+ vsf_color( vdih, toolbar_styles[tb->style].bgcolor );
+ vswr_mode( vdih, 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;
@@ -123,46 +185,49 @@
&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) ){
- objc_draw( tree, 0, 0, todo.g_x, todo.g_y, todo.g_w, todo.g_h );
+ if( rc_intersect( &crect, &todo ) ){
+ 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( vdih, 1, (short*)&pxy );
+ v_bar( vdih, (short*)&pxy );
+ if( draw_bitmap ){
+ plotter->resize( plotter, work.g_w+1, work.g_h+1 );
+ plotter->move( plotter, work.g_x, work.g_y );
+ atari_plotters.bitmap( bmpx, bmpy, bmpw, bmph, icon,
+ 0, BITMAPF_BUFFER_NATIVE );
+ } else {
+ objc_draw( tree, 0, 0, todo.g_x, todo.g_y, todo.g_w, todo.g_h );
+ }
+ vs_clip( vdih, 0, (short*)&clip );
}
wind_get(gw->root->handle->handle, WF_NEXTXYWH,
&todo.g_x, &todo.g_y, &todo.g_w, &todo.g_h );
}
-
- if( gw->root->toolbar->buttons[0].comp == c && work.g_x == buff[4] ){
- vsl_color( vdih, LWHITE );
- pxy[0] = (short)buff[4];
- pxy[1] = (short)buff[5];
- pxy[2] = (short)buff[4];
- pxy[3] = (short)buff[5] + buff[7];
- v_pline( vdih, 2, (short*) pxy );
- }
- vs_clip( vdih, 0, (short*)&clip );
-}
-
-static void __CDECL button_enable( COMPONENT *c, long buff[8])
-{
- ((OBJECT*)mt_CompDataSearch(&app, c, CDT_OBJECT))->ob_state &= ~OS_DISABLED;
-}
-
-static void __CDECL button_disable( COMPONENT *c, long buff[8])
-{
- ((OBJECT*)mt_CompDataSearch(&app, c, CDT_OBJECT))->ob_state |= OS_DISABLED;
-}
-
-static void __CDECL button_click( COMPONENT *c, long buff[8])
-{
+}
+
+static void __CDECL button_enable( COMPONENT *c, long buff[8], void * data )
+{
+ printf("enb...");
+ struct s_tb_button * bt = (struct s_tb_button *)data;
+ bt->aes_object->ob_state &= ~OS_DISABLED;
+}
+
+static void __CDECL button_disable( COMPONENT *c, long buff[8], void * data )
+{
+ printf("dis...");
+ struct s_tb_button * bt = (struct s_tb_button *)data;
+ bt->aes_object->ob_state |= OS_DISABLED;
+}
+
+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 = (struct gui_window *)mt_CompDataSearch(&app, c, CDT_OWNER);
+ struct gui_window * gw = bt->gw;
assert( gw );
- while( i < gw->root->toolbar->btcnt ) {
- if(c == gw->root->toolbar->buttons[i].comp ) {
- gw->root->toolbar->buttons[i].cb_click( gw );
- break;
- }
- i++;
- }
+ gw->root->toolbar->buttons[i].cb_click( gw );
}
static struct s_tb_button * find_button( struct gui_window * gw, int rsc_id )
@@ -177,17 +242,41 @@
}
-static COMPONENT *button_create( OBJECT *o, short type, long size, short flex )
-{
- COMPONENT *c = mt_CompCreate( &app, type, size, flex );
- OBJECT *oc = mt_ObjcNDup( &app, o, NULL, 1);
- oc->ob_next = oc->ob_head = oc->ob_tail = -1;
- mt_CompDataAttach( &app, c, CDT_OBJECT, oc );
- mt_CompEvntAttach( &app, c, WM_REDRAW, button_redraw );
- mt_CompEvntAttach( &app, c, WM_XBUTTON, button_click );
- mt_CompEvntAttach( &app, c, CM_GETFOCUS, button_enable );
- mt_CompEvntAttach( &app, c, CM_LOSEFOCUS, button_disable );
- return c;
+static COMPONENT *button_init( CMP_TOOLBAR t, OBJECT * tree, int index,
+ struct s_tb_button * instance )
+{
+ instance->index = index;
+ instance->gw = t->owner;
+ instance->rsc_id = tb_buttons[index].rsc_id;
+ instance->cb_click = tb_buttons[index].cb_click;
+
+ instance->comp = mt_CompCreate( &app, CLT_VERTICAL, TB_BUTTON_WIDTH, 0 );
+
+ assert( instance->comp );
+
+ if( img_toolbar == false ){
+ OBJECT *oc = mt_ObjcNDup( &app, &tree[instance->rsc_id], NULL, 1);
+ oc->ob_next = oc->ob_head = oc->ob_tail = -1;
+ instance->aes_object = oc;
+ } else {
+ if( (tb_buttons[index].iconfile != NULL) ){
+ /* Fixme: use one a single icon instance! */
+ instance->iconfile = tb_buttons[index].iconfile;
+ instance->icon = load_icon( instance->iconfile,
+ toolbar_icon_callback, instance );
+ }
+ instance->comp->bounds.max_width = TB_BUTTON_WIDTH;
+ }
+
+ mt_CompEvntDataAttach( &app, instance->comp, WM_REDRAW, button_redraw,
+ instance );
+ mt_CompEvntDataAttach( &app, instance->comp, WM_XBUTTON, button_click,
+ instance );
+ mt_CompEvntDataAttach( &app, instance->comp, CM_GETFOCUS, button_enable,
+ instance );
+ mt_CompEvntDataAttach( &app, instance->comp, CM_LOSEFOCUS, button_disable,
+ instance );
+ return instance->comp;
}
@@ -346,9 +435,9 @@
// TODO: do not send an complete redraw!
ApplWrite( _AESapid, WM_REDRAW, gw->root->handle->handle,
work.g_x, work.g_y, work.g_w, work.g_h );
-
-}
-
+}
+
+
void tb_adjust_size( struct gui_window * gw )
{
LGRECT work;
@@ -391,7 +480,8 @@
return;
CMP_TOOLBAR t = data;
if( t->url.redraw == false ){
- t->url.redraw = true;
+ t->url.redraw = true;
+ //t->redraw = true;
t->url.rdw_area.g_x = x;
t->url.rdw_area.g_y = y;
t->url.rdw_area.g_w = w;
@@ -492,51 +582,57 @@
CMP_TOOLBAR tb_create( struct gui_window * gw )
{
int i;
- OBJECT * tbut;
+ OBJECT * tbut = NULL;
CMP_TOOLBAR t = malloc( sizeof(struct s_toolbar) );
if( t == NULL )
return( NULL );
- t->owner = gw;
+ t->owner = gw;
+ t->style = 1;
/* create the root component: */
- t->comp = (COMPONENT*)mt_CompCreate(&app, CLT_HORIZONTAL, TOOLBAR_HEIGHT, 0);
- t->comp->rect.g_h = TOOLBAR_HEIGHT;
- t->comp->bounds.max_height = TOOLBAR_HEIGHT;
- mt_CompEvntDataAdd(&app, t->comp, WM_REDRAW, evnt_toolbar_redraw, NULL, EV_BOT);
+ 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,
+ NULL, EV_BOT);
+
+ if( img_toolbar == false ){
+ RsrcGaddr( h_gem_rsrc, R_TREE, TOOLBAR, &tbut );
+ }
/* count buttons and add them as components: */
- RsrcGaddr( h_gem_rsrc, R_TREE, TOOLBAR , &tbut );
- t->btdim.g_x = 0;
- t->btdim.g_y = 1;
- t->btdim.g_w = 0;
- t->btdim.g_h = TB_BUTTON_HEIGHT+1;
i = 0;
while( tb_buttons[i].rsc_id > 0 ) {
i++;
}
t->btcnt = i;
- t->buttons = malloc( sizeof(struct s_tb_button) * t->btcnt );
+ 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++ ) {
- t->buttons[i].rsc_id = tb_buttons[i].rsc_id;
- t->buttons[i].cb_click = tb_buttons[i].cb_click;
- t->buttons[i].comp = button_create( &tbut[t->buttons[i].rsc_id] , CLT_VERTICAL, TB_BUTTON_WIDTH+1, 0);
- mt_CompDataAttach( &app, t->buttons[i].comp, CDT_OWNER, gw );
- t->buttons[i].comp->bounds.max_width = TB_BUTTON_WIDTH+1;
+ button_init( t, tbut, i, &t->buttons[i] );
mt_CompAttach( &app, t->comp, t->buttons[i].comp );
- t->btdim.g_w += TB_BUTTON_WIDTH+1;
- }
-
- /* create the url widget: */
- t->url.textarea = textarea_create( 300, TOOLBAR_TEXTAREA_HEIGHT, 0,
+ }
+
+ /* create the url widget: */
+ font_style_url.size =
+ toolbar_styles[t->style].font_height_pt * FONT_SIZE_SCALE;
+
+ int ta_height = toolbar_styles[t->style].height;
+ ta_height -= (TOOLBAR_URL_MARGIN_TOP + TOOLBAR_URL_MARGIN_BOTTOM);
+ t->url.textarea = textarea_create( 300,
+ ta_height,
+ 0,
&font_style_url, tb_txt_request_redraw,
t );
if( t->url.textarea != NULL ){
textarea_set_text(t->url.textarea, "http://");
}
- t->url.comp = (COMPONENT*)mt_CompCreate(&app, CLT_HORIZONTAL, TOOLBAR_HEIGHT, 1);
+ t->url.comp = (COMPONENT*)mt_CompCreate(&app, CLT_HORIZONTAL,
+ toolbar_styles[t->style].height, 1);
mt_CompEvntAttach( &app, t->url.comp, WM_REDRAW, evnt_url_redraw );
mt_CompEvntAttach( &app, t->url.comp, WM_XBUTTON, evnt_url_click );
mt_CompDataAttach( &app, t->url.comp, CDT_OWNER, gw );
@@ -548,10 +644,11 @@
throbber_form->ob_x = 0;
throbber_form->ob_y = 0;
}
- t->throbber.comp = (COMPONENT*)mt_CompCreate(&app, CLT_HORIZONTAL, TOOLBAR_HEIGHT, 0);
- t->throbber.comp->rect.g_h = TOOLBAR_HEIGHT;
+ 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 = 32;
- t->throbber.comp->bounds.max_height = TOOLBAR_HEIGHT;
+ t->throbber.comp->bounds.max_height = toolbar_styles[t->style].height;
t->throbber.comp->bounds.max_width = 32;
t->throbber.index = THROBBER_MIN_INDEX;
t->throbber.max_index = THROBBER_MAX_INDEX;
@@ -559,16 +656,17 @@
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 );
-
return( t );
}
void tb_destroy( CMP_TOOLBAR tb )
{
- int i=0;
- while( i < tb->btcnt ) {
- mt_ObjcFree( &app, (OBJECT*)mt_CompDataSearch(&app, tb->buttons[i].comp, CDT_OBJECT) );
+ int i=0;
+ while( i < tb->btcnt ) {
+ if( tb->buttons[i].aes_object ){
+ mt_ObjcFree( &app, tb->buttons[i].aes_object );
+ }
i++;
}
free( tb->buttons );
@@ -594,42 +692,81 @@
}
-void tb_update_buttons( struct gui_window * gw )
-{
+void tb_update_buttons( struct gui_window * gw, short button )
+{
+
+#define FIRST_BUTTON TOOLBAR_BT_BACK
+
struct s_tb_button * bt;
- return; /* not working correctly, buttons disabled, even if it shouldn't */
-
- bt = find_button( gw, TOOLBAR_BT_BACK );
- if( browser_window_back_available(gw->browser->bw) ) {
- ((OBJECT*)mt_CompDataSearch(&app, bt->comp, CDT_OBJECT))->ob_state |= OS_DISABLED;
- } else {
- ((OBJECT*)mt_CompDataSearch(&app, bt->comp, CDT_OBJECT))->ob_state &= ~OS_DISABLED;
- }
- mt_CompEvntRedraw( &app, bt->comp );
-
- bt = find_button( gw, TOOLBAR_BT_FORWARD );
- if( browser_window_forward_available(gw->browser->bw) ) {
- ((OBJECT*)mt_CompDataSearch(&app, bt->comp, CDT_OBJECT))->ob_state |= OS_DISABLED;
- } else {
- ((OBJECT*)mt_CompDataSearch(&app, bt->comp, CDT_OBJECT))->ob_state &= ~OS_DISABLED;
- }
- mt_CompEvntRedraw( &app, bt->comp );
-
- bt = find_button( gw, TOOLBAR_BT_RELOAD );
- if( browser_window_reload_available(gw->browser->bw) ) {
- ((OBJECT*)mt_CompDataSearch(&app, bt->comp, CDT_OBJECT))->ob_state |= OS_DISABLED;
- } else {
- ((OBJECT*)mt_CompDataSearch(&app, bt->comp, CDT_OBJECT))->ob_state &= ~OS_DISABLED;
- }
- mt_CompEvntRedraw( &app, bt->comp );
-
- bt = find_button( gw, TOOLBAR_BT_STOP );
- if( browser_window_stop_available(gw->browser->bw) ) {
- ((OBJECT*)mt_CompDataSearch(&app, bt->comp, CDT_OBJECT))->ob_state |= OS_DISABLED;
- } else {
- ((OBJECT*)mt_CompDataSearch(&app, bt->comp, CDT_OBJECT))->ob_state &= ~OS_DISABLED;
- }
- mt_CompEvntRedraw( &app, bt->comp );
+ bool enable = false;
+ return;
+ 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( bt->aes_object ){
+ if( enable ) {
+ bt->aes_object->ob_state |= OS_DISABLED;
+ } else {
+ bt->aes_object->ob_state &= ~OS_DISABLED;
+ }
+ mt_CompEvntRedraw( &app, bt->comp );
+ } else {
+ // TODOs
+ }
+
+ }
+
+ 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_FORWARD || button <= 0 ){
+ bt = &gw->root->toolbar->buttons[TOOLBAR_BT_FORWARD-FIRST_BUTTON];
+ enable = browser_window_forward_available(gw->browser->bw);
+ if( bt->aes_object ){
+ if( enable ) {
+ bt->aes_object->ob_state |= OS_DISABLED;
+ } else {
+ bt->aes_object->ob_state &= ~OS_DISABLED;
+ }
+ mt_CompEvntRedraw( &app, bt->comp );
+ } else {
+ // TODOs
+ }
+ }
+
+ 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( bt->aes_object ){
+ if( enable ) {
+ bt->aes_object->ob_state |= OS_DISABLED;
+ } else {
+ bt->aes_object->ob_state &= ~OS_DISABLED;
+ }
+ mt_CompEvntRedraw( &app, bt->comp );
+ } else {
+ // TODOs
+ }
+ }
+
+ 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( bt->aes_object ){
+ if( enable ) {
+ bt->aes_object->ob_state |= OS_DISABLED;
+ } else {
+ bt->aes_object->ob_state &= ~OS_DISABLED;
+ }
+ mt_CompEvntRedraw( &app, bt->comp );
+ } else {
+ // TODOs
+ }
+ }
+
+#undef FIRST_BUTON
}
@@ -724,7 +861,7 @@
if( history_back_available(bw->history) )
history_back(bw, bw->history);
- tb_update_buttons(gw);
+ tb_update_buttons(gw, TOOLBAR_BT_BACK );
}
void tb_reload_click( struct gui_window * gw )
@@ -739,13 +876,13 @@
if (history_forward_available(bw->history))
history_forward(bw, bw->history);
- tb_update_buttons(gw);
+ tb_update_buttons(gw, TOOLBAR_BT_FORWARD );
}
void tb_home_click( struct gui_window * gw )
{
browser_window_go(gw->browser->bw, cfg_homepage_url, 0, true);
- tb_update_buttons(gw);
+ tb_update_buttons(gw, TOOLBAR_BT_HOME );
}
@@ -766,8 +903,8 @@
} else {
tb->hidden = false;
- tb->comp->rect.g_h = TOOLBAR_HEIGHT;
- tb->comp->bounds.max_height = TOOLBAR_HEIGHT;
+ 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 );
Modified: trunk/netsurf/atari/toolbar.h
URL: http://source.netsurf-browser.org/trunk/netsurf/atari/toolbar.h?rev=13848...
==============================================================================
--- trunk/netsurf/atari/toolbar.h (original)
+++ trunk/netsurf/atari/toolbar.h Tue Apr 10 18:12:13 2012
@@ -21,28 +21,30 @@
#include "desktop/textarea.h"
#include "desktop/textinput.h"
+#include "content/hlcache.h"
#include "atari/browser.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
-#define TOOLBAR_URL_TEXT_SIZE_PT 14
-#define TOOLBAR_TEXTAREA_HEIGHT 19
#define TOOLBAR_URL_MARGIN_LEFT 2
#define TOOLBAR_URL_MARGIN_RIGHT 2
#define TOOLBAR_URL_MARGIN_TOP 2
-#define TOOLBAR_URL_MARGIN_BOTTOM 2
+#define TOOLBAR_URL_MARGIN_BOTTOM 2
+
struct s_tb_button
{
short rsc_id;
void (*cb_click)(struct gui_window * gw);
- COMPONENT * comp;
+ const char * iconfile;
+ COMPONENT * comp;
+ OBJECT * aes_object;
+ hlcache_handle * icon;
+ struct gui_window * gw;
+ short index;
};
@@ -72,10 +74,15 @@
/* size & location of buttons: */
struct s_tb_button * buttons;
bool hidden;
- int btcnt;
+ int btcnt;
+ int style;
+ bool redraw;
};
-/* interface to the toolbar */
+/* interface to the toolbar */
+
+/* Must be called before any other toolbar function is called: */
+void toolbar_init( void );
CMP_TOOLBAR tb_create( struct gui_window * gw );
void tb_destroy( CMP_TOOLBAR tb );
/* recalculate size/position of nested controls within the toolbar: */
@@ -88,7 +95,7 @@
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 );
+void tb_update_buttons( struct gui_window * gw, short buttonid );
/* 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:*/
11 years, 7 months
r13847 mono - in /trunk/netsurf/atari: misc.c misc.h
by netsurf@semichrome.net
Author: mono
Date: Tue Apr 10 18:10:49 2012
New Revision: 13847
URL: http://source.netsurf-browser.org?rev=13847&view=rev
Log:
Added function load_icon
Modified:
trunk/netsurf/atari/misc.c
trunk/netsurf/atari/misc.h
Modified: trunk/netsurf/atari/misc.c
URL: http://source.netsurf-browser.org/trunk/netsurf/atari/misc.c?rev=13847&r1...
==============================================================================
--- trunk/netsurf/atari/misc.c (original)
+++ trunk/netsurf/atari/misc.c Tue Apr 10 18:10:49 2012
@@ -15,17 +15,23 @@
* 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 <assert.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <stdbool.h>
+#include <string.h>
#include <sys/types.h>
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
#include <mint/osbind.h>
-#include <windom.h>
-
+#include <windom.h>
+
+#include "content/content.h"
+#include "content/hlcache.h"
#include "desktop/cookies.h"
#include "desktop/mouse.h"
-#include "desktop/cookies.h"
+#include "desktop/cookies.h"
+#include "desktop/tree.h"
+#include "desktop/options.h"
#include "utils/messages.h"
#include "utils/utils.h"
#include "utils/url.h"
@@ -164,6 +170,94 @@
OBJECT *tree;
RsrcGaddr( h_gem_rsrc, R_TREE, idx, &tree);
return tree;
+}
+
+
+
+/**
+ * Callback for load_icon(). Should be removed once bitmaps get loaded directly
+ * from disc
+ */
+static nserror load_icon_callback(hlcache_handle *handle,
+ const hlcache_event *event, void *pw)
+{
+ return NSERROR_OK;
+}
+
+
+/**
+ * utility function. Placed here so that this code doesn't have to be
+ * copied by each user.
+ *
+ * \param name the name of the loaded icon, if it's not a full path the icon is
+ * looked for in the directory specified by icons_dir
+ * \return the icon in form of a content or NULL on failure
+ */
+hlcache_handle *load_icon(const char *name, hlcache_handle_callback cb,
+ void * pw )
+{
+ char *url = NULL;
+ const char *icon_url = NULL;
+ int len;
+ hlcache_handle *c;
+ nserror err;
+ nsurl *icon_nsurl;
+ char * icons_dir = nsoption_charp(tree_icons_path);
+
+ /** @todo something like bitmap_from_disc is needed here */
+
+ if (!strncmp(name, "file://", 7)) {
+ icon_url = name;
+ } else {
+ char *native_path;
+
+ if (icons_dir == NULL)
+ return NULL;
+
+ /* path + separator + leafname + '\0' */
+ len = strlen(icons_dir) + 1 + strlen(name) + 1;
+ native_path = malloc(len);
+ if (native_path == NULL) {
+ LOG(("malloc failed"));
+ warn_user("NoMemory", 0);
+ return NULL;
+ }
+
+ /* Build native path */
+ memcpy(native_path, icons_dir,
+ strlen(icons_dir) + 1);
+ path_add_part(native_path, len, name);
+
+ /* Convert native path to URL */
+ url = path_to_url(native_path);
+
+ free(native_path);
+ icon_url = url;
+ }
+
+ err = nsurl_create(icon_url, &icon_nsurl);
+ if (err != NSERROR_OK) {
+ if (url != NULL)
+ free(url);
+ return NULL;
+ }
+
+ /* Fetch the icon */
+ err = hlcache_handle_retrieve(icon_nsurl, 0, 0, 0,
+ ((cb != NULL) ? cb : load_icon_callback), pw, 0,
+ CONTENT_IMAGE, &c);
+
+ nsurl_unref(icon_nsurl);
+
+ /* If we built the URL here, free it */
+ if (url != NULL)
+ free(url);
+
+ if (err != NSERROR_OK) {
+ return NULL;
+ }
+
+ return c;
}
void gem_set_cursor( MFORM_EX * cursor )
Modified: trunk/netsurf/atari/misc.h
URL: http://source.netsurf-browser.org/trunk/netsurf/atari/misc.h?rev=13847&r1...
==============================================================================
--- trunk/netsurf/atari/misc.h (original)
+++ trunk/netsurf/atari/misc.h Tue Apr 10 18:10:49 2012
@@ -20,6 +20,8 @@
#define NS_ATARI_MISC_H
#include "cflib.h"
+#include "content/content.h"
+#include "content/hlcache.h"
#include "desktop/textinput.h"
#include "atari/gui.h"
@@ -42,13 +44,16 @@
struct gui_window * find_cmp_window( COMPONENT * c );
OBJECT *get_tree( int idx );
char *get_rsc_string( int idx );
-void gem_set_cursor( MFORM_EX * cursor );
+void gem_set_cursor( MFORM_EX * cursor );
+hlcache_handle *load_icon( const char *name, hlcache_handle_callback cb,
+ void * pw );
void dbg_grect( char * str, GRECT * r );
void dbg_lgrect( char * str, LGRECT * r );
void dbg_pxy( char * str, short * pxy );
void * ldg_open( char * name, short * global );
void * ldg_find( char * name, short * ldg );
+const char * file_select( const char * title, const char * name );
int ldg_close( void * ldg, short * global );
long nkc_to_input_key(short nkc, long * ucs4_out);
-const char * file_select( const char * title, const char * name );
+
#endif
11 years, 7 months
r13846 mono - in /trunk/netsurf/atari: bitmap.c bitmap.h
by netsurf@semichrome.net
Author: mono
Date: Tue Apr 10 18:07:10 2012
New Revision: 13846
URL: http://source.netsurf-browser.org?rev=13846&view=rev
Log:
Introduced BITMAPF_BUFFER_NATIVE and native image buffer, for fast redraw of bitmaps.
Modified:
trunk/netsurf/atari/bitmap.c
trunk/netsurf/atari/bitmap.h
Modified: trunk/netsurf/atari/bitmap.c
URL: http://source.netsurf-browser.org/trunk/netsurf/atari/bitmap.c?rev=13846&...
==============================================================================
--- trunk/netsurf/atari/bitmap.c (original)
+++ trunk/netsurf/atari/bitmap.c Tue Apr 10 18:07:10 2012
@@ -240,6 +240,8 @@
if( bm->resized != NULL ) {
bitmap_destroy(bm->resized);
}
+ if( bm->native.fd_addr )
+ free( bm->native.fd_addr );
free(bm->pixdata);
free(bm);
}
Modified: trunk/netsurf/atari/bitmap.h
URL: http://source.netsurf-browser.org/trunk/netsurf/atari/bitmap.h?rev=13846&...
==============================================================================
--- trunk/netsurf/atari/bitmap.h (original)
+++ trunk/netsurf/atari/bitmap.h Tue Apr 10 18:07:10 2012
@@ -19,10 +19,9 @@
#ifndef NS_ATARI_BITMAP_H
#define NS_ATARI_BITMAP_H
-#define BITMAP_SHRINK 0
-#define BITMAP_GROW 0x1024
-#define BITMAP_MONOGLYPH 0x2048
-#define BITMAP_CLEAR 0x4096
+#define BITMAP_SHRINK 0
+#define BITMAP_GROW 1024 /* Don't realloc when bitmap size shrinks */
+#define BITMAP_CLEAR 2048 /* Zero bitmap memory */
struct bitmap {
int width;
@@ -32,6 +31,7 @@
short bpp; /* number of BYTES! per pixel */
size_t rowstride;
struct bitmap * resized;
+ MFDB native;
};
#define NS_BMP_DEFAULT_BPP 4
11 years, 7 months
r13845 mono - in /trunk/netsurf/atari/plot: font_internal.c plotter.h plotter_vdi.c
by netsurf@semichrome.net
Author: mono
Date: Tue Apr 10 18:06:21 2012
New Revision: 13845
URL: http://source.netsurf-browser.org?rev=13845&view=rev
Log:
Introduced BITMAPF_BUFFER_NATIVE, for fast redraw of bitmaps.
Modified:
trunk/netsurf/atari/plot/font_internal.c
trunk/netsurf/atari/plot/plotter.h
trunk/netsurf/atari/plot/plotter_vdi.c
Modified: trunk/netsurf/atari/plot/font_internal.c
URL: http://source.netsurf-browser.org/trunk/netsurf/atari/plot/font_internal....
==============================================================================
--- trunk/netsurf/atari/plot/font_internal.c (original)
+++ trunk/netsurf/atari/plot/font_internal.c Tue Apr 10 18:06:21 2012
@@ -162,7 +162,7 @@
pixmask = (pixmask << 1);
}
}
- self->plotter->bitmap( self->plotter, fontbmp, loc.g_x, loc.g_y, 0, BITMAP_MONOGLYPH );
+ self->plotter->bitmap( self->plotter, fontbmp, loc.g_x, loc.g_y, 0, BITMAPF_MONOGLYPH );
}
static int text( FONT_PLOTTER self, int x, int y, const char *text, size_t length,
Modified: trunk/netsurf/atari/plot/plotter.h
URL: http://source.netsurf-browser.org/trunk/netsurf/atari/plot/plotter.h?rev=...
==============================================================================
--- trunk/netsurf/atari/plot/plotter.h (original)
+++ trunk/netsurf/atari/plot/plotter.h Tue Apr 10 18:06:21 2012
@@ -69,8 +69,12 @@
/* Flags for init_mfdb function: */
#define MFDB_FLAG_STAND 0x01
#define MFDB_FLAG_ZEROMEM 0x02
-#define MFDB_FLAG_NOALLOC 0x04
-
+#define MFDB_FLAG_NOALLOC 0x04
+
+/* Flags for blit functions: */
+#define BITMAPF_MONOGLYPH 4096 /* The bitmap is an character bitmap */
+#define BITMAPF_BUFFER_NATIVE 8192 /* Bitmap shall be kept converted */
+
/* Error codes: */
#define ERR_BUFFERSIZE_EXCEEDS_SCREEN 1 /* The buffer allocated is larger than the screen */
#define ERR_NO_MEM 2 /* Not enough memory for requested operation */
@@ -166,7 +170,8 @@
typedef int (*_pmf_bitmap)(GEM_PLOTTER self, struct bitmap * bmp, int x, int y,
unsigned long bg, unsigned long flags );
typedef int (*_pmf_plot_mfdb)(GEM_PLOTTER self, GRECT * loc, MFDB * mfdb, unsigned char fgcolor, uint32_t flags);
-typedef int (*_pmf_text)(GEM_PLOTTER self, int x, int y, const char *text, size_t length, const plot_font_style_t *fstyle);
+typedef int (*_pmf_text)(GEM_PLOTTER self, int x, int y, const char *text, size_t length, const plot_font_style_t *fstyle);
+typedef int (*_pmf_blit)(GEM_PLOTTER self, GRECT * region);
typedef int (*_pmf_dtor)(GEM_PLOTTER self);
@@ -207,7 +212,9 @@
/* plot an netsurf bitmap into the buffer / screen: */
_pmf_bitmap bitmap;
/* plot an mfdb into the buffer / screen: */
- _pmf_plot_mfdb plot_mfdb;
+ _pmf_plot_mfdb plot_mfdb;
+ /* draw to screen, only valid for offscreen plotters: */
+ _pmf_blit blit;
_pmf_text text;
_pmf_dtor dtor;
};
Modified: trunk/netsurf/atari/plot/plotter_vdi.c
URL: http://source.netsurf-browser.org/trunk/netsurf/atari/plot/plotter_vdi.c?...
==============================================================================
--- trunk/netsurf/atari/plot/plotter_vdi.c (original)
+++ trunk/netsurf/atari/plot/plotter_vdi.c Tue Apr 10 18:06:21 2012
@@ -433,9 +433,11 @@
{
if( w == VIEW(self).w && h == VIEW(self).h )
return( 1 );
+ struct rect newclip = { 0, 0, w-1, h-1 };
VIEW(self).w = w;
VIEW(self).h = h;
update_visible_rect( self );
+ set_clip( self, &newclip);
LOG(("%s: %s\n", (char*)__FILE__, (char*)__FUNCTION__));
return( 1 );
}
@@ -1002,6 +1004,9 @@
}
}
+
+#ifdef WITH_8BPP_SUPPORT
+
static inline void set_stdpx( MFDB * dst, int wdplanesz, int x, int y, unsigned char val )
{
short * buf;
@@ -1077,7 +1082,6 @@
return( ret );
}
-#ifdef WITH_8BPP_SUPPORT
static int bitmap_convert_8( GEM_PLOTTER self,
struct bitmap * img,
int x,
@@ -1094,7 +1098,7 @@
int bw;
struct bitmap * scrbuf = NULL;
struct bitmap * bm;
- bool transp = ( ( (img->opaque == false) || ( (flags & BITMAP_MONOGLYPH) != 0) )
+ bool transp = ( ( (img->opaque == false) || ( (flags & BITMAPF_MONOGLYPH) != 0) )
&& ((self->flags & PLOT_FLAG_TRANS) != 0) );
assert( clip->g_h > 0 );
@@ -1135,7 +1139,7 @@
// realloc mem for stdform
MFDB stdform;
if( transp ){
- if( ((self->flags & PLOT_FLAG_TRANS) != 0) || ( (flags & BITMAP_MONOGLYPH) != 0) ) {
+ if( ((self->flags & PLOT_FLAG_TRANS) != 0) || ( (flags & BITMAPF_MONOGLYPH) != 0) ) {
// point image to snapshot buffer, otherwise allocate mem
MFDB * bg = snapshot_create_std_mfdb( self, x+clip->g_x,y+clip->g_y, clip->g_w, clip->g_h );
stdform.fd_addr = bg->fd_addr;
@@ -1260,7 +1264,11 @@
}
#endif
-/* convert bitmap to the virutal (chunked) framebuffer format */
+/*
+*
+* Convert bitmap to the virutal (chunked) framebuffer format
+*
+*/
static int bitmap_convert( GEM_PLOTTER self,
struct bitmap * img,
int x,
@@ -1273,24 +1281,34 @@
int dststride; /* stride of dest. image */
int dstsize; /* size of dest. in byte */
int err;
- int bw;
+ int bw, bh;
struct bitmap * scrbuf = NULL;
- struct bitmap * bm;
+ struct bitmap * bm;
+ bool cache = ( flags & BITMAPF_BUFFER_NATIVE );
assert( clip->g_h > 0 );
- assert( clip->g_w > 0 );
-
+ assert( clip->g_w > 0 );
+
bm = img;
- bw = bitmap_get_width( img );
+ bw = bitmap_get_width( img );
+ bh = bitmap_get_height( img );
+
+ if( cache ){
+ assert( clip->g_w >= bw && clip->g_h >= bh );
+ if( img->native.fd_addr != NULL ){
+ *out = img->native;
+ return( 0 );
+ }
+ }
/* rem. if eddi xy is installed, we could directly access the screen! */
/* apply transparency to the image: */
- if( (img->opaque == false)
+ if( ( img->opaque == false )
&& ( (self->flags & PLOT_FLAG_TRANS) != 0)
&& (
(vdi_sysinfo.vdiformat == VDI_FORMAT_PACK )
||
- ( (flags & BITMAP_MONOGLYPH) != 0)
+ ( (flags & BITMAPF_MONOGLYPH) != 0)
) ) {
uint32_t * imgpixel;
uint32_t * screenpixel;
@@ -1320,28 +1338,38 @@
bm = scrbuf;
}
}
-
/* (re)allocate buffer for framebuffer image: */
dststride = MFDB_STRIDE( clip->g_w );
- dstsize = ( ((dststride >> 3) * clip->g_h) * self->bpp_virt);
- if( dstsize > DUMMY_PRIV(self)->size_buf_packed) {
- int blocks = (dstsize / (CONV_BLOCK_SIZE-1))+1;
- if( DUMMY_PRIV(self)->buf_packed == NULL )
- DUMMY_PRIV(self)->buf_packed =(void*)malloc( blocks * CONV_BLOCK_SIZE );
- else
- DUMMY_PRIV(self)->buf_packed =(void*)realloc(
- DUMMY_PRIV(self)->buf_packed,
- blocks * CONV_BLOCK_SIZE
- );
- assert( DUMMY_PRIV(self)->buf_packed );
- if( DUMMY_PRIV(self)->buf_packed == NULL ) {
+ dstsize = ( ((dststride >> 3) * clip->g_h) * self->bpp_virt);
+ if( cache == false ){
+ if( dstsize > DUMMY_PRIV(self)->size_buf_packed) {
+ int blocks = (dstsize / (CONV_BLOCK_SIZE-1))+1;
+ if( DUMMY_PRIV(self)->buf_packed == NULL )
+ DUMMY_PRIV(self)->buf_packed =(void*)malloc( blocks * CONV_BLOCK_SIZE );
+ else
+ DUMMY_PRIV(self)->buf_packed =(void*)realloc(
+ DUMMY_PRIV(self)->buf_packed,
+ blocks * CONV_BLOCK_SIZE
+ );
+ assert( DUMMY_PRIV(self)->buf_packed );
+ if( DUMMY_PRIV(self)->buf_packed == NULL ) {
+ if( scrbuf != NULL )
+ bitmap_destroy( scrbuf );
+ return( 0-ERR_NO_MEM );
+ }
+ DUMMY_PRIV(self)->size_buf_packed = blocks * CONV_BLOCK_SIZE;
+ }
+ out->fd_addr = DUMMY_PRIV(self)->buf_packed;
+ } else {
+ assert( out->fd_addr == NULL );
+ out->fd_addr = (void*)malloc( dstsize );
+ if( out->fd_addr == NULL ){
if( scrbuf != NULL )
- bitmap_destroy( scrbuf );
- return( 0-ERR_NO_MEM );
- }
- DUMMY_PRIV(self)->size_buf_packed = blocks * CONV_BLOCK_SIZE;
- }
- out->fd_addr = DUMMY_PRIV(self)->buf_packed;
+ bitmap_destroy( scrbuf );
+ return( 0-ERR_NO_MEM );
+ }
+ }
+
out->fd_w = dststride;
out->fd_h = clip->g_h;
out->fd_wdwidth = dststride >> 4;
@@ -1368,8 +1396,10 @@
clip->g_w, clip->g_h,
(dststride >> 3) * self->bpp_virt /* stride as bytes */
);
- assert( err != 0 );
-
+ assert( err != 0 );
+ if( cache == true ){
+ img->native = *out;
+ }
return( 0 );
}
@@ -1399,7 +1429,7 @@
off.g_x = x;
off.g_y = y;
off.g_h = bmp->height;
- off.g_w = bmp->width;
+ off.g_w = bmp->width;
clip.g_x = VIEW( self ).clipping.x0;
clip.g_y = VIEW( self ).clipping.y0;
@@ -1408,7 +1438,7 @@
if( !rc_intersect( &clip, &off) ) {
return( true );
- }
+ }
plotter_get_visible_grect( self, &vis );
if( !rc_intersect( &vis, &off) ) {
@@ -1419,7 +1449,7 @@
off.g_x = MAX(0, off.g_x - x);
off.g_y = MAX(0, off.g_y - y);
loc.g_x = MAX(0, loc.g_x);
- loc.g_y = MAX(0, loc.g_y);
+ loc.g_y = MAX(0, loc.g_y);
pxy[0] = 0;
pxy[1] = 0;
@@ -1431,6 +1461,7 @@
pxy[7] = VIEW(self).y + loc.g_y + off.g_h-1;
/* Convert the Bitmap to native screen format - ready for output*/
/* This includes blending transparent pixels */
+
if( self->bitmap_convert( self, bmp, pxy[4], pxy[5], &off, bg, flags, &src_mf) != 0 ) {
return( true );
}
11 years, 7 months
r13843 chris_y - /trunk/netsurf/amiga/font.c
by netsurf@semichrome.net
Author: chris_y
Date: Mon Apr 9 07:01:57 2012
New Revision: 13843
URL: http://source.netsurf-browser.org?rev=13843&view=rev
Log:
Just get glyph widths rather than the entire glyph when calculating sizes.
This should be faster but isn't (probably still rendering the glyph
internally)
Modified:
trunk/netsurf/amiga/font.c
Modified: trunk/netsurf/amiga/font.c
URL: http://source.netsurf-browser.org/trunk/netsurf/amiga/font.c?rev=13843&r1...
==============================================================================
--- trunk/netsurf/amiga/font.c (original)
+++ trunk/netsurf/amiga/font.c Mon Apr 9 07:01:57 2012
@@ -78,6 +78,8 @@
int32 ami_font_plot_glyph(struct OutlineFont *ofont, struct RastPort *rp,
uint16 char1, uint16 char2, uint32 x, uint32 y, uint32 emwidth);
+int32 ami_font_width_glyph(struct OutlineFont *ofont,
+ uint16 char1, uint16 char2, uint32 emwidth);
struct OutlineFont *ami_open_outline_font(const plot_font_style_t *fstyle,
BOOL fallback);
static void ami_font_cleanup(struct MinList *ami_font_list);
@@ -161,8 +163,7 @@
utf16next = utf16[utf16charlen];
- tempx = ami_font_plot_glyph(ofont, NULL, *utf16, utf16next,
- 0, 0, emwidth);
+ tempx = ami_font_width_glyph(ofont, *utf16, utf16next, emwidth);
if(tempx == 0)
{
@@ -173,14 +174,12 @@
if(ufont)
{
- tempx = ami_font_plot_glyph(ufont, NULL, *utf16, utf16next,
- 0, 0, emwidth);
+ tempx = ami_font_width_glyph(ufont, *utf16, utf16next, emwidth);
}
/*
if(tempx == 0)
{
- tempx = ami_font_plot_glyph(ofont, NULL, 0xfffd, utf16next,
- 0, 0, emwidth);
+ tempx = ami_font_width_glyph(ofont, NULL, 0xfffd, utf16next, emwidth);
}
*/
}
@@ -282,7 +281,7 @@
}
}
- tempx = ami_font_plot_glyph(ofont, NULL, *utf16, utf16next, 0, 0, emwidth);
+ tempx = ami_font_width_glyph(ofont, *utf16, utf16next, emwidth);
if(tempx == 0)
{
@@ -293,14 +292,12 @@
if(ufont)
{
- tempx = ami_font_plot_glyph(ufont, NULL, *utf16, utf16next,
- 0, 0, emwidth);
+ tempx = ami_font_width_glyph(ufont, *utf16, utf16next, emwidth);
}
/*
if(tempx == 0)
{
- tempx = ami_font_plot_glyph(ofont, NULL, 0xfffd, utf16next,
- 0, 0, emwidth);
+ tempx = ami_font_width_glyph(ofont, 0xfffd, utf16next, emwidth);
}
*/
}
@@ -562,6 +559,47 @@
EReleaseInfo(&ofont->olf_EEngine,
OT_GlyphMap8Bit,glyph,
TAG_END);
+ }
+ }
+
+ return char_advance;
+}
+
+int32 ami_font_width_glyph(struct OutlineFont *ofont,
+ uint16 char1, uint16 char2, uint32 emwidth)
+{
+ int32 char_advance = 0;
+ FIXED kern = 0;
+ struct MinList *gwlist;
+ FIXED char1w;
+ struct GlyphWidthEntry *gwnode;
+
+ if(ESetInfo(&ofont->olf_EEngine,
+ OT_GlyphCode, char1,
+ OT_GlyphCode2, char1,
+ TAG_END) == OTERR_Success)
+ {
+ if(EObtainInfo(&ofont->olf_EEngine,
+ OT_WidthList, &gwlist,
+ TAG_END) == 0)
+ {
+ gwnode = GetHead((struct MinList *)gwlist);
+ char1w = gwnode->gwe_Width;
+
+ kern = 0;
+
+ if(char2) {
+ if(ESetInfo(&ofont->olf_EEngine,
+ OT_GlyphCode, char1,
+ OT_GlyphCode2, char2,
+ TAG_END) == OTERR_Success)
+ {
+ EObtainInfo(&ofont->olf_EEngine,
+ OT_TextKernPair, &kern,
+ TAG_END);
+ }
+ }
+ char_advance = (ULONG)(((char1w - kern) * emwidth) / 65536);
}
}
11 years, 7 months
r13842 mono - in /trunk/netsurf/atari: global_evnt.c global_evnt.h
by netsurf@semichrome.net
Author: mono
Date: Mon Apr 9 06:44:09 2012
New Revision: 13842
URL: http://source.netsurf-browser.org?rev=13842&view=rev
Log:
Removed obsolete menu item struct member.
Modified:
trunk/netsurf/atari/global_evnt.c
trunk/netsurf/atari/global_evnt.h
Modified: trunk/netsurf/atari/global_evnt.c
URL: http://source.netsurf-browser.org/trunk/netsurf/atari/global_evnt.c?rev=1...
==============================================================================
--- trunk/netsurf/atari/global_evnt.c (original)
+++ trunk/netsurf/atari/global_evnt.c Mon Apr 9 06:44:09 2012
@@ -360,35 +360,35 @@
static struct s_menu_item_evnt menu_evnt_tbl[] =
{
- {T_ABOUT,MAINMENU_M_ABOUT, "About", menu_about, {0,0,0}, NULL },
- {T_FILE, MAINMENU_M_NEWWIN, "NewWindow", menu_new_win, {0,0,0}, NULL},
- {T_FILE, MAINMENU_M_OPENURL, "OpenURL", menu_open_url, {'G',0,K_CTRL}, NULL},
- {T_FILE, MAINMENU_M_OPENFILE, "OpenFile", menu_open_file, {'O',0,K_CTRL}, NULL},
- {T_FILE, MAINMENU_M_CLOSEWIN, "CloseWindow", menu_close_win, {0,0,0}, NULL},
- {T_FILE, MAINMENU_M_SAVEPAGE, "Save", menu_save_page, {0,NK_F3,0}, NULL},
- {T_FILE, MAINMENU_M_QUIT, "Quit", menu_quit, {'Q',0,K_CTRL}, NULL},
- {T_EDIT, MAINMENU_M_CUT, "Cut", menu_cut, {'X',0,K_CTRL}, NULL},
- {T_EDIT, MAINMENU_M_COPY, "Copy", menu_copy, {'C',0,K_CTRL}, NULL},
- {T_EDIT, MAINMENU_M_PASTE, "Paste", menu_paste, {'V',0,K_CTRL}, NULL},
- {T_EDIT, MAINMENU_M_FIND, "FindText", menu_find, {0,NK_F4,0}, NULL},
- {T_VIEW, MAINMENU_M_RELOAD, "Reload", menu_reload, {0,NK_F5,0}, NULL},
- {T_VIEW, MAINMENU_M_TOOLBARS, "Toolbars", menu_toolbars, {0,NK_F1,K_CTRL}, NULL},
- {T_VIEW, MAINMENU_M_SAVEWIN, "", menu_savewin, {0,0,0}, NULL},
- {T_VIEW, MAINMENU_M_DEBUG_RENDER, "", menu_debug_render, {0,0,0}, NULL},
- {T_VIEW, MAINMENU_M_FG_IMAGES, "", menu_fg_images, {0,0,0}, NULL},
- {T_VIEW, MAINMENU_M_BG_IMAGES, "", menu_bg_images, {0,0,0}, NULL},
- {T_VIEW, MAINMENU_M_STOP, "Stop", menu_stop, {0,NK_ESC,K_ALT}, NULL},
- {T_NAV, MAINMENU_M_BACK, "Back", menu_back, {0,NK_LEFT,K_ALT}, NULL},
- {T_NAV, MAINMENU_M_FORWARD, "Forward", menu_forward, {0,NK_RIGHT,K_ALT}, NULL},
- {T_NAV, MAINMENU_M_HOME, "Home", menu_home, {0,NK_CLRHOME,0}, NULL},
- {T_UTIL, MAINMENU_M_LHISTORY, "HistLocal", menu_lhistory, {0,NK_F7,0}, NULL},
- {T_UTIL, MAINMENU_M_GHISTORY, "HistGlobal", menu_ghistory, {0,NK_F7,K_CTRL}, NULL},
- {T_UTIL, MAINMENU_M_ADD_BOOKMARK, "HotlistAdd", menu_add_bookmark, {'D',0,K_CTRL}, NULL},
- {T_UTIL, MAINMENU_M_BOOKMARKS, "HotlistShow", menu_bookmarks, {0,NK_F6,0}, NULL},
- {T_UTIL, MAINMENU_M_CHOICES, "Choices", menu_choices, {0,0,0}, NULL},
- {T_UTIL, MAINMENU_M_VLOG, "Verbose Log", menu_vlog, {'V',0,K_ALT}, NULL},
- {T_HELP, MAINMENU_M_HELP_CONTENT, "Help", menu_help_content, {0,NK_F1,0}, NULL},
- {T_HELP, -1, "", NULL,{0,0,0}, NULL }
+ {T_ABOUT,MAINMENU_M_ABOUT, menu_about, {0,0,0}, NULL },
+ {T_FILE, MAINMENU_M_NEWWIN, menu_new_win, {0,0,0}, NULL},
+ {T_FILE, MAINMENU_M_OPENURL, menu_open_url, {'G',0,K_CTRL}, NULL},
+ {T_FILE, MAINMENU_M_OPENFILE, menu_open_file, {'O',0,K_CTRL}, NULL},
+ {T_FILE, MAINMENU_M_CLOSEWIN, menu_close_win, {0,0,0}, NULL},
+ {T_FILE, MAINMENU_M_SAVEPAGE, menu_save_page, {0,NK_F3,0}, NULL},
+ {T_FILE, MAINMENU_M_QUIT, menu_quit, {'Q',0,K_CTRL}, NULL},
+ {T_EDIT, MAINMENU_M_CUT, menu_cut, {'X',0,K_CTRL}, NULL},
+ {T_EDIT, MAINMENU_M_COPY, menu_copy, {'C',0,K_CTRL}, NULL},
+ {T_EDIT, MAINMENU_M_PASTE, menu_paste, {'V',0,K_CTRL}, NULL},
+ {T_EDIT, MAINMENU_M_FIND, menu_find, {0,NK_F4,0}, NULL},
+ {T_VIEW, MAINMENU_M_RELOAD, menu_reload, {0,NK_F5,0}, NULL},
+ {T_VIEW, MAINMENU_M_TOOLBARS, menu_toolbars, {0,NK_F1,K_CTRL}, NULL},
+ {T_VIEW, MAINMENU_M_SAVEWIN, menu_savewin, {0,0,0}, NULL},
+ {T_VIEW, MAINMENU_M_DEBUG_RENDER, menu_debug_render, {0,0,0}, NULL},
+ {T_VIEW, MAINMENU_M_FG_IMAGES, menu_fg_images, {0,0,0}, NULL},
+ {T_VIEW, MAINMENU_M_BG_IMAGES, menu_bg_images, {0,0,0}, NULL},
+ {T_VIEW, MAINMENU_M_STOP, menu_stop, {0,NK_ESC,K_ALT}, NULL},
+ {T_NAV, MAINMENU_M_BACK, menu_back, {0,NK_LEFT,K_ALT}, NULL},
+ {T_NAV, MAINMENU_M_FORWARD, menu_forward, {0,NK_RIGHT,K_ALT}, NULL},
+ {T_NAV, MAINMENU_M_HOME, menu_home, {0,NK_CLRHOME,0}, NULL},
+ {T_UTIL, MAINMENU_M_LHISTORY,menu_lhistory, {0,NK_F7,0}, NULL},
+ {T_UTIL, MAINMENU_M_GHISTORY, menu_ghistory, {0,NK_F7,K_CTRL}, NULL},
+ {T_UTIL, MAINMENU_M_ADD_BOOKMARK, menu_add_bookmark, {'D',0,K_CTRL}, NULL},
+ {T_UTIL, MAINMENU_M_BOOKMARKS, menu_bookmarks, {0,NK_F6,0}, NULL},
+ {T_UTIL, MAINMENU_M_CHOICES, menu_choices, {0,0,0}, NULL},
+ {T_UTIL, MAINMENU_M_VLOG, menu_vlog, {'V',0,K_ALT}, NULL},
+ {T_HELP, MAINMENU_M_HELP_CONTENT, menu_help_content, {0,NK_F1,0}, NULL},
+ {T_HELP, -1, NULL,{0,0,0}, NULL }
};
void __CDECL global_evnt_apterm( WINDOW * win, short buff[8] )
Modified: trunk/netsurf/atari/global_evnt.h
URL: http://source.netsurf-browser.org/trunk/netsurf/atari/global_evnt.h?rev=1...
==============================================================================
--- trunk/netsurf/atari/global_evnt.h (original)
+++ trunk/netsurf/atari/global_evnt.h Mon Apr 9 06:44:09 2012
@@ -45,7 +45,6 @@
struct s_menu_item_evnt {
short title; /* to which menu this item belongs */
short rid; /* resource ID */
- const char * nsid; /* Netsurf message ID */
menu_evnt_func menu_func; /* click handler */
struct s_accelerator accel; /* accelerator info */
char * menustr;
11 years, 7 months
r13841 mono - in /trunk/netsurf/atari: browser.c browser_win.c hotlist.c
by netsurf@semichrome.net
Author: mono
Date: Mon Apr 9 06:33:34 2012
New Revision: 13841
URL: http://source.netsurf-browser.org?rev=13841&view=rev
Log:
Removed debug output, text format changes...
Modified:
trunk/netsurf/atari/browser.c
trunk/netsurf/atari/browser_win.c
trunk/netsurf/atari/hotlist.c
Modified: trunk/netsurf/atari/browser.c
URL: http://source.netsurf-browser.org/trunk/netsurf/atari/browser.c?rev=13841...
==============================================================================
--- trunk/netsurf/atari/browser.c (original)
+++ trunk/netsurf/atari/browser.c Mon Apr 9 06:33:34 2012
@@ -780,7 +780,6 @@
if( wf_top[0] == gw->root->handle->handle
&& wf_top[1] == _AESapid ){
- printf("top redraw");
/* The window is on top, so there is no need to walk the */
/* AES rectangle list. */
for( i=0; i<b->redraw.areas_used; i++ ){
Modified: trunk/netsurf/atari/browser_win.c
URL: http://source.netsurf-browser.org/trunk/netsurf/atari/browser_win.c?rev=1...
==============================================================================
--- trunk/netsurf/atari/browser_win.c (original)
+++ trunk/netsurf/atari/browser_win.c Mon Apr 9 06:33:34 2012
@@ -112,7 +112,7 @@
return( -1 );
memset( gw->root, 0, sizeof(struct s_gui_win_root) );
gw->root->title = malloc(atari_sysinfo.aes_max_win_title_len+1);
- gw->root->handle = WindCreate( flags,40, 40, app.w, app.h );
+ gw->root->handle = WindCreate( flags, 40, 40, app.w, app.h );
if( gw->root->handle == NULL ) {
free( gw->root->title );
free( gw->root );
Modified: trunk/netsurf/atari/hotlist.c
URL: http://source.netsurf-browser.org/trunk/netsurf/atari/hotlist.c?rev=13841...
==============================================================================
--- trunk/netsurf/atari/hotlist.c (original)
+++ trunk/netsurf/atari/hotlist.c Mon Apr 9 06:33:34 2012
@@ -45,8 +45,8 @@
struct atari_hotlist hl;
static void evnt_hl_toolbar( WINDOW *win, short buff[8]) {
- /* handle toolbar object (index in buff[4] ) */
- switch( buff[4] ) {
+ /* handle toolbar object (index in buff[4] ) */
+ switch( buff[4] ) {
case TOOLBAR_HOTLIST_CREATE_FOLDER:
hotlist_add_folder(true);
break;
@@ -58,12 +58,12 @@
case TOOLBAR_HOTLIST_DELETE:
hotlist_delete_selected();
break;
-
+
case TOOLBAR_HOTLIST_EDIT:
hotlist_edit_selected();
break;
}
- ObjcChange( OC_TOOLBAR, win, buff[4], ~SELECTED, OC_MSG );
+ ObjcChange( OC_TOOLBAR, win, buff[4], ~SELECTED, OC_MSG );
}
@@ -75,9 +75,9 @@
static void __CDECL evnt_hl_mbutton( WINDOW *win, short buff[8] )
{
- /* todo: implement popup?
+ /* todo: implement popup?
if(evnt.mbut & 2) {
-
+
}
*/
}
@@ -108,7 +108,7 @@
WindSetPtr( hl.window, WF_TOOLBAR, tree, evnt_hl_toolbar );
EvntAttach( hl.window, WM_CLOSED, evnt_hl_close );
EvntAttach( hl.window, WM_XBUTTON,evnt_hl_mbutton );
- hl.tv = atari_treeview_create(
+ hl.tv = atari_treeview_create(
hotlist_get_tree_flags(),
hl.window
);
@@ -117,14 +117,14 @@
LOG(("Failed to allocate treeview"));
return;
}
-
+
hotlist_initialise(
hl.tv->tree,
/* TODO: use option_hotlist_file or slt*/
(char*)&hl.path,
"dir.png"
);
-
+
} else {
}
@@ -132,7 +132,7 @@
}
-void hotlist_open(void)
+void hotlist_open(void)
{
if( hl.init == false ) {
return;
@@ -142,7 +142,7 @@
hl.open = true;
atari_treeview_open( hl.tv );
} else {
- WindTop( hl.window );
+ WindTop( hl.window );
}
}
@@ -160,7 +160,7 @@
}
if( hl.window != NULL ) {
hotlist_cleanup( (char*)&hl.path );
- if( hl.open )
+ if( hl.open )
hotlist_close();
WindDelete( hl.window );
hl.window = NULL;
11 years, 7 months
r13840 mono - /trunk/netsurf/atari/global_evnt.c
by netsurf@semichrome.net
Author: mono
Date: Mon Apr 9 06:30:59 2012
New Revision: 13840
URL: http://source.netsurf-browser.org?rev=13840&view=rev
Log:
Simplified keyboard-shortcut code: Don't use Messages file for Menu strings and accelerator definitions. These things are now taken from the RSC file.
Modified:
trunk/netsurf/atari/global_evnt.c
Modified: trunk/netsurf/atari/global_evnt.c
URL: http://source.netsurf-browser.org/trunk/netsurf/atari/global_evnt.c?rev=1...
==============================================================================
--- trunk/netsurf/atari/global_evnt.c (original)
+++ trunk/netsurf/atari/global_evnt.c Mon Apr 9 06:30:59 2012
@@ -70,8 +70,7 @@
#define T_UTIL MAINMENU_T_UTIL - MAINMENU_T_FILE + 1
#define T_HELP MAINMENU_T_NAVIGATE - MAINMENU_T_FILE + 1
/* Count of the above defines: */
-#define NUM_MENU_TITLES 7
-static char * menu_titles[NUM_MENU_TITLES] = {NULL};
+#define NUM_MENU_TITLES 7
/* Global event handlers: */
static void __CDECL global_evnt_apterm( WINDOW * win, short buff[8] );
@@ -81,9 +80,6 @@
/* Menu event handlers: */
static void __CDECL menu_about(WINDOW *win, int item, int title, void *data);
-
-static char * get_accel(int mode, char * message, struct s_accelerator * accel);
-static int parse_accel( char * message, struct s_accelerator * accel);
/* Menu event handlers: */
@@ -366,32 +362,32 @@
{
{T_ABOUT,MAINMENU_M_ABOUT, "About", menu_about, {0,0,0}, NULL },
{T_FILE, MAINMENU_M_NEWWIN, "NewWindow", menu_new_win, {0,0,0}, NULL},
- {T_FILE, MAINMENU_M_OPENURL, "OpenURL", menu_open_url, {0,0,0}, NULL},
- {T_FILE, MAINMENU_M_OPENFILE, "OpenFile", menu_open_file, {0,0,0}, NULL},
+ {T_FILE, MAINMENU_M_OPENURL, "OpenURL", menu_open_url, {'G',0,K_CTRL}, NULL},
+ {T_FILE, MAINMENU_M_OPENFILE, "OpenFile", menu_open_file, {'O',0,K_CTRL}, NULL},
{T_FILE, MAINMENU_M_CLOSEWIN, "CloseWindow", menu_close_win, {0,0,0}, NULL},
- {T_FILE, MAINMENU_M_SAVEPAGE, "Save", menu_save_page, {0,0,0}, NULL},
+ {T_FILE, MAINMENU_M_SAVEPAGE, "Save", menu_save_page, {0,NK_F3,0}, NULL},
{T_FILE, MAINMENU_M_QUIT, "Quit", menu_quit, {'Q',0,K_CTRL}, NULL},
- {T_EDIT, MAINMENU_M_CUT, "Cut", menu_cut, {0,0,0}, NULL},
- {T_EDIT, MAINMENU_M_COPY, "Copy", menu_copy, {0,0,0}, NULL},
- {T_EDIT, MAINMENU_M_PASTE, "Paste", menu_paste, {0,0,0}, NULL},
- {T_EDIT, MAINMENU_M_FIND, "FindText", menu_find, {0,0,0}, NULL},
+ {T_EDIT, MAINMENU_M_CUT, "Cut", menu_cut, {'X',0,K_CTRL}, NULL},
+ {T_EDIT, MAINMENU_M_COPY, "Copy", menu_copy, {'C',0,K_CTRL}, NULL},
+ {T_EDIT, MAINMENU_M_PASTE, "Paste", menu_paste, {'V',0,K_CTRL}, NULL},
+ {T_EDIT, MAINMENU_M_FIND, "FindText", menu_find, {0,NK_F4,0}, NULL},
{T_VIEW, MAINMENU_M_RELOAD, "Reload", menu_reload, {0,NK_F5,0}, NULL},
- {T_VIEW, MAINMENU_M_TOOLBARS, "Toolbars", menu_toolbars, {0,0,0}, NULL},
+ {T_VIEW, MAINMENU_M_TOOLBARS, "Toolbars", menu_toolbars, {0,NK_F1,K_CTRL}, NULL},
{T_VIEW, MAINMENU_M_SAVEWIN, "", menu_savewin, {0,0,0}, NULL},
{T_VIEW, MAINMENU_M_DEBUG_RENDER, "", menu_debug_render, {0,0,0}, NULL},
{T_VIEW, MAINMENU_M_FG_IMAGES, "", menu_fg_images, {0,0,0}, NULL},
{T_VIEW, MAINMENU_M_BG_IMAGES, "", menu_bg_images, {0,0,0}, NULL},
- {T_VIEW, MAINMENU_M_STOP, "Stop", menu_stop, {0,0,0}, NULL},
- {T_NAV, MAINMENU_M_BACK, "Back", menu_back, {0,0,0}, NULL},
- {T_NAV, MAINMENU_M_FORWARD, "Forward", menu_forward, {0,0,0}, NULL},
- {T_NAV, MAINMENU_M_HOME, "Home", menu_home, {0,0,0}, NULL},
- {T_UTIL, MAINMENU_M_LHISTORY, "HistLocal", menu_lhistory, {0,0,0}, NULL},
- {T_UTIL, MAINMENU_M_GHISTORY, "HistGlobal", menu_ghistory, {0,0,0}, NULL},
+ {T_VIEW, MAINMENU_M_STOP, "Stop", menu_stop, {0,NK_ESC,K_ALT}, NULL},
+ {T_NAV, MAINMENU_M_BACK, "Back", menu_back, {0,NK_LEFT,K_ALT}, NULL},
+ {T_NAV, MAINMENU_M_FORWARD, "Forward", menu_forward, {0,NK_RIGHT,K_ALT}, NULL},
+ {T_NAV, MAINMENU_M_HOME, "Home", menu_home, {0,NK_CLRHOME,0}, NULL},
+ {T_UTIL, MAINMENU_M_LHISTORY, "HistLocal", menu_lhistory, {0,NK_F7,0}, NULL},
+ {T_UTIL, MAINMENU_M_GHISTORY, "HistGlobal", menu_ghistory, {0,NK_F7,K_CTRL}, NULL},
{T_UTIL, MAINMENU_M_ADD_BOOKMARK, "HotlistAdd", menu_add_bookmark, {'D',0,K_CTRL}, NULL},
- {T_UTIL, MAINMENU_M_BOOKMARKS, "HotlistShow", menu_bookmarks, {0,0,0}, NULL},
+ {T_UTIL, MAINMENU_M_BOOKMARKS, "HotlistShow", menu_bookmarks, {0,NK_F6,0}, NULL},
{T_UTIL, MAINMENU_M_CHOICES, "Choices", menu_choices, {0,0,0}, NULL},
- {T_UTIL, MAINMENU_M_VLOG, "Verbose Log", menu_vlog, {0,0,0}, NULL},
- {T_HELP, MAINMENU_M_HELP_CONTENT, "Help", menu_help_content, {0,0,0}, NULL},
+ {T_UTIL, MAINMENU_M_VLOG, "Verbose Log", menu_vlog, {'V',0,K_ALT}, NULL},
+ {T_HELP, MAINMENU_M_HELP_CONTENT, "Help", menu_help_content, {0,NK_F1,0}, NULL},
{T_HELP, -1, "", NULL,{0,0,0}, NULL }
};
@@ -526,111 +522,85 @@
i++;
}
}
-
-/*
- mode = 0 -> return string ptr
- (build from accel definition in s_accelerator accel)
- mode = 1 -> return ptr to (untranslated) NS accel string, if any
-*/
-static char * get_accel(int mode, char * message, struct s_accelerator * accel )
-{
- static char result[8];
- int pos = 0;
- char * r = NULL;
- char * s = NULL;
- memset( &result, 0, 8);
- if( (accel->ascii != 0 || accel->keycode != 0) && mode == 0)
- goto predefined_accel;
- s = strrchr(message, (int)' ' ) ;
- if(!s)
- goto error;
- if( strlen( s ) < 2)
- goto error;
- if(strlen(s) >= 2){
- s++;
- /* if string after space begins with lowercase ascii, its not an accelerator: */
- if( s[0] >= 0x061 && s[0] <= 0x07A )
- goto error;
- if( strncmp(s, "URL", 3) == 0)
- goto error;
- if(mode == 1)
- return( s );
- /* detect obscure shift accelerator: */
- if(!strncmp("\xe2\x87\x91", s, 3)){
- s = s+3;
- strcpy((char*)&result, "");
- strncpy((char*)&result[1], s, 14);
- goto success;
- }
- strncpy((char*)&result, s, 15);
- }
-goto success;
-
-predefined_accel:
- if( (accel->mod & K_RSHIFT) || (accel->mod & K_RSHIFT) ) {
- result[pos]='';
- pos++;
- }
- if(accel->mod == K_CTRL ) {
- result[pos]='^';
- pos++;
- }
- if(accel->ascii != 0L ) {
- result[pos]= accel->ascii;
- pos++;
- }
- else if(accel->keycode != 0L ) {
- if( accel->keycode >= NK_F1 && accel->keycode <= NK_F10){
- result[pos++] = 'F';
- sprintf( (char*)&result[pos++], "%d", ((accel->keycode - NK_F1)+1) );
- } else {
- *((char*)0) = 1;
- switch( accel->keycode ) {
- /* TODO: Add further Keycodes & Symbols here, if needed. */
- default:
- goto error;
- }
- }
- }
-success:
- r = (char*)&result;
-error:
- return r;
-}
-
-/* create accelerator info and keep track of the line length */
-static int parse_accel( char * message, struct s_accelerator * accel)
-{
- int retval = strlen( message ) ;
- char * s = get_accel( 0, message, accel );
- if(!s && (accel->keycode == 0 && accel->ascii == 0 && accel->mod == 0) ) {
- return retval+4; /* add 3 "imaginary" accel characters + blank */
- }
-
- /* the accel is already defined: */
- if(accel->keycode != 0 ||accel->ascii != 0 || accel->mod != 0) {
- return( retval+1 );
- }
-
- if(s[0] == '' ) { /* arrow up */
- accel->mod |= (K_LSHIFT|K_RSHIFT);
- s++;
- }
- else if(s[0] == 0x05E ) { /* ^ */
- accel->mod |= K_CTRL;
- s++;
- }
-
- /* expect F1/F10 or something like A, B, C ... : */
- if(strlen(s) >= 2 && s[0] == 'F' ) {
- if(s[1] >= 49 && s[1] <= 57) {
- accel->keycode = NK_F1 + (atoi(&s[1])-1);
- }
- }
- else {
- accel->ascii = s[0];
- }
- return( retval+1 ); /* add 1 blank */
+
+/*
+ Parse encoded menu key shortcut
+
+ The format is:
+
+ "[" - marks start of the shortcut
+ "@,^,<" - If the keyshortcut is only valid
+ with modifier keys, one of these characters must directly
+ follow the start mark.
+ Meaning:
+ @ -> Alternate
+ ^ -> Control
+ "#" - keycode or ascii character.
+ The value is handled as keycode if the character value
+ is <= 28 ( Atari chracter table )
+ or if it is interpreted as function key string.
+ (strings: F1 - F10)
+
+*/
+static void register_menu_str( struct s_menu_item_evnt * mi )
+{
+ char * str = ObjcString( h_gem_menu, mi->rid, NULL );
+ int l = strlen(str);
+ int i = l;
+ int x = -1;
+ struct s_accelerator * accel = &mi->accel;
+
+
+
+ while( i>2 ){
+ if( str[i] == '['){
+ x = i;
+ break;
+ }
+ i--;
+ }
+ if( x > -1 ){
+ mi->menustr = malloc( l+1 );
+ strcpy(mi->menustr, str );
+ mi->menustr[x]=' ';
+ x++;
+ if( str[x] == '@' ){
+ accel->mod = K_ALT;
+ mi->menustr[x] = 0x07;
+ x++;
+ }
+ else if( str[x] == '^' ) {
+ accel->mod = K_CTRL;
+ x++;
+ }
+ if( str[x] <= 28 ){
+ // parse symbol
+ unsigned short keycode=0;
+ switch( str[x] ){
+ case 0x03:
+ accel->keycode = NK_RIGHT;
+ break;
+ case 0x04:
+ accel->keycode = NK_LEFT;
+ break;
+ case 0x1B:
+ accel->keycode = NK_ESC;
+ break;
+ default:
+ break;
+ }
+ } else {
+ if(str[x] == 'F' && ( str[x+1] >= '1' && str[x+1] <= '9') ){
+ // parse function key
+ short fkey = atoi( &str[x+1] );
+ if( (fkey >= 0) && (fkey <= 10) ){
+ accel->keycode = NK_F1 - 1 + fkey;
+ }
+ } else {
+ accel->ascii = str[x];
+ }
+ }
+ }
}
@@ -655,27 +625,6 @@
}
}
-
-static void set_menu_title(int rid, const char * nsid)
-{
- static int count=0;
- char * msgstr;
- msgstr = (char*)messages_get(nsid);
- if(msgstr != NULL) {
- if(msgstr[0] != 0) {
- // TODO: modify resource tree, adjust width of menu to chars
- // actually used.
- assert(count < NUM_MENU_TITLES);
- menu_titles[count] = malloc( strlen(msgstr)+3 );
- strcpy((char*)menu_titles[count], " ");
- strncat((char*)menu_titles[count], msgstr, strlen(msgstr)+1 );
- strncat((char*)menu_titles[count], " ", 2 );
- MenuText(NULL, rid, menu_titles[count] );
- count++;
- }
- }
-}
-
void main_menu_update( void )
{
MenuIcheck( NULL, MAINMENU_M_DEBUG_RENDER, (html_redraw_debug) ? 1 : 0);
@@ -696,98 +645,23 @@
EvntAttach( NULL, AP_TERM, global_evnt_apterm );
EvntAttach( NULL, MN_SELECTED, global_evnt_menu );
EvntAttach( NULL, WM_XM1, global_evnt_m1 );
-
- set_menu_title( MAINMENU_T_FILE, "Page");
- set_menu_title( MAINMENU_T_EDIT, "Edit" );
- set_menu_title( MAINMENU_T_NAVIGATE, "Navigate");
- set_menu_title( MAINMENU_T_VIEW, "View");
- set_menu_title( MAINMENU_T_UTIL, "Utilities");
- set_menu_title( MAINMENU_T_HELP, "Help");
-
- /* measure items in titles : */
+
+ /* parse and update menu items: */
i = 0;
- while( menu_evnt_tbl[i].rid != -1 ) {
- if( menu_evnt_tbl[i].nsid[0] != 0 ) {
- m = (char*)messages_get(menu_evnt_tbl[i].nsid);
- assert(strlen(m)<40);
- /* create accelerator: */
- len = parse_accel(m, &menu_evnt_tbl[i].accel);
- maxlen[menu_evnt_tbl[i].title]=MAX(len, maxlen[menu_evnt_tbl[i].title] );
- assert(maxlen[menu_evnt_tbl[i].title]<40);
+ while( menu_evnt_tbl[i].rid != -1 ) {
+ char * str = ObjcString( h_gem_menu, menu_evnt_tbl[i].rid, NULL );
+ register_menu_str( &menu_evnt_tbl[i] );
+ if( menu_evnt_tbl[i].menustr != NULL ){
+ MenuText( NULL, menu_evnt_tbl[i].rid, menu_evnt_tbl[i].menustr );
}
i++;
- }
- for( i=0; i<NUM_MENU_TITLES; i++) {
- if ( maxlen[i] > 120 )
- maxlen[i] = 120;
- }
- /* set menu texts : */
- i = 0;
- while( menu_evnt_tbl[i].rid != -1 ) {
- if( menu_evnt_tbl[i].nsid[0] != 0 ) {
- m = (char*)messages_get(menu_evnt_tbl[i].nsid);
- if(m == NULL) {
- m = (char*)menu_evnt_tbl[i].nsid;
- }
- u = get_accel( 1, m, &menu_evnt_tbl[i].accel); /* get NS accel str */
- t = get_accel( 0, m, &menu_evnt_tbl[i].accel); /* get NS or custom accel */
- memset((char*)&spare, ' ', 121);
- spare[0]=' '; /*''; */
- spare[1]=' ';
- if( u != NULL && t != NULL ) {
- LOG(("Menu Item %s: found NS accelerator, ascii: %c, scancode: %x, mod: %x",
- m,
- menu_evnt_tbl[i].accel.ascii,
- menu_evnt_tbl[i].accel.keycode,
- menu_evnt_tbl[i].accel.mod
- ));
- /* Accelerator is defined in menu string: */
- memcpy((char*)&spare[2], m, u-m-1);
- strncpy(&spare[maxlen[menu_evnt_tbl[i].title]-strlen(t)], t, 4);
- }
- else if( t != NULL && u == NULL) {
- LOG(("Menu Item %s: found RSC accelerator, ascii: %c, scancode: %x, mod: %x",
- m,
- menu_evnt_tbl[i].accel.ascii,
- menu_evnt_tbl[i].accel.keycode,
- menu_evnt_tbl[i].accel.mod
- ));
- /* Accelerator is defined in struct: */
- memcpy( (char*)&spare[2], m, strlen(m) );
- strncpy(&spare[maxlen[menu_evnt_tbl[i].title]-strlen(t)], t, 4);
- }
- else {
- /* No accel defined: */
- strcpy((char*)&spare[2], m);
- }
- spare[ maxlen[menu_evnt_tbl[i].title]+1 ] = 0;
- menu_evnt_tbl[i].menustr = malloc(strlen((char*)&spare)+1);
- if( menu_evnt_tbl[i].menustr ) {
- strcpy( menu_evnt_tbl[i].menustr , (char*)&spare );
- }
- }
- i++;
- }
- i=0;
- while( menu_evnt_tbl[i].rid != -1 ) {
- if( menu_evnt_tbl[i].menustr != NULL ) {
- // TODO: modify resource tree, adjust width of menu to chars
- // actually used.
- MenuText( NULL, menu_evnt_tbl[i].rid, menu_evnt_tbl[i].menustr );
- }
- i++;
- }
- main_menu_update();
- /* TODO: Fix pixel sizes for Titles and Items (for non-8px fonts) */
+ }
+ main_menu_update();
}
void unbind_global_events( void )
{
int i;
- for( i=0; i<NUM_MENU_TITLES; i++){
- if( menu_titles[i]!= NULL)
- free( menu_titles[i] );
- }
i=0;
while(menu_evnt_tbl[i].rid != -1) {
if( menu_evnt_tbl[i].menustr != NULL )
11 years, 7 months