1 #ifndef __DW_STYLE_HH__
2 #define __DW_STYLE_HH__
6 #ifndef __INCLUDED_FROM_DW_CORE_HH__
7 # error Do not include this file directly, use "core.hh" instead.
12 #include "../lout/signal.hh"
13 #include "../lout/debug.hh"
435 return ((
int)(v * (1 << 18)) & ~3) | 2; }
439 return ((
int)(v * (1 << 18)) & ~3) | 3; }
459 {
return (
double)(l & ~3) / (1 << 18); }
466 inline double relLengthVal(Length l) {
return (
double)(l & ~3) / (1 << 18); }
509 inline void setVal(
int val) { top = right = bottom = left = val; }
511 return top == other->
top &&
512 right == other->
right &&
513 bottom == other->
bottom &&
517 return top + right + bottom +
left;
592 {
return margin.
left + borderWidth.
left + padding.
left; }
597 {
return margin.
top + borderWidth.
top + padding.
top; }
603 {
return backgroundColor != NULL || backgroundImage != NULL; }
630 Style *style = styleTable->
get (attrs);
634 style =
new Style (attrs);
635 styleTable->
put(style, style);
640 inline void ref () { refCount++; }
641 inline void unref () {
if (--refCount == 0)
delete this; }
667 inline void ref () { refCount++; }
669 {
if (--refCount == 0)
delete this; }
722 inline void ref () { refCount++; }
723 inline void unref () {
if (--refCount == 0)
delete this; }
776 inline void ref () { refCount++; }
778 {
if (--refCount == 0)
delete this; }
828 virtual void getBgArea (
int *x,
int *y,
int *width,
int *height) = 0;
835 virtual void getRefArea (
int *xRef,
int *yRef,
int *widthRef,
848 virtual void draw (
int x,
int y,
int width,
int height) = 0;
873 inline void ref () { refCount++; }
875 {
if (--refCount == 0)
delete this; }
879 {
return (imgbufTiled && repeatX && repeatY) ? imgbufTiled :
imgbufSrc; }
881 {
return (imgbufTiled && repeatX && repeatY) ? tilesX : 1; }
883 {
return (imgbufTiled && repeatX && repeatY) ? tilesY : 1; }
891 { imgRendererDist->
put (ir); }
897 { imgRendererDist->
remove (ir); }
901 int x,
int y,
int width,
int height,
902 Style *style,
bool inverse);
904 int x,
int y,
int width,
int height,
905 int xRef,
int yRef,
int widthRef,
int heightRef,
906 Style *style, Color *bgColor,
bool inverse,
bool atTop);
910 Length backgroundPositionX,
911 Length backgroundPositionY,
912 int x,
int y,
int width,
int height,
913 int xRef,
int yRef,
int widthRef,
int heightRef);
920 #endif // __DW_STYLE_HH__
Implementation of ImgRenderer, which distributes all calls to a set of other implementations of ImgRe...
Definition: imgrenderer.hh:59
virtual Length getBackgroundPositionY()=0
int wordSpacing
Definition: style.hh:555
bool equals(lout::object::Object *other)
Returns, whether two objects are equal.
Definition: style.cc:154
Cursor
Definition: style.hh:200
Length createAbsLength(int n)
Returns a length of n pixels.
Definition: style.hh:431
static Font * create(Layout *layout, FontAttrs *attrs)
Definition: style.cc:443
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
const char * name
Definition: style.hh:683
void fatal()
Called, when there are problems with the retrieval of image data.
Definition: style.cc:710
int boxOffsetX()
Definition: style.hh:591
Length backgroundPositionX
Definition: style.hh:539
void drawRow(int row)
Called, when data from a row is available and has been copied into the image buffer.
Definition: style.cc:650
Overflow
Definition: style.hh:336
void ref()
Definition: style.hh:873
Length right
Definition: style.hh:553
int bottom
Definition: style.hh:507
TextAlignType textAlign
Definition: style.hh:542
Box margin
Definition: style.hh:559
An object::Object wrapper for strings (char*).
Definition: object.hh:185
StyleImage * image
Definition: style.hh:788
Imgbuf * imgbufSrc
Definition: style.hh:800
virtual ~Font()
Definition: style.cc:421
Length createRelLength(double v)
Returns a relative length.
Definition: style.hh:438
virtual BackgroundAttachment getBackgroundAttachment()=0
void initValues()
Definition: style.cc:56
void unref()
Definition: style.hh:777
int getTilesY(bool repeatX, bool repeatY)
Definition: style.hh:882
Typed version of container::untyped::HashTable.
Definition: container.hh:514
Represents a dimension box according to the CSS box model.
Definition: style.hh:503
Shading
Definition: style.hh:767
dw::core::Shape implemtation for simple rectangles.
Definition: types.hh:69
static StyleImage * create()
Definition: style.hh:871
Length left
Definition: style.hh:553
Color * color
Definition: style.hh:535
int right
Definition: style.hh:507
Length minWidth
Definition: style.hh:557
int vBorderSpacing
Definition: style.hh:555
void unref()
Definition: style.hh:874
bool equals(lout::object::Object *other)
Returns, whether two objects are equal.
Definition: style.cc:455
int top
Definition: style.hh:507
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
bool isPerLength(Length l)
Returns true if l is a percentage.
Definition: style.hh:445
LineType
Definition: style.hh:291
The central class for managing and drawing a widget tree.
Definition: layout.hh:16
This is the base class for many other classes, which defines very common virtual methods.
Definition: object.hh:24
int absLengthVal(Length l)
Returns the value of a length in pixels, as an integer.
Definition: style.hh:451
void finish()
Called, when all image data has been retrieved.
Definition: style.cc:608
void ref()
Definition: style.hh:722
BorderStyle
Definition: style.hh:223
StyleImgRenderer * styleImgRenderer
Definition: style.hh:802
int shadeColor(int color, int d)
Definition: style.cc:471
Box borderWidth
Definition: style.hh:559
V * get(K *key) const
Definition: container.hh:523
StyleImage * backgroundImage
Definition: style.hh:536
int tilesX
Definition: style.hh:799
Length lineHeight
Definition: style.hh:556
BorderCollapse
Definition: style.hh:218
int refCount
Definition: style.hh:701
DisplayType display
Definition: style.hh:564
int xHeight
Definition: style.hh:717
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
FloatType vloat
Definition: style.hh:547
static Layout * layout
Definition: dw_anchors_test.cc:38
int refCount
Definition: style.hh:617
bool equals(Box *other)
Definition: style.hh:510
virtual StyleImage * getBackgroundImage()=0
Useful (but not mandatory) base class for updates of areas with background images.
Definition: style.hh:812
int hashValue()
Return a hash value for the object.
Definition: style.cc:410
int textDecoration
Definition: style.hh:533
int hashValue()
Definition: style.hh:516
void finish()
Called, when all image data has been retrieved.
Definition: style.cc:698
double relLengthVal(Length l)
Returns the value of a relative length, as a float.
Definition: style.hh:466
ListStyleType listStyleType
Definition: style.hh:567
int hBorderSpacing
Definition: style.hh:555
BackgroundAttachment
Definition: style.hh:243
WhiteSpace whiteSpace
Definition: style.hh:565
TextTransform textTransform
Definition: style.hh:545
TextDecoration
Definition: style.hh:350
Length textIndent
Definition: style.hh:556
void setVal(int val)
Definition: style.hh:509
Imgbuf * getImgbufSrc()
Definition: style.hh:877
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
~StyleImage()
Definition: style.cc:631
BorderStyle top
Definition: style.hh:562
char textAlignChar
Definition: style.hh:544
int multiplyWithPerLength(int x, Length l)
Multiply an int with a percentage length, returning int.
Definition: style.hh:473
Length maxHeight
Definition: style.hh:557
FloatType
Definition: style.hh:366
ImgRenderer * getMainImgRenderer()
Definition: style.hh:884
void copyAttrs(StyleAttrs *attrs)
Definition: style.cc:342
BackgroundAttachment backgroundAttachment
Definition: style.hh:538
static lout::container::typed::HashTable< StyleAttrs, Style > * styleTable
Definition: style.hh:618
int getTilesX(bool repeatX, bool repeatY)
Definition: style.hh:880
int tilesY
Definition: style.hh:799
bool isRelLength(Length l)
Returns true if l is a relative length.
Definition: style.hh:448
Font()
Definition: style.hh:706
int boxDiffWidth()
Definition: style.hh:595
int boxRestHeight()
Definition: style.hh:598
Length height
Definition: style.hh:556
FontStyle
Definition: style.hh:325
Imgbuf * imgbufTiled
Definition: style.hh:800
int multiplyWithPerLengthRounded(int x, Length l)
Like multiplyWithPerLength, but rounds to nearest integer instead of down.
Definition: style.hh:483
int letterSpacing
Definition: style.hh:686
FontStyle style
Definition: style.hh:688
int weight
Definition: style.hh:685
virtual ~Color()
Definition: style.cc:466
Color * backgroundColor
Definition: style.hh:535
StyleImgRenderer(StyleImage *image)
Definition: style.hh:791
StyleImage()
Definition: style.cc:618
static Font * create0(Layout *layout, FontAttrs *attrs, bool tryEverything)
Definition: style.cc:437
Length bottom
Definition: style.hh:553
int color
Definition: style.hh:733
BorderCollapse borderCollapse
Definition: style.hh:560
Length minHeight
Definition: style.hh:557
Represents "auto" lengths.
Definition: style.hh:494
#define DBG_OBJ_CREATE(klass)
Definition: debug_rtfl.hh:412
ImgRendererDist * imgRendererDist
Definition: style.hh:801
int boxDiffHeight()
Definition: style.hh:600
~Style()
Definition: style.cc:315
int multiplyWithRelLength(int x, Length l)
Definition: style.hh:487
bool equals(lout::object::Object *other)
Returns, whether two objects are equal.
Definition: style.cc:397
void put(ImgRenderer *child)
Definition: imgrenderer.hh:75
void put(K *key, V *value)
Definition: container.hh:521
FontVariant fontVariant
Definition: style.hh:687
Tooltip * x_tooltip
Definition: style.hh:573
An observed object has a signal emitter, which tells the receivers, when the object is deleted...
Definition: signal.hh:274
Definition: container.cc:27
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
int hashValue()
Return a hash value for the object.
Definition: style.cc:461
Color * top
Definition: style.hh:561
void putExternalImgRenderer(ImgRenderer *ir)
Add an additional ImgRenderer, especially used for drawing.
Definition: style.hh:890
Length backgroundPositionY
Definition: style.hh:540
int hashValue()
Return a hash value for the object.
Definition: style.cc:215
ListStylePosition listStylePosition
Definition: style.hh:566
FontVariant
Definition: style.hh:331
Imgbuf * getImgbufTiled(bool repeatX, bool repeatY)
Definition: style.hh:878
void resetValues()
Reset those style attributes to their standard values, which are not inherited, according to CSS...
Definition: style.cc:103
int spaceWidth
Definition: style.hh:716
int boxRestWidth()
Definition: style.hh:593
'z-index' is stored as int; use this for the value 'auto'.
Definition: style.hh:387
bool isAbsLength(Length l)
Returns true if l is an absolute length.
Definition: style.hh:442
virtual bool readyToDraw()=0
If this method returns false, nothing is done at all.
void unref()
Definition: style.hh:641
VAlignType
Definition: style.hh:256
ClearType
Definition: style.hh:372
ListStylePosition
Definition: style.hh:297
char x_lang[2]
Definition: style.hh:574
ClearType clear
Definition: style.hh:548
static int totalRef
Definition: style.hh:616
int size
Definition: style.hh:684
Overflow overflow
Definition: style.hh:550
void setBuffer(core::Imgbuf *buffer, bool resize)
Called, when an image buffer is attached.
Definition: style.cc:542
struct dw::core::style::StyleAttrs::@17 borderColor
void setBorderStyle(BorderStyle val)
Definition: style.hh:587
virtual void getRefArea(int *xRef, int *yRef, int *widthRef, int *heightRef)=0
Return the "reference area".
virtual void getBgArea(int *x, int *y, int *width, int *height)=0
Return the area covered by the background image.
VAlignType valign
Definition: style.hh:543
The platform independent interface for image buffers.
Definition: imgbuf.hh:161
Length maxWidth
Definition: style.hh:557
BackgroundRepeat backgroundRepeat
Definition: style.hh:537
int zIndex
Definition: style.hh:569
void copyAttrs(FontAttrs *attrs)
Definition: style.cc:427
Length createPerLength(double v)
Returns a percentage, v is relative to 1, not to 100.
Definition: style.hh:434
Dw is in this namespace, or sub namespaces of this one.
Definition: alignedtablecell.cc:28
void remove(ImgRenderer *child)
Definition: imgrenderer.hh:77
void drawRow(int row)
Called, when data from a row is available and has been copied into the image buffer.
Definition: style.cc:584
Length width
Definition: style.hh:556
An interface to encapsulate platform dependent drawing.
Definition: view.hh:16
double perLengthVal_useThisOnlyForDebugging(Length l)
Returns the value of a percentage, relative to 1, as a double.
Definition: style.hh:458
int ascent
Definition: style.hh:715
int roundInt(double d)
Definition: misc.hh:61
int boxOffsetY()
Definition: style.hh:596
int refCount
Definition: style.hh:754
Cursor cursor
Definition: style.hh:568
Color(int color)
Definition: style.hh:760
Position position
Definition: style.hh:552
void fatal()
Called, when there are problems with the retrieval of image data.
Definition: style.cc:613
static Style * create(StyleAttrs *attrs)
Definition: style.hh:628
int getColor()
Definition: style.hh:741
TextTransform
Definition: style.hh:267
virtual BackgroundRepeat getBackgroundRepeat()=0
ColorAttrs(int color)
Definition: style.hh:736
void setBuffer(core::Imgbuf *buffer, bool resize)
Called, when an image buffer is attached.
Definition: style.cc:644
void unref()
Definition: style.hh:723
Style(StyleAttrs *attrs)
Definition: style.cc:276
WhiteSpace
Definition: style.hh:358
int x_img
Definition: style.hh:572
BackgroundRepeat
Definition: style.hh:236
static bool exists(Layout *layout, const char *name)
Definition: style.cc:448
bool hasBackground()
Definition: style.hh:602
static Color * create(Layout *layout, int color)
Definition: style.cc:528
Length top
Definition: style.hh:553
int Length
Type for representing all lengths within dw::core::style.
Definition: style.hh:428
int left
Definition: style.hh:507
int descent
Definition: style.hh:715
struct dw::core::style::StyleAttrs::@18 borderStyle
void setBorderColor(Color *val)
Definition: style.hh:584
void ref()
Definition: style.hh:776
...
Definition: imgrenderer.hh:16
ListStyleType
Definition: style.hh:301
int x_link
Definition: style.hh:571
Box padding
Definition: style.hh:559
void ref()
Definition: style.hh:640
int refCount
Definition: style.hh:799
DisplayType
Definition: style.hh:277
Position
Definition: style.hh:343
virtual Length getBackgroundPositionX()=0
void removeExternalImgRenderer(ImgRenderer *ir)
Remove a previously added additional ImgRenderer.
Definition: style.hh:896
virtual void draw(int x, int y, int width, int height)=0
Draw (or queue for drawing) an area, which is given in canvas coordinates.
Font * font
Definition: style.hh:532
TextAlignType
Definition: style.hh:248