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 struct Length
00047 {
00048 Length() { *((Q_UINT32 *)this) = 0; }
00049 Length(LengthType t) { type = t; value = 0; }
00050 Length(int v, LengthType t) : value(v), type(t) {}
00051 Length(const Length &o)
00052 { *((Q_UINT32 *)this) = *((Q_UINT32 *)&o); }
00053
00054 Length& operator=(const Length& o)
00055 { *((Q_UINT32 *)this) = *((Q_UINT32 *)&o); return *this; }
00056 bool operator==(const Length& o) const
00057 { return *((Q_UINT32 *)this) == *((Q_UINT32 *)&o); }
00058 bool operator!=(const Length& o) const
00059 { return *((Q_UINT32 *)this) != *((Q_UINT32 *)&o); }
00060
00061
00062
00063
00064
00065 int width(int maxWidth) const
00066 {
00067 switch(type)
00068 {
00069 case Fixed:
00070 return value;
00071 case Percent:
00072 return maxWidth*value/100;
00073 case Variable:
00074 return maxWidth;
00075 default:
00076 return -1;
00077 }
00078 }
00079
00080
00081
00082 int minWidth(int maxWidth) const
00083 {
00084 switch(type)
00085 {
00086 case Fixed:
00087 return value;
00088 case Percent:
00089 return maxWidth*value/100;
00090 case Variable:
00091 default:
00092 return 0;
00093 }
00094 }
00095 bool isVariable() const { return (type == Variable); }
00096 bool isRelative() const { return (type == Relative); }
00097 bool isPercent() const { return (type == Percent); }
00098 bool isFixed() const { return (type == Fixed); }
00099 bool isStatic() const { return (type == Static); }
00100
00101 int value : 29;
00102 LengthType type : 3;
00103 };
00104
00105 };
00106
00107 #ifdef __GNUC__
00108 #if __GNUC__ < 3 // stupid stl_relops.h
00109 inline bool operator!=(khtml::LengthType __x, khtml::LengthType __y) {
00110 return !(__x == __y);
00111 }
00112 #endif
00113 #endif
00114
00115 #endif
This file is part of the documentation for kdelibs Version 3.1.0.