1075e65c7SAxel Dörfler /* 2075e65c7SAxel Dörfler * Copyright 2006, 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: 1552a38012Sejakowatz BStatusBar(BRect frame, const char* name, const char* label = NULL, 1652a38012Sejakowatz const char* trailingLabel = NULL); 17*d23c4822SIngo Weinhold BStatusBar(const char* name, const char* label = NULL, 18*d23c4822SIngo Weinhold const char* trailingLabel = NULL); 1952a38012Sejakowatz BStatusBar(BMessage* archive); 2052a38012Sejakowatz virtual ~BStatusBar(); 2152a38012Sejakowatz 2252a38012Sejakowatz static BArchivable* Instantiate(BMessage* archive); 2352a38012Sejakowatz virtual status_t Archive(BMessage* archive, bool deep = true) const; 2452a38012Sejakowatz 2552a38012Sejakowatz virtual void AttachedToWindow(); 2652a38012Sejakowatz virtual void MessageReceived(BMessage* message); 2752a38012Sejakowatz virtual void Draw(BRect updateRect); 2852a38012Sejakowatz 2952a38012Sejakowatz virtual void SetBarColor(rgb_color color); 3052a38012Sejakowatz virtual void SetBarHeight(float height); 31075e65c7SAxel Dörfler 3252a38012Sejakowatz virtual void SetText(const char* string); 3352a38012Sejakowatz virtual void SetTrailingText(const char* string); 3452a38012Sejakowatz virtual void SetMaxValue(float max); 3552a38012Sejakowatz 36075e65c7SAxel Dörfler virtual void Update(float delta, const char* text = NULL, 37075e65c7SAxel Dörfler const char* trailingText = NULL); 38075e65c7SAxel Dörfler virtual void Reset(const char* label = NULL, 39075e65c7SAxel Dörfler const char* trailingLabel = NULL); 40075e65c7SAxel Dörfler virtual void SetTo(float value, const char* text = NULL, 41075e65c7SAxel Dörfler const char* trailingText = NULL); 4252a38012Sejakowatz 4352a38012Sejakowatz float CurrentValue() const; 4452a38012Sejakowatz float MaxValue() const; 4552a38012Sejakowatz rgb_color BarColor() const; 4652a38012Sejakowatz float BarHeight() const; 47075e65c7SAxel Dörfler 4852a38012Sejakowatz const char* Text() const; 4952a38012Sejakowatz const char* TrailingText() const; 5052a38012Sejakowatz const char* Label() const; 5152a38012Sejakowatz const char* TrailingLabel() const; 5252a38012Sejakowatz 5352a38012Sejakowatz virtual void MouseDown(BPoint point); 5452a38012Sejakowatz virtual void MouseUp(BPoint point); 5552a38012Sejakowatz virtual void WindowActivated(bool state); 56075e65c7SAxel Dörfler virtual void MouseMoved(BPoint point, uint32 transit, 57075e65c7SAxel Dörfler const BMessage* dragMessage); 5852a38012Sejakowatz virtual void DetachedFromWindow(); 59075e65c7SAxel Dörfler virtual void FrameMoved(BPoint newPosition); 60075e65c7SAxel Dörfler virtual void FrameResized(float newWidth, float newHeight); 6152a38012Sejakowatz 62075e65c7SAxel Dörfler virtual BHandler* ResolveSpecifier(BMessage* message, int32 index, 63075e65c7SAxel Dörfler BMessage* specifier, int32 what, const char* property); 6452a38012Sejakowatz 6552a38012Sejakowatz virtual void ResizeToPreferred(); 66075e65c7SAxel Dörfler virtual void GetPreferredSize(float* _width, float* _height); 67075e65c7SAxel Dörfler virtual void MakeFocus(bool focus = true); 6852a38012Sejakowatz virtual void AllAttached(); 6952a38012Sejakowatz virtual void AllDetached(); 7052a38012Sejakowatz virtual status_t GetSupportedSuites(BMessage* data); 7152a38012Sejakowatz 7252a38012Sejakowatz virtual status_t Perform(perform_code d, void* arg); 7352a38012Sejakowatz 74*d23c4822SIngo Weinhold // Layout methods 75*d23c4822SIngo Weinhold virtual BSize MinSize(); 76*d23c4822SIngo Weinhold virtual BSize MaxSize(); 77*d23c4822SIngo Weinhold virtual BSize PreferredSize(); 78*d23c4822SIngo Weinhold 7952a38012Sejakowatz private: 8052a38012Sejakowatz virtual void _ReservedStatusBar2(); 8152a38012Sejakowatz virtual void _ReservedStatusBar3(); 8252a38012Sejakowatz virtual void _ReservedStatusBar4(); 8352a38012Sejakowatz 84075e65c7SAxel Dörfler BStatusBar &operator=(const BStatusBar& other); 8552a38012Sejakowatz 86075e65c7SAxel Dörfler void _InitObject(); 87075e65c7SAxel Dörfler void _SetTextData(BString& text, float& width, const char* string, float pos, 88075e65c7SAxel Dörfler bool rightAligned); 89075e65c7SAxel Dörfler BRect _BarFrame(const font_height* fontHeight = NULL) const; 90075e65c7SAxel Dörfler float _BarPosition(const BRect& barFrame) const; 9152a38012Sejakowatz 92075e65c7SAxel Dörfler BString fLabel; 93075e65c7SAxel Dörfler BString fTrailingLabel; 94075e65c7SAxel Dörfler BString fText; 95075e65c7SAxel Dörfler BString fTrailingText; 9652a38012Sejakowatz float fMax; 9752a38012Sejakowatz float fCurrent; 9852a38012Sejakowatz float fBarHeight; 99075e65c7SAxel Dörfler float fLabelWidth; 100075e65c7SAxel Dörfler float fTrailingLabelWidth; 101075e65c7SAxel Dörfler float fTextWidth; 102075e65c7SAxel Dörfler float fTrailingTextWidth; 10352a38012Sejakowatz rgb_color fBarColor; 10452a38012Sejakowatz bool fCustomBarHeight; 105075e65c7SAxel Dörfler 106075e65c7SAxel Dörfler uint32 _reserved[2]; 10752a38012Sejakowatz }; 10852a38012Sejakowatz 10952a38012Sejakowatz #endif // _STATUS_BAR_H 110