khtmllayout.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef HTML_LAYOUT_H
00026 #define HTML_LAYOUT_H
00027
00028
00029
00030
00031
00032
00033 namespace khtml
00034 {
00035
00036 const int UNDEFINED = -1;
00037
00038
00039 enum VAlign { VNone=0, Bottom, VCenter, Top, Baseline };
00040 enum HAlign { HDefault, Left, HCenter, Right, HNone = 0 };
00041
00042
00043
00044
00045 enum LengthType { Variable = 0, Relative, Percent, Fixed, Static };
00046 class Length
00047 {
00048 public:
00049 Length() : _length(0) {}
00050 Length(LengthType t) { l.value = 0; l.type = t; }
00051 Length(int v, LengthType t) { l.value = v; l.type = t; }
00052
00053 bool operator==(const Length& o) const
00054 { return _length == o._length; }
00055 bool operator!=(const Length& o) const
00056 { return _length != o._length ; }
00057
00058
00059
00060
00061 int width(int maxWidth) const
00062 {
00063 switch(l.type)
00064 {
00065 case Fixed:
00066 return l.value;
00067 case Percent:
00068 return maxWidth*l.value/100;
00069 case Variable:
00070 return maxWidth;
00071 default:
00072 return -1;
00073 }
00074 }
00075
00076
00077
00078 int minWidth(int maxWidth) const
00079 {
00080 switch(l.type)
00081 {
00082 case Fixed:
00083 return l.value;
00084 case Percent:
00085 return maxWidth*l.value/100;
00086 case Variable:
00087 default:
00088 return 0;
00089 }
00090 }
00091 bool isVariable() const { return (l.type == Variable); }
00092 bool isRelative() const { return (l.type == Relative); }
00093 bool isPercent() const { return (l.type == Percent); }
00094 bool isFixed() const { return (l.type == Fixed); }
00095 bool isStatic() const { return (l.type == Static); }
00096
00097 int value() const { return l.value; }
00098 LengthType type() const { return l.type; }
00099 union {
00100 struct {
00101 signed int value : 29;
00102 LengthType type : 3;
00103 } l;
00104 Q_UINT32 _length;
00105 };
00106 };
00107
00108 }
00109
00110 #ifdef __GNUC__
00111 #if __GNUC__ - 0 < 3 // stupid stl_relops.h
00112 inline bool operator!=(khtml::LengthType __x, khtml::LengthType __y) {
00113 return !(__x == __y);
00114 }
00115 #endif
00116 #endif
00117
00118 #endif
This file is part of the documentation for kdelibs Version 3.1.4.