xref: /haiku/headers/os/interface/StatusBar.h (revision 1e36cfc2721ef13a187c6f7354dc9cbc485e89d3)
1 /*
2  * Copyright 2006, Haiku, Inc. All Rights Reserved.
3  * Distributed under the terms of the MIT License.
4  */
5 #ifndef _STATUS_BAR_H
6 #define _STATUS_BAR_H
7 
8 
9 #include <String.h>
10 #include <View.h>
11 
12 
13 class BStatusBar : public BView {
14 	public:
15 		BStatusBar(BRect frame, const char* name, const char* label = NULL,
16 			const char* trailingLabel = NULL);
17 		BStatusBar(BMessage* archive);
18 		virtual ~BStatusBar();
19 
20 		static BArchivable* Instantiate(BMessage* archive);
21 		virtual	status_t Archive(BMessage* archive, bool deep = true) const;
22 
23 		virtual void AttachedToWindow();
24 		virtual void MessageReceived(BMessage* message);
25 		virtual void Draw(BRect updateRect);
26 
27 		virtual void SetBarColor(rgb_color color);
28 		virtual void SetBarHeight(float height);
29 
30 		virtual void SetText(const char* string);
31 		virtual void SetTrailingText(const char* string);
32 		virtual void SetMaxValue(float max);
33 
34 		virtual void Update(float delta, const char* text = NULL,
35 			const char* trailingText = NULL);
36 		virtual void Reset(const char* label = NULL,
37 			const char* trailingLabel = NULL);
38 		virtual void SetTo(float value, const char* text = NULL,
39 			const char* trailingText = NULL);
40 
41 		float CurrentValue() const;
42 		float MaxValue() const;
43 		rgb_color BarColor() const;
44 		float BarHeight() const;
45 
46 		const char* Text() const;
47 		const char* TrailingText() const;
48 		const char* Label() const;
49 		const char* TrailingLabel() const;
50 
51 		virtual	void MouseDown(BPoint point);
52 		virtual	void MouseUp(BPoint point);
53 		virtual	void WindowActivated(bool state);
54 		virtual	void MouseMoved(BPoint point, uint32 transit,
55 			const BMessage* dragMessage);
56 		virtual	void DetachedFromWindow();
57 		virtual	void FrameMoved(BPoint newPosition);
58 		virtual	void FrameResized(float newWidth, float newHeight);
59 
60 		virtual BHandler* ResolveSpecifier(BMessage* message, int32 index,
61 			BMessage* specifier, int32 what, const char* property);
62 
63 		virtual void ResizeToPreferred();
64 		virtual void GetPreferredSize(float* _width, float* _height);
65 		virtual void MakeFocus(bool focus = true);
66 		virtual void AllAttached();
67 		virtual void AllDetached();
68 		virtual status_t GetSupportedSuites(BMessage* data);
69 
70 		virtual status_t Perform(perform_code d, void* arg);
71 
72 	private:
73 		virtual	void _ReservedStatusBar2();
74 		virtual	void _ReservedStatusBar3();
75 		virtual	void _ReservedStatusBar4();
76 
77 		BStatusBar &operator=(const BStatusBar& other);
78 
79 		void _InitObject();
80 		void _SetTextData(BString& text, float& width, const char* string, float pos,
81 			bool rightAligned);
82 		BRect _BarFrame(const font_height* fontHeight = NULL) const;
83 		float _BarPosition(const BRect& barFrame) const;
84 
85 		BString fLabel;
86 		BString fTrailingLabel;
87 		BString fText;
88 		BString fTrailingText;
89 		float fMax;
90 		float fCurrent;
91 		float fBarHeight;
92 		float fLabelWidth;
93 		float fTrailingLabelWidth;
94 		float fTextWidth;
95 		float fTrailingTextWidth;
96 		rgb_color fBarColor;
97 		bool fCustomBarHeight;
98 
99 		uint32 _reserved[2];
100 };
101 
102 #endif	// _STATUS_BAR_H
103