xref: /haiku/headers/os/interface/StatusBar.h (revision f75a7bf508f3156d63a14f8fd77c5e0ca4d08c42)
1 /*
2  * Copyright 2006-2008, 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(const char* name, const char* label = NULL,
18 			const char* trailingLabel = NULL);
19 		BStatusBar(BMessage* archive);
20 		virtual ~BStatusBar();
21 
22 		static BArchivable* Instantiate(BMessage* archive);
23 		virtual	status_t Archive(BMessage* archive, bool deep = true) const;
24 
25 		virtual void AttachedToWindow();
26 		virtual void MessageReceived(BMessage* message);
27 		virtual void Draw(BRect updateRect);
28 
29 		virtual void SetBarColor(rgb_color color);
30 		virtual void SetBarHeight(float height);
31 
32 		virtual void SetText(const char* string);
33 		virtual void SetTrailingText(const char* string);
34 		virtual void SetMaxValue(float max);
35 
36 		virtual void Update(float delta, const char* text = NULL,
37 			const char* trailingText = NULL);
38 		virtual void Reset(const char* label = NULL,
39 			const char* trailingLabel = NULL);
40 		virtual void SetTo(float value, const char* text = NULL,
41 			const char* trailingText = NULL);
42 
43 		float CurrentValue() const;
44 		float MaxValue() const;
45 		rgb_color BarColor() const;
46 		float BarHeight() const;
47 
48 		const char* Text() const;
49 		const char* TrailingText() const;
50 		const char* Label() const;
51 		const char* TrailingLabel() const;
52 
53 		virtual	void MouseDown(BPoint point);
54 		virtual	void MouseUp(BPoint point);
55 		virtual	void WindowActivated(bool state);
56 		virtual	void MouseMoved(BPoint point, uint32 transit,
57 			const BMessage* dragMessage);
58 		virtual	void DetachedFromWindow();
59 		virtual	void FrameMoved(BPoint newPosition);
60 		virtual	void FrameResized(float newWidth, float newHeight);
61 
62 		virtual BHandler* ResolveSpecifier(BMessage* message, int32 index,
63 			BMessage* specifier, int32 what, const char* property);
64 
65 		virtual void ResizeToPreferred();
66 		virtual void GetPreferredSize(float* _width, float* _height);
67 		virtual void MakeFocus(bool focus = true);
68 		virtual void AllAttached();
69 		virtual void AllDetached();
70 		virtual status_t GetSupportedSuites(BMessage* data);
71 
72 		virtual status_t Perform(perform_code d, void* arg);
73 
74 		// Layout methods
75 		virtual BSize MinSize();
76 		virtual BSize MaxSize();
77 		virtual BSize PreferredSize();
78 
79 	private:
80 		virtual	void _ReservedStatusBar2();
81 		virtual	void _ReservedStatusBar3();
82 		virtual	void _ReservedStatusBar4();
83 
84 		BStatusBar &operator=(const BStatusBar& other);
85 
86 		void _InitObject();
87 		void _SetTextData(BString& text, const char* string,
88 			const BString& combineWith, bool rightAligned);
89 		BRect _BarFrame(const font_height* fontHeight = NULL) const;
90 		float _BarPosition(const BRect& barFrame) const;
91 
92 		BString fLabel;
93 		BString fTrailingLabel;
94 		BString fText;
95 		BString fTrailingText;
96 		float fMax;
97 		float fCurrent;
98 		float fBarHeight;
99 		float fTextDivider;
100 		rgb_color fBarColor;
101 		bool fCustomBarHeight;
102 
103 		uint32 _reserved[5];
104 };
105 
106 #endif	// _STATUS_BAR_H
107