diff options
author | wl <wl> | 2007-11-19 09:28:44 +0000 |
---|---|---|
committer | wl <wl> | 2007-11-19 09:28:44 +0000 |
commit | 5291a235c550b0b9304a0b8db5069f9045b6dbf4 (patch) | |
tree | 492b16e8fc3ad23fdeaf75372cf17952c2c2fe4b /src/preproc | |
parent | 2bfcebf32711adf0f7579ca08b3ad843e6145ce9 (diff) | |
download | groff-5291a235c550b0b9304a0b8db5069f9045b6dbf4.tar.gz |
* src/groff/preproc/pic/lex.cpp (table): Add box attributes
`xslanted' and `yslanted'.
* src/groff/preproc/pic/object.cpp (object_spec::object_spec):
Initialize `xslanted' and `yslanted'.
(graphic_object): Add methods `set_xlanted' and `set_yslanted'.
(closed_object): Ditto.
Add members `xslanted' and `yslanted'.
(box_object::print): Use them.
(object_spec::make_object): Handle slant values.
* src/groff/preproc/pic/object.h (IS_XSLANTED, IS_YSLANTED): New
constants.
(object_spec): Add members `xslanted' and `yslanted'.
* src/groff/preproc/pic/pic.y (XSLANTED, YSLANTED): New left-valued
tokens.
Add rules for them.
* src/groff/preproc/pic/pic.man, NEWS, doc/pic.ms: Document above
changes.
Diffstat (limited to 'src/preproc')
-rw-r--r-- | src/preproc/pic/lex.cpp | 6 | ||||
-rw-r--r-- | src/preproc/pic/object.cpp | 45 | ||||
-rw-r--r-- | src/preproc/pic/object.h | 52 | ||||
-rw-r--r-- | src/preproc/pic/pic.man | 16 | ||||
-rw-r--r-- | src/preproc/pic/pic.y | 15 |
5 files changed, 101 insertions, 33 deletions
diff --git a/src/preproc/pic/lex.cpp b/src/preproc/pic/lex.cpp index 17357ac6..b286e0f0 100644 --- a/src/preproc/pic/lex.cpp +++ b/src/preproc/pic/lex.cpp @@ -1,6 +1,6 @@ // -*- C++ -*- -/* Copyright (C) 1989, 1990, 1991, 1992, 2000, 2002, 2003, 2004, 2006 - Free Software Foundation, Inc. +/* Copyright (C) 1989, 1990, 1991, 1992, 2000, 2002, 2003, 2004, 2006, + 2007 Free Software Foundation, Inc. Written by James Clark (jjc@jclark.com) This file is part of groff. @@ -557,6 +557,8 @@ int lookup_keyword(const char *str, int len) { "wid", WIDTH }, { "width", WIDTH }, { "with", WITH }, + { "xslanted", XSLANTED }, + { "yslanted", YSLANTED }, }; const keyword *start = table; diff --git a/src/preproc/pic/object.cpp b/src/preproc/pic/object.cpp index 2eeb9cde..f16ab40c 100644 --- a/src/preproc/pic/object.cpp +++ b/src/preproc/pic/object.cpp @@ -413,6 +413,8 @@ object_spec::object_spec(object_type t) : type(t) segment_is_absolute = 0; text = 0; shaded = 0; + xslanted = 0; + yslanted = 0; outlined = 0; with = 0; dir = RIGHT_DIRECTION; @@ -565,6 +567,8 @@ public: void set_outline_color(char *); char *get_outline_color(); virtual void set_fill(double); + virtual void set_xslanted(double); + virtual void set_yslanted(double); virtual void set_fill_color(char *); }; @@ -594,6 +598,14 @@ void graphic_object::set_fill(double) { } +void graphic_object::set_xslanted(double) +{ +} + +void graphic_object::set_yslanted(double) +{ +} + void graphic_object::set_fill_color(char *c) { color_fill = strsave(c); @@ -701,14 +713,18 @@ public: closed_object(const position &); object_type type() = 0; void set_fill(double); + void set_xslanted(double); + void set_yslanted(double); void set_fill_color(char *fill); protected: double fill; // < 0 if not filled + double xslanted; // !=0 if x is slanted + double yslanted; // !=0 if y is slanted char *color_fill; // = 0 if not colored }; closed_object::closed_object(const position &pos) -: rectangle_object(pos), fill(-1.0), color_fill(0) +: rectangle_object(pos), fill(-1.0), xslanted(0), yslanted(0), color_fill(0) { } @@ -718,6 +734,19 @@ void closed_object::set_fill(double f) fill = f; } +/* accept positive and negative values */ +void closed_object::set_xslanted(double s) +{ + //assert(s >= 0.0); + xslanted = s; +} +/* accept positive and negative values */ +void closed_object::set_yslanted(double s) +{ + //assert(s >= 0.0); + yslanted = s; +} + void closed_object::set_fill_color(char *f) { color_fill = strsave(f); @@ -775,10 +804,12 @@ void box_object::print() if (xrad == 0.0) { distance dim2 = dim/2.0; position vec[4]; - vec[0] = cent + position(dim2.x, -dim2.y); - vec[1] = cent + position(dim2.x, dim2.y); - vec[2] = cent + position(-dim2.x, dim2.y); - vec[3] = cent + position(-dim2.x, -dim2.y); + /* error("x slanted %1", xslanted); */ + /* error("y slanted %1", yslanted); */ + vec[0] = cent + position(dim2.x, -(dim2.y - yslanted)); /* lr */ + vec[1] = cent + position(dim2.x + xslanted, dim2.y + yslanted); /* ur */ + vec[2] = cent + position(-(dim2.x - xslanted), dim2.y); /* ul */ + vec[3] = cent + position(-(dim2.x), -dim2.y); /* ll */ out->polygon(vec, 4, lt, fill); } else { @@ -1896,6 +1927,10 @@ object *object_spec::make_object(position *curpos, direction *dirp) obj->set_thickness(th); if (flags & IS_OUTLINED) obj->set_outline_color(outlined); + if (flags & IS_XSLANTED) + obj->set_xslanted(xslanted); + if (flags & IS_YSLANTED) + obj->set_yslanted(yslanted); if (flags & (IS_DEFAULT_FILLED | IS_FILLED)) { if (flags & IS_SHADED) obj->set_fill_color(shaded); diff --git a/src/preproc/pic/object.h b/src/preproc/pic/object.h index 9f7f4bc3..e87cc8bc 100644 --- a/src/preproc/pic/object.h +++ b/src/preproc/pic/object.h @@ -1,5 +1,5 @@ // -*- C++ -*- -/* Copyright (C) 1989, 1990, 1991, 1992, 2002, 2004 +/* Copyright (C) 1989, 1990, 1991, 1992, 2002, 2004, 2007 Free Software Foundation, Inc. Written by James Clark (jjc@jclark.com) @@ -133,29 +133,31 @@ struct text_item { ~text_item(); }; -const unsigned long IS_DOTTED = 01; -const unsigned long IS_DASHED = 02; -const unsigned long IS_CLOCKWISE = 04; -const unsigned long IS_INVISIBLE = 020; -const unsigned long HAS_LEFT_ARROW_HEAD = 040; -const unsigned long HAS_RIGHT_ARROW_HEAD = 0100; -const unsigned long HAS_SEGMENT = 0200; -const unsigned long IS_SAME = 0400; -const unsigned long HAS_FROM = 01000; -const unsigned long HAS_AT = 02000; -const unsigned long HAS_WITH = 04000; -const unsigned long HAS_HEIGHT = 010000; -const unsigned long HAS_WIDTH = 020000; -const unsigned long HAS_RADIUS = 040000; -const unsigned long HAS_TO = 0100000; -const unsigned long IS_CHOPPED = 0200000; -const unsigned long IS_DEFAULT_CHOPPED = 0400000; -const unsigned long HAS_THICKNESS = 01000000; -const unsigned long IS_FILLED = 02000000; -const unsigned long IS_DEFAULT_FILLED = 04000000; -const unsigned long IS_ALIGNED = 010000000; -const unsigned long IS_SHADED = 020000000; -const unsigned long IS_OUTLINED = 040000000; +const unsigned long IS_DOTTED = 01; +const unsigned long IS_DASHED = 02; +const unsigned long IS_CLOCKWISE = 04; +const unsigned long IS_INVISIBLE = 020; +const unsigned long HAS_LEFT_ARROW_HEAD = 040; +const unsigned long HAS_RIGHT_ARROW_HEAD = 0100; +const unsigned long HAS_SEGMENT = 0200; +const unsigned long IS_SAME = 0400; +const unsigned long HAS_FROM = 01000; +const unsigned long HAS_AT = 02000; +const unsigned long HAS_WITH = 04000; +const unsigned long HAS_HEIGHT = 010000; +const unsigned long HAS_WIDTH = 020000; +const unsigned long HAS_RADIUS = 040000; +const unsigned long HAS_TO = 0100000; +const unsigned long IS_CHOPPED = 0200000; +const unsigned long IS_DEFAULT_CHOPPED = 0400000; +const unsigned long HAS_THICKNESS = 01000000; +const unsigned long IS_FILLED = 02000000; +const unsigned long IS_DEFAULT_FILLED = 04000000; +const unsigned long IS_ALIGNED = 010000000; +const unsigned long IS_SHADED = 020000000; +const unsigned long IS_OUTLINED = 040000000; +const unsigned long IS_XSLANTED = 0100000000; +const unsigned long IS_YSLANTED = 0200000000; struct segment { int is_absolute; @@ -189,6 +191,8 @@ struct object_spec { double end_chop; double thickness; double fill; + double xslanted; + double yslanted; char *shaded; char *outlined; direction dir; diff --git a/src/preproc/pic/pic.man b/src/preproc/pic/pic.man index c54cfbef..9242d656 100644 --- a/src/preproc/pic/pic.man +++ b/src/preproc/pic/pic.man @@ -1,5 +1,6 @@ .ig -Copyright (C) 1989-2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. +Copyright (C) 1989-2000, 2001, 2002, 2003, 2004, 2007 + Free Software Foundation, Inc. Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice @@ -735,6 +736,17 @@ has a value of\ 0. A box with rounded corners can be dotted or dashed. . .LP +Boxes can have slanted sides. +This effectively changes the shape of a box from a rectangle to an +arbitrary parallelogram. +The +.B xslanted +and +.B yslanted +attributes specify the x and y\~offset of the box's upper right corner +from its default position. +. +.LP The .B .PS line can have a second argument specifying a maximum height for @@ -818,7 +830,7 @@ variable, nor by the width or height given in the line. . .LP -Boxes (including boxes with rounded corners), +Boxes (including boxes with rounded corners or slanted sides), circles and ellipses can be filled by giving them an attribute of .BR fill [ ed ]. This takes an optional argument of an expression with a value between diff --git a/src/preproc/pic/pic.y b/src/preproc/pic/pic.y index 2f838da3..2f0b31f9 100644 --- a/src/preproc/pic/pic.y +++ b/src/preproc/pic/pic.y @@ -197,6 +197,8 @@ char *do_sprintf(const char *form, const double *v, int nv); %token COLORED %token OUTLINED %token SHADED +%token XSLANTED +%token YSLANTED %token ALIGNED %token SPRINTF %token COMMAND @@ -221,6 +223,7 @@ box "foo" above ljust == box ("foo" above ljust) precedence than left and right, so that eg `line chop left' parses properly. */ %left CHOP SOLID DASHED DOTTED UP DOWN FILL COLORED OUTLINED +%left XSLANTED YSLANTED %left LABEL %left VARIABLE NUMBER '(' SIN COS ATAN2 LOG EXP SQRT K_MAX K_MIN INT RAND SRAND LAST @@ -935,6 +938,18 @@ object_spec: $$->flags |= IS_FILLED; $$->fill = $3; } + | object_spec XSLANTED expr + { + $$ = $1; + $$->flags |= IS_XSLANTED; + $$->xslanted = $3; + } + | object_spec YSLANTED expr + { + $$ = $1; + $$->flags |= IS_YSLANTED; + $$->yslanted = $3; + } | object_spec SHADED text { $$ = $1; |