git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24770 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler 2008-04-03 12:19:44 +00:00
parent 9a87228642
commit 70f87b87d9

View File

@ -34,36 +34,42 @@ All rights reserved.
// defines the status area drawn in the bottom left corner of a Tracker window
#include "CountView.h"
#include <Application.h>
#include "AutoLock.h"
#include "Bitmaps.h"
#include "CountView.h"
#include "ContainerWindow.h"
#include "DirMenu.h"
#include "PoseView.h"
BCountView::BCountView(BRect bounds, BPoseView* view)
: BView(bounds, "CountVw", B_FOLLOW_LEFT + B_FOLLOW_BOTTOM,
B_PULSE_NEEDED | B_WILL_DRAW),
fLastCount(-1),
fPoseView(view),
fShowingBarberPole(false),
fBarberPoleMap(NULL),
fLastBarberPoleOffset(5),
fStartSpinningAfter(0),
fTypeAheadString("")
const bigtime_t kBarberPoleDelay = 500000;
BCountView::BCountView(BRect bounds, BPoseView* view)
: BView(bounds, "CountVw", B_FOLLOW_LEFT + B_FOLLOW_BOTTOM,
B_PULSE_NEEDED | B_WILL_DRAW),
fLastCount(-1),
fPoseView(view),
fShowingBarberPole(false),
fBarberPoleMap(NULL),
fLastBarberPoleOffset(5),
fStartSpinningAfter(0),
fTypeAheadString("")
{
GetTrackerResources()->GetBitmapResource(B_MESSAGE_TYPE, kResBarberPoleBitmap,
&fBarberPoleMap);
GetTrackerResources()->GetBitmapResource(B_MESSAGE_TYPE,
kResBarberPoleBitmap, &fBarberPoleMap);
}
BCountView::~BCountView()
{
delete fBarberPoleMap;
}
void
BCountView::TrySpinningBarberPole()
{
@ -83,12 +89,14 @@ BCountView::TrySpinningBarberPole()
Invalidate(BarberPoleInnerRect());
}
void
BCountView::Pulse()
{
TrySpinningBarberPole();
}
void
BCountView::EndBarberPole()
{
@ -99,7 +107,6 @@ BCountView::EndBarberPole()
Invalidate();
}
const bigtime_t kBarberPoleDelay = 500000;
void
BCountView::StartBarberPole()
@ -113,6 +120,7 @@ BCountView::StartBarberPole()
// wait a bit before showing the barber pole
}
BRect
BCountView::BarberPoleInnerRect() const
{
@ -123,6 +131,7 @@ BCountView::BarberPoleInnerRect() const
return result;
}
BRect
BCountView::BarberPoleOuterRect() const
{
@ -131,6 +140,7 @@ BCountView::BarberPoleOuterRect() const
return result;
}
BRect
BCountView::TextInvalRect() const
{
@ -138,12 +148,13 @@ BCountView::TextInvalRect() const
result.InsetBy(4, 2);
// if the barber pole is not present, use its space for text
if(fShowingBarberPole)
if (fShowingBarberPole)
result.right -= 10;
return result;
}
BRect
BCountView::TextAndBarberPoleRect() const
{
@ -153,6 +164,7 @@ BCountView::TextAndBarberPoleRect() const
return result;
}
void
BCountView::CheckCount()
{
@ -165,6 +177,7 @@ BCountView::CheckCount()
TrySpinningBarberPole();
}
void
BCountView::Draw(BRect)
{
@ -185,11 +198,12 @@ BCountView::Draw(BRect)
TruncateString(&string, B_TRUNCATE_END, textRect.Width());
if (IsTypingAhead())
if (IsTypingAhead()) {
// use a muted gray for the typeahead
SetHighColor(tint_color(ui_color(B_PANEL_BACKGROUND_COLOR), B_DARKEN_4_TINT));
else
} else
SetHighColor(0, 0, 0);
MovePenTo(textRect.LeftBottom());
DrawString(string.String());
@ -237,6 +251,7 @@ BCountView::Draw(BRect)
DrawBitmap(fBarberPoleMap, destRect);
}
void
BCountView::MouseDown(BPoint)
{
@ -266,6 +281,7 @@ BCountView::MouseDown(BPoint)
}
}
void
BCountView::AttachedToWindow()
{
@ -278,6 +294,7 @@ BCountView::AttachedToWindow()
CheckCount();
}
void
BCountView::SetTypeAhead(const char *string)
{
@ -285,12 +302,14 @@ BCountView::SetTypeAhead(const char *string)
Invalidate();
}
const char *
BCountView::TypeAhead() const
{
return fTypeAheadString.String();
}
bool
BCountView::IsTypingAhead() const
{