- Your Widget Set For OpenGL
Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | Related Pages

ucombobox.hpp

00001 /*************************************************************************** 00002 LibUFO - UI For OpenGL 00003 copyright : (C) 2001-2005 by Johannes Schmidt 00004 email : schmidtjf at users.sourceforge.net 00005 ------------------- 00006 00007 file : include/ufo/widgets/ucombobox.hpp 00008 begin : Sat May 24 2003 00009 $Id: ucombobox.hpp,v 1.7 2005/07/05 11:23:02 schmidtjf Exp $ 00010 ***************************************************************************/ 00011 00012 /*************************************************************************** 00013 * This library is free software; you can redistribute it and/or * 00014 * modify it under the terms of the GNU Lesser General Public * 00015 * License as published by the Free Software Foundation; either * 00016 * version 2.1 of the License, or (at your option) any later version. * 00017 * * 00018 * This library is distributed in the hope that it will be useful, * 00019 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00020 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00021 * Lesser General Public License for more details. * 00022 * * 00023 * You should have received a copy of the GNU Lesser General Public * 00024 * License along with this library; if not, write to the Free Software * 00025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * 00026 ***************************************************************************/ 00027 00028 #ifndef UCOMBOBOX_HPP 00029 #define UCOMBOBOX_HPP 00030 00031 #include "uwidget.hpp" 00032 00033 namespace ufo { 00034 00035 class UItem; 00036 class UIcon; 00037 class UColor; 00038 00039 class UListBox; 00040 class UTextEdit; 00041 00052 class UFO_EXPORT UComboBox : public UWidget { 00053 UFO_DECLARE_DYNAMIC_CLASS(UComboBox) 00054 UFO_UI_CLASS(UComboBoxUI) 00055 UFO_STYLE_TYPE(UStyle::CE_ComboBox) 00056 public: // Public constructors 00057 UComboBox(); 00058 UComboBox(const std::vector<UString> & listDataA); 00059 public: // Item accessing methods 00064 void addList(const std::vector<UString> & listData); 00067 void addItem(UItem * itemA, int index = -1); 00070 void addItem(const UString & itemA, int index = -1); 00073 void addItem(UIcon * itemA, int index = -1); 00074 00076 void removeItem(unsigned int index); 00077 void removeAllItems(); 00078 00079 UItem * getItemAt(unsigned int n) const; 00080 const std::vector<UItem*> & getItems() const; 00081 00082 unsigned int getItemCount() const; 00083 00084 public: // Other methods 00088 void setVisibleRowCount(int visibleRowCountA); 00089 int getVisibleRowCount() const; 00090 00091 public: 00092 00096 int getCurrentItem() const; 00097 void setCurrentItem(int index); 00098 00102 std::string getCurrentText() const; 00103 void setCurrentText(const std::string & text); 00104 00106 virtual void popup(); 00107 00108 public: // Public methods 00109 virtual void setListBox(UListBox * listBox); 00110 UListBox * getListBox() const; 00111 00112 virtual void setTextEdit(UTextEdit * textEdit); 00113 UTextEdit * getTextEdit() const; 00114 00115 public: // Public signal accessors 00116 typedef USignal2<UComboBox*, int> sig_activated_t; 00117 typedef USignal2<UComboBox*, int> sig_highlighted_t; 00118 typedef USignal3<UComboBox*, int, int> sig_selection_change_t; 00119 sig_activated_t & sigActivated(); 00120 sig_highlighted_t & sigHighlighted(); 00121 sig_selection_change_t & sigSelectionChanged(); 00122 00123 protected: // Overrides UWidget 00124 virtual UDimension getContentsSize(const UDimension & maxSize) const; 00125 virtual void processMouseEvent(UMouseEvent * e); 00126 virtual void processKeyEvent(UKeyEvent * e); 00127 00128 protected: // Protected attributes 00129 // internally used widgets to represent the data 00130 UListBox * m_listBox; 00131 UTextEdit * m_textEdit; 00132 00133 private: // Private attributes 00134 UItem * m_activated; 00135 std::string m_currentText; 00136 00137 int m_visRowCount; 00138 private: // Private signals 00139 sig_activated_t m_sigActivated; 00140 sig_highlighted_t m_sigHighlighted; 00141 sig_selection_change_t m_sigSelectionChanged; 00142 }; 00143 00144 00145 inline UComboBox::sig_activated_t & 00146 UComboBox::sigActivated() { 00147 return m_sigActivated; 00148 } 00149 00150 inline UComboBox::sig_highlighted_t & 00151 UComboBox::sigHighlighted() { 00152 return m_sigHighlighted; 00153 } 00154 00155 inline UComboBox::sig_selection_change_t & 00156 UComboBox::sigSelectionChanged() { 00157 return m_sigSelectionChanged; 00158 } 00159 00160 } // namespace ufo 00161 00162 #endif // UCOMBOBOX_HPP

The libUFO Project - written by Johannes Schmidt