Beispiel #1
0
	virtual void MessageReceived(BMessage* message)
	{
		switch (message->what) {
			case MSG_SCROLL_TABS_LEFT:
				fTabContainerView->SetFirstVisibleTabIndex(
					fTabContainerView->FirstVisibleTabIndex() - 1);
				break;
			case MSG_SCROLL_TABS_RIGHT:
				fTabContainerView->SetFirstVisibleTabIndex(
					fTabContainerView->FirstVisibleTabIndex() + 1);
				break;
			case MSG_OPEN_TAB_MENU:
			{
				BPopUpMenu* tabMenu = new BPopUpMenu("tab menu", true, false);
				int tabCount = fTabContainerView->GetLayout()->CountItems();
				for (int i = 0; i < tabCount; i++) {
					TabView* tab = fTabContainerView->TabAt(i);
					if (tab) {
						BMenuItem* item = new BMenuItem(tab->Label(), NULL);
						tabMenu->AddItem(item);
						if (tab->IsFront())
							item->SetMarked(true);
					}
				}

				// Force layout to get the final menu size. InvalidateLayout()
				// did not seem to work here.
				tabMenu->AttachedToWindow();
				BRect buttonFrame = fTabMenuButton->Frame();
				BRect menuFrame = tabMenu->Frame();
				BPoint openPoint = ConvertToScreen(buttonFrame.LeftBottom());
				// Open with the right side of the menu aligned with the right
				// side of the button and a little below.
				openPoint.x -= menuFrame.Width() - buttonFrame.Width();
				openPoint.y += 2;

				BMenuItem *selected = tabMenu->Go(openPoint, false, false,
					ConvertToScreen(buttonFrame));
				if (selected) {
					selected->SetMarked(true);
					int32 index = tabMenu->IndexOf(selected);
					if (index != B_ERROR)
						fTabContainerView->SelectTab(index);
				}
				fTabMenuButton->MenuClosed();
				delete tabMenu;
				
				break;
			}
			default:
				BGroupView::MessageReceived(message);
				break;
		}
	}
Beispiel #2
0
void
GLObject::MenuInvoked(BPoint point)
{
	BPopUpMenu* m = new BPopUpMenu("Object",false,false);
	BMenuItem* i;

	int c = 1;
	m->AddItem(i = new BMenuItem("White",NULL));
	if (color == c++)
		i->SetMarked(true);
	m->AddItem(i = new BMenuItem("Yellow",NULL));
	if (color == c++)
		i->SetMarked(true);
	m->AddItem(i = new BMenuItem("Blue",NULL));
	if (color == c++)
		i->SetMarked(true);
	m->AddItem(i = new BMenuItem("Red",NULL));
	if (color == c++)
		i->SetMarked(true);
	m->AddItem(i = new BMenuItem("Green",NULL));
	if (color == c++)
		i->SetMarked(true);
	m->AddSeparatorItem();

	c = 0;
	m->AddItem(i = new BMenuItem("Solid",NULL));
	if (solidity == c++)
		i->SetMarked(true);
	m->AddItem(i = new BMenuItem("Translucent",NULL));
	if (solidity == c++)
		i->SetMarked(true);
	m->AddItem(i = new BMenuItem("Transparent",NULL));
	if (solidity == c++)
		i->SetMarked(true);

	i = m->Go(point);
	int32 index = m->IndexOf(i);
	delete m;
	
	if (index < 5) {
		color = index+1;
	} else if (index > 5) {
		solidity = index-6;
	}
	changed = true;
	setEvent(fObjView->drawEvent);
}