From b7b28df0235366cacbff170a4c237d2f7c63564c Mon Sep 17 00:00:00 2001 From: haydentech Date: Wed, 11 Jun 2003 14:13:29 +0000 Subject: [PATCH] Conform more tightly with the BeBook, and fix a few crashing bugs in the process git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3472 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/interface/StatusBar.cpp | 35 ++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/src/kits/interface/StatusBar.cpp b/src/kits/interface/StatusBar.cpp index 45f06fcfc4..a236158bfd 100644 --- a/src/kits/interface/StatusBar.cpp +++ b/src/kits/interface/StatusBar.cpp @@ -201,7 +201,10 @@ void BStatusBar::AttachedToWindow() ResizeTo(Frame().Width(), height); if (Parent()) - SetViewColor(Parent ()->ViewColor()); + { + SetViewColor(Parent()->ViewColor()); + SetLowColor(Parent()->ViewColor()); + } } //------------------------------------------------------------------------------ void BStatusBar::MessageReceived(BMessage *message) @@ -342,12 +345,13 @@ void BStatusBar::SetBarHeight(float height) ResizeTo(frame.Width(), fBarHeight + 16); } //------------------------------------------------------------------------------ -void BStatusBar::SetText ( const char *string ) +void BStatusBar::SetText (const char *string) { if (fText) free(fText); - fText = strdup(string); + if (string) + fText = strdup(string); Invalidate(); } @@ -357,7 +361,8 @@ void BStatusBar::SetTrailingText(const char *string) if (fTrailingText) free(fTrailingText); - fTrailingText = strdup(string); + if (string) + fTrailingText = strdup(string); Invalidate(); } @@ -378,13 +383,15 @@ void BStatusBar::Update(float delta, const char *text, const char *trailingText) if (fText) free(fText); - - fText = strdup(text); + + if (text) + fText = strdup(text); if (fTrailingText) free(fTrailingText); - fTrailingText = strdup(trailingText); + if (trailingText) + fTrailingText = strdup(trailingText); Invalidate(); } @@ -394,17 +401,27 @@ void BStatusBar::Reset(const char *label, const char *trailingLabel) if (fLabel) free(fLabel); - fLabel = strdup(label); + if (label) + fLabel = strdup(label); if (fTrailingLabel) free(fTrailingLabel); - fTrailingLabel = strdup(trailingLabel); + if (trailingLabel) + fTrailingLabel = strdup(trailingLabel); + + if (fText) + free(fText); + + if (fTrailingText) + free(fTrailingText); fCurrent = 0.0f; + fMax = 100.0f; Invalidate(); } +//------------------------------------------------------------------------------ float BStatusBar::CurrentValue() const { return fCurrent;