guiupdown.h

Go to the documentation of this file.
00001 /********************************************************************************/
00002 /*                                                                              */
00003 /*  Netrinjo-Engine - a library for game-development                            */
00004 /*  Copyright (C) 1999, 2000, 2005 by Tobias Nadler und Georg Schnattinger      */
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 Free Software         */
00018 /*  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA   */
00019 /*                                                                              */
00020 /********************************************************************************/
00021 
00022 #ifndef GUIUPDOWN_H
00023 #define GUIUPDOWN_H
00024 
00025 #include "guibackground.h"
00026 #include "guitext.h"
00027 #include "guidynamicbutton.h"
00028 
00040 class DECLSPEC GuiUpDown : public GuiPictureBg
00041 {
00042 public:
00043     DECLSPEC GuiUpDown( const SDL_Rect &r, GuiElement *el, const char *name, int val = 0, bool usetheme = true );
00052     DECLSPEC GuiUpDown(TiXmlElement *el, GuiElement *p);
00053     virtual DECLSPEC ~GuiUpDown();
00054 
00055     virtual const char *getClassName()  { return "GuiUpDown"; }
00056     
00057     void setCallback( Callback c )      { cb.func = c; }
00058     void setCallbackData( BasicObject* d )  { cb.obj = d; }
00059     DECLSPEC void setValue( int v );
00060     DECLSPEC void setMinMax( int min, int max );
00061     void chooseFont( GuiText::FontSize size, bool light )   { text->chooseFont( size, light ); }
00062     DECLSPEC int getValue();
00063 
00064     DECLSPEC int operator ++();
00065     DECLSPEC int operator --();
00066     DECLSPEC int operator +=(int i);
00067     DECLSPEC int operator -=(int i);
00068 
00069     int increment;
00070 
00071     static void newguiobject(void *presult, BasicObject *o, void *xmldata)
00072     {
00073         GuiElement *r = new GuiUpDown((TiXmlElement*)xmldata, (GuiElement*)o);
00074         *(GuiElement**)presult = r;
00075     }
00076 protected:
00077     virtual DECLSPEC Uint32 onRelease();
00078     virtual DECLSPEC Uint32 onResize();
00079     virtual DECLSPEC void onInit();
00080     virtual DECLSPEC Uint32 onThemeChanged( UiTheme *t );
00081 
00082 private:
00083     void refresh();
00084     void arrange();
00085     void onButton( GuiClickableBtn * button );
00086 
00087     FunctionData cb;
00088     int value;
00089     int min, max;
00090     GuiClickableBtn * up;
00091     GuiClickableBtn * down;
00092     GuiTextInput * text;
00093 
00094     bool bThemeBtns;
00095 
00096     static inline void onUdBtn( void * btn, BasicObject *reciever, void * )
00097     {
00098         ((GuiUpDown*)reciever )->onButton( (GuiClickableBtn*)btn );
00099     }
00100     static inline void onText( void*, BasicObject *reciever, void * )
00101     {
00102         ((GuiUpDown*)reciever )->onRelease();
00103     }
00104 };
00105 
00106 #endif

Generated on Wed May 9 17:35:55 2007 for netrinjo by  doxygen 1.5.1