2 * Copyright 2001-2008, Haiku, Inc. All rights reserved.
3 * Distributed under the terms of the MIT License.
12 #define B_V_SCROLL_BAR_WIDTH 14.0f
13 #define B_H_SCROLL_BAR_HEIGHT 14.0f
15 // TODO: shouldn't these be moved into the implementation?
16 #define SCROLL_BAR_MAXIMUM_KNOB_SIZE 50
17 #define SCROLL_BAR_MINIMUM_KNOB_SIZE 9
19 #define DISABLES_ON_WINDOW_DEACTIVATION 1
22 class BScrollBar
: public BView
{
24 BScrollBar(BRect frame
, const char* name
,
25 BView
* target
, float min
, float max
,
26 orientation direction
);
27 BScrollBar(const char* name
, BView
* target
,
29 orientation orientation
);
30 BScrollBar(BMessage
* archive
);
31 virtual ~BScrollBar();
32 static BArchivable
* Instantiate(BMessage
* archive
);
33 virtual status_t
Archive(BMessage
* archive
,
34 bool deep
= true) const;
36 virtual void AllAttached();
37 virtual void AllDetached();
39 virtual void AttachedToWindow();
40 virtual void DetachedFromWindow();
42 virtual void Draw(BRect updateRect
);
43 virtual void FrameMoved(BPoint new_position
);
44 virtual void FrameResized(float newWidth
, float newHeight
);
46 virtual void MessageReceived(BMessage
* message
);
48 virtual void MouseDown(BPoint where
);
49 virtual void MouseUp(BPoint where
);
50 virtual void MouseMoved(BPoint where
, uint32 code
,
51 const BMessage
* dragMessage
);
53 #if DISABLES_ON_WINDOW_DEACTIVATION
54 virtual void WindowActivated(bool active
);
57 void SetValue(float value
);
60 void SetProportion(float);
61 float Proportion() const;
63 virtual void ValueChanged(float newValue
);
65 void SetRange(float min
, float max
);
66 void GetRange(float* _min
, float* _max
) const;
67 void SetSteps(float smallStep
, float largeStep
);
68 void GetSteps(float* _smallStep
,
69 float* _largeStep
) const;
71 void SetTarget(BView
*target
);
72 void SetTarget(const char* targetName
);
73 BView
* Target() const;
75 void SetOrientation(orientation direction
);
76 orientation
Orientation() const;
78 // TODO: Make this a virtual method, it should be one,
79 // but it's not important right now. This is supposed
80 // to be used in case the BScrollBar should draw part of
81 // the focus indication of the target view for aesthetical
82 // reasons. BScrollView will forward this method.
83 status_t
SetBorderHighlighted(bool highlight
);
85 virtual void GetPreferredSize(float* _width
,
87 virtual void ResizeToPreferred();
88 virtual void MakeFocus(bool focus
= true);
90 virtual BSize
MinSize();
91 virtual BSize
MaxSize();
92 virtual BSize
PreferredSize();
94 virtual status_t
GetSupportedSuites(BMessage
* message
);
95 virtual BHandler
* ResolveSpecifier(BMessage
* message
,
96 int32 index
, BMessage
* specifier
,
97 int32 what
, const char* property
);
99 virtual status_t
Perform(perform_code d
, void* arg
);
103 friend class Private
;
105 friend status_t
control_scrollbar(scroll_bar_info
* info
,
107 // for use within the preflet
109 virtual void _ReservedScrollBar1();
110 virtual void _ReservedScrollBar2();
111 virtual void _ReservedScrollBar3();
112 virtual void _ReservedScrollBar4();
115 BScrollBar
& operator=(const BScrollBar
& other
);
117 bool _DoubleArrows() const;
118 void _UpdateThumbFrame();
119 float _ValueFor(BPoint where
) const;
120 int32
_ButtonFor(BPoint where
) const;
121 BRect
_ButtonRectFor(int32 button
) const;
122 void _UpdateTargetValue(BPoint where
);
123 void _UpdateArrowButtons();
124 void _DrawDisabledBackground(BRect area
,
125 const rgb_color
& light
,
126 const rgb_color
& dark
,
127 const rgb_color
& fill
);
128 void _DrawArrowButton(int32 direction
,
129 bool doubleArrows
, BRect frame
,
130 const BRect
& updateRect
,
131 bool enabled
, bool down
);
133 BSize
_MinSize() const;
143 orientation fOrientation
;
145 Private
* fPrivateData
;
150 #endif // _SCROLL_BAR_H