Dillo v3.1.1-98-g318d1f14
Loading...
Searching...
No Matches
alignedtablecell.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#include "alignedtablecell.hh"
21#include "table.hh"
22#include "tablecell.hh"
23#include "../lout/debug.hh"
24#include <stdio.h>
25
26using namespace lout;
27
28namespace dw {
29
31
33 AlignedTextblock (limitTextWidth)
34{
35 DBG_OBJ_CREATE ("dw::AlignedTableCell");
36 registerName ("dw::AlignedTableCell", &CLASS_ID);
37
39 //ignoreLine1OffsetSometimes = true;
40 charWordIndex = -1;
41 setRefTextblock (ref);
43}
44
49
50
55
60
65
66int AlignedTableCell::getAvailWidthOfChild (Widget *child, bool forceValue)
67{
68 DBG_OBJ_ENTER ("resize", 0, "AlignedTableCell::getAvailWidthOfChild",
69 "%p, %s", child, forceValue ? "true" : "false");
70
72 (this, child, Textblock::getAvailWidthOfChild (child, forceValue),
73 forceValue);
74
76 return width;
77}
78
79int AlignedTableCell::getAvailHeightOfChild (Widget *child, bool forceValue)
80{
81 DBG_OBJ_ENTER ("resize", 0, "AlignedTableCell::getAvailHeightOfChild",
82 "%p, %s", child, forceValue ? "true" : "false");
83
85 (this, child, Textblock::getAvailHeightOfChild (child, forceValue),
86 forceValue);
87
89 return height;
90}
91
94 *requisition,
95 void (*splitHeightFun) (int,
96 int*,
97 int*),
98 bool allowDecreaseWidth,
99 bool allowDecreaseHeight)
100{
101 DBG_OBJ_ENTER ("resize", 0, "AlignedTableCell::correctRequisitionOfChild",
102 "%p, %d * (%d + %d), ..., %s, %s", child, requisition->width,
104 misc::boolToStr (allowDecreaseWidth),
105 misc::boolToStr (allowDecreaseHeight));
106
108 splitHeightFun,
109 allowDecreaseWidth,
110 allowDecreaseHeight);
112 splitHeightFun,
113 allowDecreaseWidth,
114 allowDecreaseHeight);
115
116 DBG_OBJ_LEAVE ();
117}
118
120 core::Extremes *extremes,
121 bool useAdjustmentWidth)
122{
123 DBG_OBJ_ENTER ("resize", 0, "AlignedTableCell::correctExtremesOfChild",
124 "%p, %d (%d) / %d (%d)",
127
129 useAdjustmentWidth);
131 useAdjustmentWidth);
132
133 DBG_OBJ_LEAVE ();
134}
135
136int AlignedTableCell::applyPerWidth (int containerWidth,
137 core::style::Length perWidth)
138{
139 return tablecell::applyPerWidth (this, containerWidth, perWidth);
140}
141
142int AlignedTableCell::applyPerHeight (int containerHeight,
143 core::style::Length perHeight)
144{
145 return tablecell::applyPerHeight (this, containerHeight, perHeight);
146}
147
152
153int AlignedTableCell::wordWrap(int wordIndex, bool wrapAll)
154{
155 Textblock::Word *word;
156 const char *p;
157
158 int ret = Textblock::wordWrap (wordIndex, wrapAll);
159
160 if (charWordIndex == -1) {
161 word = words->getRef (wordIndex);
162 if (word->content.type == core::Content::TEXT) {
163 if ((p = strchr (word->content.text,
164 word->style->textAlignChar))) {
165 charWordIndex = wordIndex;
166 charWordPos = p - word->content.text + 1;
167 } else if (word->style->textAlignChar == ' ' &&
168 word->content.space) {
169 charWordIndex = wordIndex + 1;
170 charWordPos = 0;
171 }
172 }
173 }
174
175 if (wordIndex == charWordIndex)
176 updateValue ();
177
178 return ret;
179}
180
182{
183 Textblock::Word *word;
184 int i, wordIndex;
185 int w;
186
187 if (charWordIndex == -1)
188 wordIndex = words->size () -1;
189 else
190 wordIndex = charWordIndex;
191
192 w = 0;
193 for (i = 0; i < wordIndex; i++) {
194 word = words->getRef (i);
195 w += word->size.width + word->origSpace;
196 }
197
198 if (charWordIndex == -1) {
199 if (words->size () > 0) {
200 word = words->getRef (words->size () - 1);
201 w += word->size.width;
202 }
203 } else {
204 word = words->getRef (charWordIndex);
205 w += layout->textWidth (word->style->font, word->content.text,
207 }
208
209 return w;
210}
211
212void AlignedTableCell::setMaxValue (int maxValue, int value)
213{
214 line1Offset = maxValue - value;
216}
217
218} // namespace dw
int applyPerHeight(int containerHeight, core::style::Length perHeight)
void correctExtremesOfChild(Widget *child, core::Extremes *extremes, bool useAdjustmentWidth)
int getAvailWidthOfChild(Widget *child, bool forceValue)
void setMaxValue(int maxValue, int value)
int applyPerWidth(int containerWidth, core::style::Length perWidth)
void correctRequisitionOfChild(Widget *child, core::Requisition *requisition, void(*splitHeightFun)(int, int *, int *), bool allowDecreaseWidth, bool allowDecreaseHeight)
int wordWrap(int wordIndex, bool wrapAll)
int getAvailHeightOfChild(Widget *child, bool forceValue)
AlignedTableCell(AlignedTableCell *ref, bool limitTextWidth)
bool adjustExtraSpaceWhenCorrectingRequisitionByOOF()
Base widget for all textblocks (sub classes of dw::Textblock), which are positioned vertically and al...
void setRefTextblock(AlignedTextblock *ref)
lout::misc::NotSoSimpleVector< Word > * words
Definition textblock.hh:611
virtual int wordWrap(int wordIndex, bool wrapAll)
int getAvailHeightOfChild(core::Widget *child, bool forceValue)
Definition textblock.cc:809
int getAvailWidthOfChild(core::Widget *child, bool forceValue)
Computes the content width available of a child widget.
Definition textblock.cc:755
Extremes extremes
Analogue to dw::core::Widget::requisition.
Definition widget.hh:166
void setButtonSensitive(bool buttonSensitive)
Definition widget.cc:1568
Requisition requisition
Size_request() stores the result of the last call of size_request_impl().
Definition widget.hh:160
virtual void correctRequisitionOfChild(Widget *child, Requisition *requisition, void(*splitHeightFun)(int, int *, int *), bool allowDecreaseWidth, bool allowDecreaseHeight)
Definition widget.cc:1893
virtual void correctExtremesOfChild(Widget *child, Extremes *extremes, bool useAdjustmentWidth)
Definition widget.cc:2128
void queueResize(int ref, bool extremesChanged, bool fast)
This method should be called, when a widget changes its size.
Definition widget.cc:321
int makeParentRefInFlow(int inFlowSubRef)
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)
#define DBG_OBJ_ENTER(aspect, prio, funname, fmt,...)
#define DBG_OBJ_LEAVE()
static Layout * layout
int Length
Type for representing all lengths within dw::core::style.
Definition style.hh:429
int applyPerHeight(core::Widget *widget, int containerHeight, core::style::Length perHeight)
Definition tablecell.cc:121
int correctAvailHeightOfChild(core::Widget *widget, core::Widget *child, int height, bool forceValue)
Definition tablecell.cc:72
bool adjustExtraSpaceWhenCorrectingRequisitionByOOF()
Definition tablecell.hh:36
bool getAdjustMinWidth()
Definition tablecell.cc:37
int applyPerWidth(core::Widget *widget, int containerWidth, core::style::Length perWidth)
Definition tablecell.cc:115
int correctAvailWidthOfChild(core::Widget *widget, core::Widget *child, int width, bool forceValue)
Definition tablecell.cc:47
bool isBlockLevel()
Definition tablecell.cc:42
bool usesMaxGeneratorWidth()
Definition tablecell.hh:10
void correctCorrectedRequisitionOfChild(core::Widget *widget, core::Widget *child, core::Requisition *requisition, void(*splitHeightFun)(int, int *, int *), bool allowDecreaseWidth, bool allowDecreaseHeight)
Definition tablecell.cc:79
void correctCorrectedExtremesOfChild(core::Widget *widget, core::Widget *child, core::Extremes *extremes, bool useAdjustmentWidth)
Definition tablecell.cc:108
Dw is in this namespace, or sub namespaces of this one.
const char * boolToStr(bool b)
Definition misc.hh:108
core::style::Style * style
Definition textblock.hh:492
core::Requisition size
Definition textblock.hh:463
core::Content content
Definition textblock.hh:475
const char * text
Definition types.hh:236