Dillo
Classes | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
dw::Table Class Reference

A Widget for rendering tables. More...

#include <table.hh>

Classes

struct  Child
 
class  TableIterator
 

Public Member Functions

 Table (bool limitTextWidth)
 
 ~Table ()
 
int applyPerWidth (int containerWidth, core::style::Length perWidth)
 
int applyPerHeight (int containerHeight, core::style::Length perHeight)
 
core::Iteratoriterator (core::Content::Type mask, bool atEnd)
 Return an iterator for this widget. More...
 
void addCell (Widget *widget, int colspan, int rowspan)
 
void addRow (core::style::Style *style)
 
AlignedTableCellgetCellRef ()
 
- Public Member Functions inherited from dw::oof::OOFAwareWidget
 OOFAwareWidget ()
 
 ~OOFAwareWidget ()
 
core::RequisitiongetRequisitionWithoutOOF ()
 
bool doesWidgetOOFInterruptDrawing (Widget *widget)
 
void draw (core::View *view, core::Rectangle *area, core::DrawingContext *context)
 
virtual void updateReference (int ref)
 
virtual void widgetRefSizeChanged (int externalIndex)
 
virtual void clearPositionChanged ()
 
virtual void oofSizeChanged (bool extremesChanged)
 
virtual int getGeneratorX (int oofmIndex)
 
virtual int getGeneratorY (int oofmIndex)
 
virtual int getGeneratorWidth (int callerX, int callerWidth)
 
virtual int getMaxGeneratorWidth ()
 
virtual bool usesMaxGeneratorWidth ()
 
virtual bool isPossibleOOFContainer (int oofmIndex)
 
virtual bool isPossibleOOFContainerParent (int oofmIndex)
 
- Public Member Functions inherited from dw::core::Widget
void setDeleteCallback (DW_Callback_t func, void *data)
 
 Widget ()
 
 ~Widget ()
 
bool resizeQueued ()
 
bool extremesQueued ()
 
bool needsResize ()
 
bool needsAllocate ()
 
bool allocateQueued ()
 
bool extremesChanged ()
 
bool wasAllocated ()
 
void setParent (Widget *parent)
 
void setQuasiParent (Widget *quasiParent)
 
void setGenerator (Widget *generator)
 
style::StylegetStyle ()
 
AllocationgetAllocation ()
 
bool inAllocation (int x, int y)
 
int boxOffsetX ()
 
int boxRestWidth ()
 
int boxDiffWidth ()
 
int boxOffsetY ()
 
int boxRestHeight ()
 
int boxDiffHeight ()
 
virtual int numSizeRequestReferences ()
 See Sizes of Dillo Widgets (or Size requisitions depending on positions). More...
 
virtual WidgetsizeRequestReference (int index)
 See Sizes of Dillo Widgets (or Size requisitions depending on positions). More...
 
virtual int numGetExtremesReferences ()
 See Sizes of Dillo Widgets (or Size requisitions depending on positions). More...
 
virtual WidgetgetExtremesReference (int index)
 See Sizes of Dillo Widgets (or Size requisitions depending on positions). More...
 
void sizeRequest (Requisition *requisition, int numPos=0, Widget **references=NULL, int *x=NULL, int *y=NULL)
 This method is a wrapper for Widget::sizeRequestImpl(); it calls the latter only when needed. More...
 
void getExtremes (Extremes *extremes, int numPos=0, Widget **references=NULL, int *x=NULL, int *y=NULL)
 Wrapper for Widget::getExtremesImpl(). More...
 
void sizeAllocate (Allocation *allocation)
 Wrapper for Widget::sizeAllocateImpl, calls the latter only when needed. More...
 
void calcExtraSpace (int numPos, Widget **references, int *x, int *y)
 Calculates dw::core::Widget::extraSpace. More...
 
int getAvailWidth (bool forceValue)
 
int getAvailHeight (bool forceValue)
 
void correctRequisition (Requisition *requisition, void(*splitHeightFun)(int, int *, int *), bool allowDecreaseWidth, bool allowDecreaseHeight)
 
void correctExtremes (Extremes *extremes, bool useAdjustmentWidth)
 
int calcWidth (style::Length cssValue, int refWidth, Widget *refWidget, int limitMinWidth, bool forceValue)
 
void calcFinalWidth (style::Style *style, int refWidth, Widget *refWidget, int limitMinWidth, bool forceValue, int *finalWidth)
 
int calcHeight (style::Length cssValue, bool usePercentage, int refHeight, Widget *refWidget, bool forceValue)
 
int getMinWidth (Extremes *extremes, bool forceValue)
 Used to evaluate Widget::adjustMinWidth. More...
 
