qwt_dyngrid_layout.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
  2. * Qwt Widget Library
  3. * Copyright (C) 1997 Josef Wilgen
  4. * Copyright (C) 2002 Uwe Rathmann
  5. *
  6. * This library is free software; you can redistribute it and/or
  7. * modify it under the terms of the Qwt License, Version 1.0
  8. *****************************************************************************/
  9. #ifndef QWT_DYNGRID_LAYOUT_H
  10. #define QWT_DYNGRID_LAYOUT_H
  11. #include "qwt_global.h"
  12. #include <qlayout.h>
  13. #include <qsize.h>
  14. #include <qlist.h>
  15. /*!
  16. \brief The QwtDynGridLayout class lays out widgets in a grid,
  17. adjusting the number of columns and rows to the current size.
  18. QwtDynGridLayout takes the space it gets, divides it up into rows and
  19. columns, and puts each of the widgets it manages into the correct cell(s).
  20. It lays out as many number of columns as possible (limited by maxColumns()).
  21. */
  22. class QWT_EXPORT QwtDynGridLayout : public QLayout
  23. {
  24. Q_OBJECT
  25. public:
  26. explicit QwtDynGridLayout( QWidget *, int margin = 0, int spacing = -1 );
  27. explicit QwtDynGridLayout( int spacing = -1 );
  28. virtual ~QwtDynGridLayout();
  29. virtual void invalidate();
  30. void setMaxColumns( uint maxColumns );
  31. uint maxColumns() const;
  32. uint numRows () const;
  33. uint numColumns () const;
  34. virtual void addItem( QLayoutItem * );
  35. virtual QLayoutItem *itemAt( int index ) const;
  36. virtual QLayoutItem *takeAt( int index );
  37. virtual int count() const;
  38. void setExpandingDirections( Qt::Orientations );
  39. virtual Qt::Orientations expandingDirections() const;
  40. QList<QRect> layoutItems( const QRect &, uint numColumns ) const;
  41. virtual int maxItemWidth() const;
  42. virtual void setGeometry( const QRect &rect );
  43. virtual bool hasHeightForWidth() const;
  44. virtual int heightForWidth( int ) const;
  45. virtual QSize sizeHint() const;
  46. virtual bool isEmpty() const;
  47. uint itemCount() const;
  48. virtual uint columnsForWidth( int width ) const;
  49. protected:
  50. void layoutGrid( uint numColumns,
  51. QVector<int>& rowHeight, QVector<int>& colWidth ) const;
  52. void stretchGrid( const QRect &rect, uint numColumns,
  53. QVector<int>& rowHeight, QVector<int>& colWidth ) const;
  54. private:
  55. void init();
  56. int maxRowWidth( int numColumns ) const;
  57. class PrivateData;
  58. PrivateData *d_data;
  59. };
  60. #endif