xref: /haiku/src/apps/terminal/SmartTabView.h (revision 22440f4105cafc95cc1d49f9bc65bb395c527d86)
1 /*
2  * Copyright 2007-2010, Haiku. All rights reserved.
3  * Distributed under the terms of the MIT License.
4  *
5  *	Authors:
6  *		Stefano Ceccherini (burton666@libero.it)
7  *		Ingo Weinhold (ingo_weinhold@gmx.de)
8  */
9 #ifndef SMART_TAB_VIEW_H
10 #define SMART_TAB_VIEW_H
11 
12 
13 #include <TabView.h>
14 
15 
16 class BPopUpMenu;
17 class BScrollView;
18 
19 
20 class SmartTabView : public BTabView {
21 public:
22 			class Listener;
23 
24 public:
25 								SmartTabView(BRect frame, const char* name,
26 									button_width width = B_WIDTH_AS_USUAL,
27 									uint32 resizingMode = B_FOLLOW_ALL,
28 									uint32 flags = B_FULL_UPDATE_ON_RESIZE
29 										| B_WILL_DRAW | B_NAVIGABLE_JUMP
30 										| B_FRAME_EVENTS | B_NAVIGABLE);
31 								SmartTabView(const char* name,
32 									button_width width = B_WIDTH_AS_USUAL,
33 									uint32 flags = B_FULL_UPDATE_ON_RESIZE
34 										| B_WILL_DRAW | B_NAVIGABLE_JUMP
35 										| B_FRAME_EVENTS | B_NAVIGABLE
36 										| B_SUPPORTS_LAYOUT);
37 	virtual						~SmartTabView();
38 
39 			void				SetInsets(float left, float top, float right,
40 									float bottom);
41 
42 	virtual void				MouseDown(BPoint where);
43 
44 	virtual void				AttachedToWindow();
45 	virtual void				AllAttached();
46 
47 	virtual	void				Select(int32 tab);
48 
49 	virtual	void				AddTab(BView* target, BTab* tab = NULL);
50 	virtual BTab*				RemoveTab(int32 index);
51 			void				MoveTab(int32 index, int32 newIndex);
52 
53 	virtual BRect				DrawTabs();
54 
55 			void				SetScrollView(BScrollView* scrollView);
56 
57 			void				SetListener(Listener* listener)
58 									{ fListener = listener; }
59 
60 private:
61 			int32				_ClickedTabIndex(const BPoint& point);
62 
63 private:
64 			BRect				fInsets;
65 			BScrollView*		fScrollView;
66 			Listener*			fListener;
67 };
68 
69 
70 class SmartTabView::Listener {
71 public:
72 	virtual						~Listener();
73 
74 	virtual	void				TabSelected(SmartTabView* tabView, int32 index);
75 	virtual	void				TabDoubleClicked(SmartTabView* tabView,
76 									BPoint point, int32 index);
77 	virtual	void				TabMiddleClicked(SmartTabView* tabView,
78 									BPoint point, int32 index);
79 	virtual	void				TabRightClicked(SmartTabView* tabView,
80 									BPoint point, int32 index);
81 };
82 
83 
84 #endif // SMART_TAB_VIEW_H
85