combobox.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_COMBOBOX_H
00024 #define OMGUI_INITIALIZER_COMBOBOX_H
00025 
00026 #include <omgui/initializer/widget.h>
00027 
00028 namespace omgui {
00029     namespace initializer {
00030 
00034 class OMGUI_API ComboBoxData : public WidgetData
00035 {
00036 private:
00038     bool m_sorted;
00039 
00041     bool m_editable;
00042 
00043 public:
00044     ComboBoxData();
00045 
00046     void set_sorted(bool sorted);
00047     bool get_sorted() const;
00048     void set_editable(bool editable);
00049     bool get_editable() const;
00050 };
00051 
00055 template<class T> class ComboBox : public Widget<T>
00056 {
00057 public:
00058     typedef ComboBoxData data_type;
00059 
00060 protected:
00061     data_type *m_data;
00062 
00063     ComboBox(data_type *data)
00064         : Widget<T>(data),
00065         m_data(data)
00066     { }
00067 
00068 public:
00069     T &sorted(bool sorted = true)
00070     {
00071         m_data->set_sorted(sorted);
00072         return static_cast<T&>(*this);
00073     }
00074 
00075     T &editable(bool editable = true)
00076     {
00077         m_data->set_editable(editable);
00078         return static_cast<T&>(*this);
00079     }
00080 
00081     bool get_sorted() const { return m_data->get_sorted(); }
00082     bool get_editable() const { return m_data->get_editable(); }
00083 };
00084 
00085     } // initializer
00086 
00087 class ComboBox;
00091 class OMGUI_API ComboBoxInitializer : public omgui::initializer::ComboBox<ComboBoxInitializer>
00092 {
00093     friend class omgui::ComboBox;
00094 public:
00095     ComboBoxInitializer();
00096 
00097 private:
00098     data_type get_data() const;
00099 };
00100 
00101 } // omgui
00102 
00103 #endif // OMGUI_INITIALIZER_COMBOBOX_H

doxygen SourceForge.net Logo