listbox.h

00001 /*--License:
00002         Kyra Sprite Engine
00003         Copyright Lee Thomason (Grinning Lizard Software) 2001-2005
00004         www.grinninglizard.com/kyra
00005         www.sourceforge.net/projects/kyra
00006 
00007         Kyra is provided under the LGPL. 
00008         
00009         I kindly request you display a splash screen (provided in the HTML documentation)
00010         to promote Kyra and acknowledge the software and everyone who has contributed to it, 
00011         but it is not required by the license.
00012 
00013 --- LGPL License --
00014 
00015     This library is free software; you can redistribute it and/or
00016     modify it under the terms of the GNU Lesser General Public
00017     License as published by the Free Software Foundation; either
00018     version 2.1 of the License, or (at your option) any later version.
00019 
00020     This library is distributed in the hope that it will be useful,
00021     but WITHOUT ANY WARRANTY; without even the implied warranty of
00022     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00023     Lesser General Public License for more details.
00024 
00025     You should have received a copy of the GNU Lesser General Public
00026     License along with this library; if not, write to the Free Software
00027     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00028 
00029         The full text of the license can be found in lgpl.txt
00030 */
00031 
00032 #ifndef KYRA_SCROLLBOX_INCLUDED
00033 #define KYRA_SCROLLBOX_INCLUDED
00034 
00035 #ifdef _MSC_VER
00036 // Disable the no-exception handling warning.
00037 #pragma warning( disable : 4530 )
00038 #pragma warning( disable : 4786 )
00039 #endif
00040 
00041 #include "widget.h"
00042 class KrTextWidget;
00043 
00044 
00052 class KrListBox : public KrWidget
00053 {
00054   public:
00062         KrListBox(      int width, int height, 
00063                                 const KrScheme& scheme, 
00064                                 bool drawBorder );
00065 
00066         virtual ~KrListBox();
00067 
00068         virtual const char* WidgetType() { return "ListBox"; }
00069 
00071         int NumItems()                                                                  { return textStrings.size(); }
00073         int SelectedItem()                                                              { return selectedItem; }
00075         std::string SelectedItemText()                                  { if ( selectedItem >= 0 && selectedItem < (int)textStrings.size() )
00076                                                                                                                 return textStrings[selectedItem];
00077                                                                                                           else
00078                                                                                                                 return "";
00079                                                                                                         }
00080 
00082         int AddTextChar( const std::string& text );
00084         void GetTextChar( int index, std::string* text );
00086         void MoveSelection( int delta );
00088         void MoveUpOne()        { MoveSelection( -1 ); }
00090         void MoveDownOne()      { MoveSelection( 1 ); }
00091 
00092         virtual bool HandleWidgetEvent( KrWidget* source, const KrWidgetEvent& event );
00093 
00094         // Used to initialize the widget.
00095         virtual void AddedtoTree();
00096 
00097   private:
00098         void DrawText();
00099         void ItemSelected( KrWidget* source );
00100 
00101         int width, height;
00102 //      KrFontResource* font;
00103         KrBevelElement  *outerBevel;
00104 
00105         std::vector< KrTextWidget* > textWidgets;
00106         std::vector< std::string >   textStrings;
00107 
00108         int firstItem;
00109         int selectedItem;
00110 };
00111 
00112 
00113 
00114 #endif
00115 

Generated on Thu Jul 20 20:45:32 2006 for Kyra by  doxygen 1.4.7