00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef SLIDER_H
00019 #define SLIDER_H
00020
00021 #include "../constants.h"
00022 #include "widget.h"
00023 #include "label.h"
00024
00029 class Slider : public Widget {
00030 private:
00031 int x2;
00032 int minValue, maxValue;
00033 Label *label;
00034 bool inside;
00035 bool dragging;
00036 int pos;
00037 float alpha, alphaInc;
00038 GLint lastTick;
00039 GLuint highlight;
00040
00041 public:
00042
00043 Slider(int x1, int y1, int x2, GLuint highlight, int minValue=0, int maxValue=100, char *label=NULL);
00044 ~Slider();
00045 bool handleEvent(Widget *parent, SDL_Event *event, int x, int y);
00046 void removeEffects(Widget *parent);
00047 void drawWidget(Widget *parent);
00048
00049 inline int getValue() {
00050 return (int)((float)(pos * (maxValue - minValue)) / (float)getWidth());
00051 }
00052
00053 void setValue(int n);
00054
00055 inline int getStep() {
00056 return (int)((float)getWidth() / (float)(maxValue - minValue));
00057 }
00058
00059
00060 virtual inline bool hasSound() { return false; }
00061
00062 };
00063
00064 #endif
00065