• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ TTeamMenuItem类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中TTeamMenuItem的典型用法代码示例。如果您正苦于以下问题:C++ TTeamMenuItem类的具体用法?C++ TTeamMenuItem怎么用?C++ TTeamMenuItem使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了TTeamMenuItem类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: _FinishedDrag

void
TExpandoMenuBar::MouseMoved(BPoint where, uint32 code, const BMessage* message)
{
	if (!message) {
		// force a cleanup
		_FinishedDrag();
		BMenuBar::MouseMoved(where, code, message);
		return;
	}

	uint32 buttons;
	if (!(Window()->CurrentMessage())
		|| Window()->CurrentMessage()->FindInt32("buttons", (int32*)&buttons)
		< B_OK)
		buttons = 0;

	if (buttons == 0)
		return;

	switch (code) {
		case B_ENTERED_VIEW:
			// fPreviousDragTargetItem should always be NULL here anyways.
			if (fPreviousDragTargetItem)
				_FinishedDrag();

			fBarView->CacheDragData(message);
			fPreviousDragTargetItem = NULL;
			break;

		case B_OUTSIDE_VIEW:
			// NOTE: Should not be here, but for the sake of defensive
			// programming...
		case B_EXITED_VIEW:
			_FinishedDrag();
			break;

		case B_INSIDE_VIEW:
			if (fBarView->Dragging()) {
				TTeamMenuItem* item = NULL;
				for (int32 i = 0; i < CountItems(); i++) {
					BMenuItem* _item = ItemAt(i);
					if (_item->Frame().Contains(where)) {
						item = dynamic_cast<TTeamMenuItem*>(_item);
						break;
					}
				}
				if (item == fPreviousDragTargetItem)
					break;
				if (fPreviousDragTargetItem != NULL)
					fPreviousDragTargetItem->SetOverrideSelected(false);
				if (item != NULL)
					item->SetOverrideSelected(true);
				fPreviousDragTargetItem = item;
			}
			break;
	}
}
开发者ID:,项目名称:,代码行数:57,代码来源:


示例2: CountItems

void
TExpandoMenuBar::AddTeam(team_id team, const char* signature)
{
	int32 itemCount = CountItems();
	for (int32 i = 0; i < itemCount; i++) {
		// Only add to team menu items
		TTeamMenuItem* item = dynamic_cast<TTeamMenuItem*>(ItemAt(i));
		if (item != NULL && strcasecmp(item->Signature(), signature) == 0
			&& !(item->Teams()->HasItem((void*)(addr_t)team))) {
			item->Teams()->AddItem((void*)(addr_t)team);
			break;
		}
	}
}
开发者ID:,项目名称:,代码行数:14,代码来源:


示例3: Frame

void
TExpandoMenuBar::CheckItemSizes(int32 delta)
{
	float width = Frame().Width();
	int32 count = CountItems();
	bool reset = false;
	float newWidth = 0;
	float fullWidth = (sMinimumWindowWidth * count);

	if (!fBarView->Vertical()) {
		// in this case there are 2 extra items:
		//   - The Be Menu
		//   - The little separator item
		fullWidth = fullWidth - (sMinimumWindowWidth * 2)
			+ (fBeMenuWidth + kSepItemWidth);
		width -= (fBeMenuWidth + kSepItemWidth);
		count -= 2;
	}

	if (delta >= 0 && fullWidth > width) {
		fOverflow = true;
		reset = true;
		newWidth = floorf(width / count);
	} else if (delta < 0 && fOverflow) {
		reset = true;
		if (fullWidth > width)
			newWidth = floorf(width / count);
		else
			newWidth = sMinimumWindowWidth;
	}
	if (newWidth > sMinimumWindowWidth)
		newWidth = sMinimumWindowWidth;

	if (reset) {
		SetMaxContentWidth(newWidth);
		if (newWidth == sMinimumWindowWidth)
			fOverflow = false;
		InvalidateLayout();

		for (int32 index = fFirstApp; ; index++) {
			TTeamMenuItem* item = (TTeamMenuItem*)ItemAt(index);
			if (!item)
				break;
			item->SetOverrideWidth(newWidth);
		}

		Invalidate();
		Window()->UpdateIfNeeded();
	}
}
开发者ID:,项目名称:,代码行数:50,代码来源:


示例4: TTeamMenuItem

