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