dillo  3.0.5
About: dillo is a small, fast, extensible Web browser particularly suitable for older or smaller computers and embedded systems (but only limited or no support for frames, CSS, JavaScript, Java).
  Fossies Dox: dillo-3.0.5.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

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 
26 namespace dw {
27 
29 {
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 
82 {
83  list->unref (listPos);
84  DBG_OBJ_DELETE ();
85 }
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
DBG_OBJ_DELETE
#define DBG_OBJ_DELETE()
Definition: debug.hh:176
dw::AlignedTextblock
Base widget for all textblocks (sub classes of dw::Textblock), which are positioned vertically and al...
Definition: alignedtextblock.hh:13
dw::AlignedTextblock::list
List * list
Definition: alignedtextblock.hh:41
dw::AlignedTextblock::setRefTextblock
void setRefTextblock(AlignedTextblock *ref)
Definition: alignedtextblock.cc:70
dw::AlignedTextblock::List::textblocks
lout::misc::SimpleVector< AlignedTextblock * > * textblocks
Definition: alignedtextblock.hh:19
DBG_OBJ_CREATE
#define DBG_OBJ_CREATE(klass)
Definition: debug.hh:175
dw::Textblock
A Widget for rendering text blocks, i.e. paragraphs or sequences of paragraphs.
Definition: textblock.hh:149
dw::AlignedTextblock::listPos
int listPos
Definition: alignedtextblock.hh:42
dw::AlignedTextblock::List::unref
void unref(int pos)
Definition: alignedtextblock.cc:51
dw::Textblock::limitTextWidth
bool limitTextWidth
Definition: textblock.hh:474
dw::AlignedTextblock::updateValue
void updateValue()
Definition: alignedtextblock.cc:87
dw::AlignedTextblock::List::List
List()
Definition: alignedtextblock.cc:28
dw::AlignedTextblock::setMaxValue
virtual void setMaxValue(int maxValue, int value)=0
alignedtextblock.hh
dw::AlignedTextblock::List
Definition: alignedtextblock.hh:16
dw::AlignedTextblock::List::setValue
void setValue(int pos, int value)
Definition: alignedtextblock.hh:37
dw::AlignedTextblock::CLASS_ID
static int CLASS_ID
Definition: alignedtextblock.hh:54
dw::AlignedTextblock::getValue
virtual int getValue()=0
dw::AlignedTextblock::List::~List
~List()
Definition: alignedtextblock.cc:36
dw::AlignedTextblock::List::getMaxValue
int getMaxValue()
Definition: alignedtextblock.hh:30
dw::AlignedTextblock::List::getValue
int getValue(int pos)
Definition: alignedtextblock.hh:36
dw::AlignedTextblock::List::getTextblock
AlignedTextblock * getTextblock(int pos)
Definition: alignedtextblock.hh:34
dw::AlignedTextblock::List::refCount
int refCount
Definition: alignedtextblock.hh:21
dw::AlignedTextblock::List::values
lout::misc::SimpleVector< int > * values
Definition: alignedtextblock.hh:20
dw::AlignedTextblock::List::add
int add(AlignedTextblock *textblock)
Definition: alignedtextblock.cc:42
lout::identity::IdentifiableObject::registerName
void registerName(const char *className, int *classId)
This method must be called in the constructor for the sub class. See class comment for details.
Definition: identity.cc:67
dw::AlignedTextblock::List::maxValue
int maxValue
Definition: alignedtextblock.hh:21
dw::AlignedTextblock::~AlignedTextblock
~AlignedTextblock()
Definition: alignedtextblock.cc:81
dw::AlignedTextblock::List::setMaxValue
void setMaxValue(int maxValue)
Definition: alignedtextblock.hh:31
dw
Dw is in this namespace, or sub namespaces of this one.
Definition: alignedtextblock.cc:26
lout::misc::SimpleVector
Simple (simpler than container::untyped::Vector and container::typed::Vector) template based vector.
Definition: misc.hh:71
dw::AlignedTextblock::AlignedTextblock
AlignedTextblock(bool limitTextWidth)
Definition: alignedtextblock.cc:63
dw::AlignedTextblock::List::size
int size()
Definition: alignedtextblock.hh:33