1 //------------------------------------------------------------------------------ 2 // Copyright (c) 2001-2002, OpenBeOS 3 // 4 // Permission is hereby granted, free of charge, to any person obtaining a 5 // copy of this software and associated documentation files (the "Software"), 6 // to deal in the Software without restriction, including without limitation 7 // the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 // and/or sell copies of the Software, and to permit persons to whom the 9 // Software is furnished to do so, subject to the following conditions: 10 // 11 // The above copyright notice and this permission notice shall be included in 12 // all copies or substantial portions of the Software. 13 // 14 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 19 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 20 // DEALINGS IN THE SOFTWARE. 21 // 22 // File Name: ScrollBar.h 23 // Author: Marc Flerackers (mflerackers@androme.be) 24 // DarkWyrm (bpmagic@columbus.rr.com) 25 // Description: Client-side class for scrolling 26 // 27 //------------------------------------------------------------------------------ 28 #ifndef _SCROLL_BAR_H 29 #define _SCROLL_BAR_H 30 31 #include <BeBuild.h> 32 #include <View.h> 33 34 //---------------------------------------------------------------- 35 //----- scroll bar defines --------------------------------------- 36 37 #define B_V_SCROLL_BAR_WIDTH 14.0 38 #define B_H_SCROLL_BAR_HEIGHT 14.0 39 40 #define SCROLL_BAR_MAXIMUM_KNOB_SIZE 50 41 #define SCROLL_BAR_MINIMUM_KNOB_SIZE 9 42 43 //---------------------------------------------------------------- 44 //----- BScrollBar class ----------------------------------------- 45 46 class BScrollArrowButton; 47 class BScrollBarPrivateData; 48 49 class BScrollBar : public BView { 50 51 public: 52 BScrollBar( BRect frame, 53 const char *name, 54 BView *target, 55 float min, 56 float max, 57 orientation direction); 58 BScrollBar(BMessage *data); 59 virtual ~BScrollBar(); 60 static BArchivable *Instantiate(BMessage *data); 61 virtual status_t Archive(BMessage *data, bool deep = true) const; 62 63 virtual void AttachedToWindow(); 64 void SetValue(float value); 65 float Value() const; 66 void SetProportion(float); 67 float Proportion() const; 68 virtual void ValueChanged(float newValue); 69 70 void SetRange(float min, float max); 71 void GetRange(float *min, float *max) const; 72 void SetSteps(float smallStep, float largeStep); 73 void GetSteps(float *smallStep, float *largeStep) const; 74 void SetTarget(BView *target); 75 void SetTarget(const char *targetName); 76 BView *Target() const; 77 orientation Orientation() const; 78 79 virtual void MessageReceived(BMessage *msg); 80 virtual void MouseDown(BPoint pt); 81 virtual void MouseUp(BPoint pt); 82 virtual void MouseMoved(BPoint pt, uint32 code, const BMessage *msg); 83 virtual void DetachedFromWindow(); 84 virtual void Draw(BRect updateRect); 85 virtual void FrameMoved(BPoint new_position); 86 virtual void FrameResized(float new_width, float new_height); 87 88 virtual BHandler *ResolveSpecifier(BMessage *msg, 89 int32 index, 90 BMessage *specifier, 91 int32 form, 92 const char *property); 93 94 virtual void ResizeToPreferred(); 95 virtual void GetPreferredSize(float *width, float *height); 96 virtual void MakeFocus(bool state = true); 97 virtual void AllAttached(); 98 virtual void AllDetached(); 99 virtual status_t GetSupportedSuites(BMessage *data); 100 101 102 //----- Private or reserved ----------------------------------------- 103 virtual status_t Perform(perform_code d, void *arg); 104 105 private: 106 friend class BScrollArrowButton; 107 friend class BScrollBarPrivateData; 108 friend status_t control_scrollbar(scroll_bar_info *info, BScrollBar *bar); // for use within the preflet 109 friend status_t scroll_by_value(float valueByWhichToScroll, BScrollBar *bar); // for use here within the IK 110 virtual void _ReservedScrollBar1(); 111 virtual void _ReservedScrollBar2(); 112 virtual void _ReservedScrollBar3(); 113 virtual void _ReservedScrollBar4(); 114 115 BScrollBar &operator=(const BScrollBar &); 116 void DoScroll(float delta); 117 118 void InitObject(float min, float max, orientation o, BView *t); 119 float fMin; 120 float fMax; 121 float fSmallStep; 122 float fLargeStep; 123 float fValue; 124 float fProportion; 125 BView* fTarget; 126 orientation fOrientation; 127 char *fTargetName; 128 129 BScrollBarPrivateData *privatedata; 130 131 uint32 _reserved[3]; 132 }; 133 134 //------------------------------------------------------------- 135 //------------------------------------------------------------- 136 137 #endif // _SCROLL_BAR_H 138