SectionEdit.h revision 323ba9b7fb40975a7c28fb985b30c3a38352b4e9
1/*
2 * Copyright 2004-2011, 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 *		Hamish Morrison <hamish@lavabit.com>
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 TSectionEdit : public BControl {
22public:
23								TSectionEdit(const char* name,
24									uint32 sections);
25	virtual						~TSectionEdit();
26
27	virtual	void				AttachedToWindow();
28	virtual	void				Draw(BRect updateRect);
29	virtual	void				MouseDown(BPoint point);
30	virtual	void				MakeFocus(bool focused = true);
31	virtual	void				KeyDown(const char* bytes, int32 numBytes);
32
33			BSize				MaxSize();
34			BSize				MinSize();
35			BSize				PreferredSize();
36
37			uint32				CountSections() const;
38			int32				FocusIndex() const;
39			BRect				SectionArea() const;
40
41protected:
42	virtual	void				DrawBorder(const BRect& updateRect);
43	virtual	void				DrawSection(uint32 index, BRect bounds,
44									bool isFocus) {}
45	virtual	void				DrawSeparator(uint32 index, BRect bounds) {}
46
47			BRect				FrameForSection(uint32 index);
48			BRect				FrameForSeparator(uint32 index);
49
50	virtual	void				SectionFocus(uint32 index) {}
51	virtual	void				SectionChange(uint32 index, uint32 value) {}
52	virtual	void				SetSections(BRect area) {}
53
54	virtual	float				SeparatorWidth() = 0;
55	virtual	float				MinSectionWidth() = 0;
56	virtual float				PreferredHeight() = 0;
57
58	virtual	void				DoUpPress() {}
59	virtual	void				DoDownPress() {}
60
61	virtual	void				DispatchMessage();
62	virtual	void				BuildDispatch(BMessage* message) = 0;
63
64			BRect				fUpRect;
65			BRect				fDownRect;
66
67			int32				fFocus;
68			uint32				fSectionCount;
69			uint32				fHoldValue;
70};
71
72
73#endif	// _SECTION_EDIT_H
74