1075e65c7SAxel Dörfler /* 2*8296330eSStephan Aßmus * Copyright 2006-2009, Haiku, Inc. All Rights Reserved. 3075e65c7SAxel Dörfler * Distributed under the terms of the MIT License. 4075e65c7SAxel Dörfler */ 552a38012Sejakowatz #ifndef _STATUS_BAR_H 652a38012Sejakowatz #define _STATUS_BAR_H 752a38012Sejakowatz 852a38012Sejakowatz 9075e65c7SAxel Dörfler #include <String.h> 1052a38012Sejakowatz #include <View.h> 1152a38012Sejakowatz 1252a38012Sejakowatz 13075e65c7SAxel Dörfler class BStatusBar : public BView { 1452a38012Sejakowatz public: 15*8296330eSStephan Aßmus BStatusBar(BRect frame, const char* name, 16*8296330eSStephan Aßmus const char* label = NULL, 1752a38012Sejakowatz const char* trailingLabel = NULL); 18*8296330eSStephan Aßmus BStatusBar(const char* name, 19*8296330eSStephan Aßmus const char* label = NULL, 20d23c4822SIngo Weinhold const char* trailingLabel = NULL); 2152a38012Sejakowatz BStatusBar(BMessage* archive); 2252a38012Sejakowatz virtual ~BStatusBar(); 2352a38012Sejakowatz 2452a38012Sejakowatz static BArchivable* Instantiate(BMessage* archive); 25*8296330eSStephan Aßmus virtual status_t Archive(BMessage* archive, 26*8296330eSStephan Aßmus bool deep = true) const; 2752a38012Sejakowatz 2852a38012Sejakowatz virtual void AttachedToWindow(); 2952a38012Sejakowatz virtual void MessageReceived(BMessage* message); 3052a38012Sejakowatz virtual void Draw(BRect updateRect); 3152a38012Sejakowatz 3252a38012Sejakowatz virtual void SetBarColor(rgb_color color); 3352a38012Sejakowatz virtual void SetBarHeight(float height); 34075e65c7SAxel Dörfler 3552a38012Sejakowatz virtual void SetText(const char* string); 3652a38012Sejakowatz virtual void SetTrailingText(const char* string); 3752a38012Sejakowatz virtual void SetMaxValue(float max); 3852a38012Sejakowatz 39075e65c7SAxel Dörfler virtual void Update(float delta, const char* text = NULL, 40075e65c7SAxel Dörfler const char* trailingText = NULL); 41075e65c7SAxel Dörfler virtual void Reset(const char* label = NULL, 42075e65c7SAxel Dörfler const char* trailingLabel = NULL); 43075e65c7SAxel Dörfler virtual void SetTo(float value, const char* text = NULL, 44075e65c7SAxel Dörfler const char* trailingText = NULL); 4552a38012Sejakowatz 4652a38012Sejakowatz float CurrentValue() const; 4752a38012Sejakowatz float MaxValue() const; 4852a38012Sejakowatz rgb_color BarColor() const; 4952a38012Sejakowatz float BarHeight() const; 50075e65c7SAxel Dörfler 5152a38012Sejakowatz const char* Text() const; 5252a38012Sejakowatz const char* TrailingText() const; 5352a38012Sejakowatz const char* Label() const; 5452a38012Sejakowatz const char* TrailingLabel() const; 5552a38012Sejakowatz 56*8296330eSStephan Aßmus virtual void MouseDown(BPoint where); 57*8296330eSStephan Aßmus virtual void MouseUp(BPoint where); 5852a38012Sejakowatz virtual void WindowActivated(bool state); 59*8296330eSStephan Aßmus virtual void MouseMoved(BPoint where, uint32 transit, 60075e65c7SAxel Dörfler const BMessage* dragMessage); 6152a38012Sejakowatz virtual void DetachedFromWindow(); 62075e65c7SAxel Dörfler virtual void FrameMoved(BPoint newPosition); 63075e65c7SAxel Dörfler virtual void FrameResized(float newWidth, float newHeight); 6452a38012Sejakowatz 65075e65c7SAxel Dörfler virtual BHandler* ResolveSpecifier(BMessage* message, int32 index, 66*8296330eSStephan Aßmus BMessage* specifier, int32 what, 67*8296330eSStephan Aßmus const char* property); 6852a38012Sejakowatz 6952a38012Sejakowatz virtual void ResizeToPreferred(); 70075e65c7SAxel Dörfler virtual void GetPreferredSize(float* _width, float* _height); 71075e65c7SAxel Dörfler virtual void MakeFocus(bool focus = true); 7252a38012Sejakowatz virtual void AllAttached(); 7352a38012Sejakowatz virtual void AllDetached(); 7452a38012Sejakowatz virtual status_t GetSupportedSuites(BMessage* data); 7552a38012Sejakowatz 7652a38012Sejakowatz virtual status_t Perform(perform_code d, void* arg); 7752a38012Sejakowatz 78d23c4822SIngo Weinhold // Layout methods 79d23c4822SIngo Weinhold virtual BSize MinSize(); 80d23c4822SIngo Weinhold virtual BSize MaxSize(); 81d23c4822SIngo Weinhold virtual BSize PreferredSize(); 82d23c4822SIngo Weinhold 8352a38012Sejakowatz private: 84*8296330eSStephan Aßmus // FBC memebers 8552a38012Sejakowatz virtual void _ReservedStatusBar2(); 8652a38012Sejakowatz virtual void _ReservedStatusBar3(); 8752a38012Sejakowatz virtual void _ReservedStatusBar4(); 8852a38012Sejakowatz 89075e65c7SAxel Dörfler BStatusBar& operator=(const BStatusBar& other); 9052a38012Sejakowatz 91075e65c7SAxel Dörfler void _InitObject(); 92f466d35dSStephan Aßmus void _SetTextData(BString& text, const char* string, 93*8296330eSStephan Aßmus const BString& combineWith, 94*8296330eSStephan Aßmus bool rightAligned); 95*8296330eSStephan Aßmus BRect _BarFrame(const font_height* fontHeight 96*8296330eSStephan Aßmus = NULL) const; 97075e65c7SAxel Dörfler float _BarPosition(const BRect& barFrame) const; 9852a38012Sejakowatz 99075e65c7SAxel Dörfler BString fLabel; 100075e65c7SAxel Dörfler BString fTrailingLabel; 101075e65c7SAxel Dörfler BString fText; 102075e65c7SAxel Dörfler BString fTrailingText; 10352a38012Sejakowatz float fMax; 10452a38012Sejakowatz float fCurrent; 10552a38012Sejakowatz float fBarHeight; 106f466d35dSStephan Aßmus float fTextDivider; 10752a38012Sejakowatz rgb_color fBarColor; 10852a38012Sejakowatz bool fCustomBarHeight; 109075e65c7SAxel Dörfler 110f466d35dSStephan Aßmus uint32 _reserved[5]; 11152a38012Sejakowatz }; 11252a38012Sejakowatz 11352a38012Sejakowatz #endif // _STATUS_BAR_H 114