1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
|
/*
ParaGUI - crossplatform widgetset
Copyright (C) 2000,2001,2002 Alexander Pipelka
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; if not, write to the Free
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Alexander Pipelka
pipelka@teleweb.at
Last Update: $Author: mbickel $
Update Date: $Date: 2009-04-18 13:48:39 $
Source File: $Source: /home/cvspsrv/cvsroot/games/asc/source/libs/paragui/include/pgspinnerbox.h,v $
CVS/RCS Revision: $Revision: 1.3 $
Status: $State: Exp $
*/
/** \file pgspinnerbox.h
Header file for the PG_SpinnerBox class.
*/
#ifndef PG_SPINNERBOX_H
#define PG_SPINNERBOX_H
#include "pgthemewidget.h"
class PG_Button;
class PG_MaskEdit;
class PG_LineEdit;
/**
* @author Atani - Mike Dunston
*
* @short PG_SpinnerBox creates a textbox with attached increase/decrease buttons to control the numeric value.
*
* PG_SpinnerBox creates a textbox with attached increase/decrease buttons to
* control the numeric value. Many convenience methods are available...
* SetValue, SetMinValue, SetMaxValue, SetMask
* GetValue, GetMinValue, GetMaxValue, GetMask
*
* Registerable Events:
*
* MSG_SPINNER_CHANGE -
*
* Fired when the user clicks either up or down on the spinner buttons.
* Currently typed modifications are not populated to the value. This will be
* added soon. Note: using SetValue above will fire this event.
*/
class DECLSPEC PG_SpinnerBox : public PG_ThemeWidget {
public:
/**
Signal type declaration
**/
template<class datatype>
class SignalChange : public PG_Signal2<PG_SpinnerBox*, datatype> {}
;
enum {
IDSPINNERBOX_UP = PG_WIDGETID_INTERNAL + 12,
IDSPINNERBOX_DOWN = PG_WIDGETID_INTERNAL + 13
};
/**
*/
PG_SpinnerBox(PG_Widget *parent, const PG_Rect& r = PG_Rect::null, const std::string& style = "SpinnerBox");
void SetValue(int value) {
m_iValue = value;
SetTextValue();
}
void SetMinValue( int value ) {
m_iMinValue = value;
}
void SetMaxValue( int value ) {
m_iMaxValue = value;
}
void SetMask( const std::string& value );
int GetValue() {
return( m_iValue );
}
int GetMinValue() {
return( m_iMinValue );
}
int GetMaxValue() {
return( m_iMaxValue );
}
const PG_String& GetMask() {
return( m_sMask );
}
SignalChange<int> sigChange;
protected:
bool handleButtonClick(PG_Button* button);
bool handleEditEnd(PG_LineEdit* edit);
private:
DLLLOCAL void SetTextValue();
DLLLOCAL void AdjustSize();
PG_Widget* m_pParent;
PG_MaskEdit* m_pEditBox;
PG_Button* m_pButtonUp;
PG_Button* m_pButtonDown;
int m_iMinValue;
int m_iMaxValue;
int m_iValue;
PG_String m_sMask;
};
#endif // PG_SPINNERBOX_H
|