DropDownList.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 /* GG is a GUI for SDL and OpenGL.
00003    Copyright (C) 2003 T. Zachary Laine
00004 
00005    This library is free software; you can redistribute it and/or
00006    modify it under the terms of the GNU Lesser General Public License
00007    as published by the Free Software Foundation; either version 2.1
00008    of the License, or (at your option) any later version.
00009    
00010    This library 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 GNU
00013    Lesser General Public License for more details.
00014     
00015    You should have received a copy of the GNU Lesser General Public
00016    License along with this library; if not, write to the Free
00017    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
00018    02111-1307 USA
00019 
00020    If you do not wish to comply with the terms of the LGPL please
00021    contact the author as other terms are available for a fee.
00022     
00023    Zach Laine
00024    whatwasthataddress@hotmail.com */
00025 
00030 #ifndef _GG_DropDownList_h_
00031 #define _GG_DropDownList_h_
00032 
00033 #include <GG/ListBox.h>
00034 
00035 
00036 namespace GG {
00037 
00050 class GG_API DropDownList : public Control
00051 {
00052 public:
00054     typedef ListBox::Row Row;
00055  
00057     typedef boost::signal<void (int)>   SelChangedSignalType;   
00058 
00059  
00061     typedef SelChangedSignalType::slot_type   SelChangedSlotType;  
00062 
00063  
00065 
00066     DropDownList(int x, int y, int w, int h, int drop_ht, Clr color, Flags<WndFlag> flags = CLICKABLE);
00067 
00068     ~DropDownList(); 
00069 
00070  
00072     const Row*     CurrentItem() const;      
00073     int            CurrentItemIndex() const; 
00074 
00075     bool           Empty() const;            
00076     const Row&     GetItem(int n) const;     
00077     bool           Selected(int n) const;    
00078     Clr            InteriorColor() const;    
00079 
00080     int            DropHeight() const; 
00081 
00083     Flags<ListBoxStyle> Style() const;
00084 
00085     int            NumRows() const;          
00086     int            NumCols() const;          
00087 
00090     int            SortCol() const;
00091 
00092     int            ColWidth(int n) const;     
00093     Alignment      ColAlignment(int n) const; 
00094     Alignment      RowAlignment(int n) const; 
00095 
00096     virtual Pt     ClientUpperLeft() const;
00097     virtual Pt     ClientLowerRight() const;
00098 
00099     mutable SelChangedSignalType SelChangedSignal; 
00100 
00101  
00103     virtual void   Render();
00104     virtual void   LClick(const Pt& pt, Flags<ModKey> mod_keys);
00105     virtual void   KeyPress(Key key, Flags<ModKey> mod_keys);
00106 
00107     virtual void   SizeMove(const Pt& ul, const Pt& lr); 
00108 
00109     virtual void   SetColor(Clr c);
00110 
00111     int            Insert(Row* row, int at = -1); 
00112     Row*           Erase(int idx);                
00113     void           Clear();                       
00114     Row&           GetRow(int n);                 
00115 
00116     void           Select(int row);               
00117 
00118     void           SetInteriorColor(Clr c);       
00119     void           SetDropHeight(int h);          
00120 
00122     void           SetStyle(Flags<ListBoxStyle> s);
00123 
00124     void           SetNumCols(int n);         
00125     void           SetSortCol(int n);         
00126     void           SetColWidth(int n, int w); 
00127 
00130     void           LockColWidths();
00131 
00133     void           UnLockColWidths();
00134 
00135     void           SetColAlignment(int n, Alignment align); 
00136     void           SetRowAlignment(int n, Alignment align); 
00137 
00138     virtual void   DefineAttributes(WndEditor* editor);
00140 
00141 protected: 
00143     DropDownList(); 
00144 
00145  
00147     ListBox*       LB();                
00148 
00149 
00150 private:
00151     int            m_current_item_idx;  
00152     ListBox*       m_LB;                
00153 
00154     friend class boost::serialization::access;
00155     template <class Archive>
00156     void serialize(Archive& ar, const unsigned int version);
00157 };
00158 
00159 } // namespace GG
00160 
00161 // template implementations
00162 template <class Archive>
00163 void GG::DropDownList::serialize(Archive& ar, const unsigned int version)
00164 {
00165     ar  & BOOST_SERIALIZATION_BASE_OBJECT_NVP(Control)
00166         & BOOST_SERIALIZATION_NVP(m_current_item_idx)
00167         & BOOST_SERIALIZATION_NVP(m_LB);
00168 }
00169 
00170 #endif // _GG_DropDownList_h_

Generated on Wed Mar 26 14:35:41 2008 for GG by  doxygen 1.5.2