From 70f87b87d961ff3feb1e6c56df796e110ae640f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Thu, 3 Apr 2008 12:19:44 +0000 Subject: [PATCH] Cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24770 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/tracker/CountView.cpp | 71 +++++++++++++++++++++------------- 1 file changed, 45 insertions(+), 26 deletions(-) diff --git a/src/kits/tracker/CountView.cpp b/src/kits/tracker/CountView.cpp index 0fe095d3af..3627e4854b 100644 --- a/src/kits/tracker/CountView.cpp +++ b/src/kits/tracker/CountView.cpp @@ -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 #include "AutoLock.h" #include "Bitmaps.h" -#include "CountView.h" #include "ContainerWindow.h" #include "DirMenu.h" #include "PoseView.h" + +const bigtime_t kBarberPoleDelay = 500000; + + BCountView::BCountView(BRect bounds, BPoseView* view) - : BView(bounds, "CountVw", B_FOLLOW_LEFT + B_FOLLOW_BOTTOM, + : 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("") - + 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,25 +89,26 @@ BCountView::TrySpinningBarberPole() Invalidate(BarberPoleInnerRect()); } -void + +void BCountView::Pulse() { TrySpinningBarberPole(); } -void + +void BCountView::EndBarberPole() { if (!fShowingBarberPole) return; - + fShowingBarberPole = false; Invalidate(); } -const bigtime_t kBarberPoleDelay = 500000; -void +void BCountView::StartBarberPole() { AutoLock lock(Window()); @@ -113,7 +120,8 @@ BCountView::StartBarberPole() // wait a bit before showing the barber pole } -BRect + +BRect BCountView::BarberPoleInnerRect() const { BRect result = Bounds(); @@ -123,7 +131,8 @@ BCountView::BarberPoleInnerRect() const return result; } -BRect + +BRect BCountView::BarberPoleOuterRect() const { BRect result(BarberPoleInnerRect()); @@ -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) { @@ -179,17 +192,18 @@ BCountView::Draw(BRect) itemString << fLastCount << " items"; } else itemString << TypeAhead(); - + BString string(itemString); BRect textRect(TextInvalRect()); 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()); @@ -212,7 +226,7 @@ BCountView::Draw(BRect) EndLineArray(); return; } - + BRect barberPoleRect(BarberPoleOuterRect()); AddLine(barberPoleRect.LeftTop(), barberPoleRect.RightTop(), shadow); @@ -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,20 +294,23 @@ BCountView::AttachedToWindow() CheckCount(); } -void + +void BCountView::SetTypeAhead(const char *string) { fTypeAheadString = string; Invalidate(); } + const char * BCountView::TypeAhead() const { return fTypeAheadString.String(); } -bool + +bool BCountView::IsTypingAhead() const { return fTypeAheadString.Length() != 0;