Dillo v3.2.0-151-g90488cbf
Loading...
Searching...
No Matches
style.cc
Go to the documentation of this file.
1/*
2 * Dillo Widget
3 *
4 * Copyright 2005-2007 Sebastian Geerken <sgeerken@dillo.org>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#include <stdio.h>
21#include <string.h>
22#include <unistd.h>
23#include <math.h>
24
25#include "dlib/dlib.h"
26#include "core.hh"
27#include "../lout/msg.h"
28
29using namespace lout;
30
31namespace dw {
32namespace core {
33namespace style {
34
35const bool drawBackgroundLineByLine = false;
36
37const int MIN_BG_IMG_W = 10;
38const int MIN_BG_IMG_H = 10;
39const int OPT_BG_IMG_W = 50;
40const int OPT_BG_IMG_H = 50;
41
42static void calcBackgroundRelatedValues (StyleImage *backgroundImage,
43 BackgroundRepeat backgroundRepeat,
45 backgroundAttachment,
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);
55
98
135
150{
151 return false;
152}
153
155 StyleAttrs *otherAttrs = (StyleAttrs *) other;
156
157 return this == otherAttrs ||
158 (font == otherAttrs->font &&
159 textDecoration == otherAttrs->textDecoration &&
160 color == otherAttrs->color &&
161 backgroundColor == otherAttrs->backgroundColor &&
162 backgroundImage == otherAttrs->backgroundImage &&
163 backgroundRepeat == otherAttrs->backgroundRepeat &&
167 textAlign == otherAttrs->textAlign &&
168 valign == otherAttrs->valign &&
169 textAlignChar == otherAttrs->textAlignChar &&
170 textTransform == otherAttrs->textTransform &&
171 vloat == otherAttrs->vloat &&
172 clear == otherAttrs->clear &&
173 overflow == otherAttrs->overflow &&
174 position == otherAttrs->position &&
175 top == otherAttrs->top &&
176 bottom == otherAttrs->bottom &&
177 left == otherAttrs->left &&
178 right == otherAttrs->right &&
179 hBorderSpacing == otherAttrs->hBorderSpacing &&
180 vBorderSpacing == otherAttrs->vBorderSpacing &&
181 wordSpacing == otherAttrs->wordSpacing &&
182 width == otherAttrs->width &&
183 height == otherAttrs->height &&
184 minWidth == otherAttrs->minWidth &&
185 maxWidth == otherAttrs->maxWidth &&
186 minHeight == otherAttrs->minHeight &&
187 maxHeight == otherAttrs->maxHeight &&
188 lineHeight == otherAttrs->lineHeight &&
189 textIndent == otherAttrs->textIndent &&
190 margin.equals (&otherAttrs->margin) &&
191 borderWidth.equals (&otherAttrs->borderWidth) &&
192 padding.equals (&otherAttrs->padding) &&
193 borderCollapse == otherAttrs->borderCollapse &&
194 borderColor.top == otherAttrs->borderColor.top &&
195 borderColor.right == otherAttrs->borderColor.right &&
196 borderColor.bottom == otherAttrs->borderColor.bottom &&
197 borderColor.left == otherAttrs->borderColor.left &&
198 borderStyle.top == otherAttrs->borderStyle.top &&
199 borderStyle.right == otherAttrs->borderStyle.right &&
200 borderStyle.bottom == otherAttrs->borderStyle.bottom &&
201 borderStyle.left == otherAttrs->borderStyle.left &&
202 display == otherAttrs->display &&
203 whiteSpace == otherAttrs->whiteSpace &&
204 listStylePosition == otherAttrs->listStylePosition &&
205 listStyleType == otherAttrs->listStyleType &&
206 cursor == otherAttrs->cursor &&
207 zIndex == otherAttrs->zIndex &&
208 x_link == otherAttrs->x_link &&
209 x_lang[0] == otherAttrs->x_lang[0] &&
210 x_lang[1] == otherAttrs->x_lang[1] &&
211 x_img == otherAttrs->x_img &&
212 x_tooltip == otherAttrs->x_tooltip);
213}
214
216 return (intptr_t) font +
218 (intptr_t) color +
219 (intptr_t) backgroundColor +
220 (intptr_t) backgroundImage +
225 textAlign +
226 valign +
229 vloat +
230 clear +
231 overflow +
232 position +
233 top +
234 bottom +
235 left +
236 right +
240 width +
241 height +
242 minWidth +
243 maxWidth +
244 minHeight +
245 maxHeight +
246 lineHeight +
247 textIndent +
248 margin.hashValue () +
250 padding.hashValue () +
252 (intptr_t) borderColor.top +
253 (intptr_t) borderColor.right +
254 (intptr_t) borderColor.bottom +
255 (intptr_t) borderColor.left +
256 borderStyle.top +
257 borderStyle.right +
258 borderStyle.bottom +
259 borderStyle.left +
260 display +
261 whiteSpace +
264 cursor +
265 zIndex +
266 x_link +
267 x_lang[0] + x_lang[1] +
268 x_img +
269 (intptr_t) x_tooltip;
270}
271
272int Style::totalRef = 0;
273container::typed::HashTable <StyleAttrs, Style> * Style::styleTable =
274 new container::typed::HashTable <StyleAttrs, Style> (false, false, 1024);
275
277{
278 DBG_OBJ_CREATE ("dw::core::style::Style");
279
280 copyAttrs (attrs);
281
290 //DBG_OBJ_ASSOC_CHILD (x_tooltip);
291
292 refCount = 1;
293
294 font->ref ();
295 if (color)
296 color->ref ();
297 if (backgroundColor)
299 if (backgroundImage)
301 if (borderColor.top)
302 borderColor.top->ref();
303 if (borderColor.bottom)
304 borderColor.bottom->ref();
305 if (borderColor.left)
306 borderColor.left->ref();
307 if (borderColor.right)
308 borderColor.right->ref();
309 if (x_tooltip)
310 x_tooltip->ref();
311
312 totalRef++;
313}
314
316{
317 font->unref ();
318
319 if (color)
320 color->unref ();
321 if (backgroundColor)
323 if (backgroundImage)
325 if (borderColor.top)
326 borderColor.top->unref();
327 if (borderColor.bottom)
328 borderColor.bottom->unref();
329 if (borderColor.left)
330 borderColor.left->unref();
331 if (borderColor.right)
332 borderColor.right->unref();
333 if (x_tooltip)
334 x_tooltip->unref();
335
336 styleTable->remove (this);
337 totalRef--;
338
340}
341
343{
344 font = attrs->font;
346 color = attrs->color;
353 textAlign = attrs->textAlign;
354 valign = attrs->valign;
357 vloat = attrs->vloat;
358 clear = attrs->clear;
359 overflow = attrs->overflow;
360 position = attrs->position;
361 top = attrs->top;
362 bottom = attrs->bottom;
363 left = attrs->left;
364 right = attrs->right;
367 wordSpacing = attrs->wordSpacing;
368 width = attrs->width;
369 height = attrs->height;
370 lineHeight = attrs->lineHeight;
371 textIndent = attrs->textIndent;
372 minWidth = attrs->minWidth;
373 maxWidth = attrs->maxWidth;
374 minHeight = attrs->minHeight;
375 maxHeight = attrs->maxHeight;
376 margin = attrs->margin;
377 borderWidth = attrs->borderWidth;
378 padding = attrs->padding;
380 borderColor = attrs->borderColor;
381 borderStyle = attrs->borderStyle;
382 display = attrs->display;
383 whiteSpace = attrs->whiteSpace;
386 cursor = attrs->cursor;
387 zIndex = attrs->zIndex;
388 x_link = attrs->x_link;
389 x_lang[0] = attrs->x_lang[0];
390 x_lang[1] = attrs->x_lang[1];
391 x_img = attrs->x_img;
392 x_tooltip = attrs->x_tooltip;
393}
394
395// ----------------------------------------------------------------------
396
398{
399 FontAttrs *otherAttrs = (FontAttrs*)other;
400 return
401 this == otherAttrs ||
402 (size == otherAttrs->size &&
403 weight == otherAttrs->weight &&
404 style == otherAttrs->style &&
405 letterSpacing == otherAttrs->letterSpacing &&
406 fontVariant == otherAttrs->fontVariant &&
407 strcmp (name, otherAttrs->name) == 0);
408}
409
411{
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;
416 h = (h << 5) - h + letterSpacing;
417 h = (h << 5) - h + fontVariant;
418 return h;
419}
420
422{
423 free ((char*)name);
425}
426
428{
429 name = dStrdup (attrs->name);
430 size = attrs->size;
431 weight = attrs->weight;
432 style = attrs->style;
434 fontVariant = attrs->fontVariant;
435}
436
438 bool tryEverything)
439{
440 return layout->createFont (attrs, tryEverything);
441}
442
444{
445 return create0 (layout, attrs, false);
446}
447
448bool Font::exists (Layout *layout, const char *name)
449{
450 return layout->fontExists (name);
451}
452
453// ----------------------------------------------------------------------
454
456{
457 ColorAttrs *oc = (ColorAttrs*)other;
458 return this == oc || (color == oc->color);
459}
460
462{
463 return color;
464}
465
467{
469}
470
471int Color::shadeColor (int color, int d)
472{
473 int red = (color >> 16) & 255;
474 int green = (color >> 8) & 255;
475 int blue = color & 255;
476
477 double oldLightness = ((double) misc::max (red, green, blue)) / 255;
478 double newLightness;
479
480 if (oldLightness > 0.8) {
481 if (d > 0)
482 newLightness = oldLightness - 0.2;
483 else
484 newLightness = oldLightness - 0.4;
485 } else if (oldLightness < 0.2) {
486 if (d > 0)
487 newLightness = oldLightness + 0.4;
488 else
489 newLightness = oldLightness + 0.2;
490 } else
491 newLightness = oldLightness + d * 0.2;
492
493 if (oldLightness) {
494 double f = (newLightness / oldLightness);
495 red = (int)(red * f);
496 green = (int)(green * f);
497 blue = (int)(blue * f);
498 } else {
499 red = green = blue = (int)(newLightness * 255);
500 }
501
502 return (red << 16) | (green << 8) | blue;
503}
504
505int Color::shadeColor (int color, Shading shading)
506{
507 switch (shading) {
508 case SHADING_NORMAL:
509 return color;
510
511 case SHADING_LIGHT:
512 return shadeColor(color, +1);
513
514 case SHADING_INVERSE:
515 return color ^ 0xffffff;
516
517 case SHADING_DARK:
518 return shadeColor(color, -1);
519
520 default:
521 // compiler happiness
523 return -1;
524 }
525}
526
527
529{
530 ColorAttrs attrs(col);
531
532 return layout->createColor (col);
533}
534
536{
537 return layout->createTooltip (text);
538}
539
540// ----------------------------------------------------------------------
541
543{
544 if (image->imgbufSrc)
545 image->imgbufSrc->unref ();
546 if (image->imgbufTiled)
548
549 image->imgbufTiled = NULL;
550
551 image->imgbufSrc = buffer;
553
554 if (image->imgbufSrc) {
555 image->imgbufSrc->ref ();
556
557 // If the image is too small, drawing a background will cause
558 // many calls of View::drawImgbuf. For this reason, we create
559 // another image buffer, the "tiled" image buffer, which is
560 // larger (the "optimal" size is defined as OPT_BG_IMG_W *
561 // OPT_BG_IMG_H) and contains the "source" buffer several times.
562 //
563 // This "tiled" buffer is not used when 'background-repeat' has
564 // another value than 'repeat', for obvious reasons. Image
565 // buffers only "tiled" in one dimension (to optimize 'repeat-x'
566 // and 'repeat-y') are not supported.
567
570 image->tilesX =
572 image->tilesY =
578
580 }
581 }
582}
583
585{
586 if (image->imgbufTiled) {
587 // A row of data has been copied to the source buffer, here it
588 // is copied into the tiled buffer.
589
590 // Unfortunately, this code may be called *after* some other
591 // implementations of ImgRenderer::drawRow, which actually
592 // *draw* the tiled buffer, which is so not up to date
593 // (ImgRendererDist does not define an order). OTOH, these
594 // drawing implementations calle Widget::queueResize, so the
595 // actual drawing (and so access to the tiled buffer) is done
596 // later.
597
598 int w = image->imgbufSrc->getRootWidth ();
599 int h = image->imgbufSrc->getRootHeight ();
600
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,
604 0, row, w, 1);
605 }
606}
607
609{
610 // Nothing to do.
611}
612
614{
615 // Nothing to do.
616}
617
619{
620 DBG_OBJ_CREATE ("dw::core::style::StyleImage");
621
622 refCount = 0;
623 imgbufSrc = NULL;
624 imgbufTiled = NULL;
625
629}
630
632{
633 if (imgbufSrc)
634 imgbufSrc->unref ();
635 if (imgbufTiled)
636 imgbufTiled->unref ();
637
638 delete imgRendererDist;
639 delete styleImgRenderer;
640
642}
643
645 bool resize)
646{
647 // Nothing to do?
648}
649
651{
653 StyleImage *backgroundImage;
654 if (readyToDraw () && (backgroundImage = getBackgroundImage ())) {
655 // All single rows are drawn.
656
657 Imgbuf *imgbuf = backgroundImage->getImgbufSrc();
658 int imgWidth = imgbuf->getRootWidth ();
659 int imgHeight = imgbuf->getRootHeight ();
660
661 int x, y, width, height;
662 getBgArea (&x, &y, &width, &height);
663
664 int xRef, yRef, widthRef, heightRef;
665 getRefArea (&xRef, &yRef, &widthRef, &heightRef);
666
667 bool repeatX, repeatY, doDraw;
668 int origX, origY, tileX1, tileX2, tileY1, tileY2;
669
670 calcBackgroundRelatedValues (backgroundImage,
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,
678 &tileY2, &doDraw);
679
680 //printf ("tileX1 = %d, tileX2 = %d, tileY1 = %d, tileY2 = %d\n",
681 // tileX1, tileX2, tileY1, tileY2);
682
683 if (doDraw)
684 // Only iterate over y, because the rows can be combined
685 // horizontally.
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);
689
690 int yt = origY + tileY * imgHeight + row;
691 if (yt >= y && yt < y + height)
692 draw (x1, yt, x2 - x1, 1);
693 }
694 }
695 }
696}
697
699{
701 if (readyToDraw ()) {
702 // Draw total area, as a whole.
703 int x, y, width, height;
704 getBgArea (&x, &y, &width, &height);
705 draw (x, y, width, height);
706 }
707 }
708}
709
711{
712 // Nothing to do.
713}
714
715// ----------------------------------------------------------------------
716
718{
719 Style *style = getStyle ();
720 return style ? style->backgroundImage : NULL;
721}
722
728
735
737{
738 Style *style = getStyle ();
739 return style ? style->backgroundPositionX : createPerLength (0);
740}
741
743{
744 Style *style = getStyle ();
745 return style ? style->backgroundPositionY : createPerLength (0);
746}
747
748// ----------------------------------------------------------------------
749
750/*
751 * The drawBorder{Top,Bottom,Left,Right} functions are similar. They
752 * use a trapezium as draw polygon, or drawTypedLine() for dots and dashes.
753 * Although the concept is simple, achieving pixel accuracy is laborious [1].
754 *
755 * [1] https://dillo-browser.github.io/old/css_compat/tests/border-style.html
756 */
757static void drawBorderTop(View *view, Style *style,
758 int x1, int y1, int x2, int y2)
759
760{
761 int d, w;
762 Point points[4];
763 const bool filled = true, convex = true;
764 bool ridge = false, inset = false, dotted = false;
766
767 if (!style->borderColor.top || style->borderWidth.top == 0)
768 return;
769
770 switch (style->borderStyle.top) {
771 case BORDER_NONE:
772 case BORDER_HIDDEN:
773 break;
774 case BORDER_DOTTED:
775 dotted = true;
776 /* fallthrough */
777 case BORDER_DASHED:
778 w = style->borderWidth.top;
779 view->drawTypedLine(style->borderColor.top, shading,
780 dotted ? LINE_DOTTED : LINE_DASHED,
781 w, x1+w/2, y1+w/2, x2-w/2, y2+w/2);
782 break;
783 case BORDER_SOLID:
784 case BORDER_INSET:
785 inset = true;
786 /* fallthrough */
787 case BORDER_OUTSET:
788 if (style->borderStyle.top != BORDER_SOLID)
789 shading = (inset) ? Color::SHADING_DARK : Color::SHADING_LIGHT;
790
791 if (style->borderWidth.top == 1) {
792 view->drawLine(style->borderColor.top, shading, x1, y1, x2, y2);
793 } else {
794 points[0].x = x1;
795 points[1].x = x2 + 1;
796 points[0].y = points[1].y = y1;
797 points[2].x = points[1].x - style->borderWidth.right;
798 points[3].x = x1 + style->borderWidth.left;
799 points[2].y = points[3].y = points[0].y + style->borderWidth.top;
800 view->drawPolygon (style->borderColor.top, shading, filled, convex,
801 points, 4);
802 }
803 break;
804 case BORDER_RIDGE:
805 ridge = true;
806 /* fallthrough */
807 case BORDER_GROOVE:
808 d = style->borderWidth.top & 1;
809 points[0].x = x1;
810 points[1].x = x2 + 1;
811 points[0].y = points[1].y = y1;
812 points[2].x = x2 - style->borderWidth.right / 2;
813 points[3].x = x1 + style->borderWidth.left / 2;
814 points[2].y = points[3].y = y1 + style->borderWidth.top / 2 + d;
815 shading = (ridge) ? Color::SHADING_LIGHT : Color::SHADING_DARK;
816 view->drawPolygon (style->borderColor.top, shading, filled, convex,
817 points, 4);
818 points[0].x = x1 + style->borderWidth.left / 2 + d;
819 points[1].x = x2 - style->borderWidth.right / 2 + 1 - d;
820 points[0].y = points[1].y = y1 + style->borderWidth.top / 2 + d;
821 points[2].x = x2 - style->borderWidth.right + 1 - d;
822 points[3].x = x1 + style->borderWidth.left;
823 points[2].y = points[3].y = y1 + style->borderWidth.top;
824 shading = (ridge) ? Color::SHADING_DARK : Color::SHADING_LIGHT;
825 view->drawPolygon (style->borderColor.top, shading, filled, convex,
826 points, 4);
827 break;
828 case BORDER_DOUBLE:
829 w = (int) rint(style->borderWidth.top / 3.0);
830 d = w ? style->borderWidth.top - 2 * w : 0;
831 int w_l = (int) rint(style->borderWidth.left / 3.0);
832 int w_r = (int) rint(style->borderWidth.right / 3.0);
833 if (style->borderWidth.top == 1) {
834 view->drawLine(style->borderColor.top, shading, x1, y1, x2, y2);
835 break;
836 }
837 points[0].x = x1;
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;
843 view->drawPolygon (style->borderColor.top, shading, filled, convex,
844 points, 4);
845 points[0].x = x1 + style->borderWidth.left - w_l;
846 points[1].x = x2 + 1 - style->borderWidth.right + w_r;
847 points[0].y = points[1].y = y1 + w + d;
848 points[2].x = x2 + 1 - style->borderWidth.right;
849 points[3].x = x1 + style->borderWidth.left;
850 points[2].y = points[3].y = y1 + style->borderWidth.top;
851 view->drawPolygon (style->borderColor.top, shading, filled, convex,
852 points, 4);
853 break;
854 }
855}
856
857static void drawBorderBottom(View *view, Style *style,
858 int x1, int y1, int x2, int y2)
859
860{
861 int d, w;
862 Point points[4];
863 const bool filled = true, convex = true;
864 bool ridge = false, inset = false, dotted = false;
866
867 if (!style->borderColor.bottom || style->borderWidth.bottom == 0)
868 return;
869
870 switch (style->borderStyle.bottom) {
871 case BORDER_NONE:
872 case BORDER_HIDDEN:
873 break;
874 case BORDER_DOTTED:
875 dotted = true;
876 /* fallthrough */
877 case BORDER_DASHED:
878 w = style->borderWidth.bottom;
879 view->drawTypedLine(style->borderColor.bottom, shading,
880 dotted ? LINE_DOTTED : LINE_DASHED,
881 w, x1+w/2, y1-w/2, x2-w/2, y2-w/2);
882 break;
883 case BORDER_SOLID:
884 case BORDER_INSET:
885 inset = true;
886 /* fallthrough */
887 case BORDER_OUTSET:
888 if (style->borderStyle.bottom != BORDER_SOLID)
889 shading = (inset) ? Color::SHADING_LIGHT : Color::SHADING_DARK;
890
891 if (style->borderWidth.bottom == 1) { /* 1 pixel line */
892 view->drawLine(style->borderColor.bottom, shading, x1, y1, x2, y2);
893 } else {
894 points[0].x = x1 - 1;
895 points[1].x = x2 + 2;
896 points[0].y = points[1].y = y1 + 1;
897 points[2].x = points[1].x - style->borderWidth.right;
898 points[3].x = points[0].x + style->borderWidth.left;
899 points[2].y = points[3].y = points[0].y-style->borderWidth.bottom;
900 view->drawPolygon (style->borderColor.bottom, shading, filled, convex,
901 points, 4);
902 }
903 break;
904 case BORDER_RIDGE:
905 ridge = true;
906 /* fallthrough */
907 case BORDER_GROOVE:
908 w = style->borderWidth.bottom;
909 d = w & 1;
910 points[0].x = x1 - 1;
911 points[1].x = x2 + 2 - d;
912 points[0].y = points[1].y = y1 + 1;
913 points[2].x = points[1].x - style->borderWidth.right / 2;
914 points[3].x = points[0].x + style->borderWidth.left / 2 + d;
915 points[2].y = points[3].y = points[0].y - w/2 - d;
916 shading = (ridge) ? Color::SHADING_DARK : Color::SHADING_LIGHT;
917 view->drawPolygon (style->borderColor.bottom, shading, filled, convex,
918 points, 4);
919 // clockwise
920 points[0].x = x1 + style->borderWidth.left - 1;
921 points[1].x = x2 + 1 - style->borderWidth.right + 1;
922 points[0].y = points[1].y = y1 - w + 1;
923 points[2].x = points[1].x + style->borderWidth.right / 2;
924 points[3].x = points[0].x - style->borderWidth.left / 2;
925 points[2].y = points[3].y = points[0].y + w/2;
926 shading = (ridge) ? Color::SHADING_LIGHT : Color::SHADING_DARK;
927 view->drawPolygon (style->borderColor.bottom, shading, filled, convex,
928 points, 4);
929 break;
930 case BORDER_DOUBLE:
931 w = (int) rint(style->borderWidth.bottom / 3.0);
932 d = w ? style->borderWidth.bottom - 2 * w : 0;
933 int w_l = (int) rint(style->borderWidth.left / 3.0);
934 int w_r = (int) rint(style->borderWidth.right / 3.0);
935 if (style->borderWidth.bottom == 1) {
936 view->drawLine(style->borderColor.bottom, shading, x1, y1, x2, y2);
937 break;
938 }
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;
945 view->drawPolygon (style->borderColor.bottom, shading, filled, convex,
946 points, 4);
947 points[0].x = x2 + 2 - style->borderWidth.right + w_r;
948 points[1].x = x1 - 1 + style->borderWidth.left - w_l;
949 points[0].y = points[1].y = y1 + 1 - w - d;
950 points[2].x = x1 - 1 + style->borderWidth.left;
951 points[3].x = x2 + 2 - style->borderWidth.right;
952 points[2].y = points[3].y = y1 + 1 - style->borderWidth.bottom;
953 view->drawPolygon (style->borderColor.bottom, shading, filled, convex,
954 points, 4);
955 break;
956 }
957}
958
959static void drawBorderLeft(View *view, Style *style,
960 int x1, int y1, int x2, int y2)
961
962{
963 int d, w;
964 Point points[4];
965 bool filled = true, convex = true;
966 bool ridge = false, inset = false, dotted = false;
968
969 if (!style->borderColor.left || style->borderWidth.left == 0)
970 return;
971
972 switch (style->borderStyle.left) {
973 case BORDER_NONE:
974 case BORDER_HIDDEN:
975 break;
976 case BORDER_DOTTED:
977 dotted = true;
978 /* fallthrough */
979 case BORDER_DASHED:
980 w = style->borderWidth.left;
981 view->drawTypedLine(style->borderColor.left, shading,
982 dotted ? LINE_DOTTED : LINE_DASHED,
983 w, x1+w/2, y1+w/2, x1+w/2, y2-w/2);
984 break;
985 case BORDER_SOLID:
986 case BORDER_INSET:
987 inset = true;
988 /* fallthrough */
989 case BORDER_OUTSET:
990 if (style->borderStyle.left != BORDER_SOLID)
991 shading = (inset) ? Color::SHADING_DARK : Color::SHADING_LIGHT;
992 if (style->borderWidth.left == 1) { /* 1 pixel line */
993 view->drawLine(style->borderColor.left, shading, x1, y1, x2, y2);
994 } else {
995 points[0].x = points[1].x = x1;
996 points[0].y = y1 - 1;
997 points[1].y = y2 + 1;
998 points[2].x = points[3].x = points[0].x + style->borderWidth.left;
999 points[2].y = points[1].y - style->borderWidth.bottom;
1000 points[3].y = points[0].y + style->borderWidth.top;
1001 view->drawPolygon (style->borderColor.left, shading, filled, convex,
1002 points, 4);
1003 }
1004 break;
1005 case BORDER_RIDGE:
1006 ridge = true;
1007 /* fallthrough */
1008 case BORDER_GROOVE:
1009 w = style->borderWidth.left;
1010 d = w & 1;
1011 points[0].x = points[1].x = x1;
1012 points[0].y = y1;
1013 points[1].y = y2;
1014 points[2].x = points[3].x = x1 + w / 2 + d;
1015 points[2].y = y2 - style->borderWidth.bottom / 2;
1016 points[3].y = y1 + style->borderWidth.top / 2;
1017 shading = (ridge) ? Color::SHADING_LIGHT : Color::SHADING_DARK;
1018 view->drawPolygon (style->borderColor.left, shading, filled, convex,
1019 points, 4);
1020 points[0].x = points[1].x = x1 + w / 2 + d;
1021 points[0].y = y1 + style->borderWidth.top / 2;
1022 points[1].y = y2 - style->borderWidth.bottom / 2;
1023 points[2].x = points[3].x = x1 + w;
1024 points[2].y = y2 - style->borderWidth.bottom;
1025 points[3].y = y1 + style->borderWidth.top;
1026 shading = (ridge) ? Color::SHADING_DARK : Color::SHADING_LIGHT;
1027 view->drawPolygon (style->borderColor.left, shading, filled, convex,
1028 points, 4);
1029 break;
1030 case BORDER_DOUBLE:
1031 w = (int) rint(style->borderWidth.left / 3.0);
1032 d = w ? style->borderWidth.left - 2 * w : 0;
1033 int w_b = (int) rint(style->borderWidth.bottom / 3.0);
1034 int w_t = (int) rint(style->borderWidth.top / 3.0);
1035 if (style->borderWidth.left == 1) {
1036 view->drawLine(style->borderColor.left, shading, x1, y1, x2, y2-1);
1037 break;
1038 }
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;
1045 view->drawPolygon (style->borderColor.left, shading, filled, convex,
1046 points, 4);
1047 points[0].x = points[1].x = x1 + w + d;
1048 points[0].y = y1 - 1 + style->borderWidth.top - w_t;
1049 points[1].y = y2 + 1 - style->borderWidth.bottom + w_b;
1050 points[2].x = points[3].x = points[0].x + w;
1051 points[2].y = y2 + 1 - style->borderWidth.bottom;
1052 points[3].y = y1 - 1 + style->borderWidth.top;
1053 view->drawPolygon (style->borderColor.left, shading, filled, convex,
1054 points, 4);
1055 break;
1056 }
1057}
1058
1059static void drawBorderRight(View *view, Style *style,
1060 int x1, int y1, int x2, int y2)
1061
1062{
1063 int d, w;
1064 Point points[4];
1065 const bool filled = true, convex = true;
1066 bool ridge = false, inset = false, dotted = false;
1068
1069 if (!style->borderColor.right || style->borderWidth.right == 0)
1070 return;
1071
1072 switch (style->borderStyle.right) {
1073 case BORDER_NONE:
1074 case BORDER_HIDDEN:
1075 break;
1076 case BORDER_DOTTED:
1077 dotted = true;
1078 /* fallthrough */
1079 case BORDER_DASHED:
1080 w = style->borderWidth.right;
1081 view->drawTypedLine(style->borderColor.right, shading,
1082 dotted ? LINE_DOTTED : LINE_DASHED,
1083 w, x1 - w/2, y1 + w/2, x1 - w/2, y2 - w/2);
1084 break;
1085 case BORDER_SOLID:
1086 case BORDER_INSET:
1087 inset = true;
1088 /* fallthrough */
1089 case BORDER_OUTSET:
1090 if (style->borderStyle.right != BORDER_SOLID)
1091 shading = (inset) ? Color::SHADING_LIGHT : Color::SHADING_DARK;
1092 if (style->borderWidth.right == 1) { /* 1 pixel line */
1093 view->drawLine(style->borderColor.right, shading, x1, y1, x2, y2);
1094 } else {
1095 points[0].x = points[1].x = x1 + 1;
1096 points[0].y = y1 - 1;
1097 points[1].y = y2 + 1;
1098 points[2].x = points[3].x = points[0].x-style->borderWidth.right;
1099 points[2].y = points[1].y - style->borderWidth.bottom;
1100 points[3].y = points[0].y + style->borderWidth.top;
1101 view->drawPolygon (style->borderColor.right, shading, filled, convex,
1102 points,4);
1103 }
1104 break;
1105 case BORDER_RIDGE:
1106 ridge = true;
1107 /* fallthrough */
1108 case BORDER_GROOVE:
1109 w = style->borderWidth.right;
1110 d = w & 1;
1111 points[0].x = points[1].x = x1 + 1;
1112 points[0].y = y1;
1113 points[1].y = y2;
1114 points[2].x = points[3].x = points[0].x - w / 2 - d;
1115 points[2].y = y2 - style->borderWidth.bottom / 2;
1116 points[3].y = points[0].y + style->borderWidth.top / 2;
1117 shading = (ridge) ? Color::SHADING_DARK : Color::SHADING_LIGHT;
1118 view->drawPolygon (style->borderColor.right, shading, filled, convex,
1119 points, 4);
1120 points[0].x = points[1].x = x1 + 1 - w / 2 - d;
1121 points[0].y = y1 + style->borderWidth.top / 2;
1122 points[1].y = y2 - style->borderWidth.bottom / 2;
1123 points[2].x = points[3].x = x1 + 1 - w;
1124 points[2].y = y2 - style->borderWidth.bottom;
1125 points[3].y = y1 + style->borderWidth.top;
1126 shading = (ridge) ? Color::SHADING_LIGHT: Color::SHADING_DARK;
1127 view->drawPolygon (style->borderColor.right, shading, filled, convex,
1128 points, 4);
1129 break;
1130 case BORDER_DOUBLE:
1131 w = (int) rint(style->borderWidth.right / 3.0);
1132 d = w ? style->borderWidth.right - 2 * w : 0;
1133 int w_b = (int) rint(style->borderWidth.bottom / 3.0);
1134 int w_t = (int) rint(style->borderWidth.top / 3.0);
1135 if (style->borderWidth.right == 1) {
1136 view->drawLine(style->borderColor.right, shading, x1, y1, x2, y2);
1137 break;
1138 }
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;
1145 view->drawPolygon (style->borderColor.right, shading, filled, convex,
1146 points, 4);
1147 points[0].x = points[1].x = x1 + 1 - w - d;
1148 points[0].y = y1 - 1 + style->borderWidth.top - w_t;
1149 points[1].y = y2 + 1 - style->borderWidth.bottom + w_b;
1150 points[2].x = points[3].x = points[0].x - w;
1151 points[2].y = y2 + 1 - style->borderWidth.bottom;
1152 points[3].y = y1 - 1 + style->borderWidth.top;
1153 view->drawPolygon (style->borderColor.right, shading, filled, convex,
1154 points, 4);
1155 break;
1156 }
1157}
1158
1168 int x, int y, int width, int height,
1169 Style *style, bool inverse)
1170{
1172 int xb1, yb1, xb2, yb2;
1173
1174 // top left and bottom right point of outer border boundary
1175 xb1 = x + style->margin.left;
1176 yb1 = y + style->margin.top;
1177 xb2 = x + (width > 0 ? width - 1 : 0) - style->margin.right;
1178 yb2 = y + (height > 0 ? height - 1 : 0) - style->margin.bottom;
1179
1180 /*
1181 // top left and bottom right point of inner border boundary
1182 xp1 = xb1 + style->borderWidth.left;
1183 yp1 = yb1 + style->borderWidth.top;
1184 xp2 = xb2 - style->borderWidth.right;
1185 yp2 = yb2 - style->borderWidth.bottom;
1186
1187 light = inverse ? Color::SHADING_DARK : Color::SHADING_LIGHT;
1188 dark = inverse ? Color::SHADING_LIGHT : Color::SHADING_DARK;
1189 normal = inverse ? Color::SHADING_INVERSE : Color::SHADING_NORMAL;
1190 */
1191
1192 drawBorderRight(view, style, xb2, yb1, xb2, yb2);
1193 drawBorderLeft(view, style, xb1, yb1, xb1, yb2);
1194 drawBorderTop(view, style, xb1, yb1, xb2, yb1);
1195 drawBorderBottom(view, style, xb1, yb2, xb2, yb2);
1196}
1197
1198
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)
1236{
1237 bool hasBgColor = bgColor != NULL &&
1238 // The test for background colors is rather simple, since only the color
1239 // has to be compared, ...
1240 (!atTop || layout->getBgColor () != bgColor);
1241 bool hasBgImage = (style->backgroundImage != NULL &&
1242 style->backgroundImage->getImgbufSrc() != NULL) &&
1243 // ... but for backgrounds, it would be rather complicated. To handle the
1244 // two cases (normal HTML in a viewport, where the layout background
1245 // image is set, and contents of <button> within a flat view, where the
1246 // background image of the toplevel widget is set), only the background
1247 // images are compared. A full test, which also deals with all other
1248 // attributes related to background images (repeat, position etc.) would
1249 // be complicated and useless, so not worth the work.
1250 (!atTop || layout->getBgImage () != style->backgroundImage);
1251
1252 // Since widgets are always drawn from top to bottom, it is *not*
1253 // necessary to draw the background if background color and image
1254 // are not set (NULL), i. e. shining through.
1255
1256 if (hasBgColor || hasBgImage) {
1257 Rectangle bgArea, intersection;
1258 bgArea.x = x;
1259 bgArea.y = y;
1260 bgArea.width = width;
1261 bgArea.height = height;
1262
1263 if (area->intersectsWith (&bgArea, &intersection)) {
1264 if (hasBgColor)
1265 view->drawRectangle (bgColor,
1266 inverse ?
1268 true, intersection.x, intersection.y,
1269 intersection.width, intersection.height);
1270
1271 if (hasBgImage)
1273 style->backgroundRepeat,
1274 style->backgroundAttachment,
1275 style->backgroundPositionX,
1276 style->backgroundPositionY,
1277 intersection.x, intersection.y,
1278 intersection.width, intersection.height,
1279 xRef, yRef, widthRef, heightRef);
1280
1281 }
1282 }
1283}
1284
1285void drawBackgroundImage (View *view, StyleImage *backgroundImage,
1286 BackgroundRepeat backgroundRepeat,
1287 BackgroundAttachment backgroundAttachment,
1288 Length backgroundPositionX,
1289 Length backgroundPositionY,
1290 int x, int y, int width, int height,
1291 int xRef, int yRef, int widthRef, int heightRef)
1292{
1293 //printf ("drawBackgroundImage (..., [img: %d, %d], ..., (%d, %d), %d x %d, "
1294 // "(%d, %d), %d x %d)\n", imgWidth, imgHeight, x, y, width, height,
1295 // xRef, yRef, widthRef, heightRef);
1296
1297 bool repeatX, repeatY, doDraw;
1298 int origX, origY, tileX1, tileX2, tileY1, tileY2;
1299
1300 calcBackgroundRelatedValues (backgroundImage, backgroundRepeat,
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);
1306
1307 //printf ("tileX1 = %d, tileX2 = %d, tileY1 = %d, tileY2 = %d\n",
1308 // tileX1, tileX2, tileY1, tileY2);
1309
1310 if (doDraw) {
1311 // Drawing is done with the "tiled" buffer, but all calculations
1312 // before have been done with the "source" buffer.
1313
1314 Imgbuf *imgbufS = backgroundImage->getImgbufSrc();
1315 int imgWidthS = imgbufS->getRootWidth ();
1316 int imgHeightS = imgbufS->getRootHeight ();
1317
1318 Imgbuf *imgbufT = backgroundImage->getImgbufTiled(repeatX, repeatY);
1319 int imgWidthT = imgbufT->getRootWidth ();
1320 int imgHeightT = imgbufT->getRootHeight ();
1321 int tilesX = backgroundImage->getTilesX (repeatX, repeatY);
1322 int tilesY = backgroundImage->getTilesY (repeatX, repeatY);
1323
1324 for (int tileX = tileX1; tileX <= tileX2; tileX += tilesX)
1325 for (int tileY = tileY1; tileY <= tileY2; tileY += tilesY) {
1326 int xt = origX + tileX * imgWidthS;
1327 int x1 = misc::max (xt, x);
1328 int x2 = misc::min (xt + imgWidthT, x + width);
1329 int yt = origY + tileY * imgHeightS;
1330 int y1 = misc::max (yt, y);
1331 int y2 = misc::min (yt + imgHeightT, y + height);
1332
1333 view->drawImage (imgbufT, xt, yt, x1 - xt, y1 - yt,
1334 x2 - x1, y2 - y1);
1335 }
1336 }
1337}
1338
1340 BackgroundRepeat backgroundRepeat,
1341 BackgroundAttachment backgroundAttachment,
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)
1350{
1351 Imgbuf *imgbuf = backgroundImage->getImgbufSrc();
1352 int imgWidth = imgbuf->getRootWidth ();
1353 int imgHeight = imgbuf->getRootHeight ();
1354
1355 *repeatX = backgroundRepeat == BACKGROUND_REPEAT ||
1356 backgroundRepeat == BACKGROUND_REPEAT_X;
1357 *repeatY = backgroundRepeat == BACKGROUND_REPEAT ||
1358 backgroundRepeat == BACKGROUND_REPEAT_Y;
1359
1360 *origX = xRef +
1361 (isPerLength (backgroundPositionX) ?
1362 multiplyWithPerLength (widthRef - imgWidth, backgroundPositionX) :
1363 absLengthVal (backgroundPositionX));
1364 *origY = yRef +
1365 (isPerLength (backgroundPositionY) ?
1366 multiplyWithPerLength (heightRef - imgHeight, backgroundPositionY) :
1367 absLengthVal (backgroundPositionY));
1368
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;
1381
1382 *doDraw = true;
1383 if (!*repeatX) {
1384 // Only center tile (tileX = 0) is drawn, ...
1385 if (*tileX1 <= 0 && *tileX2 >= 0)
1386 // ... and is visible.
1387 *tileX1 = *tileX2 = 0;
1388 else
1389 // ... but is not visible.
1390 *doDraw = false;
1391 }
1392
1393 if (!*repeatY) {
1394 // Analogue.
1395 if (*tileY1 <= 0 && *tileY2 >= 0)
1396 *tileY1 = *tileY2 = 0;
1397 else
1398 *doDraw = false;
1399 }
1400}
1401
1402// ----------------------------------------------------------------------
1403
1404static const char
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" },
1408 *const roman_I3[] = { "","M","MM","MMM","MMMM" };
1409
1410static void strAsciiTolower (char *s)
1411{
1412 for ( ; *s; s++)
1413 *s = misc::AsciiTolower (*s);
1414}
1415
1421void numtostr (int num, char *buf, int buflen, ListStyleType listStyleType)
1422{
1423 int i3, i2, i1, i0;
1424 bool low = false;
1425 int start_ch = 'A';
1426
1427 if (buflen <= 0)
1428 return;
1429
1430 switch(listStyleType){
1433 start_ch = 'a';
1434 /* fallthrough */
1437 i0 = num - 1;
1438 i1 = i0/26 - 1; i2 = i1/26 - 1;
1439 if (i2 > 25) /* more than 26+26^2+26^3=18278 elements ? */
1440 snprintf(buf, buflen, "****.");
1441 else
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);
1446 break;
1448 low = true;
1449 /* fallthrough */
1451 i0 = num;
1452 i1 = i0/10; i2 = i1/10; i3 = i2/10;
1453 i0 %= 10; i1 %= 10; i2 %= 10;
1454 if (num < 0 || i3 > 4) /* more than 4999 elements ? */
1455 snprintf(buf, buflen, "****.");
1456 else
1457 snprintf(buf, buflen, "%s%s%s%s.", roman_I3[i3], roman_I2[i2],
1458 roman_I1[i1], roman_I0[i0]);
1459 break;
1461 default:
1462 snprintf(buf, buflen, "%d.", num);
1463 break;
1464 }
1465
1466 // ensure termination
1467 buf[buflen - 1] = '\0';
1468
1469 if (low)
1470 strAsciiTolower(buf);
1471
1472}
1473
1474} // namespace style
1475} // namespace core
1476} // namespace dw
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.
Definition imgbuf.hh:162
virtual int getRootWidth()=0
virtual void ref()=0
virtual void unref()=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.
Definition layout.hh:37
dw::core::Shape implementation for simple rectangles.
Definition types.hh:70
bool intersectsWith(Rectangle *otherRect, Rectangle *dest)
Return whether this rectangle and otherRect intersect.
Definition types.cc:53
An interface to encapsulate platform dependent drawing.
Definition view.hh:17
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(Box *other)
Definition style.hh:511
void setVal(int val)
Definition style.hh:510
bool equals(lout::object::Object *other)
Returns, whether two objects are equal.
Definition style.cc:455
int hashValue()
Return a hash value for the object.
Definition style.cc:461
int shadeColor(int color, int d)
Definition style.cc:471
static Color * create(Layout *layout, int color)
Definition style.cc:528
FontVariant fontVariant
Definition style.hh:688
bool equals(lout::object::Object *other)
Returns, whether two objects are equal.
Definition style.cc:397
int hashValue()
Return a hash value for the object.
Definition style.cc:410
static bool exists(Layout *layout, const char *name)
Definition style.cc:448
static Font * create(Layout *layout, FontAttrs *attrs)
Definition style.cc:443
void copyAttrs(FontAttrs *attrs)
Definition style.cc:427
static Font * create0(Layout *layout, FontAttrs *attrs, bool tryEverything)
Definition style.cc:437
ListStyleType listStyleType
Definition style.hh:568
ListStylePosition listStylePosition
Definition style.hh:567
TextTransform textTransform
Definition style.hh:546
StyleImage * backgroundImage
Definition style.hh:537
bool equals(lout::object::Object *other)
Returns, whether two objects are equal.
Definition style.cc:154
BackgroundRepeat backgroundRepeat
Definition style.hh:538
struct dw::core::style::StyleAttrs::@20 borderColor
BackgroundAttachment backgroundAttachment
Definition style.hh:539
int hashValue()
Return a hash value for the object.
Definition style.cc:215
void setBorderStyle(BorderStyle val)
Definition style.hh:588
bool sizeDiffs(StyleAttrs *otherStyleAttrs)
This method returns whether something may change its size, when its style changes from this style to ...
Definition style.cc:149
void setBorderColor(Color *val)
Definition style.hh:585
BorderCollapse borderCollapse
Definition style.hh:561
TextAlignType textAlign
Definition style.hh:543
struct dw::core::style::StyleAttrs::@21 borderStyle
void resetValues()
Reset those style attributes to their standard values, which are not inherited, according to CSS.
Definition style.cc:103
void finish()
Called, when all image data has been retrieved.
Definition style.cc:698
void drawRow(int row)
Called, when data from a row is available and has been copied into the image buffer.
Definition style.cc:650
void fatal()
Called, when there are problems with the retrieval of image data.
Definition style.cc:710
void setBuffer(core::Imgbuf *buffer, bool resize)
Called, when an image buffer is attached.
Definition style.cc:644
void fatal()
Called, when there are problems with the retrieval of image data.
Definition style.cc:613
void setBuffer(core::Imgbuf *buffer, bool resize)
Called, when an image buffer is attached.
Definition style.cc:542
void drawRow(int row)
Called, when data from a row is available and has been copied into the image buffer.
Definition style.cc:584
void finish()
Called, when all image data has been retrieved.
Definition style.cc:608
int getTilesX(bool repeatX, bool repeatY)
Definition style.hh:882
Imgbuf * getImgbufTiled(bool repeatX, bool repeatY)
Definition style.hh:880
StyleImgRenderer * styleImgRenderer
Definition style.hh:804
int getTilesY(bool repeatX, bool repeatY)
Definition style.hh:884
ImgRendererDist * imgRendererDist
Definition style.hh:803
static lout::container::typed::HashTable< StyleAttrs, Style > * styleTable
Definition style.hh:619
static int totalRef
Definition style.hh:617
void copyAttrs(StyleAttrs *attrs)
Definition style.cc:342
Style(StyleAttrs *attrs)
Definition style.cc:276
static Tooltip * create(dw::core::Layout *layout, const char *text)
Definition style.cc:535
This is the base class for many other classes, which defines very common virtual methods.
Definition object.hh:45
#define DBG_OBJ_DELETE()
#define DBG_OBJ_CREATE(klass)
#define DBG_OBJ_ASSOC(parent, child)
#define DBG_OBJ_ASSOC_CHILD(child)
char * dStrdup(const char *s)
Definition dlib.c:76
static Layout * layout
static Image * image
static core::Imgbuf * imgbuf
const int OPT_BG_IMG_H
Definition style.cc:40
@ LIST_STYLE_POSITION_OUTSIDE
Definition style.hh:300
static const char *const *const *const *const roman_I3[]
Definition style.cc:1408
int multiplyWithPerLength(int x, Length l)
Multiply an int with a percentage length, returning int.
Definition style.hh:474
static const char *const roman_I0[]
Definition style.cc:1405
@ BACKGROUND_ATTACHMENT_SCROLL
Definition style.hh:245
@ BACKGROUND_REPEAT_Y
Definition style.hh:240
@ BACKGROUND_REPEAT_X
Definition style.hh:239
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.
Definition style.cc:1232
@ LIST_STYLE_TYPE_DISC
Definition style.hh:303
@ LIST_STYLE_TYPE_LOWER_LATIN
Definition style.hh:312
@ LIST_STYLE_TYPE_UPPER_LATIN
Definition style.hh:314
@ LIST_STYLE_TYPE_UPPER_ALPHA
Definition style.hh:313
@ LIST_STYLE_TYPE_LOWER_ALPHA
Definition style.hh:311
@ LIST_STYLE_TYPE_UPPER_ROMAN
Definition style.hh:309
@ LIST_STYLE_TYPE_DECIMAL
Definition style.hh:306
@ LIST_STYLE_TYPE_LOWER_ROMAN
Definition style.hh:308
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)
Definition style.cc:1285
static const char *const *const roman_I1[]
Definition style.cc:1406
Length createPerLength(double v)
Returns a percentage, v is relative to 1, not to 100.
Definition style.hh:435
int Length
Type for representing all lengths within dw::core::style.
Definition style.hh:429
@ TEXT_TRANSFORM_NONE
Definition style.hh:269
static const char *const *const *const roman_I2[]
Definition style.cc:1407
@ TEXT_DECORATION_NONE
Definition style.hh:352
const int OPT_BG_IMG_W
Definition style.cc:39
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.
Definition style.cc:1167
static void drawBorderRight(View *view, Style *style, int x1, int y1, int x2, int y2)
Definition style.cc:1059
const int MIN_BG_IMG_H
Definition style.cc:38
static void drawBorderBottom(View *view, Style *style, int x1, int y1, int x2, int y2)
Definition style.cc:857
void numtostr(int num, char *buf, int buflen, ListStyleType listStyleType)
Convert a number into a string, in a given list style.
Definition style.cc:1421
@ BORDER_MODEL_SEPARATE
Definition style.hh:220
static void drawBorderTop(View *view, Style *style, int x1, int y1, int x2, int y2)
Definition style.cc:757
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)
Definition style.cc:1339
static void drawBorderLeft(View *view, Style *style, int x1, int y1, int x2, int y2)
Definition style.cc:959
@ Z_INDEX_AUTO
'z-index' is stored as int; use this for the value 'auto'.
Definition style.hh:388
bool isPerLength(Length l)
Returns true if l is a percentage.
Definition style.hh:446
const int MIN_BG_IMG_W
Definition style.cc:37
const bool drawBackgroundLineByLine
Definition style.cc:35
static void strAsciiTolower(char *s)
Definition style.cc:1410
int absLengthVal(Length l)
Returns the value of a length in pixels, as an integer.
Definition style.hh:452
@ LENGTH_AUTO
Represents "auto" lengths.
Definition style.hh:495
Dw is in this namespace, or sub namespaces of this one.
T min(T a, T b)
Definition misc.hh:40
T max(T a, T b)
Definition misc.hh:41
int AsciiTolower(char c)
Definition misc.hh:87
void assertNotReached()
Definition misc.hh:56