1/* 2Open Tracker License 3 4Terms and Conditions 5 6Copyright (c) 1991-2000, Be Incorporated. All rights reserved. 7 8Permission is hereby granted, free of charge, to any person obtaining a copy of 9this software and associated documentation files (the "Software"), to deal in 10the Software without restriction, including without limitation the rights to 11use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 12of the Software, and to permit persons to whom the Software is furnished to do 13so, subject to the following conditions: 14 15The above copyright notice and this permission notice applies to all licensees 16and shall be included in all copies or substantial portions of the Software. 17 18THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY, 20FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 22AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION 23WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 25Except as contained in this notice, the name of Be Incorporated shall not be 26used in advertising or otherwise to promote the sale, use or other dealings in 27this Software without prior written authorization from Be Incorporated. 28 29Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered 30trademarks of Be Incorporated in the United States and other countries. Other 31brand product names are registered trademarks or trademarks of their respective 32holders. 33All 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 48const float kSepItemWidth = 5.0f; 49 50 51enum drag_and_drop_selection { 52 kNoSelection, 53 kDeskbarMenuSelection, 54 kAppMenuSelection, 55 kAnyMenuSelection 56}; 57 58 59class BBitmap; 60class TBarView; 61class TBarMenuTitle; 62class TTeamMenuItem; 63 64 65class TExpandoMenuBar : public BMenuBar { 66public: 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 BMenuItem* ItemAtPoint(BPoint point); 87 TTeamMenuItem* TeamItemAtPoint(BPoint location, 88 BMenuItem** _item = NULL); 89 bool InDeskbarMenu(BPoint) const; 90 91 void CheckItemSizes(int32 delta, bool reset = false); 92 93 float MinHorizontalItemWidth(); 94 float MaxHorizontalItemWidth(); 95 96 menu_layout MenuLayout() const; 97 void SetMenuLayout(menu_layout layout); 98 99 void SizeWindow(int32 delta); 100 bool CheckForSizeOverrun(); 101 102 void StartMonitoringWindows(); 103 void StopMonitoringWindows(); 104 105private: 106 static int CompareByName(const void* first, 107 const void* second); 108 static int32 monitor_team_windows(void* arg); 109 110 void AddTeam(BList* team, BBitmap* icon, char* name, 111 char* signature); 112 void AddTeam(team_id team, const char* signature); 113 void RemoveTeam(team_id team, bool partial); 114 115 void _FinishedDrag(bool invoke = false); 116 117 bool CheckForSizeOverrunVertical(); 118 bool CheckForSizeOverrunHorizontal(); 119 120 float MaxHorizontalWidth(); 121 122 bool Vertical() const 123 { return MenuLayout() == B_ITEMS_IN_COLUMN; }; 124private: 125 TBarView* fBarView; 126 bool fOverflow : 1; 127 bool fUnderflow : 1; 128 bool fFirstBuild : 1; 129 130 TTeamMenuItem* fPreviousDragTargetItem; 131 BMenuItem* fLastMousedOverItem; 132 BMenuItem* fLastClickedItem; 133 bigtime_t fLastClickTime; 134 BList fTeamList; 135 136 static bool sDoMonitor; 137 static thread_id sMonThread; 138 static BLocker sMonLocker; 139}; 140 141 142#endif // EXPANDO_MENU_BAR_H 143