Beispiel #1
0
status_t
PMenuItem::GetProperty(const char *name, PValue *value, const int32 &index) const
{
	if (!name || !value)
		return B_ERROR;
	
	BString str(name);
	PProperty *prop = FindProperty(name,index);
	if (!prop)
		return B_NAME_NOT_FOUND;
	
	BMenuItem *backend = (BMenuItem*)fBackend;
	if (str.ICompare("Message") == 0)
		((IntProperty*)prop)->SetValue(backend->Command());
	else if (str.ICompare("Trigger") == 0)
		((CharProperty*)prop)->SetValue(backend->Trigger());
	else if (str.ICompare("Label") == 0)
		((StringProperty*)prop)->SetValue(backend->Label());
	else if (str.ICompare("Frame") == 0)
		((RectProperty*)prop)->SetValue(backend->Frame());
	else if (str.ICompare("Marked") == 0)
		((BoolProperty*)prop)->SetValue(backend->IsMarked());
	else if (str.ICompare("Enabled") == 0)
		((BoolProperty*)prop)->SetValue(backend->IsEnabled());
	else
	{
		return PObject::GetProperty(name, value, index);
	}

	return prop->GetValue(value);
}
Beispiel #2
0
void
PopUpResults(vector<BString>& results, MTextAddOn* addon)
{
	BPopUpMenu selections("API Selections", false, false);
	selections.SetFont(be_plain_font);

	for (uint32 i = 0; i < results.size(); i++) {
		BMenuItem* item = new BMenuItem(FormatResultString(results[i]).String(),
										new BMessage(i));
		selections.AddItem(item);
	}

	// Here we get a nice BPoint to popup the results (end of the toolbar).
	BPoint menupos;

	if (addon->Window()->Lock()) {
		float x = addon->Window()->FindView("ButtonBar")->Frame().right + 2;
		float y = addon->Window()->FindView("ToolBar")->Frame().Height() - 2;

		menupos = addon->Window()->Frame().LeftTop() + BPoint(x, y);
		addon->Window()->Unlock();
	}

	BMenuItem* item = selections.Go(menupos, false, true);

	if (item != NULL) {
		int index = item->Command();
		OpenDoc(results[index].String());
	}
}
Beispiel #3
0
void
TListView::MouseDown(BPoint point)
{
	int32 buttons;	
	Looper()->CurrentMessage()->FindInt32("buttons",&buttons);

	if (buttons & B_SECONDARY_MOUSE_BUTTON)
	{
		BFont font = *be_plain_font;
		font.SetSize(10);

		BPopUpMenu menu("enclosure", false, false);
		menu.SetFont(&font);
		menu.AddItem(new BMenuItem(TR("Open attachment"),
			new BMessage(LIST_INVOKED)));
		menu.AddItem(new BMenuItem(TR("Remove attachment"),
			new BMessage(M_REMOVE)));

		BPoint menuStart = ConvertToScreen(point);
		
		BMenuItem *item;
		if ((item = menu.Go(menuStart)) != NULL)
		{
			if (item->Command() == LIST_INVOKED)
			{
				BMessage msg(LIST_INVOKED);
				msg.AddPointer("source",this);
				msg.AddInt32("index",IndexOf(point));
				Window()->PostMessage(&msg,fParent);
			}
			else
			{
				Select(IndexOf(point));
				Window()->PostMessage(item->Command(),fParent);
			}
		}
	}
	else
		BListView::MouseDown(point);
}
status_t
InterfaceAddressView::Save()
{
	BMenuItem* item = fModePopUpMenu->FindMarked();
	if (item == NULL)
		return B_ERROR;

	fSettings->SetIP(fFamily, fAddressField->Text());
	fSettings->SetNetmask(fFamily, fNetmaskField->Text());
	fSettings->SetGateway(fFamily, fGatewayField->Text());
	fSettings->SetAutoConfigure(fFamily, item->Command() == M_MODE_AUTO);

	return B_OK;
}
Beispiel #5
0
void TeamListView::ItemsToPopUpPriorityMenu()
{
	BMenuField *Priority = (BMenuField *)slayer->mainWindow->FindView("MainPriorityField");
	BMenu *menu = Priority->Menu();
	BMenuItem *add;
	int32 i;
	for (i = 2; (add = menu->ItemAt(i)); i++) {
		BMenuItem *newItem;
		if (add->Label() && add->Label()[0])
			newItem = new BMenuItem(add->Label(), new BMessage(
				add->Command()));
		else
			newItem = new BSeparatorItem();
			
		newItem->SetTarget(slayer->mainWindow);
		priorityMenu->AddItem(newItem);
	}
		// priorityMenu->AddItem(add);
}