virtual bool isPossibleContainer ()
 
void containerSizeChanged ()
 
bool intersects (Widget *refWidget, Rectangle *area, Rectangle *intersection)
 Calculates the intersection of the visible allocation (i. e. the intersection with the visible parent allocation) and "area" (in widget coordinates referring to "refWidget"), returned in intersection (in widget coordinates). More...
 
void drawInterruption (View *view, Rectangle *area, DrawingContext *context)
 
WidgetgetWidgetAtPointInterrupted (int x, int y, GettingWidgetAtPointContext *context)
 
bool buttonPress (EventButton *event)
 
bool buttonRelease (EventButton *event)
 
bool motionNotify (EventMotion *event)
 
void enterNotify (EventCrossing *event)
 
void leaveNotify (EventCrossing *event)
 
virtual void setStyle (style::Style *style)
 Change the style of a widget. More...
 
void setBgColor (style::Color *bgColor)
 Set the background "behind" the widget, if it is not the background of the parent widget, e.g. the background of a table row. More...
 
style::ColorgetBgColor ()
 Get the actual background of a widget. More...
 
void drawBox (View *view, style::Style *style, Rectangle *area, int x, int y, int width, int height, bool inverse)
 Draw borders and background of a widget part, which allocation is given by (x, y, width, height) (widget coordinates). More...
 
void drawWidgetBox (View *view, Rectangle *area, bool inverse)
 Draw borders and background of a widget. More...
 
void drawSelected (View *view, Rectangle *area)
 
void setButtonSensitive (bool buttonSensitive)
 
bool isButtonSensitive ()
 
WidgetgetParent ()
 
WidgetgetContainer ()
 
WidgetgetTopLevel ()
 Get the widget at the root of the tree, this widget is part from. More...
 
int getLevel ()
 Get the level of the widget within the tree. More...
 
int getGeneratorLevel ()
 Get the level of the widget within the tree, regarting the generators, not the parents. More...
 
WidgetgetNearestCommonAncestor (Widget *otherWidget)
 Get the widget with the highest level, which is a direct ancestor of widget1 and widget2. More...
 
WidgetReferencegetWidgetReference ()
 
void setWidgetReference (WidgetReference *widgetReference)
 
WidgetgetGenerator ()
 
LayoutgetLayout ()
 
void scrollTo (HPosition hpos, VPosition vpos, int x, int y, int width, int height)
 
void getMarginArea (int *xMar, int *yMar, int *widthMar, int *heightMar)
 
void getBorderArea (int *xBor, int *yBor, int *widthBor, int *heightBor)
 
void getPaddingArea (int *xPad, int *yPad, int *widthPad, int *heightPad)
 Return the padding area (content plus padding). More...
 
virtual void removeChild (Widget *child)
 
- Public Member Functions inherited from lout::identity::IdentifiableObject
 IdentifiableObject ()
 
void intoStringBuffer (misc::StringBuffer *sb)
 Store a textual representation of the object in a misc::StringBuffer. More...
 
int getClassId ()
 Returns the class identifier. More...
 
const char * getClassName ()
 Return the name, under which the class of this object was registered. More...
 
bool instanceOf (int otherClassId)
 Returns, whether this class is an instance of the class, given by otherClassId, or of a sub class of this class. More...
 
- Public Member Functions inherited from lout::object::Object
virtual ~Object ()
 The destructor is defined as virtual (but not abstract), so that destruction of Object's works properly. More...
 
virtual bool equals (Object *other)
 Returns, whether two objects are equal. More...
 
virtual int hashValue ()
 Return a hash value for the object. More...
 
virtual Objectclone ()
 Return an exact copy of the object. More...
 
const char * toString ()
 Use object::Object::intoStringBuffer to return a textual representation of the object. More...
 
virtual size_t sizeOf ()
 Return the number of bytes, this object totally uses. More...
 

Static Public Member Functions

static void setAdjustTableMinWidth (bool adjustTableMinWidth)
 
static bool getAdjustTableMinWidth ()
 
- Static Public Member Functions inherited from dw::oof::OOFAwareWidget
static const char * stackingLevelText (int level)
 
static bool testStyleFloat (core::style::Style *style)
 
static bool testStyleAbsolutelyPositioned (core::style::Style *style)
 
static bool testStyleFixedlyPositioned (core::style::Style *style)
 
static bool testStyleRelativelyPositioned (core::style::Style *style)
 
static bool testStylePositioned (core::style::Style *style)
 
static bool testStyleOutOfFlow (core::style::Style *style)
 
