diff options
author | Sebastian Geerken <devnull@localhost> | 2014-12-08 17:35:18 +0100 |
---|---|---|
committer | Sebastian Geerken <devnull@localhost> | 2014-12-08 17:35:18 +0100 |
commit | 3d521d286174264448cbd1b2315ff89f9d8e8edf (patch) | |
tree | 37515aa58dc935014b677c7212ada0fdfab7b2bd | |
parent | de2139f76ee1fa4f14970914bb6c87fe46feed17 (diff) | |
parent | 2bb03c759cb44241d42e3385336a1c6b9a8d7d9f (diff) |
Merged with main repo (part 1/2).
-rw-r--r-- | dw/fltkviewbase.cc | 9 | ||||
-rw-r--r-- | dw/fltkviewbase.hh | 2 | ||||
-rw-r--r-- | dw/oofawarewidget.hh | 52 | ||||
-rw-r--r-- | dw/textblock.cc | 4 | ||||
-rw-r--r-- | dw/textblock.hh | 6 | ||||
-rw-r--r-- | dw/textblock_linebreaking.cc | 21 | ||||
-rw-r--r-- | dw/widget.cc | 6 | ||||
-rw-r--r-- | lout/debug_rtfl.hh | 36 | ||||
-rw-r--r-- | src/html.cc | 8 |
9 files changed, 106 insertions, 38 deletions
diff --git a/dw/fltkviewbase.cc b/dw/fltkviewbase.cc index f7e331fc..68218800 100644 --- a/dw/fltkviewbase.cc +++ b/dw/fltkviewbase.cc @@ -69,7 +69,7 @@ FltkViewBase::FltkViewBase (int x, int y, int w, int h, const char *label): canvasHeight = 1; bgColor = FL_WHITE; mouse_x = mouse_y = 0; - // focused_child = NULL; + focused_child = NULL; exposeArea = NULL; if (backBuffer == NULL) { backBuffer = new BackBuffer (); @@ -355,8 +355,6 @@ int FltkViewBase::handle (int event) case FL_LEAVE: theLayout->leaveNotify (this, getDwButtonState ()); break; -#if 0 - // BUG: starting with fltk-1.3.3, we can't use fl_oldfocus. case FL_FOCUS: if (focused_child && find(focused_child) < children()) { /* strangely, find() == children() if the child is not found */ @@ -364,9 +362,10 @@ int FltkViewBase::handle (int event) } return 1; case FL_UNFOCUS: - focused_child = fl_oldfocus; + // FLTK delivers UNFOCUS to the previously focused widget + if (find(Fl::focus()) < children()) + focused_child = Fl::focus(); // remember the focused child! return 0; -#endif case FL_KEYBOARD: if (Fl::event_key() == FL_Tab) return manageTabToFocus(); diff --git a/dw/fltkviewbase.hh b/dw/fltkviewbase.hh index 88fd9041..eb4ec322 100644 --- a/dw/fltkviewbase.hh +++ b/dw/fltkviewbase.hh @@ -56,7 +56,7 @@ protected: core::Layout *theLayout; int canvasWidth, canvasHeight; int mouse_x, mouse_y; - // Fl_Widget *focused_child; + Fl_Widget *focused_child; virtual int translateViewXToCanvasX (int x) = 0; virtual int translateViewYToCanvasY (int y) = 0; diff --git a/dw/oofawarewidget.hh b/dw/oofawarewidget.hh index 95af54a0..8fb32716 100644 --- a/dw/oofawarewidget.hh +++ b/dw/oofawarewidget.hh @@ -144,23 +144,6 @@ protected: { return oofContainer[oofmIndex] ? oofContainer[oofmIndex]->outOfFlowMgr[oofmIndex] : NULL; } - static inline bool testWidgetFloat (Widget *widget) - { return widget->getStyle()->vloat != core::style::FLOAT_NONE; } - static inline bool testWidgetAbsolutelyPositioned (Widget *widget) - { return widget->getStyle()->position == core::style::POSITION_ABSOLUTE; } - static inline bool testWidgetFixedlyPositioned (Widget *widget) - { return widget->getStyle()->position == core::style::POSITION_FIXED; } - static inline bool testWidgetPositioned (Widget *widget) - { return testWidgetAbsolutelyPositioned (widget) || - testWidgetRelativelyPositioned (widget) || - testWidgetFixedlyPositioned (widget); } - static inline bool testWidgetOutOfFlow (Widget *widget) - { return testWidgetFloat (widget) || testWidgetAbsolutelyPositioned (widget) - || testWidgetFixedlyPositioned (widget); } - - static inline bool testWidgetRelativelyPositioned (Widget *widget) - { return widget->getStyle()->position == core::style::POSITION_RELATIVE; } - static bool getOOFMIndex (Widget *widget); void initOutOfFlowMgrs (); @@ -232,6 +215,41 @@ public: OOFAwareWidget (); ~OOFAwareWidget (); + static inline bool testStyleFloat (core::style::Style *style) + { return style->vloat != core::style::FLOAT_NONE; } + + static inline bool testStyleAbsolutelyPositioned (core::style::Style *style) + { return style->position == core::style::POSITION_ABSOLUTE; } + static inline bool testStyleFixedlyPositioned (core::style::Style *style) + { return style->position == core::style::POSITION_FIXED; } + static inline bool testStyleRelativelyPositioned (core::style::Style *style) + { return style->position == core::style::POSITION_RELATIVE; } + + static inline bool testStylePositioned (core::style::Style *style) + { return testStyleAbsolutelyPositioned (style) || + testStyleRelativelyPositioned (style) || + testStyleFixedlyPositioned (style); } + + static inline bool testStyleOutOfFlow (core::style::Style *style) + { return testStyleFloat (style) || testStyleAbsolutelyPositioned (style) + || testStyleFixedlyPositioned (style); } + + static inline bool testWidgetFloat (Widget *widget) + { return testStyleFloat (widget->getStyle ()); } + + static inline bool testWidgetAbsolutelyPositioned (Widget *widget) + { return testStyleAbsolutelyPositioned (widget->getStyle ()); } + static inline bool testWidgetFixedlyPositioned (Widget *widget) + { return testStyleFixedlyPositioned (widget->getStyle ()); } + static inline bool testWidgetRelativelyPositioned (Widget *widget) + { return testStyleRelativelyPositioned (widget->getStyle ()); } + + static inline bool testWidgetPositioned (Widget *widget) + { return testStylePositioned (widget->getStyle ()); } + + static inline bool testWidgetOutOfFlow (Widget *widget) + { return testStyleOutOfFlow (widget->getStyle ()); } + bool doesWidgetOOFInterruptDrawing (Widget *widget); void draw (core::View *view, core::Rectangle *area, diff --git a/dw/textblock.cc b/dw/textblock.cc index c9709f4d..20c114fa 100644 --- a/dw/textblock.cc +++ b/dw/textblock.cc @@ -2539,7 +2539,7 @@ void Textblock::fillSpace (int wordNo, core::style::Style *style) setBreakOption (word, style, 0, 0, false); word->content.space = true; - word->effSpace = word->origSpace = + word->origSpace = word->effSpace = style->font->spaceWidth + style->wordSpacing; removeSpaceImgRenderer (wordNo); @@ -3156,8 +3156,6 @@ Textblock *Textblock::getTextblockForLine (int firstWord, int lastWord) Textblock *textblock = NULL; if (firstWord < words->size ()) { - DBG_MSG_WORD ("resize", 1, "<i>first word:</i> ", firstWord, ""); - // A textblock is always between two line breaks, and so the // first word of the line. Word *word = words->getRef (firstWord); diff --git a/dw/textblock.hh b/dw/textblock.hh index aaab0e1a..c4f2c66d 100644 --- a/dw/textblock.hh +++ b/dw/textblock.hh @@ -607,7 +607,7 @@ protected: lout::misc::NotSoSimpleVector <Word> *words; lout::misc::SimpleVector <Anchor> *anchors; - struct {int index, nChar;} + struct { int index, nChar; } hlStart[core::HIGHLIGHT_NUM_LAYERS], hlEnd[core::HIGHLIGHT_NUM_LAYERS]; int hoverLink; /* The link under the mouse pointer */ @@ -884,9 +884,7 @@ public: void addText (const char *text, size_t len, core::style::Style *style); inline void addText (const char *text, core::style::Style *style) - { - addText (text, strlen(text), style); - } + { addText (text, strlen(text), 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); diff --git a/dw/textblock_linebreaking.cc b/dw/textblock_linebreaking.cc index cdd99197..5cc6ad65 100644 --- a/dw/textblock_linebreaking.cc +++ b/dw/textblock_linebreaking.cc @@ -1735,7 +1735,7 @@ void Textblock::alignLine (int lineIndex) this->lineBreakWidth - (line->leftOffset + line->rightOffset); for (int i = line->firstWord; i < line->lastWord; i++) - words->getRef(i)->origSpace = words->getRef(i)->effSpace; + words->getRef(i)->effSpace = words->getRef(i)->origSpace; if (firstWord->content.type != core::Content::BREAK) { switch (firstWord->style->textAlign) { @@ -2130,8 +2130,23 @@ void Textblock::showMissingLines () void Textblock::removeTemporaryLines () { - lines->setSize (nonTemporaryLines); - DBG_OBJ_SET_NUM ("lines.size", lines->size ()); + DBG_OBJ_ENTER0 ("construct.line", 0, "removeTemporaryLines"); + + if (nonTemporaryLines < lines->size ()) { + lines->setSize (nonTemporaryLines); + DBG_OBJ_SET_NUM ("lines.size", lines->size ()); + + // For words which will be added, the values calculated before in + // accumulateWordData() are wrong, so it is called again. (Actually, the + // words from the first temporary line are correct, but for simplicity, + // we re-calculate all.) + int firstWord = + lines->size () > 0 ? lines->getLastRef()->lastWord + 1 : 0; + for (int i = firstWord; i < words->size (); i++) + accumulateWordData (i); + } + + DBG_OBJ_LEAVE (); } int Textblock::getSpaceShrinkability(struct Word *word) diff --git a/dw/widget.cc b/dw/widget.cc index 8840fc3a..c02b007f 100644 --- a/dw/widget.cc +++ b/dw/widget.cc @@ -1358,6 +1358,12 @@ void Widget::setStyle (style::Style *style) DBG_OBJ_SET_NUM ("style.height (raw)", style->height); DBG_OBJ_SET_NUM ("style.min-height (raw)", style->minHeight); DBG_OBJ_SET_NUM ("style.max-height (raw)", style->maxHeight); + + if (style->backgroundColor) + DBG_OBJ_SET_COL ("style.background-color", + style->backgroundColor->getColor ()); + else + DBG_OBJ_SET_SYM ("style.background-color", "transparent"); } /** diff --git a/lout/debug_rtfl.hh b/lout/debug_rtfl.hh index c2ecfd8b..dad2c3c0 100644 --- a/lout/debug_rtfl.hh +++ b/lout/debug_rtfl.hh @@ -37,9 +37,10 @@ // Prints an RTFL message to stdout. "fmt" contains simple format // characters how to deal with the additional arguments (no "%" -// preceeding, as in printf), or other characters, which are simply -// printed. No quoting: this function cannot be used to print the -// characters "d", "p", and "s" directly. +// preceeding, as in printf), or "c" (short for "#%06x" and used for +// colors), or other characters, which are simply printed. No quoting: +// this function cannot be used to print the characters "d", "p", and +// "s" directly. inline void rtfl_print (const char *version, const char *file, int line, const char *fmt, ...) @@ -76,6 +77,11 @@ inline void rtfl_print (const char *version, const char *file, int line, } break; + case 'c': + n = va_arg(args, int); + printf ("#06x", n); + break; + default: putchar (fmt[i]); break; @@ -211,6 +217,12 @@ inline void rtfl_print (const char *version, const char *file, int line, #define DBG_OBJ_SET_PTR_O(obj, var, val) \ RTFL_OBJ_PRINT ("set", "p:s:p", obj, var, val) +#define DBG_OBJ_SET_COL(var, val) \ + DBG_OBJ_SET_COL_O (this, var, val) + +#define DBG_OBJ_SET_COL_O(obj, var, val) \ + RTFL_OBJ_PRINT ("set", "p:s:c", obj, var, val) + #define DBG_OBJ_ARRSET_NUM(var, ind, val) \ DBG_OBJ_ARRSET_NUM_O (this, var, ind, val) @@ -241,6 +253,12 @@ inline void rtfl_print (const char *version, const char *file, int line, #define DBG_OBJ_ARRSET_PTR_O(obj, var, ind, val) \ RTFL_OBJ_PRINT ("set", "p:s.d:p", obj, var, ind, val) +#define DBG_OBJ_ARRSET_COL(var, ind, val) \ + DBG_OBJ_ARRSET_COL_O (this, var, ind, val) + +#define DBG_OBJ_ARRSET_COL_O(obj, var, ind, val) \ + RTFL_OBJ_PRINT ("set", "p:s.d:c", obj, var, ind, val) + #define DBG_OBJ_ARRATTRSET_NUM(var, ind, attr, val) \ DBG_OBJ_ARRATTRSET_NUM_O (this, var, ind, attr, val) @@ -272,6 +290,12 @@ inline void rtfl_print (const char *version, const char *file, int line, #define DBG_OBJ_ARRATTRSET_PTR_O(obj, var, ind, attr, val) \ RTFL_OBJ_PRINT ("set", "p:s.d.s:p", obj, var, ind, attr, val) +#define DBG_OBJ_ARRATTRSET_COL(var, ind, attr, val) \ + DBG_OBJ_ARRATTRSET_COL_O (this, var, ind, attr, val) + +#define DBG_OBJ_ARRATTRSET_COL_O(obj, var, ind, attr, val) \ + RTFL_OBJ_PRINT ("set", "p:s.d.s:c", obj, var, ind, attr, val) + #define DBG_OBJ_CLASS_COLOR(klass, color) \ RTFL_OBJ_PRINT ("class-color", "s:s", klass, color) @@ -313,6 +337,8 @@ inline void rtfl_print (const char *version, const char *file, int line, #define DBG_OBJ_SET_STR_O(obj, var, val) STMT_NOP #define DBG_OBJ_SET_PTR(var, val) STMT_NOP #define DBG_OBJ_SET_PTR_O(obj, var, val) STMT_NOP +#define DBG_OBJ_SET_COL(var, val) STMT_NOP +#define DBG_OBJ_SET_COL_O(obj, var, val) STMT_NOP #define DBG_OBJ_ARRSET_NUM(var, ind, val) STMT_NOP #define DBG_OBJ_ARRSET_NUM_O(obj, var, ind, val) STMT_NOP #define DBG_OBJ_ARRSET_SYM(var, ind, val) STMT_NOP @@ -323,6 +349,8 @@ inline void rtfl_print (const char *version, const char *file, int line, #define DBG_OBJ_ARRSET_STR_O(obj, var, ind, val) STMT_NOP #define DBG_OBJ_ARRSET_PTR(var, ind, val) STMT_NOP #define DBG_OBJ_ARRSET_PTR_O(obj, var, ind, val) STMT_NOP +#define DBG_OBJ_ARRSET_COL(var, ind, val) STMT_NOP +#define DBG_OBJ_ARRSET_COL_O(obj, var, ind, val) STMT_NOP #define DBG_OBJ_ARRATTRSET_NUM(var, ind, attr, val) STMT_NOP #define DBG_OBJ_ARRATTRSET_NUM_O(obj, var, ind, attr, val) STMT_NOP #define DBG_OBJ_ARRATTRSET_SYM(var, ind, attr, val) STMT_NOP @@ -333,6 +361,8 @@ inline void rtfl_print (const char *version, const char *file, int line, #define DBG_OBJ_ARRATTRSET_STR_O(obj, var, ind, attr, val) STMT_NOP #define DBG_OBJ_ARRATTRSET_PTR(var, ind, attr, val) STMT_NOP #define DBG_OBJ_ARRATTRSET_PTR_O(obj, var, ind, attr, val) STMT_NOP +#define DBG_OBJ_ARRATTRSET_COL(var, ind, attr, val) STMT_NOP +#define DBG_OBJ_ARRATTRSET_COL_O(obj, var, ind, attr, val) STMT_NOP #define DBG_OBJ_CLASS_COLOR(klass, color) STMT_NOP #endif /* DBG_RTFL */ diff --git a/src/html.cc b/src/html.cc index 843b69ff..56af12a9 100644 --- a/src/html.cc +++ b/src/html.cc @@ -374,6 +374,11 @@ static void Html_add_textblock(DilloHtml *html, bool addBreaks, int breakSpace) S_TOP(html)->hand_over_break = true; } +static bool Html_will_textblock_be_out_of_flow(DilloHtml *html) +{ + return HT2TB(html)->testStyleOutOfFlow (html->style ()); +} + /* * Create and initialize a new DilloHtml class */ @@ -3859,8 +3864,7 @@ static void Html_check_html5_obsolete(DilloHtml *html, int ni) static void Html_display_block(DilloHtml *html) { - //HT2TB(html)->addParbreak (5, html->styleEngine->wordStyle ()); - Html_add_textblock(html, true, 0); + Html_add_textblock(html, !Html_will_textblock_be_out_of_flow (html), 0); } static void Html_display_inline_block(DilloHtml *html) |