void
TExpandoMenuBar::AddTeam(BList* team, BBitmap* icon, char* name,
	char* signature)
{
	float itemWidth = fVertical ? fBarView->Bounds().Width()
		: sMinimumWindowWidth;
	float itemHeight = -1.0f;

	desk_settings* settings = ((TBarApp*)be_app)->Settings();
	TTeamMenuItem* item = new TTeamMenuItem(team, icon, name, signature,
		itemWidth, itemHeight, fDrawLabel, fVertical);

	if (settings->trackerAlwaysFirst && !strcmp(signature, kTrackerSignature)) {
		AddItem(item, fFirstApp);
	} else if (settings->sortRunningApps) {
		TTeamMenuItem* teamItem
			= dynamic_cast<TTeamMenuItem*>(ItemAt(fFirstApp));
		int32 firstApp = fFirstApp;

		// if Tracker should always be the first item, we need to skip it
		// when sorting in the current item
		if (settings->trackerAlwaysFirst && teamItem != NULL
			&& !strcmp(teamItem->Signature(), kTrackerSignature)) {
			firstApp++;
		}

		int32 count = CountItems(), i;
		for (i = firstApp; i < count; i++) {
			teamItem = dynamic_cast<TTeamMenuItem*>(ItemAt(i));
			if (teamItem != NULL && strcasecmp(teamItem->Name(), name) > 0) {
				AddItem(item, i);
				break;
			}
		}
		// was the item added to the list yet?
		if (i == count)
			AddItem(item);
	} else
		AddItem(item);

	if (fVertical) {
		if (item && fShowTeamExpander && fExpandNewTeams)
			item->ToggleExpandState(false);

		fBarView->SizeWindow(BScreen(Window()).Frame());
	} else
		CheckItemSizes(1);

	Window()->UpdateIfNeeded();
}
开发者ID:,项目名称:,代码行数:50,代码来源:


示例5:

void
TBarView::SaveExpandedItems()
{
	if (fExpando == NULL || fExpando->CountItems() <= 0)
		return;

	// Get a list of the signatures of expanded apps. Can't use
	// team_id because there can be more than one team per application
	for (int32 i = 0; i < fExpando->CountItems(); i++) {
		TTeamMenuItem* teamItem
			= dynamic_cast<TTeamMenuItem*>(fExpando->ItemAt(i));

		if (teamItem != NULL && teamItem->IsExpanded())
			AddExpandedItem(teamItem->Signature());
	}
}
开发者ID:Barrett17,项目名称:haiku-contacts-kit-old,代码行数:16,代码来源:BarView.cpp


示例6: locker

void
TExpandoMenuBar::RemoveTeam(team_id team, bool partial)
{
	TWindowMenuItem* windowItem = NULL;

	for (int32 i = CountItems() - 1; i >= 0; i--) {
		TTeamMenuItem* item = dynamic_cast<TTeamMenuItem*>(ItemAt(i));
		if (item != NULL && item->Teams()->HasItem((void*)(addr_t)team)) {
			item->Teams()->RemoveItem(team);
			if (partial)
				return;

			BAutolock locker(sMonLocker);
				// make the update thread wait
			RemoveItem(i);
			if (item == fPreviousDragTargetItem)
				fPreviousDragTargetItem = NULL;

			if (item == fLastMousedOverItem)
				fLastMousedOverItem = NULL;

			if (item == fLastClickedItem)
				fLastClickedItem = NULL;

			delete item;
			while ((windowItem = dynamic_cast<TWindowMenuItem*>(
					ItemAt(i))) != NULL) {
				// Also remove window items (if there are any)
				RemoveItem(i);
				if (windowItem == fLastMousedOverItem)
					fLastMousedOverItem = NULL;

				if (windowItem == fLastClickedItem)
					fLastClickedItem = NULL;

				delete windowItem;
			}
			SizeWindow(-1);
			Window()->UpdateIfNeeded();
			return;
		}
	}
}
开发者ID:,项目名称:,代码行数:43,代码来源:


示例7:

void
TBarView::ExpandItems()
{
	if (fExpandoMenuBar == NULL || !fVertical || fState != kExpandoState
		|| !fBarApp->Settings()->superExpando
		|| fExpandedItems.CountItems() <= 0) {
		return;
	}

	// Start at the 'bottom' of the list working up.
	// Prevents being thrown off by expanding items.
	for (int32 i = fExpandoMenuBar->CountItems() - 1; i >= 0; i--) {
		TTeamMenuItem* teamItem
			= dynamic_cast<TTeamMenuItem*>(fExpandoMenuBar->ItemAt(i));

		if (teamItem != NULL) {
			// Start at the 'bottom' of the fExpandedItems list working up
			// matching the order of the fExpandoMenuBar list in the outer loop.
			for (int32 j = fExpandedItems.CountItems() - 1; j >= 0; j--) {
				BString* itemSig =
					static_cast<BString*>(fExpandedItems.ItemAt(j));

				if (itemSig->Compare(teamItem->Signature()) == 0) {
					// Found it, expand the item and delete signature from
					// the list so that we don't consider it for later items.
					teamItem->ToggleExpandState(false);
					fExpandedItems.RemoveItem(j);
					delete itemSig;
					break;
				}
			}
		}
	}

	// Clean up the expanded items list
	RemoveExpandedItems();
}
开发者ID:DonCN,项目名称:haiku,代码行数:37,代码来源:BarView.cpp


示例8:

void
TExpandoMenuBar::_DoneTracking(BPoint point)
{
	TTeamMenuItem* lastItem = dynamic_cast<TTeamMenuItem*>(fLastClickedItem);
	if (lastItem == NULL)
		return;

	if (!lastItem->ExpanderBounds().Contains(point))
		return;

	lastItem->ToggleExpandState(true);
	lastItem->SetArrowDirection(lastItem->IsExpanded()
		? BControlLook::B_DOWN_ARROW
		: BControlLook::B_RIGHT_ARROW);

	Invalidate(lastItem->ExpanderBounds());
}
开发者ID:,项目名称:,代码行数:17,代码来源:


