diff options
author | Sebastian Geerken <devnull@localhost> | 2012-11-28 12:54:36 +0100 |
---|---|---|
committer | Sebastian Geerken <devnull@localhost> | 2012-11-28 12:54:36 +0100 |
commit | 90ca861dcdc37266b51f645951448f3757aeb80f (patch) | |
tree | 44c5f66ceeef56fbd53e3b969348b4025bfce665 | |
parent | 69d1b0097e8991679ec3c0df1eea149ae41b27c9 (diff) | |
parent | c3457db125316fe83f9a6c714ac1dd76e70b581c (diff) |
Merge.
-rw-r--r-- | dpi/downloads.cc | 1 | ||||
-rw-r--r-- | dw/fltkui.cc | 25 | ||||
-rw-r--r-- | dw/textblock.cc | 27 | ||||
-rw-r--r-- | dw/textblock.hh | 2 | ||||
-rw-r--r-- | dw/textblock_linebreaking.cc | 3 | ||||
-rw-r--r-- | src/dialog.cc | 1 | ||||
-rw-r--r-- | src/form.cc | 16 |
7 files changed, 50 insertions, 25 deletions
diff --git a/dpi/downloads.cc b/dpi/downloads.cc index 418dbd1b..a25b511e 100644 --- a/dpi/downloads.cc +++ b/dpi/downloads.cc @@ -30,6 +30,7 @@ #include <sys/wait.h> #include <FL/Fl.H> +#include <FL/fl_ask.H> #include <FL/fl_draw.H> #include <FL/Fl_File_Chooser.H> #include <FL/Fl_Window.H> diff --git a/dw/fltkui.cc b/dw/fltkui.cc index 14914dfe..86a3af3f 100644 --- a/dw/fltkui.cc +++ b/dw/fltkui.cc @@ -1229,12 +1229,19 @@ void FltkListResource::widgetCallback (Fl_Widget *widget, void *data) { Fl_Tree_Item *fltkItem = ((Fl_Tree *) widget)->callback_item (); int index = -1; + if (fltkItem) index = (long) (fltkItem->user_data ()); if (index > -1) { - FltkListResource *res = (FltkListResource *) data; bool selected = fltkItem->is_selected (); - res->itemsSelected.set (index, selected); + + if (selected && fltkItem->has_children()) { + /* Don't permit a group to be selected. */ + fltkItem->deselect(); + } else { + FltkListResource *res = (FltkListResource *) data; + res->itemsSelected.set (index, selected); + } } } @@ -1273,15 +1280,18 @@ void FltkListResource::addItem (const char *str, bool enabled, bool selected) void FltkListResource::setItem (int index, bool selected) { Fl_Tree *tree = (Fl_Tree *) widget; - Fl_Tree_Item *item = tree->root()->child(index); + Fl_Tree_Item *item = tree->root()->next(); + + for (int i = 0; item && i < index; i++) + item = item->next(); - /* TODO: handle groups */ if (item) { itemsSelected.set (index, selected); - if (mode == SELECTION_MULTIPLE) + if (selected && mode != SELECTION_MULTIPLE) { + const bool do_callback = true; + tree->select_only(item, do_callback); + } else item->select(selected); - else if (selected) - tree->select_only(item); queueResize (true); } } @@ -1290,7 +1300,6 @@ void FltkListResource::pushGroup (const char *name, bool enabled) { bool selected = false; - /* TODO: make it impossible to select a group */ currParent = (Fl_Tree_Item *) newItem(name, enabled, selected); queueResize (true); } diff --git a/dw/textblock.cc b/dw/textblock.cc index 67d03449..446c4757 100644 --- a/dw/textblock.cc +++ b/dw/textblock.cc @@ -54,6 +54,16 @@ int Textblock::penalties[PENALTY_NUM][2] = { { 100, 800 } }; +/** + * 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 minus-hyphen is used. + */ +const char *Textblock::hyphenDrawChar = "-"; + void Textblock::setPenaltyHyphen (int penaltyHyphen) { penalties[PENALTY_HYPHEN][0] = penaltyHyphen; @@ -971,8 +981,8 @@ void Textblock::drawWord (Line *line, int wordIndex1, int wordIndex2, l += strlen (w->content.text); totalWidth += w->size.width; } - - char text[l + (drawHyphen ? 3 : 0) + 1]; + + char text[l + (drawHyphen ? strlen (hyphenDrawChar) : 0) + 1]; int p = 0; for (int i = wordIndex1; i <= wordIndex2; i++) { const char * t = words->getRef(i)->content.text; @@ -981,10 +991,8 @@ void Textblock::drawWord (Line *line, int wordIndex1, int wordIndex2, } if(drawHyphen) { - // "\xe2\x80\x90" is an unconditional hyphen. - text[p++] = '\xe2'; - text[p++] = '\x80'; - text[p++] = '\x90'; + for (int i = 0; hyphenDrawChar[i]; i++) + text[p++] = hyphenDrawChar[i]; text[p++] = 0; } @@ -1638,10 +1646,11 @@ void Textblock::addText (const char *text, size_t len, // Currently, only unconditional hyphens (UTF-8: // "\xe2\x80\x90") can be used. See also drawWord, last // section "if (drawHyphen)". - // The character defined in DivChar::s could be used, - // but it must then also stored in the word. + // Could be extended by adding respective members to + // DivChar and Word. word->hyphenWidth = - layout->textWidth (word->style->font, "\xe2\x80\x90", 3); + layout->textWidth (word->style->font, hyphenDrawChar, + strlen (hyphenDrawChar)); word->flags |= Word::DIV_CHAR_AT_EOL; } diff --git a/dw/textblock.hh b/dw/textblock.hh index 9c848354..b1ad3ee8 100644 --- a/dw/textblock.hh +++ b/dw/textblock.hh @@ -229,6 +229,8 @@ private: static DivChar divChars[NUM_DIV_CHARS]; + static const char *hyphenDrawChar; + protected: struct Line { diff --git a/dw/textblock_linebreaking.cc b/dw/textblock_linebreaking.cc index cbfd4fa7..63d482ee 100644 --- a/dw/textblock_linebreaking.cc +++ b/dw/textblock_linebreaking.cc @@ -706,7 +706,8 @@ int Textblock::hyphenateWord (int wordIndex) penalties[PENALTY_HYPHEN][1]); // "\xe2\x80\x90" is an unconditional hyphen. w->hyphenWidth = - layout->textWidth (origWord.style->font, "\xe2\x80\x90", 3); + layout->textWidth (w->style->font, hyphenDrawChar, + strlen (hyphenDrawChar)); w->flags |= (Word::DRAW_AS_ONE_TEXT | Word::DIV_CHAR_AT_EOL | Word::UNBREAKABLE_FOR_MIN_WIDTH); diff --git a/src/dialog.cc b/src/dialog.cc index 1b8fd2db..6a8fd071 100644 --- a/src/dialog.cc +++ b/src/dialog.cc @@ -13,6 +13,7 @@ #include <math.h> // for rint() +#include <FL/fl_ask.H> #include <FL/Fl_Window.H> #include <FL/Fl_File_Chooser.H> #include <FL/Fl_Return_Button.H> diff --git a/src/form.cc b/src/form.cc index 92e06ab1..05042569 100644 --- a/src/form.cc +++ b/src/form.cc @@ -752,11 +752,12 @@ void Html_tag_open_select(DilloHtml *html, const char *tag, int tagsize) type = DILLO_HTML_INPUT_SELECT; res = factory->createOptionMenuResource (); } else { + ListResource::SelectionMode mode; + type = DILLO_HTML_INPUT_SEL_LIST; - res = factory->createListResource (multi ? - ListResource::SELECTION_MULTIPLE : - ListResource::SELECTION_EXACTLY_ONE, - rows); + mode = multi ? ListResource::SELECTION_MULTIPLE + : ListResource::SELECTION_AT_MOST_ONE; + res = factory->createListResource (mode, rows); } Embed *embed = new Embed(res); @@ -787,9 +788,10 @@ void Html_tag_close_select(DilloHtml *html) DilloHtmlInput *input = Html_get_current_input(html); DilloHtmlSelect *select = input->select; - // BUG(?): should not do this for MULTI selections - select->ensureSelection (); - + if (input->type == DILLO_HTML_INPUT_SELECT) { + // option menu interface requires that something be selected */ + select->ensureSelection (); + } SelectionResource *res = (SelectionResource*)input->embed->getResource(); select->addOptionsTo (res); } |