* fix small mem leak

* whitespace cleanup, etc
* some renaming to fit Haiku style



git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28856 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Karsten Heimrich
2009-01-08 15:48:10 +00:00
parent 359176d906
commit e6753e37c6
2 changed files with 282 additions and 297 deletions
+89 -113
View File
@@ -10,148 +10,124 @@
/
*******************************************************************************/
#if !defined(_CHANNEL_SLIDER_H)
#ifndef _CHANNEL_SLIDER_H
#define _CHANNEL_SLIDER_H
#include <ChannelControl.h>
class BChannelSlider :
public BChannelControl
class BChannelSlider : public BChannelControl
{
public:
BChannelSlider(
BRect area,
const char * name,
const char * label,
BMessage * model,
int32 channels = 1,
uint32 resize = B_FOLLOW_LEFT | B_FOLLOW_TOP,
uint32 flags = B_WILL_DRAW);
BChannelSlider(
BRect area,
const char * name,
const char * label,
BMessage * model,
orientation o,
int32 channels = 1,
uint32 resize = B_FOLLOW_LEFT | B_FOLLOW_TOP,
uint32 flags = B_WILL_DRAW);
BChannelSlider(
BMessage * from);
BChannelSlider(BRect area, const char* name,
const char* label, BMessage* message,
int32 channels = 1,
uint32 resize = B_FOLLOW_LEFT | B_FOLLOW_TOP,
uint32 flags = B_WILL_DRAW);
BChannelSlider(BRect area, const char* name,
const char* label, BMessage* message,
orientation o, int32 channels = 1,
uint32 resize = B_FOLLOW_LEFT | B_FOLLOW_TOP,
uint32 flags = B_WILL_DRAW);
BChannelSlider(BMessage* archive);
virtual ~BChannelSlider();
static BArchivable * Instantiate(BMessage * from);
virtual status_t Archive(BMessage * into, bool deep = true) const;
static BArchivable* Instantiate(BMessage* from);
virtual status_t Archive(BMessage* into, bool deep = true) const;
virtual orientation Orientation() const;
void SetOrientation(orientation o);
virtual orientation Orientation() const;
void SetOrientation(orientation o);
virtual int32 MaxChannelCount() const;
virtual bool SupportsIndividualLimits() const;
virtual int32 MaxChannelCount() const;
virtual bool SupportsIndividualLimits() const;
virtual void AttachedToWindow();
virtual void AllAttached();
virtual void DetachedFromWindow();
virtual void AllDetached();
virtual void AttachedToWindow();
virtual void AllAttached();
virtual void DetachedFromWindow();
virtual void AllDetached();
virtual void MessageReceived(BMessage *msg);
virtual void MessageReceived(BMessage* msg);
virtual void Draw(BRect area);
virtual void MouseDown(BPoint where);
virtual void MouseUp(BPoint pt);
virtual void MouseMoved( BPoint pt,
uint32 code,
const BMessage * message);
virtual void WindowActivated(bool state);
virtual void KeyDown(const char *bytes, int32 numBytes);
virtual void KeyUp(const char *bytes, int32 numBytes);
virtual void FrameResized(float width, float height);
virtual void Draw(BRect area);
virtual void MouseDown(BPoint where);
virtual void MouseUp(BPoint pt);
virtual void MouseMoved(BPoint pt,uint32 code,
const BMessage* message);
virtual void WindowActivated(bool state);
virtual void KeyDown(const char* bytes, int32 numBytes);
virtual void KeyUp(const char* bytes, int32 numBytes);
virtual void FrameResized(float width, float height);
virtual void SetFont(const BFont *font, uint32 mask = B_FONT_ALL);
virtual void MakeFocus(bool focusState = true);
virtual void SetFont(const BFont* font, uint32 mask = B_FONT_ALL);
virtual void MakeFocus(bool focusState = true);
virtual void SetEnabled(bool on);
virtual void SetEnabled(bool on);
virtual void GetPreferredSize(float *width, float *height);
virtual void GetPreferredSize(float* width, float* height);
virtual BHandler *ResolveSpecifier(BMessage *msg,
int32 index,
BMessage *specifier,
int32 form,
const char *property);
virtual status_t GetSupportedSuites(BMessage *data);
virtual BHandler* ResolveSpecifier(BMessage* msg, int32 index,
BMessage* specifier, int32 form, const char* p);
virtual status_t GetSupportedSuites(BMessage* data);
// Perform rendering for an entire slider channel.
virtual void DrawChannel(BView* into,
int32 channel,
BRect area,
bool pressed);
// Perform rendering for an entire slider channel.
virtual void DrawChannel(BView* into, int32 channel, BRect area,
bool pressed);
// Draw the groove that appears behind a channel's thumb.
virtual void DrawGroove( BView* into,
int32 channel,
BPoint tl,
BPoint br);
// Draw groove that appears behind a channel's thumb.
virtual void DrawGroove(BView* into, int32 channel, BPoint lt,
BPoint br);
// Draw the thumb for a single channel.
virtual void DrawThumb( BView* into,
int32 channel,
BPoint where,
bool pressed );
// Draw the thumb for a single channel.
virtual void DrawThumb(BView* into, int32 channel, BPoint where,
bool pressed);
virtual const BBitmap * ThumbFor(int32 channel, bool pressed);
virtual BRect ThumbFrameFor(int32 channel);
virtual float ThumbDeltaFor(int32 channel);
virtual float ThumbRangeFor(int32 channel);
virtual const BBitmap* ThumbFor(int32 channel, bool pressed);
virtual BRect ThumbFrameFor(int32 channel);
virtual float ThumbDeltaFor(int32 channel);
virtual float ThumbRangeFor(int32 channel);
private:
typedef BChannelControl inherited;
BChannelSlider( /* unimplemented */
const BChannelSlider &);
BChannelSlider& operator=( /* unimplemented */
const BChannelSlider &);
BChannelSlider(const BChannelSlider &);
BChannelSlider& operator=(const BChannelSlider &);
virtual void _Reserved_BChannelSlider_0(void *, ...);
virtual void _Reserved_BChannelSlider_1(void *, ...);
virtual void _Reserved_BChannelSlider_2(void *, ...);
virtual void _Reserved_BChannelSlider_3(void *, ...);
virtual void _Reserved_BChannelSlider_4(void *, ...);
virtual void _Reserved_BChannelSlider_5(void *, ...);
virtual void _Reserved_BChannelSlider_6(void *, ...);
virtual void _Reserved_BChannelSlider_7(void *, ...);
virtual void _Reserved_BChannelSlider_0(void* , ...);
virtual void _Reserved_BChannelSlider_1(void* , ...);
virtual void _Reserved_BChannelSlider_2(void* , ...);
virtual void _Reserved_BChannelSlider_3(void* , ...);
virtual void _Reserved_BChannelSlider_4(void* , ...);
virtual void _Reserved_BChannelSlider_5(void* , ...);
virtual void _Reserved_BChannelSlider_6(void* , ...);
virtual void _Reserved_BChannelSlider_7(void* , ...);
float fBaseLine;
float fLineFeed;
BBitmap * fLeftKnob;
BBitmap * fMidKnob;
BBitmap * fRightKnob;
BBitmap * fBacking;
BView * fBackingView;
bool fVertical;
bool fPadding[3];
BPoint fClickDelta;
float fBaseLine;
float fLineFeed;
BBitmap* fLeftKnob;
BBitmap* fMidKnob;
BBitmap* fRightKnob;
BBitmap* fBacking;
BView* fBackingView;
bool fVertical;
bool fPadding[3];
BPoint fClickDelta;
int32 fCurrentChannel;
bool fAllChannels;
int32* fInitialValues;
float fMinpoint;
int32 fFocusChannel;
int32 fCurrentChannel;
bool fAllChannels;
int32* fInitialValues;
float fMinpoint;
int32 fFocusChannel;
uint32 _reserved_[12];
uint32 _reserved_[12];
void InitData();
void FinishChange();
void UpdateFontDimens();
void DrawThumbs();
void DrawThumbFrame(
BView * where,
const BRect & area);
bool Vertical() const;
void Redraw();
void MouseMovedCommon(BPoint , BPoint );
void _InitData();
void _FinishChange();
void _UpdateFontDimens();
void _DrawThumbs();
void _DrawGrooveFrame(BView* where, const BRect& area);
bool _Vertical() const;
void _Redraw();
void _MouseMovedCommon(BPoint point, BPoint point2);
};
+102 -93
View File
@@ -1,5 +1,5 @@
/*
* Copyright 2005, Haiku Inc. All Rights Reserved.
* Copyright 2005 - 2008, Haiku Inc. All Rights Reserved.
* Author: Stefano Ceccherini ([email protected])
* Distributed under the terms of the MIT License.
*/
@@ -34,18 +34,22 @@ kVerticalKnobData[] = {
const static unsigned char
kHorizontalKnobData[] = {
0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff, 0xff,
0xff, 0x00, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x00, 0xff, 0xff,
0xff, 0x00, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x00, 0xff, 0xff,
0xff, 0x00, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0xcb, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x00, 0x12, 0xff,
0xff, 0x00, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0xcb, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x00, 0x12, 0xff,
0xff, 0x00, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0xcb, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x00, 0x12, 0xff,
0xff, 0x00, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0xcb, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x00, 0x12, 0xff,
0xff, 0x00, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x00, 0x12, 0xff,
0xff, 0x00, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x00, 0x12, 0xff,
0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0c, 0x12, 0xff,
0xff, 0xff, 0xff, 0xff, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0xff, 0xff, 0xff, 0xff, 0x00, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f,
0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x00, 0xff, 0xff, 0xff, 0x00, 0x3f, 0x3f,
0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x00, 0xff, 0xff,
0xff, 0x00, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0xcb, 0x3f, 0x3f, 0x3f, 0x3f,
0x3f, 0x00, 0x12, 0xff, 0xff, 0x00, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0xcb,
0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x00, 0x12, 0xff, 0xff, 0x00, 0x3f, 0x3f,
0x3f, 0x3f, 0x3f, 0xcb, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x00, 0x12, 0xff,
0xff, 0x00, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0xcb, 0x3f, 0x3f, 0x3f, 0x3f,
0x3f, 0x00, 0x12, 0xff, 0xff, 0x00, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f,
0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x00, 0x12, 0xff, 0xff, 0x00, 0x3f, 0x3f,
0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x3f, 0x00, 0x12, 0xff,
0xff, 0xff, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x0c, 0x12, 0xff, 0xff, 0xff, 0xff, 0xff, 0x12, 0x12, 0x12, 0x12,
0x12, 0x12, 0x12, 0x12, 0x12, 0x12, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff
};
@@ -62,11 +66,12 @@ sPropertyInfo[] = {
const static float kPadding = 10.0;
BChannelSlider::BChannelSlider(BRect area, const char *name, const char *label,
BMessage *model, int32 channels, uint32 resizeMode, uint32 flags)
: BChannelControl(area, name, label, model, channels, resizeMode, flags)
{
InitData();
_InitData();
}
@@ -75,7 +80,7 @@ BChannelSlider::BChannelSlider(BRect area, const char *name, const char *label,
: BChannelControl(area, name, label, model, channels, resizeMode, flags)
{
InitData();
_InitData();
SetOrientation(o);
}
@@ -83,7 +88,7 @@ BChannelSlider::BChannelSlider(BRect area, const char *name, const char *label,
BChannelSlider::BChannelSlider(BMessage *archive)
: BChannelControl(archive)
{
InitData();
_InitData();
orientation orient;
if (archive->FindInt32("_orient", (int32 *)&orient) == B_OK)
@@ -93,6 +98,7 @@ BChannelSlider::BChannelSlider(BMessage *archive)
BChannelSlider::~BChannelSlider()
{
delete fBacking;
delete fLeftKnob;
delete fMidKnob;
delete fRightKnob;
@@ -124,7 +130,7 @@ BChannelSlider::Archive(BMessage *into, bool deep) const
orientation
BChannelSlider::Orientation() const
{
return Vertical() ? B_VERTICAL : B_HORIZONTAL;
return _Vertical() ? B_VERTICAL : B_HORIZONTAL;
}
@@ -132,7 +138,7 @@ void
BChannelSlider::SetOrientation(orientation _orientation)
{
bool isVertical = _orientation == B_VERTICAL;
if (isVertical != Vertical()) {
if (isVertical != _Vertical()) {
fVertical = isVertical;
Invalidate(Bounds());
}
@@ -160,28 +166,28 @@ BChannelSlider::AttachedToWindow()
if (parent != NULL)
SetViewColor(parent->ViewColor());
inherited::AttachedToWindow();
BChannelControl::AttachedToWindow();
}
void
BChannelSlider::AllAttached()
{
BControl::AllAttached();
BChannelControl::AllAttached();
}
void
BChannelSlider::DetachedFromWindow()
{
inherited::DetachedFromWindow();
BChannelControl::DetachedFromWindow();
}
void
BChannelSlider::AllDetached()
{
BControl::AllDetached();
BChannelControl::AllDetached();
}
@@ -189,16 +195,16 @@ void
BChannelSlider::MessageReceived(BMessage *message)
{
switch (message->what) {
case B_SET_PROPERTY:
case B_SET_PROPERTY: {
case B_GET_PROPERTY:
{
BMessage reply(B_REPLY);
int32 index = 0;
BMessage specifier;
int32 what = 0;
const char *property = NULL;
bool handled = false;
status_t status = message->GetCurrentSpecifier(&index, &specifier, &what, &property);
status_t status = message->GetCurrentSpecifier(&index, &specifier,
&what, &property);
BPropertyInfo propInfo(sPropertyInfo);
if (status == B_OK
&& propInfo.FindMatch(message, index, &specifier, what, property) >= 0) {
@@ -218,12 +224,13 @@ BChannelSlider::MessageReceived(BMessage *message)
if (handled) {
reply.AddInt32("error", status);
message->SendReply(&reply);
} else
inherited::MessageReceived(message);
break;
}
} else {
BChannelControl::MessageReceived(message);
}
} break;
default:
inherited::MessageReceived(message);
BChannelControl::MessageReceived(message);
break;
}
}
@@ -232,8 +239,8 @@ BChannelSlider::MessageReceived(BMessage *message)
void
BChannelSlider::Draw(BRect updateRect)
{
UpdateFontDimens();
DrawThumbs();
_UpdateFontDimens();
_DrawThumbs();
if (Label()) {
BRect bounds(Bounds());
@@ -260,7 +267,7 @@ BChannelSlider::MouseDown(BPoint where)
frame.OffsetBy(fClickDelta);
float range = ThumbRangeFor(channel);
if (Vertical()) {
if (_Vertical()) {
fMinpoint = frame.top + frame.Height() / 2;
frame.bottom += range;
} else {
@@ -305,19 +312,20 @@ BChannelSlider::MouseDown(BPoint where)
if (Window()->Flags() & B_ASYNCHRONOUS_CONTROLS) {
if (!IsTracking()) {
SetTracking(true);
DrawThumbs();
_DrawThumbs();
Flush();
}
MouseMovedCommon(where, B_ORIGIN);
SetMouseEventMask(B_POINTER_EVENTS, B_LOCK_WINDOW_FOCUS | B_NO_POINTER_HISTORY);
_MouseMovedCommon(where, B_ORIGIN);
SetMouseEventMask(B_POINTER_EVENTS, B_LOCK_WINDOW_FOCUS |
B_NO_POINTER_HISTORY);
} else {
do {
snooze(30000);
GetMouse(&where, &buttons);
MouseMovedCommon(where, B_ORIGIN);
_MouseMovedCommon(where, B_ORIGIN);
} while (buttons != 0);
FinishChange();
_FinishChange();
fCurrentChannel = -1;
fAllChannels = false;
}
@@ -329,13 +337,13 @@ void
BChannelSlider::MouseUp(BPoint where)
{
if (IsEnabled() && IsTracking()) {
FinishChange();
_FinishChange();
SetTracking(false);
fAllChannels = false;
fCurrentChannel = -1;
fMinpoint = 0;
} else
BControl::MouseUp(where);
BChannelControl::MouseUp(where);
}
@@ -343,16 +351,16 @@ void
BChannelSlider::MouseMoved(BPoint where, uint32 code, const BMessage *message)
{
if (IsEnabled() && IsTracking())
MouseMovedCommon(where, B_ORIGIN);
_MouseMovedCommon(where, B_ORIGIN);
else
BControl::MouseMoved(where, code, message);
BChannelControl::MouseMoved(where, code, message);
}
void
BChannelSlider::WindowActivated(bool state)
{
BControl::WindowActivated(state);
BChannelControl::WindowActivated(state);
}
@@ -373,7 +381,7 @@ BChannelSlider::KeyUp(const char *bytes, int32 numBytes)
void
BChannelSlider::FrameResized(float newWidth, float newHeight)
{
inherited::FrameResized(newWidth, newHeight);
BChannelControl::FrameResized(newWidth, newHeight);
Invalidate(Bounds());
}
@@ -381,7 +389,7 @@ BChannelSlider::FrameResized(float newWidth, float newHeight)
void
BChannelSlider::SetFont(const BFont *font, uint32 mask)
{
inherited::SetFont(font, mask);
BChannelControl::SetFont(font, mask);
}
@@ -390,14 +398,14 @@ BChannelSlider::MakeFocus(bool focusState)
{
if (focusState && !IsFocus())
fFocusChannel = -1;
BControl::MakeFocus(focusState);
BChannelControl::MakeFocus(focusState);
}
void
BChannelSlider::SetEnabled(bool on)
{
BControl::SetEnabled(on);
BChannelControl::SetEnabled(on);
}
@@ -406,14 +414,14 @@ BChannelSlider::GetPreferredSize(float *width, float *height)
{
if (width) {
float _width = (float)ceil(StringWidth(Label()));
if (Vertical()) {
if (_Vertical()) {
*width = max_c(_width, 2 + 12 * CountChannels());
} else {
*width = max_c(_width, 64);
}
}
if (height) {
if (Vertical())
if (_Vertical())
*height = 195;
else
*height = 71;
@@ -423,13 +431,14 @@ BChannelSlider::GetPreferredSize(float *width, float *height)
BHandler *
BChannelSlider::ResolveSpecifier(BMessage *msg, int32 index, BMessage *specifier,
int32 form, const char *property)
int32 form, const char *property)
{
BHandler *target = this;
BPropertyInfo propertyInfo(sPropertyInfo);
if (propertyInfo.FindMatch(msg, index, specifier, form, property) < B_OK)
target = BChannelControl::ResolveSpecifier(msg, index, specifier, form, property);
if (propertyInfo.FindMatch(msg, index, specifier, form, property) < B_OK) {
target = BChannelControl::ResolveSpecifier(msg, index, specifier, form,
property);
}
return target;
}
@@ -460,7 +469,7 @@ BChannelSlider::DrawChannel(BView *into, int32 channel, BRect area, bool pressed
BPoint leftTop;
BPoint bottomRight;
if (Vertical()) {
if (_Vertical()) {
leftTop.Set(area.left + hCenter, area.top + vCenter);
bottomRight.Set(leftTop.x, leftTop.y + ThumbRangeFor(channel));
} else {
@@ -471,7 +480,7 @@ BChannelSlider::DrawChannel(BView *into, int32 channel, BRect area, bool pressed
DrawGroove(into, channel, leftTop, bottomRight);
BPoint thumbLocation = leftTop;
if (Vertical())
if (_Vertical())
thumbLocation.y += ThumbDeltaFor(channel);
else
thumbLocation.x += ThumbDeltaFor(channel);
@@ -481,12 +490,13 @@ BChannelSlider::DrawChannel(BView *into, int32 channel, BRect area, bool pressed
void
BChannelSlider::DrawGroove(BView *into, int32 channel, BPoint topLeft, BPoint bottomRight)
BChannelSlider::DrawGroove(BView *into, int32 channel, BPoint leftTop,
BPoint bottomRight)
{
ASSERT(into != NULL);
BRect rect(topLeft, bottomRight);
BRect rect(leftTop, bottomRight);
DrawThumbFrame(fBackingView, rect.InsetByCopy(-2.5, -2.5));
_DrawGrooveFrame(fBackingView, rect.InsetByCopy(-2.5, -2.5));
rect.InsetBy(-0.5, -0.5);
into->FillRect(rect, B_SOLID_HIGH);
@@ -494,7 +504,7 @@ BChannelSlider::DrawGroove(BView *into, int32 channel, BPoint topLeft, BPoint bo
void
BChannelSlider::DrawThumb(BView *into, int32 channel, BPoint where, bool pressed)
BChannelSlider::DrawThumb(BView* into, int32 channel, BPoint where, bool pressed)
{
ASSERT(into != NULL);
@@ -534,12 +544,14 @@ BChannelSlider::ThumbFor(int32 channel, bool pressed)
{
// TODO: Finish me
if (fLeftKnob == NULL) {
if (Vertical()) {
if (_Vertical()) {
fLeftKnob = new BBitmap(BRect(0, 0, 11, 14), B_CMAP8);
fLeftKnob->SetBits(kVerticalKnobData, sizeof(kVerticalKnobData), 0, B_CMAP8);
fLeftKnob->SetBits(kVerticalKnobData, sizeof(kVerticalKnobData),
0, B_CMAP8);
} else {
fLeftKnob = new BBitmap(BRect(0, 0, 14, 11), B_CMAP8);
fLeftKnob->SetBits(kHorizontalKnobData, sizeof(kHorizontalKnobData), 0, B_CMAP8);
fLeftKnob->SetBits(kHorizontalKnobData, sizeof(kHorizontalKnobData),
0, B_CMAP8);
}
}
@@ -550,13 +562,13 @@ BChannelSlider::ThumbFor(int32 channel, bool pressed)
BRect
BChannelSlider::ThumbFrameFor(int32 channel)
{
UpdateFontDimens();
_UpdateFontDimens();
BRect frame(0, 0, 0, 0);
const BBitmap *thumb = ThumbFor(channel, false);
if (thumb != NULL) {
frame = thumb->Bounds();
if (Vertical())
if (_Vertical())
frame.OffsetBy(channel * frame.Width(), fLineFeed + kPadding);
else
frame.OffsetBy(kPadding, fLineFeed + channel * frame.Height());
@@ -575,7 +587,7 @@ BChannelSlider::ThumbDeltaFor(int32 channel)
int32 limitRange = MaxLimitList()[channel] - MinLimitList()[channel];
delta = (ValueList()[channel] - MinLimitList()[channel]) * range / limitRange;
if (Vertical())
if (_Vertical())
delta = range - delta;
}
@@ -586,12 +598,12 @@ BChannelSlider::ThumbDeltaFor(int32 channel)
float
BChannelSlider::ThumbRangeFor(int32 channel)
{
UpdateFontDimens();
_UpdateFontDimens();
float range = 0;
BRect bounds = Bounds();
BRect frame = ThumbFrameFor(channel);
if (Vertical())
if (_Vertical())
range = bounds.Height() - frame.Height() - (kPadding + fLineFeed) * 2;
else
range = bounds.Width() - frame.Width() - kPadding * 2;
@@ -601,9 +613,9 @@ BChannelSlider::ThumbRangeFor(int32 channel)
void
BChannelSlider::InitData()
BChannelSlider::_InitData()
{
UpdateFontDimens();
_UpdateFontDimens();
fLeftKnob = NULL;
fMidKnob = NULL;
@@ -624,7 +636,7 @@ BChannelSlider::InitData()
void
BChannelSlider::FinishChange()
BChannelSlider::_FinishChange()
{
if (fInitialValues != NULL) {
bool *inMask = NULL;
@@ -639,12 +651,12 @@ BChannelSlider::FinishChange()
}
SetTracking(false);
Redraw();
_Redraw();
}
void
BChannelSlider::UpdateFontDimens()
BChannelSlider::_UpdateFontDimens()
{
font_height height;
GetFontHeight(&height);
@@ -654,7 +666,7 @@ BChannelSlider::UpdateFontDimens()
void
BChannelSlider::DrawThumbs()
BChannelSlider::_DrawThumbs()
{
if (fBacking == NULL) {
// This is the idea: we build a bitmap by taking the coordinates
@@ -663,20 +675,15 @@ BChannelSlider::DrawThumbs()
BRect last = ThumbFrameFor(CountChannels() - 1);
BRect bitmapFrame(first.LeftTop(), last.RightBottom());
if (Vertical())
if (_Vertical())
bitmapFrame.top -= ThumbRangeFor(0);
else
bitmapFrame.right += ThumbRangeFor(0);
fBacking = new BBitmap(bitmapFrame.OffsetToCopy(B_ORIGIN),
#ifdef __HAIKU__
BScreen(Window()).ColorSpace(),
#else
B_RGB32,
#endif
true, false);
bitmapFrame.OffsetTo(B_ORIGIN);
fBacking = new BBitmap(bitmapFrame, B_RGBA32, true, false);
if (fBacking->Lock()) {
fBackingView = new BView(bitmapFrame.OffsetToCopy(B_ORIGIN), "backing view", B_FOLLOW_NONE, B_WILL_DRAW);
fBackingView = new BView(bitmapFrame, "", 0, B_WILL_DRAW);
fBacking->AddChild(fBackingView);
fBackingView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
fBackingView->SetLowColor(fBackingView->ViewColor());
@@ -700,7 +707,7 @@ BChannelSlider::DrawThumbs()
// take into account that the view we draw on is attached to an offscreen
// bitmap. Still this doesn't make much sense:
// could be that I'm simply missing something.
if (Vertical())
if (_Vertical())
channelArea.OffsetBy(0, -channelArea.top);
else
channelArea.OffsetBy(0, -channelArea.Height());
@@ -718,7 +725,7 @@ BChannelSlider::DrawThumbs()
float width = fBackingView->StringWidth(valueString);
BRect valueRect(0, 0, width, 10);
rgb_color oldColor = fBackingView->HighColor();
if (Vertical())
if (_Vertical())
valueRect.OffsetTo((ThumbFrameFor(fCurrentChannel).Width() - width) / 2 + fCurrentChannel * ThumbFrameFor(fCurrentChannel).Width(),
ThumbDeltaFor(fCurrentChannel));
else
@@ -763,7 +770,7 @@ BChannelSlider::DrawThumbs()
fClickDelta = drawHere;
// TODO: See above
if (Vertical())
if (_Vertical())
fClickDelta.y -= ThumbFrameFor(0).top;
else
fClickDelta.y -= ThumbFrameFor(0).Height();
@@ -771,7 +778,7 @@ BChannelSlider::DrawThumbs()
void
BChannelSlider::DrawThumbFrame(BView *into, const BRect &area)
BChannelSlider::_DrawGrooveFrame(BView *into, const BRect &area)
{
rgb_color oldColor = into->HighColor();
@@ -789,14 +796,14 @@ BChannelSlider::DrawThumbFrame(BView *into, const BRect &area)
bool
BChannelSlider::Vertical() const
BChannelSlider::_Vertical() const
{
return fVertical;
}
void
BChannelSlider::Redraw()
BChannelSlider::_Redraw()
{
Invalidate(Bounds());
Flush();
@@ -804,23 +811,25 @@ BChannelSlider::Redraw()
void
BChannelSlider::MouseMovedCommon(BPoint point, BPoint point2)
BChannelSlider::_MouseMovedCommon(BPoint point, BPoint point2)
{
float floatValue = 0;
int32 limitRange = MaxLimitList()[fCurrentChannel] - MinLimitList()[fCurrentChannel];
int32 limitRange = MaxLimitList()[fCurrentChannel] -
MinLimitList()[fCurrentChannel];
float range = ThumbRangeFor(fCurrentChannel);
if (Vertical())
if (_Vertical())
floatValue = range - (point.y - fMinpoint);
else
floatValue = range + (point.x - fMinpoint);
int32 value = (int32)(floatValue / range * limitRange) + MinLimitList()[fCurrentChannel];
int32 value = (int32)(floatValue / range * limitRange) +
MinLimitList()[fCurrentChannel];
if (fAllChannels)
SetAllValue(value);
else
SetValueFor(fCurrentChannel, value);
DrawThumbs();
_DrawThumbs();
}