static bool testWidgetFloat (Widget *widget)
 
static bool testWidgetAbsolutelyPositioned (Widget *widget)
 
static bool testWidgetFixedlyPositioned (Widget *widget)
 
static bool testWidgetRelativelyPositioned (Widget *widget)
 
static bool testWidgetPositioned (Widget *widget)
 
static bool testWidgetOutOfFlow (Widget *widget)
 
- Static Public Member Functions inherited from dw::core::Widget
static void setAdjustMinWidth (bool adjustMinWidth)
 
static void adjustHeight (int *height, bool allowDecreaseHeight, int ascent, int descent)
 

Static Public Attributes

static int CLASS_ID = -1
 
- Static Public Attributes inherited from dw::oof::OOFAwareWidget
static int CLASS_ID = -1
 
- Static Public Attributes inherited from dw::core::Widget
static int CLASS_ID = -1
 

Protected Member Functions

void sizeRequestSimpl (core::Requisition *requisition)
 Simple variant, to be implemented by widgets with sizes not depending on positions. More...
 
void getExtremesSimpl (core::Extremes *extremes)
 Simple variant, to be implemented by widgets with extremes not depending on positions. More...
 
void sizeAllocateImpl (core::Allocation *allocation)
 See Sizes of Dillo Widgets. More...
 
void resizeDrawImpl ()
 Called after sizeAllocateImpl() to redraw necessary areas. By default the whole widget is redrawn. More...
 
bool getAdjustMinWidth ()
 
int getAvailWidthOfChild (Widget *child, bool forceValue)
 
void containerSizeChangedForChildren ()
 
bool affectsSizeChangeContainerChild (Widget *child)
 
bool usesAvailWidth ()
 Must be implemengted by a method returning true, when getAvailWidth() is called. More...
 
bool isBlockLevel ()
 
void drawLevel (core::View *view, core::Rectangle *area, int level, core::DrawingContext *context)
 
WidgetgetWidgetAtPointLevel (int x, int y, int level, core::GettingWidgetAtPointContext *context)
 
void removeChild (Widget *child)
 
- Protected Member Functions inherited from dw::oof::OOFAwareWidget
bool isParentRefOOF (int parentRef)
 
int makeParentRefInFlow (int inFlowSubRef)
 
int getParentRefInFlowSubRef (int parentRef)
 
int makeParentRefOOF (int oofmIndex, int oofmSubRef)
 
int getParentRefOOFSubRef (int parentRef)
 
int getParentRefOOFIndex (int parentRef)
 
oof::OutOfFlowMgrgetParentRefOutOfFlowMgr (int parentRef)
 
bool isWidgetOOF (Widget *widget)
 
int getWidgetInFlowSubRef (Widget *widget)
 
int getWidgetOOFSubRef (Widget *widget)
 
int getWidgetOOFIndex (Widget *widget)
 
oof::OutOfFlowMgrgetWidgetOutOfFlowMgr (Widget *widget)
 
OutOfFlowMgrsearchOutOfFlowMgr (int oofmIndex)
 
void initOutOfFlowMgrs ()
 
void correctRequisitionByOOF (core::Requisition *requisition, void(*splitHeightFun)(int, int *, int *))
 
void correctExtremesByOOF (core::Extremes *extremes)
 
void sizeAllocateStart (core::Allocation *allocation)
 
void sizeAllocateEnd ()
 
void containerSizeChangedForChildrenOOF ()
 
void drawOOF (core::View *view, core::Rectangle *area, core::DrawingContext *context)
 
WidgetgetWidgetAtPoint (int x, int y, core::GettingWidgetAtPointContext *context)
 
WidgetgetWidgetOOFAtPoint (int x, int y, core::GettingWidgetAtPointContext *context)
 
void notifySetAsTopLevel ()
 This method is called after a widget has been set as the top of a widget tree. More...
 
void notifySetParent ()
 This method is called after a widget has been added to a parent. More...
 
void removeChild (Widget *child)
 
virtual bool adjustExtraSpaceWhenCorrectingRequisitionByOOF ()
 
- Protected Member Functions inherited from dw::core::Widget
int getHeight ()
 
int getContentWidth ()
 
int getContentHeight ()
 
StackingContextMgrgetNextStackingContextMgr ()
 
void printFlag (Flags f)
 
void setFlags (Flags f)
 
void unsetFlags (Flags f)
 
void queueDraw ()
 
void queueDrawArea (int x, int y, int width, int height)
 
void queueResize (int ref, bool extremesChanged)
 
virtual void sizeRequestImpl (Requisition *requisition, int numPos, Widget **references, int *x, int *y)
 See Sizes of Dillo Widgets. More...
 
