aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Geerken <devnull@localhost>2014-09-12 13:03:47 +0200
committerSebastian Geerken <devnull@localhost>2014-09-12 13:03:47 +0200
commit36fcd74196a898403ef1e66884dc52d296c42665 (patch)
tree4465142622a9ae8b8f91a75577bf64e8df3bc5a8
parent3590571500d5e00bdb65e70ce777735a26318a39 (diff)
OOFAwareWidget: moving more stuff from Textblock to OOFAwareWidget.
-rw-r--r--dw/oofawarewidget.cc55
-rw-r--r--dw/oofawarewidget.hh8
-rw-r--r--dw/textblock.cc40
-rw-r--r--dw/textblock.hh1
4 files changed, 65 insertions, 39 deletions
diff --git a/dw/oofawarewidget.cc b/dw/oofawarewidget.cc
index f2a85563..673d4596 100644
--- a/dw/oofawarewidget.cc
+++ b/dw/oofawarewidget.cc
@@ -18,6 +18,10 @@
*/
#include "oofawarewidget.hh"
+#include "ooffloatsmgr.hh"
+#include "oofposabsmgr.hh"
+#include "oofposfixedmgr.hh"
+#include "textblock.hh"
using namespace lout::misc;
@@ -25,6 +29,57 @@ namespace dw {
namespace oof {
+OOFAwareWidget::OOFAwareWidget ()
+{
+ for (int i = 0; i < NUM_OOFM; i++) {
+ oofContainer[i] = NULL;
+ outOfFlowMgr[i] = NULL;
+ }
+}
+
+OOFAwareWidget::~OOFAwareWidget ()
+{
+}
+
+void OOFAwareWidget::initOutOfFlowMgrs ()
+{
+ if (oofContainer[OOFM_FLOATS]->outOfFlowMgr[OOFM_FLOATS] == NULL) {
+ oofContainer[OOFM_FLOATS]->outOfFlowMgr[OOFM_FLOATS] =
+ new OOFFloatsMgr (oofContainer[OOFM_FLOATS]);
+ DBG_OBJ_ASSOC (oofContainer[OOFM_FLOATS],
+ oofContainer[OOFM_FLOATS]->outOfFlowMgr[OOFM_FLOATS]);
+ }
+
+ if (oofContainer[OOFM_ABSOLUTE]->outOfFlowMgr[OOFM_ABSOLUTE] == NULL) {
+ oofContainer[OOFM_ABSOLUTE]->outOfFlowMgr[OOFM_ABSOLUTE] =
+ new OOFPosAbsMgr (oofContainer[OOFM_ABSOLUTE]);
+ DBG_OBJ_ASSOC (oofContainer[OOFM_ABSOLUTE],
+ oofContainer[OOFM_ABSOLUTE]->outOfFlowMgr[OOFM_ABSOLUTE]);
+ }
+
+ if (oofContainer[OOFM_FIXED]->outOfFlowMgr[OOFM_FIXED] == NULL) {
+ oofContainer[OOFM_FIXED]->outOfFlowMgr[OOFM_FIXED] =
+ new OOFPosFixedMgr (oofContainer[OOFM_FIXED]);
+ DBG_OBJ_ASSOC (oofContainer[OOFM_FIXED],
+ oofContainer[OOFM_FIXED]->outOfFlowMgr[OOFM_FIXED]);
+ }
+}
+
+void OOFAwareWidget::sizeAllocateStart (core::Allocation *allocation)
+{
+
+ for (int i = 0; i < NUM_OOFM; i++)
+ if (oofContainer[i]->outOfFlowMgr[i])
+ oofContainer[i]->outOfFlowMgr[i]->sizeAllocateStart (this, allocation);
+}
+
+void OOFAwareWidget::sizeAllocateEnd ()
+{
+ for (int i = 0; i < NUM_OOFM; i++)
+ if (oofContainer[i]->outOfFlowMgr[i])
+ oofContainer[i]->outOfFlowMgr[i]->sizeAllocateEnd (this);
+}
+
void OOFAwareWidget::borderChanged (int y, Widget *vloat)
{
assertNotReached ();
diff --git a/dw/oofawarewidget.hh b/dw/oofawarewidget.hh
index 37b8eeb3..890d8a14 100644
--- a/dw/oofawarewidget.hh
+++ b/dw/oofawarewidget.hh
@@ -26,10 +26,18 @@ public:
OOFAwareWidget *oofContainer[NUM_OOFM];
oof::OutOfFlowMgr *outOfFlowMgr[NUM_OOFM];
+protected:
+ void initOutOfFlowMgrs ();
+ void sizeAllocateStart (core::Allocation *allocation);
+ void sizeAllocateEnd ();
+
inline OutOfFlowMgr *searchOutOfFlowMgr (int oofmIndex)
{ return oofContainer[oofmIndex] ?
oofContainer[oofmIndex]->outOfFlowMgr[oofmIndex] : NULL; }
public:
+ OOFAwareWidget ();
+ ~OOFAwareWidget ();
+
virtual void borderChanged (int y, core::Widget *vloat);
virtual void oofSizeChanged (bool extremesChanged);
virtual int getLineBreakWidth (); // Should perhaps be renamed.
diff --git a/dw/textblock.cc b/dw/textblock.cc
index 5e213975..062b727b 100644
--- a/dw/textblock.cc
+++ b/dw/textblock.cc
@@ -19,9 +19,6 @@
#include "textblock.hh"
-#include "ooffloatsmgr.hh"
-#include "oofposabsmgr.hh"
-#include "oofposfixedmgr.hh"
#include "../lout/msg.h"
#include "../lout/misc.hh"
#include "../lout/unicode.hh"
@@ -230,11 +227,6 @@ Textblock::Textblock (bool limitTextWidth)
registerName ("dw::Textblock", &CLASS_ID);
setButtonSensitive(true);
- for (int i = 0; i < NUM_OOFM; i++) {
- oofContainer[i] = NULL;
- outOfFlowMgr[i] = NULL;
- }
-
hasListitemValue = false;
leftInnerPadding = 0;
line1Offset = 0;
@@ -585,9 +577,7 @@ void Textblock::sizeAllocateImpl (core::Allocation *allocation)
DBG_OBJ_SET_NUM ("childBaseAllocation.ascent", childBaseAllocation.ascent);
DBG_OBJ_SET_NUM ("childBaseAllocation.descent", childBaseAllocation.descent);
- for (int i = 0; i < NUM_OOFM; i++)
- if (searchOutOfFlowMgr(i))
- searchOutOfFlowMgr(i)->sizeAllocateStart (this, allocation);
+ sizeAllocateStart (allocation);
int lineIndex, wordIndex;
Line *line;
@@ -715,9 +705,7 @@ void Textblock::sizeAllocateImpl (core::Allocation *allocation)
DBG_OBJ_MSG_END ();
- for (int i = 0; i < NUM_OOFM; i++)
- if (searchOutOfFlowMgr(i))
- searchOutOfFlowMgr(i)->sizeAllocateEnd (this);
+ sizeAllocateEnd ();
for (int i = 0; i < anchors->size(); i++) {
Anchor *anchor = anchors->getRef(i);
@@ -2349,30 +2337,6 @@ void Textblock::addText0 (const char *text, size_t len, short flags,
DBG_OBJ_LEAVE ();
}
-void Textblock::initOutOfFlowMgrs ()
-{
- if (oofContainer[OOFM_FLOATS]->outOfFlowMgr[OOFM_FLOATS] == NULL) {
- oofContainer[OOFM_FLOATS]->outOfFlowMgr[OOFM_FLOATS] =
- new oof::OOFFloatsMgr (oofContainer[OOFM_FLOATS]);
- DBG_OBJ_ASSOC (oofContainer[OOFM_FLOATS],
- oofContainer[OOFM_FLOATS]->outOfFlowMgr[OOFM_FLOATS]);
- }
-
- if (oofContainer[OOFM_ABSOLUTE]->outOfFlowMgr[OOFM_ABSOLUTE] == NULL) {
- oofContainer[OOFM_ABSOLUTE]->outOfFlowMgr[OOFM_ABSOLUTE] =
- new oof::OOFPosAbsMgr (oofContainer[OOFM_ABSOLUTE]);
- DBG_OBJ_ASSOC (oofContainer[OOFM_ABSOLUTE],
- oofContainer[OOFM_ABSOLUTE]->outOfFlowMgr[OOFM_ABSOLUTE]);
- }
-
- if (oofContainer[OOFM_FIXED]->outOfFlowMgr[OOFM_FIXED] == NULL) {
- oofContainer[OOFM_FIXED]->outOfFlowMgr[OOFM_FIXED] =
- new oof::OOFPosFixedMgr (oofContainer[OOFM_FIXED]);
- DBG_OBJ_ASSOC (oofContainer[OOFM_FIXED],
- oofContainer[OOFM_FIXED]->outOfFlowMgr[OOFM_FIXED]);
- }
-}
-
/**
* Add a widget (word type) to the page.
*/
diff --git a/dw/textblock.hh b/dw/textblock.hh
index ec47ec9b..4cadeffd 100644
--- a/dw/textblock.hh
+++ b/dw/textblock.hh
@@ -833,7 +833,6 @@ protected:
void addText0 (const char *text, size_t len, short flags,
core::style::Style *style, core::Requisition *size);
- void initOutOfFlowMgrs ();
void calcTextSizes (const char *text, size_t textLen,
core::style::Style *style,
int numBreaks, int *breakPos,