Dillo v3.1.1-14-g8f67d6e0
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 <ctype.h>
24#include <math.h>
25
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 = strdup (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 case BORDER_DASHED:
777 w = style->borderWidth.top;
778 view->drawTypedLine(style->borderColor.top, shading,
779 dotted ? LINE_DOTTED : LINE_DASHED,
780 w, x1+w/2, y1+w/2, x2-w/2, y2+w/2);
781 break;
782 case BORDER_SOLID:
783 case BORDER_INSET:
784 inset = true;
785 case BORDER_OUTSET:
786 if (style->borderStyle.top != BORDER_SOLID)
787 shading = (inset) ? Color::SHADING_DARK : Color::SHADING_LIGHT;
788
789 if (style->borderWidth.top == 1) {
790 view->drawLine(style->borderColor.top, shading, x1, y1, x2, y2);
791 } else {
792 points[0].x = x1;
793 points[1].x = x2 + 1;
794 points[0].y = points[1].y = y1;
795 points[2].x = points[1].x - style->borderWidth.right;
796 points[3].x = x1 + style->borderWidth.left;
797 points[2].y = points[3].y = points[0].y + style->borderWidth.top;
798 view->drawPolygon (style->borderColor.top, shading, filled, convex,
799 points, 4);
800 }
801 break;
802 case BORDER_RIDGE:
803 ridge = true;
804 case BORDER_GROOVE:
805 d = style->borderWidth.top & 1;
806 points[0].x = x1;
807 points[1].x = x2 + 1;
808 points[0].y = points[1].y = y1;
809 points[2].x = x2 - style->borderWidth.right / 2;
810 points[3].x = x1 + style->borderWidth.left / 2;
811 points[2].y = points[3].y = y1 + style->borderWidth.top / 2 + d;
812 shading = (ridge) ? Color::SHADING_LIGHT : Color::SHADING_DARK;
813 view->drawPolygon (style->borderColor.top, shading, filled, convex,
814 points, 4);
815 points[0].x = x1 + style->borderWidth.left / 2 + d;
816 points[1].x = x2 - style->borderWidth.right / 2 + 1 - d;
817 points[0].y = points[1].y = y1 + style->borderWidth.top / 2 + d;
818 points[2].x = x2 - style->borderWidth.right + 1 - d;
819 points[3].x = x1 + style->borderWidth.left;
820 points[2].y = points[3].y = y1 + style->borderWidth.top;
821 shading = (ridge) ? Color::SHADING_DARK : Color::SHADING_LIGHT;
822 view->drawPolygon (style->borderColor.top, shading, filled, convex,
823 points, 4);
824 break;
825 case BORDER_DOUBLE:
826 w = (int) rint(style->borderWidth.top / 3.0);
827 d = w ? style->borderWidth.top - 2 * w : 0;
828 int w_l = (int) rint(style->borderWidth.left / 3.0);
829 int w_r = (int) rint(style->borderWidth.right / 3.0);
830 if (style->borderWidth.top == 1) {
831 view->drawLine(style->borderColor.top, shading, x1, y1, x2, y2);
832 break;
833 }
834 points[0].x = x1;
835 points[1].x = x2 + 1;
836 points[0].y = points[1].y = y1;
837 points[2].x = points[1].x - w_r;
838 points[3].x = points[0].x + w_l;
839 points[2].y = points[3].y = points[0].y + w;
840 view->drawPolygon (style->borderColor.top, shading, filled, convex,
841 points, 4);
842 points[0].x = x1 + style->borderWidth.left - w_l;
843 points[1].x = x2 + 1 - style->borderWidth.right + w_r;
844 points[0].y = points[1].y = y1 + w + d;
845 points[2].x = x2 + 1 - style->borderWidth.right;
846 points[3].x = x1 + style->borderWidth.left;
847 points[2].y = points[3].y = y1 + style->borderWidth.top;
848 view->drawPolygon (style->borderColor.top, shading, filled, convex,
849 points, 4);
850 break;
851 }
852}
853
854static void drawBorderBottom(View *view, Style *style,
855 int x1, int y1, int x2, int y2)
856
857{
858 int d, w;
859 Point points[4];
860 const bool filled = true, convex = true;
861 bool ridge = false, inset = false, dotted = false;
863
864 if (!style->borderColor.bottom || style->borderWidth.bottom == 0)
865 return;
866
867 switch (style->borderStyle.bottom) {
868 case BORDER_NONE:
869 case BORDER_HIDDEN:
870 break;
871 case BORDER_DOTTED:
872 dotted = true;
873 case BORDER_DASHED:
874 w = style->borderWidth.bottom;
875 view->drawTypedLine(style->borderColor.bottom, shading,
876 dotted ? LINE_DOTTED : LINE_DASHED,
877 w, x1+w/2, y1-w/2, x2-w/2, y2-w/2);
878 break;
879 case BORDER_SOLID:
880 case BORDER_INSET:
881 inset = true;
882 case BORDER_OUTSET:
883 if (style->borderStyle.bottom != BORDER_SOLID)
884 shading = (inset) ? Color::SHADING_LIGHT : Color::SHADING_DARK;
885
886 if (style->borderWidth.bottom == 1) { /* 1 pixel line */
887 view->drawLine(style->borderColor.bottom, shading, x1, y1, x2, y2);
888 } else {
889 points[0].x = x1 - 1;
890 points[1].x = x2 + 2;
891 points[0].y = points[1].y = y1 + 1;
892 points[2].x = points[1].x - style->borderWidth.right;
893 points[3].x = points[0].x + style->borderWidth.left;
894 points[2].y = points[3].y = points[0].y-style->borderWidth.bottom;
895 view->drawPolygon (style->borderColor.bottom, shading, filled, convex,
896 points, 4);
897 }
898 break;
899 case BORDER_RIDGE:
900 ridge = true;
901 case BORDER_GROOVE:
902 w = style->borderWidth.bottom;
903 d = w & 1;
904 points[0].x = x1 - 1;
905 points[1].x = x2 + 2 - d;
906 points[0].y = points[1].y = y1 + 1;
907 points[2].x = points[1].x - style->borderWidth.right / 2;
908 points[3].x = points[0].x + style->borderWidth.left / 2 + d;
909 points[2].y = points[3].y = points[0].y - w/2 - d;
910 shading = (ridge) ? Color::SHADING_DARK : Color::SHADING_LIGHT;
911 view->drawPolygon (style->borderColor.bottom, shading, filled, convex,
912 points, 4);
913 // clockwise
914 points[0].x = x1 + style->borderWidth.left - 1;
915 points[1].x = x2 + 1 - style->borderWidth.right + 1;
916 points[0].y = points[1].y = y1 - w + 1;
917 points[2].x = points[1].x + style->borderWidth.right / 2;
918 points[3].x = points[0].x - style->borderWidth.left / 2;
919 points[2].y = points[3].y = points[0].y + w/2;
920 shading = (ridge) ? Color::SHADING_LIGHT : Color::SHADING_DARK;
921 view->drawPolygon (style->borderColor.bottom, shading, filled, convex,
922 points, 4);
923 break;
924 case BORDER_DOUBLE:
925 w = (int) rint(style->borderWidth.bottom / 3.0);
926 d = w ? style->borderWidth.bottom - 2 * w : 0;
927 int w_l = (int) rint(style->borderWidth.left / 3.0);
928 int w_r = (int) rint(style->borderWidth.right / 3.0);
929 if (style->borderWidth.bottom == 1) {
930 view->drawLine(style->borderColor.bottom, shading, x1, y1, x2, y2);
931 break;
932 }
933 points[0].x = x2 + 2;
934 points[1].x = x1 - 1;
935 points[0].y = points[1].y = y1 + 1;
936 points[2].x = points[1].x + w_l;
937 points[3].x = points[0].x - w_r;
938 points[2].y = points[3].y = points[0].y - w;
939 view->drawPolygon (style->borderColor.bottom, shading, filled, convex,
940 points, 4);
941 points[0].x = x2 + 2 - style->borderWidth.right + w_r;
942 points[1].x = x1 - 1 + style->borderWidth.left - w_l;
943 points[0].y = points[1].y = y1 + 1 - w - d;
944 points[2].x = x1 - 1 + style->borderWidth.left;
945 points[3].x = x2 + 2 - style->borderWidth.right;
946 points[2].y = points[3].y = y1 + 1 - style->borderWidth.bottom;
947 view->drawPolygon (style->borderColor.bottom, shading, filled, convex,
948 points, 4);
949 break;
950 }
951}
952
953static void drawBorderLeft(View *view, Style *style,
954 int x1, int y1, int x2, int y2)
955
956{
957 int d, w;
958 Point points[4];
959 bool filled = true, convex = true;
960 bool ridge = false, inset = false, dotted = false;
962
963 if (!style->borderColor.left || style->borderWidth.left == 0)
964 return;
965
966 switch (style->borderStyle.left) {
967 case BORDER_NONE:
968 case BORDER_HIDDEN:
969 break;
970 case BORDER_DOTTED:
971 dotted = true;
972 case BORDER_DASHED:
973 w = style->borderWidth.left;
974 view->drawTypedLine(style->borderColor.left, shading,
975 dotted ? LINE_DOTTED : LINE_DASHED,
976 w, x1+w/2, y1+w/2, x1+w/2, y2-w/2);
977 break;
978 case BORDER_SOLID:
979 case BORDER_INSET:
980 inset = true;
981 case BORDER_OUTSET:
982 if (style->borderStyle.left != BORDER_SOLID)
983 shading = (inset) ? Color::SHADING_DARK : Color::SHADING_LIGHT;
984 if (style->borderWidth.left == 1) { /* 1 pixel line */
985 view->drawLine(style->borderColor.left, shading, x1, y1, x2, y2);
986 } else {
987 points[0].x = points[1].x = x1;
988 points[0].y = y1 - 1;
989 points[1].y = y2 + 1;
990 points[2].x = points[3].x = points[0].x + style->borderWidth.left;
991 points[2].y = points[1].y - style->borderWidth.bottom;
992 points[3].y = points[0].y + style->borderWidth.top;
993 view->drawPolygon (style->borderColor.left, shading, filled, convex,
994 points, 4);
995 }
996 break;
997 case BORDER_RIDGE:
998 ridge = true;
999 case BORDER_GROOVE:
1000 w = style->borderWidth.left;
1001 d = w & 1;
1002 points[0].x = points[1].x = x1;
1003 points[0].y = y1;
1004 points[1].y = y2;
1005 points[2].x = points[3].x = x1 + w / 2 + d;
1006 points[2].y = y2 - style->borderWidth.bottom / 2;
1007 points[3].y = y1 + style->borderWidth.top / 2;
1008 shading = (ridge) ? Color::SHADING_LIGHT : Color::SHADING_DARK;
1009 view->drawPolygon (style->borderColor.left, shading, filled, convex,
1010 points, 4);
1011 points[0].x = points[1].x = x1 + w / 2 + d;
1012 points[0].y = y1 + style->borderWidth.top / 2;
1013 points[1].y = y2 - style->borderWidth.bottom / 2;
1014 points[2].x = points[3].x = x1 + w;
1015 points[2].y = y2 - style->borderWidth.bottom;
1016 points[3].y = y1 + style->borderWidth.top;
1017 shading = (ridge) ? Color::SHADING_DARK : Color::SHADING_LIGHT;
1018 view->drawPolygon (style->borderColor.left, shading, filled, convex,
1019 points, 4);
1020 break;
1021 case BORDER_DOUBLE:
1022 w = (int) rint(style->borderWidth.left / 3.0);
1023 d = w ? style->borderWidth.left - 2 * w : 0;
1024 int w_b = (int) rint(style->borderWidth.bottom / 3.0);
1025 int w_t = (int) rint(style->borderWidth.top / 3.0);
1026 if (style->borderWidth.left == 1) {
1027 view->drawLine(style->borderColor.left, shading, x1, y1, x2, y2-1);
1028 break;
1029 }
1030 points[0].x = points[1].x = x1;
1031 points[0].y = y1 - 1;
1032 points[1].y = y2 + 1;
1033 points[2].x = points[3].x = points[0].x + w;
1034 points[2].y = points[1].y - w_b;
1035 points[3].y = points[0].y + w_t;
1036 view->drawPolygon (style->borderColor.left, shading, filled, convex,
1037 points, 4);
1038 points[0].x = points[1].x = x1 + w + d;
1039 points[0].y = y1 - 1 + style->borderWidth.top - w_t;
1040 points[1].y = y2 + 1 - style->borderWidth.bottom + w_b;
1041 points[2].x = points[3].x = points[0].x + w;
1042 points[2].y = y2 + 1 - style->borderWidth.bottom;
1043 points[3].y = y1 - 1 + style->borderWidth.top;
1044 view->drawPolygon (style->borderColor.left, shading, filled, convex,
1045 points, 4);
1046 break;
1047 }
1048}
1049
1050static void drawBorderRight(View *view, Style *style,
1051 int x1, int y1, int x2, int y2)
1052
1053{
1054 int d, w;
1055 Point points[4];
1056 const bool filled = true, convex = true;
1057 bool ridge = false, inset = false, dotted = false;
1059
1060 if (!style->borderColor.right || style->borderWidth.right == 0)
1061 return;
1062
1063 switch (style->borderStyle.right) {
1064 case BORDER_NONE:
1065 case BORDER_HIDDEN:
1066 break;
1067 case BORDER_DOTTED:
1068 dotted = true;
1069 case BORDER_DASHED:
1070 w = style->borderWidth.right;
1071 view->drawTypedLine(style->borderColor.right, shading,
1072 dotted ? LINE_DOTTED : LINE_DASHED,
1073 w, x1 - w/2, y1 + w/2, x1 - w/2, y2 - w/2);
1074 break;
1075 case BORDER_SOLID:
1076 case BORDER_INSET:
1077 inset = true;
1078 case BORDER_OUTSET:
1079 if (style->borderStyle.right != BORDER_SOLID)
1080 shading = (inset) ? Color::SHADING_LIGHT : Color::SHADING_DARK;
1081 if (style->borderWidth.right == 1) { /* 1 pixel line */
1082 view->drawLine(style->borderColor.right, shading, x1, y1, x2, y2);
1083 } else {
1084 points[0].x = points[1].x = x1 + 1;
1085 points[0].y = y1 - 1;
1086 points[1].y = y2 + 1;
1087 points[2].x = points[3].x = points[0].x-style->borderWidth.right;
1088 points[2].y = points[1].y - style->borderWidth.bottom;
1089 points[3].y = points[0].y + style->borderWidth.top;
1090 view->drawPolygon (style->borderColor.right, shading, filled, convex,
1091 points,4);
1092 }
1093 break;
1094 case BORDER_RIDGE:
1095 ridge = true;
1096 case BORDER_GROOVE:
1097 w = style->borderWidth.right;
1098 d = w & 1;
1099 points[0].x = points[1].x = x1 + 1;
1100 points[0].y = y1;
1101 points[1].y = y2;
1102 points[2].x = points[3].x = points[0].x - w / 2 - d;
1103 points[2].y = y2 - style->borderWidth.bottom / 2;
1104 points[3].y = points[0].y + style->borderWidth.top / 2;
1105 shading = (ridge) ? Color::SHADING_DARK : Color::SHADING_LIGHT;
1106 view->drawPolygon (style->borderColor.right, shading, filled, convex,
1107 points, 4);
1108 points[0].x = points[1].x = x1 + 1 - w / 2 - d;
1109 points[0].y = y1 + style->borderWidth.top / 2;
1110 points[1].y = y2 - style->borderWidth.bottom / 2;
1111 points[2].x = points[3].x = x1 + 1 - w;
1112 points[2].y = y2 - style->borderWidth.bottom;
1113 points[3].y = y1 + style->borderWidth.top;
1114 shading = (ridge) ? Color::SHADING_LIGHT: Color::SHADING_DARK;
1115 view->drawPolygon (style->borderColor.right, shading, filled, convex,
1116 points, 4);
1117 break;
1118 case BORDER_DOUBLE:
1119 w = (int) rint(style->borderWidth.right / 3.0);
1120 d = w ? style->borderWidth.right - 2 * w : 0;
1121 int w_b = (int) rint(style->borderWidth.bottom / 3.0);
1122 int w_t = (int) rint(style->borderWidth.top / 3.0);
1123 if (style->borderWidth.right == 1) {
1124 view->drawLine(style->borderColor.right, shading, x1, y1, x2, y2);
1125 break;
1126 }
1127 points[0].x = points[1].x = x1 + 1;
1128 points[0].y = y1 - 1;
1129 points[1].y = y2 + 1;
1130 points[2].x = points[3].x = points[0].x - w;
1131 points[2].y = points[1].y - w_b;
1132 points[3].y = points[0].y + w_t;
1133 view->drawPolygon (style->borderColor.right, shading, filled, convex,
1134 points, 4);
1135 points[0].x = points[1].x = x1 + 1 - w - d;
1136 points[0].y = y1 - 1 + style->borderWidth.top - w_t;
1137 points[1].y = y2 + 1 - style->borderWidth.bottom + w_b;
1138 points[2].x = points[3].x = points[0].x - w;
1139 points[2].y = y2 + 1 - style->borderWidth.bottom;
1140 points[3].y = y1 - 1 + style->borderWidth.top;
1141 view->drawPolygon (style->borderColor.right, shading, filled, convex,
1142 points, 4);
1143 break;
1144 }
1145}
1146
1156 int x, int y, int width, int height,
1157 Style *style, bool inverse)
1158{
1160 int xb1, yb1, xb2, yb2;
1161
1162 // top left and bottom right point of outer border boundary
1163 xb1 = x + style->margin.left;
1164 yb1 = y + style->margin.top;
1165 xb2 = x + (width > 0 ? width - 1 : 0) - style->margin.right;
1166 yb2 = y + (height > 0 ? height - 1 : 0) - style->margin.bottom;
1167
1168 /*
1169 // top left and bottom right point of inner border boundary
1170 xp1 = xb1 + style->borderWidth.left;
1171 yp1 = yb1 + style->borderWidth.top;
1172 xp2 = xb2 - style->borderWidth.right;
1173 yp2 = yb2 - style->borderWidth.bottom;
1174
1175 light = inverse ? Color::SHADING_DARK : Color::SHADING_LIGHT;
1176 dark = inverse ? Color::SHADING_LIGHT : Color::SHADING_DARK;
1177 normal = inverse ? Color::SHADING_INVERSE : Color::SHADING_NORMAL;
1178 */
1179
1180 drawBorderRight(view, style, xb2, yb1, xb2, yb2);
1181 drawBorderLeft(view, style, xb1, yb1, xb1, yb2);
1182 drawBorderTop(view, style, xb1, yb1, xb2, yb1);
1183 drawBorderBottom(view, style, xb1, yb2, xb2, yb2);
1184}
1185
1186
1221 int x, int y, int width, int height,
1222 int xRef, int yRef, int widthRef, int heightRef,
1223 Style *style, Color *bgColor, bool inverse, bool atTop)
1224{
1225 bool hasBgColor = bgColor != NULL &&
1226 // The test for background colors is rather simple, since only the color
1227 // has to be compared, ...
1228 (!atTop || layout->getBgColor () != bgColor);
1229 bool hasBgImage = (style->backgroundImage != NULL &&
1230 style->backgroundImage->getImgbufSrc() != NULL) &&
1231 // ... but for backgrounds, it would be rather complicated. To handle the
1232 // two cases (normal HTML in a viewport, where the layout background
1233 // image is set, and contents of <button> within a flat view, where the
1234 // background image of the toplevel widget is set), only the background
1235 // images are compared. A full test, which also deals with all other
1236 // attributes related to background images (repeat, position etc.) would
1237 // be complicated and useless, so not worth the work.
1238 (!atTop || layout->getBgImage () != style->backgroundImage);
1239
1240 // Since widgets are always drawn from top to bottom, it is *not*
1241 // necessary to draw the background if background color and image
1242 // are not set (NULL), i. e. shining through.
1243
1244 if (hasBgColor || hasBgImage) {
1245 Rectangle bgArea, intersection;
1246 bgArea.x = x;
1247 bgArea.y = y;
1248 bgArea.width = width;
1249 bgArea.height = height;
1250
1251 if (area->intersectsWith (&bgArea, &intersection)) {
1252 if (hasBgColor)
1253 view->drawRectangle (bgColor,
1254 inverse ?
1256 true, intersection.x, intersection.y,
1257 intersection.width, intersection.height);
1258
1259 if (hasBgImage)
1261 style->backgroundRepeat,
1262 style->backgroundAttachment,
1263 style->backgroundPositionX,
1264 style->backgroundPositionY,
1265 intersection.x, intersection.y,
1266 intersection.width, intersection.height,
1267 xRef, yRef, widthRef, heightRef);
1268
1269 }
1270 }
1271}
1272
1273void drawBackgroundImage (View *view, StyleImage *backgroundImage,
1274 BackgroundRepeat backgroundRepeat,
1275 BackgroundAttachment backgroundAttachment,
1276 Length backgroundPositionX,
1277 Length backgroundPositionY,
1278 int x, int y, int width, int height,
1279 int xRef, int yRef, int widthRef, int heightRef)
1280{
1281 //printf ("drawBackgroundImage (..., [img: %d, %d], ..., (%d, %d), %d x %d, "
1282 // "(%d, %d), %d x %d)\n", imgWidth, imgHeight, x, y, width, height,
1283 // xRef, yRef, widthRef, heightRef);
1284
1285 bool repeatX, repeatY, doDraw;
1286 int origX, origY, tileX1, tileX2, tileY1, tileY2;
1287
1288 calcBackgroundRelatedValues (backgroundImage, backgroundRepeat,
1289 backgroundAttachment, backgroundPositionX,
1290 backgroundPositionY, x, y, width, height,
1291 xRef, yRef, widthRef, heightRef,
1292 &repeatX, &repeatY, &origX, &origY,
1293 &tileX1, &tileX2, &tileY1, &tileY2, &doDraw);
1294
1295 //printf ("tileX1 = %d, tileX2 = %d, tileY1 = %d, tileY2 = %d\n",
1296 // tileX1, tileX2, tileY1, tileY2);
1297
1298 if (doDraw) {
1299 // Drawing is done with the "tiled" buffer, but all calculations
1300 // before have been done with the "source" buffer.
1301
1302 Imgbuf *imgbufS = backgroundImage->getImgbufSrc();
1303 int imgWidthS = imgbufS->getRootWidth ();
1304 int imgHeightS = imgbufS->getRootHeight ();
1305
1306 Imgbuf *imgbufT = backgroundImage->getImgbufTiled(repeatX, repeatY);
1307 int imgWidthT = imgbufT->getRootWidth ();
1308 int imgHeightT = imgbufT->getRootHeight ();
1309 int tilesX = backgroundImage->getTilesX (repeatX, repeatY);
1310 int tilesY = backgroundImage->getTilesY (repeatX, repeatY);
1311
1312 for (int tileX = tileX1; tileX <= tileX2; tileX += tilesX)
1313 for (int tileY = tileY1; tileY <= tileY2; tileY += tilesY) {
1314 int xt = origX + tileX * imgWidthS;
1315 int x1 = misc::max (xt, x);
1316 int x2 = misc::min (xt + imgWidthT, x + width);
1317 int yt = origY + tileY * imgHeightS;
1318 int y1 = misc::max (yt, y);
1319 int y2 = misc::min (yt + imgHeightT, y + height);
1320
1321 view->drawImage (imgbufT, xt, yt, x1 - xt, y1 - yt,
1322 x2 - x1, y2 - y1);
1323 }
1324 }
1325}
1326
1328 BackgroundRepeat backgroundRepeat,
1329 BackgroundAttachment backgroundAttachment,
1330 Length backgroundPositionX,
1331 Length backgroundPositionY,
1332 int xDraw, int yDraw, int widthDraw,
1333 int heightDraw, int xRef, int yRef,
1334 int widthRef, int heightRef, bool *repeatX,
1335 bool *repeatY, int *origX, int *origY,
1336 int *tileX1, int *tileX2, int *tileY1,
1337 int *tileY2, bool *doDraw)
1338{
1339 Imgbuf *imgbuf = backgroundImage->getImgbufSrc();
1340 int imgWidth = imgbuf->getRootWidth ();
1341 int imgHeight = imgbuf->getRootHeight ();
1342
1343 *repeatX = backgroundRepeat == BACKGROUND_REPEAT ||
1344 backgroundRepeat == BACKGROUND_REPEAT_X;
1345 *repeatY = backgroundRepeat == BACKGROUND_REPEAT ||
1346 backgroundRepeat == BACKGROUND_REPEAT_Y;
1347
1348 *origX = xRef +
1349 (isPerLength (backgroundPositionX) ?
1350 multiplyWithPerLength (widthRef - imgWidth, backgroundPositionX) :
1351 absLengthVal (backgroundPositionX));
1352 *origY = yRef +
1353 (isPerLength (backgroundPositionY) ?
1354 multiplyWithPerLength (heightRef - imgHeight, backgroundPositionY) :
1355 absLengthVal (backgroundPositionY));
1356
1357 *tileX1 = xDraw < *origX ?
1358 - (*origX - xDraw + imgWidth - 1) / imgWidth :
1359 (xDraw - *origX) / imgWidth;
1360 *tileX2 = *origX < xDraw + widthDraw ?
1361 (xDraw + widthDraw - *origX - 1) / imgWidth :
1362 - (*origX - (xDraw + widthDraw) + imgWidth - 1) / imgWidth;
1363 *tileY1 = yDraw < *origY ?
1364 - (*origY - yDraw + imgHeight - 1) / imgHeight :
1365 (yDraw - *origY) / imgHeight;
1366 *tileY2 = *origY < yDraw + heightDraw ?
1367 (yDraw + heightDraw - *origY - 1) / imgHeight :
1368 - (*origY - (yDraw + heightDraw) + imgHeight - 1) / imgHeight;
1369
1370 *doDraw = true;
1371 if (!*repeatX) {
1372 // Only center tile (tileX = 0) is drawn, ...
1373 if (*tileX1 <= 0 && *tileX2 >= 0)
1374 // ... and is visible.
1375 *tileX1 = *tileX2 = 0;
1376 else
1377 // ... but is not visible.
1378 *doDraw = false;
1379 }
1380
1381 if (!*repeatY) {
1382 // Analogue.
1383 if (*tileY1 <= 0 && *tileY2 >= 0)
1384 *tileY1 = *tileY2 = 0;
1385 else
1386 *doDraw = false;
1387 }
1388}
1389
1390// ----------------------------------------------------------------------
1391
1392static const char
1393 *const roman_I0[] = { "","I","II","III","IV","V","VI","VII","VIII","IX" },
1394 *const roman_I1[] = { "","X","XX","XXX","XL","L","LX","LXX","LXXX","XC" },
1395 *const roman_I2[] = { "","C","CC","CCC","CD","D","DC","DCC","DCCC","CM" },
1396 *const roman_I3[] = { "","M","MM","MMM","MMMM" };
1397
1398static void strAsciiTolower (char *s)
1399{
1400 for ( ; *s; s++)
1401 *s = misc::AsciiTolower (*s);
1402}
1403
1409void numtostr (int num, char *buf, int buflen, ListStyleType listStyleType)
1410{
1411 int i3, i2, i1, i0;
1412 bool low = false;
1413 int start_ch = 'A';
1414
1415 if (buflen <= 0)
1416 return;
1417
1418 switch(listStyleType){
1421 start_ch = 'a';
1424 i0 = num - 1;
1425 i1 = i0/26 - 1; i2 = i1/26 - 1;
1426 if (i2 > 25) /* more than 26+26^2+26^3=18278 elements ? */
1427 snprintf(buf, buflen, "****.");
1428 else
1429 snprintf(buf, buflen, "%c%c%c.",
1430 i2<0 ? ' ' : start_ch + i2%26,
1431 i1<0 ? ' ' : start_ch + i1%26,
1432 i0<0 ? ' ' : start_ch + i0%26);
1433 break;
1435 low = true;
1437 i0 = num;
1438 i1 = i0/10; i2 = i1/10; i3 = i2/10;
1439 i0 %= 10; i1 %= 10; i2 %= 10;
1440 if (num < 0 || i3 > 4) /* more than 4999 elements ? */
1441 snprintf(buf, buflen, "****.");
1442 else
1443 snprintf(buf, buflen, "%s%s%s%s.", roman_I3[i3], roman_I2[i2],
1444 roman_I1[i1], roman_I0[i0]);
1445 break;
1447 default:
1448 snprintf(buf, buflen, "%d.", num);
1449 break;
1450 }
1451
1452 // ensure termination
1453 buf[buflen - 1] = '\0';
1454
1455 if (low)
1456 strAsciiTolower(buf);
1457
1458}
1459
1460} // namespace style
1461} // namespace core
1462} // 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:17
dw::core::Shape implemtation 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:510
void setVal(int val)
Definition style.hh:509
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:687
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:567
ListStylePosition listStylePosition
Definition style.hh:566
TextTransform textTransform
Definition style.hh:545
StyleImage * backgroundImage
Definition style.hh:536
bool equals(lout::object::Object *other)
Returns, whether two objects are equal.
Definition style.cc:154
BackgroundRepeat backgroundRepeat
Definition style.hh:537
struct dw::core::style::StyleAttrs::@20 borderColor
BackgroundAttachment backgroundAttachment
Definition style.hh:538
int hashValue()
Return a hash value for the object.
Definition style.cc:215
void setBorderStyle(BorderStyle val)
Definition style.hh:587
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:584
BorderCollapse borderCollapse
Definition style.hh:560
TextAlignType textAlign
Definition style.hh:542
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:880
Imgbuf * getImgbufTiled(bool repeatX, bool repeatY)
Definition style.hh:878
StyleImgRenderer * styleImgRenderer
Definition style.hh:802
int getTilesY(bool repeatX, bool repeatY)
Definition style.hh:882
ImgRendererDist * imgRendererDist
Definition style.hh:801
static lout::container::typed::HashTable< StyleAttrs, Style > * styleTable
Definition style.hh:618
static int totalRef
Definition style.hh:616
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:25
#define DBG_OBJ_DELETE()
#define DBG_OBJ_CREATE(klass)
#define DBG_OBJ_ASSOC(parent, child)
#define DBG_OBJ_ASSOC_CHILD(child)
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:299
static const char *const *const *const *const roman_I3[]
Definition style.cc:1396
int multiplyWithPerLength(int x, Length l)
Multiply an int with a percentage length, returning int.
Definition style.hh:473
static const char *const roman_I0[]
Definition style.cc:1393
@ BACKGROUND_ATTACHMENT_SCROLL
Definition style.hh:244
@ BACKGROUND_REPEAT_Y
Definition style.hh:239
@ BACKGROUND_REPEAT_X
Definition style.hh:238
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:1220
@ LIST_STYLE_TYPE_DISC
Definition style.hh:302
@ LIST_STYLE_TYPE_LOWER_LATIN
Definition style.hh:311
@ LIST_STYLE_TYPE_UPPER_LATIN
Definition style.hh:313
@ LIST_STYLE_TYPE_UPPER_ALPHA
Definition style.hh:312
@ LIST_STYLE_TYPE_LOWER_ALPHA
Definition style.hh:310
@ LIST_STYLE_TYPE_UPPER_ROMAN
Definition style.hh:308
@ LIST_STYLE_TYPE_DECIMAL
Definition style.hh:305
@ LIST_STYLE_TYPE_LOWER_ROMAN
Definition style.hh:307
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:1273
static const char *const *const roman_I1[]
Definition style.cc:1394
Length createPerLength(double v)
Returns a percentage, v is relative to 1, not to 100.
Definition style.hh:434
int Length
Type for representing all lengths within dw::core::style.
Definition style.hh:428
@ TEXT_TRANSFORM_NONE
Definition style.hh:268
static const char *const *const *const roman_I2[]
Definition style.cc:1395
@ TEXT_DECORATION_NONE
Definition style.hh:351
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:1155
static void drawBorderRight(View *view, Style *style, int x1, int y1, int x2, int y2)
Definition style.cc:1050
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:854
void numtostr(int num, char *buf, int buflen, ListStyleType listStyleType)
Convert a number into a string, in a given list style.
Definition style.cc:1409
@ BORDER_MODEL_SEPARATE
Definition style.hh:219
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:1327
static void drawBorderLeft(View *view, Style *style, int x1, int y1, int x2, int y2)
Definition style.cc:953
@ Z_INDEX_AUTO
'z-index' is stored as int; use this for the value 'auto'.
Definition style.hh:387
bool isPerLength(Length l)
Returns true if l is a percentage.
Definition style.hh:445
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:1398
int absLengthVal(Length l)
Returns the value of a length in pixels, as an integer.
Definition style.hh:451
@ LENGTH_AUTO
Represents "auto" lengths.
Definition style.hh:494
Dw is in this namespace, or sub namespaces of this one.
T min(T a, T b)
Definition misc.hh:19
T max(T a, T b)
Definition misc.hh:20
int AsciiTolower(char c)
Definition misc.hh:66
void assertNotReached()
Definition misc.hh:35