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)  

tablecell.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 "tablecell.hh"
23 #include "../lout/debug.hh"
24 #include <stdio.h>
25 
26 namespace dw {
27 
28 int TableCell::CLASS_ID = -1;
29 
30 TableCell::TableCell (TableCell *ref, bool limitTextWidth):
31  AlignedTextblock (limitTextWidth)
32 {
33  DBG_OBJ_CREATE ("dw::TableCell");
34  registerName ("dw::TableCell", &CLASS_ID);
35 
37  //ignoreLine1OffsetSometimes = true;
38  charWordIndex = -1;
39  setRefTextblock (ref);
40  setButtonSensitive(true);
41 }
42 
44 {
45  DBG_OBJ_DELETE ();
46 }
47 
48 bool TableCell::wordWrap(int wordIndex, bool wrapAll)
49 {
50  Textblock::Word *word;
51  const char *p;
52 
53  bool ret = Textblock::wordWrap (wordIndex, wrapAll);
54 
55  if (charWordIndex == -1) {
56  word = words->getRef (wordIndex);
57  if (word->content.type == core::Content::TEXT) {
58  if ((p = strchr (word->content.text,
59  word->style->textAlignChar))) {
60  charWordIndex = wordIndex;
61  charWordPos = p - word->content.text + 1;
62  } else if (word->style->textAlignChar == ' ' &&
63  word->content.space) {
64  charWordIndex = wordIndex + 1;
65  charWordPos = 0;
66  }
67  }
68  }
69 
70  if (wordIndex == charWordIndex)
71  updateValue ();
72 
73  return ret;
74 }
75 
77 {
78  Textblock::Word *word;
79  int i, wordIndex;
80  int w;
81 
82  if (charWordIndex == -1)
83  wordIndex = words->size () -1;
84  else
85  wordIndex = charWordIndex;
86 
87  w = 0;
88  for (i = 0; i < wordIndex; i++) {
89  word = words->getRef (i);
90  w += word->size.width + word->origSpace;
91  }
92 
93  if (charWordIndex == -1) {
94  if (words->size () > 0) {
95  word = words->getRef (words->size () - 1);
96  w += word->size.width;
97  }
98  } else {
99  word = words->getRef (charWordIndex);
100  w += layout->textWidth (word->style->font, word->content.text,
101  charWordPos);
102  }
103 
104  return w;
105 }
106 
107 void TableCell::setMaxValue (int maxValue, int value)
108 {
109  line1Offset = maxValue - value;
110  queueResize (0, true);
111 }
112 
113 } // 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::setRefTextblock
void setRefTextblock(AlignedTextblock *ref)
Definition: alignedtextblock.cc:70
dw::TableCell::charWordPos
int charWordPos
Definition: tablecell.hh:12
DBG_OBJ_CREATE
#define DBG_OBJ_CREATE(klass)
Definition: debug.hh:175
dw::TableCell
Definition: tablecell.hh:9
dw::core::Widget::layout
Layout * layout
Definition: widget.hh:159
dw::core::style::StyleAttrs::textAlignChar
char textAlignChar
Definition: style.hh:504
dw::Textblock::Word::origSpace
short origSpace
Definition: textblock.hh:361
dw::core::Widget::setButtonSensitive
void setButtonSensitive(bool buttonSensitive)
Definition: widget.cc:474
dw::AlignedTextblock::updateValue
void updateValue()
Definition: alignedtextblock.cc:87
dw::TableCell::charWordIndex
int charWordIndex
Definition: tablecell.hh:12
dw::core::Content::space
bool space
Definition: types.hh:202
dw::core::Content::text
const char * text
Definition: types.hh:204
dw::Textblock::Word
Definition: textblock.hh:328
dw::TableCell::TableCell
TableCell(TableCell *ref, bool limitTextWidth)
Definition: tablecell.cc:30
dw::Textblock::line1Offset
int line1Offset
Definition: textblock.hh:437
tablecell.hh
dw::TableCell::wordWrap
bool wordWrap(int wordIndex, bool wrapAll)
Definition: tablecell.cc:48
dw::Textblock::Word::style
core::style::Style * style
Definition: textblock.hh:388
dw::Textblock::Word::content
core::Content content
Definition: textblock.hh:371
dw::core::Layout::textWidth
int textWidth(style::Font *font, const char *text, int len)
Definition: layout.hh:327
dw::TableCell::~TableCell
~TableCell()
Definition: tablecell.cc:43
dw::core::Requisition::width
int width
Definition: types.hh:174
dw::TableCell::getValue
int getValue()
Definition: tablecell.cc:76
dw::TableCell::setMaxValue
void setMaxValue(int maxValue, int value)
Definition: tablecell.cc:107
dw::Textblock::Word::size
core::Requisition size
Definition: textblock.hh:359
dw::Textblock::words
lout::misc::NotSoSimpleVector< Word > * words
Definition: textblock.hh:487
dw::core::style::StyleAttrs::font
Font * font
Definition: style.hh:492
dw::core::Content::TEXT
Definition: types.hh:190
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::core::Widget::queueResize
void queueResize(int ref, bool extremesChanged)
This method should be called, when a widget changes its size.
Definition: widget.cc:171
dw
Dw is in this namespace, or sub namespaces of this one.
Definition: alignedtextblock.cc:26
dw::TableCell::CLASS_ID
static int CLASS_ID
Definition: tablecell.hh:21
dw::core::Content::type
short type
Definition: types.hh:201
dw::Textblock::wordWrap
virtual bool wordWrap(int wordIndex, bool wrapAll)
Definition: textblock_linebreaking.cc:508