virtual void getExtremesImpl (Extremes *extremes, int numPos, Widget **references, int *x, int *y)
 See Sizes of Dillo Widgets. More...
 
virtual void calcExtraSpaceImpl (int numPos, Widget **references, int *x, int *y)
 The actual implementation for calculating dw::core::Widget::extraSpace. More...
 
virtual void markSizeChange (int ref)
 See Sizes of Dillo Widgets. More...
 
virtual void markExtremesChange (int ref)
 See Sizes of Dillo Widgets. More...
 
virtual int getAvailWidthOfChild (Widget *child, bool forceValue)
 
virtual int getAvailHeightOfChild (Widget *child, bool forceValue)
 
virtual void correctRequisitionOfChild (Widget *child, Requisition *requisition, void(*splitHeightFun)(int, int *, int *), bool allowDecreaseWidth, bool allowDecreaseHeight)
 
void correctReqWidthOfChild (Widget *child, Requisition *requisition, bool allowDecreaseWidth)
 
void correctReqHeightOfChild (Widget *child, Requisition *requisition, void(*splitHeightFun)(int, int *, int *), bool allowDecreaseHeight)
 
virtual void correctExtremesOfChild (Widget *child, Extremes *extremes, bool useAdjustmentWidth)
 
virtual bool affectedByContainerSizeChange ()
 
virtual bool affectsSizeChangeContainerChild (Widget *child)
 
virtual bool usesAvailHeight ()
 Must be implemengted by a method returning true, when getAvailHeight() is called. More...
 
virtual bool buttonPressImpl (EventButton *event)
 
virtual bool buttonReleaseImpl (EventButton *event)
 
virtual bool motionNotifyImpl (EventMotion *event)
 
virtual void enterNotifyImpl (EventCrossing *event)
 
virtual void leaveNotifyImpl (EventCrossing *event)
 
char * addAnchor (const char *name)
 
char * addAnchor (const char *name, int y)
 
void changeAnchor (char *name, int y)
 
void removeAnchor (char *name)
 
void setCursor (style::Cursor cursor)
 
bool selectionHandleEvent (SelectionState::EventType eventType, Iterator *it, int charPos, int linkNo, MousePositionEvent *event)
 
- Protected Member Functions inherited from lout::identity::IdentifiableObject
void registerName (const char *className, int *classId)
 This method must be called in the constructor for the sub class. See class comment for details. More...
 

Private Types

enum  ExtrMod {
  MIN, MIN_INTR, MIN_MIN, MAX_MIN,
  MAX, MAX_INTR, DATA
}
 

Private Member Functions

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)
 
void setColExtreme (int col, ExtrMod mod, void *data, int value)
 
bool childDefined (int n)
 
int calcAvailWidthForDescendant (Widget *child)
 
void reallocChildren (int newNumCols, int newNumRows)
 
void calcCellSizes (bool calcHeights)
 
void forceCalcCellSizes (bool calcHeights)
 
void actuallyCalcCellSizes (bool calcHeights)
 
void apportionRowSpan ()
 
void forceCalcColumnExtremes ()
 Fills dw::Table::colExtremes in all cases. More...
 
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 firstCol, int lastCol, ExtrMod minExtrMod, ExtrMod maxExtrMod, void *extrData, lout::misc::SimpleVector< int > *dest, int destOffset)
 Actual apportionment function. More...
 
void setCumHeight (int row, int value)
 

Private Attributes

bool limitTextWidth
 
bool rowClosed
 
int numRows
 
int numCols
 
int curRow
 
int curCol
 
lout::misc::SimpleVector
< Child * > * 
children
 
int redrawX
 
int redrawY
 
lout::misc::SimpleVector
< core::Extremes > * 
colExtremes
 The extremes of all columns. More...
 
lout::misc::SimpleVector< bool > * colWidthSpecified
 Wether the column itself (in the future?) or at least one cell in this column or spanning over this column has CSS 'width' specified. More...
 
int numColWidthSpecified
 
lout::misc::SimpleVector< bool > * colWidthPercentage
 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. More...
 
int numColWidthPercentage
 
lout::misc::SimpleVector< int > * colWidths
 The widths of all columns. More...
 
lout::misc::SimpleVector< int > * cumHeight
 
lout::misc::SimpleVector< int > * rowSpanCells
 
lout::misc::SimpleVector< int > * baseline
 
lout::misc::SimpleVector
< core::style::Style * > * 
rowStyle
 
bool colWidthsUpToDateWidthColExtremes
 

Static Private Attributes

static bool adjustTableMinWidth = true
 

