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 EXPANDO_MENU_BAR_H 36 #define EXPANDO_MENU_BAR_H 37 38 39 // application list 40 // top level at window 41 // in expanded mode horizontal and vertical 42 43 44 #include <MenuBar.h> 45 #include <Locker.h> 46 47 48 const float kSepItemWidth = 5.0f; 49 50 51 enum drag_and_drop_selection { 52 kNoSelection, 53 kDeskbarMenuSelection, 54 kAppMenuSelection, 55 kAnyMenuSelection 56 }; 57 58 59 class BBitmap; 60 class TBarView; 61 class TBarMenuTitle; 62 class TTeamMenuItem; 63 64 65 class TExpandoMenuBar : public BMenuBar { 66 public: 67 TExpandoMenuBar(menu_layout layout, 68 TBarView* barView = NULL); 69 70 virtual void AllAttached(); 71 virtual void AttachedToWindow(); 72 virtual void DetachedFromWindow(); 73 74 virtual void Draw(BRect update); 75 virtual void DrawBackground(BRect update); 76 77 virtual void MessageReceived(BMessage* message); 78 79 virtual void MouseDown(BPoint where); 80 virtual void MouseMoved(BPoint where, uint32 code, 81 const BMessage* message); 82 virtual void MouseUp(BPoint where); 83 84 void BuildItems(); 85 86 TTeamMenuItem* TeamItemAtPoint(BPoint location, 87 BMenuItem** _item = NULL); 88 bool InDeskbarMenu(BPoint) const; 89 90 void CheckItemSizes(int32 delta, bool reset = false); 91 92 float MinHorizontalItemWidth(); 93 float MaxHorizontalItemWidth(); 94 95 menu_layout MenuLayout() const; 96 void SetMenuLayout(menu_layout layout); 97 98 void SizeWindow(int32 delta); 99 bool CheckForSizeOverrun(); 100 101 void StartMonitoringWindows(); 102 void StopMonitoringWindows(); 103 104 private: 105 static int CompareByName(const void* first, 106 const void* second); 107 static int32 monitor_team_windows(void* arg); 108 109 void AddTeam(BList* team, BBitmap* icon, char* name, 110 char* signature); 111 void AddTeam(team_id team, const char* signature); 112 void RemoveTeam(team_id team, bool partial); 113 114 void _FinishedDrag(bool invoke = false); 115 116 bool CheckForSizeOverrunVertical(); 117 bool CheckForSizeOverrunHorizontal(); 118 119 float MaxHorizontalWidth(); 120 121 bool Vertical() const 122 { return MenuLayout() == B_ITEMS_IN_COLUMN; }; 123 private: 124 TBarView* fBarView; 125 bool fOverflow : 1; 126 bool fUnderflow : 1; 127 bool fFirstBuild : 1; 128 129 TTeamMenuItem* fPreviousDragTargetItem; 130 BMenuItem* fLastMousedOverItem; 131 BMenuItem* fLastClickedItem; 132 bigtime_t fLastClickTime; 133 BList fTeamList; 134 135 static bool sDoMonitor; 136 static thread_id sMonThread; 137 static BLocker sMonLocker; 138 }; 139 140 141 #endif // EXPANDO_MENU_BAR_H 142