Back to index

extremetuxracer  0.5beta
listbox.h
Go to the documentation of this file.
00001 /* 
00002  * PPRacer 
00003  * Copyright (C) 2004-2005 Volker Stroebel <volker@planetpenguin.de>
00004  *
00005  * This program is free software; you can redistribute it and/or
00006  * modify it under the terms of the GNU General Public License
00007  * as published by the Free Software Foundation; either version 2
00008  * of the License, or (at your option) any later version.
00009  * 
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013  * GNU General Public License for more details.
00014  * 
00015  * You should have received a copy of the GNU General Public License
00016  * along with this program; if not, write to the Free Software
00017  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00018  */
00019 
00020 #ifndef LISTBOX_H
00021 #define LISTBOX_H
00022 
00023 #include "widget.h"
00024 #include "button.h"
00025 
00026 #include <list>
00027 
00028 namespace pp {
00029 
00030 
00031 template <class T>
00032 class Listbox : public Widget {
00033        double m_arrowWidth;
00034     double m_borderWidth;
00035     double m_textPad;
00036     double m_arrowVertSeparation;
00037 
00038        pp::Font *mp_font;
00039        pp::Font *mp_insensitiveFont;
00040        
00041     pp::Color m_borderColor;
00042     pp::Color m_backgroundColor;
00043     pp::Button *mp_upButton;
00044     pp::Button *mp_downButton;
00045        
00046        typedef typename std::list<T> listType_t;
00047        typedef typename std::list<T>::iterator listIterator_t; 
00048        
00049        listType_t& m_items;
00050        listIterator_t mi_curItem;
00051        
00052        void updateButtonEnabledStates();
00053        void updateButtonPositions();
00054 
00055 public:
00056        Listbox( pp::Vec2d pos, pp::Vec2d size, 
00057                         const char *binding, listType_t& itemList);   
00058        ~Listbox();
00059 
00060        void setPosition(pp::Vec2d pos);
00061        void setCurrentItem( listIterator_t item );
00062        listIterator_t getCurrentItem(){return mi_curItem;};
00063        void setItemList( listType_t& itemList );
00064        listType_t& getItemList(){return m_items;};
00065        
00066        void setSensitive(bool sensitive);
00067               
00068        void setInsensitiveFont(const char* binding);
00069 
00070        bool gotoNextItem();
00071        bool gotoPrevItem();
00072        
00073        void upButtonClick();
00074        void downButtonClick();
00075        
00076        void draw();
00077        
00078        //signals
00079        pp::Signal0 signalChange;
00080 };
00081 
00082 } //namespace pp
00083 
00084 #include "listbox.cpp"
00085 
00086 #endif // LISTBOX_H