Dillo v3.1.1-119-g140d9ebd
Loading...
Searching...
No Matches
alignedtextblock.cc
Go to the documentation of this file.
1/*
2 * Dillo Widget
3 *
4 * Copyright 2005-2007 Sebastian Geerken <sgeerken@dillo.org>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20
21
22#include "alignedtextblock.hh"
23#include "../lout/debug.hh"
24#include <stdio.h>
25
26namespace dw {
27
29{
30 textblocks = new lout::misc::SimpleVector <AlignedTextblock*> (4);
31 values = new lout::misc::SimpleVector <int> (4);
32 maxValue = 0;
33 refCount = 0;
34}
35
37{
38 delete textblocks;
39 delete values;
40}
41
43{
44 textblocks->increase ();
45 values->increase ();
46 textblocks->set (textblocks->size () - 1, textblock);
47 refCount++;
48 return textblocks->size () - 1;
49}
50
52{
53 assert (textblocks->get (pos) != NULL);
54 textblocks->set (pos, NULL);
55 refCount--;
56
57 if (refCount == 0)
58 delete this;
59}
60
62
65{
66 DBG_OBJ_CREATE ("dw::AlignedTextblock");
67 registerName ("dw::AlignedTextblock", &CLASS_ID);
68}
69
71{
72 if (ref == NULL)
73 list = new List();
74 else
75 list = ref->list;
76
77 listPos = list->add (this);
78 updateValue ();
79}
80
86
88{
89 if (list) {
91
92 if (list->getValue (listPos) > list->getMaxValue ()) {
93 // New value greater than current maximum -> apply it to others.
95
96 for (int i = 0; i < list->size (); i++)
97 if (list->getTextblock (i))
99 list->getValue (i));
100 } else {
101 /* No change, apply old max_value only to this page. */
103 }
104 }
105}
106
107} // namespace dw
void setMaxValue(int maxValue)
lout::misc::SimpleVector< AlignedTextblock * > * textblocks
lout::misc::SimpleVector< int > * values
AlignedTextblock * getTextblock(int pos)
void setValue(int pos, int value)
int add(AlignedTextblock *textblock)
Base widget for all textblocks (sub classes of dw::Textblock), which are positioned vertically and al...
virtual int getValue()=0
virtual void setMaxValue(int maxValue, int value)=0
AlignedTextblock(bool limitTextWidth)
void setRefTextblock(AlignedTextblock *ref)
A Widget for rendering text blocks, i.e.
Definition textblock.hh:206
bool limitTextWidth
Definition textblock.hh:572
void registerName(const char *className, int *classId)
This method must be called in the constructor for the sub class.
Definition identity.cc:83
#define DBG_OBJ_DELETE()
#define DBG_OBJ_CREATE(klass)
Dw is in this namespace, or sub namespaces of this one.