dillo  3.0.5
About: dillo is a small, fast, extensible Web browser particularly suitable for older or smaller computers and embedded systems (but only limited or no support for frames, CSS, JavaScript, Java).
  Fossies Dox: dillo-3.0.5.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

dw::Textblock Class Reference

A Widget for rendering text blocks, i.e. paragraphs or sequences of paragraphs. More...

#include <textblock.hh>

Inheritance diagram for dw::Textblock:
[legend]
Collaboration diagram for dw::Textblock:
[legend]

Classes

struct  Anchor
 
class  BadnessAndPenalty
 
struct  DivChar
 
struct  Line
 
struct  Paragraph
 
class  SpaceImgRenderer
 
class  TextblockIterator
 
struct  Word
 
class  WordImgRenderer
 Implementation used for words. More...
 

Public Member Functions

 Textblock (bool limitTextWidth)
 
 ~Textblock ()
 
core::Iteratoriterator (core::Content::Type mask, bool atEnd)
 Return an iterator for this widget. More...
 
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, bool forceBreak)
 
void addParbreak (int space, core::style::Style *style)
 
void addLinebreak (core::style::Style *style)
 
core::WidgetgetWidgetAtPoint (int x, int y, int level)
 Search recursively through widget. More...
 
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::StylegetStyle ()
 
AllocationgetAllocation ()
 
void sizeRequest (Requisition *requisition)
 This method is a wrapper for Widget::sizeRequestImpl(); it calls the latter only when needed. More...
 
void getExtremes (Extremes *extremes)
 Wrapper for Widget::getExtremesImpl(). More...
 
void sizeAllocate (Allocation *allocation)
 Wrapper for Widget::sizeAllocateImpl, calls the latter only when needed. More...
 
bool intersects (Rectangle *area, Rectangle *intersection)
 Calculates the intersection of widget->allocation and area, returned in intersection (in widget coordinates!). More...
 
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. More...
 
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. More...
 
style::ColorgetBgColor ()
 Get the actual background of a widget. More...
 
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). More...
 
void drawWidgetBox (View *view, Rectangle *area, bool inverse)
 Draw borders and background of a widget. More...
 
void drawSelected (View *view, Rectangle *area)
 
void setButtonSensitive (bool buttonSensitive)
 
bool isButtonSensitive ()
 
WidgetgetParent ()
 
WidgetgetTopLevel ()
 Get the widget at the root of the tree, this widget is part from. More...
 
int getLevel ()
 Get the level of the widget within the tree. More...
 
WidgetgetNearestCommonAncestor (Widget *otherWidget)
 Get the widget with the highest level, which is a direct ancestor of widget1 and widget2. More...
 
LayoutgetLayout ()
 
void scrollTo (HPosition hpos, VPosition vpos, int x, int y, int width, int height)
 
void getPaddingArea (int *xPad, int *yPad, int *widthPad, int *heightPad)
 Return the padding area (content plus padding). More...
 
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. More...
 
int getClassId ()
 Returns the class identifier. More...
 
const char * getClassName ()
 Return the name, under which the class of this object was registered. More...
 
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. More...
 
- 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. More...
 
virtual bool equals (Object *other)
 Returns, whether two objects are equal. More...
 
virtual int hashValue ()
 Return a hash value for the object. More...
 
virtual Objectclone ()
 Return an exact copy of the object. More...
 
const char * toString ()
 Use object::Object::intoStringBuffer to return a textual representation of the object. More...
 
virtual size_t sizeOf ()
 Return the number of bytes, this object totally uses. More...
 

Static Public Member Functions

static void setPenaltyHyphen (int penaltyHyphen)
 
static void setPenaltyHyphen2 (int penaltyHyphen2)
 
static void setPenaltyEmDashLeft (int penaltyLeftEmDash)
 
static void setPenaltyEmDashRight (int penaltyRightEmDash)
 
static void setPenaltyEmDashRight2 (int penaltyRightEmDash2)
 
static void setStretchabilityFactor (int stretchabilityFactor)
 

Static Public Attributes

static int CLASS_ID = -1
 
- Static Public Attributes inherited from dw::core::Widget
static int CLASS_ID = -1
 

Protected Member Functions

void printWordShort (Word *word)
 
