|
Dillo
|
A Widget for rendering text blocks, i.e. paragraphs or sequences of paragraphs. More...
#include <textblock.hh>
Classes | |
| struct | Anchor |
| class | BadnessAndPenalty |
| struct | Line |
| class | TextblockIterator |
| struct | Word |
Public Member Functions | |
| Textblock (bool limitTextWidth) | |
| ~Textblock () | |
| core::Iterator * | iterator (core::Content::Type mask, bool atEnd) |
| Return an iterator for this widget. | |
| void | flush () |
| void | addText (const char *text, size_t len, core::style::Style *style) |
| void | addText (const char *text, core::style::Style *style) |
| void | addWidget (core::Widget *widget, core::style::Style *style) |
| bool | addAnchor (const char *name, core::style::Style *style) |
| void | addSpace (core::style::Style *style) |
| void | addBreakOption (core::style::Style *style) |
| void | addHyphen () |
| void | addParbreak (int space, core::style::Style *style) |
| void | addLinebreak (core::style::Style *style) |
| core::Widget * | getWidgetAtPoint (int x, int y, int level) |
| Search recursively through widget. | |
| void | handOverBreak (core::style::Style *style) |
| void | changeLinkColor (int link, int newColor) |
| void | changeWordStyle (int from, int to, core::style::Style *style, bool includeFirstSpace, bool includeLastSpace) |
Public Member Functions inherited from dw::core::Widget | |
| void | setDeleteCallback (DW_Callback_t func, void *data) |
| Widget () | |
| ~Widget () | |
| bool | needsResize () |
| bool | needsAllocate () |
| bool | extremesChanged () |
| bool | wasAllocated () |
| bool | usesHints () |
| bool | hasContents () |
| bool | blockLevel () |
| void | setParent (Widget *parent) |
| style::Style * | getStyle () |
| Allocation * | getAllocation () |
| void | sizeRequest (Requisition *requisition) |
| This method is a wrapper for Widget::sizeRequestImpl(); it calls the latter only when needed. | |
| void | getExtremes (Extremes *extremes) |
| Wrapper for Widget::getExtremesImpl(). | |
| void | sizeAllocate (Allocation *allocation) |
| Wrapper for Widget::sizeAllocateImpl, calls the latter only when needed. | |
| bool | intersects (Rectangle *area, Rectangle *intersection) |
| Calculates the intersection of widget->allocation and area, returned in intersection (in widget coordinates!). | |
| bool | buttonPress (EventButton *event) |
| bool | buttonRelease (EventButton *event) |
| bool | motionNotify (EventMotion *event) |
| void | enterNotify (EventCrossing *event) |
| void | leaveNotify (EventCrossing *event) |
| virtual void | setStyle (style::Style *style) |
| Change the style of a widget. | |
| void | setBgColor (style::Color *bgColor) |
| Set the background "behind" the widget, if it is not the background of the parent widget, e.g. the background of a table row. | |
| style::Color * | getBgColor () |
| Get the actual background of a widget. | |
| void | drawBox (View *view, style::Style *style, Rectangle *area, int x, int y, int width, int height, bool inverse) |
| Draw borders and background of a widget part, which allocation is given by (x, y, width, height) (widget coordinates). | |
| void | drawWidgetBox (View *view, Rectangle *area, bool inverse) |
| Draw borders and background of a widget. | |
| void | drawSelected (View *view, Rectangle *area) |
| void | setButtonSensitive (bool buttonSensitive) |
| bool | isButtonSensitive () |
| Widget * | getParent () |
| Widget * | getTopLevel () |
| Get the widget at the root of the tree, this widget is part from. | |
| int | getLevel () |
| Get the level of the widget within the tree. | |
| Widget * | getNearestCommonAncestor (Widget *otherWidget) |
| Get the widget with the highest level, which is a direct ancestor of widget1 and widget2. | |
| Layout * | getLayout () |
| void | scrollTo (HPosition hpos, VPosition vpos, int x, int y, int width, int height) |
| virtual void | removeChild (Widget *child) |
Public Member Functions inherited from lout::identity::IdentifiableObject | |
| IdentifiableObject () | |
| virtual void | intoStringBuffer (misc::StringBuffer *sb) |
| Store a textual representation of the object in a misc::StringBuffer. | |
| int | getClassId () |
| Returns the class identifier. | |
| const char * | getClassName () |
| Return the name, under which the class of this object was registered. | |
| bool | instanceOf (int otherClassId) |
| Returns, whether this class is an instance of the class, given by otherClassId, or of a sub class of this class. | |
Public Member Functions inherited from lout::object::Object | |
| virtual | ~Object () |
| The destructor is defined as virtual (but not abstract), so that destruction of Object's works properly. | |
| virtual bool | equals (Object *other) |
| Returns, whether two objects are equal. | |
| virtual int | hashValue () |
| Return a hash value for the object. | |
| virtual Object * | clone () |
| Return an exact copy of the object. | |
| const char * | toString () |
| Use object::Object::intoStringBuffer to return a textual representation of the object. | |
| virtual size_t | sizeOf () |
| Return the number of bytes, this object totally uses. | |
Static Public Attributes | |
| static int | CLASS_ID = -1 |
Static Public Attributes inherited from dw::core::Widget | |
| static int | CLASS_ID = -1 |
Protected Types | |
| enum | { HYPHEN_BREAK = 100 } |
Protected Types inherited from dw::core::Widget | |
| enum | Flags { NEEDS_RESIZE = 1 << 0, NEEDS_ALLOCATE = 1 << 1, EXTREMES_CHANGED = 1 << 2, USES_HINTS = 1 << 3, HAS_CONTENTS = 1 << 4, WAS_ALLOCATED = 1 << 5, BLOCK_LEVEL = 1 << 6 } |
Protected Member Functions | |
| void | printWord (Word *word) |
| void | queueDrawRange (int index1, int index2) |
| void | getWordExtremes (Word *word, core::Extremes *extremes) |
| void | markChange (int ref) |
| void | justifyLine (Line *line, int diff) |
| Line * | addLine (int firstWord, int lastWord, bool temporary) |
| void | calcWidgetSize (core::Widget *widget, core::Requisition *size) |
| void | rewrap () |
| void | showMissingLines () |
| void | removeTemporaryLines () |
| void | decorateText (core::View *view, core::style::Style *style, core::style::Color::Shading shading, int x, int yBase, int width) |
| void | drawText (core::View *view, core::style::Style *style, core::style::Color::Shading shading, int x, int y, const char *text, int start, int len) |
| void | drawWord (Line *line, int wordIndex1, int wordIndex2, core::View *view, core::Rectangle *area, int xWidget, int yWidgetBase) |
| void | drawWord0 (int wordIndex1, int wordIndex2, const char *text, int totalWidth, core::style::Style *style, core::View *view, core::Rectangle *area, int xWidget, int yWidgetBase) |
| void | drawSpace (int wordIndex, core::View *view, core::Rectangle *area, int xWidget, int yWidgetBase) |
| void | drawLine (Line *line, core::View *view, core::Rectangle *area) |
| int | findLineIndex (int y) |
| int | findLineOfWord (int wordIndex) |
| Find the line of word wordIndex. | |
| Word * | findWord (int x, int y, bool *inSpace) |
| Find the index of the word, or -1. | |
| Word * | addWord (int width, int ascent, int descent, bool canBeHyphenated, core::style::Style *style) |
| void | fillWord (Word *word, int width, int ascent, int descent, bool canBeHyphenated, core::style::Style *style) |
| void | fillSpace (Word *word, core::style::Style *style) |
| void | setBreakOption (Word *word, core::style::Style *style) |
| int | textWidth (const char *text, int start, int len, core::style::Style *style) |
| void | calcTextSize (const char *text, size_t len, core::style::Style *style, core::Requisition *size) |
| int | lineXOffsetContents (Line *line) |
| Returns the x offset (the indentation plus any offset needed for centering or right justification) for the line. | |
| int | lineXOffsetWidget (Line *line) |
| Like lineXOffset, but relative to the allocation (i.e. including border etc.). | |
| int | lineYOffsetWidgetAllocation (Line *line, core::Allocation *allocation) |
| int | lineYOffsetWidget (Line *line) |
| int | lineYOffsetCanvasAllocation (Line *line, core::Allocation *allocation) |
| int | lineYOffsetCanvas (Line *line) |
| int | lineYOffsetWidgetI (int lineIndex) |
| int | lineYOffsetCanvasI (int lineIndex) |
| bool | sendSelectionEvent (core::SelectionState::EventType eventType, core::MousePositionEvent *event) |
| Send event to selection. | |
| void | accumulateWordExtremes (int firstWord, int lastWord, int *maxOfMinWidth, int *sumOfMaxWidth) |
| virtual void | wordWrap (int wordIndex, bool wrapAll) |
| int | hyphenateWord (int wordIndex) |
| void | accumulateWordForLine (int lineIndex, int wordIndex) |
| void | accumulateWordData (int wordIndex) |
| int | calcAvailWidth (int lineIndex) |
| void | initLine1Offset (int wordIndex) |
| void | alignLine (int lineIndex) |
| void | sizeRequestImpl (core::Requisition *requisition) |
| void | getExtremesImpl (core::Extremes *extremes) |
| See Sizes of Dillo Widgets. | |
| void | sizeAllocateImpl (core::Allocation *allocation) |
| See Sizes of Dillo Widgets. | |
| void | resizeDrawImpl () |
| Called after sizeAllocateImpl() to redraw necessary areas. By default the whole widget is redrawn. | |
| void | markSizeChange (int ref) |
| See Sizes of Dillo Widgets. | |
| void | markExtremesChange (int ref) |
| See Sizes of Dillo Widgets. | |
| void | setWidth (int width) |
| void | setAscent (int ascent) |
| void | setDescent (int descent) |
| void | draw (core::View *view, core::Rectangle *area) |
| bool | buttonPressImpl (core::EventButton *event) |
| bool | buttonReleaseImpl (core::EventButton *event) |
| bool | motionNotifyImpl (core::EventMotion *event) |
| void | enterNotifyImpl (core::EventCrossing *event) |
| void | leaveNotifyImpl (core::EventCrossing *event) |
| void | removeChild (Widget *child) |
| void | addText0 (const char *text, size_t len, bool canBeHyphenated, core::style::Style *style, core::Requisition *size) |
| void | calcTextSizes (const char *text, size_t textLen, core::style::Style *style, int numBreaks, int *breakPos, core::Requisition *wordSize) |
Protected Member Functions inherited from dw::core::Widget | |
| int | getHeight () |
| int | getContentWidth () |
| int | getContentHeight () |
| void | setFlags (Flags f) |
| void | unsetFlags (Flags f) |
| void | queueDraw () |
| void | queueDrawArea (int x, int y, int width, int height) |
| void | queueResize (int ref, bool extremesChanged) |
| This method should be called, when a widget changes its size. | |
| char * | addAnchor (const char *name) |
| char * | addAnchor (const char *name, int y) |
| void | changeAnchor (char *name, int y) |
| void | removeAnchor (char *name) |
| void | setCursor (style::Cursor cursor) |
| bool | selectionButtonPress (Iterator *it, int charPos, int linkNo, EventButton *event, bool withinContent) |
| bool | selectionButtonRelease (Iterator *it, int charPos, int linkNo, EventButton *event, bool withinContent) |
| bool | selectionButtonMotion (Iterator *it, int charPos, int linkNo, EventMotion *event, bool withinContent) |
| bool | selectionHandleEvent (SelectionState::EventType eventType, Iterator *it, int charPos, int linkNo, MousePositionEvent *event) |
Protected Member Functions inherited from lout::identity::IdentifiableObject | |
| void | registerName (const char *className, int *classId) |
| This method must be called in the constructor for the sub class. See class comment for details. | |
Protected Attributes | |
| bool | hasListitemValue |
| int | innerPadding |
| int | line1Offset |
| int | line1OffsetEff |
| bool | ignoreLine1OffsetSometimes |
| bool | mustQueueResize |
| bool | limitTextWidth |
| int | redrawY |
| int | lastWordDrawn |
| int | availWidth |
| int | availAscent |
| int | availDescent |
| int | wrapRef |
| lout::misc::SimpleVector< Line > * | lines |
| int | nonTemporaryLines |
| lout::misc::NotSoSimpleVector < Word > * | words |
| lout::misc::SimpleVector < Anchor > * | anchors |
| struct { | |
| int index | |
| int nChar | |
| } | hlStart [core::HIGHLIGHT_NUM_LAYERS] |
| struct { | |
| int index | |
| int nChar | |
| } | hlEnd [core::HIGHLIGHT_NUM_LAYERS] |
| int | hoverLink |
Protected Attributes inherited from dw::core::Widget | |
| Allocation | allocation |
| The current allocation: size and position, always relative to the canvas. | |
| Layout * | layout |
Friends | |
| class | TextblockIterator |
Additional Inherited Members | |
Public Attributes inherited from dw::core::Widget | |
| int | parentRef |
| This value is defined by the parent widget, and used for incremential resizing. | |
A Widget for rendering text blocks, i.e. paragraphs or sequences of paragraphs.
dw::Textblock uses the signals defined in dw::core::Layout::LinkReceiver, related to links. The coordinates are always -1.
The idea behind this is that every paragraph has a specific vertical space around and that they are combined to one space, according to rules stated below. A paragraph consists either of the lines between two paragraph breaks within a dw::Textblock, or of a dw::Textblock within a dw::Textblock, in a single line; the latter is used for indented boxes and list items.
The rules:
If a paragraph is following by another, the space between them is the maximum of both box spaces:
are combined like this:
a) If one paragraph is the first paragraph within another, the upper space of these paragraphs collapse. b) The analogue is the case for the last box:
If B and C are put into A, the result is:
For achieving this, there are some features of dw::Textblock:
Consequent breaks are automatically combined, according to rule 1. See the code of dw::Textblock::addParBreak for details.
If a break is added as the first word of the dw::Textblock within another dw::Textblock, collapsing according to rule 2a is done automatically. See the code of dw::Textblock::addParBreak.
Collapsing margins, as defined in the CSS2 specification, are, supported in addition to collapsing spaces. Also, spaces and margins collapse themselves. I.e., the space between two paragraphs is the maximum of the space calculated as described in "Collapsing Spaces" and the space calculated according to the rules for collapsing margins.
(This is an intermediate hybrid state, collapsing spaces are used in the current version of dillo, while I implemented collapsing margins for the CSS prototype and integrated it already into the main trunk. For a pure CSS-based dillo, collapsing spaces will not be needed anymore, and may be removed for simplicity.)
There are 3 lists, dw::Textblock::words, dw::Textblock::lines, and dw::Textblock::anchors. The word list is quite static; only new words may be added. A word is either text, a widget, or a break.
Lines refer to the word list (first and last). They are completely redundant, i.e., they can be rebuilt from the words. Lines can be rewrapped either completely or partially (see "Incremental Resizing" below). For the latter purpose, several values are accumulated in the lines. See dw::Textblock::Line for details.
Anchors associate the anchor name with the index of the next word at the point of the anchor.
dw::Textblock makes use of incremental resizing as described in Sizes of Dillo Widgets. The parentRef is, for children of a dw::Textblock, simply the number of the line.
Generally, there are three cases which may change the size of the widget:
The available size of the widget has changed, e.g., because the user has changed the size of the browser window. In this case, it is necessary to rewrap all the lines.
A child widget has changed its size. In this case, only a rewrap down from the line where this widget is located is necessary.
(This case is very important for tables. Tables are quite at the bottom, so that a partial rewrap is relevant. Otherwise, tables change their size quite often, so that this is necessary for a fast, non-blocking rendering)
The state of the size calculation is stored in wrapRef within dw::Textblock, which has the value -1 if no rewrapping of lines necessary, or otherwise the line from which a rewrap is necessary.
|
protected |
| HYPHEN_BREAK |
The penalty for hyphens, multiplied by 100. So, 100 means 1.0. See dw::Textblock::BadnessAndPenalty::setPenalty for more details. |
| dw::Textblock::Textblock | ( | bool | limitTextWidth | ) |
References dw::core::HIGHLIGHT_NUM_LAYERS.
| dw::Textblock::~Textblock | ( | ) |
|
protected |
References dw::Textblock::Word::badnessAndPenalty, dw::Textblock::BadnessAndPenalty::calcBadness(), dw::Textblock::Word::hyphenWidth, dw::Textblock::Word::origSpace, PRINTF, dw::Textblock::Word::shrinkability, dw::Textblock::Word::size, dw::Textblock::Word::stretchability, dw::Textblock::Word::totalShrinkability, dw::Textblock::Word::totalStretchability, dw::Textblock::Word::totalWidth, and dw::core::Requisition::width.
|
protected |
|
protected |
References dw::core::Requisition::ascent, dw::core::style::Font::ascent, dw::core::Widget::blockLevel(), dw::core::style::Box::bottom, dw::Textblock::Line::boxAscent, dw::Textblock::Line::boxDescent, dw::core::Content::breakSpace, dw::Textblock::Line::breakSpace, dw::Textblock::Word::content, dw::Textblock::Line::contentAscent, dw::Textblock::Line::contentDescent, dw::core::Requisition::descent, dw::core::style::Font::descent, dw::core::style::StyleAttrs::font, dw::core::Widget::getStyle(), dw::core::style::StyleAttrs::margin, dw::Textblock::Line::marginDescent, lout::misc::max(), dw::core::Widget::parentRef, PRINTF, dw::Textblock::Word::size, dw::Textblock::Word::style, dw::core::style::Box::top, dw::core::Content::type, dw::core::style::StyleAttrs::valign, dw::core::style::VALIGN_SUB, dw::core::style::VALIGN_SUPER, and dw::core::Content::widget.
| bool dw::Textblock::addAnchor | ( | const char * | name, |
| core::style::Style * | style | ||
| ) |
Add an anchor to the page. "name" is copied, so no strdup is necessary for the caller.
Return true on success, and false, when this anchor had already been added to the widget tree.
References dw::Textblock::Anchor::name, and dw::Textblock::Anchor::wordIndex.
|
inline |
Add a break option (see setBreakOption() for details). Used instead of addStyle for ideographic characters.
References lout::misc::NotSoSimpleVector< T >::getRef(), setBreakOption(), lout::misc::NotSoSimpleVector< T >::size(), dw::core::Widget::style, and words.
| void dw::Textblock::addHyphen | ( | ) |
|
protected |
References dw::Textblock::Word::badnessAndPenalty, dw::Textblock::Line::boxAscent, dw::Textblock::Line::boxDescent, dw::Textblock::Line::breakSpace, dw::Textblock::Line::contentAscent, dw::Textblock::Line::contentDescent, dw::Textblock::Word::effSpace, dw::Textblock::Line::firstWord, dw::Textblock::Word::hyphenWidth, dw::Textblock::Line::lastWord, dw::Textblock::Line::leftOffset, dw::Textblock::BadnessAndPenalty::lineMustBeBroken(), dw::Textblock::Line::marginDescent, lout::misc::max(), dw::Textblock::Line::maxLineWidth, dw::Textblock::Line::maxParMax, dw::Textblock::Line::maxParMin, dw::Textblock::Word::origSpace, dw::Textblock::Line::parMax, PRINTF, dw::Textblock::Line::top, and dw::Textblock::Word::totalWidth.
| void dw::Textblock::addLinebreak | ( | core::style::Style * | style | ) |
| void dw::Textblock::addParbreak | ( | int | space, |
| core::style::Style * | style | ||
| ) |
Cause a paragraph break
References dw::Textblock::Word::badnessAndPenalty, dw::Textblock::Line::boxDescent, dw::core::Content::breakSpace, dw::Textblock::Line::breakSpace, dw::Textblock::Word::content, dw::core::Widget::getParent(), lout::misc::SimpleVector< T >::getRef(), lout::misc::NotSoSimpleVector< T >::getRef(), hasListitemValue, lines, dw::Textblock::Line::marginDescent, lout::misc::max(), mustQueueResize, dw::core::Widget::queueResize(), dw::Textblock::BadnessAndPenalty::setPenaltyForceBreak(), dw::core::Content::type, and words.
Referenced by handOverBreak().
| void dw::Textblock::addSpace | ( | core::style::Style * | style | ) |
?
Referenced by dw::ListItem::initWithText(), and dw::ListItem::initWithWidget().
| void dw::Textblock::addText | ( | const char * | text, |
| size_t | len, | ||
| core::style::Style * | style | ||
| ) |
Add a word to the page structure. If it contains soft hyphens, it is divided.
References PRINTF, and PUTCHAR.
Referenced by addText(), and dw::ListItem::initWithText().
|
inline |
References addText().
|
protected |
Add a word (without hyphens) to the page structure.
References dw::core::Requisition::ascent, dw::Textblock::Word::content, dw::core::Requisition::descent, dw::core::Content::text, dw::core::Content::type, and dw::core::Requisition::width.
| void dw::Textblock::addWidget | ( | core::Widget * | widget, |
| core::style::Style * | style | ||
| ) |
Add a widget (word type) to the page.
References dw::core::Requisition::ascent, dw::Textblock::Word::content, dw::core::Requisition::descent, dw::core::Widget::parentRef, PRINTF, dw::core::Widget::setParent(), dw::core::Widget::setStyle(), dw::core::Content::type, dw::core::Content::widget, and dw::core::Requisition::width.
Referenced by dw::ListItem::initWithWidget().
|
protected |
Add a new word (text, widget etc.) to a page.
|
protected |
Align the line.
References dw::Textblock::Word::content, dw::Textblock::Line::firstWord, dw::Textblock::Line::lastWord, dw::Textblock::Line::leftOffset, dw::Textblock::Word::origSpace, PRINTF, dw::Textblock::Word::style, dw::core::style::TEXT_ALIGN_CENTER, dw::core::style::TEXT_ALIGN_JUSTIFY, dw::core::style::TEXT_ALIGN_LEFT, dw::core::style::TEXT_ALIGN_RIGHT, dw::core::style::TEXT_ALIGN_STRING, dw::core::style::StyleAttrs::textAlign, dw::Textblock::Word::totalWidth, and dw::core::Content::type.
|
protectedvirtual |
Reimplemented from dw::core::Widget.
|
protectedvirtual |
Reimplemented from dw::core::Widget.
|
protected |
|
protected |
Calculate the size of a text word.
References dw::core::style::absLengthVal(), dw::core::Requisition::ascent, dw::core::style::Font::ascent, dw::core::Requisition::descent, dw::core::style::Font::descent, dw::core::style::StyleAttrs::font, dw::core::style::isAbsLength(), dw::core::style::LENGTH_AUTO, dw::core::style::StyleAttrs::lineHeight, dw::core::style::perLengthVal(), lout::misc::roundInt(), dw::core::style::FontAttrs::size, dw::core::style::StyleAttrs::valign, dw::core::style::VALIGN_SUB, dw::core::style::VALIGN_SUPER, and dw::core::Requisition::width.
|
protected |
References PRINTF, PUTCHAR, and dw::core::Requisition::width.
|
protected |
Calculate the size of a widget within the page. (Subject of change in the near future!)
References dw::core::style::absLengthVal(), dw::core::Requisition::ascent, dw::core::style::Box::bottom, dw::core::style::StyleAttrs::boxDiffHeight(), dw::core::style::StyleAttrs::boxDiffWidth(), dw::core::Requisition::descent, dw::core::Widget::getStyle(), dw::core::style::StyleAttrs::height, dw::core::style::isAbsLength(), dw::core::style::LENGTH_AUTO, dw::core::style::StyleAttrs::margin, dw::core::style::perLengthVal(), dw::core::Widget::setAscent(), dw::core::Widget::setDescent(), dw::core::Widget::setWidth(), dw::core::Widget::sizeRequest(), dw::core::style::Box::top, dw::core::Widget::usesHints(), dw::core::Requisition::width, and dw::core::style::StyleAttrs::width.
| void dw::Textblock::changeLinkColor | ( | int | link, |
| int | newColor | ||
| ) |
References dw::Textblock::Line::boxAscent, dw::Textblock::Line::boxDescent, dw::core::style::StyleAttrs::color, dw::Textblock::Word::content, dw::Textblock::Line::firstWord, dw::core::Widget::getStyle(), dw::core::style::StyleAttrs::setBorderColor(), dw::core::Widget::setStyle(), dw::Textblock::Word::spaceStyle, dw::Textblock::Word::style, dw::core::Content::type, dw::core::style::Style::unref(), dw::core::Content::widget, and dw::core::style::StyleAttrs::x_link.
| void dw::Textblock::changeWordStyle | ( | int | from, |
| int | to, | ||
| core::style::Style * | style, | ||
| bool | includeFirstSpace, | ||
| bool | includeLastSpace | ||
| ) |
|
protected |
References dw::core::style::Font::ascent, dw::core::style::StyleAttrs::color, dw::core::style::Font::descent, dw::core::View::drawRectangle(), dw::core::style::StyleAttrs::font, dw::core::style::TEXT_DECORATION_LINE_THROUGH, dw::core::style::TEXT_DECORATION_OVERLINE, dw::core::style::TEXT_DECORATION_UNDERLINE, dw::core::style::StyleAttrs::textDecoration, and dw::core::style::Font::xHeight.
|
protectedvirtual |
Area is given in widget coordinates.
Implements dw::core::Widget.
References dw::core::Rectangle::height, PRINTF, dw::core::Rectangle::width, dw::core::Rectangle::x, and dw::core::Rectangle::y.
|
protected |
References dw::Textblock::Line::boxAscent, dw::Textblock::Line::boxDescent, dw::Textblock::Word::content, dw::core::Widget::draw(), dw::Textblock::Word::effSpace, dw::Textblock::Line::firstWord, dw::core::style::StyleAttrs::hasBackground(), dw::core::Widget::intersects(), dw::Textblock::Word::size, dw::Textblock::Word::spaceStyle, dw::Textblock::Word::style, dw::core::Content::type, dw::core::Content::widget, dw::core::Rectangle::width, dw::core::Requisition::width, and dw::core::Rectangle::x.
|
protected |
References dw::core::style::Font::ascent, dw::core::style::StyleAttrs::backgroundColor, dw::core::style::Font::descent, dw::core::View::drawRectangle(), dw::Textblock::Word::effSpace, dw::core::style::StyleAttrs::font, dw::core::HIGHLIGHT_NUM_LAYERS, dw::Textblock::Word::spaceStyle, dw::core::style::StyleAttrs::textDecoration, dw::core::style::StyleAttrs::valign, dw::core::style::VALIGN_SUB, and dw::core::style::VALIGN_SUPER.
|
protected |
References dw::core::style::StyleAttrs::color, dw::core::View::drawText(), dw::core::style::StyleAttrs::font, dw::core::style::TEXT_TRANSFORM_CAPITALIZE, dw::core::style::TEXT_TRANSFORM_LOWERCASE, dw::core::style::TEXT_TRANSFORM_NONE, dw::core::style::TEXT_TRANSFORM_UPPERCASE, and dw::core::style::StyleAttrs::textTransform.
|
protected |
Draw a word of text.
Since hyphenated words consist of multiple instance of dw::Textblock::Word, which should be drawn as a whole (to preserve kerning etc.; see Changes in Line-Breaking and Hyphenation), two indices are passed. See also drawLine(), where drawWord() is called.
References dw::Textblock::Line::boxAscent, dw::Textblock::Line::boxDescent, dw::Textblock::Word::content, dw::core::style::StyleAttrs::hasBackground(), dw::Textblock::Line::lastWord, dw::Textblock::Word::size, dw::core::Content::text, and dw::core::Requisition::width.
|
protected |
TODO Comment
References dw::core::style::Font::ascent, dw::core::style::StyleAttrs::backgroundColor, dw::core::style::Font::descent, dw::core::View::drawRectangle(), dw::core::style::StyleAttrs::font, dw::core::HIGHLIGHT_NUM_LAYERS, lout::misc::min(), dw::core::style::StyleAttrs::textDecoration, dw::core::style::StyleAttrs::valign, dw::core::style::VALIGN_SUB, and dw::core::style::VALIGN_SUPER.
|
protectedvirtual |
Reimplemented from dw::core::Widget.
|
protected |
References dw::Textblock::Word::content, dw::Textblock::Word::effSpace, dw::core::style::StyleAttrs::font, dw::Textblock::Word::origSpace, dw::core::style::Style::ref(), dw::Textblock::Word::shrinkability, dw::core::Content::space, dw::Textblock::Word::spaceStyle, dw::core::style::Font::spaceWidth, dw::Textblock::Word::stretchability, dw::core::style::TEXT_ALIGN_JUSTIFY, dw::core::style::StyleAttrs::textAlign, dw::core::style::Style::unref(), and dw::core::style::StyleAttrs::wordSpacing.
|
protected |
References dw::core::Requisition::ascent, dw::Textblock::Word::badnessAndPenalty, dw::Textblock::Word::canBeHyphenated, dw::Textblock::Word::content, dw::core::Requisition::descent, dw::Textblock::Word::effSpace, dw::Textblock::Word::hyphenWidth, dw::Textblock::Word::origSpace, dw::core::style::Style::ref(), dw::Textblock::BadnessAndPenalty::setPenaltyProhibitBreak(), dw::Textblock::Word::shrinkability, dw::Textblock::Word::size, dw::core::Content::space, dw::Textblock::Word::spaceStyle, dw::Textblock::Word::stretchability, dw::Textblock::Word::style, and dw::core::Requisition::width.
|
protected |
Find the first line index that includes y, relative to top of widget.
|
protected |
Find the line of word wordIndex.
Referenced by dw::Textblock::TextblockIterator::getAllocation().
|
protected |
Find the index of the word, or -1.
References dw::core::Requisition::ascent, dw::core::style::Font::ascent, dw::Textblock::Line::boxAscent, dw::Textblock::Line::boxDescent, dw::Textblock::Word::effSpace, dw::Textblock::Line::firstWord, dw::core::style::StyleAttrs::font, dw::Textblock::Word::size, dw::Textblock::Word::spaceStyle, and dw::core::Requisition::width.
| void dw::Textblock::flush | ( | ) |
References PRINTF.
|
protectedvirtual |
Reimplemented from dw::core::Widget.
References dw::Textblock::Word::badnessAndPenalty, dw::Textblock::Word::hyphenWidth, dw::Textblock::Line::lastWord, dw::Textblock::BadnessAndPenalty::lineCanBeBroken(), dw::Textblock::BadnessAndPenalty::lineMustBeBroken(), lout::misc::max(), dw::Textblock::Line::maxParMax, dw::Textblock::Line::maxParMin, dw::core::Extremes::maxWidth, dw::core::Extremes::minWidth, dw::Textblock::Word::origSpace, dw::Textblock::Line::parMax, PRINTF, and dw::Textblock::Word::size.
|
virtual |
Search recursively through widget.
This is an optimized version of the general dw::core::Widget::getWidgetAtPoint method.
Reimplemented from dw::core::Widget.
References dw::Textblock::Word::content, dw::Textblock::Line::firstWord, dw::core::Widget::getWidgetAtPoint(), dw::core::Content::type, and dw::core::Content::widget.
|
protected |
Get the extremes of a word within a textblock.
References dw::core::style::absLengthVal(), dw::core::style::StyleAttrs::boxDiffWidth(), dw::Textblock::Word::content, dw::core::Widget::getExtremes(), dw::core::Widget::getStyle(), dw::core::Widget::hasContents(), dw::core::style::isAbsLength(), dw::core::style::isPerLength(), dw::core::Extremes::maxWidth, dw::core::Extremes::minWidth, dw::Textblock::Word::size, dw::Textblock::Word::style, dw::core::Content::type, dw::core::Widget::usesHints(), dw::core::Content::widget, dw::core::Requisition::width, and dw::core::style::StyleAttrs::width.
| void dw::Textblock::handOverBreak | ( | core::style::Style * | style | ) |
This function "hands" the last break of a page "over" to a parent page. This is used for "collapsing spaces".
References addParbreak(), and dw::Textblock::Line::breakSpace.
|
protected |
References dw::Textblock::Word::badnessAndPenalty, dw::Textblock::Word::content, dw::core::style::StyleAttrs::font, dw::Hyphenator::hyphenateWord(), dw::Textblock::Word::hyphenWidth, PRINTF, dw::Textblock::BadnessAndPenalty::setPenalty(), dw::core::Content::space, dw::Textblock::Word::spaceStyle, dw::Textblock::Word::style, dw::core::Content::text, dw::core::Content::type, dw::core::style::Style::unref(), dw::Textblock::Anchor::wordIndex, and dw::core::style::StyleAttrs::x_lang.
|
protected |
References dw::core::style::absLengthVal(), dw::core::Widget::blockLevel(), dw::Textblock::Word::content, dw::core::style::isPerLength(), dw::core::style::perLengthVal(), lout::misc::roundInt(), dw::Textblock::Word::size, dw::core::Content::type, dw::core::Content::widget, and dw::core::Requisition::width.
|
virtual |
Return an iterator for this widget.
mask can narrow the types returned by the iterator, this can enhance performance quite much, e.g. when only searching for child widgets.
With atEnd == false, the iterator starts before the beginning, i.e. the first call of dw::core::Iterator::next will let the iterator point on the first piece of contents. Likewise, With atEnd == true, the iterator starts after the last piece of contents, call dw::core::Iterator::prev in this case.
Implements dw::core::Widget.
|
protected |
|
protectedvirtual |
Reimplemented from dw::core::Widget.
References dw::core::style::Tooltip::onLeave().
|
inlineprotected |
Returns the x offset (the indentation plus any offset needed for centering or right justification) for the line.
The offset returned is relative to the page content (i.e. without border etc.).
References lout::misc::SimpleVector< T >::getFirstRef(), innerPadding, dw::Textblock::Line::leftOffset, line1OffsetEff, and lines.
Referenced by lineXOffsetWidget().
|
inlineprotected |
Like lineXOffset, but relative to the allocation (i.e. including border etc.).
References dw::core::style::StyleAttrs::boxOffsetX(), dw::core::Widget::getStyle(), and lineXOffsetContents().
Referenced by dw::Textblock::TextblockIterator::getAllocation().
|
inlineprotected |
Returns the y offset (within the canvas) of a line.
References dw::core::Widget::allocation, and lineYOffsetCanvasAllocation().
Referenced by dw::Textblock::TextblockIterator::getAllocation(), and lineYOffsetCanvasI().
|
inlineprotected |
Like lineYOffsetCanvas, but with the allocation as parameter.
References lineYOffsetWidgetAllocation(), and dw::core::Allocation::y.
Referenced by lineYOffsetCanvas().
|
inlineprotected |
References lout::misc::SimpleVector< T >::getRef(), lines, and lineYOffsetCanvas().
|
inlineprotected |
References dw::core::Widget::allocation, and lineYOffsetWidgetAllocation().
Referenced by lineYOffsetWidgetI().
|
inlineprotected |
References dw::core::Allocation::ascent, dw::Textblock::Line::boxAscent, lout::misc::SimpleVector< T >::getRef(), lines, and dw::Textblock::Line::top.
Referenced by lineYOffsetCanvasAllocation(), and lineYOffsetWidget().
|
inlineprotected |
References lout::misc::SimpleVector< T >::getRef(), lines, and lineYOffsetWidget().
|
protected |
References lout::misc::min(), and PRINTF.
|
protectedvirtual |
Reimplemented from dw::core::Widget.
|
protectedvirtual |
Reimplemented from dw::core::Widget.
|
protectedvirtual |
Reimplemented from dw::core::Widget.
References dw::core::BUTTON1_MASK, dw::core::style::StyleAttrs::cursor, hoverTooltip, dw::core::style::Tooltip::onEnter(), dw::core::style::Tooltip::onLeave(), dw::core::style::Tooltip::onMotion(), dw::Textblock::Word::spaceStyle, dw::core::MouseEvent::state, dw::Textblock::Word::style, dw::core::style::StyleAttrs::x_link, dw::core::style::StyleAttrs::x_tooltip, dw::core::MousePositionEvent::xWidget, and dw::core::MousePositionEvent::yWidget.
|
protected |
References dw::Textblock::Word::badnessAndPenalty, dw::Textblock::Word::content, dw::Textblock::Word::origSpace, dw::Textblock::BadnessAndPenalty::print(), dw::Textblock::Word::shrinkability, dw::Textblock::Word::size, dw::Textblock::Word::stretchability, dw::core::Content::text, dw::Textblock::Word::totalShrinkability, dw::Textblock::Word::totalStretchability, dw::Textblock::Word::totalWidth, dw::core::Content::type, dw::core::Content::widget, and dw::core::Requisition::width.
|
protected |
|
protected |
|
protectedvirtual |
Called after sizeAllocateImpl() to redraw necessary areas. By default the whole widget is redrawn.
Reimplemented from dw::core::Widget.
References dw::Textblock::Line::lastWord.
|
protected |
Rewrap the page from the line from which this is necessary. There are basically two times we'll want to do this: either when the viewport is resized, or when the size changes on one of the child widgets.
References dw::Textblock::Word::content, lout::misc::min(), dw::core::Widget::parentRef, PRINTF, dw::Textblock::Word::size, dw::core::Content::type, and dw::core::Content::widget.
|
protected |
Send event to selection.
References dw::core::Requisition::ascent, dw::core::style::Font::ascent, dw::Textblock::Line::boxAscent, dw::Textblock::Line::boxDescent, dw::Textblock::Word::content, dw::core::Requisition::descent, dw::core::style::Font::descent, dw::Textblock::Word::effSpace, dw::Textblock::Line::firstWord, dw::core::style::StyleAttrs::font, dw::Textblock::Line::lastWord, dw::Textblock::Word::size, dw::Textblock::Word::spaceStyle, dw::Textblock::Word::style, dw::core::Content::text, dw::core::Content::type, dw::core::Iterator::unref(), dw::core::Requisition::width, dw::core::style::StyleAttrs::x_link, dw::core::MousePositionEvent::xWidget, dw::core::MousePositionEvent::yCanvas, and dw::core::MousePositionEvent::yWidget.
|
protectedvirtual |
Reimplemented from dw::core::Widget.
|
protected |
Set a break option, if allowed by the style. Called by fillSpace (and so addSpace), but may be called, via addBreakOption(), as an alternative, e. g. for ideographic characters.
References dw::Textblock::Word::badnessAndPenalty, dw::Textblock::BadnessAndPenalty::lineMustBeBroken(), dw::Textblock::BadnessAndPenalty::setPenalty(), dw::Textblock::BadnessAndPenalty::setPenaltyProhibitBreak(), dw::core::style::WHITE_SPACE_NORMAL, dw::core::style::WHITE_SPACE_NOWRAP, dw::core::style::WHITE_SPACE_PRE, dw::core::style::WHITE_SPACE_PRE_LINE, dw::core::style::WHITE_SPACE_PRE_WRAP, and dw::core::style::StyleAttrs::whiteSpace.
Referenced by addBreakOption().
|
protectedvirtual |
Reimplemented from dw::core::Widget.
|
protectedvirtual |
Reimplemented from dw::core::Widget.
|
protected |
References PRINTF.
|
protectedvirtual |
Reimplemented from dw::core::Widget.
References dw::core::Allocation::ascent, dw::core::Requisition::ascent, dw::core::style::Box::bottom, dw::Textblock::Line::boxAscent, dw::Textblock::Word::content, dw::core::Allocation::descent, dw::core::Requisition::descent, dw::Textblock::Word::effSpace, dw::Textblock::Line::firstWord, dw::core::Widget::getAllocation(), dw::core::Widget::getStyle(), dw::Textblock::Line::lastWord, dw::core::style::StyleAttrs::margin, lout::misc::min(), dw::Textblock::Anchor::name, PRINTF, dw::Textblock::Word::size, dw::core::Widget::sizeAllocate(), dw::core::style::Box::top, dw::core::Content::type, dw::core::Widget::wasAllocated(), dw::core::Content::widget, dw::core::Allocation::width, dw::core::Requisition::width, dw::Textblock::Anchor::wordIndex, dw::core::Allocation::x, and dw::core::Allocation::y.
|
protectedvirtual |
The ascent of a textblock is the ascent of the first line, plus padding/border/margin. This can be used to align the first lines of several textblocks in a horizontal line.
Implements dw::core::Widget.
References dw::core::Requisition::ascent, dw::Textblock::Line::boxAscent, dw::Textblock::Line::boxDescent, dw::core::Requisition::descent, dw::Textblock::Line::maxLineWidth, PRINTF, dw::Textblock::Line::top, and dw::core::Requisition::width.
|
protected |
References dw::core::style::StyleAttrs::font, dw::core::style::TEXT_TRANSFORM_CAPITALIZE, dw::core::style::TEXT_TRANSFORM_LOWERCASE, dw::core::style::TEXT_TRANSFORM_NONE, dw::core::style::TEXT_TRANSFORM_UPPERCASE, and dw::core::style::StyleAttrs::textTransform.
Referenced by dw::Textblock::TextblockIterator::getAllocation().
|
protectedvirtual |
Reimplemented in dw::TableCell.
References dw::Textblock::Word::badnessAndPenalty, dw::Textblock::Word::canBeHyphenated, dw::Textblock::BadnessAndPenalty::compareTo(), dw::Textblock::Word::content, dw::Textblock::Word::effSpace, dw::Textblock::BadnessAndPenalty::lineLoose(), dw::Textblock::BadnessAndPenalty::lineMustBeBroken(), dw::Textblock::BadnessAndPenalty::lineTight(), dw::Textblock::BadnessAndPenalty::lineTooTight(), dw::Textblock::Word::origSpace, PRINTF, dw::Textblock::BadnessAndPenalty::setPenalty(), dw::Textblock::Word::style, dw::core::Content::text, dw::core::Content::type, and dw::core::style::StyleAttrs::x_lang.
Referenced by dw::TableCell::wordWrap().
|
friend |
Referenced by dw::Textblock::TextblockIterator::clone().
|
protected |
|
protected |
|
protected |
|
protected |
|
static |
|
protected |
Referenced by addParbreak(), dw::ListItem::initWithText(), and dw::ListItem::initWithWidget().
| struct { ... } dw::Textblock::hlEnd[core::HIGHLIGHT_NUM_LAYERS] |
| struct { ... } dw::Textblock::hlStart[core::HIGHLIGHT_NUM_LAYERS] |
|
protected |
|
protected |
| int dw::Textblock::index |
Referenced by dw::Textblock::TextblockIterator::clone(), dw::Textblock::TextblockIterator::compareTo(), dw::Textblock::TextblockIterator::getAllocation(), dw::Textblock::TextblockIterator::highlight(), dw::Textblock::TextblockIterator::next(), dw::Textblock::TextblockIterator::prev(), and dw::Textblock::TextblockIterator::unhighlight().
|
protected |
Referenced by lineXOffsetContents(), and dw::ListItem::setMaxValue().
|
protected |
|
protected |
|
protected |
Referenced by dw::ListItem::setMaxValue(), and dw::TableCell::setMaxValue().
|
protected |
Referenced by lineXOffsetContents().
|
protected |
|
protected |
Referenced by addParbreak().
| int dw::Textblock::nChar |
|
protected |
|
protected |
Referenced by dw::ListItem::setMaxValue().
|
protected |
Referenced by addBreakOption(), addParbreak(), dw::Textblock::TextblockIterator::getAllocation(), dw::ListItem::getValue(), dw::TableCell::getValue(), dw::Textblock::TextblockIterator::next(), dw::Textblock::TextblockIterator::prev(), dw::Textblock::TextblockIterator::TextblockIterator(), and dw::TableCell::wordWrap().
|
protected |
1.8.2