dillo  3.0.5
About: dillo is a small, fast, extensible Web browser particularly suitable for older or smaller computers and embedded systems (but only limited or no support for frames, CSS, JavaScript, Java).
  Fossies Dox: dillo-3.0.5.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

table.hh
Go to the documentation of this file.
1 #ifndef __DW_TABLE_HH__
2 #define __DW_TABLE_HH__
3 
4 #include "core.hh"
5 #include "tablecell.hh"
6 #include "../lout/misc.hh"
7 
8 namespace dw {
9 
316 class Table: public core::Widget
317 {
318 private:
319 
320  struct Child
321  {
322  enum {
323  CELL, // cell starts here
324  SPAN_SPACE // part of a spanning cell
325  } type;
326  union {
327  struct {
330  } cell;
331  struct {
332  int startCol, startRow; // where the cell starts
333  } spanSpace;
334  };
335  };
336 
338  {
339  private:
340  int index;
341 
342  public:
343  TableIterator (Table *table, core::Content::Type mask, bool atEnd);
345 
348 
349  bool next ();
350  bool prev ();
351  void highlight (int start, int end, core::HighlightLayer layer);
352  void unhighlight (int direction, core::HighlightLayer layer);
353  void getAllocation (int start, int end, core::Allocation *allocation);
354  };
355 
356  friend class TableIterator;
357 
359  int availWidth, availAscent, availDescent; // set by set...
360 
363 
365 
370 
375 
391 
393 
399 
400  inline bool childDefined(int n)
401  {
402  return n < children->size() && children->get(n) != NULL &&
403  children->get(n)->type != Child::SPAN_SPACE;
404  }
405 
406  void reallocChildren (int newNumCols, int newNumRows);
407 
408  void calcCellSizes ();
409  void forceCalcCellSizes ();
410  void apportionRowSpan ();
411 
412  void calcColumnExtremes ();
413  void forceCalcColumnExtremes ();
414 
415  void apportion2 (int totalWidth, int forceTotalWidth);
416  void apportion_percentages2 (int totalWidth, int forceTotalWidth);
417 
418  void setCumHeight (int row, int value)
419  {
420  if (value != cumHeight->get (row)) {
421  redrawY = lout::misc::min ( redrawY, value );
422  cumHeight->set (row, value);
423  }
424  }
425 
426  inline void setColWidth (int col, int value)
427  {
428  if (value != colWidths->get (col)) {
429  redrawX = lout::misc::min (redrawX, value);
430  colWidths->set (col, value);
431  }
432  }
433 
434 protected:
438  void resizeDrawImpl ();
439 
440  void setWidth (int width);
441  void setAscent (int ascent);
442  void setDescent (int descent);
443  void draw (core::View *view, core::Rectangle *area);
444 
445  //bool buttonPressImpl (core::EventButton *event);
446  //bool buttonReleaseImpl (core::EventButton *event);
447  //bool motionNotifyImpl (core::EventMotion *event);
448 
449  void removeChild (Widget *child);
450 
451 public:
452  static int CLASS_ID;
453 
454  Table(bool limitTextWidth);
455  ~Table();
456 
457  core::Iterator *iterator (core::Content::Type mask, bool atEnd);
458 
459  void addCell (Widget *widget, int colspan, int rowspan);
461  TableCell *getCellRef ();
462 };
463 
464 } // namespace dw
465 
466 #endif // __DW_TABLE_HH__
dw::Table::setCumHeight
void setCumHeight(int row, int value)
Definition: table.hh:418
dw::Table::TableIterator::next
bool next()
Move iterator forward and store content it.
Definition: table.cc:1148
dw::Table::CLASS_ID
static int CLASS_ID
Definition: table.hh:452
dw::Table
A Widget for rendering tables.
Definition: table.hh:316
dw::Table::Child::widget
core::Widget * widget
Definition: table.hh:328
dw::Table::setDescent
void setDescent(int descent)
Definition: table.cc:223
dw::Table::getExtremesImpl
void getExtremesImpl(core::Extremes *extremes)
See Sizes of Dillo Widgets.
Definition: table.cc:124
dw::Table::redrawX
int redrawX
Definition: table.hh:364
dw::Table::numCols
int numCols
Definition: table.hh:361
dw::core::HighlightLayer
HighlightLayer
Definition: types.hh:42
dw::core::Requisition
Definition: types.hh:172
lout::misc::SimpleVector::get
T get(int i) const
Return the one element, explicitly.
Definition: misc.hh:177
dw::Table::rowStyle
lout::misc::SimpleVector< core::style::Style * > * rowStyle
Definition: table.hh:392
dw::TableCell
Definition: tablecell.hh:9
dw::Table::TableIterator::clone
lout::object::Object * clone()
Return an exact copy of the object.
Definition: table.cc:1138
dw::Table::Child::rowspan
int rowspan
Definition: table.hh:329
dw::Table::setColWidth
void setColWidth(int col, int value)
Definition: table.hh:426
dw::Table::Child::startRow
int startRow
Definition: table.hh:332
dw::Table::apportion_percentages2
void apportion_percentages2(int totalWidth, int forceTotalWidth)
Definition: table.cc:927
dw::core::Content::Type
Type
Definition: types.hh:187
dw::Table::TableIterator::prev
bool prev()
Move iterator backward and store content it.
Definition: table.cc:1175
dw::Table::rowSpanCells
lout::misc::SimpleVector< int > * rowSpanCells
Definition: table.hh:385
dw::core::Iterator
Iterators are used to iterate through the contents of a widget.
Definition: iterator.hh:19
dw::Table::removeChild
void removeChild(Widget *child)
Definition: table.cc:263
dw::Table::Child::spanSpace
struct dw::Table::Child::@16::@19 spanSpace
dw::Table::Child::type
enum dw::Table::Child::@15 type
dw::Table::redrawY
int redrawY
Definition: table.hh:364
dw::Table::setAscent
void setAscent(int ascent)
Definition: table.cc:215
dw::core::Allocation
Represents the allocation, i.e. actual position and size of a dw::core::Widget.
Definition: types.hh:163
dw::Table::TableIterator::unhighlight
void unhighlight(int direction, core::HighlightLayer layer)
Shrink highlighted region to no longer contain the current content.
Definition: table.cc:1208
dw::core::Widget::style
style::Style * style
Definition: widget.hh:104
dw::Table::TableIterator::index
int index
Definition: table.hh:340
dw::Table::rowClosed
bool rowClosed
Definition: table.hh:358
dw::Table::forceCalcCellSizes
void forceCalcCellSizes()
Definition: table.cc:490
dw::Table::children
lout::misc::SimpleVector< Child * > * children
Definition: table.hh:362
dw::Table::limitTextWidth
bool limitTextWidth
Definition: table.hh:358
dw::Table::TableIterator::getAllocation
void getAllocation(int start, int end, core::Allocation *allocation)
Return the shape, which a part of the item, the iterator points on, allocates.
Definition: table.cc:1213
tablecell.hh
lout::misc::min
T min(T a, T b)
Definition: misc.hh:19
dw::Table::reallocChildren
void reallocChildren(int newNumCols, int newNumRows)
Definition: table.cc:412
dw::Table::apportionRowSpan
void apportionRowSpan()
Definition: table.cc:578
lout::misc::SimpleVector::set
void set(int i, T t)
Store an object in the vector.
Definition: misc.hh:222
dw::Table::Child::colspanEff
int colspanEff
Definition: table.hh:329
lout::object::Object
This is the base class for many other classes, which defines very common virtual methods.
Definition: object.hh:24
dw::Table::apportion2
void apportion2(int totalWidth, int forceTotalWidth)
Apportionment function for AUTO-length columns. 'extremes' comes filled, 'result' comes defined for p...
Definition: table.cc:847
dw::Table::Child::colspanOrig
int colspanOrig
Definition: table.hh:329
dw::Table::colSpanCells
lout::misc::SimpleVector< int > * colSpanCells
Definition: table.hh:389
dw::Table::~Table
~Table()
Definition: table.cc:72
dw::core::Widget::Widget
Widget()
Definition: widget.cc:67
dw::core::Widget::requisition
Requisition requisition
Size_request() stores the result of the last call of size_request_impl().
Definition: widget.hh:114
dw::core::Iterator::mask
Content::Type mask
Definition: iterator.hh:30
dw::Table::Child::startCol
int startCol
Definition: table.hh:332
dw::Table::cumHeight
lout::misc::SimpleVector< int > * cumHeight
Definition: table.hh:381
dw::Table::colExtremes
lout::misc::SimpleVector< core::Extremes > * colExtremes
The extremes of all columns.
Definition: table.hh:369
dw::Table::colWidths
lout::misc::SimpleVector< int > * colWidths
The widths of all columns.
Definition: table.hh:374
dw::Table::TableIterator::compareTo
int compareTo(lout::object::Comparable *other)
Compare two objects c1 and c2.
Definition: table.cc:1143
dw::Table::getCellRef
TableCell * getCellRef()
Definition: table.cc:396
dw::Table::curRow
int curRow
Definition: table.hh:361
dw::Table::TableIterator::highlight
void highlight(int start, int end, core::HighlightLayer layer)
Extend highlighted region to contain part of the current content.
Definition: table.cc:1202
dw::Table::TableIterator::TableIterator
TableIterator(Table *table, core::Content::Type mask, bool atEnd)
Definition: table.cc:1114
dw::Table::childDefined
bool childDefined(int n)
Definition: table.hh:400
dw::core::Rectangle
dw::core::Shape implemtation for simple rectangles.
Definition: types.hh:69
dw::core::Extremes
Definition: types.hh:179
dw::core::View
An interface to encapsulate platform dependent drawing.
Definition: view.hh:16
dw::Table::addRow
void addRow(core::style::Style *style)
Definition: table.cc:378
dw::Table::availAscent
int availAscent
Definition: table.hh:359
dw::Table::Child::CELL
Definition: table.hh:323
dw::Table::calcColumnExtremes
void calcColumnExtremes()
Fills dw::Table::colExtremes, only if recalculation is necessary.
Definition: table.cc:641
dw::core::Widget::extremes
Extremes extremes
Analogue to dw::core::Widget::requisition.
Definition: widget.hh:119
dw::Table::baseline
lout::misc::SimpleVector< int > * baseline
Definition: table.hh:390
dw::Table::setWidth
void setWidth(int width)
Definition: table.cc:205
dw::Table::sizeAllocateImpl
void sizeAllocateImpl(core::Allocation *allocation)
See Sizes of Dillo Widgets.
Definition: table.cc:153
lout::object::Comparable
Instances of a sub class of may be compared (less, greater).
Definition: object.hh:41
core.hh
dw::Table::addCell
void addCell(Widget *widget, int colspan, int rowspan)
Definition: table.cc:273
dw::Table::availWidth
int availWidth
Definition: table.hh:359
dw::Table::availDescent
int availDescent
Definition: table.hh:359
dw::Table::calcCellSizes
void calcCellSizes()
Definition: table.cc:483
dw::Table::Child::cell
struct dw::Table::Child::@16::@18 cell
dw::Table::Child
Definition: table.hh:320
dw::Table::forceCalcColumnExtremes
void forceCalcColumnExtremes()
Fills dw::Table::colExtremes in all cases.
Definition: table.cc:651
dw::Table::hasColPercent
int hasColPercent
Definition: table.hh:397
dw::Table::draw
void draw(core::View *view, core::Rectangle *area)
Definition: table.cc:231
dw::Table::sizeRequestImpl
void sizeRequestImpl(core::Requisition *requisition)
See Sizes of Dillo Widgets.
Definition: table.cc:105
dw::core::Widget
The base class of all dillo widgets.
Definition: widget.hh:23
dw::Table::Table
Table(bool limitTextWidth)
Definition: table.cc:33
dw::core::Widget::allocation
Allocation allocation
The current allocation: size and position, always relative to the canvas.
Definition: widget.hh:151
dw
Dw is in this namespace, or sub namespaces of this one.
Definition: alignedtextblock.cc:26
dw::Table::colPercents
lout::misc::SimpleVector< core::style::Length > * colPercents
Definition: table.hh:398
dw::Table::resizeDrawImpl
void resizeDrawImpl()
Called after sizeAllocateImpl() to redraw necessary areas. By default the whole widget is redrawn.
Definition: table.cc:197
dw::Table::curCol
int curCol
Definition: table.hh:361
dw::Table::numRows
int numRows
Definition: table.hh:361
dw::Table::Child::SPAN_SPACE
Definition: table.hh:324
lout::misc::SimpleVector
Simple (simpler than container::untyped::Vector and container::typed::Vector) template based vector.
Definition: misc.hh:71
dw::core::style::Style
Definition: style.hh:571
dw::Table::iterator
core::Iterator * iterator(core::Content::Type mask, bool atEnd)
Return an iterator for this widget.
Definition: table.cc:268
dw::Table::TableIterator
Definition: table.hh:337