Dillo
|
Anything related to Dillo Widget styles is defined here. More...
Classes | |
class | Box |
Represents a dimension box according to the CSS box model. More... | |
class | Color |
class | ColorAttrs |
class | Font |
class | FontAttrs |
class | Style |
class | StyleAttrs |
class | StyleImage |
class | Tooltip |
class | TooltipAttrs |
Typedefs | |
typedef int | Length |
Type for representing all lengths within dw::core::style. More... | |
Functions | |
static void | calcBackgroundRelatedValues (StyleImage *backgroundImage, BackgroundRepeat backgroundRepeat, BackgroundAttachment backgroundAttachment, Length backgroundPositionX, Length backgroundPositionY, int xDraw, int yDraw, int widthDraw, int heightDraw, int xRef, int yRef, int widthRef, int heightRef, bool *repeatX, bool *repeatY, int *origX, int *origY, int *tileX1, int *tileX2, int *tileY1, int *tileY2, bool *doDraw) |
static void | drawBorderTop (View *view, Style *style, int x1, int y1, int x2, int y2) |
static void | drawBorderBottom (View *view, Style *style, int x1, int y1, int x2, int y2) |
static void | drawBorderLeft (View *view, Style *style, int x1, int y1, int x2, int y2) |
static void | drawBorderRight (View *view, Style *style, int x1, int y1, int x2, int y2) |
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. More... | |
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. More... | |
void | drawBackgroundImage (View *view, StyleImage *backgroundImage, BackgroundRepeat backgroundRepeat, BackgroundAttachment backgroundAttachment, Length backgroundPositionX, Length backgroundPositionY, int x, int y, int width, int height, int xRef, int yRef, int widthRef, int heightRef) |
static void | strAsciiTolower (char *s) |
void | numtostr (int num, char *buf, int buflen, ListStyleType listStyleType) |
Convert a number into a string, in a given list style. More... | |
Length | createAbsLength (int n) |
Returns a length of n pixels. More... | |
Length | createPerLength (double v) |
Returns a percentage, v is relative to 1, not to 100. More... | |
Length | createRelLength (double v) |
Returns a relative length. More... | |
bool | isAbsLength (Length l) |
Returns true if l is an absolute length. More... | |
bool | isPerLength (Length l) |
Returns true if l is a percentage. More... | |
bool | isRelLength (Length l) |
Returns true if l is a relative length. More... | |
int | absLengthVal (Length l) |
Returns the value of a length in pixels, as an integer. More... | |
double | perLengthVal_useThisOnlyForDebugging (Length l) |
Returns the value of a percentage, relative to 1, as a double. More... | |
double | relLengthVal (Length l) |
Returns the value of a relative length, as a float. More... | |
int | multiplyWithPerLength (int x, Length l) |
Multiply an int with a percentage length, returning int. More... | |
int | multiplyWithPerLengthRounded (int x, Length l) |
Like multiplyWithPerLength, but rounds to nearest integer instead of down. More... | |
int | multiplyWithRelLength (int x, Length l) |
Variables | |
const bool | drawBackgroundLineByLine = false |
const int | MIN_BG_IMG_W = 10 |
const int | MIN_BG_IMG_H = 10 |
const int | OPT_BG_IMG_W = 50 |
const int | OPT_BG_IMG_H = 50 |
static const char *const | roman_I0 [] = { "","I","II","III","IV","V","VI","VII","VIII","IX" } |
static const char *const *const | roman_I1 [] = { "","X","XX","XXX","XL","L","LX","LXX","LXXX","XC" } |
static const char *const *const *const | roman_I2 [] = { "","C","CC","CCC","CD","D","DC","DCC","DCCC","CM" } |
static const char *const *const *const *const | roman_I3 [] = { "","M","MM","MMM","MMMM" } |
Anything related to Dillo Widget styles is defined here.
dw::core::style::Style provides some resources and attributes for drawing widgets, as well as for parts of a widget (e.g., dw::Textblock uses styles for its words). Creating a style is done by filling a dw::core::style::StyleAttrs with the attributes and calling dw::core::style::Style::create:
After this, the attributes of a dw::core::style::Style should not be changed anymore, since styles are often shared between different widgets etc. (see below). Most times, you simply copy the attributes of another style (possible, since dw::core::style::Style is a sub class of dw::core::style::StyleAttrs), modify them and create a new style:
The dw::core::style::Font structure can be created by dw::core::style::Font::create, in a similar, with dw::core::style::FontAttrs, and colors by dw::core::style::Color::create, passing 0xrrggbb as an argument. Furthermore, there is dw::core::style::Tooltip, created by dw::core::style::Tooltip::create.
Notice that fonts, colors and tooltips are only intended to be used in conjunction with dw::core::style::Style.
dw::core::style::Style will become important for CSS, each CSS attribute, which is supported by dillo, will refer to an attribute in dw::core::style::Style. For this reason, the attributes in dw::core::style::Style get the names from the CSS attributes, with "camelCase" instead of hyphens (e.g. "background-color" becomes "backgroundColor").
However, dw::core::style::Style will be extended by some more attributes, which are not defined by CSS. To distinguish them, they get the prefix "x_", e.g. dw::core::style::Style::x_link.
dw::core::style::Length is a simple data type for lengths and percentages:
A length refers to an absolute measurement. It is used to represent the HTML type Pixels; and the CSS type <length>.
For CSS lengths, there are two units: (i) pixels and absolute units, which have to be converted to pixels (a pixel is, unlike in the CSS specification, treated as absolute unit), and (ii) the relative units "em" and "ex" (see below).
A percentage refers to a value relative to another value. It is used for the HTML type Length; (except Pixels;), and the CSS type <percentage>.
Since many values in CSS may be either lengths or percentages, a single type is very useful.
Creating lengths:
Examine lengths:
For borders, margins etc., the box model defined by CSS2 is used. dw::core::style::Style contains some members defining these attributes. A dw::core::Widget must use these values for any calculation of sizes. There are some helper functions (see dw/style.hh). A dw::core::style::Style box looks quite similar to a CSS box:
The background color is stored in dw::core::style::Style::backgroundColor, which may be NULL (the background color of the parent widget is shining through).
For toplevel widgets, this color is set as the background color of the views (dw::core::View::setBgColor), for other widgets, a filled rectangle is drawn, covering the content and padding. (This is compliant with CSS2, the background color of the toplevel element covers the whole canvas.)
The following methods may be useful:
dw::core::Widget::drawWidgetBox for drawing the box of a widget (typically at the beginning of the implementation of dw::core::Widget::draw), and
Memory management is done by reference counting, dw::core::style::Style::create returns a pointer to dw::core::style::Style with an increased reference counter, so you should care about calling dw::core::style::Style::unref if it is not used anymore. You do not need to care about the reference counters of fonts and styles.
In detail:
dw::core::style::Style::ref is called in
dw::core::style::Style::unref is called in
typedef int dw::core::style::Length |
Type for representing all lengths within dw::core::style.
Lengths are int's. Absolute lengths are represented in the following way:
Percentages:
Relative lengths (only used in HTML):
This is an implementation detail, use one of the following functions:
Creating lengths:
Examine lengths:
"auto" lengths are represented as dw::core::style::LENGTH_AUTO.
anonymous enum |
|
inline |
Returns the value of a length in pixels, as an integer.
Referenced by calcBackgroundRelatedValues(), dw::core::Widget::calcHeight(), dw::oof::OOFPosAbsLikeMgr::calcHPosAndSizeChildOfChild(), dw::Textblock::calcTextSize(), dw::oof::OOFPosAbsLikeMgr::calcVPosAndSizeChildOfChild(), dw::core::Widget::calcWidth(), dw::core::Widget::getAvailHeight(), dw::core::Widget::getAvailHeightOfChild(), dw::oof::OOFPositionedMgr::getPosBorder(), and dw::Textblock::initLine1Offset().
|
static |
References absLengthVal(), BACKGROUND_REPEAT, BACKGROUND_REPEAT_X, BACKGROUND_REPEAT_Y, dw::core::style::StyleImage::getImgbufSrc(), dw::core::Imgbuf::getRootHeight(), dw::core::Imgbuf::getRootWidth(), imgbuf, isPerLength(), and multiplyWithPerLength().
Referenced by drawBackgroundImage(), and dw::core::style::StyleImage::ExternalImgRenderer::drawRow().
|
inline |
Returns a length of n pixels.
Referenced by main().
|
inline |
Returns a percentage, v is relative to 1, not to 100.
Referenced by dw::core::style::StyleImage::ExternalWidgetImgRenderer::getBackgroundPositionX(), dw::core::style::StyleImage::ExternalWidgetImgRenderer::getBackgroundPositionY(), dw::core::style::StyleAttrs::initValues(), main(), and dw::core::style::StyleAttrs::resetValues().
|
inline |
Returns a relative length.
void dw::core::style::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.
Used by dw::core::Widget::drawBox and dw::core::Widget::drawWidgetBox.
"area" is the area to be drawn, "x", "y", "width" and "height" define the box itself (padding box). "xRef", "yRef", "widthRef" and "heightRef" define the reference area, which is important for the tiling of background images (for position 0%/0%, a tile is set at xRef/yRef; for position 100%/100%, a tile is set at xRef + widthRef/yRef + widthRef). See calls for more informations; in most cases, these boxes are identical (padding box). All these coordinates are given in canvas coordinates.
"atTop" should be true, only if the area is drawn directly on the canvas, not on top of other areas; this is only true for the toplevel widget itself (not parts of its contents). Toplevel widget background colors are already set as viewport background color, so that drawing again is is not neccessary, but some time can be saved.
Otherwise, the caller should not try to increase the performance by doing some tests before; this is all done in this method.
"bgColor" is passes implicitly. For non-inversed drawing, style->backgroundColor may simply used. However, when drawing is inversed, and style->backgroundColor is undefined (NULL), a background color defined higher in the hierarchy (which is not accessable here) must be used.
(Background images are never drawn inverse.)
References dw::core::style::StyleAttrs::backgroundAttachment, dw::core::style::StyleAttrs::backgroundImage, dw::core::style::StyleAttrs::backgroundPositionX, dw::core::style::StyleAttrs::backgroundPositionY, dw::core::style::StyleAttrs::backgroundRepeat, drawBackgroundImage(), dw::core::View::drawRectangle(), dw::core::Layout::getBgColor(), dw::core::Layout::getBgImage(), dw::core::style::StyleImage::getImgbufSrc(), dw::core::Rectangle::height, dw::core::Rectangle::intersectsWith(), dw::core::Rectangle::width, dw::core::Rectangle::x, and dw::core::Rectangle::y.
Referenced by dw::core::Widget::drawBox(), and dw::core::Widget::drawWidgetBox().
void dw::core::style::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 | ||
) |
References calcBackgroundRelatedValues(), dw::core::View::drawImage(), dw::core::style::StyleImage::getImgbufSrc(), dw::core::style::StyleImage::getImgbufTiled(), dw::core::Imgbuf::getRootHeight(), dw::core::Imgbuf::getRootWidth(), dw::core::style::StyleImage::getTilesX(), dw::core::style::StyleImage::getTilesY(), lout::misc::max(), and lout::misc::min().
Referenced by dw::core::Layout::draw(), and drawBackground().
void dw::core::style::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.
Used by dw::core::Widget::drawBox and dw::core::Widget::drawWidgetBox.
"area" is the area to be drawn, "x", "y", "width" and "height" define the box itself. All are given in canvas coordinates.
References dw::core::style::Box::bottom, drawBorderBottom(), drawBorderLeft(), drawBorderRight(), drawBorderTop(), dw::core::style::Box::left, dw::core::style::StyleAttrs::margin, dw::core::style::Box::right, and dw::core::style::Box::top.
Referenced by dw::core::Widget::drawBox(), and dw::core::Widget::drawWidgetBox().
|
static |
References BORDER_DASHED, BORDER_DOTTED, BORDER_DOUBLE, BORDER_GROOVE, BORDER_HIDDEN, BORDER_INSET, BORDER_NONE, BORDER_OUTSET, BORDER_RIDGE, BORDER_SOLID, dw::core::style::StyleAttrs::borderColor, dw::core::style::StyleAttrs::borderStyle, dw::core::style::StyleAttrs::borderWidth, dw::core::style::Box::bottom, dw::core::style::StyleAttrs::bottom, dw::core::View::drawLine(), dw::core::View::drawPolygon(), dw::core::View::drawTypedLine(), dw::core::style::Box::left, LINE_DASHED, LINE_DOTTED, dw::core::style::Box::right, dw::core::Point::x, and dw::core::Point::y.
Referenced by drawBorder().
|
static |
References BORDER_DASHED, BORDER_DOTTED, BORDER_DOUBLE, BORDER_GROOVE, BORDER_HIDDEN, BORDER_INSET, BORDER_NONE, BORDER_OUTSET, BORDER_RIDGE, BORDER_SOLID, dw::core::style::StyleAttrs::borderColor, dw::core::style::StyleAttrs::borderStyle, dw::core::style::StyleAttrs::borderWidth, dw::core::style::Box::bottom, dw::core::View::drawLine(), dw::core::View::drawPolygon(), dw::core::View::drawTypedLine(), dw::core::style::Box::left, dw::core::style::StyleAttrs::left, LINE_DASHED, LINE_DOTTED, dw::core::style::Box::top, dw::core::Point::x, and dw::core::Point::y.
Referenced by drawBorder().
|
static |
References BORDER_DASHED, BORDER_DOTTED, BORDER_DOUBLE, BORDER_GROOVE, BORDER_HIDDEN, BORDER_INSET, BORDER_NONE, BORDER_OUTSET, BORDER_RIDGE, BORDER_SOLID, dw::core::style::StyleAttrs::borderColor, dw::core::style::StyleAttrs::borderStyle, dw::core::style::StyleAttrs::borderWidth, dw::core::style::Box::bottom, dw::core::View::drawLine(), dw::core::View::drawPolygon(), dw::core::View::drawTypedLine(), LINE_DASHED, LINE_DOTTED, dw::core::style::Box::right, dw::core::style::StyleAttrs::right, dw::core::style::Box::top, dw::core::Point::x, and dw::core::Point::y.
Referenced by drawBorder().
|
static |
References BORDER_DASHED, BORDER_DOTTED, BORDER_DOUBLE, BORDER_GROOVE, BORDER_HIDDEN, BORDER_INSET, BORDER_NONE, BORDER_OUTSET, BORDER_RIDGE, BORDER_SOLID, dw::core::style::StyleAttrs::borderColor, dw::core::style::StyleAttrs::borderStyle, dw::core::style::StyleAttrs::borderWidth, dw::core::View::drawLine(), dw::core::View::drawPolygon(), dw::core::View::drawTypedLine(), dw::core::style::Box::left, LINE_DASHED, LINE_DOTTED, dw::core::style::Box::right, dw::core::style::Box::top, dw::core::style::StyleAttrs::top, dw::core::Point::x, and dw::core::Point::y.
Referenced by drawBorder().
|
inline |
Returns true if l is an absolute length.
Referenced by dw::core::Widget::affectedByContainerSizeChange(), dw::core::Widget::affectsSizeChangeContainerChild(), dw::core::Widget::calcHeight(), dw::oof::OOFPosAbsLikeMgr::calcHPosAndSizeChildOfChild(), dw::Textblock::calcTextSize(), dw::oof::OOFPosAbsLikeMgr::calcVPosAndSizeChildOfChild(), dw::core::Widget::calcWidth(), dw::core::Widget::getAvailHeight(), dw::core::Widget::getAvailHeightOfChild(), dw::oof::OOFPositionedMgr::getPosBorder(), dw::oof::OOFPosAbsLikeMgr::posXAbsolute(), and dw::oof::OOFPosAbsLikeMgr::posYAbsolute().
|
inline |
Returns true if l is a percentage.
Referenced by dw::core::Widget::affectedByContainerSizeChange(), dw::core::Widget::affectsSizeChangeContainerChild(), calcBackgroundRelatedValues(), dw::core::Widget::calcHeight(), dw::oof::OOFPosAbsLikeMgr::calcHPosAndSizeChildOfChild(), dw::oof::OOFPosAbsLikeMgr::calcVPosAndSizeChildOfChild(), dw::core::Widget::calcWidth(), dw::core::ui::ComplexButtonResource::correctExtremesOfChild(), dw::core::ui::ComplexButtonResource::correctRequisitionOfChild(), dw::Table::forceCalcColumnExtremes(), dw::core::Widget::getAvailHeight(), dw::core::Widget::getAvailHeightOfChild(), dw::Image::getExtremesSimpl(), dw::oof::OOFPositionedMgr::getPosBorder(), dw::Textblock::initLine1Offset(), dw::oof::OOFPosAbsLikeMgr::posXAbsolute(), and dw::oof::OOFPosAbsLikeMgr::posYAbsolute().
|
inline |
Returns true if l is a relative length.
|
inline |
Multiply an int with a percentage length, returning int.
Use this instead of perLengthVal, when possible.
References perLengthVal_useThisOnlyForDebugging().
Referenced by dw::tablecell::applyPerHeight(), dw::Table::applyPerHeight(), dw::core::Widget::applyPerHeight(), dw::tablecell::applyPerWidth(), dw::Table::applyPerWidth(), dw::core::Widget::applyPerWidth(), calcBackgroundRelatedValues(), dw::oof::OOFPosAbsLikeMgr::calcHPosAndSizeChildOfChild(), dw::oof::OOFPosAbsLikeMgr::calcVPosAndSizeChildOfChild(), and dw::oof::OOFPositionedMgr::getPosBorder().
|
inline |
Like multiplyWithPerLength, but rounds to nearest integer instead of down.
(This function exists for backward compatibility.)
References perLengthVal_useThisOnlyForDebugging(), and lout::misc::roundInt().
Referenced by dw::Textblock::calcTextSize(), and dw::Textblock::initLine1Offset().
|
inline |
References relLengthVal().
void dw::core::style::numtostr | ( | int | num, |
char * | buf, | ||
int | buflen, | ||
ListStyleType | listStyleType | ||
) |
Convert a number into a string, in a given list style.
Used for ordered lists.
References LIST_STYLE_TYPE_DECIMAL, LIST_STYLE_TYPE_LOWER_ALPHA, LIST_STYLE_TYPE_LOWER_LATIN, LIST_STYLE_TYPE_LOWER_ROMAN, LIST_STYLE_TYPE_UPPER_ALPHA, LIST_STYLE_TYPE_UPPER_LATIN, LIST_STYLE_TYPE_UPPER_ROMAN, roman_I0, roman_I1, roman_I2, roman_I3, and strAsciiTolower().
|
inline |
Returns the value of a percentage, relative to 1, as a double.
When possible, do not use this function directly; it may be removed soon. Instead, use multiplyWithPerLength or multiplyWithPerLengthRounded.
Referenced by dw::core::Widget::calcHeight(), dw::oof::OOFPosAbsLikeMgr::calcHPosAndSizeChildOfChild(), dw::oof::OOFPosAbsLikeMgr::calcVPosAndSizeChildOfChild(), dw::core::Widget::calcWidth(), dw::core::Widget::getAvailHeight(), dw::core::Widget::getAvailHeightOfChild(), multiplyWithPerLength(), and multiplyWithPerLengthRounded().
|
inline |
Returns the value of a relative length, as a float.
When possible, do not use this function directly; it may be removed soon.
Referenced by multiplyWithRelLength().
|
static |
References lout::misc::AsciiTolower().
Referenced by numtostr().
const bool dw::core::style::drawBackgroundLineByLine = false |
const int dw::core::style::MIN_BG_IMG_H = 10 |
Referenced by dw::core::style::StyleImage::StyleImgRenderer::setBuffer().
const int dw::core::style::MIN_BG_IMG_W = 10 |
const int dw::core::style::OPT_BG_IMG_H = 50 |
const int dw::core::style::OPT_BG_IMG_W = 50 |
|
static |
Referenced by numtostr().
|
static |
Referenced by numtostr().
|
static |
Referenced by numtostr().
|
static |
Referenced by numtostr().