1 /* 2 * Copyright © 2006-2009 Stephan Aßmus <superstippi@gmx.de> 3 * All rights reserved. Distributed under the terms of the MIT License. 4 */ 5 #ifndef SEEK_SLIDER_H 6 #define SEEK_SLIDER_H 7 8 9 #include <Box.h> 10 #include <Control.h> 11 #include <String.h> 12 13 14 class SeekSlider : public BControl { 15 public: 16 SeekSlider(BRect frame, 17 const char* name, BMessage* message, 18 int32 minValue, int32 maxValue); 19 20 virtual ~SeekSlider(); 21 22 // BControl interface 23 virtual void AttachedToWindow(); 24 virtual void SetValue(int32 value); 25 virtual void Draw(BRect updateRect); 26 virtual void MouseDown(BPoint where); 27 virtual void MouseMoved(BPoint where, uint32 transit, 28 const BMessage* dragMessage); 29 virtual void MouseUp(BPoint where); 30 virtual void ResizeToPreferred(); 31 virtual void FrameResized(float width, float height); 32 33 // SeekSlider 34 void SetPosition(float position); 35 float Position() const; 36 bool IsTracking() const; 37 void SetDisabledString(const char* string); 38 39 private: 40 int32 _ValueFor(float x) const; 41 int32 _KnobPosFor(BRect bounds, 42 int32 value) const; 43 void _StrokeFrame(BRect frame, 44 rgb_color left, rgb_color top, 45 rgb_color right, rgb_color bottom); 46 void _SetKnobPosition(int32 knobPos); 47 48 private: 49 bool fTracking; 50 bigtime_t fLastTrackTime; 51 int32 fKnobPos; 52 int32 fMinValue; 53 int32 fMaxValue; 54 55 BString fDisabledString; 56 }; 57 58 59 #endif //SEEK_SLIDER_H 60