xref: /haiku/src/apps/deskbar/TeamMenuItem.h (revision cbe0a0c436162d78cc3f92a305b64918c839d079)
1 /*
2 Open Tracker License
3 
4 Terms and Conditions
5 
6 Copyright (c) 1991-2000, Be Incorporated. All rights reserved.
7 
8 Permission is hereby granted, free of charge, to any person obtaining a copy of
9 this software and associated documentation files (the "Software"), to deal in
10 the Software without restriction, including without limitation the rights to
11 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
12 of the Software, and to permit persons to whom the Software is furnished to do
13 so, subject to the following conditions:
14 
15 The above copyright notice and this permission notice applies to all licensees
16 and shall be included in all copies or substantial portions of the Software.
17 
18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY,
20 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
21 BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
22 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION
23 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 
25 Except as contained in this notice, the name of Be Incorporated shall not be
26 used in advertising or otherwise to promote the sale, use or other dealings in
27 this Software without prior written authorization from Be Incorporated.
28 
29 Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered
30 trademarks of Be Incorporated in the United States and other countries. Other
31 brand product names are registered trademarks or trademarks of their respective
32 holders.
33 All rights reserved.
34 */
35 #ifndef TEAM_MENU_ITEM_H
36 #define TEAM_MENU_ITEM_H
37 
38 
39 //	Individual team/application listing
40 //	item for TeamMenu in mini/vertical mode
41 //	item for ExpandoMenuBar in vertical or horizontal expanded mode
42 
43 
44 #include "TruncatableMenuItem.h"
45 
46 
47 const float kSwitchWidth = 12.0f;
48 
49 
50 class BBitmap;
51 class TBarView;
52 class TWindowMenuItem;
53 
54 class TTeamMenuItem : public TTruncatableMenuItem {
55 public:
56 								TTeamMenuItem(BList* team, BBitmap* icon,
57 									char* name, char* signature,
58 									float width = -1.0f, float height = -1.0f);
59 								TTeamMenuItem(float width = -1.0f,
60 									float height = -1.0f);
61 	virtual						~TTeamMenuItem();
62 
63 			status_t			Invoke(BMessage* message = NULL);
64 
65 			void				SetOverrideWidth(float width)
66 									{ fOverrideWidth = width; };
67 			void				SetOverrideHeight(float height)
68 									{ fOverrideHeight = height; };
69 			void				SetOverrideSelected(bool selected);
70 
71 			int32				ArrowDirection() const
72 									{ return fArrowDirection; };
73 			void				SetArrowDirection(int32 direction)
74 									{ fArrowDirection = direction; };
75 
76 			BBitmap*			Icon() const { return fIcon; };
77 			void				SetIcon(BBitmap* icon);
78 
79 			bool				IsExpanded() const { return fExpanded; };
80 			void				ToggleExpandState(bool resizeWindow);
81 
82 			BRect				ExpanderBounds() const;
83 			TWindowMenuItem*	ExpandedWindowItem(int32 id);
84 
85 			float				LabelWidth() const { return fLabelWidth; };
86 			BList*				Teams() const { return fTeam; };
87 			const char*			Signature() const { return fSignature; };
88 
89 protected:
90 			void				GetContentSize(float* width, float* height);
91 			void				Draw();
92 			void				DrawContent();
93 			void				DrawExpanderArrow();
94 
95 private:
96 			void				_Init(BList* team, BBitmap* icon,
97 									char* name, char* signature,
98 									float width = -1.0f, float height = -1.0f);
99 
100 			bool				_IsSelected() const;
101 
102 private:
103 			BList*				fTeam;
104 			BBitmap*			fIcon;
105 			char*				fSignature;
106 
107 			float				fOverrideWidth;
108 			float				fOverrideHeight;
109 
110 			TBarView*			fBarView;
111 			float				fLabelWidth;
112 			float				fLabelAscent;
113 			float				fLabelDescent;
114 			float				fLabelHeight;
115 
116 			bool				fOverriddenSelected;
117 
118 			bool				fExpanded;
119 			int32				fArrowDirection;
120 };
121 
122 
123 #endif	// TEAM_MENU_ITEM_H
124