Friends

class TableIterator
 

Additional Inherited Members

- Public Types inherited from dw::oof::OOFAwareWidget
enum  {
  SL_START, SL_BACKGROUND, SL_SC_BOTTOM, SL_IN_FLOW,
  SL_OOF_REF, SL_OOF_CONT, SL_SC_TOP, SL_END
}
 
- Public Attributes inherited from dw::core::Widget
int parentRef
 This value is defined by the parent widget, and used for incremential resizing. More...
 
- Protected Types inherited from dw::oof::OOFAwareWidget
enum  {
  OOFM_FLOATS, OOFM_ABSOLUTE, OOFM_RELATIVE, OOFM_FIXED,
  NUM_OOFM
}
 
enum  { PARENT_REF_OOFM_BITS = 3, PARENT_REF_OOFM_MASK = (1 << PARENT_REF_OOFM_BITS) - 1 }
 
- Protected Types inherited from dw::core::Widget
enum  Flags {
  RESIZE_QUEUED = 1 << 0, EXTREMES_QUEUED = 1 << 1, NEEDS_RESIZE = 1 << 2, NEEDS_ALLOCATE = 1 << 3,
  ALLOCATE_QUEUED = 1 << 4, EXTREMES_CHANGED = 1 << 5, WAS_ALLOCATED = 1 << 6
}
 
- Static Protected Member Functions inherited from dw::oof::OOFAwareWidget
static int getOOFMIndex (Widget *widget)
 
static bool isOOFContainer (Widget *widget, int oofmIndex)
 
- Protected Attributes inherited from dw::oof::OOFAwareWidget
OOFAwareWidgetoofContainer [NUM_OOFM]
 
OutOfFlowMgroutOfFlowMgr [NUM_OOFM]
 
core::Requisition requisitionWithoutOOF
 
- Protected Attributes inherited from dw::core::Widget
WidgetImgRendererwidgetImgRenderer
 
Allocation allocation
 The current allocation: size and position, always relative to the canvas. More...
 
Layoutlayout
 
style::Box extraSpace
 Space around the margin box. Allocation is extraSpace + margin + border + padding + contents. More...
 
StackingContextMgrstackingContextMgr
 Set iff this widget constitutes a stacking context, as defined by CSS. More...
 
WidgetstackingContextWidget
 The bottom-most ancestor (or this) for which stackingContextMgr is set. More...
 
- Static Protected Attributes inherited from dw::oof::OOFAwareWidget
static const char * OOFM_NAME [NUM_OOFM]
 

Detailed Description

A Widget for rendering tables.

Warning: Some parts of this description are outdated since GROWS - Grand Redesign Of Widget Sizes.

Introduction

The dw::Table widget is used to render HTML tables.

Each cell is itself a separate widget. Any widget may be used, however, in dillo, only instances of dw::Textblock and dw::TableCell are used as children of dw::Table.

Sizes

General

The following diagram shows the dependencies between the different functions, which are related to size calculation. Click on the boxes for more information.

dot_inline_dotgraph_14.png

[A] In this case, the new calculation is not forced, but only done, when necessary.

[B] In this case, the new calculation is allways necessary, since [C] is the case.

[C] Whether this function is called, depends on NEEDS_RESIZE / RESIZE_QUEUED / EXTREMES_CHANGED / EXTREMES_QUEUED.

TODO:

Apportionment

See also
How to Avoid Rounding Errors

Given two array $e_{i,\min}$ and $e_{i,\max}$, which represent the column minima and maxima, and a total width $W$, apportionment means to calculate column widths $w_{i}$, with

\[e_{i,\min} \le w_{i} \le e_{i,\max}\]

and

\[\sum w_{i} = W\]

