1 /* 2 * Copyright (c) 2001-2005, Haiku, Inc. 3 * Distributed under the terms of the MIT license. 4 * 5 * Authors: 6 * Marc Flerackers (mflerackers@androme.be) 7 * DarkWyrm (bpmagic@columbus.rr.com) 8 * Stefano Ceccherini (burton666@libero.it) 9 * Stephan Aßmus <superstippi@gmx.de> 10 */ 11 12 #ifndef _SCROLL_BAR_H 13 #define _SCROLL_BAR_H 14 15 #include <BeBuild.h> 16 #include <View.h> 17 18 //---------------------------------------------------------------- 19 //----- scroll bar defines --------------------------------------- 20 21 #define B_V_SCROLL_BAR_WIDTH 14.0 22 #define B_H_SCROLL_BAR_HEIGHT 14.0 23 24 #define SCROLL_BAR_MAXIMUM_KNOB_SIZE 50 25 #define SCROLL_BAR_MINIMUM_KNOB_SIZE 9 26 27 #define DISABLES_ON_WINDOW_DEACTIVATION 1 28 29 //---------------------------------------------------------------- 30 //----- BScrollBar class ----------------------------------------- 31 32 class BScrollBar : public BView { 33 34 public: 35 BScrollBar( BRect frame, 36 const char *name, 37 BView *target, 38 float min, 39 float max, 40 orientation direction); 41 BScrollBar(BMessage *data); 42 virtual ~BScrollBar(); 43 static BArchivable *Instantiate(BMessage *data); 44 virtual status_t Archive(BMessage *data, bool deep = true) const; 45 46 virtual void AttachedToWindow(); 47 void SetValue(float value); 48 float Value() const; 49 void SetProportion(float); 50 float Proportion() const; 51 virtual void ValueChanged(float newValue); 52 53 void SetRange(float min, float max); 54 void GetRange(float *min, float *max) const; 55 void SetSteps(float smallStep, float largeStep); 56 void GetSteps(float *smallStep, float *largeStep) const; 57 void SetTarget(BView *target); 58 void SetTarget(const char *targetName); 59 BView *Target() const; 60 orientation Orientation() const; 61 62 virtual void MessageReceived(BMessage *msg); 63 virtual void MouseDown(BPoint pt); 64 virtual void MouseUp(BPoint pt); 65 virtual void MouseMoved(BPoint pt, uint32 code, const BMessage *msg); 66 virtual void DetachedFromWindow(); 67 virtual void Draw(BRect updateRect); 68 virtual void FrameMoved(BPoint new_position); 69 virtual void FrameResized(float new_width, float new_height); 70 71 virtual BHandler *ResolveSpecifier(BMessage *msg, 72 int32 index, 73 BMessage *specifier, 74 int32 form, 75 const char *property); 76 77 virtual void ResizeToPreferred(); 78 virtual void GetPreferredSize(float *width, float *height); 79 virtual void MakeFocus(bool state = true); 80 virtual void AllAttached(); 81 virtual void AllDetached(); 82 virtual status_t GetSupportedSuites(BMessage *data); 83 84 85 //----- Private or reserved ----------------------------------------- 86 virtual status_t Perform(perform_code d, void *arg); 87 88 #if DISABLES_ON_WINDOW_DEACTIVATION 89 virtual void WindowActivated(bool active); 90 #endif 91 92 private: 93 class Private; 94 friend class Private; 95 96 friend status_t control_scrollbar(scroll_bar_info *info, BScrollBar *bar); // for use within the preflet 97 98 virtual void _ReservedScrollBar1(); 99 virtual void _ReservedScrollBar2(); 100 virtual void _ReservedScrollBar3(); 101 virtual void _ReservedScrollBar4(); 102 103 BScrollBar &operator=(const BScrollBar &); 104 105 bool _DoubleArrows() const; 106 void _UpdateThumbFrame(); 107 float _ValueFor(BPoint where) const; 108 int32 _ButtonFor(BPoint where) const; 109 BRect _ButtonRectFor(int32 button) const; 110 void _UpdateTargetValue(BPoint where); 111 void _UpdateArrowButtons(); 112 void _DrawDisabledBackground(BRect area, 113 const rgb_color& light, 114 const rgb_color& dark, 115 const rgb_color& fill); 116 void _DrawArrowButton(int32 direction, 117 bool doubleArrows, 118 BRect frame, 119 const BRect& updateRect, 120 bool enabled, bool down); 121 122 float fMin; 123 float fMax; 124 float fSmallStep; 125 float fLargeStep; 126 float fValue; 127 float fProportion; 128 BView* fTarget; 129 orientation fOrientation; 130 char* fTargetName; 131 132 Private* fPrivateData; 133 134 uint32 _reserved[3]; 135 }; 136 137 //------------------------------------------------------------- 138 //------------------------------------------------------------- 139 140 #endif // _SCROLL_BAR_H 141