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_COMBOBOX_H
00024 #define OMGUI_COMBOBOX_H
00025 
00026 #include <omgui/widget.h>
00027 #include <omgui/initializer/combobox.h>
00028 
00029 namespace omgui {
00030 
00031 class ComboBoxItem
00032 {
00033 private:
00034     string m_text;
00035 
00036 public:
00037     ComboBoxItem() { }
00038     ComboBoxItem(const string &text): m_text(text) { }
00039     
00040     ComboBoxItem &text(const string &text)
00041     {
00042         m_text = text;
00043         return *this;
00044     }
00045 
00046     string get_text() const { return m_text; }
00047 };
00048 
00055 class OMGUI_API ComboBox : public Widget
00056 {
00057 public:
00058     typedef omgui::api::ComboBox api_type;
00059     typedef ComboBoxInitializer Initializer;
00060 
00064     static Pointer<ComboBox> create(const Initializer &initializer, object_id id = OBJECT_ID_ANY);
00065 
00069     bool is_sorted() const;
00070 
00074     bool is_editable() const;
00075 
00083     void append(const ComboBoxItem &item, bool select = false);
00084 
00092     void prepend(const ComboBoxItem &item, bool select = false);
00093 
00102     void insert(const ComboBoxItem &item, int index, bool select = false);
00103 
00109     void remove(int index);
00110 
00115     void clear();
00116 
00120     int get_item_count() const;
00121 
00129     string get_text() const;
00130 
00138     int get_selection() const;
00139 
00145     void set_selection(int index);
00146 
00150     void clear_selection();
00151 
00161     ComboBoxItem get_item(int index) const;
00162 
00172     ComboBoxItem get_selected_item() const;
00173 
00174 private:
00175     api_type *m_impl;
00176 
00177 protected:
00178     ComboBox(object_id id);
00179     ComboBox(object_id id, api_type *impl);
00180 
00184     void initialize(const Initializer &initializer);
00185 
00186 public:
00187     api_type *get_impl() const;
00188 };
00189 
00190 } // omgui
00191 
00192 #endif // OMGUI_COMBOBOX_H

doxygen SourceForge.net Logo