diff options
author | Chris Young <chris@unsatisfactorysoftware.co.uk> | 2008-08-07 18:44:28 +0000 |
---|---|---|
committer | Chris Young <chris@unsatisfactorysoftware.co.uk> | 2008-08-07 18:44:28 +0000 |
commit | 394263bb2f81ce0d330058468496ecfa387ca60e (patch) | |
tree | 99919fd7a679b1e1eba9fe4ae1d0d1ff6b5bc23e /amiga | |
parent | 15eb877a4c6b002968db7fce279d7ad093e4d121 (diff) | |
download | netsurf-394263bb2f81ce0d330058468496ecfa387ca60e.tar.gz netsurf-394263bb2f81ce0d330058468496ecfa387ca60e.tar.bz2 |
Basic plotter functions and support code for the plotters.
svn path=/trunk/netsurf/; revision=4948
Diffstat (limited to 'amiga')
-rw-r--r-- | amiga/font.c | 40 | ||||
-rwxr-xr-x | amiga/gui.c | 65 | ||||
-rwxr-xr-x | amiga/gui.h | 2 | ||||
-rwxr-xr-x | amiga/plotters.c | 111 |
4 files changed, 204 insertions, 14 deletions
diff --git a/amiga/font.c b/amiga/font.c index 49c1cdc8c..a6c3b4e1e 100644 --- a/amiga/font.c +++ b/amiga/font.c @@ -20,6 +20,8 @@ #include <assert.h> #include "css/css.h" #include "render/font.h" +#include "amiga/gui.h" +#include <proto/graphics.h> static bool nsfont_width(const struct css_style *style, const char *string, size_t length, @@ -43,13 +45,28 @@ bool nsfont_width(const struct css_style *style, const char *string, size_t length, int *width) { - assert(style); - assert(string); +// ULONG w; + +printf("nsfont_width\n"); - *width = length * 10; + *width = TextLength(currp,string,length); + +// *width = length*10; return true; } +/** + * Find the position in a string where an x coordinate falls. + * + * \param style css_style for this text, with style->font_size.size == + * CSS_FONT_SIZE_LENGTH + * \param string UTF-8 string to measure + * \param length length of string + * \param x x coordinate to search for + * \param char_offset updated to offset in string of actual_x, [0..length] + * \param actual_x updated to x coordinate of character closest to x + * \return true on success, false on error and error reported + */ bool nsfont_position_in_string(const struct css_style *style, const char *string, size_t length, @@ -66,6 +83,23 @@ bool nsfont_position_in_string(const struct css_style *style, } +/** + * Find where to split a string to make it fit a width. + * + * \param style css_style for this text, with style->font_size.size == + * CSS_FONT_SIZE_LENGTH + * \param string UTF-8 string to measure + * \param length length of string + * \param x width available + * \param char_offset updated to offset in string of actual_x, [0..length] + * \param actual_x updated to x coordinate of character closest to x + * \return true on success, false on error and error reported + * + * On exit, [char_offset == 0 || + * string[char_offset] == ' ' || + * char_offset == length] + */ + bool nsfont_split(const struct css_style *style, const char *string, size_t length, int x, size_t *char_offset, int *actual_x) diff --git a/amiga/gui.c b/amiga/gui.c index 2f2cc1487..02d0a0b99 100755 --- a/amiga/gui.c +++ b/amiga/gui.c @@ -71,7 +71,7 @@ void gui_init(int argc, char** argv) void gui_init2(int argc, char** argv) { struct browser_window *bw; - const char *addr = "http://netsurf-browser.org/welcome/"; + const char *addr = NETSURF_HOMEPAGE; //"http://netsurf-browser.org/welcome/"; curbw = browser_window_create(addr, 0, 0, true); // curbw = temp } @@ -167,9 +167,17 @@ struct gui_window *gui_create_browser_window(struct browser_window *bw, WA_SizeGadget, TRUE, WA_SizeBRight, TRUE, WA_SizeBBottom, TRUE, + WA_Activate, TRUE, TAG_DONE); -curwin=gwin; //test + gwin->bw = bw; + curwin = gwin; //test + currp = gwin->win->RPort; + + bw->x0 = 0; + bw->y0 = 0; + bw->x1=800; + bw->y1=600; return gwin; } @@ -192,12 +200,31 @@ void gui_window_redraw(struct gui_window *g, int x0, int y0, int x1, int y1) void gui_window_redraw_window(struct gui_window *g) { - DebugPrintF("REDRAW2\n"); // next + struct content *c; + + DebugPrintF("REDRAW2\n"); + + c = g->bw->current_content; + current_redraw_browser = g->bw; + + currp = curwin->win->RPort; + + content_redraw(c, 0, 0, + 800, + 600, + 0, + 0, + 800, + 600, + g->bw->scale, 0xFFFFFF); + + current_redraw_browser = NULL; } void gui_window_update_box(struct gui_window *g, const union content_msg_data *data) { + DebugPrintF("update box\n"); } bool gui_window_get_scroll(struct gui_window *g, int *sx, int *sy) @@ -206,25 +233,41 @@ bool gui_window_get_scroll(struct gui_window *g, int *sx, int *sy) void gui_window_set_scroll(struct gui_window *g, int sx, int sy) { + printf("set scr\n"); } void gui_window_scroll_visible(struct gui_window *g, int x0, int y0, int x1, int y1) { + printf("scr vis\n"); } void gui_window_position_frame(struct gui_window *g, int x0, int y0, int x1, int y1) { + printf("posn frame\n"); } void gui_window_get_dimensions(struct gui_window *g, int *width, int *height, bool scaled) { + printf("get dimensions\n"); + + *width = 800; + *height = 600; + +/* + if(scaled) + { + *width /= g->bw->scale; + *height /= g->bw->scale; + } +*/ } void gui_window_update_extent(struct gui_window *g) { + printf("upd ext\n"); } void gui_window_set_status(struct gui_window *g, const char *text) @@ -234,6 +277,19 @@ void gui_window_set_status(struct gui_window *g, const char *text) void gui_window_set_pointer(struct gui_window *g, gui_pointer_shape shape) { + switch(shape) + { + case GUI_POINTER_WAIT: + SetWindowPointer(g->win, + WA_BusyPointer,TRUE, + WA_PointerDelay,TRUE, + TAG_DONE); + break; + + default: + SetWindowPointer(g->win,TAG_DONE); + break; + } } void gui_window_hide_pointer(struct gui_window *g) @@ -262,6 +318,7 @@ void gui_window_remove_caret(struct gui_window *g) void gui_window_new_content(struct gui_window *g) { + DebugPrintF("new content\n"); } bool gui_window_scroll_start(struct gui_window *g) @@ -275,6 +332,7 @@ bool gui_window_box_scroll_start(struct gui_window *g, bool gui_window_frame_resize_start(struct gui_window *g) { + printf("resize frame\n"); } void gui_window_save_as_link(struct gui_window *g, struct content *c) @@ -283,6 +341,7 @@ void gui_window_save_as_link(struct gui_window *g, struct content *c) void gui_window_set_scale(struct gui_window *g, float scale) { + printf("set scale\n"); } struct gui_download_window *gui_download_window_create(const char *url, diff --git a/amiga/gui.h b/amiga/gui.h index 220846704..377a54678 100755 --- a/amiga/gui.h +++ b/amiga/gui.h @@ -22,7 +22,9 @@ void ami_get_msg(void); struct gui_window { struct Window *win; + struct browser_window *bw; }; struct gui_window *curwin; +struct RastPort *currp; #endif diff --git a/amiga/plotters.c b/amiga/plotters.c index 12e7a15b3..0abbfd0e6 100755 --- a/amiga/plotters.c +++ b/amiga/plotters.c @@ -20,7 +20,11 @@ #include "amiga/gui.h" #include "amiga/bitmap.h" #include <proto/Picasso96API.h> +#include <proto/graphics.h> #include <intuition/intuition.h> +#include <graphics/rpattr.h> + +static clipx,clipy; struct plotter_table plot; const struct plotter_table amiplot = { @@ -35,54 +39,133 @@ const struct plotter_table amiplot = { ami_arc, ami_bitmap, ami_bitmap_tile, - ami_group_start, - ami_group_end, - ami_flush, + NULL, //ami_group_start, + NULL, //ami_group_end, + ami_flush, // optional ami_path }; bool ami_clg(colour c) { - printf("clg\n"); + printf("clg %lx\n",c); + + p96RectFill(currp,0,0,clipx,clipy, + p96EncodeColor(RGBFB_A8B8G8R8,c)); + + return true; } bool ami_rectangle(int x0, int y0, int width, int height, int line_width, colour c, bool dotted, bool dashed) { printf("rect\n"); + return true; } bool ami_line(int x0, int y0, int x1, int y1, int width, colour c, bool dotted, bool dashed) { printf("line\n"); + 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 + + return true; } bool ami_polygon(int *p, unsigned int n, colour fill) { + printf("poly\n"); + return true; } bool ami_fill(int x0, int y0, int x1, int y1, colour c) { + printf("fill\n"); + p96RectFill(currp,x0,y0,x1,y1, + p96EncodeColor(RGBFB_A8B8G8R8,c)); + return true; } bool ami_clip(int x0, int y0, int x1, int y1) { + clipx=x1; + clipy=y1; + + return true; } bool ami_text(int x, int y, const struct css_style *style, const char *text, size_t length, colour bg, colour c) { - printf("%s\n",text); +/* copied from css/css.h - need to open the correct font here + * font properties * + css_font_family font_family; + struct { + css_font_size_type size; + union { + struct css_length length; + float absolute; + float percent; + } value; + } font_size; + css_font_style font_style; + css_font_variant font_variant; + css_font_weight font_weight; + + struct { + enum { CSS_HEIGHT_INHERIT, + CSS_HEIGHT_AUTO, + CSS_HEIGHT_LENGTH, + CSS_HEIGHT_NOT_SET } height; + struct css_length length; + } height; + + struct { + enum { CSS_LETTER_SPACING_INHERIT, + CSS_LETTER_SPACING_NORMAL, + CSS_LETTER_SPACING_LENGTH, + CSS_LETTER_SPACING_NOT_SET } letter_spacing; + struct css_length length; + } letter_spacing; + + struct { + enum { CSS_LINE_HEIGHT_INHERIT, + CSS_LINE_HEIGHT_ABSOLUTE, + CSS_LINE_HEIGHT_LENGTH, + CSS_LINE_HEIGHT_PERCENT, + CSS_LINE_HEIGHT_NOT_SET } size; + union { + float absolute; + struct css_length length; + float percent; + } value; + } line_height; +*/ + + SetRPAttrs(currp,RPTAG_APenColor,p96EncodeColor(RGBFB_A8B8G8R8,c), + RPTAG_BPenColor,p96EncodeColor(RGBFB_A8B8G8R8,bg), + TAG_DONE); + Move(currp,x,y); + Text(currp,text,length); + return true; } bool ami_disc(int x, int y, int radius, colour c, bool filled) { + printf("disc\n"); + SetRPAttrs(currp,RPTAG_APenColor,p96EncodeColor(RGBFB_A8B8G8R8,c), + TAG_DONE); + DrawEllipse(currp,x,y,radius,radius); // NB: does not support fill, need to use AreaCircle for that + return true; } bool ami_arc(int x, int y, int radius, int angle1, int angle2, colour c) { + printf("arc\n"); + return true; } bool ami_bitmap(int x, int y, int width, int height, @@ -91,11 +174,16 @@ bool ami_bitmap(int x, int y, int width, int height, struct RenderInfo ri; printf("bitmap plotter\n"); + +// ami_fill(x,y,x+width,y+height,bg); + ri.Memory = bitmap->pixdata; - ri.BytesPerRow = bitmap->width * 3; - ri.RGBFormat = RGBFB_B8G8R8; + ri.BytesPerRow = bitmap->width * 4; + ri.RGBFormat = RGBFB_A8R8G8B8; + + p96WritePixelArray((struct RenderInfo *)&ri,0,0,currp,x,y,width,height); - p96WritePixelArray((struct RenderInfo *)&ri,0,0,curwin->win->RPort,x,y,width,height); + return true; } bool ami_bitmap_tile(int x, int y, int width, int height, @@ -103,23 +191,30 @@ bool ami_bitmap_tile(int x, int y, int width, int height, bool repeat_x, bool repeat_y) { printf("bitmap tile plotter\n"); + return true; } bool ami_group_start(const char *name) { /** optional */ + return false; } bool ami_group_end(void) { /** optional */ + return false; } bool ami_flush(void) { + printf("flush\n"); + return true; } bool ami_path(float *p, unsigned int n, colour fill, float width, colour c, float *transform) { + printf("path\n"); + return true; } |