don't discard iframe children.
[kdelibs.git] / khtml / misc / khtmllayout.h
blob91d6ab63fc43d2f805f4bc36d10e2fbce93c4ec3
1 /*
2 This file is part of the KDE libraries
4 Copyright (C) 1999 Lars Knoll (knoll@kde.org)
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
11 This library 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 GNU
14 Library General Public License for more details.
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
21 This widget holds some useful definitions needed for layouting Elements
23 #ifndef HTML_LAYOUT_H
24 #define HTML_LAYOUT_H
26 #include <QVector>
28 * this namespace contains definitions for various types needed for
29 * layouting.
31 namespace khtml
34 const int UNDEFINED = -1;
36 // alignment
37 enum VAlign { VNone=0, Bottom, VCenter, Top, Baseline };
38 enum HAlign { HDefault, Left, HCenter, Right, HNone = 0 };
41 * %multiLength and %Length
43 enum LengthType { Variable = 0, Relative, Percent, Fixed, Static };
44 struct Length
46 Length() : _length(0) {}
47 Length(LengthType t) { _length = 0; l.type = t; }
48 Length(int v, LengthType t, bool q=false)
49 { _length= 0; l.value = v; l.type = t; l.quirk = q; }
50 bool operator==(const Length& o) const
51 { return _length == o._length; }
52 bool operator!=(const Length& o) const
53 { return _length != o._length; }
54 void setValue(LengthType t, int v) {
55 _length = 0; l.value = v; l.type = t; l.quirk = false;
58 * works only for Fixed and Percent, returns -1 otherwise
60 int width(int maxWidth) const
62 switch(l.type)
64 case Fixed:
65 return l.value;
66 case Percent:
67 return maxWidth*l.value/100;
68 case Variable:
69 return maxWidth;
70 default:
71 return -1;
75 * returns the minimum width value which could work...
77 int minWidth(int maxWidth) const
79 switch(l.type)
81 case Fixed:
82 return l.value;
83 case Percent:
84 return maxWidth*l.value/100;
85 case Variable:
86 default:
87 return 0;
90 bool isVariable() const { return ((LengthType) l.type == Variable); }
91 bool isRelative() const { return ((LengthType) l.type == Relative); }
92 bool isPercent() const { return ((LengthType ) l.type == Percent); }
93 bool isFixed() const { return ((LengthType) l.type == Fixed); }
94 bool isStatic() const { return ((LengthType) l.type == Static); }
95 bool isQuirk() const { return l.quirk; }
97 int value() const { return l.value; }
98 LengthType type() const { return (LengthType) l.type; }
100 union {
101 struct {
102 signed int value : 28;
103 unsigned type : 3;
104 unsigned quirk : 1;
105 } l;
106 quint32 _length;
112 #endif