aboutsummaryrefslogtreecommitdiff
path: root/dw/tablecell.cc
diff options
context:
space:
mode:
Diffstat (limited to 'dw/tablecell.cc')
-rw-r--r--dw/tablecell.cc146
1 files changed, 77 insertions, 69 deletions
diff --git a/dw/tablecell.cc b/dw/tablecell.cc
index 8612f620..3e143c96 100644
--- a/dw/tablecell.cc
+++ b/dw/tablecell.cc
@@ -1,7 +1,7 @@
/*
* Dillo Widget
*
- * Copyright 2005-2007 Sebastian Geerken <sgeerken@dillo.org>
+ * 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
@@ -17,97 +17,105 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-
-
#include "tablecell.hh"
-#include "../lout/debug.hh"
-#include <stdio.h>
+#include "table.hh"
namespace dw {
-int TableCell::CLASS_ID = -1;
+/**
+ * \brief Provided some common implementations of virtual widget
+ * methods.
+ *
+ * Once I understand how diamond inheritance works, a class TableCell
+ * will be provided, from which SimpleTableCell and AlignedTableCell
+ * will inherit, additionaly (in a multiple way).
+ */
+namespace tablecell {
-TableCell::TableCell (TableCell *ref, bool limitTextWidth):
- AlignedTextblock (limitTextWidth)
+bool getAdjustMinWidth ()
{
- DBG_OBJ_CREATE ("dw::TableCell");
- registerName ("dw::TableCell", &CLASS_ID);
-
- /** \bug ignoreLine1OffsetSometimes does not work? */
- //ignoreLine1OffsetSometimes = true;
- charWordIndex = -1;
- setRefTextblock (ref);
- setButtonSensitive(true);
+ return Table::getAdjustTableMinWidth ();
}
-TableCell::~TableCell()
+bool isBlockLevel ()
{
- DBG_OBJ_DELETE ();
+ return false;
}
-bool TableCell::wordWrap(int wordIndex, bool wrapAll)
+int correctAvailWidthOfChild (core::Widget *widget, core::Widget *child,
+ int width, bool forceValue)
{
- Textblock::Word *word;
- const char *p;
-
- bool ret = Textblock::wordWrap (wordIndex, wrapAll);
-
- if (charWordIndex == -1) {
- word = words->getRef (wordIndex);
- if (word->content.type == core::Content::TEXT) {
- if ((p = strchr (word->content.text,
- word->style->textAlignChar))) {
- charWordIndex = wordIndex;
- charWordPos = p - word->content.text + 1;
- } else if (word->style->textAlignChar == ' ' &&
- word->content.space) {
- charWordIndex = wordIndex + 1;
- charWordPos = 0;
- }
- }
+ DBG_OBJ_ENTER_O ("resize", 0, widget, "tablecell/correctAvailWidthOfChild",
+ "%p, %d, %s", child, width, forceValue ? "true" : "false");
+
+ // Make sure that this width does not exceed the width of the table
+ // cell (minus margin/border/padding).
+
+ if (width != -1) {
+ int thisWidth = widget->getAvailWidth (forceValue);
+ DBG_OBJ_MSGF_O ("resize", 1, widget, "thisWidth = %d", thisWidth);
+ if (thisWidth != -1)
+ width =
+ lout::misc::max (lout::misc::min (width,
+ thisWidth
+ - widget->boxDiffWidth ()),
+ 0);
}
- if (wordIndex == charWordIndex)
- updateValue ();
+ DBG_OBJ_MSGF_O ("resize", 1, widget, "=> %d", width);
+ DBG_OBJ_LEAVE_O (widget);
+ return width;
+}
- return ret;
+int correctAvailHeightOfChild (core::Widget *widget, core::Widget *child,
+ int height, bool forceValue)
+{
+ // Something to do?
+ return height;
}
-int TableCell::getValue ()
+void correctCorrectedRequisitionOfChild (core::Widget *widget,
+ core::Widget *child,
+ core::Requisition *requisition,
+ void (*splitHeightFun) (int, int*,
+ int*))
{
- Textblock::Word *word;
- int i, wordIndex;
- int w;
-
- if (charWordIndex == -1)
- wordIndex = words->size () -1;
- else
- wordIndex = charWordIndex;
-
- w = 0;
- for (i = 0; i < wordIndex; i++) {
- word = words->getRef (i);
- w += word->size.width + word->origSpace;
- }
+ DBG_OBJ_ENTER_O ("resize", 0, widget, "tablecell/correctRequisitionOfChild",
+ "%p, %d * (%d + %d), ...", child, requisition->width,
+ requisition->ascent, requisition->descent);
- if (charWordIndex == -1) {
- if (words->size () > 0) {
- word = words->getRef (words->size () - 1);
- w += word->size.width;
- }
- } else {
- word = words->getRef (charWordIndex);
- w += layout->textWidth (word->style->font, word->content.text,
- charWordPos);
- }
+ // Make sure that this width does not exceed the width of the table
+ // cell (minus margin/border/padding).
+
+ int thisWidth = widget->getAvailWidth (true);
+ DBG_OBJ_MSGF_O ("resize", 1, widget, "thisWidth = %d", thisWidth);
+ requisition->width =
+ lout::misc::max (lout::misc::min (requisition->width,
+ thisWidth - widget->boxDiffWidth ()),
+ 0);
- return w;
+ DBG_OBJ_LEAVE_O (widget);
}
-void TableCell::setMaxValue (int maxValue, int value)
+void correctCorrectedExtremesOfChild (core::Widget *widget, core::Widget *child,
+ core::Extremes *extremes,
+ bool useAdjustmentWidth)
{
- line1Offset = maxValue - value;
- queueResize (0, true);
+ // Something to do?
}
+int applyPerWidth (core::Widget *widget, int containerWidth,
+ core::style::Length perWidth)
+{
+ return core::style::multiplyWithPerLength (containerWidth, perWidth);
+}
+
+int applyPerHeight (core::Widget *widget, int containerHeight,
+ core::style::Length perHeight)
+{
+ return core::style::multiplyWithPerLength (containerHeight, perHeight);
+}
+
+} // namespace dw
+
} // namespace dw