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
28 * this namespace contains definitions for various types needed for
34 const int UNDEFINED
= -1;
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
};
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
67 return maxWidth
*l
.value
/100;
75 * returns the minimum width value which could work...
77 int minWidth(int maxWidth
) const
84 return maxWidth
*l
.value
/100;
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
; }
102 signed int value
: 28;