00001 /* 00002 libwftk - Worldforge Toolkit - a widget library 00003 Copyright (C) 2002 Malcolm Walker <malcolm@worldforge.org> 00004 Based on code copyright (C) 1999-2002 Karsten Laux 00005 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Lesser General Public 00008 License as published by the Free Software Foundation; either 00009 version 2.1 of the License, or (at your option) any later version. 00010 00011 This library is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 Lesser General Public License for more details. 00015 00016 You should have received a copy of the GNU Lesser General Public 00017 License along with this library; if not, write to the 00018 Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00019 Boston, MA 02111-1307, SA. 00020 */ 00021 00022 // June 1999 00023 00024 00025 #ifndef _LISTBOX_H 00026 #define _LISTBOX_H 00027 00028 #include <wftk/singlecontainer.h> 00029 #include <wftk/label.h> 00030 00031 #include <map> 00032 00033 namespace wftk { 00034 00035 class Button; 00036 class PushButton; 00037 class Box; 00038 00042 class ListBox : public SingleContainer 00043 { 00044 //OBJECT 00045 00046 public: 00050 ListBox(); 00051 00056 void setColor(const Color& color); 00061 void setSelectedColor(const Color& color); 00062 00068 std::string getSelection() const {return selected_ ? selected_->getText() : "";} 00069 00074 void addElement(const std::string& data ); 00079 void addElements(const std::vector<std::string>& data); 00083 void clear(); 00087 void scrollUp(); 00091 void scrollDown(); 00092 00096 SigC::Signal1<void, const std::string&> selectionChanged; 00097 00102 void setSelected(const std::string& item); 00103 00104 private: 00106 void setSelectedElement(ScreenArea*); 00108 void setSelectedLabel(Label*); 00110 void selected(Button*); 00112 void addElementImpl(const std::string&); 00114 PushButton* scrollUp_; 00116 PushButton* scrollDown_; 00118 Box* buttonBox_; 00120 typedef std::map<std::string,Label*> Elements; 00122 Elements elements_; 00124 bool lock_; 00126 Label* selected_; 00128 Color selectedCol_; 00129 }; 00130 00131 00132 } 00133 00134 #endif // !_LISTBOX_H
This document is licensed under the terms of the GNU Free Documentation License and may be freely distributed under the conditions given by this license.