QGUINumberSelector.hh
Go to the documentation of this file.00001
00002 #ifndef _QGUI_NUMBER_SELECTOR_HH
00003 #define _QGUI_NUMBER_SELECTOR_HH
00004
00005
00006
00007 #include "TGFrame.h"
00008 #include "TGNumberEntry.h"
00009 #include "QCuore.hh"
00010
00011
00012 #include "Rtypes.h"
00013 #include "TTimer.h"
00014 #include "TQObject.h"
00015
00016
00017 #include <iostream>
00018 #include <vector>
00019 #include <set>
00020
00021 class TGTextButton;
00022 class TGTextEntry;
00023
00040 class QGUINumberSelector: public TQObject
00041 {
00042 public:
00043
00049 QGUINumberSelector(const std::vector<int>& validNumbers);
00050
00051
00062 QGUINumberSelector(const std::vector<unsigned int>& validNumbers);
00063
00064
00066 virtual ~QGUINumberSelector();
00067
00069 const std::set<int>& GetValues() const { return fValidNumbers; }
00070
00072 inline int GetCurrent() const { return fCurrent; }
00073
00075 void SetCurrent(int value);
00076
00077
00081 void HandleValueSet();
00082
00088 void UpdateCurrentNumber();
00089
00091 void Loaded() {Emit("Loaded()");}
00093 void Changed() {Emit("Changed()");}
00094
00096 TGNumberEntry* GetSelector(const TGWindow* parent);
00098 TGTextEntry* GetDisplay(const TGWindow* parent);
00099
00107 void SetState(bool state);
00108
00110 void Set(const std::vector<int>& values);
00112 void Set(const std::vector<unsigned int>& values);
00114 void Set(const std::set<int>& values);
00116 void Set(const std::set<unsigned int>& values);
00117
00118 protected:
00119
00120
00121 private:
00122
00124 enum QDirection_t
00125 {
00126 QUP =true,
00127 QDOWN=false
00128 };
00129
00130
00131 std::set<int> fValidNumbers;
00132
00133
00134 int fPrevious;
00135 int fCurrent;
00137
00138 TTimer fTimer;
00139
00140 TGNumberEntry *fSelector;
00141 TGTextEntry *fLoadText;
00144 inline int GetSelected() const {return (int)(fSelector->GetNumber());}
00145
00151 bool IsValid(int value) const;
00152
00159 int GetNextValid(int current, QDirection_t dir) const;
00160
00162 int GetFirstValid() const;
00163
00165 int GetLastValid() const;
00166
00167 void Init();
00168
00169 void StartTimer();
00170
00171 ClassDef(QGUINumberSelector,0)
00172 };
00173
00174 #endif // _QGUI_NUMBER_SELECTOR_HH