* Added const version of GetLimits() (the non-const version is still around

for binary compatibility).
* Always round the bar thickness, or we get drawing artefacts.
* Cleaned up the header following our coding style.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30070 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2009-04-09 15:41:10 +00:00
parent 7997389772
commit d9479a6951
2 changed files with 175 additions and 150 deletions
+45 -39
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2001-2006, Haiku.
* Copyright 2001-2009, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
@@ -28,27 +28,33 @@ enum thumb_style {
};
#define USE_OFF_SCREEN_VIEW 1
class BSlider : public BControl {
public:
BSlider(BRect frame, const char *name, const char *label,
BMessage *message, int32 minValue, int32 maxValue,
BSlider(BRect frame, const char* name,
const char* label, BMessage* message,
int32 minValue, int32 maxValue,
thumb_style thumbType = B_BLOCK_THUMB,
uint32 resizingMode = B_FOLLOW_LEFT | B_FOLLOW_TOP,
uint32 flags = B_NAVIGABLE | B_WILL_DRAW | B_FRAME_EVENTS);
uint32 resizingMode
= B_FOLLOW_LEFT | B_FOLLOW_TOP,
uint32 flags = B_NAVIGABLE | B_WILL_DRAW
| B_FRAME_EVENTS);
BSlider(BRect frame, const char *name, const char *label,
BMessage *message, int32 minValue, int32 maxValue,
orientation posture, thumb_style thumbType = B_BLOCK_THUMB,
uint32 resizingMode = B_FOLLOW_LEFT | B_FOLLOW_TOP,
uint32 flags = B_NAVIGABLE | B_WILL_DRAW | B_FRAME_EVENTS);
BSlider(BRect frame, const char* name,
const char* label, BMessage* message,
int32 minValue, int32 maxValue,
orientation posture,
thumb_style thumbType = B_BLOCK_THUMB,
uint32 resizingMode
= B_FOLLOW_LEFT | B_FOLLOW_TOP,
uint32 flags = B_NAVIGABLE | B_WILL_DRAW
| B_FRAME_EVENTS);
BSlider(const char* name, const char* label,
BMessage *message, int32 minValue, int32 maxValue,
orientation posture, thumb_style thumbType = B_BLOCK_THUMB,
uint32 flags = B_NAVIGABLE | B_WILL_DRAW | B_FRAME_EVENTS);
BMessage* message, int32 minValue,
int32 maxValue, orientation posture,
thumb_style thumbType = B_BLOCK_THUMB,
uint32 flags = B_NAVIGABLE | B_WILL_DRAW
| B_FRAME_EVENTS);
BSlider(BMessage* data);
virtual ~BSlider();
@@ -63,13 +69,14 @@ class BSlider : public BControl {
virtual void AllDetached();
virtual void DetachedFromWindow();
virtual void MessageReceived(BMessage *msg);
virtual void FrameMoved(BPoint new_position);
virtual void FrameResized(float w,float h);
virtual void KeyDown(const char * bytes, int32 n);
virtual void MouseDown(BPoint);
virtual void MouseUp(BPoint pt);
virtual void MouseMoved(BPoint pt, uint32 c, const BMessage *m);
virtual void MessageReceived(BMessage* message);
virtual void FrameMoved(BPoint newPosition);
virtual void FrameResized(float width, float height);
virtual void KeyDown(const char* bytes, int32 numBytes);
virtual void MouseDown(BPoint point);
virtual void MouseUp(BPoint point);
virtual void MouseMoved(BPoint point, uint32 transit,
const BMessage* dragMessage);
virtual void Pulse();
virtual void SetLabel(const char* label);
@@ -82,7 +89,7 @@ class BSlider : public BControl {
virtual void SetPosition(float);
float Position() const;
virtual void SetEnabled(bool on);
void GetLimits(int32 * minimum, int32 * maximum);
void GetLimits(int32* minimum, int32* maximum) const;
virtual void Draw(BRect);
virtual void DrawSlider();
@@ -104,8 +111,8 @@ class BSlider : public BControl {
virtual void GetPreferredSize(float* width, float* height);
virtual void ResizeToPreferred();
virtual status_t Invoke(BMessage *msg=NULL);
virtual BHandler* ResolveSpecifier(BMessage *msg, int32 index,
virtual status_t Invoke(BMessage* message = NULL);
virtual BHandler* ResolveSpecifier(BMessage* message, int32 index,
BMessage* specifier, int32 form,
const char* property);
virtual status_t GetSupportedSuites(BMessage* data);
@@ -125,13 +132,14 @@ class BSlider : public BControl {
virtual void SetHashMarks(hash_mark_location where);
hash_mark_location HashMarks() const;
virtual void SetStyle(thumb_style s);
virtual void SetStyle(thumb_style style);
thumb_style Style() const;
virtual void SetBarColor(rgb_color);
virtual void SetBarColor(rgb_color color);
rgb_color BarColor() const;
virtual void UseFillColor(bool, const rgb_color* c=NULL);
bool FillColor(rgb_color*) const;
virtual void UseFillColor(bool useFill,
const rgb_color* color = NULL);
bool FillColor(rgb_color* color) const;
BView* OffscreenView() const;
@@ -155,15 +163,19 @@ class BSlider : public BControl {
virtual BSize PreferredSize();
private:
// deprecated leftover of BeOS compatibility
void GetLimits(int32* minimum, int32* maximum);
void _DrawBlockThumb();
void _DrawTriangleThumb();
BPoint _Location() const;
void _SetLocation(BPoint p);
void _SetLocation(BPoint point);
float _MinPosition() const;
float _MaxPosition() const;
bool _ConstrainPoint(BPoint& point, BPoint compare) const;
bool _ConstrainPoint(BPoint& point,
BPoint compare) const;
BSize _ValidateMinSize();
@@ -175,7 +187,7 @@ class BSlider : public BControl {
virtual void _ReservedSlider11();
virtual void _ReservedSlider12();
BSlider& operator=(const BSlider &);
BSlider& operator=(const BSlider& other);
void _InitBarColor();
void _InitObject();
@@ -199,10 +211,8 @@ class BSlider : public BControl {
int32 fHashMarkCount;
hash_mark_location fHashMarks;
#if USE_OFF_SCREEN_VIEW
BBitmap* fOffScreenBits;
BView* fOffScreenView;
#endif
thumb_style fStyle;
@@ -216,11 +226,7 @@ class BSlider : public BControl {
float fMaxUpdateTextWidth;
#if USE_OFF_SCREEN_VIEW
uint32 _reserved[4];
#else
uint32 _reserved[6];
#endif
};
#endif // _SLIDER_H
+20 -1
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2001-2006, Haiku.
* Copyright 2001-2009, Haiku.
* Distributed under the terms of the MIT License.
*
* Authors:
@@ -27,6 +27,9 @@
#include <binary_compatibility/Interface.h>
#define USE_OFF_SCREEN_VIEW 1
BSlider::BSlider(BRect frame, const char* name, const char* label,
BMessage* message, int32 minValue, int32 maxValue,
thumb_style thumbType, uint32 resizingMode, uint32 flags)
@@ -777,10 +780,23 @@ BSlider::SetEnabled(bool on)
}
void
BSlider::GetLimits(int32 *minimum, int32 *maximum) const
{
if (minimum != NULL)
*minimum = fMinValue;
if (maximum != NULL)
*maximum = fMaxValue;
}
//! This one is deprecated, and only left for binary compatiblity (it's private)
void
BSlider::GetLimits(int32 *minimum, int32 *maximum)
{
if (minimum != NULL)
*minimum = fMinValue;
if (maximum != NULL)
*maximum = fMaxValue;
}
@@ -1594,6 +1610,9 @@ BSlider::SetBarThickness(float thickness)
{
if (thickness < 1.0)
thickness = 1.0;
else
thickness = roundf(thickness);
if (thickness != fBarThickness) {
// calculate invalid barframe and extend by hashmark size
float hInset = 0.0;