1 /* 2 * Copyright 2006, Haiku. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Stephan Aßmus <superstippi@gmx.de> 7 * Ingo Weinhold <bonefish@cs.tu-berlin.de> 8 */ 9 10 #ifndef SLIDER_VIEW_H 11 #define SLIDER_VIEW_H 12 13 #include <String.h> 14 15 #include "PopupView.h" 16 17 class BFont; 18 class PopupSlider; 19 20 class SliderView : public PopupView { 21 public: 22 SliderView(PopupSlider* target, 23 int32 min, 24 int32 max, 25 int32 value, 26 const char* formatString); 27 virtual ~SliderView(); 28 29 // MView 30 virtual minimax layoutprefs(); 31 virtual BRect layout(BRect frame); 32 33 // BView 34 virtual void Draw(BRect updateRect); 35 virtual void MouseMoved(BPoint where, uint32 transit, 36 const BMessage* message); 37 virtual void MouseUp(BPoint where); 38 39 // BHandler 40 virtual void MessageReceived(BMessage* message); 41 42 // SliderView 43 void SetValue(int32 value); 44 int32 Value() const; 45 void SetMin(int32 min); 46 int32 Min() const; 47 void SetMax(int32 max); 48 int32 Max() const; 49 50 void SetFormatString(const char* formatString); 51 const char* FormatString() const; 52 53 void SetDragOffset(float offset); 54 55 float ButtonOffset(); 56 57 static void GetSliderButtonDimensions(int32 max, 58 const char* formatString, 59 BFont* font, 60 float& width, 61 float& height); 62 static void DrawSliderButton(BView* into, BRect frame, 63 int32 value, 64 const char* formatString, 65 bool enabled); 66 67 68 private: 69 int32 _ValueAt(float h); 70 71 PopupSlider* fTarget; 72 BString fFormatString; 73 74 int32 fMin; 75 int32 fMax; 76 int32 fValue; 77 78 BRect fButtonRect; 79 float fDragOffset; 80 }; 81 82 83 #endif // SLIDER_VIEW_H 84