File indexing completed on 2024-04-28 15:24:22

0001 /*
0002  * This file is part of the HTML rendering engine for KDE.
0003  *
0004  * Copyright (C) 2002 Lars Knoll (knoll@kde.org)
0005  *           (C) 2002 Dirk Mueller (mueller@kde.org)
0006  *
0007  * This library is free software; you can redistribute it and/or
0008  * modify it under the terms of the GNU Library General Public
0009  * License as published by the Free Software Foundation; either
0010  * version 2 of the License.
0011  *
0012  * This library is distributed in the hope that it will be useful,
0013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0015  * Library General Public License for more details.
0016  *
0017  * You should have received a copy of the GNU Library General Public License
0018  * along with this library; see the file COPYING.LIB.  If not, write to
0019  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0020  * Boston, MA 02110-1301, USA.
0021  *
0022  */
0023 #ifndef TABLE_LAYOUT_H
0024 #define TABLE_LAYOUT_H
0025 
0026 #include <misc/khtmllayout.h>
0027 #include <QVector>
0028 namespace khtml
0029 {
0030 
0031 class RenderTable;
0032 class RenderTableCell;
0033 
0034 // -------------------------------------------------------------------------
0035 
0036 class TableLayout
0037 {
0038 public:
0039     TableLayout(RenderTable *t) : table(t) {}
0040     virtual ~TableLayout() {}
0041 
0042     virtual void calcMinMaxWidth() = 0;
0043     virtual void layout() = 0;
0044 
0045 protected:
0046     RenderTable *table;
0047 };
0048 
0049 // -------------------------------------------------------------------------
0050 
0051 class FixedTableLayout : public TableLayout
0052 {
0053 public:
0054     FixedTableLayout(RenderTable *table);
0055     ~FixedTableLayout();
0056 
0057     void calcMinMaxWidth() override;
0058     void layout() override;
0059 
0060 protected:
0061     int calcWidthArray();
0062 
0063     QVector<Length> width;
0064 };
0065 
0066 // -------------------------------------------------------------------------
0067 
0068 class AutoTableLayout : public TableLayout
0069 {
0070 public:
0071     AutoTableLayout(RenderTable *table);
0072     ~AutoTableLayout();
0073 
0074     void calcMinMaxWidth() override;
0075     void layout() override;
0076 
0077 protected:
0078     void fullRecalc();
0079     void recalcColumn(int effCol);
0080     int calcEffectiveWidth();
0081     void insertSpanCell(RenderTableCell *cell);
0082 
0083     struct Layout {
0084         Layout() : minWidth(1), maxWidth(1),
0085             effMinWidth(0), effMaxWidth(0),
0086             calcWidth(0), emptyCellsOnly(true) {}
0087         Length width;
0088         Length effWidth;
0089         short minWidth;
0090         int maxWidth;
0091         short effMinWidth;
0092         int effMaxWidth;
0093         int calcWidth;
0094         bool emptyCellsOnly;
0095     };
0096 
0097     QVector<Layout> layoutStruct;
0098     QVector<RenderTableCell *>spanCells;
0099     bool hasPercent : 1;
0100     mutable bool effWidthDirty : 1;
0101 };
0102 
0103 }
0104 #endif