Dillo v3.1.1-117-gc0464026
Loading...
Searching...
No Matches
tablecell.cc
Go to the documentation of this file.
1/*
2 * Dillo Widget
3 *
4 * Copyright 2014 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 "tablecell.hh"
21#include "table.hh"
22
23using namespace lout;
24
25namespace dw {
26
35namespace tablecell {
36
41
43{
44 return false;
45}
46
48 int width, bool forceValue)
49{
50 DBG_OBJ_ENTER_O ("resize", 0, widget, "tablecell::correctAvailWidthOfChild",
51 "%p, %d, %s", child, width, forceValue ? "true" : "false");
52
53 // Make sure that this width does not exceed the width of the table
54 // cell (minus margin/border/padding).
55
56 if (width != -1) {
57 int thisWidth = widget->getAvailWidth (forceValue);
58 DBG_OBJ_MSGF_O ("resize", 1, widget, "thisWidth = %d", thisWidth);
59 if (thisWidth != -1)
60 width =
62 thisWidth
63 - widget->boxDiffWidth ()),
64 0);
65 }
66
67 DBG_OBJ_MSGF_O ("resize", 1, widget, "=> %d", width);
68 DBG_OBJ_LEAVE_O (widget);
69 return width;
70}
71
73 int height, bool forceValue)
74{
75 // Something to do?
76 return height;
77}
78
80 core::Widget *child,
81 core::Requisition *requisition,
82 void (*splitHeightFun) (int, int*,
83 int*),
84 bool allowDecreaseWidth,
85 bool allowDecreaseHeight)
86{
87 DBG_OBJ_ENTER_O ("resize", 0, widget, "tablecell::correctRequisitionOfChild",
88 "%p, %d * (%d + %d), ..., %s, %s",
89 child, requisition->width, requisition->ascent,
90 requisition->descent, misc::boolToStr (allowDecreaseWidth),
91 misc::boolToStr (allowDecreaseHeight));
92
93 // Make sure that this width does not exceed the width of the table
94 // cell (minus margin/border/padding).
95
96 int thisWidth = widget->getAvailWidth (true);
97 DBG_OBJ_MSGF_O ("resize", 1, widget, "thisWidth = %d", thisWidth);
98 int newWidth =
100 thisWidth - widget->boxDiffWidth ()),
101 0);
102 requisition->width = allowDecreaseWidth ?
103 newWidth : misc::max (requisition->width, newWidth);
104
105 DBG_OBJ_LEAVE_O (widget);
106}
107
109 core::Extremes *extremes,
110 bool useAdjustmentWidth)
111{
112 // Something to do?
113}
114
115int applyPerWidth (core::Widget *widget, int containerWidth,
116 core::style::Length perWidth)
117{
118 return core::style::multiplyWithPerLength (containerWidth, perWidth);
119}
120
121int applyPerHeight (core::Widget *widget, int containerHeight,
122 core::style::Length perHeight)
123{
124 return core::style::multiplyWithPerLength (containerHeight, perHeight);
125}
126
127} // namespace dw
128
129} // namespace dw
static bool getAdjustTableMinWidth()
Definition table.hh:500
The base class of all dillo widgets.
Definition widget.hh:44
int boxDiffWidth()
Definition widget.hh:495
int getAvailWidth(bool forceValue)
Return available width including margin/border/padding (extraSpace?), not only the content width.
Definition widget.cc:665
#define DBG_OBJ_LEAVE_O(obj)
#define DBG_OBJ_MSGF_O(aspect, prio, obj, fmt,...)
#define DBG_OBJ_ENTER_O(aspect, prio, obj, funname, fmt,...)
int multiplyWithPerLength(int x, Length l)
Multiply an int with a percentage length, returning int.
Definition style.hh:474
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 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
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.
T min(T a, T b)
Definition misc.hh:40
T max(T a, T b)
Definition misc.hh:41
const char * boolToStr(bool b)
Definition misc.hh:108