void printWordFlags (short flags)
 
void printWordWithFlags (Word *word)
 
void printWord (Word *word)
 
void queueDrawRange (int index1, int index2)
 
void getWordExtremes (Word *word, core::Extremes *extremes)
 
void justifyLine (Line *line, int diff)
 
LineaddLine (int firstWord, int lastWord, bool temporary)
 
void calcWidgetSize (core::Widget *widget, core::Requisition *size)
 
void rewrap ()
 
void fillParagraphs ()
 
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, bool isStart, bool isEnd)
 
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, bool drawHyphen, 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. More...
 
int findParagraphOfWord (int wordIndex)
 Find the paragraph of word wordIndex. More...
 
WordfindWord (int x, int y, bool *inSpace)
 Find the index of the word, or -1. More...
 
WordaddWord (int width, int ascent, int descent, short flags, core::style::Style *style)
 
void initWord (int wordNo)
 
void removeWordImgRenderer (int wordNo)
 
void setWordImgRenderer (int wordNo)
 
void removeSpaceImgRenderer (int wordNo)
 
void setSpaceImgRenderer (int wordNo)
 
void fillWord (int wordNo, int width, int ascent, int descent, short flags, core::style::Style *style)
 
void fillSpace (int wordNo, core::style::Style *style)
 
void setBreakOption (Word *word, core::style::Style *style, int breakPenalty1, int breakPenalty2, bool forceBreak)
 
bool isBreakAllowed (Word *word)
 
int textWidth (const char *text, int start, int len, core::style::Style *style, bool isStart, bool isEnd)
 
void calcTextSize (const char *text, size_t len, core::style::Style *style, core::Requisition *size, bool isStart, bool isEnd)
 
int lineXOffsetContents (Line *line)
 Returns the x offset (the indentation plus any offset needed for centering or right justification) for the line. More...
 
int lineXOffsetWidget (Line *line)
 Like lineXOffset, but relative to the allocation (i.e. including border etc.). More...
 
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)
 
int calcPenaltyIndexForNewLine ()
 
bool sendSelectionEvent (core::SelectionState::EventType eventType, core::MousePositionEvent *event)
 Send event to selection. More...
 
void accumulateWordExtremes (int firstWord, int lastWord, int *maxOfMinWidth, int *sumOfMaxWidth)
 
void processWord (int wordIndex)
 
virtual bool wordWrap (int wordIndex, bool wrapAll)
 
int searchMinBap (int firstWord, int lastWordm, int penaltyIndex, bool correctAtEnd)
 
int considerHyphenation (int firstIndex, int breakPos)
 
bool isHyphenationCandidate (Word *word)
 
void handleWordExtremes (int wordIndex)
 
void correctLastWordExtremes ()
 
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. More...
 
void sizeAllocateImpl (core::Allocation *allocation)
 See Sizes of Dillo Widgets. More...
 
void resizeDrawImpl ()
 Called after sizeAllocateImpl() to redraw necessary areas. By default the whole widget is redrawn. More...
 
void markSizeChange (int ref)
 See Sizes of Dillo Widgets. More...
 
void markExtremesChange (int ref)
 See Sizes of Dillo Widgets. More...
 
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, short flags, 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. More...
 
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 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. More...
 

Static Protected Member Functions

static int getSpaceShrinkability (struct Word *word)
 
static int getSpaceStretchability (struct Word *word)
 
static int getLineShrinkability (Word *lastWord)
 
static int getLineStretchability (Word *lastWord)
 

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 wrapRefLines
 
int wrapRefParagraphs
 
lout::misc::SimpleVector< Line > * lines
 
lout::misc::SimpleVector< Paragraph > * paragraphs
 
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
WidgetImgRendererwidgetImgRenderer
 
Allocation allocation
 The current allocation: size and position, always relative to the canvas. More...
 
Layoutlayout
 

Static Protected Attributes

static int penalties [PENALTY_NUM][2]
 
static int stretchabilityFactor = 100
 

Private Types

enum  { PENALTY_FORCE_BREAK = INT_MIN, PENALTY_PROHIBIT_BREAK = INT_MAX }
 
enum  { PENALTY_HYPHEN, PENALTY_EM_DASH_LEFT, PENALTY_EM_DASH_RIGHT, PENALTY_NUM }
 
enum  { NUM_DIV_CHARS = 4 }
 

Static Private Attributes

static DivChar divChars [NUM_DIV_CHARS]
 
static const char * hyphenDrawChar = "-"
 

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. More...
 
- 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
}
 

Detailed Description

A Widget for rendering text blocks, i.e. paragraphs or sequences of paragraphs.

Info: The recent changes (line breaking and hyphenation) have not yet been incorporated into this documentation. See Changes in Line-Breaking and Hyphenation.

Signals

dw::Textblock uses the signals defined in dw::core::Layout::LinkReceiver, related to links. The coordinates are always -1.

Collapsing Spaces

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:

  1. If a paragraph is following by another, the space between them is the maximum of both box spaces:

    are combined like this:

  2. 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.

  • To collapse spaces according to rule 2b, dw::Textblock::addParBreak::handOverBreak must be called for the inner widget. The HTML parser does this in Html_eventually_pop_dw.

Collapsing Margins

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.)

Some Internals

There are 4 lists, dw::Textblock::words, dw::Textblock::paragraphs, 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.

A recent change was the introduction of the paragraphs list, which works quite similar, is also redundant, but is used to calculate the extremes, not the size.

Anchors associate the anchor name with the index of the next word at the point of the anchor.

Incremental Resizing

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)

  • A word (or widget, break etc.) is added to the text block. This makes it possible to reuse the old size by simply adjusting the current width and height, so no rewrapping is necessary.

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.

Definition at line 149 of file textblock.hh.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private

This class encapsulates the badness/penalty calculation, and so (i) makes changes (hopefully) simpler, and (ii) hides the integer arithmetic (floating point arithmetic avoided for performance reasons). Unfortunately, the value range of the badness is not well defined, so fiddling with the penalties is a bit difficult.

Enumerator
PENALTY_FORCE_BREAK 
PENALTY_PROHIBIT_BREAK 

Definition at line 161 of file textblock.hh.

◆ anonymous enum

anonymous enum
private
Enumerator
PENALTY_HYPHEN 
PENALTY_EM_DASH_LEFT 
PENALTY_EM_DASH_RIGHT 
PENALTY_NUM 

Definition at line 224 of file textblock.hh.

◆ anonymous enum

anonymous enum
private
Enumerator
NUM_DIV_CHARS 

Definition at line 226 of file textblock.hh.

Constructor & Destructor Documentation

◆ Textblock()

dw::Textblock::Textblock ( bool  limitTextWidth)

Definition at line 223 of file textblock.cc.

References DBG_OBJ_CREATE, and dw::core::HIGHLIGHT_NUM_LAYERS.

◆ ~Textblock()

Member Function Documentation

◆ accumulateWordData()

◆ accumulateWordExtremes()

void dw::Textblock::accumulateWordExtremes ( int  firstWord,
int  lastWord,
int *  maxOfMinWidth,
int *  sumOfMaxWidth 
)
protected

◆ accumulateWordForLine()

◆ addAnchor()

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.

Todo:
It may be necessary for future uses to save the anchor in some way, e.g. when parts of the widget tree change.

Definition at line 1987 of file textblock.cc.

References dw::Textblock::Anchor::name, and dw::Textblock::Anchor::wordIndex.

◆ addBreakOption()

void dw::Textblock::addBreakOption ( core::style::Style style,
bool  forceBreak 
)

Add a break option (see setBreakOption() for details). Used instead of addStyle for ideographic characters.

When "forceBreak" is true, a break is even possible within PRE etc.

Definition at line 2040 of file textblock.cc.

◆ addLine()

◆ addLinebreak()

◆ addParbreak()

◆ addSpace()

void dw::Textblock::addSpace ( core::style::Style style)

◆ addText() [1/2]

void dw::Textblock::addText ( const char *  text,
core::style::Style style 
)
inline

Definition at line 686 of file textblock.hh.

References addText(), and dw::core::Widget::style.

◆ addText() [2/2]

void dw::Textblock::addText ( const char *  text,
size_t  len,
core::style::Style style 
)

Add a word to the page structure. If it contains dividing characters (hard or soft hyphens, em-dashes, etc.), it is divided.

Definition at line 1676 of file textblock.cc.

References dw::core::style::StyleAttrs::font, dw::Textblock::Word::hyphenWidth, lout::unicode::nextUtf8Char(), PRINTF, PUTCHAR, and dw::Textblock::Word::style.

Referenced by addText(), Html_tag_content_frame(), and dw::ListItem::initWithText().

◆ addText0()

void dw::Textblock::addText0 ( const char *  text,
size_t  len,
short  flags,
core::style::Style style,
core::Requisition size 
)
protected

◆ addWidget()

◆ addWord()

Textblock::Word * dw::Textblock::addWord ( int  width,
int  ascent,
int  descent,
short  flags,
core::style::Style style 
)
protected

Add a new word (text, widget etc.) to a page.

Definition at line 1457 of file textblock.cc.

References dw::Textblock::Word::size.

◆ alignLine()

◆ buttonPressImpl()

bool dw::Textblock::buttonPressImpl ( core::EventButton event)
protectedvirtual

Reimplemented from dw::core::Widget.

Definition at line 652 of file textblock.cc.

◆ buttonReleaseImpl()

bool dw::Textblock::buttonReleaseImpl ( core::EventButton event)
protectedvirtual

Reimplemented from dw::core::Widget.

Definition at line 657 of file textblock.cc.

◆ calcAvailWidth()

int dw::Textblock::calcAvailWidth ( int  lineIndex)
protected

Definition at line 1081 of file textblock_linebreaking.cc.

◆ calcPenaltyIndexForNewLine()

int dw::Textblock::calcPenaltyIndexForNewLine ( )
inlineprotected

◆ calcTextSize()

◆ calcTextSizes()

void dw::Textblock::calcTextSizes ( const char *  text,
size_t  textLen,
core::style::Style style,
int  numBreaks,
int *  breakPos,
core::Requisition wordSize 
)
protected

Definition at line 1886 of file textblock.cc.

References PRINTF, PUTCHAR, and dw::core::Requisition::width.

◆ calcWidgetSize()

◆ changeLinkColor()

◆ changeWordStyle()

void dw::Textblock::changeWordStyle ( int  from,
int  to,
core::style::Style style,
bool  includeFirstSpace,
bool  includeLastSpace 
)

Definition at line 2369 of file textblock.cc.

◆ considerHyphenation()

int dw::Textblock::considerHyphenation ( int  firstIndex,
int  breakPos 
)
protected

Suggest a word to hyphenate, when breaking at breakPos is planned. Return a word index or -1, when hyphenation makes no sense.

Definition at line 722 of file textblock_linebreaking.cc.

References dw::Textblock::Word::badnessAndPenalty, dw::Textblock::BadnessAndPenalty::lineLoose(), and dw::Textblock::BadnessAndPenalty::lineTight().

◆ correctLastWordExtremes()

void dw::Textblock::correctLastWordExtremes ( )
protected

Called when something changed for the last word (space, hyphens etc.).

Definition at line 849 of file textblock_linebreaking.cc.

References dw::Textblock::Word::badnessAndPenalty, dw::Textblock::Word::flags, dw::Textblock::BadnessAndPenalty::lineCanBeBroken(), and PRINTF.

◆ decorateText()

◆ draw()

void dw::Textblock::draw ( core::View view,
core::Rectangle area 
)
protectedvirtual

Area is given in widget coordinates.

Implements dw::core::Widget.

Definition at line 1433 of file textblock.cc.

References dw::core::Rectangle::height, PRINTF, dw::core::Rectangle::width, dw::core::Rectangle::x, and dw::core::Rectangle::y.

◆ drawLine()

◆ drawSpace()

◆ drawText()

◆ drawWord()

void dw::Textblock::drawWord ( Line line,
int  wordIndex1,
int  wordIndex2,
core::View view,
core::Rectangle area,
int  xWidget,
int  yWidgetBase 
)
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.

Definition at line 1039 of file textblock.cc.

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.

◆ drawWord0()

void dw::Textblock::drawWord0 ( int  wordIndex1,
int  wordIndex2,
const char *  text,
int  totalWidth,
bool  drawHyphen,
core::style::Style style,
core::View view,
core::Rectangle area,
int  xWidget,
int  yWidgetBase 
)
protected

◆ enterNotifyImpl()

void dw::Textblock::enterNotifyImpl ( core::EventCrossing event)
protectedvirtual

Reimplemented from dw::core::Widget.

Definition at line 709 of file textblock.cc.

References _MSG, and hoverTooltip.

◆ fillParagraphs()

void dw::Textblock::fillParagraphs ( )
protected

Counter part to rewrap(), but for extremes, not size calculation.

Definition at line 1229 of file textblock_linebreaking.cc.

References lout::misc::max(), and PRINTF.

◆ fillSpace()

◆ fillWord()

◆ findLineIndex()

int dw::Textblock::findLineIndex ( int  y)
protected

Find the first line index that includes y, relative to top of widget.

Definition at line 1308 of file textblock.cc.

◆ findLineOfWord()

int dw::Textblock::findLineOfWord ( int  wordIndex)
protected

Find the line of word wordIndex.

Definition at line 1341 of file textblock.cc.

Referenced by dw::Textblock::TextblockIterator::getAllocation().

◆ findParagraphOfWord()

int dw::Textblock::findParagraphOfWord ( int  wordIndex)
protected

Find the paragraph of word wordIndex.

Definition at line 1364 of file textblock.cc.

◆ findWord()

◆ flush()

void dw::Textblock::flush ( )

Definition at line 2304 of file textblock.cc.

References PRINTF.

◆ getExtremesImpl()

void dw::Textblock::getExtremesImpl ( core::Extremes extremes)
protectedvirtual

◆ getLineShrinkability()

int dw::Textblock::getLineShrinkability ( Word lastWord)
staticprotected

Definition at line 1307 of file textblock_linebreaking.cc.

◆ getLineStretchability()

◆ getSpaceShrinkability()

int dw::Textblock::getSpaceShrinkability ( struct Word word)
staticprotected

◆ getSpaceStretchability()

int dw::Textblock::getSpaceStretchability ( struct Word word)
staticprotected

◆ getWidgetAtPoint()

core::Widget * dw::Textblock::getWidgetAtPoint ( int  x,
int  y,
int  level 
)
virtual

Search recursively through widget.

This is an optimized version of the general dw::core::Widget::getWidgetAtPoint method.

Reimplemented from dw::core::Widget.

Definition at line 2243 of file textblock.cc.

References dw::Textblock::Word::content, dw::Textblock::Line::firstWord, dw::core::Widget::getWidgetAtPoint(), dw::core::Content::type, and dw::core::Content::widget.

◆ getWordExtremes()

◆ handleWordExtremes()

◆ handOverBreak()

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".

Definition at line 2284 of file textblock.cc.

References addParbreak(), and dw::Textblock::Line::breakSpace.

◆ hyphenateWord()

◆ initLine1Offset()

◆ initWord()

void dw::Textblock::initWord ( int  wordNo)
protected

Basic initialization, which is neccessary before fillWord.

Definition at line 1470 of file textblock.cc.

References dw::Textblock::Word::spaceImgRenderer, dw::Textblock::Word::spaceStyle, dw::Textblock::Word::style, and dw::Textblock::Word::wordImgRenderer.

◆ isBreakAllowed()

◆ isHyphenationCandidate()

◆ iterator()

core::Iterator * dw::Textblock::iterator ( core::Content::Type  mask,
bool  atEnd 
)
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.

Definition at line 875 of file textblock.cc.

◆ justifyLine()

void dw::Textblock::justifyLine ( Line line,
int  diff 
)
protected

◆ leaveNotifyImpl()

void dw::Textblock::leaveNotifyImpl ( core::EventCrossing event)
protectedvirtual

Reimplemented from dw::core::Widget.

Definition at line 716 of file textblock.cc.

References _MSG, hoverTooltip, and dw::core::style::Tooltip::onLeave().

◆ lineXOffsetContents()

int dw::Textblock::lineXOffsetContents ( Line line)
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.).

Definition at line 552 of file textblock.hh.

References innerPadding, dw::Textblock::Line::leftOffset, line1OffsetEff, and lines.

Referenced by lineXOffsetWidget().

◆ lineXOffsetWidget()

int dw::Textblock::lineXOffsetWidget ( Line line)
inlineprotected

Like lineXOffset, but relative to the allocation (i.e. including border etc.).

Definition at line 562 of file textblock.hh.

References dw::core::style::StyleAttrs::boxOffsetX(), dw::core::Widget::getStyle(), and lineXOffsetContents().

Referenced by dw::Textblock::TextblockIterator::getAllocation().

◆ lineYOffsetCanvas()

int dw::Textblock::lineYOffsetCanvas ( Line line)
inlineprotected

Returns the y offset (within the canvas) of a line.

Definition at line 590 of file textblock.hh.

References dw::core::Widget::allocation, and lineYOffsetCanvasAllocation().

Referenced by dw::Textblock::TextblockIterator::getAllocation(), and lineYOffsetCanvasI().

◆ lineYOffsetCanvasAllocation()

int dw::Textblock::lineYOffsetCanvasAllocation ( Line line,
core::Allocation allocation 
)
inlineprotected

Like lineYOffsetCanvas, but with the allocation as parameter.

Definition at line 581 of file textblock.hh.

References dw::core::Widget::allocation, lineYOffsetWidgetAllocation(), and dw::core::Allocation::y.

Referenced by lineYOffsetCanvas().

◆ lineYOffsetCanvasI()

int dw::Textblock::lineYOffsetCanvasI ( int  lineIndex)
inlineprotected

Definition at line 600 of file textblock.hh.

References lines, and lineYOffsetCanvas().

◆ lineYOffsetWidget()

int dw::Textblock::lineYOffsetWidget ( Line line)
inlineprotected

Definition at line 573 of file textblock.hh.

References dw::core::Widget::allocation, and lineYOffsetWidgetAllocation().

Referenced by lineYOffsetWidgetI().

◆ lineYOffsetWidgetAllocation()

int dw::Textblock::lineYOffsetWidgetAllocation ( Line line,
core::Allocation allocation 
)
inlineprotected

◆ lineYOffsetWidgetI()

int dw::Textblock::lineYOffsetWidgetI ( int  lineIndex)
inlineprotected

Definition at line 595 of file textblock.hh.

References lines, and lineYOffsetWidget().

◆ markExtremesChange()

void dw::Textblock::markExtremesChange ( int  ref)
protectedvirtual

See Sizes of Dillo Widgets.

Reimplemented from dw::core::Widget.

Definition at line 587 of file textblock.cc.

References lout::misc::min(), and PRINTF.

◆ markSizeChange()

void dw::Textblock::markSizeChange ( int  ref)
protectedvirtual

See Sizes of Dillo Widgets.

Reimplemented from dw::core::Widget.

Definition at line 562 of file textblock.cc.

References lout::misc::min(), and PRINTF.

◆ motionNotifyImpl()

◆ printWord()

◆ printWordFlags()

void dw::Textblock::printWordFlags ( short  flags)
protected

Definition at line 252 of file textblock_linebreaking.cc.

◆ printWordShort()

◆ printWordWithFlags()

void dw::Textblock::printWordWithFlags ( Word word)
protected

Definition at line 264 of file textblock_linebreaking.cc.

References dw::Textblock::Word::flags.

◆ processWord()

void dw::Textblock::processWord ( int  wordIndex)
protected

Definition at line 475 of file textblock_linebreaking.cc.

◆ queueDrawRange()

void dw::Textblock::queueDrawRange ( int  index1,
int  index2 
)
protected

◆ removeChild()

void dw::Textblock::removeChild ( Widget child)
protected
Bug:
Not implemented.

Definition at line 870 of file textblock.cc.

◆ removeSpaceImgRenderer()

void dw::Textblock::removeSpaceImgRenderer ( int  wordNo)
protected

◆ removeTemporaryLines()

void dw::Textblock::removeTemporaryLines ( )
protected

Definition at line 1284 of file textblock_linebreaking.cc.

◆ removeWordImgRenderer()

void dw::Textblock::removeWordImgRenderer ( int  wordNo)
protected

◆ resizeDrawImpl()

void dw::Textblock::resizeDrawImpl ( )
protectedvirtual

Called after sizeAllocateImpl() to redraw necessary areas. By default the whole widget is redrawn.

