Lots of fixes, geometry calculations updated, added buffered BSlider support
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2539 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -45,8 +45,12 @@ BButton::BButton(BRect frame, const char *name, const char *label, BMessage *mes
|
||||
: BControl(frame, name, label, message, resizingMode, flags),
|
||||
fDrawAsDefault(false)
|
||||
{
|
||||
if (Bounds().Height() < 24.0f)
|
||||
ResizeTo(Bounds().Width(), 24.0f);
|
||||
// Resize to minimum height if needed
|
||||
font_height fh;
|
||||
GetFontHeight(&fh);
|
||||
float minHeight = 12.0f + (float)ceil(fh.ascent + fh.descent);
|
||||
if (Bounds().Height() < minHeight)
|
||||
ResizeTo(Bounds().Width(), minHeight);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
BButton::~BButton()
|
||||
@@ -56,11 +60,11 @@ BButton::~BButton()
|
||||
BButton::BButton(BMessage *archive)
|
||||
: BControl (archive)
|
||||
{
|
||||
if ( archive->FindBool ( "_default", &fDrawAsDefault ) != B_OK )
|
||||
if (archive->FindBool("_default", &fDrawAsDefault) != B_OK)
|
||||
fDrawAsDefault = false;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
BArchivable *BButton::Instantiate ( BMessage *archive )
|
||||
BArchivable *BButton::Instantiate(BMessage *archive)
|
||||
{
|
||||
if (validate_instantiation(archive, "BButton"))
|
||||
return new BButton(archive);
|
||||
@@ -83,7 +87,27 @@ status_t BButton::Archive(BMessage* archive, bool deep) const
|
||||
//------------------------------------------------------------------------------
|
||||
void BButton::Draw(BRect updateRect)
|
||||
{
|
||||
BRect rect = Bounds();
|
||||
font_height fh;
|
||||
GetFontHeight(&fh);
|
||||
|
||||
BRect bounds(Bounds());
|
||||
|
||||
// If the focus is changing, just redraw the focus indicator
|
||||
if (IsFocusChanging())
|
||||
{
|
||||
float x = bounds.right / 2 - StringWidth(Label()) / 2.0f;
|
||||
float y = bounds.bottom - fh.descent - (IsDefault() ? 6.0f : 3.0f);
|
||||
|
||||
if (IsFocus())
|
||||
SetHighColor(ui_color(B_KEYBOARD_NAVIGATION_COLOR));
|
||||
else
|
||||
SetHighColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR),
|
||||
B_LIGHTEN_1_TINT));
|
||||
|
||||
StrokeLine(BPoint(x, y), BPoint(x + StringWidth(Label()), y));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
rgb_color no_tint = ui_color(B_PANEL_BACKGROUND_COLOR),
|
||||
lighten1 = tint_color(no_tint, B_LIGHTEN_1_TINT),
|
||||
@@ -93,6 +117,8 @@ void BButton::Draw(BRect updateRect)
|
||||
darken4 = tint_color(no_tint, B_DARKEN_4_TINT),
|
||||
darkenmax = tint_color(no_tint, B_DARKEN_MAX_TINT);
|
||||
|
||||
BRect rect(bounds);
|
||||
|
||||
if (IsDefault())
|
||||
rect = DrawDefault(rect, IsEnabled());
|
||||
else
|
||||
@@ -162,11 +188,8 @@ void BButton::Draw(BRect updateRect)
|
||||
}
|
||||
|
||||
// Label
|
||||
BFont font;
|
||||
GetFont(&font);
|
||||
|
||||
float x = Bounds().Width() / 2 - StringWidth(Label()) / 2.0f;
|
||||
float y = Bounds().Height() / 2.0f + (float)ceil(font.Size() / 2.0f);
|
||||
float x = bounds.right / 2 - StringWidth(Label()) / 2.0f;
|
||||
float y = bounds.bottom - fh.descent - (IsDefault() ? 8.0f : 5.0f);
|
||||
|
||||
if (Value())
|
||||
{
|
||||
@@ -184,9 +207,6 @@ void BButton::Draw(BRect updateRect)
|
||||
// Focus
|
||||
if (IsFocus())
|
||||
{
|
||||
font_height fh;
|
||||
font.GetHeight(&fh);
|
||||
|
||||
y += 2.0f;
|
||||
SetHighColor(ui_color(B_KEYBOARD_NAVIGATION_COLOR));
|
||||
StrokeLine(BPoint(x, y), BPoint(x + StringWidth(Label()), y));
|
||||
@@ -243,11 +263,8 @@ void BButton::Draw(BRect updateRect)
|
||||
FillRect(rect);
|
||||
|
||||
// Label
|
||||
BFont font;
|
||||
GetFont(&font);
|
||||
|
||||
float x = Bounds().Width() / 2 - StringWidth(Label()) / 2.0f;
|
||||
float y = Bounds().Height() / 2.0f + (float)ceil(font.Size() / 2.0f);
|
||||
float x = bounds.right / 2 - StringWidth(Label()) / 2.0f;
|
||||
float y = bounds.bottom - fh.descent - 5.0f;
|
||||
|
||||
SetHighColor(tint_color(no_tint, B_DISABLED_LABEL_TINT));
|
||||
SetLowColor(lighten2);
|
||||
@@ -367,7 +384,7 @@ void BButton::MouseUp(BPoint point)
|
||||
if ( Value() == B_CONTROL_ON)
|
||||
{
|
||||
SetValue(B_CONTROL_OFF);
|
||||
BControl::Invoke();
|
||||
Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -385,13 +402,12 @@ void BButton::SetValue(int32 value)
|
||||
BControl::SetValue(value);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
void BButton::GetPreferredSize (float *width, float *height)
|
||||
void BButton::GetPreferredSize(float *width, float *height)
|
||||
{
|
||||
font_height fh;
|
||||
|
||||
GetFontHeight(&fh);
|
||||
|
||||
*height = (float)ceil(fh.ascent + fh.descent + fh.leading) + 12.0f;
|
||||
*height = 12.0f + (float)ceil(fh.ascent + fh.descent);
|
||||
*width = 20.0f + (float)ceil(StringWidth(Label()));
|
||||
|
||||
if (*width < 75.0f)
|
||||
@@ -527,10 +543,10 @@ BRect BButton::DrawDefault(BRect bounds, bool enabled)
|
||||
return bounds;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
status_t Execute()
|
||||
status_t BButton::Execute()
|
||||
{
|
||||
// TODO:
|
||||
return B_ERROR;
|
||||
// TODO: Is there a use for this? Maybe visual feedback happens here?
|
||||
return Invoke();
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
@@ -176,8 +176,7 @@ status_t BControl::Archive(BMessage *archive, bool deep) const
|
||||
//------------------------------------------------------------------------------
|
||||
void BControl::WindowActivated(bool active)
|
||||
{
|
||||
// Should we check this?
|
||||
if (Window())
|
||||
if (IsFocus())
|
||||
{
|
||||
Draw(Bounds());
|
||||
Flush();
|
||||
@@ -339,6 +338,9 @@ void BControl::DetachedFromWindow()
|
||||
//------------------------------------------------------------------------------
|
||||
void BControl::SetLabel(const char *string)
|
||||
{
|
||||
if (strcmp(fLabel, string) == 0)
|
||||
return;
|
||||
|
||||
if (fLabel)
|
||||
free(fLabel);
|
||||
|
||||
|
||||
@@ -75,6 +75,24 @@ status_t BRadioButton::Archive(BMessage *archive, bool deep) const
|
||||
//------------------------------------------------------------------------------
|
||||
void BRadioButton::Draw(BRect updateRect)
|
||||
{
|
||||
font_height fh;
|
||||
GetFontHeight(&fh);
|
||||
|
||||
// If the focus is changing, just redraw the focus indicator
|
||||
if (IsFocusChanging())
|
||||
{
|
||||
float h = 8.0f + (float)ceil(fh.ascent / 2.0f) + 2.0f;
|
||||
|
||||
if (IsFocus())
|
||||
SetHighColor(ui_color(B_KEYBOARD_NAVIGATION_COLOR));
|
||||
else
|
||||
SetHighColor(ui_color(B_PANEL_BACKGROUND_COLOR));
|
||||
|
||||
StrokeLine(BPoint(20.0f, h), BPoint(20.0f + StringWidth(Label()), h));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Placeholder until sBitmaps is filled in
|
||||
rgb_color no_tint = ui_color(B_PANEL_BACKGROUND_COLOR),
|
||||
lighten1 = tint_color(no_tint, B_LIGHTEN_1_TINT),
|
||||
@@ -143,11 +161,6 @@ void BRadioButton::Draw(BRect updateRect)
|
||||
BPoint(rect.right - 1, rect.top + 1));
|
||||
|
||||
// Label
|
||||
BFont font;
|
||||
GetFont(&font);
|
||||
font_height fh;
|
||||
font.GetHeight(&fh);
|
||||
|
||||
SetHighColor(darkenmax);
|
||||
DrawString(Label(), BPoint(20.0f, 8.0f + (float)ceil(fh.ascent / 2.0f)));
|
||||
|
||||
@@ -205,11 +218,6 @@ void BRadioButton::Draw(BRect updateRect)
|
||||
BPoint(rect.right - 1, rect.top + 1));
|
||||
|
||||
// Label
|
||||
BFont font;
|
||||
GetFont(&font);
|
||||
font_height fh;
|
||||
font.GetHeight(&fh);
|
||||
|
||||
SetHighColor(tint_color(no_tint, B_DISABLED_LABEL_TINT));
|
||||
DrawString(Label(), BPoint(20.0f, 8.0f + (float)ceil(fh.ascent / 2.0f)));
|
||||
}
|
||||
@@ -283,9 +291,7 @@ void BRadioButton::GetPreferredSize(float *width, float *height)
|
||||
//------------------------------------------------------------------------------
|
||||
void BRadioButton::ResizeToPreferred()
|
||||
{
|
||||
float width, height;
|
||||
GetPreferredSize(&width, &height);
|
||||
BControl::ResizeTo(width, height);
|
||||
BControl::ResizeToPreferred();
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
status_t BRadioButton::Invoke(BMessage *message)
|
||||
@@ -364,7 +370,7 @@ BHandler *BRadioButton::ResolveSpecifier(BMessage *message, int32 index,
|
||||
//------------------------------------------------------------------------------
|
||||
void BRadioButton::MakeFocus(bool focused)
|
||||
{
|
||||
BControl::MakeFocus();
|
||||
BControl::MakeFocus(focused);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
void BRadioButton::AllAttached()
|
||||
|
||||
+170
-109
@@ -32,7 +32,8 @@
|
||||
#include <Slider.h>
|
||||
#include <Message.h>
|
||||
#include <Window.h>
|
||||
#include <Support/Errors.h>
|
||||
#include <Bitmap.h>
|
||||
#include <Errors.h>
|
||||
|
||||
// Project Includes ------------------------------------------------------------
|
||||
|
||||
@@ -101,7 +102,22 @@ BSlider::~BSlider()
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
BSlider::BSlider(BMessage *archive)
|
||||
: BControl (archive)
|
||||
: BControl (archive),
|
||||
fModificationMessage(NULL),
|
||||
fSnoozeAmount(20000),
|
||||
fUseFillColor(false),
|
||||
fMinLimitStr(NULL),
|
||||
fMaxLimitStr(NULL),
|
||||
fMinValue(0),
|
||||
fMaxValue(100),
|
||||
fKeyIncrementValue(1),
|
||||
fHashMarkCount(0),
|
||||
fHashMarks(B_HASH_MARKS_NONE),
|
||||
fOffScreenBits(NULL),
|
||||
fOffScreenView(NULL),
|
||||
fStyle(B_BLOCK_THUMB),
|
||||
fOrientation(B_HORIZONTAL),
|
||||
fBarThickness(6.0f)
|
||||
{
|
||||
BMessage modMessage;
|
||||
int16 anInt16;
|
||||
@@ -236,14 +252,13 @@ void BSlider::AttachedToWindow()
|
||||
{
|
||||
BControl::AttachedToWindow();
|
||||
|
||||
if (Parent())
|
||||
SetViewColor(Parent()->ViewColor());
|
||||
|
||||
ResizeToPreferred();
|
||||
|
||||
fLocation.Set(9.0f, 0.0f);
|
||||
|
||||
// TODO: Allocate fOffScreenBits and fOffScreenView
|
||||
fOffScreenBits = new BBitmap(Bounds(), B_CMAP8, true, false);
|
||||
fOffScreenView = new BView(Bounds(), "", B_FOLLOW_NONE, B_WILL_DRAW);
|
||||
fOffScreenBits->AddChild(fOffScreenView);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
void BSlider::AllAttached()
|
||||
@@ -256,6 +271,21 @@ void BSlider::AllDetached()
|
||||
//------------------------------------------------------------------------------
|
||||
void BSlider::DetachedFromWindow()
|
||||
{
|
||||
// TODO rewrite this
|
||||
if (fOffScreenView)
|
||||
{
|
||||
fOffScreenBits->Lock();
|
||||
fOffScreenView->RemoveSelf();
|
||||
fOffScreenBits->Unlock();
|
||||
delete fOffScreenView;
|
||||
fOffScreenView = NULL;
|
||||
}
|
||||
|
||||
if (fOffScreenBits)
|
||||
{
|
||||
delete fOffScreenBits;
|
||||
fOffScreenBits = NULL;
|
||||
}
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
void BSlider::MessageReceived(BMessage *msg)
|
||||
@@ -268,6 +298,21 @@ void BSlider::FrameMoved(BPoint new_position)
|
||||
//------------------------------------------------------------------------------
|
||||
void BSlider::FrameResized(float w,float h)
|
||||
{
|
||||
if (fOffScreenView)
|
||||
{
|
||||
fOffScreenBits->Lock();
|
||||
fOffScreenView->RemoveSelf();
|
||||
fOffScreenView->ResizeTo(Bounds().Width(), Bounds().Height());
|
||||
fOffScreenBits->Unlock();
|
||||
}
|
||||
else
|
||||
fOffScreenView = new BView(Bounds(), "", B_FOLLOW_NONE, B_WILL_DRAW);
|
||||
|
||||
if (fOffScreenBits)
|
||||
delete fOffScreenBits;
|
||||
|
||||
fOffScreenBits = new BBitmap(Bounds(), B_CMAP8, true, false);
|
||||
fOffScreenBits->AddChild(fOffScreenView);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
void BSlider::KeyDown(const char *bytes, int32 numBytes)
|
||||
@@ -398,16 +443,19 @@ void BSlider::GetLimits(int32 *minimum, int32 *maximum)
|
||||
//------------------------------------------------------------------------------
|
||||
void BSlider::Draw(BRect updateRect)
|
||||
{
|
||||
fOffScreenBits->Lock();
|
||||
DrawSlider();
|
||||
fOffScreenView->Sync();
|
||||
fOffScreenBits->Unlock();
|
||||
|
||||
if (fOffScreenBits)
|
||||
DrawBitmap(fOffScreenBits, B_ORIGIN);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
void BSlider::DrawSlider()
|
||||
{
|
||||
// TODO: Draw into fOffScreenView and draw fOffScreenBits on the view
|
||||
// Write drawing code for a vertical slider
|
||||
|
||||
SetHighColor(ViewColor());
|
||||
FillRect(Bounds());
|
||||
OffscreenView()->SetHighColor(ViewColor());
|
||||
OffscreenView()->FillRect(Bounds());
|
||||
|
||||
DrawBar();
|
||||
DrawHashMarks();
|
||||
@@ -422,37 +470,38 @@ void BSlider::DrawSlider()
|
||||
void BSlider::DrawBar()
|
||||
{
|
||||
BRect frame = BarFrame();
|
||||
BView *view = OffscreenView();
|
||||
|
||||
if (fUseFillColor)
|
||||
{
|
||||
if (fOrientation == B_HORIZONTAL)
|
||||
{
|
||||
SetHighColor(fBarColor);
|
||||
FillRect(BRect((float)floor(frame.left + 1 + Position() * (frame.Width() - 2)),
|
||||
frame.top, frame.right, frame.bottom));
|
||||
view->SetHighColor(fBarColor);
|
||||
view->FillRect(BRect((float)floor(frame.left + 1 + Position() *
|
||||
(frame.Width() - 2)), frame.top, frame.right, frame.bottom));
|
||||
|
||||
SetHighColor(fFillColor);
|
||||
FillRect(BRect(frame.left, frame.top,
|
||||
view->SetHighColor(fFillColor);
|
||||
view->FillRect(BRect(frame.left, frame.top,
|
||||
(float)floor(frame.left + 1 + Position() * (frame.Width() - 2)),
|
||||
frame.bottom));
|
||||
}
|
||||
else
|
||||
{
|
||||
SetHighColor(fBarColor);
|
||||
FillRect(BRect(frame.left, frame.top, frame.right,
|
||||
view->SetHighColor(fBarColor);
|
||||
view->FillRect(BRect(frame.left, frame.top, frame.right,
|
||||
(float)floor(frame.bottom - 1 - Position() * (frame.Height() - 2))));
|
||||
|
||||
SetHighColor(fFillColor);
|
||||
FillRect(BRect(frame.left,
|
||||
(float)floor(frame.bottom - 1 - Position() * (frame.Height() - 2)),
|
||||
frame.right, frame.bottom));
|
||||
view->SetHighColor(fFillColor);
|
||||
view->FillRect(BRect(frame.left,
|
||||
(float)floor(frame.bottom - 1 - Position() *
|
||||
(frame.Height() - 2)), frame.right, frame.bottom));
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
SetHighColor(fBarColor);
|
||||
FillRect(frame);
|
||||
view->SetHighColor(fBarColor);
|
||||
view->FillRect(frame);
|
||||
}
|
||||
|
||||
rgb_color no_tint = ui_color(B_PANEL_BACKGROUND_COLOR),
|
||||
@@ -461,29 +510,37 @@ void BSlider::DrawBar()
|
||||
darken2 = tint_color(no_tint, B_DARKEN_2_TINT),
|
||||
darkenmax = tint_color(no_tint, B_DARKEN_MAX_TINT);
|
||||
|
||||
SetHighColor(darken1);
|
||||
StrokeLine(BPoint(frame.left, frame.top), BPoint(frame.left + 1.0f, frame.top));
|
||||
StrokeLine(BPoint(frame.left, frame.bottom), BPoint(frame.left + 1.0f, frame.bottom));
|
||||
StrokeLine(BPoint(frame.right - 1.0f, frame.top), BPoint(frame.right, frame.top));
|
||||
view->SetHighColor(darken1);
|
||||
view->StrokeLine(BPoint(frame.left, frame.top),
|
||||
BPoint(frame.left + 1.0f, frame.top));
|
||||
view->StrokeLine(BPoint(frame.left, frame.bottom),
|
||||
BPoint(frame.left + 1.0f, frame.bottom));
|
||||
view->StrokeLine(BPoint(frame.right - 1.0f, frame.top),
|
||||
BPoint(frame.right, frame.top));
|
||||
|
||||
SetHighColor(darken2);
|
||||
StrokeLine(BPoint(frame.left + 1.0f, frame.top), BPoint(frame.right - 1.0f, frame.top));
|
||||
StrokeLine(BPoint(frame.left, frame.bottom - 1.0f), BPoint(frame.left, frame.top + 1.0f));
|
||||
view->SetHighColor(darken2);
|
||||
view->StrokeLine(BPoint(frame.left + 1.0f, frame.top),
|
||||
BPoint(frame.right - 1.0f, frame.top));
|
||||
view->StrokeLine(BPoint(frame.left, frame.bottom - 1.0f),
|
||||
BPoint(frame.left, frame.top + 1.0f));
|
||||
|
||||
SetHighColor(lightenmax);
|
||||
StrokeLine(BPoint(frame.left + 1.0f, frame.bottom), BPoint(frame.right, frame.bottom));
|
||||
StrokeLine(BPoint(frame.right, frame.top + 1.0f));
|
||||
view->SetHighColor(lightenmax);
|
||||
view->StrokeLine(BPoint(frame.left + 1.0f, frame.bottom),
|
||||
BPoint(frame.right, frame.bottom));
|
||||
view->StrokeLine(BPoint(frame.right, frame.top + 1.0f));
|
||||
|
||||
frame.InsetBy(1.0f, 1.0f);
|
||||
|
||||
SetHighColor(darkenmax);
|
||||
StrokeLine(BPoint(frame.left, frame.bottom), BPoint(frame.left, frame.top));
|
||||
StrokeLine(BPoint(frame.right, frame.top));
|
||||
view->SetHighColor(darkenmax);
|
||||
view->StrokeLine(BPoint(frame.left, frame.bottom),
|
||||
BPoint(frame.left, frame.top));
|
||||
view->StrokeLine(BPoint(frame.right, frame.top));
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
void BSlider::DrawHashMarks()
|
||||
{
|
||||
BRect frame = HashMarksFrame();
|
||||
BView *view = OffscreenView();
|
||||
rgb_color no_tint = ui_color(B_PANEL_BACKGROUND_COLOR),
|
||||
lightenmax = tint_color(no_tint, B_LIGHTEN_MAX_TINT),
|
||||
darken2 = tint_color(no_tint, B_DARKEN_2_TINT);
|
||||
@@ -497,11 +554,11 @@ void BSlider::DrawHashMarks()
|
||||
{
|
||||
for (int32 i = 0; i < fHashMarkCount; i++)
|
||||
{
|
||||
SetHighColor(darken2);
|
||||
StrokeLine(BPoint(pos, frame.top),
|
||||
view->SetHighColor(darken2);
|
||||
view->StrokeLine(BPoint(pos, frame.top),
|
||||
BPoint(pos, frame.top + 5));
|
||||
SetHighColor(lightenmax);
|
||||
StrokeLine(BPoint(pos + 1, frame.top),
|
||||
view->SetHighColor(lightenmax);
|
||||
view->StrokeLine(BPoint(pos + 1, frame.top),
|
||||
BPoint(pos + 1, frame.top + 5));
|
||||
|
||||
pos += factor;
|
||||
@@ -511,11 +568,11 @@ void BSlider::DrawHashMarks()
|
||||
{
|
||||
for (int32 i = 0; i < fHashMarkCount; i++)
|
||||
{
|
||||
SetHighColor(darken2);
|
||||
StrokeLine(BPoint(frame.left, pos),
|
||||
view->SetHighColor(darken2);
|
||||
view->StrokeLine(BPoint(frame.left, pos),
|
||||
BPoint(frame.left + 5, pos));
|
||||
SetHighColor(lightenmax);
|
||||
StrokeLine(BPoint(frame.left, pos + 1),
|
||||
view->SetHighColor(lightenmax);
|
||||
view->StrokeLine(BPoint(frame.left, pos + 1),
|
||||
BPoint(frame.left + 5, pos + 1));
|
||||
|
||||
pos += factor;
|
||||
@@ -531,11 +588,11 @@ void BSlider::DrawHashMarks()
|
||||
{
|
||||
for (int32 i = 0; i < fHashMarkCount; i++)
|
||||
{
|
||||
SetHighColor(darken2);
|
||||
StrokeLine(BPoint(pos, frame.bottom - 5),
|
||||
view->SetHighColor(darken2);
|
||||
view->StrokeLine(BPoint(pos, frame.bottom - 5),
|
||||
BPoint(pos, frame.bottom));
|
||||
SetHighColor(lightenmax);
|
||||
StrokeLine(BPoint(pos + 1, frame.bottom - 5),
|
||||
view->SetHighColor(lightenmax);
|
||||
view->StrokeLine(BPoint(pos + 1, frame.bottom - 5),
|
||||
BPoint(pos + 1, frame.bottom));
|
||||
|
||||
pos += factor;
|
||||
@@ -545,11 +602,11 @@ void BSlider::DrawHashMarks()
|
||||
{
|
||||
for (int32 i = 0; i < fHashMarkCount; i++)
|
||||
{
|
||||
SetHighColor(darken2);
|
||||
StrokeLine(BPoint(frame.right - 5, pos),
|
||||
view->SetHighColor(darken2);
|
||||
view->StrokeLine(BPoint(frame.right - 5, pos),
|
||||
BPoint(frame.right, pos));
|
||||
SetHighColor(lightenmax);
|
||||
StrokeLine(BPoint(frame.right - 5, pos + 1),
|
||||
view->SetHighColor(lightenmax);
|
||||
view->StrokeLine(BPoint(frame.right - 5, pos + 1),
|
||||
BPoint(frame.right, pos + 1));
|
||||
|
||||
pos += factor;
|
||||
@@ -568,14 +625,16 @@ void BSlider::DrawThumb()
|
||||
//------------------------------------------------------------------------------
|
||||
void BSlider::DrawFocusMark()
|
||||
{
|
||||
SetHighColor(ui_color(B_KEYBOARD_NAVIGATION_COLOR));
|
||||
StrokeRect(Bounds());
|
||||
OffscreenView()->SetHighColor(ui_color(B_KEYBOARD_NAVIGATION_COLOR));
|
||||
OffscreenView()->StrokeRect(Bounds());
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
void BSlider::DrawText()
|
||||
{
|
||||
BRect bounds(Bounds());
|
||||
SetHighColor(0, 0, 0);
|
||||
BView *view = OffscreenView();
|
||||
|
||||
view->SetHighColor(0, 0, 0);
|
||||
|
||||
font_height fheight;
|
||||
|
||||
@@ -584,13 +643,13 @@ void BSlider::DrawText()
|
||||
if (Orientation() == B_HORIZONTAL)
|
||||
{
|
||||
if (Label())
|
||||
DrawString(Label(), BPoint(2.0f, (float)ceil(fheight.ascent)));
|
||||
view->DrawString(Label(), BPoint(2.0f, (float)ceil(fheight.ascent)));
|
||||
|
||||
if (fMinLimitStr)
|
||||
DrawString(fMinLimitStr, BPoint(2.0f, bounds.bottom - 4.0f));
|
||||
view->DrawString(fMinLimitStr, BPoint(2.0f, bounds.bottom - 4.0f));
|
||||
|
||||
if (fMaxLimitStr)
|
||||
DrawString(fMaxLimitStr, BPoint(bounds.right -
|
||||
view->DrawString(fMaxLimitStr, BPoint(bounds.right -
|
||||
StringWidth(fMaxLimitStr) - 2.0f, bounds.bottom - 4.0f));
|
||||
}
|
||||
else
|
||||
@@ -598,16 +657,16 @@ void BSlider::DrawText()
|
||||
float ascent = (float)ceil(fheight.ascent);
|
||||
|
||||
if (Label())
|
||||
DrawString(Label(), BPoint(bounds.Width() / 2.0f -
|
||||
view->DrawString(Label(), BPoint(bounds.Width() / 2.0f -
|
||||
StringWidth(Label()) / 2.0f, ascent));
|
||||
|
||||
if (fMaxLimitStr)
|
||||
DrawString(fMaxLimitStr, BPoint(bounds.Width() / 2.0f -
|
||||
view->DrawString(fMaxLimitStr, BPoint(bounds.Width() / 2.0f -
|
||||
StringWidth(fMaxLimitStr) / 2.0f, ascent +
|
||||
(Label() ? (float)ceil(ascent + fheight.descent + 2.0f) : 0.0f)));
|
||||
|
||||
if (fMinLimitStr)
|
||||
DrawString(fMinLimitStr, BPoint(bounds.Width() / 2.0f -
|
||||
view->DrawString(fMinLimitStr, BPoint(bounds.Width() / 2.0f -
|
||||
StringWidth(fMinLimitStr) / 2.0f,
|
||||
bounds.bottom - 2.0f));
|
||||
}
|
||||
@@ -912,8 +971,7 @@ bool BSlider::FillColor(rgb_color *bar_color) const
|
||||
//------------------------------------------------------------------------------
|
||||
BView *BSlider::OffscreenView() const
|
||||
{
|
||||
// TODO: return fOffscreenView
|
||||
return (BView*)this;
|
||||
return fOffScreenView;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
orientation BSlider::Orientation() const
|
||||
@@ -947,6 +1005,7 @@ void BSlider::SetFont(const BFont *font, uint32 properties)
|
||||
void BSlider::_DrawBlockThumb()
|
||||
{
|
||||
BRect frame = ThumbFrame();
|
||||
BView *view = OffscreenView();
|
||||
|
||||
rgb_color no_tint = ui_color(B_PANEL_BACKGROUND_COLOR),
|
||||
lighten2 = tint_color(no_tint, B_LIGHTEN_2_TINT),
|
||||
@@ -955,70 +1014,71 @@ void BSlider::_DrawBlockThumb()
|
||||
darkenmax = tint_color(no_tint, B_DARKEN_MAX_TINT);
|
||||
|
||||
// Outline
|
||||
SetHighColor(darken3);
|
||||
StrokeLine(BPoint(frame.left, frame.bottom - 2.0f),
|
||||
view->SetHighColor(darken3);
|
||||
view->StrokeLine(BPoint(frame.left, frame.bottom - 2.0f),
|
||||
BPoint(frame.left, frame.top + 1.0f));
|
||||
StrokeLine(BPoint(frame.left + 1.0f, frame.top),
|
||||
view->StrokeLine(BPoint(frame.left + 1.0f, frame.top),
|
||||
BPoint(frame.right - 2.0f, frame.top));
|
||||
StrokeLine(BPoint(frame.right, frame.top + 2.0f),
|
||||
view->StrokeLine(BPoint(frame.right, frame.top + 2.0f),
|
||||
BPoint(frame.right, frame.bottom - 1.0f));
|
||||
StrokeLine(BPoint(frame.left + 2.0f, frame.bottom),
|
||||
view->StrokeLine(BPoint(frame.left + 2.0f, frame.bottom),
|
||||
BPoint(frame.right - 1.0f, frame.bottom));
|
||||
|
||||
// First bevel
|
||||
frame.InsetBy(1.0f, 1.0f);
|
||||
|
||||
SetHighColor(lighten2);
|
||||
FillRect(frame);
|
||||
view->SetHighColor(lighten2);
|
||||
view->FillRect(frame);
|
||||
|
||||
SetHighColor(darkenmax);
|
||||
StrokeLine(BPoint(frame.left, frame.bottom),
|
||||
view->SetHighColor(darkenmax);
|
||||
view->StrokeLine(BPoint(frame.left, frame.bottom),
|
||||
BPoint(frame.right - 1.0f, frame.bottom));
|
||||
StrokeLine(BPoint(frame.right, frame.bottom - 1),
|
||||
view->StrokeLine(BPoint(frame.right, frame.bottom - 1),
|
||||
BPoint(frame.right, frame.top));
|
||||
|
||||
frame.InsetBy(1.0f, 1.0f);
|
||||
|
||||
// Second bevel and center dots
|
||||
SetHighColor(darken2);
|
||||
StrokeLine(BPoint(frame.left, frame.bottom),
|
||||
view->SetHighColor(darken2);
|
||||
view->StrokeLine(BPoint(frame.left, frame.bottom),
|
||||
BPoint(frame.right, frame.bottom));
|
||||
StrokeLine(BPoint(frame.right, frame.top));
|
||||
view->StrokeLine(BPoint(frame.right, frame.top));
|
||||
|
||||
if (Orientation() == B_HORIZONTAL)
|
||||
{
|
||||
StrokeLine(BPoint(frame.left + 6.0f, frame.top + 2.0f),
|
||||
view->StrokeLine(BPoint(frame.left + 6.0f, frame.top + 2.0f),
|
||||
BPoint(frame.left + 6.0f, frame.top + 2.0f));
|
||||
StrokeLine(BPoint(frame.left + 6.0f, frame.top + 4.0f),
|
||||
view->StrokeLine(BPoint(frame.left + 6.0f, frame.top + 4.0f),
|
||||
BPoint(frame.left + 6.0f, frame.top + 4.0f));
|
||||
StrokeLine(BPoint(frame.left + 6.0f, frame.top + 6.0f),
|
||||
view->StrokeLine(BPoint(frame.left + 6.0f, frame.top + 6.0f),
|
||||
BPoint(frame.left + 6.0f, frame.top + 6.0f));
|
||||
}
|
||||
else
|
||||
{
|
||||
StrokeLine(BPoint(frame.left + 2.0f, frame.top + 6.0f),
|
||||
view->StrokeLine(BPoint(frame.left + 2.0f, frame.top + 6.0f),
|
||||
BPoint(frame.left + 2.0f, frame.top + 6.0f));
|
||||
StrokeLine(BPoint(frame.left + 4.0f, frame.top + 6.0f),
|
||||
view->StrokeLine(BPoint(frame.left + 4.0f, frame.top + 6.0f),
|
||||
BPoint(frame.left + 4.0f, frame.top + 6.0f));
|
||||
StrokeLine(BPoint(frame.left + 6.0f, frame.top + 6.0f),
|
||||
view->StrokeLine(BPoint(frame.left + 6.0f, frame.top + 6.0f),
|
||||
BPoint(frame.left + 6.0f, frame.top + 6.0f));
|
||||
}
|
||||
|
||||
StrokeLine(BPoint(frame.right + 1.0f, frame.bottom + 1.0f),
|
||||
view->StrokeLine(BPoint(frame.right + 1.0f, frame.bottom + 1.0f),
|
||||
BPoint(frame.right + 1.0f, frame.bottom + 1.0f));
|
||||
|
||||
frame.InsetBy(1.0f, 1.0f);
|
||||
|
||||
// Third bevel
|
||||
SetHighColor(no_tint);
|
||||
StrokeLine(BPoint(frame.left, frame.bottom),
|
||||
view->SetHighColor(no_tint);
|
||||
view->StrokeLine(BPoint(frame.left, frame.bottom),
|
||||
BPoint(frame.right, frame.bottom));
|
||||
StrokeLine(BPoint(frame.right, frame.top));
|
||||
view->StrokeLine(BPoint(frame.right, frame.top));
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
void BSlider::_DrawTriangleThumb()
|
||||
{
|
||||
BRect frame = ThumbFrame();
|
||||
BView *view = OffscreenView();
|
||||
|
||||
rgb_color no_tint = ui_color(B_PANEL_BACKGROUND_COLOR),
|
||||
lighten1 = tint_color(no_tint, B_LIGHTEN_1_TINT),
|
||||
@@ -1031,52 +1091,52 @@ void BSlider::_DrawTriangleThumb()
|
||||
|
||||
if (Orientation() == B_HORIZONTAL)
|
||||
{
|
||||
SetHighColor(lighten1);
|
||||
FillTriangle(BPoint(frame.left, frame.bottom - 1.0f),
|
||||
view->SetHighColor(lighten1);
|
||||
view->FillTriangle(BPoint(frame.left, frame.bottom - 1.0f),
|
||||
BPoint(frame.left + 6.0f, frame.top),
|
||||
BPoint(frame.right, frame.bottom - 1.0f));
|
||||
|
||||
SetHighColor(darkenmax);
|
||||
StrokeLine(BPoint(frame.right, frame.bottom + 1),
|
||||
view->SetHighColor(darkenmax);
|
||||
view->StrokeLine(BPoint(frame.right, frame.bottom + 1),
|
||||
BPoint(frame.left, frame.bottom + 1));
|
||||
StrokeLine(BPoint(frame.right, frame.bottom),
|
||||
view->StrokeLine(BPoint(frame.right, frame.bottom),
|
||||
BPoint(frame.left + 6.0f, frame.top));
|
||||
|
||||
SetHighColor(darken2);
|
||||
StrokeLine(BPoint(frame.right - 1, frame.bottom),
|
||||
view->SetHighColor(darken2);
|
||||
view->StrokeLine(BPoint(frame.right - 1, frame.bottom),
|
||||
BPoint(frame.left, frame.bottom));
|
||||
StrokeLine(BPoint(frame.left, frame.bottom),
|
||||
view->StrokeLine(BPoint(frame.left, frame.bottom),
|
||||
BPoint(frame.left + 5.0f, frame.top + 1));
|
||||
|
||||
SetHighColor(no_tint);
|
||||
StrokeLine(BPoint(frame.right - 2, frame.bottom - 1.0f),
|
||||
view->SetHighColor(no_tint);
|
||||
view->StrokeLine(BPoint(frame.right - 2, frame.bottom - 1.0f),
|
||||
BPoint(frame.left + 3.0f, frame.bottom - 1.0f));
|
||||
StrokeLine(BPoint(frame.right - 3, frame.bottom - 2.0f),
|
||||
view->StrokeLine(BPoint(frame.right - 3, frame.bottom - 2.0f),
|
||||
BPoint(frame.left + 6.0f, frame.top + 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
SetHighColor(lighten1);
|
||||
FillTriangle(BPoint(frame.left + 1.0f, frame.top),
|
||||
view->SetHighColor(lighten1);
|
||||
view->FillTriangle(BPoint(frame.left + 1.0f, frame.top),
|
||||
BPoint(frame.left + 7.0f, frame.top + 6.0f),
|
||||
BPoint(frame.left + 1.0f, frame.bottom));
|
||||
|
||||
SetHighColor(darkenmax);
|
||||
StrokeLine(BPoint(frame.left, frame.top + 1),
|
||||
view->SetHighColor(darkenmax);
|
||||
view->StrokeLine(BPoint(frame.left, frame.top + 1),
|
||||
BPoint(frame.left, frame.bottom));
|
||||
StrokeLine(BPoint(frame.left + 1.0f, frame.bottom),
|
||||
view->StrokeLine(BPoint(frame.left + 1.0f, frame.bottom),
|
||||
BPoint(frame.left + 7.0f, frame.top + 6.0f));
|
||||
|
||||
SetHighColor(darken2);
|
||||
StrokeLine(BPoint(frame.left, frame.top),
|
||||
view->SetHighColor(darken2);
|
||||
view->StrokeLine(BPoint(frame.left, frame.top),
|
||||
BPoint(frame.left, frame.bottom - 1));
|
||||
StrokeLine(BPoint(frame.left + 1.0f, frame.top),
|
||||
view->StrokeLine(BPoint(frame.left + 1.0f, frame.top),
|
||||
BPoint(frame.left + 6.0f, frame.top + 5.0f));
|
||||
|
||||
SetHighColor(no_tint);
|
||||
StrokeLine(BPoint(frame.left + 1.0f, frame.top + 2.0f),
|
||||
view->SetHighColor(no_tint);
|
||||
view->StrokeLine(BPoint(frame.left + 1.0f, frame.top + 2.0f),
|
||||
BPoint(frame.left + 1.0f, frame.bottom - 1.0f));
|
||||
StrokeLine(BPoint(frame.left + 2.0f, frame.bottom - 2.0f),
|
||||
view->StrokeLine(BPoint(frame.left + 2.0f, frame.bottom - 2.0f),
|
||||
BPoint(frame.left + 6.0f, frame.top + 6.0f));
|
||||
}
|
||||
}
|
||||
@@ -1124,6 +1184,7 @@ BSlider &BSlider::operator=(const BSlider &)
|
||||
//------------------------------------------------------------------------------
|
||||
void BSlider::_InitObject()
|
||||
{
|
||||
// TODO: Move common init code here
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
Reference in New Issue
Block a user