* 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. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@@ -28,27 +28,33 @@ enum thumb_style {
}; };
#define USE_OFF_SCREEN_VIEW 1
class BSlider : public BControl { class BSlider : public BControl {
public: public:
BSlider(BRect frame, const char *name, const char *label, BSlider(BRect frame, const char* name,
BMessage *message, int32 minValue, int32 maxValue, const char* label, BMessage* message,
int32 minValue, int32 maxValue,
thumb_style thumbType = B_BLOCK_THUMB, thumb_style thumbType = B_BLOCK_THUMB,
uint32 resizingMode = B_FOLLOW_LEFT | B_FOLLOW_TOP, uint32 resizingMode
uint32 flags = B_NAVIGABLE | B_WILL_DRAW | B_FRAME_EVENTS); = 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, BSlider(BRect frame, const char* name,
BMessage *message, int32 minValue, int32 maxValue, const char* label, BMessage* message,
orientation posture, thumb_style thumbType = B_BLOCK_THUMB, int32 minValue, int32 maxValue,
uint32 resizingMode = B_FOLLOW_LEFT | B_FOLLOW_TOP, orientation posture,
uint32 flags = B_NAVIGABLE | B_WILL_DRAW | B_FRAME_EVENTS); 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, BSlider(const char* name, const char* label,
BMessage *message, int32 minValue, int32 maxValue, BMessage* message, int32 minValue,
orientation posture, thumb_style thumbType = B_BLOCK_THUMB, int32 maxValue, orientation posture,
uint32 flags = B_NAVIGABLE | B_WILL_DRAW | B_FRAME_EVENTS); thumb_style thumbType = B_BLOCK_THUMB,
uint32 flags = B_NAVIGABLE | B_WILL_DRAW
| B_FRAME_EVENTS);
BSlider(BMessage* data); BSlider(BMessage* data);
virtual ~BSlider(); virtual ~BSlider();
@@ -63,13 +69,14 @@ class BSlider : public BControl {
virtual void AllDetached(); virtual void AllDetached();
virtual void DetachedFromWindow(); virtual void DetachedFromWindow();
virtual void MessageReceived(BMessage *msg); virtual void MessageReceived(BMessage* message);
virtual void FrameMoved(BPoint new_position); virtual void FrameMoved(BPoint newPosition);
virtual void FrameResized(float w,float h); virtual void FrameResized(float width, float height);
virtual void KeyDown(const char * bytes, int32 n); virtual void KeyDown(const char* bytes, int32 numBytes);
virtual void MouseDown(BPoint); virtual void MouseDown(BPoint point);
virtual void MouseUp(BPoint pt); virtual void MouseUp(BPoint point);
virtual void MouseMoved(BPoint pt, uint32 c, const BMessage *m); virtual void MouseMoved(BPoint point, uint32 transit,
const BMessage* dragMessage);
virtual void Pulse(); virtual void Pulse();
virtual void SetLabel(const char* label); virtual void SetLabel(const char* label);
@@ -82,7 +89,7 @@ class BSlider : public BControl {
virtual void SetPosition(float); virtual void SetPosition(float);
float Position() const; float Position() const;
virtual void SetEnabled(bool on); virtual void SetEnabled(bool on);
void GetLimits(int32 * minimum, int32 * maximum); void GetLimits(int32* minimum, int32* maximum) const;
virtual void Draw(BRect); virtual void Draw(BRect);
virtual void DrawSlider(); virtual void DrawSlider();
@@ -104,8 +111,8 @@ class BSlider : public BControl {
virtual void GetPreferredSize(float* width, float* height); virtual void GetPreferredSize(float* width, float* height);
virtual void ResizeToPreferred(); virtual void ResizeToPreferred();
virtual status_t Invoke(BMessage *msg=NULL); virtual status_t Invoke(BMessage* message = NULL);
virtual BHandler* ResolveSpecifier(BMessage *msg, int32 index, virtual BHandler* ResolveSpecifier(BMessage* message, int32 index,
BMessage* specifier, int32 form, BMessage* specifier, int32 form,
const char* property); const char* property);
virtual status_t GetSupportedSuites(BMessage* data); virtual status_t GetSupportedSuites(BMessage* data);
@@ -125,13 +132,14 @@ class BSlider : public BControl {
virtual void SetHashMarks(hash_mark_location where); virtual void SetHashMarks(hash_mark_location where);
hash_mark_location HashMarks() const; hash_mark_location HashMarks() const;
virtual void SetStyle(thumb_style s); virtual void SetStyle(thumb_style style);
thumb_style Style() const; thumb_style Style() const;
virtual void SetBarColor(rgb_color); virtual void SetBarColor(rgb_color color);
rgb_color BarColor() const; rgb_color BarColor() const;
virtual void UseFillColor(bool, const rgb_color* c=NULL); virtual void UseFillColor(bool useFill,
bool FillColor(rgb_color*) const; const rgb_color* color = NULL);
bool FillColor(rgb_color* color) const;
BView* OffscreenView() const; BView* OffscreenView() const;
@@ -155,15 +163,19 @@ class BSlider : public BControl {
virtual BSize PreferredSize(); virtual BSize PreferredSize();
private: private:
// deprecated leftover of BeOS compatibility
void GetLimits(int32* minimum, int32* maximum);
void _DrawBlockThumb(); void _DrawBlockThumb();
void _DrawTriangleThumb(); void _DrawTriangleThumb();
BPoint _Location() const; BPoint _Location() const;
void _SetLocation(BPoint p); void _SetLocation(BPoint point);
float _MinPosition() const; float _MinPosition() const;
float _MaxPosition() const; float _MaxPosition() const;
bool _ConstrainPoint(BPoint& point, BPoint compare) const; bool _ConstrainPoint(BPoint& point,
BPoint compare) const;
BSize _ValidateMinSize(); BSize _ValidateMinSize();
@@ -175,7 +187,7 @@ class BSlider : public BControl {
virtual void _ReservedSlider11(); virtual void _ReservedSlider11();
virtual void _ReservedSlider12(); virtual void _ReservedSlider12();
BSlider& operator=(const BSlider &); BSlider& operator=(const BSlider& other);
void _InitBarColor(); void _InitBarColor();
void _InitObject(); void _InitObject();
@@ -199,10 +211,8 @@ class BSlider : public BControl {
int32 fHashMarkCount; int32 fHashMarkCount;
hash_mark_location fHashMarks; hash_mark_location fHashMarks;
#if USE_OFF_SCREEN_VIEW
BBitmap* fOffScreenBits; BBitmap* fOffScreenBits;
BView* fOffScreenView; BView* fOffScreenView;
#endif
thumb_style fStyle; thumb_style fStyle;
@@ -216,11 +226,7 @@ class BSlider : public BControl {
float fMaxUpdateTextWidth; float fMaxUpdateTextWidth;
#if USE_OFF_SCREEN_VIEW
uint32 _reserved[4]; uint32 _reserved[4];
#else
uint32 _reserved[6];
#endif
}; };
#endif // _SLIDER_H #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. * Distributed under the terms of the MIT License.
* *
* Authors: * Authors:
@@ -27,6 +27,9 @@
#include <binary_compatibility/Interface.h> #include <binary_compatibility/Interface.h>
#define USE_OFF_SCREEN_VIEW 1
BSlider::BSlider(BRect frame, const char* name, const char* label, BSlider::BSlider(BRect frame, const char* name, const char* label,
BMessage* message, int32 minValue, int32 maxValue, BMessage* message, int32 minValue, int32 maxValue,
thumb_style thumbType, uint32 resizingMode, uint32 flags) 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 void
BSlider::GetLimits(int32 *minimum, int32 *maximum) BSlider::GetLimits(int32 *minimum, int32 *maximum)
{ {
if (minimum != NULL)
*minimum = fMinValue; *minimum = fMinValue;
if (maximum != NULL)
*maximum = fMaxValue; *maximum = fMaxValue;
} }
@@ -1594,6 +1610,9 @@ BSlider::SetBarThickness(float thickness)
{ {
if (thickness < 1.0) if (thickness < 1.0)
thickness = 1.0; thickness = 1.0;
else
thickness = roundf(thickness);
if (thickness != fBarThickness) { if (thickness != fBarThickness) {
// calculate invalid barframe and extend by hashmark size // calculate invalid barframe and extend by hashmark size
float hInset = 0.0; float hInset = 0.0;