示例9: switch

void
TExpandoMenuBar::MessageReceived(BMessage* message)
{
	int32 index;
	TTeamMenuItem* item;

	switch (message->what) {
		case B_SOME_APP_LAUNCHED:
		{
			BList* teams = NULL;
			message->FindPointer("teams", (void**)&teams);

			BBitmap* icon = NULL;
			message->FindPointer("icon", (void**)&icon);

			const char* signature = NULL;
			message->FindString("sig", &signature);

			uint32 flags = 0;
			message->FindInt32("flags", ((int32*) &flags));

			const char* name = NULL;
			message->FindString("name", &name);

			AddTeam(teams, icon, strdup(name), strdup(signature));
			break;
		}

		case B_MOUSE_WHEEL_CHANGED:
		{
			float deltaY = 0;
			message->FindFloat("be:wheel_delta_y", &deltaY);
			if (deltaY == 0)
				return;

			TInlineScrollView* scrollView
				= dynamic_cast<TInlineScrollView*>(Parent());
			if (scrollView == NULL)
				return;

			float largeStep;
			float smallStep;
			scrollView->GetSteps(&smallStep, &largeStep);

			// pressing the option/command/control key scrolls faster
			if (modifiers() & (B_OPTION_KEY | B_COMMAND_KEY | B_CONTROL_KEY))
				deltaY *= largeStep;
			else
				deltaY *= smallStep;

			scrollView->ScrollBy(deltaY);
			break;
		}

		case kAddTeam:
			AddTeam(message->FindInt32("team"), message->FindString("sig"));
			break;

		case kRemoveTeam:
		{
			team_id team = -1;
			message->FindInt32("team", &team);

			RemoveTeam(team, true);
			break;
		}

		case B_SOME_APP_QUIT:
		{
			team_id team = -1;
			message->FindInt32("team", &team);

			RemoveTeam(team, false);
			break;
		}

		case kMinimizeTeam:
		{
			index = message->FindInt32("itemIndex");
			item = dynamic_cast<TTeamMenuItem*>(ItemAt(index));
			if (item == NULL)
				break;

			TShowHideMenuItem::TeamShowHideCommon(B_MINIMIZE_WINDOW,
				item->Teams(),
				item->Menu()->ConvertToScreen(item->Frame()),
				true);
			break;
		}

		case kBringTeamToFront:
		{
			index = message->FindInt32("itemIndex");
			item = dynamic_cast<TTeamMenuItem*>(ItemAt(index));
			if (item == NULL)
				break;

			TShowHideMenuItem::TeamShowHideCommon(B_BRING_TO_FRONT,
				item->Teams(), item->Menu()->ConvertToScreen(item->Frame()),
				true);
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:


示例10: Window

void
TExpandoMenuBar::MouseDown(BPoint where)
{
	BMessage* message = Window()->CurrentMessage();
	BMenuItem* menuItem;
	TTeamMenuItem* item = TeamItemAtPoint(where, &menuItem);

	// check for three finger salute, a.k.a. Vulcan Death Grip
	if (message != NULL && item != NULL && !fBarView->Dragging()) {
		int32 modifiers = 0;
		message->FindInt32("modifiers", &modifiers);

		if ((modifiers & B_COMMAND_KEY) != 0
			&& (modifiers & B_CONTROL_KEY) != 0
			&& (modifiers & B_SHIFT_KEY) != 0) {
			const BList* teams = item->Teams();
			int32 teamCount = teams->CountItems();

			team_id teamID;
			for (int32 team = 0; team < teamCount; team++) {
				teamID = (team_id)teams->ItemAt(team);
				kill_team(teamID);
				// remove the team immediately from display
				RemoveTeam(teamID, false);
			}

			return;
		}

		// control click - show all/hide all shortcut
		if ((modifiers & B_CONTROL_KEY) != 0) {
			// show/hide item's teams
			BMessage showMessage((modifiers & B_SHIFT_KEY) != 0
				? kMinimizeTeam : kBringTeamToFront);
			showMessage.AddInt32("itemIndex", IndexOf(item));
			Window()->PostMessage(&showMessage, this);
			return;
		}

		// Check the bounds of the expand Team icon
		if (fShowTeamExpander && fVertical) {
			BRect expanderRect = item->ExpanderBounds();
			if (expanderRect.Contains(where)) {
				// Let the update thread wait...
				BAutolock locker(sMonLocker);

				// Toggle the item
				item->ToggleExpandState(true);
				item->Draw();

				// Absorb the message.
				return;
			}
		}

		// double-click on an item brings the team to front
		int32 clicks;
		if (message->FindInt32("clicks", &clicks) == B_OK && clicks > 1
			&& item == menuItem && item == fLastClickItem) {
			// activate this team
			be_roster->ActivateApp((team_id)item->Teams()->ItemAt(0));
			return;
		}

		fLastClickItem = item;
	}

	BMenuBar::MouseDown(where);
}
开发者ID:,项目名称:,代码行数:69,代码来源:


示例11: RemoveItems

void
TTeamMenu::AttachedToWindow()
{
	RemoveItems(0, CountItems(), true);
		// remove all items

	BMessenger self(this);
	BList teamList;
	TBarApp::Subscribe(self, &teamList);

	TBarView* barview = (dynamic_cast<TBarApp*>(be_app))->BarView();
	bool dragging = barview && barview->Dragging();
	int32 iconSize = static_cast<TBarApp*>(be_app)->IconSize();
	desk_settings* settings = ((TBarApp*)be_app)->Settings();

	float width = sMinimumWindowWidth - iconSize - 4;

	if (settings->sortRunningApps)
		teamList.SortItems(CompareByName);

	int32 count = teamList.CountItems();
	for (int32 i = 0; i < count; i++) {
		// add items back
		BarTeamInfo* barInfo = (BarTeamInfo*)teamList.ItemAt(i);
		TTeamMenuItem* item = new TTeamMenuItem(barInfo->teams,
			barInfo->icon, barInfo->name, barInfo->sig,
			width, -1, !settings->hideLabels, true);

		if (settings->trackerAlwaysFirst
			&& strcmp(barInfo->sig, kTrackerSignature) == 0) {
			AddItem(item, 0);
		} else
			AddItem(item);

		if (dragging && item != NULL) {
			bool canhandle = (dynamic_cast<TBarApp*>(be_app))->BarView()->
				AppCanHandleTypes(item->Signature());
			if (item->IsEnabled() != canhandle)
				item->SetEnabled(canhandle);

			BMenu* menu = item->Submenu();
			if (menu)
				menu->SetTrackingHook(barview->MenuTrackingHook,
					barview->GetTrackingHookData());
		}
	}

	if (CountItems() == 0) {
		BMenuItem* item = new BMenuItem("no application running", NULL);
		item->SetEnabled(false);
		AddItem(item);
	}

	if (dragging && barview->LockLooper()) {
		SetTrackingHook(barview->MenuTrackingHook,
			barview->GetTrackingHookData());
		barview->DragStart();
		barview->UnlockLooper();
	}

	BMenu::AttachedToWindow();
}
开发者ID:DonCN,项目名称:haiku,代码行数:62,代码来源:TeamMenu.cpp


示例12: while

int32
TExpandoMenuBar::monitor_team_windows(void* arg)
{
	TExpandoMenuBar* teamMenu = (TExpandoMenuBar*)arg;

	while (teamMenu->sDoMonitor) {
		sMonLocker.Lock();

		if (teamMenu->Window()->LockWithTimeout(50000) == B_OK) {
			int32 totalItems = teamMenu->CountItems();

			// Set all WindowMenuItems to require an update.
			TWindowMenuItem* item = NULL;
			for (int32 i = 0; i < totalItems; i++) {
				if (!teamMenu->SubmenuAt(i)) {
					item = static_cast<TWindowMenuItem*>(teamMenu->ItemAt(i));
					item->SetRequireUpdate(true);
				}
			}

			// Perform SetTo() on all the items that still exist as well as add
			// new items.
			bool itemModified = false;
			bool resize = false;
			TTeamMenuItem* teamItem = NULL;

			for (int32 i = 0; i < totalItems; i++) {
				if (teamMenu->SubmenuAt(i) == NULL)
					continue;

				teamItem = static_cast<TTeamMenuItem*>(teamMenu->ItemAt(i));
				if (teamItem->IsExpanded()) {
					int32 teamCount = teamItem->Teams()->CountItems();
					for (int32 j = 0; j < teamCount; j++) {
						// The following code is almost a copy/paste from
						// WindowMenu.cpp
						team_id theTeam = (addr_t)teamItem->Teams()->ItemAt(j);
						int32 count = 0;
						int32* tokens = get_token_list(theTeam, &count);

						for (int32 k = 0; k < count; k++) {
							client_window_info* wInfo
								= get_window_info(tokens[k]);
							if (wInfo == NULL)
								continue;

							if (TWindowMenu::WindowShouldBeListed(wInfo)) {
								// Check if we have a matching window item...
								item = teamItem->ExpandedWindowItem(
									wInfo->server_token);
								if (item != NULL) {
									item->SetTo(wInfo->name,
										wInfo->server_token, wInfo->is_mini,
										((1 << current_workspace())
											& wInfo->workspaces) != 0);

									if (strcasecmp(item->Label(), wInfo->name) > 0)
										item->SetLabel(wInfo->name);

									if (item->Modified())
										itemModified = true;
								} else if (teamItem->IsExpanded()) {
									// Add the item
									item = new TWindowMenuItem(wInfo->name,
										wInfo->server_token, wInfo->is_mini,
										((1 << current_workspace())
											& wInfo->workspaces) != 0, false);
									item->SetExpanded(true);
									teamMenu->AddItem(item,
										TWindowMenuItem::InsertIndexFor(
											teamMenu, i + 1, item));
									resize = true;
								}
							}
							free(wInfo);
						}
						free(tokens);
					}
				}
			}

			// Remove any remaining items which require an update.
			for (int32 i = 0; i < totalItems; i++) {
				if (!teamMenu->SubmenuAt(i)) {
					item = static_cast<TWindowMenuItem*>(teamMenu->ItemAt(i));
					if (item && item->RequiresUpdate()) {
						item = static_cast<TWindowMenuItem*>
							(teamMenu->RemoveItem(i));
						delete item;
						totalItems--;

						resize = true;
					}
				}
			}

			// If any of the WindowMenuItems changed state, we need to force a
			// repaint.
			if (itemModified || resize) {
				teamMenu->Invalidate();
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:


示例13: Window

void
TExpandoMenuBar::MouseDown(BPoint where)
{
	BMessage *message = Window()->CurrentMessage();
	
	// check for three finger salute, a.k.a. Vulcan Death Grip
	if (message != NULL) {
		int32 modifiers = 0;
		message->FindInt32("modifiers", &modifiers);

		if ((modifiers & B_COMMAND_KEY) != 0
			&& (modifiers & B_OPTION_KEY) != 0
			&& (modifiers & B_SHIFT_KEY) != 0
			&& !fBarView->Dragging()) {
			
			TTeamMenuItem *item = ItemAtPoint(where);
			if (item) {
				const BList	*teams = item->Teams();
				int32 teamCount = teams->CountItems();

				team_id teamID;
				for (int32 team = 0; team < teamCount; team++) {
					teamID = (team_id)teams->ItemAt(team);
					kill_team(teamID);
					//	remove the team immediately
					//	from display
					RemoveTeam(teamID, false);
				}
					
				return;
			}		
		}
	}
	
	const int32 count = CountItems();

// This feature is broken because the menu bar never receives
// the second click
#ifdef DOUBLECLICKBRINGSTOFRONT
	// doubleclick on an item brings all to front
	for (int32 i = fFirstApp; i < count; i++) {
		TTeamMenuItem *item = (TTeamMenuItem *)ItemAt(i);
		if (item->Frame().Contains(where)) {
			bigtime_t clickSpeed = 0;
			get_click_speed(&clickSpeed);
			if ( (fLastClickItem == i) && 
				 (clickSpeed > (system_time() - fLastClickTime)) ) {
				// bring this team's window to the front
				BMessage showMessage(M_BRING_TEAM_TO_FRONT);
				showMessage.AddInt32("itemIndex", i);
				Window()->PostMessage(&showMessage, this);
				return;
			}

			fLastClickItem = i;
			fLastClickTime = system_time();
			break;
		}
	}
#endif

	// control click - show all/hide all shortcut
	if (message != NULL) {
		int32 modifiers = 0;
		message->FindInt32("modifiers", &modifiers);
		if ((modifiers & B_CONTROL_KEY) != 0
			&& ! fBarView->Dragging()) {
			int32 lastApp = -1;

			// find the clicked item
			for (int32 i = fFirstApp; i < count; i++) {
				const TTeamMenuItem *item = (TTeamMenuItem *)ItemAt(i);

				// check if this item is really a team item	(what a cruel way...)
				// "lastApp" will always point to the last application in
				// the list - the other entries might be windows (due to the team expander)
				if (item->Submenu())
					 lastApp = i;

				if (item->Frame().Contains(where)) {
					// show/hide item's teams
					BMessage showMessage((modifiers & B_SHIFT_KEY) != 0
						? M_MINIMIZE_TEAM : M_BRING_TEAM_TO_FRONT);
					showMessage.AddInt32("itemIndex", lastApp);
					Window()->PostMessage(&showMessage, this);
					return;
				}
			}
		}
	}

	// Check the bounds of the expand Team icon
	if (fShowTeamExpander && fVertical && !fBarView->Dragging()) {
		TTeamMenuItem *item = ItemAtPoint(where);
		if (item->Submenu()){
			BRect expanderRect = item->ExpanderBounds();
			if (expanderRect.Contains(where)) {
				item->ToggleExpandState(true);
				item->Draw();
				// Absorb the message.
//.........这里部分代码省略.........
开发者ID:Ithamar,项目名称:cosmoe,代码行数:101,代码来源:ExpandoMenuBar.cpp


示例14: SetFont

void
TWindowMenu::AttachedToWindow()
{
	SetFont(be_plain_font);

	RemoveItems(0, CountItems(), true);

	int32 miniCount = 0;

	bool dragging = false;
	TBarView* barview =(static_cast<TBarApp*>(be_app))->BarView();
	if (barview && barview->LockLooper()) {
		//	'dragging' mode set in BarView::CacheDragData
		//		invoke in MouseEnter in ExpandoMenuBar
		dragging = barview->Dragging();
		if (dragging) {
			// We don't want to show the menu when dragging, but it's not
			// possible to remove a submenu once it exists, so we simply hide it
			// Don't call BMenu::Hide(), it causes the menu to pop up every now
			// and then.
			Window()->Hide();
			//	if in expando (horizontal or vertical)
			if (barview->Expando()) {
				SetTrackingHook(barview->MenuTrackingHook,
					barview->GetTrackingHookData());
			}
			barview->DragStart();
		}
		barview->UnlockLooper();
	}

	int32 parentMenuItems = 0;

	int32 numTeams = fTeam->CountItems();
	for (int32 i = 0; i < numTeams; i++) {
		team_id	theTeam = (team_id)fTeam->ItemAt(i);
		int32 count = 0;
		int32* tokens = get_token_list(theTeam, &count);

		for (int32 j = 0; j < count; j++) {
			client_window_info* wInfo = get_window_info(tokens[j]);
			if (wInfo == NULL)
				continue;

			if (WindowShouldBeListed(wInfo->feel)
				&& (wInfo->show_hide_level <= 0 || wInfo->is_mini)) {
				// Don't add new items if we're expanded. We've already done
				// this, they've just been moved.
				int32 numItems = CountItems();
				int32 addIndex = 0;
				for (; addIndex < numItems; addIndex++)
					if (strcasecmp(ItemAt(addIndex)->Label(), wInfo->name) > 0)
						break;

				if (!fExpanded) {
					TWindowMenuItem* item = new TWindowMenuItem(wInfo->name,
						wInfo->server_token, wInfo->is_mini,
						((1 << current_workspace()) & wInfo->workspaces) != 0,
						dragging);

					// disable app's window dropping for now
					if (dragging)
						item->SetEnabled(false);

					AddItem(item,
						TWindowMenuItem::InsertIndexFor(this, 0, item));
				} else {
					TTeamMenuItem* parentItem
						= static_cast<TTeamMenuItem*>(Superitem());
					if (parentItem->ExpandedWindowItem(wInfo->server_token)) {
						TWindowMenuItem* item = parentItem->ExpandedWindowItem(
							wInfo->server_token);
						if (item == NULL)
							continue;

						item->SetTo(wInfo->name, wInfo->server_token,
							wInfo->is_mini,
							((1 << current_workspace()) & wInfo->workspaces)
								!= 0, dragging);
						parentMenuItems++;
					}
				}

				if (wInfo->is_mini)
					miniCount++;
			}
			free(wInfo);
		}
		free(tokens);
	}

	int32 itemCount = CountItems() + parentMenuItems;
	if (itemCount < 1) {
		TWindowMenuItem* noWindowsItem =
 			new TWindowMenuItem("No windows", -1, false, false);

		noWindowsItem->SetEnabled(false);

		AddItem(noWindowsItem);

//.........这里部分代码省略.........
开发者ID:mmanley,项目名称:Antares,代码行数:101,代码来源:WindowMenu.cpp


示例15: self

void
TExpandoMenuBar::BuildItems()
{
	BMessenger self(this);
	TBarApp::Subscribe(self, &fTeamList);

	int32 iconSize = static_cast<TBarApp*>(be_app)->IconSize();
	desk_settings* settings = static_cast<TBarApp*>(be_app)->Settings();

	float itemWidth = -1.0f;
	if (fVertical)
		itemWidth = Frame().Width();
	else {
		itemWidth = iconSize;
		if (!settings->hideLabels)
			itemWidth += gMinimumWindowWidth - kMinimumIconSize;
		else
			itemWidth += kIconPadding * 2;
	}
	float itemHeight = -1.0f;

	TeamMenuItemMap items;
	int32 itemCount = CountItems();
	BList itemList(itemCount);
	for (int32 i = 0; i < itemCount; i++) {
		BMenuItem* menuItem = RemoveItem((int32)0);
		itemList.AddItem(menuItem);
		TTeamMenuItem* item = dynamic_cast<TTeamMenuItem*>(menuItem);
		if (item != NULL)
			items[BString(item->Signature()).ToLower()] = item;
	}

	if (settings->sortRunningApps)
		fTeamList.SortItems(TTeamMenu::CompareByName);

	int32 teamCount = fTeamList.CountItems();
	for (int32 i = 0; i < teamCount; i++) {
		BarTeamInfo* barInfo = (BarTeamInfo*)fTeamList.ItemAt(i);
		TeamMenuItemMap::const_iterator iter
			= items.find(BString(barInfo->sig).ToLower());
		if (iter == items.end()) {
			// new team
			TTeamMenuItem* item = new TTeamMenuItem(barInfo->teams,
				barInfo->icon, barInfo->name, barInfo->sig, itemWidth,
				itemHeight);

			if (settings->trackerAlwaysFirst
				&& strcasecmp(barInfo->sig, kTrackerSignature) == 0) {
				AddItem(item, 0);
			} else
				AddItem(item);

			if (fFirstBuild && fVertical && settings->expandNewTeams)
				item->ToggleExpandState(true);

		} else {
			// existing team, update info and add it
			TTeamMenuItem* item = iter->second;
			item->SetIcon(barInfo->icon);
			item->SetOverrideWidth(itemWidth);
			item->SetOverrideHeight(itemHeight);

			if (settings->trackerAlwaysFirst
				&& strcasecmp(barInfo->sig, kTrackerSignature) == 0) {
				AddItem(item, 0);
			} else
				AddItem(item);

			// add window items back
			int32 index = itemList.IndexOf(item);
			TWindowMenuItem* windowItem;
			TWindowMenu* submenu = dynamic_cast<TWindowMenu*>(item->Submenu());
			bool hasWindowItems = false;
			while ((windowItem = dynamic_cast<TWindowMenuItem*>(
					(BMenuItem*)(itemList.ItemAt(++index)))) != NULL) {
				if (fVertical)
					AddItem(windowItem);
				else {
					delete windowItem;
					hasWindowItems = submenu != NULL;
				}
			}

			// unexpand if turn off show team expander
			if (fVertical && !settings->superExpando && item->IsExpanded())
				item->ToggleExpandState(false);

			if (hasWindowItems) {
				// add (new) window items in submenu
				submenu->SetExpanded(false, 0);
				submenu->AttachedToWindow();
			}
		}
	}

	if (CountItems() == 0) {
		// If we're empty, BMenuBar::AttachedToWindow() resizes us to some
		// weird value - we just override it again
		ResizeTo(itemWidth, 0);
	}
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:


示例16: switch

void
TExpandoMenuBar::MessageReceived(BMessage *message)
{
	int32 index;
	TTeamMenuItem *item;
	
	switch (message->what) {
		case B_SOME_APP_LAUNCHED: {
			BList *teams = NULL;
			message->FindPointer("teams", (void **)&teams);

			BBitmap *icon = NULL;
			message->FindPointer("icon", (void **)&icon);

			const char *sig;
			if (message->FindString("sig", &sig) == B_OK
				&&strcasecmp(sig, TASK_BAR_MIME_SIG) == 0) {
				delete teams;
				delete icon;
				break;
			}

			uint32 flags;
			if (message->FindInt32("flags", ((int32*) &flags)) == B_OK
				&& (flags & B_BACKGROUND_APP) != 0) {
				delete teams;
				delete icon;
				break;
			}

			const char *name = NULL;
			message->FindString("name", &name);

			AddTeam(teams, icon, strdup(name), strdup(sig));
			break;
		}
		
		case msg_AddTeam:
			AddTeam(message->FindInt32("team"), message->FindString("sig"));
			break;

		case msg_RemoveTeam:
		{
			team_id team = -1;
			message->FindInt32("team", &team);

			RemoveTeam(team, true);
			break;
		}

		case B_SOME_APP_QUIT:
		{
			team_id team = -1;
			message->FindInt32("team", &team);

			RemoveTeam(team, false);
			break;
		}
		
		case M_MINIMIZE_TEAM:
		{
			index = message->FindInt32("itemIndex");
			item = dynamic_cast<TTeamMenuItem *>(ItemAt(index));
			if (item == NULL)
				break;

			TShowHideMenuItem::TeamShowHideCommon(B_MINIMIZE_WINDOW,
				item->Teams(), 
				item->Menu()->ConvertToScreen(item->Frame()), 
				true);
			break;
		}
		
		case M_BRING_TEAM_TO_FRONT:
		{
			index = message->FindInt32("itemIndex");
			item = dynamic_cast<TTeamMenuItem *>(ItemAt(index));
			if (item == NULL)
				break;

			TShowHideMenuItem::TeamShowHideCommon(B_BRING_TO_FRONT,
				item->Teams(), 
				item->Menu()->ConvertToScreen(item->Frame()),
				true);
			break;
		}
			
		default:
			BMenuBar::MessageReceived(message);
			break;
	}
}
开发者ID:Ithamar,项目名称:cosmoe,代码行数:92,代码来源:ExpandoMenuBar.cpp


示例17: while

int32
TExpandoMenuBar::monitor_team_windows(void *arg)
{
	TExpandoMenuBar *teamMenu = (TExpandoMenuBar *)arg;

	int32 totalItems = 0;
	bool itemModified = false;

	TWindowMenuItem *item = NULL;
	TTeamMenuItem *teamItem = NULL;

	int32 *tokens = NULL;

	while (teamMenu->sDoMonitor) {
		totalItems = teamMenu->CountItems();

		// Set all WindowMenuItems to require an update.
		item = NULL;
		for (int32 i = 0; i < totalItems; i++) {
			if (!teamMenu->SubmenuAt(i)){
				item = static_cast<TWindowMenuItem *>(teamMenu->ItemAt(i));
				item->SetRequireUpdate();
			}
		}

		// Perform SetTo() on all the items that still exist as well as add new items.
		itemModified = false;
		teamItem = NULL;
		for (int32 i = 0; i < totalItems; i++) {
			if (teamMenu->SubmenuAt(i)){
				teamItem = static_cast<TTeamMenuItem *>(teamMenu->ItemAt(i));
				if (teamItem->IsExpanded()) {
					int32 teamCount = teamItem->Teams()->CountItems();
					for (int32 j = 0; j < teamCount; j++) {
						// The following code is almost a copy/paste from
						// WindowMenu.cpp
						team_id	theTeam = (team_id)teamItem->Teams()->ItemAt(j);
						int32 count = 0;
						tokens = get_token_list(theTeam, &count);
						
						for (int32 k = 0; k < count; k++) {
							window_info *wInfo = get_window_info(tokens[k]);
							if (wInfo == NULL)
								continue;
							
							if (TWindowMenu::WindowShouldBeListed(wInfo->w_type)
								&& (wInfo->show_hide_level <= 0 || wInfo->is_mini)) {
								// Check if we have a matching window item...
								item = teamItem->ExpandedWindowItem(wInfo->id);
								if (item) {
									// Lock the window, changing workspaces will fry this.
									item->SetTo(wInfo->name, wInfo->id, wInfo->is_mini,
										((1 << current_workspace()) & wInfo->workspaces) != 0);

									if (strcmp(wInfo->name, item->Label()) != 0)
										item->SetLabel(wInfo->name);

									if (item->ChangedState())
										itemModified = true;
								} else if (teamItem->IsExpanded()) {
									// Add the item
									item = new TWindowMenuItem(wInfo->name, wInfo->id, 
										wInfo->is_mini,
										((1 << current_workspace()) & wInfo->workspaces) != 0,
										false);
									item->ExpandedItem(true);
									teamMenu->AddItem(item, i + 1);
									itemModified = true;
									teamMenu->Window()->Lock();
									teamMenu->SizeWindow();
									teamMenu->Window()->Unlock();
								}
							}
							free(wInfo);
						}
						free(tokens);							
					}
				}
			}
		}

		// Remove any remaining items which require an update.
		for (int32 i = 0; i < totalItems; i++) {
			if (!teamMenu->SubmenuAt(i)){
				item = static_cast<TWindowMenuItem *>(teamMenu->ItemAt(i));
				if (item && item->RequiresUpdate()) {
					item = static_cast<TWindowMenuItem *>(teamMenu->RemoveItem(i));
					delete item;
					totalItems--;
					teamMenu->Window()->Lock();
					teamMenu->SizeWindow();
					teamMenu->Window()->Unlock();
				}
			}
		}

		// If any of the WindowMenuItems changed state, we need to force a repaint.
		if (itemModified) {
			teamMenu->Window()->Lock();
			teamMenu->Invalidate();
//.........这里部分代码省略.........
开发者ID:Ithamar,项目名称:cosmoe,代码行数:101,代码来源:ExpandoMenuBar.cpp


示例18: PlaceBeMenu

void
TBarView::ChangeState(int32 state, bool vertical, bool left, bool top)
{
	bool vertSwap = (fVertical != vertical);
	bool leftSwap = (fLeft != left);

	fState = state;
	fVertical = vertical;
	fLeft = left;
	fTop = top;
	
	BRect screenFrame = (BScreen(Window())).Frame();

	PlaceBeMenu();
	if (fVertical){
#if SA_CLOCK
		PlaceClock();	// tray dependent on clock location
#endif
		PlaceTray(vertSwap, leftSwap, screenFrame);
	} else {
		PlaceTray(vertSwap, leftSwap, screenFrame);
#if SA_CLOCK
		PlaceClock();	// clock is dependent on tray location
#endif
	}

	// We need to keep track of what apps are expanded.
	BList expandedItems;
	BString *signature = NULL;
	if (fVertical && Expando() && static_cast<TBarApp *>(be_app)->Settings()->superExpando) {
		// Get a list of the Signatures of expanded apps - Can't use team_id because
		// there can be more than one team per application
		if (fVertical && Expando() && vertical && fExpando) {
			for (int index = 0; index < fExpando->CountItems(); index++) {
				TTeamMenuItem *item = dynamic_cast<TTeamMenuItem *>(fExpando->ItemAt(index));
				if (item != NULL && item->IsExpanded()) {
					signature = new BString(item->Signature());
					expandedItems.AddItem((void *)signature);
				}
			}
		}
	}

	PlaceApplicationBar(screenFrame);
	SizeWindow(screenFrame);
	PositionWindow(screenFrame);
	Window()->UpdateIfNeeded();
	
	// Re-expand those apps.
	if (expandedItems.CountItems() > 0) {
		for (int sigIndex = expandedItems.CountItems(); sigIndex-- > 0;) {
			signature = static_cast<BString *>(expandedItems.ItemAt(sigIndex));
			if (signature == NULL)
				continue;

			// Start at the 'bottom' of the list working up.
			// Prevents being thrown off by expanding items.
			for (int teamIndex = fExpando->CountItems(); teamIndex-- > 0;) {
				TTeamMenuItem *item = dynamic_cast<TTeamMenuItem *>(fExpando->ItemAt(teamIndex));
				if (item != NULL && !signature->Compare(item->Signature())) {
					item->ToggleExpandState(false);
					break;
				}
			}
		}

		// Clean up expanded signature list.
		while (!expandedItems.IsEmpty()) {
			delete static_cast<BString *>(expandedItems.RemoveItem((int32)0));
		}

		fExpando->SizeWindow();
	}

	Invalidate();
}
开发者ID:Ithamar,项目名称:cosmoe,代码行数:76,代码来源:BarView.cpp



注:本文中的TTeamMenuItem类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ TText类代码示例发布时间:2022-05-31
下一篇:
C++ TT_Face类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap