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)  

textblock.hh
Go to the documentation of this file.
1 #ifndef __DW_TEXTBLOCK_HH__
2 #define __DW_TEXTBLOCK_HH__
3 
4 #include <limits.h>
5 
6 #include "core.hh"
7 #include "../lout/misc.hh"
8 
9 // These were used when improved line breaking and hyphenation were
10 // implemented. Should be cleaned up; perhaps reactivate RTFL again.
11 #define PRINTF(fmt, ...)
12 #define PUTCHAR(ch)
13 
14 namespace dw {
15 
149 class Textblock: public core::Widget
150 {
151 private:
161  enum {
164  };
165 
167  {
168  private:
170  badnessState;
171  int ratio; // ratio is only defined when badness is defined
172  int badness, penalty[2];
173 
174  // For debugging: define DEBUG for more informations in print().
175 #ifdef DEBUG
176  int totalWidth, idealWidth, totalStretchability, totalShrinkability;
177 #endif
178 
179  // "Infinity levels" are used to represent very large numbers,
180  // including "quasi-infinite" numbers. A couple of infinity
181  // level and number can be mathematically represented as
182  //
183  // number * N ^ (infinity level)
184  //
185  // where N is a number which is large enough. Practically,
186  // infinity levels are used to circumvent limited ranges for
187  // integer numbers.
188 
189  // Here, all infinity levels have got special meanings.
190  enum {
191  INF_VALUE = 0, /* simple values */
192  INF_LARGE, /* large values, like QUITE_LOOSE */
193  INF_NOT_STRETCHABLE, /* reserved for NOT_STRECTHABLE */
194  INF_TOO_TIGHT, /* used for lines, which are too tight */
195  INF_PENALTIES, /* used for penalties */
197 
198  // That INF_PENALTIES is the last value means that an
199  // infinite penalty (breaking is prohibited) makes a break
200  // not possible at all, so that pre-formatted text
201  // etc. works.
202  };
203 
204  void setSinglePenalty (int index, int penalty);
205  int badnessValue (int infLevel);
206  int penaltyValue (int index, int infLevel);
207 
208  public:
209  void calcBadness (int totalWidth, int idealWidth,
210  int totalStretchability, int totalShrinkability);
211  inline void setPenalty (int penalty) { setPenalties (penalty, penalty); }
212  void setPenalties (int penalty1, int penalty2);
213 
214  bool lineLoose ();
215  bool lineTight ();
216  bool lineTooTight ();
217  bool lineMustBeBroken (int penaltyIndex);
218  bool lineCanBeBroken (int penaltyIndex);
219  int compareTo (int penaltyIndex, BadnessAndPenalty *other);
220 
221  void print ();
222  };
223 
226  enum { NUM_DIV_CHARS = 4 };
227 
228  typedef struct
229  {
230  const char *s;
231  bool charRemoved, canBeHyphenated, unbreakableForMinWidth;
232  int penaltyIndexLeft, penaltyIndexRight;
233  } DivChar;
234 
236 
237  static const char *hyphenDrawChar;
238 
239 protected:
245  {
246  protected:
249  bool dataSet;
250 
251  public:
253  ~WordImgRenderer ();
254 
255  void setData (int xWordWidget, int lineNo);
256 
257  bool readyToDraw ();
258  void getBgArea (int *x, int *y, int *width, int *height);
259  void getRefArea (int *xRef, int *yRef, int *widthRef, int *heightRef);
261  void draw (int x, int y, int width, int height);
262 
263  virtual void print ();
264  };
265 
267  {
268  public:
271 
272  void getBgArea (int *x, int *y, int *width, int *height);
274 
275  void print ();
276  };
277 
278  struct Paragraph
279  {
280  int firstWord; /* first word's index in word vector */
281  int lastWord; /* last word's index in word vector */
282 
283  /*
284  * General remark: all values include the last hyphen width, but
285  * not the last space; these values are, however corrected, when
286  * another word is added.
287  *
288  * Also, as opposed to lines, paragraphs are created with the
289  * first, not the last word, so these values change when new
290  * words are added.
291  */
292 
293  int parMin; /* The sum of all word minima (plus spaces,
294  hyphen width etc.) since the last possible
295  break within this paragraph. */
296  int parMax; /* The sum of all word maxima in this
297  * paragraph (plus spaces, hyphen width
298  * etc.). */
299 
300  int maxParMin; /* Maximum of all paragraph minima (value of
301  * "parMin), including this paragraph. */
302  int maxParMax; /* Maximum of all paragraph maxima (value of
303  * "parMax"), including this paragraph. */
304  };
305 
306  struct Line
307  {
308  int firstWord; /* first word's index in word vector */
309  int lastWord; /* last word's index in word vector */
310 
311  /* "top" is always relative to the top of the first line, i.e.
312  * page->lines[0].top is always 0. */
315 
316  /* This is similar to descent, but includes the bottom margins of the
317  * widgets within this line. */
319 
320  /* Maximum of all line widths, including this line. Does not
321  * include the last space, but the last hyphen width. Please
322  * notice a change: until recently (before hyphenation and
323  * changed line breaking), the values were accumulated up to the
324  * last line, not this line.*/
326  };
327 
328  struct Word
329  {
330  enum {
335  DIV_CHAR_AT_EOL = 1 << 1,
338  PERM_DIV_CHAR = 1 << 2,
344  /* When calculating the minimal width (as part of extremes),
345  * do not consider this word as breakable. This flag is
346  * ignored when the line is actually broken. */
348  /* If a word represents a "real" text word, or (after
349  * hyphenation) the first part of a "real" text word, this
350  * flag is set. Plays a role for text transformation. */
351  WORD_START = 1 << 5,
352  /* If a word represents a "real" text word, or (after
353  * hyphenation) the last part of a "real" text word, this
354  * flag is set. Analogue to WORD_START. */
355  WORD_END = 1 << 6
356  };
357 
358  /* TODO: perhaps add a xLeft? */
360  /* Space after the word, only if it's not a break: */
361  short origSpace; /* from font, set by addSpace */
362  short effSpace; /* effective space, set by wordWrap,
363  * used for drawing etc. */
364  short hyphenWidth; /* Additional width, when a word is part
365  * (except the last part) of a hyphenationed
366  * word. Has to be added to the width, when
367  * this is the last word of the line, and
368  * "hyphenWidth > 0" is also used to decide
369  * whether to draw a hyphen. */
370  short flags;
372 
373  // accumulated values, relative to the beginning of the line
374  int totalWidth; /* The sum of all word widths; plus all
375  spaces, excluding the one of this
376  word; plus the hyphen width of this
377  word (but of course, no hyphen
378  widths of previous words. In other
379  words: the value compared to the
380  ideal width of the line, if the line
381  would be broken after this word. */
383  int totalSpaceStretchability; // includes all *before* current word
384  int totalSpaceShrinkability; // includes all *before* current word
385  BadnessAndPenalty badnessAndPenalty; /* when line is broken after this
386  * word */
387 
389  core::style::Style *spaceStyle; /* initially the same as of the word,
390  later set by a_Dw_page_add_space */
391 
392  // These two are used rarely, so there is perhaps a way to store
393  // them which is consuming less memory.
396  };
397 
398  void printWordShort (Word *word);
399  void printWordFlags (short flags);
400  void printWordWithFlags (Word *word);
401  void printWord (Word *word);
402 
403  struct Anchor
404  {
405  char *name;
407  };
408 
410  {
411  private:
412  int index;
413 
414  public:
416  bool atEnd);
418  int index);
419 
422 
423  bool next ();
424  bool prev ();
425  void highlight (int start, int end, core::HighlightLayer layer);
426  void unhighlight (int direction, core::HighlightLayer layer);
427  void getAllocation (int start, int end, core::Allocation *allocation);
428  };
429 
430  friend class TextblockIterator;
431 
432  /* These fields provide some ad-hoc-functionality, used by sub-classes. */
433  bool hasListitemValue; /* If true, the first word of the page is treated
434  specially (search in source). */
435  int innerPadding; /* This is an additional padding on the left side
436  (used by ListItem). */
437  int line1Offset; /* This is an additional offset of the first line.
438  May be negative (shift to left) or positive
439  (shift to right). */
440  int line1OffsetEff; /* The "effective" value of line1_offset, may
441  differ from line1_offset when
442  ignoreLine1OffsetSometimes is set to true. */
443 
444  /* The following is really hackish: It is used for DwTableCell (see
445  * comment in dw_table_cell.c), to avoid too wide table columns. If
446  * set to true, it has following effects:
447  *
448  * (i) line1_offset is ignored in calculating the minimal width
449  * (which is used by DwTable!), and
450  * (ii) line1_offset is ignored (line1_offset_eff is set to 0),
451  * when line1_offset plus the width of the first word is
452  * greater than the the available witdh.
453  *
454  * \todo Eliminate all these ad-hoc features by a new, simpler and
455  * more elegant design. ;-)
456  */
458 
460 
467  static int penalties[PENALTY_NUM][2];
468 
473 
474  bool limitTextWidth; /* from preferences */
475 
476  int redrawY;
478 
479  /* These values are set by set_... */
481 
482  int wrapRefLines, wrapRefParagraphs; /* [0 based] */
483 
489 
490  struct {int index, nChar;}
492 
493  int hoverLink; /* The link under the mouse pointer */
494 
495 
496  void queueDrawRange (int index1, int index2);
498  void justifyLine (Line *line, int diff);
499  Line *addLine (int firstWord, int lastWord, bool temporary);
500  void calcWidgetSize (core::Widget *widget, core::Requisition *size);
501  void rewrap ();
502  void fillParagraphs ();
503  void showMissingLines ();
504  void removeTemporaryLines ();
505 
508  int x, int yBase, int width);
510  core::style::Color::Shading shading, int x, int y,
511  const char *text, int start, int len, bool isStart,
512  bool isEnd);
513  void drawWord (Line *line, int wordIndex1, int wordIndex2, core::View *view,
514  core::Rectangle *area, int xWidget, int yWidgetBase);
515  void drawWord0 (int wordIndex1, int wordIndex2,
516  const char *text, int totalWidth, bool drawHyphen,
518  core::Rectangle *area, int xWidget, int yWidgetBase);
519  void drawSpace (int wordIndex, core::View *view, core::Rectangle *area,
520  int xWidget, int yWidgetBase);
521  void drawLine (Line *line, core::View *view, core::Rectangle *area);
522  int findLineIndex (int y);
523  int findLineOfWord (int wordIndex);
524  int findParagraphOfWord (int wordIndex);
525  Word *findWord (int x, int y, bool *inSpace);
526 
527  Word *addWord (int width, int ascent, int descent, short flags,
529  void initWord (int wordNo);
530  void removeWordImgRenderer (int wordNo);
531  void setWordImgRenderer (int wordNo);
532  void removeSpaceImgRenderer (int wordNo);
533  void setSpaceImgRenderer (int wordNo);
534  void fillWord (int wordNo, int width, int ascent, int descent,
535  short flags, core::style::Style *style);
536  void fillSpace (int wordNo, core::style::Style *style);
538  int breakPenalty1, int breakPenalty2, bool forceBreak);
539  bool isBreakAllowed (Word *word);
540  int textWidth (const char *text, int start, int len,
541  core::style::Style *style, bool isStart, bool isEnd);
542  void calcTextSize (const char *text, size_t len, core::style::Style *style,
543  core::Requisition *size, bool isStart, bool isEnd);
544 
552  inline int lineXOffsetContents (Line *line)
553  {
554  return innerPadding + line->leftOffset +
555  (line == lines->getFirstRef() ? line1OffsetEff : 0);
556  }
557 
562  inline int lineXOffsetWidget (Line *line)
563  {
564  return lineXOffsetContents (line) + getStyle()->boxOffsetX ();
565  }
566 
569  {
570  return line->top + (allocation->ascent - lines->getRef(0)->boxAscent);
571  }
572 
573  inline int lineYOffsetWidget (Line *line)
574  {
575  return lineYOffsetWidgetAllocation (line, &allocation);
576  }
577 
583  {
585  }
586 
590  inline int lineYOffsetCanvas (Line *line)
591  {
593  }
594 
595  inline int lineYOffsetWidgetI (int lineIndex)
596  {
597  return lineYOffsetWidget (lines->getRef (lineIndex));
598  }
599 
600  inline int lineYOffsetCanvasI (int lineIndex)
601  {
602  return lineYOffsetCanvas (lines->getRef (lineIndex));
603  }
604 
606  {
607  if (lines->size() == 0)
608  return 0;
609  else
610  return
611  (words->getRef(lines->getLastRef()->lastWord)->flags &
613  }
614 
616  core::MousePositionEvent *event);
617 
618  void accumulateWordExtremes (int firstWord, int lastWord,
619  int *maxOfMinWidth, int *sumOfMaxWidth);
620  void processWord (int wordIndex);
621  virtual bool wordWrap (int wordIndex, bool wrapAll);
622  int searchMinBap (int firstWord, int lastWordm, int penaltyIndex,
623  bool correctAtEnd);
624  int considerHyphenation (int firstIndex, int breakPos);
625  bool isHyphenationCandidate (Word *word);
626 
627  void handleWordExtremes (int wordIndex);
628  void correctLastWordExtremes ();
629 
630  static int getSpaceShrinkability(struct Word *word);
631  static int getSpaceStretchability(struct Word *word);
632  static int getLineShrinkability(Word *lastWord);
633  static int getLineStretchability(Word *lastWord);
634  int hyphenateWord (int wordIndex);
635  void accumulateWordForLine (int lineIndex, int wordIndex);
636  void accumulateWordData (int wordIndex);
637  int calcAvailWidth (int lineIndex);
638  void initLine1Offset (int wordIndex);
639  void alignLine (int lineIndex);
640 
644  void resizeDrawImpl ();
645 
646  void markSizeChange (int ref);
647  void markExtremesChange (int ref);
648  void setWidth (int width);
649  void setAscent (int ascent);
650  void setDescent (int descent);
651  void draw (core::View *view, core::Rectangle *area);
652 
653  bool buttonPressImpl (core::EventButton *event);
654  bool buttonReleaseImpl (core::EventButton *event);
655  bool motionNotifyImpl (core::EventMotion *event);
656  void enterNotifyImpl (core::EventCrossing *event);
657  void leaveNotifyImpl (core::EventCrossing *event);
658 
659  void removeChild (Widget *child);
660 
661  void addText0 (const char *text, size_t len, short flags,
663  void calcTextSizes (const char *text, size_t textLen,
665  int numBreaks, int *breakPos,
666  core::Requisition *wordSize);
667 
668 public:
669  static int CLASS_ID;
670 
671  static void setPenaltyHyphen (int penaltyHyphen);
672  static void setPenaltyHyphen2 (int penaltyHyphen2);
673  static void setPenaltyEmDashLeft (int penaltyLeftEmDash);
674  static void setPenaltyEmDashRight (int penaltyRightEmDash);
675  static void setPenaltyEmDashRight2 (int penaltyRightEmDash2);
677 
679  ~Textblock();
680 
681  core::Iterator *iterator (core::Content::Type mask, bool atEnd);
682 
683  void flush ();
684 
685  void addText (const char *text, size_t len, core::style::Style *style);
686  inline void addText (const char *text, core::style::Style *style)
687  {
688  addText (text, strlen(text), style);
689  }
691  bool addAnchor (const char *name, core::style::Style *style);
693  void addBreakOption (core::style::Style *style, bool forceBreak);
694  void addParbreak (int space, core::style::Style *style);
696 
697  core::Widget *getWidgetAtPoint (int x, int y, int level);
699  void changeLinkColor (int link, int newColor);
700  void changeWordStyle (int from, int to, core::style::Style *style,
701  bool includeFirstSpace, bool includeLastSpace);
702 };
703 
704 } // namespace dw
705 
706 #endif // __DW_TEXTBLOCK_HH__
dw::Textblock::WordImgRenderer::getRefArea
void getRefArea(int *xRef, int *yRef, int *widthRef, int *heightRef)
Return the "reference area".
Definition: textblock.cc:88
dw::Textblock::PENALTY_NUM
Definition: textblock.hh:225
dw::Textblock::setPenaltyEmDashRight2
static void setPenaltyEmDashRight2(int penaltyRightEmDash2)
Definition: textblock.cc:213
dw::Textblock::Line::lastWord
int lastWord
Definition: textblock.hh:309
dw::Textblock::index
int index
Definition: textblock.hh:490
dw::Textblock::TextblockIterator::next
bool next()
Move iterator forward and store content it.
Definition: textblock_iterator.cc:67
dw::Textblock::mustQueueResize
bool mustQueueResize
Definition: textblock.hh:459
dw::Textblock::availDescent
int availDescent
Definition: textblock.hh:480
dw::Textblock::alignLine
void alignLine(int lineIndex)
Definition: textblock_linebreaking.cc:1132
dw::Textblock::Line::maxLineWidth
int maxLineWidth
Definition: textblock.hh:325
dw::Textblock::BadnessAndPenalty::INF_MAX
Definition: textblock.hh:196
dw::Textblock::drawSpace
void drawSpace(int wordIndex, core::View *view, core::Rectangle *area, int xWidget, int yWidgetBase)
Definition: textblock.cc:1196
dw::Textblock::markSizeChange
void markSizeChange(int ref)
See Sizes of Dillo Widgets.
Definition: textblock.cc:562
dw::Textblock::WordImgRenderer::draw
void draw(int x, int y, int width, int height)
Draw (or queue for drawing) an area, which is given in canvas coordinates.
Definition: textblock.cc:100
dw::Textblock::drawWord0
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)
Definition: textblock.cc:1092
dw::Textblock::hasListitemValue
bool hasListitemValue
Definition: textblock.hh:433
dw::Textblock::Line::contentDescent
int contentDescent
Definition: textblock.hh:313
dw::core::Allocation::y
int y
Definition: types.hh:166
dw::Textblock::lineYOffsetWidgetAllocation
int lineYOffsetWidgetAllocation(Line *line, core::Allocation *allocation)
Definition: textblock.hh:567
dw::Textblock::removeTemporaryLines
void removeTemporaryLines()
Definition: textblock_linebreaking.cc:1284
dw::Textblock::line1OffsetEff
int line1OffsetEff
Definition: textblock.hh:440
dw::Textblock::hyphenDrawChar
static const char * hyphenDrawChar
Definition: textblock.hh:237
dw::Textblock::Textblock
Textblock(bool limitTextWidth)
Definition: textblock.cc:223
dw::Textblock::Paragraph
Definition: textblock.hh:278
dw::Textblock::lineYOffsetCanvasAllocation
int lineYOffsetCanvasAllocation(Line *line, core::Allocation *allocation)
Definition: textblock.hh:581
dw::core::HighlightLayer
HighlightLayer
Definition: types.hh:42
dw::Textblock::addParbreak
void addParbreak(int space, core::style::Style *style)
Definition: textblock.cc:2137
dw::core::Requisition
Definition: types.hh:172
dw::Textblock::PENALTY_EM_DASH_RIGHT
Definition: textblock.hh:224
dw::Textblock
A Widget for rendering text blocks, i.e. paragraphs or sequences of paragraphs.
Definition: textblock.hh:149
dw::Textblock::printWordShort
void printWordShort(Word *word)
Definition: textblock_linebreaking.cc:233
dw::Textblock::changeWordStyle
void changeWordStyle(int from, int to, core::style::Style *style, bool includeFirstSpace, bool includeLastSpace)
Definition: textblock.cc:2369
dw::Textblock::BadnessAndPenalty::setPenalties
void setPenalties(int penalty1, int penalty2)
Definition: textblock_linebreaking.cc:128
dw::core::SelectionState::EventType
EventType
Definition: selection.hh:220
dw::Textblock::wrapRefLines
int wrapRefLines
Definition: textblock.hh:482
dw::core::MousePositionEvent
Base class for all mouse events related to a specific position.
Definition: events.hh:48
dw::Textblock::SpaceImgRenderer::getStyle
core::style::Style * getStyle()
Return the style this background image is part of.
Definition: textblock.cc:125
dw::Textblock::BadnessAndPenalty::BADNESS_VALUE
Definition: textblock.hh:169
dw::Textblock::addAnchor
bool addAnchor(const char *name, core::style::Style *style)
Definition: textblock.cc:1987
dw::core::EventCrossing
Represents a enter or leave notify event.
Definition: events.hh:74
dw::Textblock::rewrap
void rewrap()
Definition: textblock_linebreaking.cc:1185
dw::core::EventButton
Represents a button press or release event.
Definition: events.hh:57
dw::Textblock::BadnessAndPenalty::badnessValue
int badnessValue(int infLevel)
Definition: textblock_linebreaking.cc:35
dw::Textblock::addSpace
void addSpace(core::style::Style *style)
Definition: textblock.cc:2024
dw::Textblock::Word::UNBREAKABLE_FOR_MIN_WIDTH
Definition: textblock.hh:347
dw::Textblock::lineYOffsetCanvasI
int lineYOffsetCanvasI(int lineIndex)
Definition: textblock.hh:600
dw::Textblock::BadnessAndPenalty::INF_TOO_TIGHT
Definition: textblock.hh:194
dw::Textblock::markExtremesChange
void markExtremesChange(int ref)
See Sizes of Dillo Widgets.
Definition: textblock.cc:587
dw::Textblock::BadnessAndPenalty::badnessState
enum dw::Textblock::BadnessAndPenalty::@24 badnessState
dw::Textblock::Anchor::wordIndex
int wordIndex
Definition: textblock.hh:406
dw::Textblock::BadnessAndPenalty::lineCanBeBroken
bool lineCanBeBroken(int penaltyIndex)
Definition: textblock_linebreaking.cc:173
dw::Textblock::handOverBreak
void handOverBreak(core::style::Style *style)
Definition: textblock.cc:2284
dw::Textblock::PENALTY_FORCE_BREAK
Definition: textblock.hh:162
dw::core::Content::Type
Type
Definition: types.hh:187
dw::Textblock::Word::origSpace
short origSpace
Definition: textblock.hh:361
dw::Textblock::hyphenateWord
int hyphenateWord(int wordIndex)
Definition: textblock_linebreaking.cc:863
dw::Textblock::Word::PERM_DIV_CHAR
Definition: textblock.hh:338
dw::Textblock::BadnessAndPenalty::penaltyValue
int penaltyValue(int index, int infLevel)
Definition: textblock_linebreaking.cc:56
dw::Textblock::BadnessAndPenalty::badness
int badness
Definition: textblock.hh:172
dw::core::Iterator
Iterators are used to iterate through the contents of a widget.
Definition: iterator.hh:19
dw::Textblock::sizeRequestImpl
void sizeRequestImpl(core::Requisition *requisition)
Definition: textblock.cc:324
dw::Textblock::DivChar::penaltyIndexRight
int penaltyIndexRight
Definition: textblock.hh:232
dw::Textblock::sendSelectionEvent
bool sendSelectionEvent(core::SelectionState::EventType eventType, core::MousePositionEvent *event)
Send event to selection.
Definition: textblock.cc:733
dw::Textblock::limitTextWidth
bool limitTextWidth
Definition: textblock.hh:474
dw::Textblock::PENALTY_PROHIBIT_BREAK
Definition: textblock.hh:163
dw::Textblock::Paragraph::parMax
int parMax
Definition: textblock.hh:296
dw::Textblock::calcAvailWidth
int calcAvailWidth(int lineIndex)
Definition: textblock_linebreaking.cc:1081
dw::Textblock::fillParagraphs
void fillParagraphs()
Definition: textblock_linebreaking.cc:1229
dw::Textblock::BadnessAndPenalty::print
void print()
Definition: textblock_linebreaking.cc:193
dw::Textblock::searchMinBap
int searchMinBap(int firstWord, int lastWordm, int penaltyIndex, bool correctAtEnd)
Definition: textblock_linebreaking.cc:663
dw::Textblock::BadnessAndPenalty::QUITE_LOOSE
Definition: textblock.hh:169
dw::Textblock::setPenaltyHyphen2
static void setPenaltyHyphen2(int penaltyHyphen2)
Definition: textblock.cc:197
dw::Textblock::getLineShrinkability
static int getLineShrinkability(Word *lastWord)
Definition: textblock_linebreaking.cc:1307
dw::Textblock::innerPadding
int innerPadding
Definition: textblock.hh:435
dw::Textblock::~Textblock
~Textblock()
Definition: textblock.cc:281
dw::Textblock::handleWordExtremes
void handleWordExtremes(int wordIndex)
Definition: textblock_linebreaking.cc:770
dw::Textblock::Word::maxAscent
int maxAscent
Definition: textblock.hh:382
dw::Textblock::Line::firstWord
int firstWord
Definition: textblock.hh:308
dw::Textblock::setWidth
void setWidth(int width)
Definition: textblock.cc:607
dw::Textblock::DivChar
Definition: textblock.hh:228
dw::Textblock::Paragraph::lastWord
int lastWord
Definition: textblock.hh:281
dw::Textblock::removeChild
void removeChild(Widget *child)
Definition: textblock.cc:870
dw::Textblock::TextblockIterator::clone
lout::object::Object * clone()
Return an exact copy of the object.
Definition: textblock_iterator.cc:57
dw::core::Allocation
Represents the allocation, i.e. actual position and size of a dw::core::Widget.
Definition: types.hh:163
dw::Textblock::paragraphs
lout::misc::SimpleVector< Paragraph > * paragraphs
Definition: textblock.hh:485
dw::Textblock::Paragraph::maxParMax
int maxParMax
Definition: textblock.hh:302
dw::Textblock::getWordExtremes
void getWordExtremes(Word *word, core::Extremes *extremes)
Definition: textblock.cc:376
dw::Textblock::iterator
core::Iterator * iterator(core::Content::Type mask, bool atEnd)
Return an iterator for this widget.
Definition: textblock.cc:875
dw::Textblock::PENALTY_HYPHEN
Definition: textblock.hh:224
dw::Textblock::Word::WORD_START
Definition: textblock.hh:351
dw::core::Widget::getStyle
style::Style * getStyle()
Definition: widget.hh:268
dw::core::Widget::style
style::Style * style
Definition: widget.hh:104
dw::Textblock::Word::totalSpaceShrinkability
int totalSpaceShrinkability
Definition: textblock.hh:384
dw::Textblock::lineYOffsetWidgetI
int lineYOffsetWidgetI(int lineIndex)
Definition: textblock.hh:595
dw::Textblock::findLineOfWord
int findLineOfWord(int wordIndex)
Find the line of word wordIndex.
Definition: textblock.cc:1341
dw::Textblock::Word
Definition: textblock.hh:328
dw::Textblock::anchors
lout::misc::SimpleVector< Anchor > * anchors
Definition: textblock.hh:488
dw::Textblock::Word::totalSpaceStretchability
int totalSpaceStretchability
Definition: textblock.hh:383
dw::Textblock::leaveNotifyImpl
void leaveNotifyImpl(core::EventCrossing *event)
Definition: textblock.cc:716
dw::Textblock::Word::maxDescent
int maxDescent
Definition: textblock.hh:382
dw::Textblock::nonTemporaryLines
int nonTemporaryLines
Definition: textblock.hh:486
dw::Textblock::Word::badnessAndPenalty
BadnessAndPenalty badnessAndPenalty
Definition: textblock.hh:385
dw::Textblock::Paragraph::firstWord
int firstWord
Definition: textblock.hh:280
dw::Textblock::accumulateWordExtremes
void accumulateWordExtremes(int firstWord, int lastWord, int *maxOfMinWidth, int *sumOfMaxWidth)
Definition: textblock_linebreaking.cc:437
dw::Textblock::Line::contentAscent
int contentAscent
Definition: textblock.hh:313
dw::Textblock::removeSpaceImgRenderer
void removeSpaceImgRenderer(int wordNo)
Definition: textblock.cc:1503
dw::Textblock::removeWordImgRenderer
void removeWordImgRenderer(int wordNo)
Definition: textblock.cc:1479
dw::Textblock::line1Offset
int line1Offset
Definition: textblock.hh:437
dw::Textblock::processWord
void processWord(int wordIndex)
Definition: textblock_linebreaking.cc:475
dw::Textblock::wrapRefParagraphs
int wrapRefParagraphs
Definition: textblock.hh:482
dw::Textblock::drawText
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)
Definition: textblock.cc:972
dw::Textblock::BadnessAndPenalty::lineMustBeBroken
bool lineMustBeBroken(int penaltyIndex)
Definition: textblock_linebreaking.cc:168
dw::Textblock::BadnessAndPenalty::TOO_TIGHT
Definition: textblock.hh:169
dw::Textblock::availWidth
int availWidth
Definition: textblock.hh:480
dw::core::style::Color::Shading
Shading
Definition: style.hh:725
dw::Textblock::showMissingLines
void showMissingLines()
Definition: textblock_linebreaking.cc:1273
dw::Textblock::setDescent
void setDescent(int descent)
Definition: textblock.cc:638
dw::Textblock::WordImgRenderer::setData
void setData(int xWordWidget, int lineNo)
Definition: textblock.cc:60
dw::Textblock::lastWordDrawn
int lastWordDrawn
Definition: textblock.hh:477
dw::Textblock::BadnessAndPenalty::penalty
int penalty[2]
Definition: textblock.hh:172
dw::Textblock::BadnessAndPenalty::setSinglePenalty
void setSinglePenalty(int index, int penalty)
Definition: textblock_linebreaking.cc:135
dw::Textblock::Line::boxDescent
int boxDescent
Definition: textblock.hh:313
dw::Textblock::isHyphenationCandidate
bool isHyphenationCandidate(Word *word)
Definition: textblock_linebreaking.cc:757
dw::Textblock::queueDrawRange
void queueDrawRange(int index1, int index2)
Definition: textblock.cc:2374
dw::Textblock::textWidth
int textWidth(const char *text, int start, int len, core::style::Style *style, bool isStart, bool isEnd)
Definition: textblock.cc:1559
dw::Textblock::TextblockIterator::index
int index
Definition: textblock.hh:412
dw::Textblock::buttonReleaseImpl
bool buttonReleaseImpl(core::EventButton *event)
Definition: textblock.cc:657
dw::Textblock::accumulateWordForLine
void accumulateWordForLine(int lineIndex, int wordIndex)
Definition: textblock_linebreaking.cc:964
dw::Textblock::considerHyphenation
int considerHyphenation(int firstIndex, int breakPos)
Definition: textblock_linebreaking.cc:722
dw::Textblock::Word::style
core::style::Style * style
Definition: textblock.hh:388
dw::Textblock::lineYOffsetWidget
int lineYOffsetWidget(Line *line)
Definition: textblock.hh:573
lout::object::Object
This is the base class for many other classes, which defines very common virtual methods.
Definition: object.hh:24
dw::Textblock::calcWidgetSize
void calcWidgetSize(core::Widget *widget, core::Requisition *size)
Definition: textblock.cc:885
dw::Textblock::TextblockIterator
Definition: textblock.hh:409
dw::Textblock::SpaceImgRenderer::SpaceImgRenderer
SpaceImgRenderer(Textblock *textblock, int wordNo)
Definition: textblock.hh:269
dw::Textblock::penalties
static int penalties[PENALTY_NUM][2]
Definition: textblock.hh:467
dw::Textblock::drawLine
void drawLine(Line *line, core::View *view, core::Rectangle *area)
Definition: textblock.cc:1246
dw::Textblock::Paragraph::maxParMin
int maxParMin
Definition: textblock.hh:300
dw::Textblock::fillWord
void fillWord(int wordNo, int width, int ascent, int descent, short flags, core::style::Style *style)
Definition: textblock.cc:1527
dw::Textblock::Line::marginDescent
int marginDescent
Definition: textblock.hh:318
dw::Textblock::Word::content
core::Content content
Definition: textblock.hh:371
dw::Textblock::calcTextSize
void calcTextSize(const char *text, size_t len, core::style::Style *style, core::Requisition *size, bool isStart, bool isEnd)
Definition: textblock.cc:1621
dw::Textblock::Word::spaceStyle
core::style::Style * spaceStyle
Definition: textblock.hh:389
dw::Textblock::calcPenaltyIndexForNewLine
int calcPenaltyIndexForNewLine()
Definition: textblock.hh:605
dw::Textblock::nChar
int nChar
Definition: textblock.hh:490
dw::core::EventMotion
Represents a mouse motion event.
Definition: events.hh:67
dw::core::Widget::Widget
Widget()
Definition: widget.cc:67
dw::Textblock::BadnessAndPenalty::calcBadness
void calcBadness(int totalWidth, int idealWidth, int totalStretchability, int totalShrinkability)
Definition: textblock_linebreaking.cc:66
dw::Textblock::lineXOffsetWidget
int lineXOffsetWidget(Line *line)
Like lineXOffset, but relative to the allocation (i.e. including border etc.).
Definition: textblock.hh:562
dw::core::Widget::requisition
Requisition requisition
Size_request() stores the result of the last call of size_request_impl().
Definition: widget.hh:114
dw::Textblock::motionNotifyImpl
bool motionNotifyImpl(core::EventMotion *event)
Definition: textblock.cc:667
dw::Textblock::setStretchabilityFactor
static void setStretchabilityFactor(int stretchabilityFactor)
Definition: textblock.cc:218
dw::core::Iterator::mask
Content::Type mask
Definition: iterator.hh:30
dw::Textblock::WordImgRenderer::readyToDraw
bool readyToDraw()
If this method returns false, nothing is done at all.
Definition: textblock.cc:67
dw::Textblock::decorateText
void decorateText(core::View *view, core::style::Style *style, core::style::Color::Shading shading, int x, int yBase, int width)
Definition: textblock.cc:942
dw::Textblock::flush
void flush()
Definition: textblock.cc:2304
dw::Textblock::Word::totalWidth
int totalWidth
Definition: textblock.hh:374
dw::Textblock::WordImgRenderer::getStyle
core::style::Style * getStyle()
Return the style this background image is part of.
Definition: textblock.cc:95
dw::Textblock::setPenaltyEmDashRight
static void setPenaltyEmDashRight(int penaltyRightEmDash)
Definition: textblock.cc:208
dw::Textblock::resizeDrawImpl
void resizeDrawImpl()
Called after sizeAllocateImpl() to redraw necessary areas. By default the whole widget is redrawn.
Definition: textblock.cc:548
dw::Textblock::NUM_DIV_CHARS
Definition: textblock.hh:226
dw::Textblock::BadnessAndPenalty::lineLoose
bool lineLoose()
Definition: textblock_linebreaking.cc:149
dw::Textblock::lines
lout::misc::SimpleVector< Line > * lines
Definition: textblock.hh:484
dw::Textblock::Line
Definition: textblock.hh:306
dw::Textblock::getWidgetAtPoint
core::Widget * getWidgetAtPoint(int x, int y, int level)
Search recursively through widget.
Definition: textblock.cc:2243
dw::Textblock::WordImgRenderer::wordNo
int wordNo
Definition: textblock.hh:248
dw::Textblock::addText0
void addText0(const char *text, size_t len, short flags, core::style::Style *style, core::Requisition *size)
Definition: textblock.cc:1923
dw::Textblock::BadnessAndPenalty::ratio
int ratio
Definition: textblock.hh:171
dw::Textblock::BadnessAndPenalty::NOT_STRETCHABLE
Definition: textblock.hh:169
dw::Textblock::TextblockIterator::compareTo
int compareTo(lout::object::Comparable *other)
Compare two objects c1 and c2.
Definition: textblock_iterator.cc:62
dw::Textblock::Word::flags
short flags
Definition: textblock.hh:370
dw::Textblock::fillSpace
void fillSpace(int wordNo, core::style::Style *style)
Definition: textblock.cc:2050
dw::Textblock::printWordWithFlags
void printWordWithFlags(Word *word)
Definition: textblock_linebreaking.cc:264
dw::Textblock::Line::leftOffset
int leftOffset
Definition: textblock.hh:313
dw::Textblock::TextblockIterator::TextblockIterator
TextblockIterator(Textblock *textblock, core::Content::Type mask, bool atEnd)
Definition: textblock_iterator.cc:33
dw::Textblock::ignoreLine1OffsetSometimes
bool ignoreLine1OffsetSometimes
Definition: textblock.hh:457
dw::Textblock::findParagraphOfWord
int findParagraphOfWord(int wordIndex)
Find the paragraph of word wordIndex.
Definition: textblock.cc:1364
dw::core::Rectangle
dw::core::Shape implemtation for simple rectangles.
Definition: types.hh:69
dw::Textblock::setPenaltyHyphen
static void setPenaltyHyphen(int penaltyHyphen)
Definition: textblock.cc:192
dw::Textblock::Word::effSpace
short effSpace
Definition: textblock.hh:362
dw::Textblock::addWidget
void addWidget(core::Widget *widget, core::style::Style *style)
Definition: textblock.cc:1945
dw::Textblock::WordImgRenderer::xWordWidget
int xWordWidget
Definition: textblock.hh:248
dw::Textblock::TextblockIterator::prev
bool prev()
Move iterator backward and store content it.
Definition: textblock_iterator.cc:86
dw::Textblock::Word::DRAW_AS_ONE_TEXT
Definition: textblock.hh:343
dw::Textblock::Word::DIV_CHAR_AT_EOL
Definition: textblock.hh:335
dw::core::Extremes
Definition: types.hh:179
dw::core::HIGHLIGHT_NUM_LAYERS
Definition: types.hh:46
dw::Textblock::setPenaltyEmDashLeft
static void setPenaltyEmDashLeft(int penaltyLeftEmDash)
Definition: textblock.cc:202
dw::core::View
An interface to encapsulate platform dependent drawing.
Definition: view.hh:16
dw::Textblock::WordImgRenderer::~WordImgRenderer
~WordImgRenderer()
Definition: textblock.cc:55
dw::core::style::StyleImage::ExternalWidgetImgRenderer
Suitable for widgets and parts of widgets.
Definition: style.hh:812
dw::Textblock::printWordFlags
void printWordFlags(short flags)
Definition: textblock_linebreaking.cc:252
dw::Textblock::DivChar::unbreakableForMinWidth
bool unbreakableForMinWidth
Definition: textblock.hh:231
dw::Textblock::correctLastWordExtremes
void correctLastWordExtremes()
Definition: textblock_linebreaking.cc:849
dw::Textblock::Word::size
core::Requisition size
Definition: textblock.hh:359
dw::Textblock::lineYOffsetCanvas
int lineYOffsetCanvas(Line *line)
Definition: textblock.hh:590
dw::Textblock::BadnessAndPenalty::INF_VALUE
Definition: textblock.hh:191
dw::Textblock::changeLinkColor
void changeLinkColor(int link, int newColor)
Definition: textblock.cc:2318
dw::Textblock::printWord
void printWord(Word *word)
Definition: textblock_linebreaking.cc:272
dw::Textblock::words
lout::misc::NotSoSimpleVector< Word > * words
Definition: textblock.hh:487
dw::Textblock::BadnessAndPenalty::compareTo
int compareTo(int penaltyIndex, BadnessAndPenalty *other)
Definition: textblock_linebreaking.cc:178
dw::Textblock::setWordImgRenderer
void setWordImgRenderer(int wordNo)
Definition: textblock.cc:1491
dw::Textblock::SpaceImgRenderer
Definition: textblock.hh:266
dw::Textblock::addText
void addText(const char *text, core::style::Style *style)
Definition: textblock.hh:686
dw::Textblock::findLineIndex
int findLineIndex(int y)
Definition: textblock.cc:1308
dw::Textblock::SpaceImgRenderer::getBgArea
void getBgArea(int *x, int *y, int *width, int *height)
Return the area covered by the background image.
Definition: textblock.cc:117
dw::core::Widget::extremes
Extremes extremes
Analogue to dw::core::Widget::requisition.
Definition: widget.hh:119
lout::misc::NotSoSimpleVector
Container similar to lout::misc::SimpleVector, but some cases of insertion optimized (used for hyphen...
Definition: misc.hh:262
dw::Textblock::getLineStretchability
static int getLineStretchability(Word *lastWord)
Definition: textblock_linebreaking.cc:1312
dw::Textblock::Anchor::name
char * name
Definition: textblock.hh:405
dw::Textblock::addLine
Line * addLine(int firstWord, int lastWord, bool temporary)
Definition: textblock_linebreaking.cc:338
dw::Textblock::Line::boxAscent
int boxAscent
Definition: textblock.hh:313
dw::core::Allocation::ascent
int ascent
Definition: types.hh:168
dw::Textblock::redrawY
int redrawY
Definition: textblock.hh:476
lout::object::Comparable
Instances of a sub class of may be compared (less, greater).
Definition: object.hh:41
core.hh
dw::Textblock::getSpaceStretchability
static int getSpaceStretchability(struct Word *word)
Definition: textblock_linebreaking.cc:1297
dw::Textblock::addBreakOption
void addBreakOption(core::style::Style *style, bool forceBreak)
Definition: textblock.cc:2040
dw::Textblock::hlEnd
struct dw::Textblock::@23 hlEnd[core::HIGHLIGHT_NUM_LAYERS]
dw::Textblock::stretchabilityFactor
static int stretchabilityFactor
Definition: textblock.hh:472
dw::Textblock::hoverLink
int hoverLink
Definition: textblock.hh:493
dw::Textblock::calcTextSizes
void calcTextSizes(const char *text, size_t textLen, core::style::Style *style, int numBreaks, int *breakPos, core::Requisition *wordSize)
Definition: textblock.cc:1886
dw::Textblock::Line::top
int top
Definition: textblock.hh:313
dw::Textblock::WordImgRenderer::print
virtual void print()
Definition: textblock.cc:107
dw::core::Content
Definition: types.hh:185
dw::Textblock::setBreakOption
void setBreakOption(Word *word, core::style::Style *style, int breakPenalty1, int breakPenalty2, bool forceBreak)
Definition: textblock.cc:2101
dw::Textblock::BadnessAndPenalty
Definition: textblock.hh:166
dw::Textblock::DivChar::s
const char * s
Definition: textblock.hh:230
dw::Textblock::divChars
static DivChar divChars[NUM_DIV_CHARS]
Definition: textblock.hh:235
dw::Textblock::availAscent
int availAscent
Definition: textblock.hh:480
dw::Textblock::sizeAllocateImpl
void sizeAllocateImpl(core::Allocation *allocation)
See Sizes of Dillo Widgets.
Definition: textblock.cc:431
dw::Textblock::buttonPressImpl
bool buttonPressImpl(core::EventButton *event)
Definition: textblock.cc:652
dw::Textblock::draw
void draw(core::View *view, core::Rectangle *area)
Definition: textblock.cc:1433
dw::Textblock::accumulateWordData
void accumulateWordData(int wordIndex)
Definition: textblock_linebreaking.cc:1022
dw::Textblock::addWord
Word * addWord(int width, int ascent, int descent, short flags, core::style::Style *style)
Definition: textblock.cc:1457
dw::Textblock::Word::wordImgRenderer
WordImgRenderer * wordImgRenderer
Definition: textblock.hh:394
dw::Textblock::enterNotifyImpl
void enterNotifyImpl(core::EventCrossing *event)
Definition: textblock.cc:709
dw::Textblock::PENALTY_EM_DASH_LEFT
Definition: textblock.hh:224
dw::Textblock::justifyLine
void justifyLine(Line *line, int diff)
Definition: textblock_linebreaking.cc:288
dw::Textblock::Line::breakSpace
int breakSpace
Definition: textblock.hh:313
dw::Textblock::Word::spaceImgRenderer
SpaceImgRenderer * spaceImgRenderer
Definition: textblock.hh:395
dw::Textblock::hlStart
struct dw::Textblock::@23 hlStart[core::HIGHLIGHT_NUM_LAYERS]
dw::Textblock::getSpaceShrinkability
static int getSpaceShrinkability(struct Word *word)
Definition: textblock_linebreaking.cc:1289
dw::Textblock::Word::CAN_BE_HYPHENATED
Definition: textblock.hh:333
dw::Textblock::addLinebreak
void addLinebreak(core::style::Style *style)
Definition: textblock.cc:2214
dw::Textblock::drawWord
void drawWord(Line *line, int wordIndex1, int wordIndex2, core::View *view, core::Rectangle *area, int xWidget, int yWidgetBase)
Definition: textblock.cc:1039
dw::core::Widget::flags
Flags flags
Definition: widget.hh:106
dw::Textblock::setAscent
void setAscent(int ascent)
Definition: textblock.cc:624
dw::Textblock::Paragraph::parMin
int parMin
Definition: textblock.hh:293
dw::Textblock::Word::hyphenWidth
short hyphenWidth
Definition: textblock.hh:364
dw::core::Widget
The base class of all dillo widgets.
Definition: widget.hh:23
dw::Textblock::Word::WORD_END
Definition: textblock.hh:355
dw::core::Widget::allocation
Allocation allocation
The current allocation: size and position, always relative to the canvas.
Definition: widget.hh:151
dw
Dw is in this namespace, or sub namespaces of this one.
Definition: alignedtextblock.cc:26
dw::Textblock::BadnessAndPenalty::INF_PENALTIES
Definition: textblock.hh:195
dw::Textblock::TextblockIterator::getAllocation
void getAllocation(int start, int end, core::Allocation *allocation)
Return the shape, which a part of the item, the iterator points on, allocates.
Definition: textblock_iterator.cc:177
dw::Textblock::SpaceImgRenderer::print
void print()
Definition: textblock.cc:130
dw::Textblock::WordImgRenderer
Implementation used for words.
Definition: textblock.hh:243
dw::Textblock::WordImgRenderer::getBgArea
void getBgArea(int *x, int *y, int *width, int *height)
Return the area covered by the background image.
Definition: textblock.cc:77
dw::Textblock::TextblockIterator::highlight
void highlight(int start, int end, core::HighlightLayer layer)
Extend highlighted region to contain part of the current content.
Definition: textblock_iterator.cc:105
dw::Textblock::BadnessAndPenalty::lineTight
bool lineTight()
Definition: textblock_linebreaking.cc:156
dw::Textblock::WordImgRenderer::textblock
Textblock * textblock
Definition: textblock.hh:247
dw::Textblock::isBreakAllowed
bool isBreakAllowed(Word *word)
Definition: textblock.cc:2115
dw::Textblock::WordImgRenderer::dataSet
bool dataSet
Definition: textblock.hh:249
dw::Textblock::findWord
Word * findWord(int x, int y, bool *inSpace)
Find the index of the word, or -1.
Definition: textblock.cc:1390
dw::Textblock::initWord
void initWord(int wordNo)
Definition: textblock.cc:1470
lout::misc::SimpleVector
Simple (simpler than container::untyped::Vector and container::typed::Vector) template based vector.
Definition: misc.hh:71
dw::Textblock::BadnessAndPenalty::setPenalty
void setPenalty(int penalty)
Definition: textblock.hh:211
dw::core::style::Style
Definition: style.hh:571
dw::Textblock::wordWrap
virtual bool wordWrap(int wordIndex, bool wrapAll)
Definition: textblock_linebreaking.cc:508
dw::Textblock::WordImgRenderer::lineNo
int lineNo
Definition: textblock.hh:248
dw::Textblock::setSpaceImgRenderer
void setSpaceImgRenderer(int wordNo)
Definition: textblock.cc:1515
dw::Textblock::addText
void addText(const char *text, size_t len, core::style::Style *style)
Definition: textblock.cc:1676
dw::Textblock::initLine1Offset
void initLine1Offset(int wordIndex)
Definition: textblock_linebreaking.cc:1099
dw::core::style::StyleAttrs::boxOffsetX
int boxOffsetX()
Definition: style.hh:541
dw::Textblock::BadnessAndPenalty::lineTooTight
bool lineTooTight()
Definition: textblock_linebreaking.cc:162
dw::Textblock::getExtremesImpl
void getExtremesImpl(core::Extremes *extremes)
See Sizes of Dillo Widgets.
Definition: textblock.cc:406
dw::Textblock::CLASS_ID
static int CLASS_ID
Definition: textblock.hh:669
dw::Textblock::lineXOffsetContents
int lineXOffsetContents(Line *line)
Returns the x offset (the indentation plus any offset needed for centering or right justification) fo...
Definition: textblock.hh:552
dw::Textblock::Anchor
Definition: textblock.hh:403
dw::Textblock::TextblockIterator::unhighlight
void unhighlight(int direction, core::HighlightLayer layer)
Shrink highlighted region to no longer contain the current content.
Definition: textblock_iterator.cc:141
dw::Textblock::BadnessAndPenalty::INF_LARGE
Definition: textblock.hh:192
dw::Textblock::BadnessAndPenalty::INF_NOT_STRETCHABLE
Definition: textblock.hh:193
dw::Textblock::WordImgRenderer::WordImgRenderer
WordImgRenderer(Textblock *textblock, int wordNo)
Definition: textblock.cc:45