diff options
-rw-r--r-- | dw/layout.cc | 2 | ||||
-rw-r--r-- | dw/layout.hh | 2 | ||||
-rw-r--r-- | dw/textblock.cc | 2 | ||||
-rw-r--r-- | dw/widget.cc | 14 | ||||
-rw-r--r-- | lout/container.hh | 3 | ||||
-rw-r--r-- | test/containers.cc | 17 |
6 files changed, 32 insertions, 8 deletions
diff --git a/dw/layout.cc b/dw/layout.cc index e8907d21..2845a8e9 100644 --- a/dw/layout.cc +++ b/dw/layout.cc @@ -260,7 +260,7 @@ Layout::Layout (Platform *platform) topLevel = NULL; widgetAtPoint = NULL; - queueQueueResizeList = new typed::Vector<QueueResizeItem> (4, true); + queueQueueResizeList = new typed::Stack<QueueResizeItem> (true); queueResizeList = new typed::Vector<Widget> (4, false); DBG_OBJ_CREATE ("dw::core::Layout"); diff --git a/dw/layout.hh b/dw/layout.hh index 39ff74db..63c3ed04 100644 --- a/dw/layout.hh +++ b/dw/layout.hh @@ -172,7 +172,7 @@ private: Platform *platform; View *view; Widget *topLevel, *widgetAtPoint; - lout::container::typed::Vector<QueueResizeItem> *queueQueueResizeList; + lout::container::typed::Stack<QueueResizeItem> *queueQueueResizeList; lout::container::typed::Vector<Widget> *queueResizeList; /* The state, which must be projected into the view. */ diff --git a/dw/textblock.cc b/dw/textblock.cc index baf757b1..ead9e375 100644 --- a/dw/textblock.cc +++ b/dw/textblock.cc @@ -2914,7 +2914,7 @@ void Textblock::borderChanged (int y, Widget *vloat) } minWrapLineIndex = misc::min (minWrapLineIndex, lineIndex2); - maxWrapLineIndex = misc::max (minWrapLineIndex, lineIndex2); + maxWrapLineIndex = misc::max (maxWrapLineIndex, lineIndex2); } } diff --git a/dw/widget.cc b/dw/widget.cc index 2b153ae2..fec193a1 100644 --- a/dw/widget.cc +++ b/dw/widget.cc @@ -219,8 +219,9 @@ void Widget::queueResize (int ref, bool extremesChanged, bool fast) if (queueResizeEntered ()) { DBG_OBJ_MSG ("resize", 1, "put into queue"); - layout->queueQueueResizeList->put (new Layout::QueueResizeItem - (this, ref, extremesChanged, fast)); + layout->queueQueueResizeList->pushUnder (new Layout::QueueResizeItem + (this, ref, extremesChanged, + fast)); } else { actualQueueResize (ref, extremesChanged, fast); @@ -235,6 +236,9 @@ void Widget::queueResize (int ref, bool extremesChanged, bool fast) DBG_IF_RTFL { DBG_OBJ_MSGF ("resize", 1, "queue item list has %d elements:", layout->queueQueueResizeList->size ()); +#if 0 + // TODO This worked when queueQueueResizeList was a Vector; now, + // iterators should be used. DBG_OBJ_MSG_START (); for (int i = 0; i < layout->queueQueueResizeList->size (); i++) { DBG_OBJ_MSGF @@ -250,12 +254,14 @@ void Widget::queueResize (int ref, bool extremesChanged, bool fast) } DBG_OBJ_MSG_END (); DBG_OBJ_MSG ("resize", 1, "taking #0 out of list"); +#endif } - Layout::QueueResizeItem *item = layout->queueQueueResizeList->get (0); + Layout::QueueResizeItem *item = + layout->queueQueueResizeList->getTop (); item->widget->actualQueueResize (item->ref, item->extremesChanged, item->fast); - layout->queueQueueResizeList->remove (0); // hopefully not too large + layout->queueQueueResizeList->pop (); } } diff --git a/lout/container.hh b/lout/container.hh index 03800efd..a7f01732 100644 --- a/lout/container.hh +++ b/lout/container.hh @@ -295,7 +295,8 @@ public: }; /** - * \brief A stack (LIFO). + * \brief A stack (LIFO). Can be used as Queue (FIFO) when pushUnder() + * is used instead of push(). * * Note that the iterator returns all elements in the reversed order they have * been put on the stack. diff --git a/test/containers.cc b/test/containers.cc index 9b93f158..af317d7e 100644 --- a/test/containers.cc +++ b/test/containers.cc @@ -128,6 +128,22 @@ void testVector3 () printf (" -> %d\n", v.bsearch (&k, false)); } +void testStackAsQueue () +{ + puts ("--- testStackAsQueue ---"); + + Stack<Integer> s (true); + + for (int i = 1; i <= 10; i++) + s.pushUnder (new Integer (i)); + + while (s.size () > 0) { + Integer *i = s.getTop (); + printf ("%d\n", i->getValue ()); + s.pop (); + } +} + int main (int argc, char *argv[]) { testHashSet (); @@ -135,6 +151,7 @@ int main (int argc, char *argv[]) testVector1 (); testVector2 (); testVector3 (); + testStackAsQueue (); return 0; } |