Reimplemented from dw::core::Widget.

Definition at line 548 of file textblock.cc.

References dw::Textblock::Line::lastWord.

◆ rewrap()

void dw::Textblock::rewrap ( )
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.

Definition at line 1185 of file textblock_linebreaking.cc.

References dw::Textblock::Word::content, lout::misc::min(), PRINTF, dw::Textblock::Word::size, dw::core::Content::type, and dw::core::Content::widget.

◆ searchMinBap()

int dw::Textblock::searchMinBap ( int  firstWord,
int  lastWordm,
int  penaltyIndex,
bool  correctAtEnd 
)
protected

◆ sendSelectionEvent()

◆ setAscent()

void dw::Textblock::setAscent ( int  ascent)
protectedvirtual

Reimplemented from dw::core::Widget.

Definition at line 624 of file textblock.cc.

◆ setBreakOption()

void dw::Textblock::setBreakOption ( Word word,
core::style::Style style,
int  breakPenalty1,
int  breakPenalty2,
bool  forceBreak 
)
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.

Definition at line 2101 of file textblock.cc.

References dw::Textblock::Word::badnessAndPenalty, dw::Textblock::BadnessAndPenalty::lineMustBeBroken(), dw::Textblock::BadnessAndPenalty::setPenalties(), and dw::Textblock::BadnessAndPenalty::setPenalty().

◆ setDescent()

void dw::Textblock::setDescent ( int  descent)
protectedvirtual

Reimplemented from dw::core::Widget.

Definition at line 638 of file textblock.cc.

◆ setPenaltyEmDashLeft()

void dw::Textblock::setPenaltyEmDashLeft ( int  penaltyLeftEmDash)
static

Definition at line 202 of file textblock.cc.

Referenced by main().

◆ setPenaltyEmDashRight()

void dw::Textblock::setPenaltyEmDashRight ( int  penaltyRightEmDash)
static

Definition at line 208 of file textblock.cc.

Referenced by main().

◆ setPenaltyEmDashRight2()

void dw::Textblock::setPenaltyEmDashRight2 ( int  penaltyRightEmDash2)
static

Definition at line 213 of file textblock.cc.

Referenced by main().

◆ setPenaltyHyphen()

void dw::Textblock::setPenaltyHyphen ( int  penaltyHyphen)
static

Definition at line 192 of file textblock.cc.

Referenced by main().

◆ setPenaltyHyphen2()

void dw::Textblock::setPenaltyHyphen2 ( int  penaltyHyphen2)
static

Definition at line 197 of file textblock.cc.

Referenced by main().

◆ setSpaceImgRenderer()

◆ setStretchabilityFactor()

void dw::Textblock::setStretchabilityFactor ( int  stretchabilityFactor)
static

Definition at line 218 of file textblock.cc.

Referenced by main().

◆ setWidth()

void dw::Textblock::setWidth ( int  width)
protectedvirtual

Reimplemented from dw::core::Widget.

Definition at line 607 of file textblock.cc.

◆ setWordImgRenderer()

void dw::Textblock::setWordImgRenderer ( int  wordNo)
protected

◆ showMissingLines()

void dw::Textblock::showMissingLines ( )
protected

Definition at line 1273 of file textblock_linebreaking.cc.

References PRINTF.

◆ sizeAllocateImpl()

◆ sizeRequestImpl()

void dw::Textblock::sizeRequestImpl ( core::Requisition requisition)
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.

Definition at line 324 of file textblock.cc.

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.

◆ textWidth()

◆ wordWrap()

Friends And Related Function Documentation

◆ TextblockIterator

friend class TextblockIterator
friend

Definition at line 430 of file textblock.hh.

Referenced by dw::Textblock::TextblockIterator::clone().

Member Data Documentation

◆ anchors

lout::misc::SimpleVector<Anchor>* dw::Textblock::anchors
protected

Definition at line 488 of file textblock.hh.

◆ availAscent

int dw::Textblock::availAscent
protected

Definition at line 480 of file textblock.hh.

◆ availDescent

int dw::Textblock::availDescent
protected

Definition at line 480 of file textblock.hh.

◆ availWidth

int dw::Textblock::availWidth
protected

Definition at line 480 of file textblock.hh.

