Planeshift

pawsspinbox.h

Go to the documentation of this file.
00001 /*
00002  * pawsspinbox.h
00003  *
00004  * Copyright (C) 2003 Atomic Blue ([email protected], http://www.atomicblue.org)
00005  *
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation (version 2 of the License)
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  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00017  *
00018  */
00019 #ifndef PAWS_SPINBOX_HEADER
00020 #define PAWS_SPINBOX_HEADER
00021 
00022 
00023 #include "pawstextbox.h"
00024 #include "pawsbutton.h"
00025 #include <csutil/timer.h>
00026 
00027 
00032 #define SPIN_INTERVAL        100
00033 #define SPIN_START_DELAY     500
00034 
00035 #define SPIN_STOP   0
00036 #define SPIN_UP     1
00037 #define SPIN_DOWN   2
00038 
00039 struct SpinBoxTimerEvent;
00040 
00056 class pawsSpinBox : public pawsWidget
00057 {
00058 public:
00059     pawsSpinBox();
00060     virtual ~pawsSpinBox();
00061     pawsSpinBox(const pawsSpinBox &origin);
00062 
00063     virtual bool Setup(iDocumentNode* node);
00064     virtual bool ManualSetup(csString &value, float Min, float Max, float Inc, csString &pos);
00065     virtual void SetRange(float Min, float Max, float Inc);
00066 
00067     virtual void SetValue(float value);
00068     virtual float GetValue();
00069 
00070     virtual bool OnButtonPressed(int mouseButton, int keyModifier, pawsWidget* widget);
00071     virtual bool OnButtonReleased(int button, int keyModifier, pawsWidget* widget);
00072 
00073     virtual void OnLostFocus();
00074 
00075     virtual bool Perform(iTimerEvent* ev);
00076     virtual void Spin();
00077 
00078 private:
00079     csRef<iEventTimer>    globalTimer;
00080     SpinBoxTimerEvent*    timerEvent;
00081 
00082     int spinCounter;
00083     int spinState;
00084 
00085     pawsButton* upButton;
00086     pawsButton* downButton;
00087     pawsEditTextBox* text;
00088 
00089     float max;
00090     float min;
00091     float inc;
00092 };
00093 CREATE_PAWS_FACTORY(pawsSpinBox);
00094 
00097 #endif