SetLowColor before DrawString

git-svn-id: file:///srv/svn/repos/haiku/trunk/current@1342 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Marc Flerackers 2002-10-02 12:05:29 +00:00
parent 1d616657b9
commit a0cbca4f9f

View File

@ -92,11 +92,13 @@ void BButton::Draw(BRect updateRect)
darken2 = tint_color(no_tint, B_DARKEN_2_TINT),
darken4 = tint_color(no_tint, B_DARKEN_4_TINT),
darkenmax = tint_color(no_tint, B_DARKEN_MAX_TINT);
if (IsDefault())
rect = DrawDefault(rect, IsEnabled());
else
if (!IsDefault())
{
SetHighColor(no_tint);
StrokeRect(rect);
rect.InsetBy(1,1);
}
if (IsEnabled())
{
@ -208,6 +210,7 @@ void BButton::Draw(BRect updateRect)
float y = Bounds().Height() / 2.0f + (float)ceil(font.Size() / 2.0f);
SetHighColor(darkenmax);
SetLowColor(lighten2);
DrawString(Label(), BPoint(x, y));
// Focus
@ -285,6 +288,7 @@ void BButton::Draw(BRect updateRect)
float y = Bounds().Height() / 2.0f + (float)ceil(font.Size() / 2.0f);
SetHighColor(tint_color(no_tint, B_DISABLED_LABEL_TINT));
SetLowColor(lighten2);
DrawString(Label(), BPoint(x, y));
}
}
@ -347,14 +351,14 @@ void BButton::MakeDefault(bool flag)
if (flag)
{
ResizeBy(6.0f, 6.0f);
MoveBy(-3.0f, -3.0f);
ResizeBy(8.0f, 8.0f);
MoveBy(-4.0f, -4.0f);
window->SetDefaultButton((BButton*)this);
}
else
{
ResizeBy(-6.0f, -6.0f);
MoveBy(3.0f, 3.0f);
ResizeBy(-8.0f, -8.0f);
MoveBy(4.0f, 4.0f);
window->SetDefaultButton(NULL);
}
}
@ -435,7 +439,9 @@ void BButton::GetPreferredSize (float *width, float *height)
//------------------------------------------------------------------------------
void BButton::ResizeToPreferred()
{
BControl::ResizeToPreferred();
float width, height;
GetPreferredSize(&width, &height);
ResizeTo(width,height);
}
//------------------------------------------------------------------------------
status_t BButton::Invoke(BMessage *message)
@ -497,63 +503,8 @@ BButton &BButton::operator=(const BButton &)
//------------------------------------------------------------------------------
BRect BButton::DrawDefault(BRect bounds, bool enabled)
{
rgb_color no_tint = ui_color(B_PANEL_BACKGROUND_COLOR),
lighten1 = tint_color(no_tint, B_LIGHTEN_1_TINT),
darken1 = tint_color(no_tint, B_DARKEN_1_TINT),
darken4 = tint_color(no_tint, B_DARKEN_4_TINT);
if (enabled)
{
// Dark border
BeginLineArray(4);
AddLine(BPoint(bounds.left, bounds.bottom - 1.0f),
BPoint(bounds.left, bounds.top + 1.0f), darken4);
AddLine(BPoint(bounds.left + 1.0f, bounds.top),
BPoint(bounds.right - 1.0f, bounds.top), darken4);
AddLine(BPoint(bounds.right, bounds.top + 1.0f),
BPoint(bounds.right, bounds.bottom - 1.0f), darken4);
AddLine(BPoint(bounds.left + 1.0f, bounds.bottom),
BPoint(bounds.right - 1.0f, bounds.bottom), darken4);
EndLineArray();
bounds.InsetBy(1.0f, 1.0f);
// Bevel
SetHighColor(darken1);
StrokeRect(bounds);
bounds.InsetBy(1.0f, 1.0f);
// Filling
SetHighColor(lighten1);
FillRect(bounds);
bounds.InsetBy(2.0f, 2.0f);
}
else
{
// Dark border
BeginLineArray(4);
AddLine(BPoint(bounds.left, bounds.bottom - 1.0f),
BPoint(bounds.left, bounds.top + 1.0f), darken1);
AddLine(BPoint(bounds.left + 1.0f, bounds.top),
BPoint(bounds.right - 1.0f, bounds.top), darken1);
AddLine(BPoint(bounds.right, bounds.top + 1.0f),
BPoint(bounds.right, bounds.bottom - 1.0f), darken1);
AddLine(BPoint(bounds.left + 1.0f, bounds.bottom),
BPoint(bounds.right - 1.0f, bounds.bottom), darken1);
EndLineArray();
bounds.InsetBy(1.0f, 1.0f);
// Filling
SetHighColor(lighten1);
FillRect(bounds);
bounds.InsetBy(3.0f, 3.0f);
}
return bounds;
// TODO:
return BRect();
}
//------------------------------------------------------------------------------
status_t Execute()