◆ CLASS_ID

int dw::Textblock::CLASS_ID = -1
static

Definition at line 669 of file textblock.hh.

Referenced by DilloHtml::HtmlLinkReceiver::click().

◆ divChars

Textblock::DivChar dw::Textblock::divChars
staticprivate
Initial value:
= {
{ "\xc2\xad", true, false, true, PENALTY_HYPHEN, -1 },
{ "-", false, true, true, -1, PENALTY_HYPHEN },
{ "\xe2\x80\x90", false, true, true, -1, PENALTY_HYPHEN },
{ "\xe2\x80\x94", false, true, false,
}

Definition at line 235 of file textblock.hh.

◆ hasListitemValue

bool dw::Textblock::hasListitemValue
protected

◆ hlEnd

◆ hlStart

◆ hoverLink

int dw::Textblock::hoverLink
protected

Definition at line 493 of file textblock.hh.

◆ hyphenDrawChar

const char * dw::Textblock::hyphenDrawChar = "-"
staticprivate

The character which is used to draw a hyphen at the end of a line, either caused by automatic hyphenation, or by soft hyphens.

Initially, soft hyphens were used, but they are not drawn on some platforms. Also, unconditional hyphens (U+2010) are not available in many fonts; so, a simple hyphen-minus is used.

Definition at line 237 of file textblock.hh.

◆ ignoreLine1OffsetSometimes

bool dw::Textblock::ignoreLine1OffsetSometimes
protected

Definition at line 457 of file textblock.hh.

◆ index

◆ innerPadding

int dw::Textblock::innerPadding
protected

Definition at line 435 of file textblock.hh.

Referenced by lineXOffsetContents(), and dw::ListItem::setMaxValue().

◆ lastWordDrawn

int dw::Textblock::lastWordDrawn
protected

Definition at line 477 of file textblock.hh.

◆ limitTextWidth

bool dw::Textblock::limitTextWidth
protected

Definition at line 474 of file textblock.hh.

◆ line1Offset

int dw::Textblock::line1Offset
protected

Definition at line 437 of file textblock.hh.

Referenced by dw::ListItem::setMaxValue(), and dw::TableCell::setMaxValue().

◆ line1OffsetEff

int dw::Textblock::line1OffsetEff
protected

Definition at line 440 of file textblock.hh.

Referenced by lineXOffsetContents().

◆ lines

◆ mustQueueResize

bool dw::Textblock::mustQueueResize
protected

Definition at line 459 of file textblock.hh.

Referenced by addParbreak().

◆ nChar

int dw::Textblock::nChar

◆ nonTemporaryLines

int dw::Textblock::nonTemporaryLines
protected

Definition at line 486 of file textblock.hh.

◆ paragraphs

lout::misc::SimpleVector<Paragraph>* dw::Textblock::paragraphs
protected

Definition at line 485 of file textblock.hh.

◆ penalties

int dw::Textblock::penalties
staticprotected
Initial value:
= {
{ 100, 800 },
{ 800, 800 },
{ 100, 800 }
}

The penalties for hyphens and other, multiplied by 100. So, 100 means 1.0. INT_MAX and INT_MIN are also allowed. See dw::Textblock::BadnessAndPenalty::setPenalty for more details. Set from preferences.

Definition at line 467 of file textblock.hh.

◆ redrawY

int dw::Textblock::redrawY
protected

Definition at line 476 of file textblock.hh.

Referenced by dw::ListItem::setMaxValue().

◆ stretchabilityFactor

int dw::Textblock::stretchabilityFactor = 100
staticprotected

...

Definition at line 472 of file textblock.hh.

◆ words

◆ wrapRefLines

int dw::Textblock::wrapRefLines
protected

Definition at line 482 of file textblock.hh.

◆ wrapRefParagraphs

int dw::Textblock::wrapRefParagraphs
protected

Definition at line 482 of file textblock.hh.


The documentation for this class was generated from the following files:
dw::Textblock::PENALTY_EM_DASH_RIGHT
Definition: textblock.hh:224
dw::Textblock::PENALTY_HYPHEN
Definition: textblock.hh:224
dw::Textblock::PENALTY_EM_DASH_LEFT
Definition: textblock.hh:224