diff options
Diffstat (limited to 'dw/table.hh')
-rw-r--r-- | dw/table.hh | 140 |
1 files changed, 94 insertions, 46 deletions
diff --git a/dw/table.hh b/dw/table.hh index 1d14ec07..9b868642 100644 --- a/dw/table.hh +++ b/dw/table.hh @@ -2,7 +2,7 @@ #define __DW_TABLE_HH__ #include "core.hh" -#include "tablecell.hh" +#include "alignedtablecell.hh" #include "../lout/misc.hh" namespace dw { @@ -10,6 +10,11 @@ namespace dw { /** * \brief A Widget for rendering tables. * + * <div style="border: 2px solid #ff0000; margin-top: 0.5em; + * margin-bottom: 0.5em; padding: 0.5em 1em; + * background-color: #ffefe0"><b>Warning:</b> Some parts of this + * description are outdated since \ref dw-grows.</div> + * * <h3>Introduction</h3> * * The dw::Table widget is used to render HTML tables. @@ -38,29 +43,26 @@ namespace dw { * sizeRequestImpl [color="#0000ff", URL="\ref dw::Table::sizeRequestImpl"]; * sizeAllocateImpl [color="#0000ff", * URL="\ref dw::Table::sizeAllocateImpl"]; + * getExtremes [color="#0000ff", URL="\ref dw::core::Widget::getExtremes"]; * getExtremesImpl [color="#0000ff", URL="\ref dw::Table::getExtremesImpl"]; * - * subgraph cluster_sizes { - * style="dashed"; color="#8080c0"; - * calcCellSizes [URL="\ref dw::Table::calcCellSizes"]; - * forceCalcCellSizes [URL="\ref dw::Table::forceCalcCellSizes"]; - * } - * - * subgraph cluster_extremes { - * style="dashed"; color="#8080c0"; - * calcColumnExtremes [URL="\ref dw::Table::calcColumnExtremes"]; - * forceCalcColumnExtremes[URL="\ref dw::Table::forceCalcColumnExtremes"]; - * } + * calcCellSizes [label="calcCellSizes (calcHeights = true)", + * URL="\ref dw::Table::calcCellSizes"]; + * forceCalcCellSizes [label="forceCalcCellSizes (calcHeights = true)", + * URL="\ref dw::Table::forceCalcCellSizes"]; + * actuallyCalcCellSizes[label="actuallyCalcCellSizes (calcHeights = true)", + * URL="\ref dw::Table::actuallyCalcCellSizes"]; + * forceCalcColumnExtremes[URL="\ref dw::Table::forceCalcColumnExtremes"]; * * sizeRequestImpl -> forceCalcCellSizes [label="[B]"]; * sizeAllocateImpl -> calcCellSizes [label="[A]"]; * getExtremesImpl -> forceCalcColumnExtremes [label="[B]"]; * - * forceCalcCellSizes -> calcColumnExtremes; + * forceCalcCellSizes -> actuallyCalcCellSizes; + * actuallyCalcCellSizes-> getExtremes; + * getExtremes -> getExtremesImpl [style="dashed", label="[C]"]; * * calcCellSizes -> forceCalcCellSizes [style="dashed", label="[C]"]; - * calcColumnExtremes -> forceCalcColumnExtremes [style="dashed", - * label="[C]"]; * } * \enddot * @@ -71,8 +73,14 @@ namespace dw { * is the case. * * [C] Whether this function is called, depends on NEEDS_RESIZE / - * EXTREMES_CHANGED. + * RESIZE_QUEUED / EXTREMES_CHANGED / EXTREMES_QUEUED. * + * **TODO:** + * + * - Are <tt>*[cC]alcCellSizes (calcHeights = *false*)</tt> not + * necessary anymore? + * - Calculating available sizes (Table::getAvailWidthOfChild) should + * be documented in this diagram, too. * * <h4>Apportionment</h4> * @@ -191,8 +199,9 @@ namespace dw { * * <ul> * <li> the specified absolute width of the table, when given, or - * <li> the available width (set by dw::Table::setWidth) times the specified - * percentage width of t(at max 100%), if the latter is given, or + * <li> the available width (set by dw::Table::setWidth [TODO outdated]) times + * the specified percentage width of t(at max 100%), if the latter is + * given, or * <li> otherwise the available width. * </ul> * @@ -316,7 +325,6 @@ namespace dw { class Table: public core::Widget { private: - struct Child { enum { @@ -355,8 +363,9 @@ private: friend class TableIterator; + static bool adjustTableMinWidth; + bool limitTextWidth, rowClosed; - int availWidth, availAscent, availDescent; // set by set... int numRows, numCols, curRow, curCol; lout::misc::SimpleVector<Child*> *children; @@ -369,6 +378,28 @@ private: lout::misc::SimpleVector<core::Extremes> *colExtremes; /** + * \brief Wether the column itself (in the future?) or at least one + * cell in this column or spanning over this column has CSS + * 'width' specified. + * + * Filled by forceCalcColumnExtremes(), since it is needed to + * calculate the column widths. + */ + lout::misc::SimpleVector<bool> *colWidthSpecified; + int numColWidthSpecified; + + /** + * \brief Wether the column itself (in the future?) or at least one + * cell in this column or spanning over this column has CSS + * 'width' specified *as percentage value*. + * + * Filled by forceCalcColumnExtremes(), since it is needed to + * calculate the column widths. + */ + lout::misc::SimpleVector<bool> *colWidthPercentage; + int numColWidthPercentage; + + /** * \brief The widths of all columns. */ lout::misc::SimpleVector<int> *colWidths; @@ -383,19 +414,19 @@ private: * If a Cell has rowspan > 1, it goes into this array */ lout::misc::SimpleVector<int> *rowSpanCells; - /** - * If a Cell has colspan > 1, it goes into this array - */ - lout::misc::SimpleVector<int> *colSpanCells; lout::misc::SimpleVector<int> *baseline; lout::misc::SimpleVector<core::style::Style*> *rowStyle; - /** - * hasColPercent becomes true when any cell specifies a percentage width. - */ - int hasColPercent; - lout::misc::SimpleVector<core::style::Length> *colPercents; + bool colWidthsUpToDateWidthColExtremes; + + enum ExtrMod { MIN, MIN_INTR, MIN_MIN, MAX_MIN, MAX, MAX_INTR, DATA }; + + const char *getExtrModName (ExtrMod mod); + int getExtreme (core::Extremes *extremes, ExtrMod mod); + void setExtreme (core::Extremes *extremes, ExtrMod mod, int value); + int getColExtreme (int col, ExtrMod mod, void *data); + inline void setColExtreme (int col, ExtrMod mod, void *data, int value); inline bool childDefined(int n) { @@ -403,17 +434,26 @@ private: children->get(n)->type != Child::SPAN_SPACE; } + int calcAvailWidthForDescendant (Widget *child); + void reallocChildren (int newNumCols, int newNumRows); - void calcCellSizes (); - void forceCalcCellSizes (); + void calcCellSizes (bool calcHeights); + void forceCalcCellSizes (bool calcHeights); + void actuallyCalcCellSizes (bool calcHeights); void apportionRowSpan (); - void calcColumnExtremes (); void forceCalcColumnExtremes (); + void calcExtremesSpanMultiCols (int col, int cs, + core::Extremes *cellExtremes, + ExtrMod minExtrMod, ExtrMod maxExtrMod, + void *extrData); + void calcAdjustmentWidthSpanMultiCols (int col, int cs, + core::Extremes *cellExtremes); - void apportion2 (int totalWidth, int forceTotalWidth); - void apportion_percentages2 (int totalWidth, int forceTotalWidth); + void apportion2 (int totalWidth, int firstCol, int lastCol, + ExtrMod minExtrMod, ExtrMod maxExtrMod, void *extrData, + lout::misc::SimpleVector<int> *dest, int destOffset); void setCumHeight (int row, int value) { @@ -423,23 +463,22 @@ private: } } - inline void setColWidth (int col, int value) - { - if (value != colWidths->get (col)) { - redrawX = lout::misc::min (redrawX, value); - colWidths->set (col, value); - } - } - protected: void sizeRequestImpl (core::Requisition *requisition); void getExtremesImpl (core::Extremes *extremes); void sizeAllocateImpl (core::Allocation *allocation); void resizeDrawImpl (); - void setWidth (int width); - void setAscent (int ascent); - void setDescent (int descent); + bool getAdjustMinWidth () { return Table::adjustTableMinWidth; } + + int getAvailWidthOfChild (Widget *child, bool forceValue); + + void containerSizeChangedForChildren (); + bool affectsSizeChangeContainerChild (Widget *child); + bool usesAvailWidth (); + + bool isBlockLevel (); + void draw (core::View *view, core::Rectangle *area); //bool buttonPressImpl (core::EventButton *event); @@ -451,14 +490,23 @@ protected: public: static int CLASS_ID; + inline static void setAdjustTableMinWidth (bool adjustTableMinWidth) + { Table::adjustTableMinWidth = adjustTableMinWidth; } + + inline static bool getAdjustTableMinWidth () + { return Table::adjustTableMinWidth; } + Table(bool limitTextWidth); ~Table(); + int applyPerWidth (int containerWidth, core::style::Length perWidth); + int applyPerHeight (int containerHeight, core::style::Length perHeight); + core::Iterator *iterator (core::Content::Type mask, bool atEnd); void addCell (Widget *widget, int colspan, int rowspan); void addRow (core::style::Style *style); - TableCell *getCellRef (); + AlignedTableCell *getCellRef (); }; } // namespace dw |