tablelayout.h

Go to the documentation of this file.
00001 
00007 /*
00008     This library is free software; you can redistribute it and/or
00009     modify it under the terms of the GNU Lesser General Public
00010     License as published by the Free Software Foundation; either
00011     version 2.1 of the License, or (at your option) any later version.
00012 
00013     This library is distributed in the hope that it will be useful,
00014     but WITHOUT ANY WARRANTY; without even the implied warranty of
00015     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016     Lesser General Public License for more details.
00017 
00018     You should have received a copy of the GNU Lesser General Public
00019     License along with this library; if not, write to the Free Software
00020     Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
00021 */
00022 
00023 #ifndef OMGUI_INITIALIZER_TABLELAYOUT_H
00024 #define OMGUI_INITIALIZER_TABLELAYOUT_H
00025 
00026 #include <omgui/initializer/panel.h>
00027 
00028 namespace omgui {
00029     namespace initializer {
00030 
00034 struct OMGUI_API TableLayoutData : PanelData
00035 {
00036 public:
00037     TableLayoutData();
00038 
00039 protected:
00040     int m_gap_row, m_gap_column;
00041     int m_margin_left, m_margin_top, m_margin_right, m_margin_bottom;
00042 
00043 public:
00044     void set_gap(int f);
00045     void set_row_gap(int f);
00046     void set_column_gap(int f);
00047     void set_margins(int f);
00048     void set_left_margin(int f);
00049     void set_right_margin(int f);
00050     void set_top_margin(int f);
00051     void set_bottom_margin(int f);
00052     void set_margins(int left, int top, int right, int bottom);
00053 
00054     int get_row_gap() const;
00055     int get_column_gap() const;
00056     int get_left_margin() const;
00057     int get_top_margin() const;
00058     int get_right_margin() const;
00059     int get_bottom_margin() const;
00060 };
00061 
00065 template<class T> class TableLayout : public Panel<T>
00066 {
00067 public:
00068     typedef TableLayoutData data_type;
00069 
00070 protected:
00071     data_type *m_data;
00072 
00073     TableLayout(data_type *data)
00074         : Panel<T>(data),
00075         m_data(data)
00076     { }
00077 
00078 public:
00079     T &gap(int f)
00080     {
00081         m_data->set_gap(f);
00082         return static_cast<T&>(*this);
00083     }
00084 
00085     T &row_gap(int f)
00086     {
00087         m_data->set_row_gap(f);
00088         return static_cast<T&>(*this);
00089     }
00090 
00091     T &column_gap(int f)
00092     {
00093         m_data->set_column_gap(f);
00094         return static_cast<T&>(*this);
00095     }
00096 
00097     T &margins(int f)
00098     {
00099         m_data->set_margins(f);
00100         return static_cast<T&>(*this);
00101     }
00102 
00103     T &margins(int left, int top, int right, int bottom)
00104     {
00105         m_data->set_margins(left, top, right, bottom);
00106         return static_cast<T&>(*this);
00107     }
00108 
00109     T &left_margin(int f)
00110     {
00111         m_data->set_left_margin(f);
00112         return static_cast<T&>(*this);
00113     }
00114 
00115     T &right_margin(int f)
00116     {
00117         m_data->set_right_margin(f);
00118         return static_cast<T&>(*this);
00119     }
00120 
00121     T &top_margin(int f)
00122     {
00123         m_data->set_top_margin(f);
00124         return static_cast<T&>(*this);
00125     }
00126 
00127     T &bottom_margin(int f)
00128     {
00129         m_data->set_bottom_margin(f);
00130         return static_cast<T&>(*this);
00131     }
00132 
00133     int get_row_gap() const { return m_data->get_row_gap(); }
00134     int get_column_gap() const { return m_data->get_column_gap(); }
00135     int get_left_margin() const { return m_data->get_left_margin(); }
00136     int get_top_margin() const { return m_data->get_top_margin(); }
00137     int get_right_margin() const { return m_data->get_right_margin(); }
00138     int get_bottom_margin() const { return m_data->get_bottom_margin(); }
00139 };
00140 
00141     } // initializer
00142 
00143 class TableLayout;
00144 
00148 class OMGUI_API TableLayoutInitializer : public omgui::initializer::TableLayout<TableLayoutInitializer>
00149 {
00150     friend class omgui::TableLayout;
00151 public:
00152     TableLayoutInitializer();
00153 
00154 private:
00155     data_type get_data() const;
00156 };
00157 
00158 } // omgui
00159 
00160 #endif // OMGUI_INITIALIZER_PANEL_H

doxygen SourceForge.net Logo