OpenWalnut  1.5.0dev
WUIGridWidget.h
1 //---------------------------------------------------------------------------
2 //
3 // Project: OpenWalnut ( http://www.openwalnut.org )
4 //
5 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6 // For more information see http://www.openwalnut.org/copying
7 //
8 // This file is part of OpenWalnut.
9 //
10 // OpenWalnut is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // OpenWalnut is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22 //
23 //---------------------------------------------------------------------------
24 
25 #ifndef WUIGRIDWIDGET_H
26 #define WUIGRIDWIDGET_H
27 
28 #include <memory>
29 #include <string>
30 
31 
32 #include "WUIWidgetBase.h"
33 
34 /**
35  * Widget which is a container for others. The child widgets can be arranged in a grid. The WUIGridWidget itself is a widget, which means you can
36  * embed grids in grid cells.
37  *
38  * \note Please read documentation of \ref WUIWidgetFactory for limitations, requirements and creation of these widgets.
39  */
41 {
42 public:
43  /**
44  * Convenience typedef for a std::shared_ptr< WUIGridWidget >.
45  */
46  typedef std::shared_ptr< WUIGridWidget > SPtr;
47 
48  /**
49  * Convenience typedef for a std::shared_ptr< const WUIGridWidget >.
50  */
51  typedef std::shared_ptr< const WUIGridWidget > ConstSPtr;
52 
53  /**
54  * Destructor.
55  */
56  virtual ~WUIGridWidget();
57 
58  /**
59  * Tell the user whether this kind of widget can be used as parent. In other word, whether it is allowed to nest other widgets into this one.
60  *
61  * \return true if nesting other widgets INTO this one is allowed
62  */
63  virtual bool allowNesting() const;
64 
65  /**
66  * Place the given widget in this grid at the given coordinates. The widget to be placed must be created with this grid as parent or an
67  * exception will be thrown.
68  *
69  * \param widget the widget
70  * \param x x coord ( 0 is left )
71  * \param y y coord ( 0 is top )
72  */
73  virtual void placeWidget( WUIWidgetBase::SPtr widget, int x, int y );
74 
75  /**
76  * Sets the stretch factor of a row to stretch. The first row is number 0. The stretch factor is relative to the other rows in this grid.
77  * Rows with a higher stretch factor take more of the available space. The default stretch factor is 0. If the stretch factor is 0 and no
78  * other row in this table can grow at all, the row may still grow.
79  *
80  * \param row the row to set this value for
81  * \param stretch the stretch
82  */
83  virtual void setRowStretch( int row, int stretch ) = 0;
84 
85  /**
86  * Sets the stretch factor of a column to stretch. The first column is number 0. The stretch factor is relative to the other columns in this grid.
87  * Columns with a higher stretch factor take more of the available space. The default stretch factor is 0. If the stretch factor is 0 and no
88  * other column in this table can grow at all, the column may still grow.
89  *
90  * \param column the column to set this value for
91  * \param stretch the stretch
92  */
93  virtual void setColumnStretch( int column, int stretch ) = 0;
94 protected:
95  /**
96  * Default constructor. Create an empty grid widget.
97  *
98  * \param title the widget title
99  */
100  explicit WUIGridWidget( std::string title );
101 
102  /**
103  * Place the given widget in this grid at the given coordinates. The widget to be placed must be created with this grid as parent.
104  *
105  * \param widget the widget
106  * \param x x coord ( 0 is left )
107  * \param y y coord ( 0 is top )
108  */
109  virtual void placeWidgetImpl( WUIWidgetBase::SPtr widget, int x, int y ) = 0;
110 private:
111 };
112 
113 #endif // WUIGRIDWIDGET_H
114 
Widget which is a container for others.
Definition: WUIGridWidget.h:41
virtual void placeWidget(WUIWidgetBase::SPtr widget, int x, int y)
Place the given widget in this grid at the given coordinates.
WUIGridWidget(std::string title)
Default constructor.
std::shared_ptr< WUIGridWidget > SPtr
Convenience typedef for a std::shared_ptr< WUIGridWidget >.
Definition: WUIGridWidget.h:46
virtual ~WUIGridWidget()
Destructor.
virtual void placeWidgetImpl(WUIWidgetBase::SPtr widget, int x, int y)=0
Place the given widget in this grid at the given coordinates.
virtual void setColumnStretch(int column, int stretch)=0
Sets the stretch factor of a column to stretch.
std::shared_ptr< const WUIGridWidget > ConstSPtr
Convenience typedef for a std::shared_ptr< const WUIGridWidget >.
Definition: WUIGridWidget.h:51
virtual void setRowStretch(int row, int stretch)=0
Sets the stretch factor of a row to stretch.
virtual bool allowNesting() const
Tell the user whether this kind of widget can be used as parent.
Base class for all the widget abstraction the core UI provides.
Definition: WUIWidgetBase.h:45
std::shared_ptr< WUIWidgetBase > SPtr
Convenience typedef for a std::shared_ptr< WUIWidgetBase >.
Definition: WUIWidgetBase.h:51