2005-11-07 04:26:13 +03:00
|
|
|
/*
|
2009-08-27 15:12:41 +04:00
|
|
|
* Copyright 2001-2008, Haiku, Inc. All rights reserved.
|
|
|
|
* Distributed under the terms of the MIT License.
|
2005-11-07 04:26:13 +03:00
|
|
|
*/
|
2002-10-23 17:54:44 +04:00
|
|
|
#ifndef _SCROLL_BAR_H
|
|
|
|
#define _SCROLL_BAR_H
|
|
|
|
|
2006-07-17 23:18:38 +04:00
|
|
|
|
2002-10-23 17:54:44 +04:00
|
|
|
#include <View.h>
|
|
|
|
|
|
|
|
|
2006-07-17 23:18:38 +04:00
|
|
|
#define B_V_SCROLL_BAR_WIDTH 14.0f
|
|
|
|
#define B_H_SCROLL_BAR_HEIGHT 14.0f
|
2002-10-23 17:54:44 +04:00
|
|
|
|
2006-07-17 23:18:38 +04:00
|
|
|
// TODO: shouldn't these be moved into the implementation?
|
2004-10-09 02:36:54 +04:00
|
|
|
#define SCROLL_BAR_MAXIMUM_KNOB_SIZE 50
|
|
|
|
#define SCROLL_BAR_MINIMUM_KNOB_SIZE 9
|
|
|
|
|
2005-11-15 03:23:03 +03:00
|
|
|
#define DISABLES_ON_WINDOW_DEACTIVATION 1
|
|
|
|
|
2002-12-31 02:35:10 +03:00
|
|
|
|
2002-10-23 17:54:44 +04:00
|
|
|
class BScrollBar : public BView {
|
2008-09-11 01:07:32 +04:00
|
|
|
public:
|
2008-09-13 23:20:18 +04:00
|
|
|
BScrollBar(BRect frame, const char* name,
|
|
|
|
BView* target, float min, float max,
|
|
|
|
orientation direction);
|
|
|
|
BScrollBar(const char* name, BView* target,
|
2009-08-27 15:12:41 +04:00
|
|
|
float min, float max,
|
2013-07-09 02:27:55 +04:00
|
|
|
orientation orientation);
|
2009-08-27 15:12:41 +04:00
|
|
|
BScrollBar(BMessage* archive);
|
2008-09-13 23:20:18 +04:00
|
|
|
virtual ~BScrollBar();
|
2009-08-27 15:12:41 +04:00
|
|
|
static BArchivable* Instantiate(BMessage* archive);
|
|
|
|
virtual status_t Archive(BMessage* archive,
|
|
|
|
bool deep = true) const;
|
2008-09-13 23:20:18 +04:00
|
|
|
|
|
|
|
virtual void AttachedToWindow();
|
|
|
|
void SetValue(float value);
|
|
|
|
float Value() const;
|
|
|
|
void SetProportion(float);
|
|
|
|
float Proportion() const;
|
|
|
|
virtual void ValueChanged(float newValue);
|
|
|
|
|
|
|
|
void SetRange(float min, float max);
|
|
|
|
void GetRange(float* _min, float* _max) const;
|
|
|
|
void SetSteps(float smallStep, float largeStep);
|
|
|
|
void GetSteps(float* _smallStep,
|
|
|
|
float* _largeStep) const;
|
|
|
|
void SetTarget(BView *target);
|
|
|
|
void SetTarget(const char* targetName);
|
|
|
|
BView* Target() const;
|
2013-07-09 02:27:55 +04:00
|
|
|
void SetOrientation(orientation orientation);
|
2008-09-13 23:20:18 +04:00
|
|
|
orientation Orientation() const;
|
|
|
|
|
2009-08-27 15:12:41 +04:00
|
|
|
// TODO: Make this a virtual method, it should be one,
|
Implemented a new look for the Haiku interface controls. It was
overheard that they looked too ninety-ish.
TODO: The code behind this is work in progress. The basic idea
is to extract all drawing code into a new class BControlLook,
of which there is a global instance be_control_look, instantiated
in InterfaceDefs.cpp. At the moment, all the old drawing code is
still there, and the usage of be_control_look is inside if-bodies
checking the instance against NULL. In another words, by not
instanitating be_control_look, you can revert back to the old look.
BControlLook's job is to provide reusable methods for drawing
certain types of frames, backgrounds and labels, so that application
developers can make controls that re-use the same drawing code
as built-in controls and adopt to changes made there. I have added
the notion of "borders". Each of the frame drawing methods can be
made to draw certain borders only, which is supposed to help when
controls shall visually attach. This feature is not fully explored
at all ATM.
TODO: Update BColumnListView header view and BStringItem text
spacing. Update other apps where it makes sense to use BControlLook.
For the moment, only Tracker and LaunchBox are updated. More...
NOTE: The new look is not very radically different, so that existing
apps do not immediately look too ugly or out of place.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@29221 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-02-15 21:23:19 +03:00
|
|
|
// but it's not important right now. This is supposed
|
|
|
|
// to be used in case the BScrollBar should draw part of
|
|
|
|
// the focus indication of the target view for aesthetical
|
|
|
|
// reasons. BScrollView will forward this method.
|
|
|
|
status_t SetBorderHighlighted(bool state);
|
|
|
|
|
2008-09-13 23:20:18 +04:00
|
|
|
virtual void MessageReceived(BMessage* message);
|
|
|
|
virtual void MouseDown(BPoint pt);
|
|
|
|
virtual void MouseUp(BPoint pt);
|
|
|
|
virtual void MouseMoved(BPoint pt, uint32 code,
|
|
|
|
const BMessage* dragMessage);
|
|
|
|
virtual void DetachedFromWindow();
|
|
|
|
virtual void Draw(BRect updateRect);
|
|
|
|
virtual void FrameMoved(BPoint new_position);
|
|
|
|
virtual void FrameResized(float newWidth, float newHeight);
|
|
|
|
|
|
|
|
virtual BHandler* ResolveSpecifier(BMessage* message,
|
|
|
|
int32 index, BMessage* specifier,
|
|
|
|
int32 form, const char* property);
|
|
|
|
|
|
|
|
virtual void ResizeToPreferred();
|
2009-08-27 15:12:41 +04:00
|
|
|
virtual void GetPreferredSize(float* _width,
|
|
|
|
float* _height);
|
2008-09-13 23:20:18 +04:00
|
|
|
virtual void MakeFocus(bool state = true);
|
|
|
|
virtual void AllAttached();
|
|
|
|
virtual void AllDetached();
|
|
|
|
virtual status_t GetSupportedSuites(BMessage* data);
|
|
|
|
|
|
|
|
virtual BSize MinSize();
|
|
|
|
virtual BSize MaxSize();
|
|
|
|
virtual BSize PreferredSize();
|
|
|
|
|
|
|
|
virtual status_t Perform(perform_code d, void* arg);
|
2002-10-23 17:54:44 +04:00
|
|
|
|
2005-11-15 03:23:03 +03:00
|
|
|
#if DISABLES_ON_WINDOW_DEACTIVATION
|
2008-09-13 23:20:18 +04:00
|
|
|
virtual void WindowActivated(bool active);
|
2005-11-15 03:23:03 +03:00
|
|
|
#endif
|
|
|
|
|
2008-09-13 23:20:18 +04:00
|
|
|
private:
|
|
|
|
class Private;
|
|
|
|
friend class Private;
|
|
|
|
|
|
|
|
friend status_t control_scrollbar(scroll_bar_info* info,
|
|
|
|
BScrollBar *bar);
|
|
|
|
// for use within the preflet
|
|
|
|
|
|
|
|
virtual void _ReservedScrollBar1();
|
|
|
|
virtual void _ReservedScrollBar2();
|
|
|
|
virtual void _ReservedScrollBar3();
|
|
|
|
virtual void _ReservedScrollBar4();
|
|
|
|
|
|
|
|
// disabled
|
|
|
|
BScrollBar& operator=(const BScrollBar& other);
|
|
|
|
|
|
|
|
bool _DoubleArrows() const;
|
|
|
|
void _UpdateThumbFrame();
|
|
|
|
float _ValueFor(BPoint where) const;
|
|
|
|
int32 _ButtonFor(BPoint where) const;
|
|
|
|
BRect _ButtonRectFor(int32 button) const;
|
|
|
|
void _UpdateTargetValue(BPoint where);
|
|
|
|
void _UpdateArrowButtons();
|
|
|
|
void _DrawDisabledBackground(BRect area,
|
|
|
|
const rgb_color& light,
|
|
|
|
const rgb_color& dark,
|
|
|
|
const rgb_color& fill);
|
|
|
|
void _DrawArrowButton(int32 direction,
|
|
|
|
bool doubleArrows, BRect frame,
|
|
|
|
const BRect& updateRect,
|
|
|
|
bool enabled, bool down);
|
|
|
|
|
|
|
|
BSize _MinSize() const;
|
|
|
|
|
2009-08-27 15:12:41 +04:00
|
|
|
private:
|
2008-09-13 23:20:18 +04:00
|
|
|
float fMin;
|
|
|
|
float fMax;
|
|
|
|
float fSmallStep;
|
|
|
|
float fLargeStep;
|
|
|
|
float fValue;
|
|
|
|
float fProportion;
|
|
|
|
BView* fTarget;
|
|
|
|
orientation fOrientation;
|
|
|
|
char* fTargetName;
|
|
|
|
|
|
|
|
Private* fPrivateData;
|
|
|
|
|
|
|
|
uint32 _reserved[3];
|
2002-10-23 17:54:44 +04:00
|
|
|
};
|
|
|
|
|
2006-07-17 23:18:38 +04:00
|
|
|
#endif // _SCROLL_BAR_H
|