khtmllayout.h Source File (khtml Library)

| # khtml Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Source Files

# khtmllayout.h

    00001 /*
    00002     This file is part of the KDE libraries
    00003
    00004     Copyright (C) 1999 Lars Knoll (knoll@kde.org)
    00005
    00006     This library is free software; you can redistribute it and/or
    00007     modify it under the terms of the GNU Library General Public
    00008     License as published by the Free Software Foundation; either
    00009     version 2 of the License, or (at your option) any later version.
    00010
    00011     This library is distributed in the hope that it will be useful,
    00012     but WITHOUT ANY WARRANTY; without even the implied warranty of
    00013     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00014     Library General Public License for more details.
    00015
    00016     You should have received a copy of the GNU Library General Public License
    00017     along with this library; see the file COPYING.LIB.  If not, write to
    00018     the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    00019     Boston, MA 02111-1307, USA.
    00020
    00021     $Id: khtmllayout.h,v 1.18.2.4 2003/08/17 14:38:51 mueller Exp $
    00022
    00023     This widget holds some useful definitions needed for layouting Elements
    00024 */
    00025 #ifndef HTML_LAYOUT_H
    00026 #define HTML_LAYOUT_H
    00027
    00028
    00029 /*
    00030  * this namespace contains definitions for various types needed for
    00031  * layouting.
    00032  */
    00033 namespace khtml
    00034 {
    00035
    00036     const int UNDEFINED = -1;
    00037
    00038     // alignment
    00039     enum VAlign { VNone=0, Bottom, VCenter, Top, Baseline };
    00040     enum HAlign { HDefault, Left, HCenter, Right, HNone = 0 };
    00041
    00042     /*
    00043      * %multiLength and %Length
    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          * works only for Fixed and Percent, returns -1 otherwise
    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          * returns the minimum width value which could work...
    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.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 13:34:08 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001