summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Geerken <devnull@localhost>2012-11-14 14:04:25 +0100
committerSebastian Geerken <devnull@localhost>2012-11-14 14:04:25 +0100
commit53e9245bcbaea2b7b4485369aa2289f1d102f26c (patch)
tree686a6e3125fca5c7889d2010633d697704bf33c9
parent7a991750e1f7bdfe6bd39f95343cc742d00c6596 (diff)
Cleaned up preferences.
-rw-r--r--dw/alignedtextblock.cc4
-rw-r--r--dw/alignedtextblock.hh2
-rw-r--r--dw/listitem.cc4
-rw-r--r--dw/listitem.hh2
-rw-r--r--dw/tablecell.cc4
-rw-r--r--dw/tablecell.hh2
-rw-r--r--dw/textblock.cc15
-rw-r--r--dw/textblock.hh6
-rw-r--r--src/dillo.cc3
-rw-r--r--src/form.cc2
-rw-r--r--src/html.cc9
-rw-r--r--src/plain.cc2
-rw-r--r--src/prefs.c1
-rw-r--r--src/prefs.h2
-rw-r--r--src/prefsparser.cc1
-rw-r--r--src/table.cc4
-rw-r--r--test/dw_anchors_test.cc2
-rw-r--r--test/dw_border_test.cc4
-rw-r--r--test/dw_example.cc2
-rw-r--r--test/dw_find_test.cc4
-rw-r--r--test/dw_images_scaled.cc2
-rw-r--r--test/dw_images_scaled2.cc2
-rw-r--r--test/dw_images_simple.cc2
-rw-r--r--test/dw_links.cc2
-rw-r--r--test/dw_links2.cc2
-rw-r--r--test/dw_lists.cc4
-rw-r--r--test/dw_resource_test.cc2
-rw-r--r--test/dw_table.cc2
-rw-r--r--test/dw_table_aligned.cc2
-rw-r--r--test/dw_ui_test.cc14
30 files changed, 61 insertions, 48 deletions
diff --git a/dw/alignedtextblock.cc b/dw/alignedtextblock.cc
index 934c43ec..dde408b2 100644
--- a/dw/alignedtextblock.cc
+++ b/dw/alignedtextblock.cc
@@ -59,8 +59,8 @@ void AlignedTextblock::List::unref(int pos)
int AlignedTextblock::CLASS_ID = -1;
-AlignedTextblock::AlignedTextblock (bool limitTextWidth, int penaltyHyphen):
- Textblock (limitTextWidth, penaltyHyphen)
+AlignedTextblock::AlignedTextblock (bool limitTextWidth):
+ Textblock (limitTextWidth)
{
registerName ("dw::AlignedTextblock", &CLASS_ID);
}
diff --git a/dw/alignedtextblock.hh b/dw/alignedtextblock.hh
index 084bfcb3..7bac15bb 100644
--- a/dw/alignedtextblock.hh
+++ b/dw/alignedtextblock.hh
@@ -42,7 +42,7 @@ private:
int listPos;
protected:
- AlignedTextblock(bool limitTextWidth, int penaltyHyphen);
+ AlignedTextblock(bool limitTextWidth);
virtual int getValue () = 0;
virtual void setMaxValue (int maxValue, int value) = 0;
diff --git a/dw/listitem.cc b/dw/listitem.cc
index 54901e1a..ed7a2c75 100644
--- a/dw/listitem.cc
+++ b/dw/listitem.cc
@@ -26,8 +26,8 @@ namespace dw {
int ListItem::CLASS_ID = -1;
-ListItem::ListItem (ListItem *ref, bool limitTextWidth, int penaltyHyphen):
- AlignedTextblock (limitTextWidth, penaltyHyphen)
+ListItem::ListItem (ListItem *ref, bool limitTextWidth):
+ AlignedTextblock (limitTextWidth)
{
registerName ("dw::ListItem", &CLASS_ID);
setRefTextblock (ref);
diff --git a/dw/listitem.hh b/dw/listitem.hh
index 31b5cd27..2e303d5d 100644
--- a/dw/listitem.hh
+++ b/dw/listitem.hh
@@ -15,7 +15,7 @@ protected:
public:
static int CLASS_ID;
- ListItem(ListItem *ref, bool limitTextWidth, int penaltyHyphen);
+ ListItem(ListItem *ref, bool limitTextWidth);
~ListItem();
void initWithWidget (core::Widget *widget, core::style::Style *style);
diff --git a/dw/tablecell.cc b/dw/tablecell.cc
index 79bc77d2..90dc310d 100644
--- a/dw/tablecell.cc
+++ b/dw/tablecell.cc
@@ -26,8 +26,8 @@ namespace dw {
int TableCell::CLASS_ID = -1;
-TableCell::TableCell (TableCell *ref, bool limitTextWidth, int penaltyHyphen):
- AlignedTextblock (limitTextWidth, penaltyHyphen)
+TableCell::TableCell (TableCell *ref, bool limitTextWidth):
+ AlignedTextblock (limitTextWidth)
{
registerName ("dw::TableCell", &CLASS_ID);
diff --git a/dw/tablecell.hh b/dw/tablecell.hh
index 11003544..4bb8633c 100644
--- a/dw/tablecell.hh
+++ b/dw/tablecell.hh
@@ -20,7 +20,7 @@ protected:
public:
static int CLASS_ID;
- TableCell(TableCell *ref, bool limitTextWidth, int penaltyHyphen);
+ TableCell(TableCell *ref, bool limitTextWidth);
~TableCell();
};
diff --git a/dw/textblock.cc b/dw/textblock.cc
index 213594d3..f6e1ad9c 100644
--- a/dw/textblock.cc
+++ b/dw/textblock.cc
@@ -46,7 +46,18 @@ Textblock::DivChar Textblock::divChars[NUM_DIV_CHARS] = {
{ "\xe2\x80\x94", false, true, PENALTY_HYPHEN, PENALTY_HYPHEN }
};
-Textblock::Textblock (bool limitTextWidth, int penaltyHyphen)
+
+int Textblock::penalties[PENALTY_NUM][2] = {
+ { 100, 100 }
+};
+
+void Textblock::init (int penaltyHyphen, int penaltyHyphen2)
+{
+ penalties[PENALTY_HYPHEN][0] = penaltyHyphen;
+ penalties[PENALTY_HYPHEN][1] = penaltyHyphen2;
+}
+
+Textblock::Textblock (bool limitTextWidth)
{
registerName ("dw::Textblock", &CLASS_ID);
setFlags (BLOCK_LEVEL);
@@ -92,8 +103,6 @@ Textblock::Textblock (bool limitTextWidth, int penaltyHyphen)
availDescent = 0;
this->limitTextWidth = limitTextWidth;
- penalties[PENALTY_HYPHEN][0] = penaltyHyphen;
- penalties[PENALTY_HYPHEN][1] = INT_MAX; // TODO Configuration
for (int layer = 0; layer < core::HIGHLIGHT_NUM_LAYERS; layer++) {
/* hlStart[layer].index > hlEnd[layer].index means no highlighting */
diff --git a/dw/textblock.hh b/dw/textblock.hh
index 5f588a23..b3bb6e98 100644
--- a/dw/textblock.hh
+++ b/dw/textblock.hh
@@ -393,7 +393,7 @@ protected:
* dw::Textblock::BadnessAndPenalty::setPenalty for more
* details. Set from preferences.
*/
- int penalties[PENALTY_NUM][2];
+ static int penalties[PENALTY_NUM][2];
bool limitTextWidth; /* from preferences */
@@ -569,7 +569,9 @@ protected:
public:
static int CLASS_ID;
- Textblock(bool limitTextWidth, int penaltyHyphen);
+ static void init (int penaltyHyphen, int penaltyHyphen2);
+
+ Textblock(bool limitTextWidth);
~Textblock();
core::Iterator *iterator (core::Content::Type mask, bool atEnd);
diff --git a/src/dillo.cc b/src/dillo.cc
index 173ac036..cb522b8a 100644
--- a/src/dillo.cc
+++ b/src/dillo.cc
@@ -50,6 +50,7 @@
#include "auth.h"
#include "dw/fltkcore.hh"
+#include "dw/textblock.hh"
/*
* Command line options structure
@@ -359,6 +360,8 @@ int main(int argc, char **argv)
a_Cookies_init();
a_Auth_init();
+ dw::Textblock::init (prefs.penalty_hyphen, prefs.penalty_hyphen_2);
+
/* command line options override preferences */
if (options_got & DILLO_CLI_FULLWINDOW)
prefs.fullwindow_start = TRUE;
diff --git a/src/form.cc b/src/form.cc
index 90dc6d50..099f1a48 100644
--- a/src/form.cc
+++ b/src/form.cc
@@ -871,7 +871,7 @@ void Html_tag_open_button(DilloHtml *html, const char *tag, int tagsize)
/* We used to have Textblock (prefs.limit_text_width, ...) here,
* but it caused 100% CPU usage.
*/
- page = new Textblock (false, prefs.penalty_hyphen);
+ page = new Textblock (false);
page->setStyle (html->styleEngine->backgroundStyle ());
ResourceFactory *factory = HT2LT(html)->getResourceFactory();
diff --git a/src/html.cc b/src/html.cc
index ad4eae21..7ba1a69e 100644
--- a/src/html.cc
+++ b/src/html.cc
@@ -352,8 +352,7 @@ bool a_Html_tag_set_valign_attr(DilloHtml *html, const char *tag, int tagsize)
*/
static void Html_add_textblock(DilloHtml *html, int space)
{
- Textblock *textblock =
- new Textblock (prefs.limit_text_width, prefs.penalty_hyphen);
+ Textblock *textblock = new Textblock (prefs.limit_text_width);
HT2TB(html)->addParbreak (space, html->styleEngine->wordStyle ());
HT2TB(html)->addWidget (textblock, html->styleEngine->style ());
@@ -459,8 +458,7 @@ void DilloHtml::initDw()
dReturn_if_fail (dw == NULL);
/* Create the main widget */
- dw = stack->getRef(0)->textblock =
- new Textblock (prefs.limit_text_width, prefs.penalty_hyphen);
+ dw = stack->getRef(0)->textblock = new Textblock (prefs.limit_text_width);
bw->num_page_bugs = 0;
dStr_truncate(bw->page_bugs, 0);
@@ -3521,8 +3519,7 @@ static void Html_display_listitem(DilloHtml *html)
HT2TB(html)->addParbreak (0, wordStyle);
- list_item = new ListItem ((ListItem*)*ref_list_item,prefs.limit_text_width,
- prefs.penalty_hyphen);
+ list_item = new ListItem ((ListItem*)*ref_list_item,prefs.limit_text_width);
HT2TB(html)->addWidget (list_item, style);
HT2TB(html)->addParbreak (0, wordStyle);
*ref_list_item = list_item;
diff --git a/src/plain.cc b/src/plain.cc
index b29bf226..4da618e4 100644
--- a/src/plain.cc
+++ b/src/plain.cc
@@ -90,7 +90,7 @@ DilloPlain::DilloPlain(BrowserWindow *p_bw)
/* Init internal variables */
bw = p_bw;
- dw = new Textblock (prefs.limit_text_width, prefs.penalty_hyphen);
+ dw = new Textblock (prefs.limit_text_width);
Start_Ofs = 0;
state = ST_SeekingEol;
diff --git a/src/prefs.c b/src/prefs.c
index 09e48862..da597607 100644
--- a/src/prefs.c
+++ b/src/prefs.c
@@ -103,6 +103,7 @@ void a_Prefs_init(void)
prefs.w3c_plus_heuristics = TRUE;
prefs.penalty_hyphen = 100;
+ prefs.penalty_hyphen_2 = 100;
}
/*
diff --git a/src/prefs.h b/src/prefs.h
index 7392d74e..7cb4f113 100644
--- a/src/prefs.h
+++ b/src/prefs.h
@@ -89,7 +89,7 @@ struct _DilloPrefs {
bool_t show_msg;
bool_t show_extra_warnings;
bool_t middle_click_drags_page;
- int penalty_hyphen;
+ int penalty_hyphen, penalty_hyphen_2;
};
/* Global Data */
diff --git a/src/prefsparser.cc b/src/prefsparser.cc
index d555a55f..ceba7dd7 100644
--- a/src/prefsparser.cc
+++ b/src/prefsparser.cc
@@ -112,6 +112,7 @@ int PrefsParser::parseOption(char *name, char *value)
{ "theme", &prefs.theme, PREFS_STRING },
{ "w3c_plus_heuristics", &prefs.w3c_plus_heuristics, PREFS_BOOL },
{ "penalty_hyphen", &prefs.penalty_hyphen, PREFS_FRACTION_100 },
+ { "penalty_hyphen_2", &prefs.penalty_hyphen_2, PREFS_FRACTION_100 }
};
node = NULL;
diff --git a/src/table.cc b/src/table.cc
index 3487bab3..98157e76 100644
--- a/src/table.cc
+++ b/src/table.cc
@@ -421,9 +421,9 @@ static void Html_tag_content_table_cell(DilloHtml *html,
== TEXT_ALIGN_STRING)
col_tb = new dw::TableCell (
((dw::Table*)S_TOP(html)->table)->getCellRef (),
- prefs.limit_text_width, prefs.penalty_hyphen);
+ prefs.limit_text_width);
else
- col_tb = new Textblock (prefs.limit_text_width, prefs.penalty_hyphen);
+ col_tb = new Textblock (prefs.limit_text_width);
if (html->styleEngine->style()->borderCollapse == BORDER_MODEL_COLLAPSE){
Html_set_collapsing_border_model(html, col_tb);
diff --git a/test/dw_anchors_test.cc b/test/dw_anchors_test.cc
index 74a2be86..cb839f40 100644
--- a/test/dw_anchors_test.cc
+++ b/test/dw_anchors_test.cc
@@ -55,7 +55,7 @@ static void anchorCallback (Fl_Widget *widget, void *data)
static void textTimeout (void *data)
{
Textblock *oldTop = topTextblock;
- topTextblock = new Textblock (false, 100);
+ topTextblock = new Textblock (false);
if (oldTop) {
oldTop->addLinebreak (wordStyle);
diff --git a/test/dw_border_test.cc b/test/dw_border_test.cc
index f523750b..988abc33 100644
--- a/test/dw_border_test.cc
+++ b/test/dw_border_test.cc
@@ -76,7 +76,7 @@ int main(int argc, char **argv)
Style *widgetStyle2 = Style::create (layout, &styleAttrs);
- Textblock *textblock1 = new Textblock (false, 100);
+ Textblock *textblock1 = new Textblock (false);
textblock1->setStyle (widgetStyle1);
layout->setWidget (textblock1);
@@ -101,7 +101,7 @@ int main(int argc, char **argv)
for(int i = 0; i < 1; i++) {
textblock1->addParbreak(0, wordStyle);
- Textblock *textblock2 = new Textblock (false, 100);
+ Textblock *textblock2 = new Textblock (false);
textblock1->addWidget (textblock2, widgetStyle2);
for(int j = 0; words2[j]; j++) {
diff --git a/test/dw_example.cc b/test/dw_example.cc
index 7879dfd8..52aa2440 100644
--- a/test/dw_example.cc
+++ b/test/dw_example.cc
@@ -62,7 +62,7 @@ int main(int argc, char **argv)
dw::core::style::Style *widgetStyle =
dw::core::style::Style::create (layout, &styleAttrs);
- dw::Textblock *textblock = new dw::Textblock (false, 100);
+ dw::Textblock *textblock = new dw::Textblock (false);
textblock->setStyle (widgetStyle);
layout->setWidget (textblock);
diff --git a/test/dw_find_test.cc b/test/dw_find_test.cc
index 27817664..e5c79fd3 100644
--- a/test/dw_find_test.cc
+++ b/test/dw_find_test.cc
@@ -117,7 +117,7 @@ int main(int argc, char **argv)
styleAttrs.margin.left = 0;
Style *wordStyle = Style::create (layout, &styleAttrs);
- Textblock *textblock = new Textblock (false, 100);
+ Textblock *textblock = new Textblock (false);
textblock->setStyle (topWidgetStyle);
layout->setWidget (textblock);
@@ -128,7 +128,7 @@ int main(int argc, char **argv)
for(int j = 0; j < 10; j++) {
Textblock *current;
if(j < 5) {
- current = new Textblock (false, 100);
+ current = new Textblock (false);
stack->getTop()->addWidget (current, widgetStyle);
stack->push (current);
} else {
diff --git a/test/dw_images_scaled.cc b/test/dw_images_scaled.cc
index 415a727d..2f8896e6 100644
--- a/test/dw_images_scaled.cc
+++ b/test/dw_images_scaled.cc
@@ -122,7 +122,7 @@ int main(int argc, char **argv)
Style *widgetStyle = Style::create (layout, &styleAttrs);
- Textblock *textblock = new Textblock (false, 100);
+ Textblock *textblock = new Textblock (false);
textblock->setStyle (widgetStyle);
layout->setWidget (textblock);
diff --git a/test/dw_images_scaled2.cc b/test/dw_images_scaled2.cc
index 211d997d..2adb1770 100644
--- a/test/dw_images_scaled2.cc
+++ b/test/dw_images_scaled2.cc
@@ -97,7 +97,7 @@ int main(int argc, char **argv)
Style *widgetStyle = Style::create (layout, &styleAttrs);
- Textblock *textblock = new Textblock (false, 100);
+ Textblock *textblock = new Textblock (false);
textblock->setStyle (widgetStyle);
layout->setWidget (textblock);
diff --git a/test/dw_images_simple.cc b/test/dw_images_simple.cc
index 33e370a6..8f00f847 100644
--- a/test/dw_images_simple.cc
+++ b/test/dw_images_simple.cc
@@ -121,7 +121,7 @@ int main(int argc, char **argv)
Style *widgetStyle = Style::create (layout, &styleAttrs);
- Textblock *textblock = new Textblock (false, 100);
+ Textblock *textblock = new Textblock (false);
textblock->setStyle (widgetStyle);
layout->setWidget (textblock);
diff --git a/test/dw_links.cc b/test/dw_links.cc
index 633fa73b..5622cbd5 100644
--- a/test/dw_links.cc
+++ b/test/dw_links.cc
@@ -101,7 +101,7 @@ int main(int argc, char **argv)
Style *widgetStyle = Style::create (layout, &styleAttrs);
- Textblock *textblock = new Textblock (false, 100);
+ Textblock *textblock = new Textblock (false);
textblock->setStyle (widgetStyle);
layout->setWidget (textblock);
diff --git a/test/dw_links2.cc b/test/dw_links2.cc
index 2ec10d0d..b8e8c55b 100644
--- a/test/dw_links2.cc
+++ b/test/dw_links2.cc
@@ -130,7 +130,7 @@ int main(int argc, char **argv)
Style *widgetStyle = Style::create (layout, &styleAttrs);
- Textblock *textblock = new Textblock (false, 100);
+ Textblock *textblock = new Textblock (false);
textblock->setStyle (widgetStyle);
layout->setWidget (textblock);
diff --git a/test/dw_lists.cc b/test/dw_lists.cc
index 64b66828..12fa1627 100644
--- a/test/dw_lists.cc
+++ b/test/dw_lists.cc
@@ -63,7 +63,7 @@ int main(int argc, char **argv)
Style *widgetStyle = Style::create (layout, &styleAttrs);
- Textblock *textblock = new Textblock (false, 100);
+ Textblock *textblock = new Textblock (false);
textblock->setStyle (widgetStyle);
layout->setWidget (textblock);
@@ -103,7 +103,7 @@ int main(int argc, char **argv)
ListItem *refItem = NULL;
for(int i = 1; i <= 100; i++) {
- ListItem *listItem = new ListItem (refItem, false, 100);
+ ListItem *listItem = new ListItem (refItem, false);
refItem = listItem;
textblock->addWidget (listItem, itemStyle);
diff --git a/test/dw_resource_test.cc b/test/dw_resource_test.cc
index 0b817dcb..a2a26c62 100644
--- a/test/dw_resource_test.cc
+++ b/test/dw_resource_test.cc
@@ -64,7 +64,7 @@ int main(int argc, char **argv)
Style *widgetStyle = Style::create (layout, &styleAttrs);
- Textblock *textblock = new Textblock (false, 100);
+ Textblock *textblock = new Textblock (false);
textblock->setStyle (widgetStyle);
layout->setWidget (textblock);
diff --git a/test/dw_table.cc b/test/dw_table.cc
index ef1572a6..75842e60 100644
--- a/test/dw_table.cc
+++ b/test/dw_table.cc
@@ -92,7 +92,7 @@ int main(int argc, char **argv)
table->addRow (wordStyle);
for (int j = 0; j < 4; j++) {
- Textblock *cell = new Textblock (false, 100);
+ Textblock *cell = new Textblock (false);
cell->setStyle (cellStyle);
table->addCell (cell, 1, 1);
diff --git a/test/dw_table_aligned.cc b/test/dw_table_aligned.cc
index 927c397e..022e7026 100644
--- a/test/dw_table_aligned.cc
+++ b/test/dw_table_aligned.cc
@@ -90,7 +90,7 @@ int main(int argc, char **argv)
TableCell *ref = NULL;
for(int i = 0; i < 10; i++) {
//for(int i = 0; i < 1; i++) {
- TableCell *cell = new TableCell (ref, false, 100);
+ TableCell *cell = new TableCell (ref, false);
cell->setStyle (cellStyle);
ref = cell;
table->addRow (wordStyle);
diff --git a/test/dw_ui_test.cc b/test/dw_ui_test.cc
index ee024acc..60893f06 100644
--- a/test/dw_ui_test.cc
+++ b/test/dw_ui_test.cc
@@ -104,7 +104,7 @@ int main(int argc, char **argv)
// Note on complex buttons: before any operations on the widget, which
// need a layout, the complex button resource should be created, since
// then, a layout and a platform are instantiated.
- Textblock *cbuttontext = new Textblock(false, 100);
+ Textblock *cbuttontext = new Textblock(false);
ComplexButtonResource *cbuttonres =
layout->getResourceFactory()->createComplexButtonResource (cbuttontext,
true);
@@ -131,7 +131,7 @@ int main(int argc, char **argv)
// Create the widgets.
table->addRow (cellStyle);
- Textblock *label1 = new Textblock(false, 100);
+ Textblock *label1 = new Textblock(false);
label1->setStyle (cellStyle);
table->addCell (label1, 1, 1);
label1->addText ("val1 = ", cellStyle);
@@ -143,7 +143,7 @@ int main(int argc, char **argv)
table->addRow (cellStyle);
- Textblock *label2 = new Textblock(false, 100);
+ Textblock *label2 = new Textblock(false);
label2->setStyle (cellStyle);
table->addCell (label2, 1, 1);
label2->addText ("val2 = ", cellStyle);
@@ -155,7 +155,7 @@ int main(int argc, char **argv)
table->addRow (cellStyle);
- Textblock *label = new Textblock(false, 100);
+ Textblock *label = new Textblock(false);
label->setStyle (cellStyle);
table->addCell (label, 1, 1);
label->addText ("text = ", cellStyle);
@@ -168,7 +168,7 @@ int main(int argc, char **argv)
table->addRow (cellStyle);
- Textblock *radiolabel1 = new Textblock(false, 100);
+ Textblock *radiolabel1 = new Textblock(false);
radiolabel1->setStyle (cellStyle);
table->addCell (radiolabel1, 2, 1);
Embed *radio1 = new Embed (radiores1);
@@ -177,7 +177,7 @@ int main(int argc, char **argv)
radiolabel1->flush ();
table->addRow (cellStyle);
- Textblock *radiolabel2 = new Textblock(false, 100);
+ Textblock *radiolabel2 = new Textblock(false);
radiolabel2->setStyle (cellStyle);
table->addCell (radiolabel2, 2, 1);
Embed *radio2 = new Embed (radiores2);
@@ -186,7 +186,7 @@ int main(int argc, char **argv)
radiolabel2->flush ();
table->addRow (cellStyle);
- Textblock *checklabel = new Textblock(false, 100);
+ Textblock *checklabel = new Textblock(false);
checklabel->setStyle (cellStyle);
table->addCell (checklabel, 2, 1);
Embed *check = new Embed (checkres);