Dillo
table.hh
Go to the documentation of this file.
1 #ifndef __DW_TABLE_HH__
2 #define __DW_TABLE_HH__
3 
4 #include "oofawarewidget.hh"
5 #include "alignedtablecell.hh"
6 #include "../lout/misc.hh"
7 
8 namespace dw {
9 
326 {
327 private:
328  struct Child
329  {
330  enum {
331  CELL, // cell starts here
332  SPAN_SPACE // part of a spanning cell
333  } type;
334  union {
335  struct {
338  } cell;
339  struct {
340  int startCol, startRow; // where the cell starts
341  } spanSpace;
342  };
343  };
344 
345  class TableIterator: public OOFAwareWidgetIterator
346  {
347  protected:
348  int numContentsInFlow ();
349  void getContentInFlow (int index, core::Content *content);
350 
351  public:
352  TableIterator (Table *table, core::Content::Type mask, bool atEnd);
353 
355 
356  void highlight (int start, int end, core::HighlightLayer layer);
357  void unhighlight (int direction, core::HighlightLayer layer);
358  void getAllocation (int start, int end, core::Allocation *allocation);
359  };
360 
361  friend class TableIterator;
362 
363  static bool adjustTableMinWidth;
364 
366 
369 
371 
376 
387 
398 
403 
415 
417 
419 
421 
422  const char *getExtrModName (ExtrMod mod);
424  void setExtreme (core::Extremes *extremes, ExtrMod mod, int value);
425  int getColExtreme (int col, ExtrMod mod, void *data);
426  inline void setColExtreme (int col, ExtrMod mod, void *data, int value);
427 
428  inline bool childDefined(int n)
429  {
430  return n < children->size() && children->get(n) != NULL &&
431  children->get(n)->type != Child::SPAN_SPACE;
432  }
433 
434  int calcAvailWidthForDescendant (Widget *child);
435 
436  void reallocChildren (int newNumCols, int newNumRows);
437 
438  void calcCellSizes (bool calcHeights);
439  void forceCalcCellSizes (bool calcHeights);
440  void actuallyCalcCellSizes (bool calcHeights);
441  void apportionRowSpan ();
442 
443  void forceCalcColumnExtremes ();
444  void calcExtremesSpanMultiCols (int col, int cs,
445  core::Extremes *cellExtremes,
446  ExtrMod minExtrMod, ExtrMod maxExtrMod,
447  void *extrData);
448  void calcAdjustmentWidthSpanMultiCols (int col, int cs,
449  core::Extremes *cellExtremes);
450 
451  void apportion2 (int totalWidth, int firstCol, int lastCol,
452  ExtrMod minExtrMod, ExtrMod maxExtrMod, void *extrData,
453  lout::misc::SimpleVector<int> *dest, int destOffset);
454 
455  void setCumHeight (int row, int value)
456  {
457  if (value != cumHeight->get (row)) {
458  redrawY = lout::misc::min ( redrawY, value );
459  cumHeight->set (row, value);
460  }
461  }
462 
463 protected:
467  void resizeDrawImpl ();
468 
470 
471  int getAvailWidthOfChild (Widget *child, bool forceValue);
472 
475  bool usesAvailWidth ();
476 
477  bool isBlockLevel ();
478 
479  void drawLevel (core::View *view, core::Rectangle *area, int level,
480  core::DrawingContext *context);
481 
482  Widget *getWidgetAtPointLevel (int x, int y, int level,
484 
485  //bool buttonPressImpl (core::EventButton *event);
486  //bool buttonReleaseImpl (core::EventButton *event);
487  //bool motionNotifyImpl (core::EventMotion *event);
488 
489  void removeChild (Widget *child);
490 
491 public:
492  static int CLASS_ID;
493 
494  inline static void setAdjustTableMinWidth (bool adjustTableMinWidth)
496 
497  inline static bool getAdjustTableMinWidth ()
498  { return Table::adjustTableMinWidth; }
499 
500  Table(bool limitTextWidth);
501  ~Table();
502 
503  int applyPerWidth (int containerWidth, core::style::Length perWidth);
504  int applyPerHeight (int containerHeight, core::style::Length perHeight);
505 
506  core::Iterator *iterator (core::Content::Type mask, bool atEnd);
507 
508  void addCell (Widget *widget, int colspan, int rowspan);
511 };
512 
513 } // namespace dw
514 
515 #endif // __DW_TABLE_HH__
struct dw::Table::Child::@20::@23 spanSpace
Definition: table.hh:420
void calcCellSizes(bool calcHeights)
Definition: table.cc:823
AlignedTableCell * getCellRef()
Definition: table.cc:602
Extremes extremes
Analogue to dw::core::Widget::requisition.
Definition: widget.hh:146
bool isBlockLevel()
Definition: table.cc:374
Table(bool limitTextWidth)
Definition: table.cc:34
lout::misc::SimpleVector< int > * rowSpanCells
Definition: table.hh:413
void forceCalcCellSizes(bool calcHeights)
Definition: table.cc:839
void set(int i, T t)
Store an object in the vector.
Definition: misc.hh:246
TableIterator(Table *table, core::Content::Type mask, bool atEnd)
Definition: table_iterator.cc:29
style::Style * style
Definition: widget.hh:130
void apportion2(int totalWidth, int firstCol, int lastCol, ExtrMod minExtrMod, ExtrMod maxExtrMod, void *extrData, lout::misc::SimpleVector< int > *dest, int destOffset)
Actual apportionment function.
Definition: table.cc:1522
Set at the top when getting the widget at the point.
Definition: types.hh:312
void removeChild(Widget *child)
Definition: table.cc:458
int numColWidthSpecified
Definition: table.hh:386
int applyPerWidth(int containerWidth, core::style::Length perWidth)
Definition: table.cc:320
Requisition requisition
Size_request() stores the result of the last call of size_request_impl().
Definition: widget.hh:140
void highlight(int start, int end, core::HighlightLayer layer)
Definition: table_iterator.cc:44
dw::core::Shape implemtation for simple rectangles.
Definition: types.hh:69
enum dw::Table::Child::@19 type
Type
Definition: types.hh:199
int rowspan
Definition: table.hh:337
Definition: table.hh:345
void getContentInFlow(int index, core::Content *content)
Definition: table_iterator.cc:76
void calcAdjustmentWidthSpanMultiCols(int col, int cs, core::Extremes *cellExtremes)
Definition: table.cc:1497
Definition: table.hh:331
int numCols
Definition: table.hh:367
bool limitTextWidth
Definition: table.hh:365
This is the base class for many other classes, which defines very common virtual methods.
Definition: object.hh:24
int colspanOrig
Definition: table.hh:337
T min(T a, T b)
Definition: misc.hh:19
static bool adjustTableMinWidth
Definition: table.hh:363
struct dw::Table::Child::@20::@22 cell
void reallocChildren(int newNumCols, int newNumRows)
Definition: table.cc:723
int size() const
Return the number of elements put into this vector.
Definition: misc.hh:141
Widget * getWidgetAtPointLevel(int x, int y, int level, core::GettingWidgetAtPointContext *context)
Definition: table.cc:425
bool affectsSizeChangeContainerChild(Widget *child)
Definition: table.cc:347
int redrawY
Definition: table.hh:370
void getExtremesSimpl(core::Extremes *extremes)
Simple variant, to be implemented by widgets with extremes not depending on positions.
Definition: table.cc:133
static bool getAdjustTableMinWidth()
Definition: table.hh:497
static void setAdjustTableMinWidth(bool adjustTableMinWidth)
Definition: table.hh:494
Iterators are used to iterate through the contents of a widget.
Definition: iterator.hh:19
void containerSizeChangedForChildren()
Definition: table.cc:330
int getColExtreme(int col, ExtrMod mod, void *data)
Definition: table.cc:701
const char * getExtrModName(ExtrMod mod)
Definition: table.cc:618
void apportionRowSpan()
Definition: table.cc:1226
ExtrMod
Definition: table.hh:420
int curRow
Definition: table.hh:367
int numContentsInFlow()
Definition: table_iterator.cc:71
lout::misc::SimpleVector< Child * > * children
Definition: table.hh:368
Definition: style.hh:613
int startRow
Definition: table.hh:340
Definition: types.hh:172
Represents the allocation, i.e. actual position and size of a dw::core::Widget.
Definition: types.hh:163
lout::misc::SimpleVector< bool > * colWidthSpecified
Wether the column itself (in the future?) or at least one cell in this column or spanning over this c...
Definition: table.hh:385
int calcAvailWidthForDescendant(Widget *child)
Definition: table.cc:271
Definition: table.hh:420
void addRow(core::style::Style *style)
Definition: table.cc:584
Definition: table.hh:420
void calcExtremesSpanMultiCols(int col, int cs, core::Extremes *cellExtremes, ExtrMod minExtrMod, ExtrMod maxExtrMod, void *extrData)
Definition: table.cc:1446
Definition: alignedtablecell.hh:9
bool rowClosed
Definition: table.hh:365
A Widget for rendering tables.
Definition: table.hh:325
The base class of all dillo widgets.
Definition: widget.hh:23
int getExtreme(core::Extremes *extremes, ExtrMod mod)
Definition: table.cc:648
Set at the top when drawing.
Definition: types.hh:294
int numColWidthPercentage
Definition: table.hh:397
Simple (simpler than container::untyped::Vector and container::typed::Vector) template based vector...
Definition: misc.hh:93
Definition: types.hh:197
lout::object::Object * clone()
Definition: table_iterator.cc:35
Definition: table.hh:420
lout::misc::SimpleVector< core::Extremes > * colExtremes
The extremes of all columns.
Definition: table.hh:375
lout::misc::SimpleVector< int > * colWidths
The widths of all columns.
Definition: table.hh:402
T get(int i) const
Return the one element, explicitly.
Definition: misc.hh:201
Definition: types.hh:179
Base class for widgets which can act as container and generator for widgets out of flow...
Definition: oofawarewidget.hh:77
Allocation allocation
The current allocation: size and position, always relative to the canvas.
Definition: widget.hh:183
HighlightLayer
Definition: types.hh:42
void setColExtreme(int col, ExtrMod mod, void *data, int value)
Definition: table.cc:712
void actuallyCalcCellSizes(bool calcHeights)
Definition: table.cc:902
~Table()
Definition: table.cc:73
bool colWidthsUpToDateWidthColExtremes
Definition: table.hh:418
lout::misc::SimpleVector< int > * cumHeight
Definition: table.hh:409
void forceCalcColumnExtremes()
Fills dw::Table::colExtremes in all cases.
Definition: table.cc:1291
Definition: table.hh:332
void sizeAllocateImpl(core::Allocation *allocation)
See Sizes of Dillo Widgets.
Definition: table.cc:166
int applyPerHeight(int containerHeight, core::style::Length perHeight)
Definition: table.cc:325
Dw is in this namespace, or sub namespaces of this one.
Definition: alignedtablecell.cc:28
void unhighlight(int direction, core::HighlightLayer layer)
Definition: table_iterator.cc:53
An interface to encapsulate platform dependent drawing.
Definition: view.hh:16
bool childDefined(int n)
Definition: table.hh:428
Widget()
Definition: widget.cc:67
int numRows
Definition: table.hh:367
Definition: table.hh:420
void setExtreme(core::Extremes *extremes, ExtrMod mod, int value)
Definition: table.cc:675
core::Iterator * iterator(core::Content::Type mask, bool atEnd)
Return an iterator for this widget.
Definition: table.cc:463
void getAllocation(int start, int end, core::Allocation *allocation)
Definition: table_iterator.cc:62
void setCumHeight(int row, int value)
Definition: table.hh:455
void addCell(Widget *widget, int colspan, int rowspan)
Definition: table.cc:468
static int CLASS_ID
Definition: table.hh:492
Definition: table.hh:420
int startCol
Definition: table.hh:340
lout::misc::SimpleVector< int > * baseline
Definition: table.hh:414
int redrawX
Definition: table.hh:370
bool usesAvailWidth()
Must be implemengted by a method returning true, when getAvailWidth() is called.
Definition: table.cc:369
bool getAdjustMinWidth()
Definition: table.hh:469
void drawLevel(core::View *view, core::Rectangle *area, int level, core::DrawingContext *context)
Definition: table.cc:379
core::Widget * widget
Definition: table.hh:336
int Length
Type for representing all lengths within dw::core::style.
Definition: style.hh:428
lout::misc::SimpleVector< bool > * colWidthPercentage
Wether the column itself (in the future?) or at least one cell in this column or spanning over this c...
Definition: table.hh:396
lout::misc::SimpleVector< core::style::Style * > * rowStyle
Definition: table.hh:416
Definition: table.hh:420
void sizeRequestSimpl(core::Requisition *requisition)
Simple variant, to be implemented by widgets with sizes not depending on positions.
Definition: table.cc:106
int colspanEff
Definition: table.hh:337
int getAvailWidthOfChild(Widget *child, bool forceValue)
Definition: table.cc:225
void resizeDrawImpl()
Called after sizeAllocateImpl() to redraw necessary areas. By default the whole widget is redrawn...
Definition: table.cc:217
int curCol
Definition: table.hh:367
Definition: table.hh:328