28#include "../lout/msg.h"
47 Length backgroundPositionX,
48 Length backgroundPositionY,
49 int xDraw,
int yDraw,
int widthDraw,
50 int heightDraw,
int xRef,
int yRef,
51 int widthRef,
int heightRef,
52 bool *repeatX,
bool *repeatY,
53 int *origX,
int *origY,
54 int *tileX1,
int *tileX2,
int *tileY1,
55 int *tileY2,
bool *doDraw);
158 return this == otherAttrs ||
217 return (intptr_t)
font +
275 new container::typed::HashTable <StyleAttrs, Style> (
false,
false, 1024);
402 this == otherAttrs ||
408 strcmp (
name, otherAttrs->
name) == 0);
413 int h = object::String::hashValue (
name);
414 h = (h << 5) - h +
size;
415 h = (h << 5) - h +
weight;
416 h = (h << 5) - h +
style;
441 return layout->createFont (attrs, tryEverything);
474 int red = (
color >> 16) & 255;
475 int green = (
color >> 8) & 255;
476 int blue =
color & 255;
478 double oldLightness = ((double)
misc::max (red, green, blue)) / 255;
481 if (oldLightness > 0.8) {
483 newLightness = oldLightness - 0.2;
485 newLightness = oldLightness - 0.4;
486 }
else if (oldLightness < 0.2) {
488 newLightness = oldLightness + 0.4;
490 newLightness = oldLightness + 0.2;
492 newLightness = oldLightness + d * 0.2;
495 double f = (newLightness / oldLightness);
496 red = (int)(red * f);
497 green = (int)(green * f);
498 blue = (int)(blue * f);
500 red = green = blue = (int)(newLightness * 255);
503 return (red << 16) | (green << 8) | blue;
516 return color ^ 0xffffff;
533 return layout->createColor (col);
538 return layout->createTooltip (text);
587 if (
image->imgbufTiled) {
599 int w =
image->imgbufSrc->getRootWidth ();
600 int h =
image->imgbufSrc->getRootHeight ();
602 for (
int x = 0; x <
image->tilesX; x++)
603 for (
int y = 0; y <
image->tilesX; y++)
604 image->imgbufSrc->copyTo (
image->imgbufTiled, x * w, y * h,
655 if (readyToDraw () && (backgroundImage = getBackgroundImage ())) {
660 int imgHeight =
imgbuf->getRootHeight ();
662 int x, y, width, height;
663 getBgArea (&x, &y, &width, &height);
665 int xRef, yRef, widthRef, heightRef;
666 getRefArea (&xRef, &yRef, &widthRef, &heightRef);
668 bool repeatX, repeatY, doDraw;
669 int origX, origY, tileX1, tileX2, tileY1, tileY2;
672 getBackgroundRepeat (),
673 getBackgroundAttachment (),
674 getBackgroundPositionX (),
675 getBackgroundPositionY (),
676 x, y, width, height, xRef, yRef, widthRef,
677 heightRef, &repeatX, &repeatY, &origX,
678 &origY, &tileX1, &tileX2, &tileY1,
687 for (
int tileY = tileY1; tileY <= tileY2; tileY++) {
688 int x1 =
misc::max (origX + tileX1 * imgWidth, x);
689 int x2 =
misc::min (origX + (tileX2 + 1) * imgWidth, x + width);
691 int yt = origY + tileY * imgHeight + row;
692 if (yt >= y && yt < y + height)
693 draw (x1, yt, x2 - x1, 1);
702 if (readyToDraw ()) {
704 int x, y, width, height;
705 getBgArea (&x, &y, &width, &height);
706 draw (x, y, width, height);
720 Style *style = getStyle ();
726 Style *style = getStyle ();
733 Style *style = getStyle ();
739 Style *style = getStyle ();
745 Style *style = getStyle ();
759 int x1,
int y1,
int x2,
int y2)
764 const bool filled =
true, convex =
true;
765 bool ridge =
false, inset =
false, dotted =
false;
782 w, x1+w/2, y1+w/2, x2-w/2, y2+w/2);
796 points[1].
x = x2 + 1;
797 points[0].
y = points[1].
y = y1;
811 points[1].
x = x2 + 1;
812 points[0].
y = points[1].
y = y1;
839 points[1].
x = x2 + 1;
840 points[0].
y = points[1].
y = y1;
841 points[2].
x = points[1].
x - w_r;
842 points[3].
x = points[0].
x + w_l;
843 points[2].
y = points[3].
y = points[0].
y + w;
848 points[0].
y = points[1].
y = y1 + w + d;
859 int x1,
int y1,
int x2,
int y2)
864 const bool filled =
true, convex =
true;
865 bool ridge =
false, inset =
false, dotted =
false;
882 w, x1+w/2, y1-w/2, x2-w/2, y2-w/2);
895 points[0].
x = x1 - 1;
896 points[1].
x = x2 + 2;
897 points[0].
y = points[1].
y = y1 + 1;
911 points[0].
x = x1 - 1;
912 points[1].
x = x2 + 2 - d;
913 points[0].
y = points[1].
y = y1 + 1;
916 points[2].
y = points[3].
y = points[0].
y - w/2 - d;
923 points[0].
y = points[1].
y = y1 - w + 1;
926 points[2].
y = points[3].
y = points[0].
y + w/2;
940 points[0].
x = x2 + 2;
941 points[1].
x = x1 - 1;
942 points[0].
y = points[1].
y = y1 + 1;
943 points[2].
x = points[1].
x + w_l;
944 points[3].
x = points[0].
x - w_r;
945 points[2].
y = points[3].
y = points[0].
y - w;
950 points[0].
y = points[1].
y = y1 + 1 - w - d;
961 int x1,
int y1,
int x2,
int y2)
966 bool filled =
true, convex =
true;
967 bool ridge =
false, inset =
false, dotted =
false;
984 w, x1+w/2, y1+w/2, x1+w/2, y2-w/2);
996 points[0].
x = points[1].
x = x1;
997 points[0].
y = y1 - 1;
998 points[1].
y = y2 + 1;
1012 points[0].
x = points[1].
x = x1;
1015 points[2].
x = points[3].
x = x1 + w / 2 + d;
1021 points[0].
x = points[1].
x = x1 + w / 2 + d;
1024 points[2].
x = points[3].
x = x1 + w;
1040 points[0].
x = points[1].
x = x1;
1041 points[0].
y = y1 - 1;
1042 points[1].
y = y2 + 1;
1043 points[2].
x = points[3].
x = points[0].
x + w;
1044 points[2].
y = points[1].
y - w_b;
1045 points[3].
y = points[0].
y + w_t;
1048 points[0].
x = points[1].
x = x1 + w + d;
1051 points[2].
x = points[3].
x = points[0].
x + w;
1061 int x1,
int y1,
int x2,
int y2)
1066 const bool filled =
true, convex =
true;
1067 bool ridge =
false, inset =
false, dotted =
false;
1084 w, x1 - w/2, y1 + w/2, x1 - w/2, y2 - w/2);
1096 points[0].
x = points[1].
x = x1 + 1;
1097 points[0].
y = y1 - 1;
1098 points[1].
y = y2 + 1;
1112 points[0].
x = points[1].
x = x1 + 1;
1115 points[2].
x = points[3].
x = points[0].
x - w / 2 - d;
1121 points[0].
x = points[1].
x = x1 + 1 - w / 2 - d;
1124 points[2].
x = points[3].
x = x1 + 1 - w;
1140 points[0].
x = points[1].
x = x1 + 1;
1141 points[0].
y = y1 - 1;
1142 points[1].
y = y2 + 1;
1143 points[2].
x = points[3].
x = points[0].
x - w;
1144 points[2].
y = points[1].
y - w_b;
1145 points[3].
y = points[0].
y + w_t;
1148 points[0].
x = points[1].
x = x1 + 1 - w - d;
1151 points[2].
x = points[3].
x = points[0].
x - w;
1169 int x,
int y,
int width,
int height,
1170 Style *style,
bool inverse)
1173 int xb1, yb1, xb2, yb2;
1178 xb2 = x + (width > 0 ? width - 1 : 0) - style->
margin.
right;
1179 yb2 = y + (height > 0 ? height - 1 : 0) - style->
margin.
bottom;
1234 int x,
int y,
int width,
int height,
1235 int xRef,
int yRef,
int widthRef,
int heightRef,
1236 Style *style,
Color *bgColor,
bool inverse,
bool atTop)
1238 bool hasBgColor = bgColor != NULL &&
1241 (!atTop ||
layout->getBgColor () != bgColor);
1257 if (hasBgColor || hasBgImage) {
1261 bgArea.
width = width;
1269 true, intersection.
x, intersection.
y,
1278 intersection.
x, intersection.
y,
1280 xRef, yRef, widthRef, heightRef);
1289 Length backgroundPositionX,
1290 Length backgroundPositionY,
1291 int x,
int y,
int width,
int height,
1292 int xRef,
int yRef,
int widthRef,
int heightRef)
1298 bool repeatX, repeatY, doDraw;
1299 int origX, origY, tileX1, tileX2, tileY1, tileY2;
1302 backgroundAttachment, backgroundPositionX,
1303 backgroundPositionY, x, y, width, height,
1304 xRef, yRef, widthRef, heightRef,
1305 &repeatX, &repeatY, &origX, &origY,
1306 &tileX1, &tileX2, &tileY1, &tileY2, &doDraw);
1325 for (
int tileX = tileX1; tileX <= tileX2; tileX +=
tilesX)
1326 for (
int tileY = tileY1; tileY <= tileY2; tileY +=
tilesY) {
1327 int xt = origX + tileX * imgWidthS;
1329 int x2 =
misc::min (xt + imgWidthT, x + width);
1330 int yt = origY + tileY * imgHeightS;
1332 int y2 =
misc::min (yt + imgHeightT, y + height);
1334 view->
drawImage (imgbufT, xt, yt, x1 - xt, y1 - yt,
1343 Length backgroundPositionX,
1344 Length backgroundPositionY,
1345 int xDraw,
int yDraw,
int widthDraw,
1346 int heightDraw,
int xRef,
int yRef,
1347 int widthRef,
int heightRef,
bool *repeatX,
1348 bool *repeatY,
int *origX,
int *origY,
1349 int *tileX1,
int *tileX2,
int *tileY1,
1350 int *tileY2,
bool *doDraw)
1354 int imgHeight =
imgbuf->getRootHeight ();
1370 *tileX1 = xDraw < *origX ?
1371 - (*origX - xDraw + imgWidth - 1) / imgWidth :
1372 (xDraw - *origX) / imgWidth;
1373 *tileX2 = *origX < xDraw + widthDraw ?
1374 (xDraw + widthDraw - *origX - 1) / imgWidth :
1375 - (*origX - (xDraw + widthDraw) + imgWidth - 1) / imgWidth;
1376 *tileY1 = yDraw < *origY ?
1377 - (*origY - yDraw + imgHeight - 1) / imgHeight :
1378 (yDraw - *origY) / imgHeight;
1379 *tileY2 = *origY < yDraw + heightDraw ?
1380 (yDraw + heightDraw - *origY - 1) / imgHeight :
1381 - (*origY - (yDraw + heightDraw) + imgHeight - 1) / imgHeight;
1386 if (*tileX1 <= 0 && *tileX2 >= 0)
1388 *tileX1 = *tileX2 = 0;
1396 if (*tileY1 <= 0 && *tileY2 >= 0)
1397 *tileY1 = *tileY2 = 0;
1406 *
const roman_I0[] = {
"",
"I",
"II",
"III",
"IV",
"V",
"VI",
"VII",
"VIII",
"IX" },
1407 *
const roman_I1[] = {
"",
"X",
"XX",
"XXX",
"XL",
"L",
"LX",
"LXX",
"LXXX",
"XC" },
1408 *
const roman_I2[] = {
"",
"C",
"CC",
"CCC",
"CD",
"D",
"DC",
"DCC",
"DCCC",
"CM" },
1431 switch(listStyleType){
1439 i1 = i0/26 - 1; i2 = i1/26 - 1;
1441 snprintf(buf, buflen,
"****.");
1443 snprintf(buf, buflen,
"%c%c%c.",
1444 i2<0 ?
' ' : start_ch + i2%26,
1445 i1<0 ?
' ' : start_ch + i1%26,
1446 i0<0 ?
' ' : start_ch + i0%26);
1453 i1 = i0/10; i2 = i1/10; i3 = i2/10;
1454 i0 %= 10; i1 %= 10; i2 %= 10;
1455 if (num < 0 || i3 > 4)
1456 snprintf(buf, buflen,
"****.");
1463 snprintf(buf, buflen,
"%d.", num);
1468 buf[buflen - 1] =
'\0';
Implementation of ImgRenderer, which distributes all calls to a set of other implementations of ImgRe...
void put(ImgRenderer *child)
The platform independent interface for image buffers.
virtual int getRootWidth()=0
virtual int getRootHeight()=0
virtual Imgbuf * createSimilarBuf(int width, int height)=0
Creates an image buffer with same parameters (type, gamma etc.) except size.
The central class for managing and drawing a widget tree.
dw::core::Shape implemtation for simple rectangles.
bool intersectsWith(Rectangle *otherRect, Rectangle *dest)
Return whether this rectangle and otherRect intersect.
An interface to encapsulate platform dependent drawing.
virtual void drawImage(Imgbuf *imgbuf, int xRoot, int yRoot, int x, int y, int width, int height)=0
virtual void drawPolygon(style::Color *color, style::Color::Shading shading, bool filled, bool convex, Point *points, int npoints)=0
virtual void drawTypedLine(style::Color *color, style::Color::Shading shading, style::LineType type, int width, int x1, int y1, int x2, int y2)=0
virtual void drawLine(style::Color *color, style::Color::Shading shading, int x1, int y1, int x2, int y2)=0
virtual void drawRectangle(style::Color *color, style::Color::Shading shading, bool filled, int x, int y, int width, int height)=0
bool equals(lout::object::Object *other)
Returns, whether two objects are equal.
int hashValue()
Return a hash value for the object.
int shadeColor(int color, int d)
static Color * create(Layout *layout, int color)
bool equals(lout::object::Object *other)
Returns, whether two objects are equal.
int hashValue()
Return a hash value for the object.
static bool exists(Layout *layout, const char *name)
static Font * create(Layout *layout, FontAttrs *attrs)
void copyAttrs(FontAttrs *attrs)
static Font * create0(Layout *layout, FontAttrs *attrs, bool tryEverything)
ListStyleType listStyleType
ListStylePosition listStylePosition
TextTransform textTransform
StyleImage * backgroundImage
bool equals(lout::object::Object *other)
Returns, whether two objects are equal.
Length backgroundPositionY
BackgroundRepeat backgroundRepeat
struct dw::core::style::StyleAttrs::@20 borderColor
BackgroundAttachment backgroundAttachment
int hashValue()
Return a hash value for the object.
void setBorderStyle(BorderStyle val)
bool sizeDiffs(StyleAttrs *otherStyleAttrs)
This method returns whether something may change its size, when its style changes from this style to ...
void setBorderColor(Color *val)
BorderCollapse borderCollapse
struct dw::core::style::StyleAttrs::@21 borderStyle
void resetValues()
Reset those style attributes to their standard values, which are not inherited, according to CSS.
Length backgroundPositionX
void finish()
Called, when all image data has been retrieved.
void drawRow(int row)
Called, when data from a row is available and has been copied into the image buffer.
void fatal()
Called, when there are problems with the retrieval of image data.
void setBuffer(core::Imgbuf *buffer, bool resize)
Called, when an image buffer is attached.
void fatal()
Called, when there are problems with the retrieval of image data.
void setBuffer(core::Imgbuf *buffer, bool resize)
Called, when an image buffer is attached.
void drawRow(int row)
Called, when data from a row is available and has been copied into the image buffer.
void finish()
Called, when all image data has been retrieved.
int getTilesX(bool repeatX, bool repeatY)
Imgbuf * getImgbufTiled(bool repeatX, bool repeatY)
StyleImgRenderer * styleImgRenderer
int getTilesY(bool repeatX, bool repeatY)
ImgRendererDist * imgRendererDist
static lout::container::typed::HashTable< StyleAttrs, Style > * styleTable
void copyAttrs(StyleAttrs *attrs)
This is the base class for many other classes, which defines very common virtual methods.
#define DBG_OBJ_CREATE(klass)
#define DBG_OBJ_ASSOC(parent, child)
#define DBG_OBJ_ASSOC_CHILD(child)
char * dStrdup(const char *s)
static core::Imgbuf * imgbuf
@ LIST_STYLE_POSITION_OUTSIDE
static const char *const *const *const *const roman_I3[]
int multiplyWithPerLength(int x, Length l)
Multiply an int with a percentage length, returning int.
static const char *const roman_I0[]
@ BACKGROUND_ATTACHMENT_SCROLL
void drawBackground(View *view, Layout *layout, Rectangle *area, int x, int y, int width, int height, int xRef, int yRef, int widthRef, int heightRef, Style *style, Color *bgColor, bool inverse, bool atTop)
Draw the background (content plus padding) of a region in window, according to style.
@ LIST_STYLE_TYPE_LOWER_LATIN
@ LIST_STYLE_TYPE_UPPER_LATIN
@ LIST_STYLE_TYPE_UPPER_ALPHA
@ LIST_STYLE_TYPE_LOWER_ALPHA
@ LIST_STYLE_TYPE_UPPER_ROMAN
@ LIST_STYLE_TYPE_DECIMAL
@ LIST_STYLE_TYPE_LOWER_ROMAN
void drawBackgroundImage(View *view, StyleImage *backgroundImage, BackgroundRepeat backgroundRepeat, BackgroundAttachment backgroundAttachment, Length backgroundPositionX, Length backgroundPositionY, int x, int y, int width, int height, int xRef, int yRef, int widthRef, int heightRef)
static const char *const *const roman_I1[]
Length createPerLength(double v)
Returns a percentage, v is relative to 1, not to 100.
int Length
Type for representing all lengths within dw::core::style.
static const char *const *const *const roman_I2[]
void drawBorder(View *view, Layout *layout, Rectangle *area, int x, int y, int width, int height, Style *style, bool inverse)
Draw the border of a region in window, according to style.
static void drawBorderRight(View *view, Style *style, int x1, int y1, int x2, int y2)
static void drawBorderBottom(View *view, Style *style, int x1, int y1, int x2, int y2)
void numtostr(int num, char *buf, int buflen, ListStyleType listStyleType)
Convert a number into a string, in a given list style.
static void drawBorderTop(View *view, Style *style, int x1, int y1, int x2, int y2)
static void calcBackgroundRelatedValues(StyleImage *backgroundImage, BackgroundRepeat backgroundRepeat, BackgroundAttachment backgroundAttachment, Length backgroundPositionX, Length backgroundPositionY, int xDraw, int yDraw, int widthDraw, int heightDraw, int xRef, int yRef, int widthRef, int heightRef, bool *repeatX, bool *repeatY, int *origX, int *origY, int *tileX1, int *tileX2, int *tileY1, int *tileY2, bool *doDraw)
static void drawBorderLeft(View *view, Style *style, int x1, int y1, int x2, int y2)
@ Z_INDEX_AUTO
'z-index' is stored as int; use this for the value 'auto'.
bool isPerLength(Length l)
Returns true if l is a percentage.
const bool drawBackgroundLineByLine
static void strAsciiTolower(char *s)
int absLengthVal(Length l)
Returns the value of a length in pixels, as an integer.
@ LENGTH_AUTO
Represents "auto" lengths.
Dw is in this namespace, or sub namespaces of this one.