27#include "../lout/msg.h"
46 Length backgroundPositionX,
47 Length backgroundPositionY,
48 int xDraw,
int yDraw,
int widthDraw,
49 int heightDraw,
int xRef,
int yRef,
50 int widthRef,
int heightRef,
51 bool *repeatX,
bool *repeatY,
52 int *origX,
int *origY,
53 int *tileX1,
int *tileX2,
int *tileY1,
54 int *tileY2,
bool *doDraw);
157 return this == otherAttrs ||
216 return (intptr_t)
font +
274 new container::typed::HashTable <StyleAttrs, Style> (
false,
false, 1024);
401 this == otherAttrs ||
407 strcmp (
name, otherAttrs->
name) == 0);
412 int h = object::String::hashValue (
name);
413 h = (h << 5) - h +
size;
414 h = (h << 5) - h +
weight;
415 h = (h << 5) - h +
style;
440 return layout->createFont (attrs, tryEverything);
473 int red = (
color >> 16) & 255;
474 int green = (
color >> 8) & 255;
475 int blue =
color & 255;
477 double oldLightness = ((double)
misc::max (red, green, blue)) / 255;
480 if (oldLightness > 0.8) {
482 newLightness = oldLightness - 0.2;
484 newLightness = oldLightness - 0.4;
485 }
else if (oldLightness < 0.2) {
487 newLightness = oldLightness + 0.4;
489 newLightness = oldLightness + 0.2;
491 newLightness = oldLightness + d * 0.2;
494 double f = (newLightness / oldLightness);
495 red = (int)(red * f);
496 green = (int)(green * f);
497 blue = (int)(blue * f);
499 red = green = blue = (int)(newLightness * 255);
502 return (red << 16) | (green << 8) | blue;
515 return color ^ 0xffffff;
532 return layout->createColor (col);
537 return layout->createTooltip (text);
586 if (
image->imgbufTiled) {
598 int w =
image->imgbufSrc->getRootWidth ();
599 int h =
image->imgbufSrc->getRootHeight ();
601 for (
int x = 0; x <
image->tilesX; x++)
602 for (
int y = 0; y <
image->tilesX; y++)
603 image->imgbufSrc->copyTo (
image->imgbufTiled, x * w, y * h,
654 if (readyToDraw () && (backgroundImage = getBackgroundImage ())) {
659 int imgHeight =
imgbuf->getRootHeight ();
661 int x, y, width, height;
662 getBgArea (&x, &y, &width, &height);
664 int xRef, yRef, widthRef, heightRef;
665 getRefArea (&xRef, &yRef, &widthRef, &heightRef);
667 bool repeatX, repeatY, doDraw;
668 int origX, origY, tileX1, tileX2, tileY1, tileY2;
671 getBackgroundRepeat (),
672 getBackgroundAttachment (),
673 getBackgroundPositionX (),
674 getBackgroundPositionY (),
675 x, y, width, height, xRef, yRef, widthRef,
676 heightRef, &repeatX, &repeatY, &origX,
677 &origY, &tileX1, &tileX2, &tileY1,
686 for (
int tileY = tileY1; tileY <= tileY2; tileY++) {
687 int x1 =
misc::max (origX + tileX1 * imgWidth, x);
688 int x2 =
misc::min (origX + (tileX2 + 1) * imgWidth, x + width);
690 int yt = origY + tileY * imgHeight + row;
691 if (yt >= y && yt < y + height)
692 draw (x1, yt, x2 - x1, 1);
701 if (readyToDraw ()) {
703 int x, y, width, height;
704 getBgArea (&x, &y, &width, &height);
705 draw (x, y, width, height);
719 Style *style = getStyle ();
725 Style *style = getStyle ();
732 Style *style = getStyle ();
738 Style *style = getStyle ();
744 Style *style = getStyle ();
758 int x1,
int y1,
int x2,
int y2)
763 const bool filled =
true, convex =
true;
764 bool ridge =
false, inset =
false, dotted =
false;
781 w, x1+w/2, y1+w/2, x2-w/2, y2+w/2);
795 points[1].
x = x2 + 1;
796 points[0].
y = points[1].
y = y1;
810 points[1].
x = x2 + 1;
811 points[0].
y = points[1].
y = y1;
838 points[1].
x = x2 + 1;
839 points[0].
y = points[1].
y = y1;
840 points[2].
x = points[1].
x - w_r;
841 points[3].
x = points[0].
x + w_l;
842 points[2].
y = points[3].
y = points[0].
y + w;
847 points[0].
y = points[1].
y = y1 + w + d;
858 int x1,
int y1,
int x2,
int y2)
863 const bool filled =
true, convex =
true;
864 bool ridge =
false, inset =
false, dotted =
false;
881 w, x1+w/2, y1-w/2, x2-w/2, y2-w/2);
894 points[0].
x = x1 - 1;
895 points[1].
x = x2 + 2;
896 points[0].
y = points[1].
y = y1 + 1;
910 points[0].
x = x1 - 1;
911 points[1].
x = x2 + 2 - d;
912 points[0].
y = points[1].
y = y1 + 1;
915 points[2].
y = points[3].
y = points[0].
y - w/2 - d;
922 points[0].
y = points[1].
y = y1 - w + 1;
925 points[2].
y = points[3].
y = points[0].
y + w/2;
939 points[0].
x = x2 + 2;
940 points[1].
x = x1 - 1;
941 points[0].
y = points[1].
y = y1 + 1;
942 points[2].
x = points[1].
x + w_l;
943 points[3].
x = points[0].
x - w_r;
944 points[2].
y = points[3].
y = points[0].
y - w;
949 points[0].
y = points[1].
y = y1 + 1 - w - d;
960 int x1,
int y1,
int x2,
int y2)
965 bool filled =
true, convex =
true;
966 bool ridge =
false, inset =
false, dotted =
false;
983 w, x1+w/2, y1+w/2, x1+w/2, y2-w/2);
995 points[0].
x = points[1].
x = x1;
996 points[0].
y = y1 - 1;
997 points[1].
y = y2 + 1;
1011 points[0].
x = points[1].
x = x1;
1014 points[2].
x = points[3].
x = x1 + w / 2 + d;
1020 points[0].
x = points[1].
x = x1 + w / 2 + d;
1023 points[2].
x = points[3].
x = x1 + w;
1039 points[0].
x = points[1].
x = x1;
1040 points[0].
y = y1 - 1;
1041 points[1].
y = y2 + 1;
1042 points[2].
x = points[3].
x = points[0].
x + w;
1043 points[2].
y = points[1].
y - w_b;
1044 points[3].
y = points[0].
y + w_t;
1047 points[0].
x = points[1].
x = x1 + w + d;
1050 points[2].
x = points[3].
x = points[0].
x + w;
1060 int x1,
int y1,
int x2,
int y2)
1065 const bool filled =
true, convex =
true;
1066 bool ridge =
false, inset =
false, dotted =
false;
1083 w, x1 - w/2, y1 + w/2, x1 - w/2, y2 - w/2);
1095 points[0].
x = points[1].
x = x1 + 1;
1096 points[0].
y = y1 - 1;
1097 points[1].
y = y2 + 1;
1111 points[0].
x = points[1].
x = x1 + 1;
1114 points[2].
x = points[3].
x = points[0].
x - w / 2 - d;
1120 points[0].
x = points[1].
x = x1 + 1 - w / 2 - d;
1123 points[2].
x = points[3].
x = x1 + 1 - w;
1139 points[0].
x = points[1].
x = x1 + 1;
1140 points[0].
y = y1 - 1;
1141 points[1].
y = y2 + 1;
1142 points[2].
x = points[3].
x = points[0].
x - w;
1143 points[2].
y = points[1].
y - w_b;
1144 points[3].
y = points[0].
y + w_t;
1147 points[0].
x = points[1].
x = x1 + 1 - w - d;
1150 points[2].
x = points[3].
x = points[0].
x - w;
1168 int x,
int y,
int width,
int height,
1169 Style *style,
bool inverse)
1172 int xb1, yb1, xb2, yb2;
1177 xb2 = x + (width > 0 ? width - 1 : 0) - style->
margin.
right;
1178 yb2 = y + (height > 0 ? height - 1 : 0) - style->
margin.
bottom;
1233 int x,
int y,
int width,
int height,
1234 int xRef,
int yRef,
int widthRef,
int heightRef,
1235 Style *style,
Color *bgColor,
bool inverse,
bool atTop)
1237 bool hasBgColor = bgColor != NULL &&
1240 (!atTop ||
layout->getBgColor () != bgColor);
1256 if (hasBgColor || hasBgImage) {
1260 bgArea.
width = width;
1268 true, intersection.
x, intersection.
y,
1277 intersection.
x, intersection.
y,
1279 xRef, yRef, widthRef, heightRef);
1288 Length backgroundPositionX,
1289 Length backgroundPositionY,
1290 int x,
int y,
int width,
int height,
1291 int xRef,
int yRef,
int widthRef,
int heightRef)
1297 bool repeatX, repeatY, doDraw;
1298 int origX, origY, tileX1, tileX2, tileY1, tileY2;
1301 backgroundAttachment, backgroundPositionX,
1302 backgroundPositionY, x, y, width, height,
1303 xRef, yRef, widthRef, heightRef,
1304 &repeatX, &repeatY, &origX, &origY,
1305 &tileX1, &tileX2, &tileY1, &tileY2, &doDraw);
1324 for (
int tileX = tileX1; tileX <= tileX2; tileX +=
tilesX)
1325 for (
int tileY = tileY1; tileY <= tileY2; tileY +=
tilesY) {
1326 int xt = origX + tileX * imgWidthS;
1328 int x2 =
misc::min (xt + imgWidthT, x + width);
1329 int yt = origY + tileY * imgHeightS;
1331 int y2 =
misc::min (yt + imgHeightT, y + height);
1333 view->
drawImage (imgbufT, xt, yt, x1 - xt, y1 - yt,
1342 Length backgroundPositionX,
1343 Length backgroundPositionY,
1344 int xDraw,
int yDraw,
int widthDraw,
1345 int heightDraw,
int xRef,
int yRef,
1346 int widthRef,
int heightRef,
bool *repeatX,
1347 bool *repeatY,
int *origX,
int *origY,
1348 int *tileX1,
int *tileX2,
int *tileY1,
1349 int *tileY2,
bool *doDraw)
1353 int imgHeight =
imgbuf->getRootHeight ();
1369 *tileX1 = xDraw < *origX ?
1370 - (*origX - xDraw + imgWidth - 1) / imgWidth :
1371 (xDraw - *origX) / imgWidth;
1372 *tileX2 = *origX < xDraw + widthDraw ?
1373 (xDraw + widthDraw - *origX - 1) / imgWidth :
1374 - (*origX - (xDraw + widthDraw) + imgWidth - 1) / imgWidth;
1375 *tileY1 = yDraw < *origY ?
1376 - (*origY - yDraw + imgHeight - 1) / imgHeight :
1377 (yDraw - *origY) / imgHeight;
1378 *tileY2 = *origY < yDraw + heightDraw ?
1379 (yDraw + heightDraw - *origY - 1) / imgHeight :
1380 - (*origY - (yDraw + heightDraw) + imgHeight - 1) / imgHeight;
1385 if (*tileX1 <= 0 && *tileX2 >= 0)
1387 *tileX1 = *tileX2 = 0;
1395 if (*tileY1 <= 0 && *tileY2 >= 0)
1396 *tileY1 = *tileY2 = 0;
1405 *
const roman_I0[] = {
"",
"I",
"II",
"III",
"IV",
"V",
"VI",
"VII",
"VIII",
"IX" },
1406 *
const roman_I1[] = {
"",
"X",
"XX",
"XXX",
"XL",
"L",
"LX",
"LXX",
"LXXX",
"XC" },
1407 *
const roman_I2[] = {
"",
"C",
"CC",
"CCC",
"CD",
"D",
"DC",
"DCC",
"DCCC",
"CM" },
1430 switch(listStyleType){
1438 i1 = i0/26 - 1; i2 = i1/26 - 1;
1440 snprintf(buf, buflen,
"****.");
1442 snprintf(buf, buflen,
"%c%c%c.",
1443 i2<0 ?
' ' : start_ch + i2%26,
1444 i1<0 ?
' ' : start_ch + i1%26,
1445 i0<0 ?
' ' : start_ch + i0%26);
1452 i1 = i0/10; i2 = i1/10; i3 = i2/10;
1453 i0 %= 10; i1 %= 10; i2 %= 10;
1454 if (num < 0 || i3 > 4)
1455 snprintf(buf, buflen,
"****.");
1462 snprintf(buf, buflen,
"%d.", num);
1467 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 implementation 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.