aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Geerken <devnull@localhost>2014-05-28 00:58:21 +0200
committerSebastian Geerken <devnull@localhost>2014-05-28 00:58:21 +0200
commit4c47a19af4349ba45833ff37406f78bba1fde5ef (patch)
treecb22f4a523f4ff883c525378fb68c50e31c3d536
parentc0135425bdb0bdaeed57c99638e8bbeb94a5c17d (diff)
Split up dw::TableCell in dw::AlignedTableCell (was: dw::TableCell) and dw::SimpleTableCell (derived from dw::Textblock). The HTML parser now uses only one of these two classes for table cells, not dw::Textblock anymore.
-rw-r--r--dw/Makefile.am6
-rw-r--r--dw/alignedtablecell.cc (renamed from dw/tablecell.cc)18
-rw-r--r--dw/alignedtablecell.hh (renamed from dw/tablecell.hh)12
-rw-r--r--dw/simpletablecell.cc41
-rw-r--r--dw/simpletablecell.hh19
-rw-r--r--dw/table.cc6
-rw-r--r--dw/table.hh4
-rw-r--r--src/table.cc5
-rw-r--r--test/dw_table.cc1
-rw-r--r--test/dw_table_aligned.cc6
10 files changed, 90 insertions, 28 deletions
diff --git a/dw/Makefile.am b/dw/Makefile.am
index 5306c5a5..496e31a8 100644
--- a/dw/Makefile.am
+++ b/dw/Makefile.am
@@ -57,6 +57,8 @@ libDw_fltk_a_SOURCES = \
libDw_fltk_a_CXXFLAGS = @LIBFLTK_CXXFLAGS@
libDw_widgets_a_SOURCES = \
+ alignedtablecell.cc \
+ alignedtablecell.hh \
alignedtextblock.cc \
alignedtextblock.hh \
bullet.cc \
@@ -71,10 +73,10 @@ libDw_widgets_a_SOURCES = \
outofflowmgr.hh \
ruler.cc \
ruler.hh \
+ simpletablecell.cc \
+ simpletablecell.hh \
table.cc \
table.hh \
- tablecell.cc \
- tablecell.hh \
textblock.cc \
textblock_iterator.cc \
textblock_linebreaking.cc \
diff --git a/dw/tablecell.cc b/dw/alignedtablecell.cc
index cbd5e0bf..2b81645d 100644
--- a/dw/tablecell.cc
+++ b/dw/alignedtablecell.cc
@@ -19,19 +19,19 @@
-#include "tablecell.hh"
+#include "alignedtablecell.hh"
#include "../lout/debug.hh"
#include <stdio.h>
namespace dw {
-int TableCell::CLASS_ID = -1;
+int AlignedTableCell::CLASS_ID = -1;
-TableCell::TableCell (TableCell *ref, bool limitTextWidth):
+AlignedTableCell::AlignedTableCell (AlignedTableCell *ref, bool limitTextWidth):
AlignedTextblock (limitTextWidth)
{
- DBG_OBJ_CREATE ("dw::TableCell");
- registerName ("dw::TableCell", &CLASS_ID);
+ DBG_OBJ_CREATE ("dw::AlignedTableCell");
+ registerName ("dw::AlignedTableCell", &CLASS_ID);
/** \bug ignoreLine1OffsetSometimes does not work? */
//ignoreLine1OffsetSometimes = true;
@@ -40,12 +40,12 @@ TableCell::TableCell (TableCell *ref, bool limitTextWidth):
setButtonSensitive(true);
}
-TableCell::~TableCell()
+AlignedTableCell::~AlignedTableCell()
{
DBG_OBJ_DELETE ();
}
-int TableCell::wordWrap(int wordIndex, bool wrapAll)
+int AlignedTableCell::wordWrap(int wordIndex, bool wrapAll)
{
Textblock::Word *word;
const char *p;
@@ -73,7 +73,7 @@ int TableCell::wordWrap(int wordIndex, bool wrapAll)
return ret;
}
-int TableCell::getValue ()
+int AlignedTableCell::getValue ()
{
Textblock::Word *word;
int i, wordIndex;
@@ -104,7 +104,7 @@ int TableCell::getValue ()
return w;
}
-void TableCell::setMaxValue (int maxValue, int value)
+void AlignedTableCell::setMaxValue (int maxValue, int value)
{
line1Offset = maxValue - value;
queueResize (OutOfFlowMgr::createRefNormalFlow (0), true);
diff --git a/dw/tablecell.hh b/dw/alignedtablecell.hh
index 1e13abf9..63e550e3 100644
--- a/dw/tablecell.hh
+++ b/dw/alignedtablecell.hh
@@ -1,12 +1,12 @@
-#ifndef __DW_TABLECELL_HH__
-#define __DW_TABLECELL_HH__
+#ifndef __DW_ALIGNEDTABLECELL_HH__
+#define __DW_ALIGNEDTABLECELL_HH__
#include "core.hh"
#include "alignedtextblock.hh"
namespace dw {
-class TableCell: public AlignedTextblock
+class AlignedTableCell: public AlignedTextblock
{
private:
int charWordIndex, charWordPos;
@@ -20,10 +20,10 @@ protected:
public:
static int CLASS_ID;
- TableCell(TableCell *ref, bool limitTextWidth);
- ~TableCell();
+ AlignedTableCell(AlignedTableCell *ref, bool limitTextWidth);
+ ~AlignedTableCell();
};
} // namespace dw
-#endif // __DW_TABLECELL_HH__
+#endif // __DW_ALIGNEDTABLECELL_HH__
diff --git a/dw/simpletablecell.cc b/dw/simpletablecell.cc
new file mode 100644
index 00000000..07f4f768
--- /dev/null
+++ b/dw/simpletablecell.cc
@@ -0,0 +1,41 @@
+/*
+ * Dillo Widget
+ *
+ * Copyright 2014 Sebastian Geerken <sgeerken@dillo.org>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+
+
+#include "simpletablecell.hh"
+#include "../lout/debug.hh"
+
+namespace dw {
+
+int SimpleTableCell::CLASS_ID = -1;
+
+SimpleTableCell::SimpleTableCell (bool limitTextWidth):
+ Textblock (limitTextWidth)
+{
+ DBG_OBJ_CREATE ("dw::SimpleTableCell");
+ registerName ("dw::SimpleTableCell", &CLASS_ID);
+}
+
+SimpleTableCell::~SimpleTableCell()
+{
+ DBG_OBJ_DELETE ();
+}
+
+} // namespace dw
diff --git a/dw/simpletablecell.hh b/dw/simpletablecell.hh
new file mode 100644
index 00000000..9eccbb00
--- /dev/null
+++ b/dw/simpletablecell.hh
@@ -0,0 +1,19 @@
+#ifndef __DW_SIMPLETABLECELL_HH__
+#define __DW_SIMPLETABLECELL_HH__
+
+#include "textblock.hh"
+
+namespace dw {
+
+class SimpleTableCell: public Textblock
+{
+public:
+ static int CLASS_ID;
+
+ SimpleTableCell (bool limitTextWidth);
+ ~SimpleTableCell ();
+};
+
+} // namespace dw
+
+#endif // __DW_SIMPLETABLECELL_HH__
diff --git a/dw/table.cc b/dw/table.cc
index 565dfc9e..794e588d 100644
--- a/dw/table.cc
+++ b/dw/table.cc
@@ -393,7 +393,7 @@ void Table::addRow (core::style::Style *style)
rowClosed = false;
}
-TableCell *Table::getCellRef ()
+AlignedTableCell *Table::getCellRef ()
{
core::Widget *child;
@@ -401,8 +401,8 @@ TableCell *Table::getCellRef ()
int n = curCol + row * numCols;
if (childDefined (n)) {
child = children->get(n)->cell.widget;
- if (child->instanceOf (TableCell::CLASS_ID))
- return (TableCell*)child;
+ if (child->instanceOf (AlignedTableCell::CLASS_ID))
+ return (AlignedTableCell*)child;
}
}
diff --git a/dw/table.hh b/dw/table.hh
index 6966a163..295bdaad 100644
--- a/dw/table.hh
+++ b/dw/table.hh
@@ -2,7 +2,7 @@
#define __DW_TABLE_HH__
#include "core.hh"
-#include "tablecell.hh"
+#include "alignedtablecell.hh"
#include "../lout/misc.hh"
namespace dw {
@@ -458,7 +458,7 @@ public:
void addCell (Widget *widget, int colspan, int rowspan);
void addRow (core::style::Style *style);
- TableCell *getCellRef ();
+ AlignedTableCell *getCellRef ();
};
} // namespace dw
diff --git a/src/table.cc b/src/table.cc
index a3002ebf..29b5fbc9 100644
--- a/src/table.cc
+++ b/src/table.cc
@@ -15,6 +15,7 @@
#include "dw/style.hh"
#include "dw/textblock.hh"
#include "dw/table.hh"
+#include "dw/simpletablecell.hh"
#include "prefs.h"
#include "msg.h"
@@ -445,11 +446,11 @@ static void Html_tag_content_table_cell(DilloHtml *html,
rowspan = MAX(1, strtol (attrbuf, NULL, 10));
if (html->style ()->textAlign
== TEXT_ALIGN_STRING)
- col_tb = new dw::TableCell (
+ col_tb = new AlignedTableCell (
((dw::Table*)S_TOP(html)->table)->getCellRef (),
prefs.limit_text_width);
else
- col_tb = new Textblock (prefs.limit_text_width);
+ col_tb = new SimpleTableCell (prefs.limit_text_width);
if (html->style()->borderCollapse == BORDER_MODEL_COLLAPSE){
Html_set_collapsing_border_model(html, col_tb);
diff --git a/test/dw_table.cc b/test/dw_table.cc
index 5416d05b..9bec1a09 100644
--- a/test/dw_table.cc
+++ b/test/dw_table.cc
@@ -26,7 +26,6 @@
#include "../dw/fltkcore.hh"
#include "../dw/fltkviewport.hh"
#include "../dw/table.hh"
-#include "../dw/tablecell.hh"
using namespace dw;
using namespace dw::core;
diff --git a/test/dw_table_aligned.cc b/test/dw_table_aligned.cc
index 96cb0602..bef3d521 100644
--- a/test/dw_table_aligned.cc
+++ b/test/dw_table_aligned.cc
@@ -26,7 +26,7 @@
#include "../dw/fltkcore.hh"
#include "../dw/fltkviewport.hh"
#include "../dw/table.hh"
-#include "../dw/tablecell.hh"
+#include "../dw/alignedtablecell.hh"
using namespace dw;
using namespace dw::core;
@@ -87,10 +87,10 @@ int main(int argc, char **argv)
Style *wordStyle = Style::create (&styleAttrs);
- TableCell *ref = NULL;
+ AlignedTableCell *ref = NULL;
for(int i = 0; i < 10; i++) {
//for(int i = 0; i < 1; i++) {
- TableCell *cell = new TableCell (ref, false);
+ AlignedTableCell *cell = new AlignedTableCell (ref, false);
cell->setStyle (cellStyle);
ref = cell;
table->addRow (wordStyle);