There are different algorithms for apportionment, a simple one is recommended in the HTML 4.0.1 specification (http://www.w3.org/TR/REC-html40/appendix/notes.html#h-B.5.2.2):

\[w_{i} = e_{i,\min} + {e_{i,\max} - e_{i,\min}\over\sum e_{i,\max} - \sum e_{i,\min}} (W - \sum e_{i,\min})\]

This one is used currently, but another one will be used soon, which is described below. The rest of this chapter is independent of the exact apportionment algorithm.

When referring to the apportionment function, we will call it $a_i (W, (e_{i,\min}), (e_{i,\min}))$ and write something like this:

\[w_{i} = a_i (W, (e_{i,\min}), (e_{i,\max})) \]

It is implemented by dw::Table::apportion.

Column Extremes

See also
How to Avoid Rounding Errors

The sizes, which all other sizes depend on, are column extremes, which define, how wide a column may be at min and at max. They are calculated in the following way:

  1. First, only cells with colspan = 1 are regarded:

    \[ e_{\hbox{base},i,\min} = \max \{ e_{\hbox{cell},i,j,\min} \} \]

    \[ e_{\hbox{base},i,\max} = \max \{ e_{\hbox{cell},i,j,\max} \} \]

    only for cells $(i, j)$ with colspan = 1.

  2. Then, $e_{\hbox{span},i,\min}$ (but not $e_{\hbox{span},i,\max}$) are calculated from cells with colspan > 1. (In the following formulas, the cell at $(i_1, j)$ always span from $i_1$ to $i_2$.) If the minimal width of the column exceeds the sum of the column minima calculated in the last step:

    \[e_{\hbox{cell},i_1,j,\min} > \sum_{i=i_1}^{i=i_2} e_{\hbox{base},i,\min}\]

    then the minimal width of this cell is apportioned to the columns:

    • If the minimal width of this cell also exceeds the sum of the column maxima:

      \[e_{\hbox{cell},i_1,j,\min} > \sum_{i=i_1}^{i=i_2} e_{\hbox{base},i,\max}\]

      then $e_{\hbox{cell},i_1,j,\min}$ is apportioned in a simple way:

      \[e_{\hbox{span},i,j,\min} = e_{\hbox{base},i,\max} {e_{\hbox{span},i,j,\min} \over \sum_{i=i_1}^{i=i_2} e_{\hbox{base},i,\max}}\]

    • Otherwise, the apportionment function is used:

      \[e_{\hbox{span},i,j,\min} = a_i (e_{\hbox{cell},i_1,j,\min}, (e_{\hbox{cell},i_1,j,\min} \ldots e_{\hbox{cell},i_2,j,\min}), (e_{\hbox{cell},i_1,j,\max} \ldots e_{\hbox{cell},i_2,j,\max}))\]

    After this, $e_{\hbox{span},i,\min}$ is then the maximum of all $e_{\hbox{span},i,j,\min}$.

  3. Finally, the maximum of both is used.

    \[ e_{i,\min} = \max \{ e_{\hbox{base},i,\min}, e_{\hbox{span},i,\min} \} \]

    \[ e_{i,\max} = \max \{ e_{\hbox{base},i,\max}, e_{i,\min} \} \]

    For the maxima, there is no $e_{\hbox{span},i,\max}$, but it has to be assured, that the maximum is always greater than or equal to the minimum.

Generally, if absolute widths are specified, they are, instead of the results of dw::core::Widget::getExtremes, taken for the minimal and maximal width of a cell (minus the box difference, i.e. the difference between content size and widget size). If the content width specification is smaller than the minimal content width of the widget (determined by dw::core::Widget::getExtremes), the latter is used instead.

If percentage widths are specified, they are also collected, as column maxima. A similar method as for the extremes is used, for cells with colspan > 1:

\[w_{\hbox{span},i,j,\%} = a_i (w_{\hbox{cell},i_1,j,\%}, (e_{\hbox{cell},i_1,j,\min} \ldots e_{\hbox{cell},i_2,j,\min}), (e_{\hbox{cell},i_1,j,\max} \ldots e_{\hbox{cell},i_2,j,\max}))\]

Cell Sizes

Determining the Width of the Table

The total width is

In any case, it is corrected, if it is less than the minimal width (but not if it is greater than the maximal width).

Bug:
The parentheses is not fully clear, look at the old code.

Details on differences because of styles are omitted. Below, this total width is called $W$.

Evaluating percentages

The following algorithms are used to solve collisions between different size specifications (absolute and percentage). Generally, inherent sizes and specified absolute sizes are preferred.

  1. First, calculate the sum of the minimal widths, for columns, where no percentage width has been specified. The difference to the total width is at max available to the columns with percentage width specifications:

    \[W_{\hbox{columns}_\%,\hbox{available}} = W - \sum e_{i,\min}\]

    with only those columns $i$ with no percentage width specification.

  2. Then, calculate the sum of the widths, which the columns with percentage width specification would allocate, when fully adhering to them:

    \[W_{\hbox{columns}_\%,\hbox{best}} = W \sum w_{i,\%}\]

    with only those columns $i$ with a percentage width specification.

  3. Two cases are distinguished:

    • $W_{\hbox{columns}_\%,\hbox{available}} \ge W_{\hbox{columns}_\%,\hbox{best}}$: In this case, the percentage widths can be used without any modification, by setting the extremes:

      \[e_{i,\min} = e_{i,\max} = W w_{i,\%}\]

      for only those columns $i$ with a percentage width specification.

    • $W_{\hbox{columns}_\%,\hbox{available}} < W_{\hbox{columns}_\%,\hbox{best}}$: In this case, the widths for these columns must be cut down:

      \[e_{i,\min} = e_{i,\max} = w_{i,\%} {W_{\hbox{columns}_\%,\hbox{available}} \over w_{\hbox{total},\%}}\]

      with

      \[w_{\hbox{total},\%} = \sum w_{i,\%}\]

      in both cases for only those columns $i$ with a percentage width specification.

( $e_{i,\min}$ and $e_{i,\max}$ are set temporarily here, the notation should be a bit clearer.)

Column Widths

The column widths are now simply calculated by applying the apportionment function.

Row Heights

...

Alternative Apportionment Algorithm

The algorithm described here tends to result in more homogeneous column widths.

The following rule leads to well-defined $w_{i}$: All columns $i$ have have the same width $w$, except:

Furthermore, $w$ is

Of course, $\sum w_{i} = W$ must be the case.

Based on an initial value $w = {W\over n}$, $w$ can iteratively adjusted, based on these rules.

Borders, Paddings, Spacing

Currently, DwTable supports only the separated borders model (see CSS specification). Borders, paddings, spacing is done by creating dw::core::style::Style structures with values equivalent to following CSS:

TABLE {
  border:           outset table-border;
  border-collapse:  separate;
  border-spacing:   table-cellspacing;
  background-color: table-bgcolor;
}
TD TH {
  border:           inset table-border;
  padding:          table-cellspacing;
  background-color: td/th-bgcolor;
}

Here, foo-bar refers to the attribute bar of the tag foo foo. Look at the HTML parser for more details.

Member Enumeration Documentation

enum dw::Table::ExtrMod
private
Enumerator
MIN 
MIN_INTR 
MIN_MIN 
MAX_MIN 
MAX 
MAX_INTR 
DATA 

Constructor & Destructor Documentation

dw::Table::Table ( bool  limitTextWidth)
dw::Table::~Table ( )

References DBG_OBJ_DELETE.

Member Function Documentation

void dw::Table::actuallyCalcCellSizes ( bool  calcHeights)
private
void dw::Table::addCell ( Widget widget,
int  colspan,
int  rowspan 
)
void dw::Table::addRow ( core::style::Style style)

References dw::core::style::Style::ref().

Referenced by main().

bool dw::Table::affectsSizeChangeContainerChild ( Widget child)
protected
int dw::Table::applyPerHeight ( int  containerHeight,
core::style::Length  perHeight 
)
virtual
int dw::Table::applyPerWidth ( int  containerWidth,
core::style::Length  perWidth 
)
virtual
void dw::Table::apportion2 ( int  totalWidth,
int  firstCol,
int  lastCol,
ExtrMod  minExtrMod,
ExtrMod  maxExtrMod,
void *  extrData,
lout::misc::SimpleVector< int > *  dest,
int  destOffset 
)
private
void dw::Table::apportionRowSpan ( )
private
void dw::Table::calcAdjustmentWidthSpanMultiCols ( int  col,
int  cs,
core::Extremes cellExtremes 
)
private
int dw::Table::calcAvailWidthForDescendant ( Widget child)
private
void dw::Table::calcCellSizes ( bool  calcHeights)
private

References DBG_OBJ_ENTER, and DBG_OBJ_LEAVE.

void dw::Table::calcExtremesSpanMultiCols ( int  col,
int  cs,
core::Extremes cellExtremes,
ExtrMod  minExtrMod,
ExtrMod  maxExtrMod,
void *  extrData 
)
private
bool dw::Table::childDefined ( int  n)
inlineprivate
void dw::Table::containerSizeChangedForChildren ( )
protectedvirtual

Reimplemented from dw::core::Widget.

References DBG_OBJ_ENTER0, and DBG_OBJ_LEAVE.

void dw::Table::drawLevel ( core::View view,
core::Rectangle area,
int  level,
core::DrawingContext context 
)
protectedvirtual
void dw::Table::forceCalcCellSizes ( bool  calcHeights)
private
void dw::Table::forceCalcColumnExtremes ( )
private
bool dw::Table::getAdjustMinWidth ( )
inlineprotectedvirtual

Reimplemented from dw::core::Widget.

References adjustTableMinWidth.

static bool dw::Table::getAdjustTableMinWidth ( )
inlinestatic

References adjustTableMinWidth.

int dw::Table::getAvailWidthOfChild ( Widget child,
bool  forceValue 
)
protected
AlignedTableCell * dw::Table::getCellRef ( )
int dw::Table::getColExtreme ( int  col,
ExtrMod  mod,
void *  data 
)
private
int dw::Table::getExtreme ( core::Extremes extremes,
ExtrMod  mod 
)
private
void dw::Table::getExtremesSimpl ( core::Extremes extremes)
protectedvirtual
const char * dw::Table::getExtrModName ( ExtrMod  mod)
private
core::Widget * dw::Table::getWidgetAtPointLevel ( int  x,
int  y,
int  level,
core::GettingWidgetAtPointContext context 
)
protectedvirtual

Reimplemented from dw::oof::OOFAwareWidget.

References DBG_OBJ_ENTER, DBG_OBJ_LEAVE, and DBG_OBJ_MSGF.

bool dw::Table::isBlockLevel ( )
protectedvirtual

Reimplemented from dw::core::Widget.

core::Iterator * dw::Table::iterator ( core::Content::Type  mask,
bool  atEnd 
)
virtual

Return an iterator for this widget.

mask can narrow the types returned by the iterator, this can enhance performance quite much, e.g. when only searching for child widgets.

With atEnd == false, the iterator starts before the beginning, i.e. the first call of dw::core::Iterator::next will let the iterator point on the first piece of contents. Likewise, With atEnd == true, the iterator starts after the last piece of contents, call dw::core::Iterator::prev in this case.

Implements dw::core::Widget.

void dw::Table::reallocChildren ( int  newNumCols,
int  newNumRows 
)
private
void dw::Table::removeChild ( Widget child)
protected
Bug:
Not implemented.
void dw::Table::resizeDrawImpl ( )
protectedvirtual

Called after sizeAllocateImpl() to redraw necessary areas. By default the whole widget is redrawn.

Reimplemented from dw::core::Widget.

static void dw::Table::setAdjustTableMinWidth ( bool  adjustTableMinWidth)
inlinestatic

References adjustTableMinWidth.

void dw::Table::setColExtreme ( int  col,
ExtrMod  mod,
void *  data,
int  value 
)
inlineprivate
void dw::Table::setCumHeight ( int  row,
int  value 
)
inlineprivate
void dw::Table::setExtreme ( core::Extremes extremes,
ExtrMod  mod,
int  value 
)
private
void dw::Table::sizeAllocateImpl ( core::Allocation allocation)
protectedvirtual
void dw::Table::sizeRequestSimpl ( core::Requisition requisition)
protectedvirtual

Simple variant, to be implemented by widgets with sizes not depending on positions.

Bug:
Baselines are not regarded here.

Reimplemented from dw::core::Widget.

References dw::core::Requisition::ascent, DBG_OBJ_ENTER0, DBG_OBJ_LEAVE, dw::core::Requisition::descent, dw::core::splitHeightPreserveDescent(), and dw::core::Requisition::width.

bool dw::Table::usesAvailWidth ( )
protectedvirtual

Must be implemengted by a method returning true, when getAvailWidth() is called.

Reimplemented from dw::core::Widget.

Friends And Related Function Documentation

friend class TableIterator
friend

Member Data Documentation

bool dw::Table::adjustTableMinWidth = true
staticprivate
lout::misc::SimpleVector<int>* dw::Table::baseline
private
lout::misc::SimpleVector<Child*>* dw::Table::children
private
int dw::Table::CLASS_ID = -1
static
lout::misc::SimpleVector<core::Extremes>* dw::Table::colExtremes
private

The extremes of all columns.

lout::misc::SimpleVector<bool>* dw::Table::colWidthPercentage
private

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<int>* dw::Table::colWidths
private

The widths of all columns.

lout::misc::SimpleVector<bool>* dw::Table::colWidthSpecified
private

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.

bool dw::Table::colWidthsUpToDateWidthColExtremes
private
lout::misc::SimpleVector<int>* dw::Table::cumHeight
private

Row cumulative height array: cumHeight->size() is numRows + 1, cumHeight->get(0) is 0, cumHeight->get(numRows) is the total table height.

int dw::Table::curCol
private
int dw::Table::curRow
private
bool dw::Table::limitTextWidth
private
int dw::Table::numCols
private
int dw::Table::numColWidthPercentage
private
int dw::Table::numColWidthSpecified
private
int dw::Table::numRows
private
int dw::Table::redrawX
private
int dw::Table::redrawY
private
bool dw::Table::rowClosed
private
lout::misc::SimpleVector<int>* dw::Table::rowSpanCells
private

If a Cell has rowspan > 1, it goes into this array

lout::misc::SimpleVector<core::style::Style*>* dw::Table::rowStyle
private

The documentation for this class was generated from the following files: