Dillo v3.1.1-98-g318d1f14
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 "dlib/dlib.h"
27#include "core.hh"
28#include "../lout/msg.h"
29
30using namespace lout;
31
32namespace dw {
33namespace core {
34namespace style {
35
36const bool drawBackgroundLineByLine = false;
37
38const int MIN_BG_IMG_W = 10;
39const int MIN_BG_IMG_H = 10;
40const int OPT_BG_IMG_W = 50;
41const int OPT_BG_IMG_H = 50;
42
43static void calcBackgroundRelatedValues (StyleImage *backgroundImage,
44 BackgroundRepeat backgroundRepeat,
46 backgroundAttachment,
47 Length backgroundPositionX,
48 Length backgroundPositionY,
49 int xDraw, int yDraw, int widthDraw,
50 int heightDraw, int xRef, int yRef,
51 int widthRef, int heightRef,
52 bool *repeatX, bool *repeatY,
53 int *origX, int *origY,
54 int *tileX1, int *tileX2, int *tileY1,
55 int *tileY2, bool *doDraw);
56
99
136
151{
152 return false;
153}
154
156 StyleAttrs *otherAttrs = (StyleAttrs *) other;
157
158 return this == otherAttrs ||
159 (font == otherAttrs->font &&
160 textDecoration == otherAttrs->textDecoration &&
161 color == otherAttrs->color &&
162 backgroundColor == otherAttrs->backgroundColor &&
163 backgroundImage == otherAttrs->backgroundImage &&
164 backgroundRepeat == otherAttrs->backgroundRepeat &&
168 textAlign == otherAttrs->textAlign &&
169 valign == otherAttrs->valign &&
170 textAlignChar == otherAttrs->textAlignChar &&
171 textTransform == otherAttrs->textTransform &&
172 vloat == otherAttrs->vloat &&
173 clear == otherAttrs->clear &&
174 overflow == otherAttrs->overflow &&
175 position == otherAttrs->position &&
176 top == otherAttrs->top &&
177 bottom == otherAttrs->bottom &&
178 left == otherAttrs->left &&
179 right == otherAttrs->right &&
180 hBorderSpacing == otherAttrs->hBorderSpacing &&
181 vBorderSpacing == otherAttrs->vBorderSpacing &&
182 wordSpacing == otherAttrs->wordSpacing &&
183 width == otherAttrs->width &&
184 height == otherAttrs->height &&
185 minWidth == otherAttrs->minWidth &&
186 maxWidth == otherAttrs->maxWidth &&
187 minHeight == otherAttrs->minHeight &&
188 maxHeight == otherAttrs->maxHeight &&
189 lineHeight == otherAttrs->lineHeight &&
190 textIndent == otherAttrs->textIndent &&
191 margin.equals (&otherAttrs->margin) &&
192 borderWidth.equals (&otherAttrs->borderWidth) &&
193 padding.equals (&otherAttrs->padding) &&
194 borderCollapse == otherAttrs->borderCollapse &&
195 borderColor.top == otherAttrs->borderColor.top &&
196 borderColor.right == otherAttrs->borderColor.right &&
197 borderColor.bottom == otherAttrs->borderColor.bottom &&
198 borderColor.left == otherAttrs->borderColor.left &&
199 borderStyle.top == otherAttrs->borderStyle.top &&
200 borderStyle.right == otherAttrs->borderStyle.right &&
201 borderStyle.bottom == otherAttrs->borderStyle.bottom &&
202 borderStyle.left == otherAttrs->borderStyle.left &&
203 display == otherAttrs->display &&
204 whiteSpace == otherAttrs->whiteSpace &&
205 listStylePosition == otherAttrs->listStylePosition &&
206 listStyleType == otherAttrs->listStyleType &&
207 cursor == otherAttrs->cursor &&
208 zIndex == otherAttrs->zIndex &&
209 x_link == otherAttrs->x_link &&
210 x_lang[0] == otherAttrs->x_lang[0] &&
211 x_lang[1] == otherAttrs->x_lang[1] &&
212 x_img == otherAttrs->x_img &&
213 x_tooltip == otherAttrs->x_tooltip);
214}
215
217 return (intptr_t) font +
219 (intptr_t) color +
220 (intptr_t) backgroundColor +
221 (intptr_t) backgroundImage +
226 textAlign +
227 valign +
230 vloat +
231 clear +
232 overflow +
233 position +
234 top +
235 bottom +
236 left +
237 right +
241 width +
242 height +
243 minWidth +
244 maxWidth +
245 minHeight +
246 maxHeight +
247 lineHeight +
248 textIndent +
249 margin.hashValue () +
251 padding.hashValue () +
253 (intptr_t) borderColor.top +
254 (intptr_t) borderColor.right +
255 (intptr_t) borderColor.bottom +
256 (intptr_t) borderColor.left +
257 borderStyle.top +
258 borderStyle.right +
259 borderStyle.bottom +
260 borderStyle.left +
261 display +
262 whiteSpace +
265 cursor +
266 zIndex +
267 x_link +
268 x_lang[0] + x_lang[1] +
269 x_img +
270 (intptr_t) x_tooltip;
271}
272
273int Style::totalRef = 0;
274container::typed::HashTable <StyleAttrs, Style> * Style::styleTable =
275 new container::typed::HashTable <StyleAttrs, Style> (false, false, 1024);
276
278{
279 DBG_OBJ_CREATE ("dw::core::style::Style");
280
281 copyAttrs (attrs);
282
291 //DBG_OBJ_ASSOC_CHILD (x_tooltip);
292
293 refCount = 1;
294
295 font->ref ();
296 if (color)
297 color->ref ();
298 if (backgroundColor)
300 if (backgroundImage)
302 if (borderColor.top)
303 borderColor.top->ref();
304 if (borderColor.bottom)
305 borderColor.bottom->ref();
306 if (borderColor.left)
307 borderColor.left->ref();
308 if (borderColor.right)
309 borderColor.right->ref();
310 if (x_tooltip)
311 x_tooltip->ref();
312
313 totalRef++;
314}
315
317{
318 font->unref ();
319
320 if (color)
321 color->unref ();
322 if (backgroundColor)
324 if (backgroundImage)
326 if (borderColor.top)
327 borderColor.top->unref();
328 if (borderColor.bottom)
329 borderColor.bottom->unref();
330 if (borderColor.left)
331 borderColor.left->unref();
332 if (borderColor.right)
333 borderColor.right->unref();
334 if (x_tooltip)
335 x_tooltip->unref();
336
337 styleTable->remove (this);
338 totalRef--;
339
341}
342
344{
345 font = attrs->font;
347 color = attrs->color;
354 textAlign = attrs->textAlign;
355 valign = attrs->valign;
358 vloat = attrs->vloat;
359 clear = attrs->clear;
360 overflow = attrs->overflow;
361 position = attrs->position;
362 top = attrs->top;
363 bottom = attrs->bottom;
364 left = attrs->left;
365 right = attrs->right;
368 wordSpacing = attrs->wordSpacing;
369 width = attrs->width;
370 height = attrs->height;
371 lineHeight = attrs->lineHeight;
372 textIndent = attrs->textIndent;
373 minWidth = attrs->minWidth;
374 maxWidth = attrs->maxWidth;
375 minHeight = attrs->minHeight;
376 maxHeight = attrs->maxHeight;
377 margin = attrs->margin;
378 borderWidth = attrs->borderWidth;
379 padding = attrs->padding;
381 borderColor = attrs->borderColor;
382 borderStyle = attrs->borderStyle;
383 display = attrs->display;
384 whiteSpace = attrs->whiteSpace;
387 cursor = attrs->cursor;
388 zIndex = attrs->zIndex;
389 x_link = attrs->x_link;
390 x_lang[0] = attrs->x_lang[0];
391 x_lang[1] = attrs->x_lang[1];
392 x_img = attrs->x_img;
393 x_tooltip = attrs->x_tooltip;
394}
395
396// ----------------------------------------------------------------------
397
399{
400 FontAttrs *otherAttrs = (FontAttrs*)other;
401 return
402 this == otherAttrs ||
403 (size == otherAttrs->size &&
404 weight == otherAttrs->weight &&
405 style == otherAttrs->style &&
406 letterSpacing == otherAttrs->letterSpacing &&
407 fontVariant == otherAttrs->fontVariant &&
408 strcmp (name, otherAttrs->name) == 0);
409}
410
412{
413 int h = object::String::hashValue (name);
414 h = (h << 5) - h + size;
415 h = (h << 5) - h + weight;
416 h = (h << 5) - h + style;
417 h = (h << 5) - h + letterSpacing;
418 h = (h << 5) - h + fontVariant;
419 return h;
420}
421
423{
424 free ((char*)name);
426}
427
429{
430 name = dStrdup (attrs->name);
431 size = attrs->size;
432 weight = attrs->weight;
433 style = attrs->style;
435 fontVariant = attrs->fontVariant;
436}
437
439 bool tryEverything)
440{
441 return layout->createFont (attrs, tryEverything);
442}
443
445{
446 return create0 (layout, attrs, false);
447}
448
449bool Font::exists (Layout *layout, const char *name)
450{
451 return layout->fontExists (name);
452}
453
454// ----------------------------------------------------------------------
455
457{
458 ColorAttrs *oc = (ColorAttrs*)other;
459 return this == oc || (color == oc->color);
460}
461
463{
464 return color;
465}
466
468{
470}
471
472int Color::shadeColor (int color, int d)
473{
474 int red = (color >> 16) & 255;
475 int green = (color >> 8) & 255;
476 int blue = color & 255;
477
478 double oldLightness = ((double) misc::max (red, green, blue)) / 255;
479 double newLightness;
480
481 if (oldLightness > 0.8) {
482 if (d > 0)
483 newLightness = oldLightness - 0.2;
484 else
485 newLightness = oldLightness - 0.4;
486 } else if (oldLightness < 0.2) {
487 if (d > 0)
488 newLightness = oldLightness + 0.4;
489 else
490 newLightness = oldLightness + 0.2;
491 } else
492 newLightness = oldLightness + d * 0.2;
493
494 if (oldLightness) {
495 double f = (newLightness / oldLightness);
496 red = (int)(red * f);
497 green = (int)(green * f);
498 blue = (int)(blue * f);
499 } else {
500 red = green = blue = (int)(newLightness * 255);
501 }
502
503 return (red << 16) | (green << 8) | blue;
504}
505
506int Color::shadeColor (int color, Shading shading)
507{
508 switch (shading) {
509 case SHADING_NORMAL:
510 return color;
511
512 case SHADING_LIGHT:
513 return shadeColor(color, +1);
514
515 case SHADING_INVERSE:
516 return color ^ 0xffffff;
517
518 case SHADING_DARK:
519 return shadeColor(color, -1);
520
521 default:
522 // compiler happiness
524 return -1;
525 }
526}
527
528
530{
531 ColorAttrs attrs(col);
532
533 return layout->createColor (col);
534}
535
537{
538 return layout->createTooltip (text);
539}
540
541// ----------------------------------------------------------------------
542
544{
545 if (image->imgbufSrc)
546 image->imgbufSrc->unref ();
547 if (image->imgbufTiled)
549
550 image->imgbufTiled = NULL;
551
552 image->imgbufSrc = buffer;
554
555 if (image->imgbufSrc) {
556 image->imgbufSrc->ref ();
557
558 // If the image is too small, drawing a background will cause
559 // many calls of View::drawImgbuf. For this reason, we create
560 // another image buffer, the "tiled" image buffer, which is
561 // larger (the "optimal" size is defined as OPT_BG_IMG_W *
562 // OPT_BG_IMG_H) and contains the "source" buffer several times.
563 //
564 // This "tiled" buffer is not used when 'background-repeat' has
565 // another value than 'repeat', for obvious reasons. Image
566 // buffers only "tiled" in one dimension (to optimize 'repeat-x'
567 // and 'repeat-y') are not supported.
568
571 image->tilesX =
573 image->tilesY =
579
581 }
582 }
583}
584
586{
587 if (image->imgbufTiled) {
588 // A row of data has been copied to the source buffer, here it
589 // is copied into the tiled buffer.
590
591 // Unfortunately, this code may be called *after* some other
592 // implementations of ImgRenderer::drawRow, which actually
593 // *draw* the tiled buffer, which is so not up to date
594 // (ImgRendererDist does not define an order). OTOH, these
595 // drawing implementations calle Widget::queueResize, so the
596 // actual drawing (and so access to the tiled buffer) is done
597 // later.
598
599 int w = image->imgbufSrc->getRootWidth ();
600 int h = image->imgbufSrc->getRootHeight ();
601
602 for (int x = 0; x < image->tilesX; x++)
603 for (int y = 0; y < image->tilesX; y++)
604 image->imgbufSrc->copyTo (image->imgbufTiled, x * w, y * h,
605 0, row, w, 1);
606 }
607}
608
610{
611 // Nothing to do.
612}
613
615{
616 // Nothing to do.
617}
618
620{
621 DBG_OBJ_CREATE ("dw::core::style::StyleImage");
622
623 refCount = 0;
624 imgbufSrc = NULL;
625 imgbufTiled = NULL;
626
630}
631
633{
634 if (imgbufSrc)
635 imgbufSrc->unref ();
636 if (imgbufTiled)
637 imgbufTiled->unref ();
638
639 delete imgRendererDist;
640 delete styleImgRenderer;
641
643}
644
646 bool resize)
647{
648 // Nothing to do?
649}
650
652{
654 StyleImage *backgroundImage;
655 if (readyToDraw () && (backgroundImage = getBackgroundImage ())) {
656 // All single rows are drawn.
657
658 Imgbuf *imgbuf = backgroundImage->getImgbufSrc();
659 int imgWidth = imgbuf->getRootWidth ();
660 int imgHeight = imgbuf->getRootHeight ();
661
662 int x, y, width, height;
663 getBgArea (&x, &y, &width, &height);
664
665 int xRef, yRef, widthRef, heightRef;
666 getRefArea (&xRef, &yRef, &widthRef, &heightRef);
667
668 bool repeatX, repeatY, doDraw;
669 int origX, origY, tileX1, tileX2, tileY1, tileY2;
670
671 calcBackgroundRelatedValues (backgroundImage,
672 getBackgroundRepeat (),
673 getBackgroundAttachment (),
674 getBackgroundPositionX (),
675 getBackgroundPositionY (),
676 x, y, width, height, xRef, yRef, widthRef,
677 heightRef, &repeatX, &repeatY, &origX,
678 &origY, &tileX1, &tileX2, &tileY1,
679 &tileY2, &doDraw);
680
681 //printf ("tileX1 = %d, tileX2 = %d, tileY1 = %d, tileY2 = %d\n",
682 // tileX1, tileX2, tileY1, tileY2);
683
684 if (doDraw)
685 // Only iterate over y, because the rows can be combined
686 // horizontally.
687 for (int tileY = tileY1; tileY <= tileY2; tileY++) {
688 int x1 = misc::max (origX + tileX1 * imgWidth, x);
689 int x2 = misc::min (origX + (tileX2 + 1) * imgWidth, x + width);
690
691 int yt = origY + tileY * imgHeight + row;
692 if (yt >= y && yt < y + height)
693 draw (x1, yt, x2 - x1, 1);
694 }
695 }
696 }
697}
698
700{
702 if (readyToDraw ()) {
703 // Draw total area, as a whole.
704 int x, y, width, height;
705 getBgArea (&x, &y, &width, &height);
706 draw (x, y, width, height);
707 }
708 }
709}
710
712{
713 // Nothing to do.
714}
715
716// ----------------------------------------------------------------------
717
719{
720 Style *style = getStyle ();
721 return style ? style->backgroundImage : NULL;
722}
723
729
736
738{
739 Style *style = getStyle ();
740 return style ? style->backgroundPositionX : createPerLength (0);
741}
742
744{
745 Style *style = getStyle ();
746 return style ? style->backgroundPositionY : createPerLength (0);
747}
748
749// ----------------------------------------------------------------------
750
751/*
752 * The drawBorder{Top,Bottom,Left,Right} functions are similar. They
753 * use a trapezium as draw polygon, or drawTypedLine() for dots and dashes.
754 * Although the concept is simple, achieving pixel accuracy is laborious [1].
755 *
756 * [1] https://dillo-browser.github.io/old/css_compat/tests/border-style.html
757 */
758static void drawBorderTop(View *view, Style *style,
759 int x1, int y1, int x2, int y2)
760
761{
762 int d, w;
763 Point points[4];
764 const bool filled = true, convex = true;
765 bool ridge = false, inset = false, dotted = false;
767
768 if (!style->borderColor.top || style->borderWidth.top == 0)
769 return;
770
771 switch (style->borderStyle.top) {
772 case BORDER_NONE:
773 case BORDER_HIDDEN:
774 break;
775 case BORDER_DOTTED:
776 dotted = true;
777 /* fallthrough */
778 case BORDER_DASHED:
779 w = style->borderWidth.top;
780 view->drawTypedLine(style->borderColor.top, shading,
781 dotted ? LINE_DOTTED : LINE_DASHED,
782 w, x1+w/2, y1+w/2, x2-w/2, y2+w/2);
783 break;
784 case BORDER_SOLID:
785 case BORDER_INSET:
786 inset = true;
787 /* fallthrough */
788 case BORDER_OUTSET:
789 if (style->borderStyle.top != BORDER_SOLID)
790 shading = (inset) ? Color::SHADING_DARK : Color::SHADING_LIGHT;
791
792 if (style->borderWidth.top == 1) {
793 view->drawLine(style->borderColor.top, shading, x1, y1, x2, y2);
794 } else {
795 points[0].x = x1;
796 points[1].x = x2 + 1;
797 points[0].y = points[1].y = y1;
798 points[2].x = points[1].x - style->borderWidth.right;
799 points[3].x = x1 + style->borderWidth.left;
800 points[2].y = points[3].y = points[0].y + style->borderWidth.top;
801 view->drawPolygon (style->borderColor.top, shading, filled, convex,
802 points, 4);
803 }
804 break;
805 case BORDER_RIDGE:
806 ridge = true;
807 /* fallthrough */
808 case BORDER_GROOVE:
809 d = style->borderWidth.top & 1;
810 points[0].x = x1;
811 points[1].x = x2 + 1;
812 points[0].y = points[1].y = y1;
813 points[2].x = x2 - style->borderWidth.right / 2;
814 points[3].x = x1 + style->borderWidth.left / 2;
815 points[2].y = points[3].y = y1 + style->borderWidth.top / 2 + d;
816 shading = (ridge) ? Color::SHADING_LIGHT : Color::SHADING_DARK;
817 view->drawPolygon (style->borderColor.top, shading, filled, convex,
818 points, 4);
819 points[0].x = x1 + style->borderWidth.left / 2 + d;
820 points[1].x = x2 - style->borderWidth.right / 2 + 1 - d;
821 points[0].y = points[1].y = y1 + style->borderWidth.top / 2 + d;
822 points[2].x = x2 - style->borderWidth.right + 1 - d;
823 points[3].x = x1 + style->borderWidth.left;
824 points[2].y = points[3].y = y1 + style->borderWidth.top;
825 shading = (ridge) ? Color::SHADING_DARK : Color::SHADING_LIGHT;
826 view->drawPolygon (style->borderColor.top, shading, filled, convex,
827 points, 4);
828 break;
829 case BORDER_DOUBLE:
830 w = (int) rint(style->borderWidth.top / 3.0);
831 d = w ? style->borderWidth.top - 2 * w : 0;
832 int w_l = (int) rint(style->borderWidth.left / 3.0);
833 int w_r = (int) rint(style->borderWidth.right / 3.0);
834 if (style->borderWidth.top == 1) {
835 view->drawLine(style->borderColor.top, shading, x1, y1, x2, y2);
836 break;
837 }
838 points[0].x = x1;
839 points[1].x = x2 + 1;
840 points[0].y = points[1].y = y1;
841 points[2].x = points[1].x - w_r;
842 points[3].x = points[0].x + w_l;
843 points[2].y = points[3].y = points[0].y + w;
844 view->drawPolygon (style->borderColor.top, shading, filled, convex,
845 points, 4);
846 points[0].x = x1 + style->borderWidth.left - w_l;
847 points[1].x = x2 + 1 - style->borderWidth.right + w_r;
848 points[0].y = points[1].y = y1 + w + d;
849 points[2].x = x2 + 1 - style->borderWidth.right;
850 points[3].x = x1 + style->borderWidth.left;
851 points[2].y = points[3].y = y1 + style->borderWidth.top;
852 view->drawPolygon (style->borderColor.top, shading, filled, convex,
853 points, 4);
854 break;
855 }
856}
857
858static void drawBorderBottom(View *view, Style *style,
859 int x1, int y1, int x2, int y2)
860
861{
862 int d, w;
863 Point points[4];
864 const bool filled = true, convex = true;
865 bool ridge = false, inset = false, dotted = false;
867
868 if (!style->borderColor.bottom || style->borderWidth.bottom == 0)
869 return;
870
871 switch (style->borderStyle.bottom) {
872 case BORDER_NONE:
873 case BORDER_HIDDEN:
874 break;
875 case BORDER_DOTTED:
876 dotted = true;
877 /* fallthrough */
878 case BORDER_DASHED:
879 w = style->borderWidth.bottom;
880 view->drawTypedLine(style->borderColor.bottom, shading,
881 dotted ? LINE_DOTTED : LINE_DASHED,
882 w, x1+w/2, y1-w/2, x2-w/2, y2-w/2);
883 break;
884 case BORDER_SOLID:
885 case BORDER_INSET:
886 inset = true;
887 /* fallthrough */
888 case BORDER_OUTSET:
889 if (style->borderStyle.bottom != BORDER_SOLID)
890 shading = (inset) ? Color::SHADING_LIGHT : Color::SHADING_DARK;
891
892 if (style->borderWidth.bottom == 1) { /* 1 pixel line */
893 view->drawLine(style->borderColor.bottom, shading, x1, y1, x2, y2);
894 } else {
895 points[0].x = x1 - 1;
896 points[1].x = x2 + 2;
897 points[0].y = points[1].y = y1 + 1;
898 points[2].x = points[1].x - style->borderWidth.right;
899 points[3].x = points[0].x + style->borderWidth.left;
900 points[2].y = points[3].y = points[0].y-style->borderWidth.bottom;
901 view->drawPolygon (style->borderColor.bottom, shading, filled, convex,
902 points, 4);
903 }
904 break;
905 case BORDER_RIDGE:
906 ridge = true;
907 /* fallthrough */
908 case BORDER_GROOVE:
909 w = style->borderWidth.bottom;
910 d = w & 1;
911 points[0].x = x1 - 1;
912 points[1].x = x2 + 2 - d;
913 points[0].y = points[1].y = y1 + 1;
914 points[2].x = points[1].x - style->borderWidth.right / 2;
915 points[3].x = points[0].x + style->borderWidth.left / 2 + d;
916 points[2].y = points[3].y = points[0].y - w/2 - d;
917 shading = (ridge) ? Color::SHADING_DARK : Color::SHADING_LIGHT;
918 view->drawPolygon (style->borderColor.bottom, shading, filled, convex,
919 points, 4);
920 // clockwise
921 points[0].x = x1 + style->borderWidth.left - 1;
922 points[1].x = x2 + 1 - style->borderWidth.right + 1;
923 points[0].y = points[1].y = y1 - w + 1;
924 points[2].x = points[1].x + style->borderWidth.right / 2;
925 points[3].x = points[0].x - style->borderWidth.left / 2;
926 points[2].y = points[3].y = points[0].y + w/2;
927 shading = (ridge) ? Color::SHADING_LIGHT : Color::SHADING_DARK;
928 view->drawPolygon (style->borderColor.bottom, shading, filled, convex,
929 points, 4);
930 break;
931 case BORDER_DOUBLE:
932 w = (int) rint(style->borderWidth.bottom / 3.0);
933 d = w ? style->borderWidth.bottom - 2 * w : 0;
934 int w_l = (int) rint(style->borderWidth.left / 3.0);
935 int w_r = (int) rint(style->borderWidth.right / 3.0);
936 if (style->borderWidth.bottom == 1) {
937 view->drawLine(style->borderColor.bottom, shading, x1, y1, x2, y2);
938 break;
939 }
940 points[0].x = x2 + 2;
941 points[1].x = x1 - 1;
942 points[0].y = points[1].y = y1 + 1;
943 points[2].x = points[1].x + w_l;
944 points[3].x = points[0].x - w_r;
945 points[2].y = points[3].y = points[0].y - w;
946 view->drawPolygon (style->borderColor.bottom, shading, filled, convex,
947 points, 4);
948 points[0].x = x2 + 2 - style->borderWidth.right + w_r;
949 points[1].x = x1 - 1 + style->borderWidth.left - w_l;
950 points[0].y = points[1].y = y1 + 1 - w - d;
951 points[2].x = x1 - 1 + style->borderWidth.left;
952 points[3].x = x2 + 2 - style->borderWidth.right;
953 points[2].y = points[3].y = y1 + 1 - style->borderWidth.bottom;
954 view->drawPolygon (style->borderColor.bottom, shading, filled, convex,
955 points, 4);
956 break;
957 }
958}
959
960static void drawBorderLeft(View *view, Style *style,
961 int x1, int y1, int x2, int y2)
962
963{
964 int d, w;
965 Point points[4];
966 bool filled = true, convex = true;
967 bool ridge = false, inset = false, dotted = false;
969
970 if (!style->borderColor.left || style->borderWidth.left == 0)
971 return;
972
973 switch (style->borderStyle.left) {
974 case BORDER_NONE:
975 case BORDER_HIDDEN:
976 break;
977 case BORDER_DOTTED:
978 dotted = true;
979 /* fallthrough */
980 case BORDER_DASHED:
981 w = style->borderWidth.left;
982 view->drawTypedLine(style->borderColor.left, shading,
983 dotted ? LINE_DOTTED : LINE_DASHED,
984 w, x1+w/2, y1+w/2, x1+w/2, y2-w/2);
985 break;
986 case BORDER_SOLID:
987 case BORDER_INSET:
988 inset = true;
989 /* fallthrough */
990 case BORDER_OUTSET:
991 if (style->borderStyle.left != BORDER_SOLID)
992 shading = (inset) ? Color::SHADING_DARK : Color::SHADING_LIGHT;
993 if (style->borderWidth.left == 1) { /* 1 pixel line */
994 view->drawLine(style->borderColor.left, shading, x1, y1, x2, y2);
995 } else {
996 points[0].x = points[1].x = x1;
997 points[0].y = y1 - 1;
998 points[1].y = y2 + 1;
999 points[2].x = points[3].x = points[0].x + style->borderWidth.left;
1000 points[2].y = points[1].y - style->borderWidth.bottom;
1001 points[3].y = points[0].y + style->borderWidth.top;
1002 view->drawPolygon (style->borderColor.left, shading, filled, convex,
1003 points, 4);
1004 }
1005 break;
1006 case BORDER_RIDGE:
1007 ridge = true;
1008 /* fallthrough */
1009 case BORDER_GROOVE:
1010 w = style->borderWidth.left;
1011 d = w & 1;
1012 points[0].x = points[1].x = x1;
1013 points[0].y = y1;
1014 points[1].y = y2;
1015 points[2].x = points[3].x = x1 + w / 2 + d;
1016 points[2].y = y2 - style->borderWidth.bottom / 2;
1017 points[3].y = y1 + style->borderWidth.top / 2;
1018 shading = (ridge) ? Color::SHADING_LIGHT : Color::SHADING_DARK;
1019 view->drawPolygon (style->borderColor.left, shading, filled, convex,
1020 points, 4);
1021 points[0].x = points[1].x = x1 + w / 2 + d;
1022 points[0].y = y1 + style->borderWidth.top / 2;
1023 points[1].y = y2 - style->borderWidth.bottom / 2;
1024 points[2].x = points[3].x = x1 + w;
1025 points[2].y = y2 - style->borderWidth.bottom;
1026 points[3].y = y1 + style->borderWidth.top;
1027 shading = (ridge) ? Color::SHADING_DARK : Color::SHADING_LIGHT;
1028 view->drawPolygon (style->borderColor.left, shading, filled, convex,
1029 points, 4);
1030 break;
1031 case BORDER_DOUBLE:
1032 w = (int) rint(style->borderWidth.left / 3.0);
1033 d = w ? style->borderWidth.left - 2 * w : 0;
1034 int w_b = (int) rint(style->borderWidth.bottom / 3.0);
1035 int w_t = (int) rint(style->borderWidth.top / 3.0);
1036 if (style->borderWidth.left == 1) {
1037 view->drawLine(style->borderColor.left, shading, x1, y1, x2, y2-1);
1038 break;
1039 }
1040 points[0].x = points[1].x = x1;
1041 points[0].y = y1 - 1;
1042 points[1].y = y2 + 1;
1043 points[2].x = points[3].x = points[0].x + w;
1044 points[2].y = points[1].y - w_b;
1045 points[3].y = points[0].y + w_t;
1046 view->drawPolygon (style->borderColor.left, shading, filled, convex,
1047 points, 4);
1048 points[0].x = points[1].x = x1 + w + d;
1049 points[0].y = y1 - 1 + style->borderWidth.top - w_t;
1050 points[1].y = y2 + 1 - style->borderWidth.bottom + w_b;
1051 points[2].x = points[3].x = points[0].x + w;
1052 points[2].y = y2 + 1 - style->borderWidth.bottom;
1053 points[3].y = y1 - 1 + style->borderWidth.top;
1054 view->drawPolygon (style->borderColor.left, shading, filled, convex,
1055 points, 4);
1056 break;
1057 }
1058}
1059
1060static void drawBorderRight(View *view, Style *style,
1061 int x1, int y1, int x2, int y2)
1062
1063{
1064 int d, w;
1065 Point points[4];
1066 const bool filled = true, convex = true;
1067 bool ridge = false, inset = false, dotted = false;
1069
1070 if (!style->borderColor.right || style->borderWidth.right == 0)
1071 return;
1072
1073 switch (style->borderStyle.right) {
1074 case BORDER_NONE:
1075 case BORDER_HIDDEN:
1076 break;
1077 case BORDER_DOTTED:
1078 dotted = true;
1079 /* fallthrough */
1080 case BORDER_DASHED:
1081 w = style->borderWidth.right;
1082 view->drawTypedLine(style->borderColor.right, shading,
1083 dotted ? LINE_DOTTED : LINE_DASHED,
1084 w, x1 - w/2, y1 + w/2, x1 - w/2, y2 - w/2);
1085 break;
1086 case BORDER_SOLID:
1087 case BORDER_INSET:
1088 inset = true;
1089 /* fallthrough */
1090 case BORDER_OUTSET:
1091 if (style->borderStyle.right != BORDER_SOLID)
1092 shading = (inset) ? Color::SHADING_LIGHT : Color::SHADING_DARK;
1093 if (style->borderWidth.right == 1) { /* 1 pixel line */
1094 view->drawLine(style->borderColor.right, shading, x1, y1, x2, y2);
1095 } else {
1096 points[0].x = points[1].x = x1 + 1;
1097 points[0].y = y1 - 1;
1098 points[1].y = y2 + 1;
1099 points[2].x = points[3].x = points[0].x-style->borderWidth.right;
1100 points[2].y = points[1].y - style->borderWidth.bottom;
1101 points[3].y = points[0].y + style->borderWidth.top;
1102 view->drawPolygon (style->borderColor.right, shading, filled, convex,
1103 points,4);
1104 }
1105 break;
1106 case BORDER_RIDGE:
1107 ridge = true;
1108 /* fallthrough */
1109 case BORDER_GROOVE:
1110 w = style->borderWidth.right;
1111 d = w & 1;
1112 points[0].x = points[1].x = x1 + 1;
1113 points[0].y = y1;
1114 points[1].y = y2;
1115 points[2].x = points[3].x = points[0].x - w / 2 - d;
1116 points[2].y = y2 - style->borderWidth.bottom / 2;
1117 points[3].y = points[0].y + style->borderWidth.top / 2;
1118 shading = (ridge) ? Color::SHADING_DARK : Color::SHADING_LIGHT;
1119 view->drawPolygon (style->borderColor.right, shading, filled, convex,
1120 points, 4);
1121 points[0].x = points[1].x = x1 + 1 - w / 2 - d;
1122 points[0].y = y1 + style->borderWidth.top / 2;
1123 points[1].y = y2 - style->borderWidth.bottom / 2;
1124 points[2].x = points[3].x = x1 + 1 - w;
1125 points[2].y = y2 - style->borderWidth.bottom;
1126 points[3].y = y1 + style->borderWidth.top;
1127 shading = (ridge) ? Color::SHADING_LIGHT: Color::SHADING_DARK;
1128 view->drawPolygon (style->borderColor.right, shading, filled, convex,
1129 points, 4);
1130 break;
1131 case BORDER_DOUBLE:
1132 w = (int) rint(style->borderWidth.right / 3.0);
1133 d = w ? style->borderWidth.right - 2 * w : 0;
1134 int w_b = (int) rint(style->borderWidth.bottom / 3.0);
1135 int w_t = (int) rint(style->borderWidth.top / 3.0);
1136 if (style->borderWidth.right == 1) {
1137 view->drawLine(style->borderColor.right, shading, x1, y1, x2, y2);
1138 break;
1139 }
1140 points[0].x = points[1].x = x1 + 1;
1141 points[0].y = y1 - 1;
1142 points[1].y = y2 + 1;
1143 points[2].x = points[3].x = points[0].x - w;
1144 points[2].y = points[1].y - w_b;
1145 points[3].y = points[0].y + w_t;
1146 view->drawPolygon (style->borderColor.right, shading, filled, convex,
1147 points, 4);
1148 points[0].x = points[1].x = x1 + 1 - w - d;
1149 points[0].y = y1 - 1 + style->borderWidth.top - w_t;
1150 points[1].y = y2 + 1 - style->borderWidth.bottom + w_b;
1151 points[2].x = points[3].x = points[0].x - w;
1152 points[2].y = y2 + 1 - style->borderWidth.bottom;
1153 points[3].y = y1 - 1 + style->borderWidth.top;
1154 view->drawPolygon (style->borderColor.right, shading, filled, convex,
1155 points, 4);
1156 break;
1157 }
1158}
1159
1169 int x, int y, int width, int height,
1170 Style *style, bool inverse)
1171{
1173 int xb1, yb1, xb2, yb2;
1174
1175 // top left and bottom right point of outer border boundary
1176 xb1 = x + style->margin.left;
1177 yb1 = y + style->margin.top;
1178 xb2 = x + (width > 0 ? width - 1 : 0) - style->margin.right;
1179 yb2 = y + (height > 0 ? height - 1 : 0) - style->margin.bottom;
1180
1181 /*
1182 // top left and bottom right point of inner border boundary
1183 xp1 = xb1 + style->borderWidth.left;
1184 yp1 = yb1 + style->borderWidth.top;
1185 xp2 = xb2 - style->borderWidth.right;
1186 yp2 = yb2 - style->borderWidth.bottom;
1187
1188 light = inverse ? Color::SHADING_DARK : Color::SHADING_LIGHT;
1189 dark = inverse ? Color::SHADING_LIGHT : Color::SHADING_DARK;
1190 normal = inverse ? Color::SHADING_INVERSE : Color::SHADING_NORMAL;
1191 */
1192
1193 drawBorderRight(view, style, xb2, yb1, xb2, yb2);
1194 drawBorderLeft(view, style, xb1, yb1, xb1, yb2);
1195 drawBorderTop(view, style, xb1, yb1, xb2, yb1);
1196 drawBorderBottom(view, style, xb1, yb2, xb2, yb2);
1197}
1198
1199
1234 int x, int y, int width, int height,
1235 int xRef, int yRef, int widthRef, int heightRef,
1236 Style *style, Color *bgColor, bool inverse, bool atTop)
1237{
1238 bool hasBgColor = bgColor != NULL &&
1239 // The test for background colors is rather simple, since only the color
1240 // has to be compared, ...
1241 (!atTop || layout->getBgColor () != bgColor);
1242 bool hasBgImage = (style->backgroundImage != NULL &&
1243 style->backgroundImage->getImgbufSrc() != NULL) &&
1244 // ... but for backgrounds, it would be rather complicated. To handle the
1245 // two cases (normal HTML in a viewport, where the layout background
1246 // image is set, and contents of <button> within a flat view, where the
1247 // background image of the toplevel widget is set), only the background
1248 // images are compared. A full test, which also deals with all other
1249 // attributes related to background images (repeat, position etc.) would
1250 // be complicated and useless, so not worth the work.
1251 (!atTop || layout->getBgImage () != style->backgroundImage);
1252
1253 // Since widgets are always drawn from top to bottom, it is *not*
1254 // necessary to draw the background if background color and image
1255 // are not set (NULL), i. e. shining through.
1256
1257 if (hasBgColor || hasBgImage) {
1258 Rectangle bgArea, intersection;
1259 bgArea.x = x;
1260 bgArea.y = y;
1261 bgArea.width = width;
1262 bgArea.height = height;
1263
1264 if (area->intersectsWith (&bgArea, &intersection)) {
1265 if (hasBgColor)
1266 view->drawRectangle (bgColor,
1267 inverse ?
1269 true, intersection.x, intersection.y,
1270 intersection.width, intersection.height);
1271
1272 if (hasBgImage)
1274 style->backgroundRepeat,
1275 style->backgroundAttachment,
1276 style->backgroundPositionX,
1277 style->backgroundPositionY,
1278 intersection.x, intersection.y,
1279 intersection.width, intersection.height,
1280 xRef, yRef, widthRef, heightRef);
1281
1282 }
1283 }
1284}
1285
1286void drawBackgroundImage (View *view, StyleImage *backgroundImage,
1287 BackgroundRepeat backgroundRepeat,
1288 BackgroundAttachment backgroundAttachment,
1289 Length backgroundPositionX,
1290 Length backgroundPositionY,
1291 int x, int y, int width, int height,
1292 int xRef, int yRef, int widthRef, int heightRef)
1293{
1294 //printf ("drawBackgroundImage (..., [img: %d, %d], ..., (%d, %d), %d x %d, "
1295 // "(%d, %d), %d x %d)\n", imgWidth, imgHeight, x, y, width, height,
1296 // xRef, yRef, widthRef, heightRef);
1297
1298 bool repeatX, repeatY, doDraw;
1299 int origX, origY, tileX1, tileX2, tileY1, tileY2;
1300
1301 calcBackgroundRelatedValues (backgroundImage, backgroundRepeat,
1302 backgroundAttachment, backgroundPositionX,
1303 backgroundPositionY, x, y, width, height,
1304 xRef, yRef, widthRef, heightRef,
1305 &repeatX, &repeatY, &origX, &origY,
1306 &tileX1, &tileX2, &tileY1, &tileY2, &doDraw);
1307
1308 //printf ("tileX1 = %d, tileX2 = %d, tileY1 = %d, tileY2 = %d\n",
1309 // tileX1, tileX2, tileY1, tileY2);
1310
1311 if (doDraw) {
1312 // Drawing is done with the "tiled" buffer, but all calculations
1313 // before have been done with the "source" buffer.
1314
1315 Imgbuf *imgbufS = backgroundImage->getImgbufSrc();
1316 int imgWidthS = imgbufS->getRootWidth ();
1317 int imgHeightS = imgbufS->getRootHeight ();
1318
1319 Imgbuf *imgbufT = backgroundImage->getImgbufTiled(repeatX, repeatY);
1320 int imgWidthT = imgbufT->getRootWidth ();
1321 int imgHeightT = imgbufT->getRootHeight ();
1322 int tilesX = backgroundImage->getTilesX (repeatX, repeatY);
1323 int tilesY = backgroundImage->getTilesY (repeatX, repeatY);
1324
1325 for (int tileX = tileX1; tileX <= tileX2; tileX += tilesX)
1326 for (int tileY = tileY1; tileY <= tileY2; tileY += tilesY) {
1327 int xt = origX + tileX * imgWidthS;
1328 int x1 = misc::max (xt, x);
1329 int x2 = misc::min (xt + imgWidthT, x + width);
1330 int yt = origY + tileY * imgHeightS;
1331 int y1 = misc::max (yt, y);
1332 int y2 = misc::min (yt + imgHeightT, y + height);
1333
1334 view->drawImage (imgbufT, xt, yt, x1 - xt, y1 - yt,
1335 x2 - x1, y2 - y1);
1336 }
1337 }
1338}
1339
1341 BackgroundRepeat backgroundRepeat,
1342 BackgroundAttachment backgroundAttachment,
1343 Length backgroundPositionX,
1344 Length backgroundPositionY,
1345 int xDraw, int yDraw, int widthDraw,
1346 int heightDraw, int xRef, int yRef,
1347 int widthRef, int heightRef, bool *repeatX,
1348 bool *repeatY, int *origX, int *origY,
1349 int *tileX1, int *tileX2, int *tileY1,
1350 int *tileY2, bool *doDraw)
1351{
1352 Imgbuf *imgbuf = backgroundImage->getImgbufSrc();
1353 int imgWidth = imgbuf->getRootWidth ();
1354 int imgHeight = imgbuf->getRootHeight ();
1355
1356 *repeatX = backgroundRepeat == BACKGROUND_REPEAT ||
1357 backgroundRepeat == BACKGROUND_REPEAT_X;
1358 *repeatY = backgroundRepeat == BACKGROUND_REPEAT ||
1359 backgroundRepeat == BACKGROUND_REPEAT_Y;
1360
1361 *origX = xRef +
1362 (isPerLength (backgroundPositionX) ?
1363 multiplyWithPerLength (widthRef - imgWidth, backgroundPositionX) :
1364 absLengthVal (backgroundPositionX));
1365 *origY = yRef +
1366 (isPerLength (backgroundPositionY) ?
1367 multiplyWithPerLength (heightRef - imgHeight, backgroundPositionY) :
1368 absLengthVal (backgroundPositionY));
1369
1370 *tileX1 = xDraw < *origX ?
1371 - (*origX - xDraw + imgWidth - 1) / imgWidth :
1372 (xDraw - *origX) / imgWidth;
1373 *tileX2 = *origX < xDraw + widthDraw ?
1374 (xDraw + widthDraw - *origX - 1) / imgWidth :
1375 - (*origX - (xDraw + widthDraw) + imgWidth - 1) / imgWidth;
1376 *tileY1 = yDraw < *origY ?
1377 - (*origY - yDraw + imgHeight - 1) / imgHeight :
1378 (yDraw - *origY) / imgHeight;
1379 *tileY2 = *origY < yDraw + heightDraw ?
1380 (yDraw + heightDraw - *origY - 1) / imgHeight :
1381 - (*origY - (yDraw + heightDraw) + imgHeight - 1) / imgHeight;
1382
1383 *doDraw = true;
1384 if (!*repeatX) {
1385 // Only center tile (tileX = 0) is drawn, ...
1386 if (*tileX1 <= 0 && *tileX2 >= 0)
1387 // ... and is visible.
1388 *tileX1 = *tileX2 = 0;
1389 else
1390 // ... but is not visible.
1391 *doDraw = false;
1392 }
1393
1394 if (!*repeatY) {
1395 // Analogue.
1396 if (*tileY1 <= 0 && *tileY2 >= 0)
1397 *tileY1 = *tileY2 = 0;
1398 else
1399 *doDraw = false;
1400 }
1401}
1402
1403// ----------------------------------------------------------------------
1404
1405static const char
1406 *const roman_I0[] = { "","I","II","III","IV","V","VI","VII","VIII","IX" },
1407 *const roman_I1[] = { "","X","XX","XXX","XL","L","LX","LXX","LXXX","XC" },
1408 *const roman_I2[] = { "","C","CC","CCC","CD","D","DC","DCC","DCCC","CM" },
1409 *const roman_I3[] = { "","M","MM","MMM","MMMM" };
1410
1411static void strAsciiTolower (char *s)
1412{
1413 for ( ; *s; s++)
1414 *s = misc::AsciiTolower (*s);
1415}
1416
1422void numtostr (int num, char *buf, int buflen, ListStyleType listStyleType)
1423{
1424 int i3, i2, i1, i0;
1425 bool low = false;
1426 int start_ch = 'A';
1427
1428 if (buflen <= 0)
1429 return;
1430
1431 switch(listStyleType){
1434 start_ch = 'a';
1435 /* fallthrough */
1438 i0 = num - 1;
1439 i1 = i0/26 - 1; i2 = i1/26 - 1;
1440 if (i2 > 25) /* more than 26+26^2+26^3=18278 elements ? */
1441 snprintf(buf, buflen, "****.");
1442 else
1443 snprintf(buf, buflen, "%c%c%c.",
1444 i2<0 ? ' ' : start_ch + i2%26,
1445 i1<0 ? ' ' : start_ch + i1%26,
1446 i0<0 ? ' ' : start_ch + i0%26);
1447 break;
1449 low = true;
1450 /* fallthrough */
1452 i0 = num;
1453 i1 = i0/10; i2 = i1/10; i3 = i2/10;
1454 i0 %= 10; i1 %= 10; i2 %= 10;
1455 if (num < 0 || i3 > 4) /* more than 4999 elements ? */
1456 snprintf(buf, buflen, "****.");
1457 else
1458 snprintf(buf, buflen, "%s%s%s%s.", roman_I3[i3], roman_I2[i2],
1459 roman_I1[i1], roman_I0[i0]);
1460 break;
1462 default:
1463 snprintf(buf, buflen, "%d.", num);
1464 break;
1465 }
1466
1467 // ensure termination
1468 buf[buflen - 1] = '\0';
1469
1470 if (low)
1471 strAsciiTolower(buf);
1472
1473}
1474
1475} // namespace style
1476} // namespace core
1477} // 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:511
void setVal(int val)
Definition style.hh:510
bool equals(lout::object::Object *other)
Returns, whether two objects are equal.
Definition style.cc:456
int hashValue()
Return a hash value for the object.
Definition style.cc:462
int shadeColor(int color, int d)
Definition style.cc:472
static Color * create(Layout *layout, int color)
Definition style.cc:529
FontVariant fontVariant
Definition style.hh:688
bool equals(lout::object::Object *other)
Returns, whether two objects are equal.
Definition style.cc:398
int hashValue()
Return a hash value for the object.
Definition style.cc:411
static bool exists(Layout *layout, const char *name)
Definition style.cc:449
static Font * create(Layout *layout, FontAttrs *attrs)
Definition style.cc:444
void copyAttrs(FontAttrs *attrs)
Definition style.cc:428
static Font * create0(Layout *layout, FontAttrs *attrs, bool tryEverything)
Definition style.cc:438
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:155
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:216
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:150
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:104
void finish()
Called, when all image data has been retrieved.
Definition style.cc:699
void drawRow(int row)
Called, when data from a row is available and has been copied into the image buffer.
Definition style.cc:651
void fatal()
Called, when there are problems with the retrieval of image data.
Definition style.cc:711
void setBuffer(core::Imgbuf *buffer, bool resize)
Called, when an image buffer is attached.
Definition style.cc:645
void fatal()
Called, when there are problems with the retrieval of image data.
Definition style.cc:614
void setBuffer(core::Imgbuf *buffer, bool resize)
Called, when an image buffer is attached.
Definition style.cc:543
void drawRow(int row)
Called, when data from a row is available and has been copied into the image buffer.
Definition style.cc:585
void finish()
Called, when all image data has been retrieved.
Definition style.cc:609
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:343
Style(StyleAttrs *attrs)
Definition style.cc:277
static Tooltip * create(dw::core::Layout *layout, const char *text)
Definition style.cc:536
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)
char * dStrdup(const char *s)
Definition dlib.c:77
static Layout * layout
static Image * image
static core::Imgbuf * imgbuf
const int OPT_BG_IMG_H
Definition style.cc:41
@ LIST_STYLE_POSITION_OUTSIDE
Definition style.hh:300
static const char *const *const *const *const roman_I3[]
Definition style.cc:1409
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:1406
@ 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:1233
@ 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:1286
static const char *const *const roman_I1[]
Definition style.cc:1407
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:1408
@ TEXT_DECORATION_NONE
Definition style.hh:352
const int OPT_BG_IMG_W
Definition style.cc:40
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:1168
static void drawBorderRight(View *view, Style *style, int x1, int y1, int x2, int y2)
Definition style.cc:1060
const int MIN_BG_IMG_H
Definition style.cc:39
static void drawBorderBottom(View *view, Style *style, int x1, int y1, int x2, int y2)
Definition style.cc:858
void numtostr(int num, char *buf, int buflen, ListStyleType listStyleType)
Convert a number into a string, in a given list style.
Definition style.cc:1422
@ 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:758
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:1340
static void drawBorderLeft(View *view, Style *style, int x1, int y1, int x2, int y2)
Definition style.cc:960
@ 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:38
const bool drawBackgroundLineByLine
Definition style.cc:36
static void strAsciiTolower(char *s)
Definition style.cc:1411
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