Table 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2008 Robert Osfield
  2. *
  3. * This library is open source and may be redistributed and/or modified under
  4. * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
  5. * (at your option) any later version. The full license is in LICENSE file
  6. * included with this distribution, and on the openscenegraph.org website.
  7. *
  8. * This library is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * OpenSceneGraph Public License for more details.
  12. */
  13. // Code by: Jeremy Moles (cubicool) 2007-2008
  14. #ifndef OSGWIDGET_TABLE
  15. #define OSGWIDGET_TABLE
  16. #include <osgWidget/Window>
  17. namespace osgWidget {
  18. class OSGWIDGET_EXPORT Table: public Window
  19. {
  20. public:
  21. typedef std::vector<point_type> CellSizes;
  22. META_Object (osgWidget, Table);
  23. Table (const std::string& = "", unsigned int = 0, unsigned int = 0);
  24. Table (const Table&, const osg::CopyOp&);
  25. virtual bool addWidget (Widget*);
  26. virtual bool addWidget (Widget*, unsigned int, unsigned int);
  27. void getRowHeights (CellSizes&) const;
  28. void getRowMinHeights (CellSizes&) const;
  29. void getColumnWidths (CellSizes&) const;
  30. void getColumnMinWidths (CellSizes&) const;
  31. void addHeightToRow (unsigned int, point_type);
  32. void addWidthToColumn (unsigned int, point_type);
  33. bool isRowVerticallyFillable (unsigned int) const;
  34. bool isColumnHorizontallyFillable (unsigned int) const;
  35. Widget* getByRowCol(unsigned int row, unsigned int col)
  36. {
  37. return getObjects()[_calculateIndex(row, col)].get();
  38. }
  39. const Widget* getByRowCol(unsigned int row, unsigned int col) const
  40. {
  41. return getObjects()[_calculateIndex(row, col)].get();
  42. }
  43. protected:
  44. unsigned int _rows;
  45. unsigned int _cols;
  46. unsigned int _lastRowAdd;
  47. unsigned int _lastColAdd;
  48. unsigned int _calculateIndex(unsigned int, unsigned int) const;
  49. void _getRows (CellSizes&, Getter) const;
  50. void _getColumns (CellSizes&, Getter) const;
  51. virtual void _resizeImplementation(point_type, point_type);
  52. virtual Sizes _getWidthImplementation () const;
  53. virtual Sizes _getHeightImplementation () const;
  54. };
  55. }
  56. #endif