mirror of
https://github.com/netsurf-browser/netsurf
synced 2024-11-23 14:59:47 +03:00
Close fonts properly and default back to initial RastPort font.
svn path=/trunk/netsurf/; revision=5136
This commit is contained in:
parent
f71f8f82a1
commit
61294f493e
24
amiga/font.c
24
amiga/font.c
@ -49,8 +49,10 @@ bool nsfont_width(const struct css_style *style,
|
||||
const char *string, size_t length,
|
||||
int *width)
|
||||
{
|
||||
ami_open_font(style);
|
||||
struct TextFont *tfont = ami_open_font(style);
|
||||
*width = TextLength(currp,string,length);
|
||||
ami_close_font(tfont);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -72,12 +74,13 @@ bool nsfont_position_in_string(const struct css_style *style,
|
||||
int x, size_t *char_offset, int *actual_x)
|
||||
{
|
||||
struct TextExtent extent;
|
||||
|
||||
ami_open_font(style);
|
||||
struct TextFont *tfont = ami_open_font(style);
|
||||
*char_offset = TextFit(currp,string,length,
|
||||
&extent,NULL,1,x,32767);
|
||||
|
||||
*actual_x = extent.te_Extent.MaxX;
|
||||
|
||||
ami_close_font(tfont);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -106,8 +109,7 @@ bool nsfont_split(const struct css_style *style,
|
||||
struct TextExtent extent;
|
||||
ULONG co;
|
||||
char *charp;
|
||||
|
||||
ami_open_font(style);
|
||||
struct TextFont *tfont = ami_open_font(style);
|
||||
co = TextFit(currp,string,length,
|
||||
&extent,NULL,1,x,32767);
|
||||
|
||||
@ -121,10 +123,11 @@ bool nsfont_split(const struct css_style *style,
|
||||
*char_offset = co;
|
||||
*actual_x = TextLength(currp,string,co);
|
||||
|
||||
ami_close_font(tfont);
|
||||
return true;
|
||||
}
|
||||
|
||||
void ami_open_font(struct css_style *style)
|
||||
struct TextFont *ami_open_font(struct css_style *style)
|
||||
{
|
||||
struct TextFont *tfont;
|
||||
struct TTextAttr tattr;
|
||||
@ -216,5 +219,14 @@ void ami_open_font(struct css_style *style)
|
||||
TAG_DONE);
|
||||
}
|
||||
|
||||
return tfont;
|
||||
}
|
||||
|
||||
void ami_close_font(struct TextFont *tfont)
|
||||
{
|
||||
SetRPAttrs(currp,
|
||||
RPTAG_Font,origrpfont,
|
||||
TAG_DONE);
|
||||
|
||||
CloseFont(tfont);
|
||||
}
|
||||
|
@ -20,7 +20,9 @@
|
||||
#define AMIGA_FONT_H
|
||||
|
||||
#include "css/css.h"
|
||||
#include <graphics/text.h>
|
||||
|
||||
void ami_open_font(struct css_style *);
|
||||
struct TextFont *ami_open_font(struct css_style *);
|
||||
void ami_close_font(struct TextFont *tfont);
|
||||
|
||||
#endif
|
||||
|
36
amiga/gui.c
36
amiga/gui.c
@ -36,6 +36,8 @@
|
||||
#include <proto/utility.h>
|
||||
#include <proto/graphics.h>
|
||||
#include <proto/Picasso96API.h>
|
||||
#include "render/form.h"
|
||||
#include <graphics/rpattr.h>
|
||||
|
||||
#ifdef WITH_HUBBUB
|
||||
#include <hubbub/hubbub.h>
|
||||
@ -102,7 +104,7 @@ void gui_init(int argc, char** argv)
|
||||
TimerBase = (struct Device *)tioreq->tr_node.io_Device;
|
||||
ITimer = (struct TimerIFace *)GetInterface((struct Library *)TimerBase,"main",1,NULL);
|
||||
|
||||
verbose_log = 1;
|
||||
verbose_log = 0;
|
||||
|
||||
if(lock=Lock("Resources/LangNames",ACCESS_READ))
|
||||
{
|
||||
@ -224,9 +226,6 @@ void ami_get_msg(void)
|
||||
{
|
||||
gwin = node->objstruct;
|
||||
|
||||
if(gwin->redraw_required)
|
||||
ami_do_redraw(gwin);
|
||||
|
||||
while((result = RA_HandleInput(gwin->objects[OID_MAIN],&code)) != WMHI_LASTMSG)
|
||||
{
|
||||
|
||||
@ -377,19 +376,9 @@ void ami_get_msg(void)
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
while((result = RA_HandleInput(gwin->objects[OID_VSCROLL],&code)) != WMHI_LASTMSG)
|
||||
{
|
||||
switch(result & WMHI_CLASSMASK) // class
|
||||
{
|
||||
default:
|
||||
//case WMHI_GADGETUP:
|
||||
//switch(result & WMHI_GADGETMASK) //gadaddr->GadgetID) //result & WMHI_GADGETMASK)
|
||||
printf("vscroller %ld %ld\n",(result & WMHI_CLASSMASK),(result & WMHI_GADGETMASK));
|
||||
break;
|
||||
}
|
||||
}
|
||||
*/
|
||||
if(gwin->redraw_required)
|
||||
ami_do_redraw(gwin);
|
||||
|
||||
node = nnode;
|
||||
}
|
||||
}
|
||||
@ -670,6 +659,8 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw,
|
||||
InitRastPort(&gwin->rp);
|
||||
gwin->rp.BitMap = gwin->bm;
|
||||
|
||||
GetRPAttrs(&gwin->rp,RPTAG_Font,&origrpfont,TAG_DONE);
|
||||
|
||||
GetAttr(WINDOW_HorizObject,gwin->objects[OID_MAIN],(ULONG *)&gwin->objects[OID_HSCROLL]);
|
||||
GetAttr(WINDOW_VertObject,gwin->objects[OID_MAIN],(ULONG *)&gwin->objects[OID_VSCROLL]);
|
||||
|
||||
@ -834,7 +825,7 @@ void gui_window_scroll_visible(struct gui_window *g, int x0, int y0,
|
||||
void gui_window_position_frame(struct gui_window *g, int x0, int y0,
|
||||
int x1, int y1)
|
||||
{
|
||||
printf("posn frame\n");
|
||||
ChangeWindowBox(g->win,x0,y0,x1-x0,y1-y0);
|
||||
}
|
||||
|
||||
void gui_window_get_dimensions(struct gui_window *g, int *width, int *height,
|
||||
@ -858,7 +849,9 @@ void gui_window_get_dimensions(struct gui_window *g, int *width, int *height,
|
||||
|
||||
void gui_window_update_extent(struct gui_window *g)
|
||||
{
|
||||
// Object *hscroller,*vscroller;
|
||||
struct IBox *bbox;
|
||||
|
||||
GetAttr(SPACE_AreaBox,g->gadgets[GID_BROWSER],(ULONG *)&bbox);
|
||||
|
||||
printf("upd ext %ld,%ld\n",g->bw->current_content->width, // * g->bw->scale,
|
||||
g->bw->current_content->height); // * g->bw->scale);
|
||||
@ -870,13 +863,13 @@ void gui_window_update_extent(struct gui_window *g)
|
||||
|
||||
RefreshSetGadgetAttrs((APTR)g->objects[OID_VSCROLL],g->win,NULL,
|
||||
SCROLLER_Total,g->bw->current_content->height,
|
||||
SCROLLER_Visible,600,
|
||||
SCROLLER_Visible,bbox->Height,
|
||||
SCROLLER_Top,0,
|
||||
TAG_DONE);
|
||||
|
||||
RefreshSetGadgetAttrs((APTR)g->objects[OID_HSCROLL],g->win,NULL,
|
||||
SCROLLER_Total,g->bw->current_content->width,
|
||||
SCROLLER_Visible,800,
|
||||
SCROLLER_Visible,bbox->Width,
|
||||
SCROLLER_Top,0,
|
||||
TAG_DONE);
|
||||
}
|
||||
@ -1012,6 +1005,7 @@ bool gui_copy_to_clipboard(struct selection *s)
|
||||
void gui_create_form_select_menu(struct browser_window *bw,
|
||||
struct form_control *control)
|
||||
{
|
||||
printf("FORM TYPE: %ld\n",control->type);
|
||||
}
|
||||
|
||||
void gui_launch_url(const char *url)
|
||||
|
@ -66,6 +66,7 @@ struct gui_window {
|
||||
union content_msg_data *redraw_data;
|
||||
};
|
||||
|
||||
struct gui_window *curwin;
|
||||
//struct gui_window *curwin;
|
||||
struct RastPort *currp;
|
||||
struct TextFont *origrpfont;
|
||||
#endif
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include <proto/graphics.h>
|
||||
#include <intuition/intuition.h>
|
||||
#include <graphics/rpattr.h>
|
||||
#include <graphics/gfxmacros.h>
|
||||
|
||||
#include <proto/exec.h> // for debugprintf only
|
||||
|
||||
@ -103,9 +104,7 @@ bool ami_line(int x0, int y0, int x1, int y1, int width,
|
||||
SetRPAttrs(currp,RPTAG_APenColor,p96EncodeColor(RGBFB_A8B8G8R8,c),
|
||||
TAG_DONE);
|
||||
Move(currp,x0,y0);
|
||||
Draw(currp,x1,y1); // NB: does not support width,dotted,dashed
|
||||
|
||||
/*There is the line pattern in the rastport, would that help? There are macros in graphics/gfxmacros.h that do it. */
|
||||
Draw(currp,x1,y1);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -156,21 +155,26 @@ bool ami_clip(int x0, int y0, int x1, int y1)
|
||||
bool ami_text(int x, int y, const struct css_style *style,
|
||||
const char *text, size_t length, colour bg, colour c)
|
||||
{
|
||||
ami_open_font(style);
|
||||
struct TextFont *tfont = ami_open_font(style);
|
||||
|
||||
SetRPAttrs(currp,RPTAG_APenColor,p96EncodeColor(RGBFB_A8B8G8R8,c),
|
||||
RPTAG_BPenColor,p96EncodeColor(RGBFB_A8B8G8R8,bg),
|
||||
RPTAG_OPenColor,p96EncodeColor(RGBFB_A8B8G8R8,bg),
|
||||
// RPTAG_OPenColor,p96EncodeColor(RGBFB_A8B8G8R8,bg),
|
||||
// RPTAG_Font,tfont,
|
||||
TAG_DONE);
|
||||
Move(currp,x,y);
|
||||
Text(currp,text,length);
|
||||
|
||||
ami_close_font(tfont);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool ami_disc(int x, int y, int radius, colour c, bool filled)
|
||||
{
|
||||
struct AreaInfo ai;
|
||||
APTR buf[10];
|
||||
|
||||
DebugPrintF("disc\n");
|
||||
|
||||
currp->PenWidth = 1;
|
||||
@ -179,6 +183,16 @@ bool ami_disc(int x, int y, int radius, colour c, bool filled)
|
||||
|
||||
SetRPAttrs(currp,RPTAG_APenColor,p96EncodeColor(RGBFB_A8B8G8R8,c),
|
||||
TAG_DONE);
|
||||
|
||||
/* see rkrm
|
||||
if(filled)
|
||||
{
|
||||
// InitArea(&ai,&buf,2);
|
||||
AreaCircle(currp,x,y,radius);
|
||||
// AreaEnd(currp);
|
||||
}
|
||||
*/
|
||||
|
||||
DrawEllipse(currp,x,y,radius,radius); // NB: does not support fill, need to use AreaCircle for that
|
||||
|
||||
return true;
|
||||
|
@ -36,10 +36,10 @@ bool ami_disc(int x, int y, int radius, colour c, bool filled);
|
||||
bool ami_arc(int x, int y, int radius, int angle1, int angle2,
|
||||
colour c);
|
||||
bool ami_bitmap(int x, int y, int width, int height,
|
||||
struct bitmap *bitmap, colour bg);
|
||||
struct bitmap *bitmap, colour bg,struct content *content);
|
||||
bool ami_bitmap_tile(int x, int y, int width, int height,
|
||||
struct bitmap *bitmap, colour bg,
|
||||
bool repeat_x, bool repeat_y);
|
||||
bool repeat_x, bool repeat_y,struct content *content);
|
||||
bool ami_group_start(const char *name);
|
||||
bool ami_group_end(void);
|
||||
bool ami_flush(void);
|
||||
|
Loading…
Reference in New Issue
Block a user