SectionEdit.h revision 6d6408d6
1/*
2 * Copyright 2004-2010, Haiku, Inc. All Rights Reserved.
3 * Distributed under the terms of the MIT License.
4 *
5 * Authors:
6 *		Mike Berg <mike@berg-net.us>
7 *		Julun <host.haiku@gmx.de>
8 *
9 */
10#ifndef _SECTION_EDIT_H
11#define _SECTION_EDIT_H
12
13
14#include <Control.h>
15
16
17class BBitmap;
18class BList;
19
20
21class TSection {
22public:
23								TSection(BRect frame);
24
25			BRect				Bounds() const;
26			void				SetFrame(BRect frame);
27			BRect				Frame() const;
28
29private:
30			BRect				fFrame;
31};
32
33
34class TSectionEdit: public BControl {
35public:
36								TSectionEdit(BRect frame, const char* name,
37									uint32 sections);
38	virtual						~TSectionEdit();
39
40	virtual	void				AttachedToWindow();
41	virtual	void				Draw(BRect updateRect);
42	virtual	void				MouseDown(BPoint point);
43	virtual	void				MakeFocus(bool focused = true);
44	virtual	void				KeyDown(const char* bytes, int32 numBytes);
45
46	uint32						CountSections() const;
47	int32						FocusIndex() const;
48	BRect						SectionArea() const;
49
50protected:
51	virtual	void				InitView();
52
53	// hooks
54	virtual	void				DrawBorder(const BRect& updateRect);
55	virtual	void				DrawSection(uint32 index, bool isFocus) {}
56	virtual	void				DrawSeparator(uint32 index) {}
57
58	virtual	void				SectionFocus(uint32 index) {}
59	virtual	void				SectionChange(uint32 index, uint32 value) {}
60	virtual	void				SetSections(BRect area) {}
61	virtual	float				SeparatorWidth() const;
62
63	virtual	void				DoUpPress() {}
64	virtual	void				DoDownPress() {}
65
66	virtual	void				DispatchMessage();
67	virtual	void				BuildDispatch(BMessage* message) = 0;
68
69protected:
70			BList*				fSectionList;
71
72			BRect				fUpRect;
73			BRect				fDownRect;
74			BRect				fSectionArea;
75
76			int32				fFocus;
77			uint32				fSectionCount;
78			uint32				fHoldValue;
79
80			bool				fShowFocus;
81};
82
83
84#endif	// _SECTION_EDIT_H
85