static int
compare_menu_items(const void* _a, const void* _b)
{
	BMenuItem* a = *(BMenuItem**)_a;
	BMenuItem* b = *(BMenuItem**)_b;

	return strcasecmp(a->Label(), b->Label());
}
Beispiel #2
0
void RecipeEditor::MessageReceived(BMessage *msg)
{
	switch(msg->what)
	{
		case M_QUIT_APP:
		{
			be_app->PostMessage(B_QUIT_REQUESTED);
			break;
		}
		case M_CATEGORY_CHANGED:
		{
			BString name;
			if(msg->FindString("name",&name)==B_OK)
				fCategory = name;
			break;
		}
		case M_EDIT_RECIPE:
		{
			BMenuItem *item = fCategories->FindMarked();
			if(fCategory.Compare(item->Label()) == 0)
			{
				UpdateRecipe(fNumber, fCategory.String(), fNameBox->Text(),
						fIngredientBox->Text(), fDirectionsBox->Text());
			}
			else
			{
				// we're also recategorizing the recipe, so we'll just delete the old
				// one and add it to the new one
				DeleteRecipe(fNumber, fCategory.String());
				AddRecipe(fCategory.String(), fNameBox->Text(),
						fIngredientBox->Text(), fDirectionsBox->Text());
			}
			fMessenger.SendMessage(M_SET_RECIPE);
			PostMessage(B_QUIT_REQUESTED);
			break;
		}
		case M_ADD_RECIPE:
		{
			if(fCategory.CountChars() < 1)
			{
				BMenuItem *item = fCategories->FindMarked();
				if(item)
					fCategory = item->Label();
				else
					fCategory = "Misc";
			}
			
			AddRecipe(fCategory.String(), fNameBox->Text(),
					fIngredientBox->Text(), fDirectionsBox->Text());
			PostMessage(B_QUIT_REQUESTED);
			break;
		}
		default:
			BWindow::MessageReceived(msg);
	}
}
Beispiel #3
0
static int
compare_void_menu_items(const void* _a, const void* _b)
{
	static BCollator collator;

	BMenuItem* a = *(BMenuItem**)_a;
	BMenuItem* b = *(BMenuItem**)_b;

	return collator.Compare(a->Label(), b->Label());
}
Beispiel #4
0
void CPrefsDialog::GrabNewFont()
{
	BMenuItem *item;
	
	item = fDocFont->FindMarked();
	if (item) strcpy(fNewFontFamily, item->Label());
	fNewFontSize = atof(GetText("docsize"));
	item = fBorderFont->FindMarked();
	if (item) strcpy(fNewBFontFamily, item->Label());
	fNewBFontSize = atof(GetText("bordersize"));
} /* CPrefsDialog::GrabNewFont */
Beispiel #5
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 #6
0
void
IPSettingsView::_ApplyControlsToConfiguration()
{
	fSettings->SetIP(fIPTextControl->Text());
	fSettings->SetNetmask(fNetMaskTextControl->Text());
	fSettings->SetGateway(fGatewayTextControl->Text());

	if (!fNetworkMenuField->IsHidden(fNetworkMenuField)) {
		if (fNetworkMenuField->Menu()->ItemAt(0)->IsMarked()) {
			fSettings->SetWirelessNetwork(NULL);
		} else {
			BMenuItem* item = fNetworkMenuField->Menu()->FindMarked();
			if (item != NULL)
				fSettings->SetWirelessNetwork(item->Label());
		}
	}

	fSettings->SetAutoConfigure(
		strcmp(fTypeMenuField->Menu()->FindMarked()->Label(),
			B_TRANSLATE("DHCP")) == 0);

	fSettings->SetDisabled(
		strcmp(fTypeMenuField->Menu()->FindMarked()->Label(),
			B_TRANSLATE("Disabled")) == 0);

	fSettings->NameServers().MakeEmpty();
	fSettings->NameServers().AddItem(new BString(
		fPrimaryDNSTextControl->Text()));
	fSettings->NameServers().AddItem(new BString(
		fSecondaryDNSTextControl->Text()));
	fSettings->SetDomain(fDomainTextControl->Text());

	fApplyButton->SetEnabled(false);
	fRevertButton->SetEnabled(true);
}
void ToolbarView::MessageReceived(BMessage *msg) {
UT_UTF8String ucsText;
	switch (msg->what) {
	case 'ddwn': {
		int32 i, id, item;
		msg->FindInt32("id", &id);
		msg->FindInt32("item", &item);
		
		for (i=0; i<item_count; i++) {
			if (items[i].id == id)
				break;
		}
		if(i >= item_count) {
			return;
		}
		BMenuItem *mnuitem;
		mnuitem = items[i].menu->Menu()->FindMarked();
		//char buffer[255];
		//strcpy(buffer, mnuitem->Label());
		ucsText = mnuitem->Label();
		m_pBeOSToolbar->toolbarEvent(id, ucsText.ucs4_str().ucs4_str(), ucsText.ucs4_str().length());
		break;
	}
		
	default:		
		BView::MessageReceived(msg);
	}
}
Beispiel #8
0
bool
AutoConfigView::GetBasicAccountInfo(account_info &info)
{
	status_t status = B_OK;

	BString inboundProtocolName = "";
	BMenuItem* item = fInProtocolsField->Menu()->FindMarked();
	if (item) {
		inboundProtocolName = item->Label();
		item->Message()->FindRef("protocol", &(info.inboundProtocol));
	}
	else
		status = B_ERROR;

	if (inboundProtocolName.FindFirst("IMAP") >= 0)
		info.inboundType = IMAP;
	else
		info.inboundType = POP;

	info.outboundProtocol = fSMTPAddOnRef;
	info.name = fNameView->Text();
	info.accountName = fAccountNameView->Text();
	info.email = fEmailView->Text();
	info.loginName = fLoginNameView->Text();
	info.password = fPasswordView->Text();

	return status;
}
Beispiel #9
0
void
AppearancePrefView::_SetCurrentColorSchema(BMenuField* field)
{
	PrefHandler* pref = PrefHandler::Default();

	gCustomSchema.text_fore_color = pref->getRGB(PREF_TEXT_FORE_COLOR);
	gCustomSchema.text_back_color = pref->getRGB(PREF_TEXT_BACK_COLOR);
	gCustomSchema.select_fore_color = pref->getRGB(PREF_SELECT_FORE_COLOR);
	gCustomSchema.select_back_color = pref->getRGB(PREF_SELECT_BACK_COLOR);

	const char* currentSchemaName = NULL;

	color_schema** schemas = const_cast<color_schema**>(gPredefinedSchemas);
	while (*schemas) {
		if (gCustomSchema == **schemas) {
			currentSchemaName = (*schemas)->name;
			break;
		}
		schemas++;
	}

	for (int32 i = 0; i < fColorSchemaField->Menu()->CountItems(); i++) {
		BMenuItem* item = fColorSchemaField->Menu()->ItemAt(i);
		if (!strcmp(item->Label(), currentSchemaName)) {
			item->SetMarked(true);
			break;
		}
	}
}
Beispiel #10
0
extern "C" void
process_refs(entry_ref dir, BMessage* message, void* /*reserved*/)
{
	BPopUpMenu* menu = new BPopUpMenu("status");
	retrieve_status_items(menu);

	BMenuItem* item = menu->Go(mouse_position() - BPoint(5, 5), false, true);
	if (item == NULL)
		return;

	BString status = item->Label();

	entry_ref ref;
	for (int i = 0; message->FindRef("refs", i, &ref) == B_OK; i++) {
		BNode node(&ref);
		BString type;

		if (node.InitCheck() == B_OK
			&& node.ReadAttrString("BEOS:TYPE", &type) == B_OK
			&& type == "text/x-email") {
			BString previousStatus;

			// Only update the attribute if there is an actual change
			if (node.ReadAttrString("MAIL:status", &previousStatus) != B_OK
				|| previousStatus != status)
				node.WriteAttrString("MAIL:status", &status);
		}
	}
}
Beispiel #11
0
void
AppearancePrefView::_SetCurrentColorScheme()
{
	PrefHandler* pref = PrefHandler::Default();

	gCustomColorScheme.text_fore_color = pref->getRGB(PREF_TEXT_FORE_COLOR);
	gCustomColorScheme.text_back_color = pref->getRGB(PREF_TEXT_BACK_COLOR);
	gCustomColorScheme.select_fore_color = pref->getRGB(PREF_SELECT_FORE_COLOR);
	gCustomColorScheme.select_back_color = pref->getRGB(PREF_SELECT_BACK_COLOR);
	gCustomColorScheme.cursor_fore_color = pref->getRGB(PREF_CURSOR_FORE_COLOR);
	gCustomColorScheme.cursor_back_color = pref->getRGB(PREF_CURSOR_BACK_COLOR);

	const char* currentSchemeName = NULL;

	for (const color_scheme** schemes = gPredefinedColorSchemes;
			*schemes != NULL; schemes++) {
		if (gCustomColorScheme == **schemes) {
			currentSchemeName = (*schemes)->name;
			break;
		}
	}

	for (int32 i = 0; i < fColorSchemeField->Menu()->CountItems(); i++) {
		BMenuItem* item = fColorSchemeField->Menu()->ItemAt(i);
		if (strcmp(item->Label(), currentSchemeName) == 0) {
			item->SetMarked(true);
			break;
		}
	}
}
Beispiel #12
0
BMenu *
TestView::AddMenuSorted(BMenu *parent,const char *name)
{
	// XXX: TODO: This doesn't work for some reason -- the items aren't sorted :(
	
	if (!name)
		return NULL;
	
	BMenu *menu = new BMenu(name);
	
	for (int32 i = 0; i < parent->CountItems(); i++)
	{
		BMenuItem *item = parent->ItemAt(i);
		
		if (strcmp(item->Label(),name) == -1)
		{
//		printf("INSERT: %s is after %s\n",name,item->Label());
			parent->AddItem(menu,i);
			return menu;
		}
	}
	
//	if (parent->CountItems())
//		printf("%s is after %s\n",name,parent->ItemAt(parent->CountItems() - 1)->Label());
//	else
//		printf("%s is last\n",name);

	parent->AddItem(menu);
	return menu;
}
Beispiel #13
0
int32
GoGoEncoder::GetFormat(char* format) {
	PRINT(("GoGoEncoder::GetFormat(char*)\n"));

	BMenuItem* item;
	BMenu* formatMenu;

	item = menu->FindItem(OUTPUT_FORMAT_STR);
	if (!item) {
		return B_ERROR;
	}
	formatMenu = item->Submenu();
	if (!formatMenu) {
		return B_ERROR;
	}

	item = formatMenu->FindMarked();
	if (!item) {
		return B_ERROR;
	}

	const char* label = item->Label();

	if (strcmp(label, STEREO) == 0) {
		strcpy(format, STEREO_CODE);
	} else if (strcmp(label, MONO) == 0) {
		strcpy(format, MONO_CODE);
	} else if (strcmp(label, JSTEREO) == 0) {
		strcpy(format, JSTEREO_CODE);
	}

	return B_OK;
}
void
FrequencyMenu::UpdateMenu()
{
	freq_preferences* pref = fStorage->GetPreferences();
	switch (pref->mode) {
		case DYNAMIC:
			_SetL1MenuLabelFrom(fDynamicPerformance);
			break;

		case PERFORMANCE:
			_SetL1MenuLabelFrom(fHighPerformance);
			break;

		case LOW_ENERGIE:
			_SetL1MenuLabelFrom(fLowEnergie);
			break;

		case CUSTOM:
		{
			BMenuItem* markedItem = fCustomStateMenu->FindMarked();
			if (markedItem)
				markedItem->SetMarked(false);
			BMenuItem* customItem
				= fCustomStateMenu->ItemAt(pref->custom_stepping);
			if (customItem)
				customItem->SetMarked(true);
			BMenuItem* superItem = fCustomStateMenu->Supermenu()->Superitem();
			if (superItem && customItem)
				superItem->SetLabel(customItem->Label());
			break;
		}
	}
}
Beispiel #15
0
void
TermWindow::_GetPreferredFont(BFont& font)
{
	// Default to be_fixed_font
	font = be_fixed_font;

	const char* family
		= PrefHandler::Default()->getString(PREF_HALF_FONT_FAMILY);
	const char* style
		= PrefHandler::Default()->getString(PREF_HALF_FONT_STYLE);
	const char* size = PrefHandler::Default()->getString(PREF_HALF_FONT_SIZE);

	font.SetFamilyAndStyle(family, style);
	font.SetSize(atoi(size));

	// mark the font size menu item
	for (int32 i = 0; i < fFontSizeMenu->CountItems(); i++) {
		BMenuItem* item = fFontSizeMenu->ItemAt(i);
		if (item == NULL)
			continue;

		item->SetMarked(false);
		if (strcmp(item->Label(), size) == 0)
			item->SetMarked(true);
	}
}
Beispiel #16
0
void
NetworkSetupWindow::_BuildProfilesMenu(BMenu* menu, int32 msg_what)
{
    BMenuItem*	item;
    char current_profile[256] = { 0 };

    menu->SetRadioMode(true);

    BDirectory dir("/boot/common/settings/network/profiles");

    if (dir.InitCheck() == B_OK) {
        BEntry entry;
        BMessage* msg;

        dir.Rewind();
        while (dir.GetNextEntry(&entry) >= 0) {
            BPath name;
            entry.GetPath(&name);

            if (entry.IsSymLink() &&
                    strcmp("current", name.Leaf()) == 0) {
                BSymLink symlink(&entry);

                if (symlink.IsAbsolute())
                    // oh oh, sorry, wrong symlink...
                    continue;

                symlink.ReadLink(current_profile, sizeof(current_profile));
                continue;
            };

            if (!entry.IsDirectory())
                continue;

            msg = new BMessage(msg_what);
            msg->AddString("path", name.Path());

            item = new BMenuItem(name.Leaf(), msg);
            menu->AddItem(item);
        }
    }

    menu->AddSeparatorItem();
    menu->AddItem(new BMenuItem(B_TRANSLATE("New" B_UTF8_ELLIPSIS),
                                new BMessage(kMsgProfileNew)));
    menu->AddItem(new BMenuItem(B_TRANSLATE("Manage" B_UTF8_ELLIPSIS),
                                new BMessage(kMsgProfileManage)));

    if (strlen(current_profile)) {
        item = menu->FindItem(current_profile);
        if (item) {
            BString label;
            label << item->Label();
            label << " (current)";
            item->SetLabel(label.String());
            item->SetMarked(true);
        }
    }
}
void RIFFWAVESettingsWindow::RememberSettings(PSettings *settings)
{
	BMenuItem *item;

	item = formatPop->FindMarked();
	if (item != NULL)
		settings->WriteStringEntryValue("General", "OutputFormat", item->Label());
}
void DraggableListView::MouseDown(BPoint point) {
	uint32 buttons = Looper()->CurrentMessage()->FindInt32("buttons");
	int32 index = IndexOf(point);
	if (buttons & B_SECONDARY_MOUSE_BUTTON && index >= 0) {
		Select(index);
		if (list_type == filter) {
			BPopUpMenu popup_menu("popup_menu", false, false);
			popup_menu.SetFont(be_plain_font);
			BMessage* del_msg = new BMessage(SM_REMOVE_FILTER);
			del_msg->AddInt32("filter_id", ((FilterItem*)ItemAt(index))->FilterID());
			BMessage* help_msg = new BMessage(SM_HELP_REQUESTED);
			help_msg->AddString("addon_name", ((FilterItem*)ItemAt(index))->Text());
			popup_menu.AddItem(new BMenuItem("Delete", del_msg));
			popup_menu.AddItem(new BMenuItem("Add-on Help"B_UTF8_ELLIPSIS, help_msg));
			BMenuItem* item = popup_menu.Go(ConvertToScreen(point));
			if (item != NULL) {
				if (strcmp(item->Label(),"Delete") == 0) {
					be_app_messenger.SendMessage(item->Message());
					delete RemoveItem(index);
				if (strcmp(item->Label(),"Add-on Help"B_UTF8_ELLIPSIS) == 0)
					Window()->PostMessage(item->Message());
				}
			}
		} else {
			BView* active_list = Window()->FindView("active_list");
			if (active_list != NULL) {
				BPopUpMenu popup_menu("popup_menu", false, false);
				popup_menu.SetFont(be_plain_font);
				BMessage* add_msg = new BMessage(SM_DRAG_FILTER);
				add_msg->AddString("filter_name", ((BStringItem*)ItemAt(index))->Text());
				BMessage* help_msg = new BMessage(SM_HELP_REQUESTED);
				help_msg->AddString("addon_name", ((BStringItem*)ItemAt(index))->Text());
				popup_menu.AddItem(new BMenuItem("Add", add_msg));
				popup_menu.AddItem(new BMenuItem("Add-on Help"B_UTF8_ELLIPSIS, help_msg));
				BMenuItem* item = popup_menu.Go(ConvertToScreen(point));
				if (item != NULL) {
					if (strcmp(item->Label(),"Add") == 0)
						active_list->MessageReceived(item->Message());
					if (strcmp(item->Label(),"Add-on Help"B_UTF8_ELLIPSIS) == 0)
						Window()->PostMessage(item->Message());
				}
			}
		}
	}
	BListView::MouseDown(point);
}
/*------------------------------------------------------------------------------*\
	()
		-	
\*------------------------------------------------------------------------------*/
void BmPrefsSendMailView::AuthTypeSelected() {
	if (!mCurrAcc)
		return;
	BMenuItem* item = mAuthControl->Menu()->FindMarked();
	if (item)
		mCurrAcc->AuthMethod( item->Label());
	else
		mCurrAcc->AuthMethod( "");
}
Beispiel #20
0
void
DCCPrefsView::MessageReceived (BMessage *msg)
{
    switch (msg->what)
    {
    case M_BLOCK_SIZE_CHANGED:
    {
        BMenuItem *it (NULL);
        msg->FindPointer ("source", reinterpret_cast<void **>(&it));
        if (it)
            vision_app->SetString ("dccBlockSize", 0, it->Label());
    }
    break;

    case M_DEFAULT_PATH_CHANGED:
    {
        const char *path (fDefDir->Text());
        BPath testPath (path, NULL, true);
        if (testPath.InitCheck() == B_OK)
            vision_app->SetString ("dccDefPath", 0, path);
    }
    break;

    case M_AUTO_ACCEPT_CHANGED:
    {
        int32 val (fAutoAccept->Value());
        fDefDir->SetEnabled (val == B_CONTROL_ON);
        vision_app->SetBool ("dccAutoAccept", val);
    }
    break;

    case M_DCC_MIN_PORT_CHANGED:
    {
        const char *portMin (fDccPortMin->Text());
        if (portMin != NULL)
            vision_app->SetString ("dccMinPort", 0, portMin);
    }
    break;
    case M_DCC_MAX_PORT_CHANGED:
    {
        const char *portMax (fDccPortMax->Text());
        if (portMax != NULL)
            vision_app->SetString ("dccMaxPort", 0, portMax);
    }
    break;

    case M_DCC_PRIVATE_CHANGED:
    {
        vision_app->SetBool("dccPrivateCheck", fPrivateCheck->Value() == B_CONTROL_ON);
    }
    break;

    default:
        BView::MessageReceived (msg);
        break;
    }
}
Beispiel #21
0
void ArpMenuField::ComputeDimens(ArpDimens& cur_dimens)
{
	BMenu* menu = MenuBar();
	BMenu* popup = Menu();
	
	if( menu ) {
		copy_attrs(menu);
		copy_attrs(popup);
		menu->SetFont(&PV_MenuFont);
		menu->InvalidateLayout();
	}
	
	get_view_dimens(&cur_dimens, this, false);
	
	font_height fhs;
	BasicFont()->GetHeight(&fhs);
	const float fh = fhs.ascent+fhs.descent+fhs.leading;
	float fw = BasicFont()->StringWidth("WWWW");
	
	float pref_w=0;
	if( popup ) {
		int32 num = popup->CountItems();
		for( int32 i=0; i<num; i++ ) {
			BMenuItem* item = popup->ItemAt(i);
			if( item ) {
				const float w=BasicFont()->StringWidth(item->Label());
				ArpD(cdb << ADH << "Dimensions for popup label "
							<< item->Label() << ": " << w << endl);
				if( w > pref_w ) pref_w = w;
			}
		}
	}
	
	cur_dimens.Y().SetTo(0, fh+12, fh+12, fh+12, 0);
	
	float labelWidth = (Label() && *Label())
		? BasicFont()->StringWidth(Label())	+ BasicFont()->StringWidth(" ")
		: 0;
	
	cur_dimens.X().SetTo(labelWidth,
						 (fw < pref_w ? fw : pref_w) + 20,
						 pref_w + 20, pref_w + 20,
						 0);
}
Beispiel #22
0
status_t
OutputView::GetCodecsForFamily(const media_format_family &family,
					const int32 &width, const int32 &height,
					BMenu *codecs, media_format &initialFormat)
{
	SetInitialFormat(width, height, Settings().ClipDepth(),
		10, initialFormat);
	
	// find the full media_file_format corresponding to
	// the given format family (e.g. AVI)
	media_file_format fileFormat;
	if (!GetMediaFileFormat(family, fileFormat))
		return B_ERROR;
	
	BString currentCodec;
	BMenuItem *marked = codecs->FindMarked();
	if (marked != NULL)
		currentCodec = marked->Label();
	
	// suspend updates while we're rebuilding this menu in order to
	// reduce window flicker and other annoyances
	Window()->BeginViewTransaction();
		
	codecs->RemoveItems(0, codecs->CountItems(), true);
	
	int32 cookie = 0;
	media_codec_info codec;
	media_format dummyFormat;
	while (get_next_encoder(&cookie, &fileFormat, &initialFormat,
			&dummyFormat, &codec) == B_OK) {
		BMenuItem *item = CreateCodecMenuItem(codec);
		if (item != NULL)
			codecs->AddItem(item);
				
		if (codec.pretty_name == currentCodec)
			item->SetMarked(true);
	}
	
	if (codecs->FindMarked() == NULL) {
		BMenuItem *item = codecs->ItemAt(0);
		if (item != NULL)
			item->SetMarked(true);
	}
	
	Window()->EndViewTransaction();
	
	marked = codecs->FindMarked();
	BMessage *message = marked->Message();
	media_codec_info *info;
	ssize_t size;
	if (message->FindData(kCodecData, B_SIMPLE_DATA,
			(const void **)&info, &size) == B_OK)
		fController->SetMediaCodecInfo(*info);
		
	return B_OK;
}
Beispiel #23
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);
}
Beispiel #24
0
/***********************************************************
 * AccountName
 ***********************************************************/
const char*
HAddressView::AccountName()
{
	BMenuField *field = cast_as(FindView("FromMenu"),BMenuField);
	BMenu *menu = field->Menu();
	BMenuItem *item = menu->FindMarked();
	if(!item)
		return NULL;
	return item->Label();
}
Beispiel #25
0
/***********************************************************
 * AddPerson
 ***********************************************************/
void
HAddressView::AddPerson(BMenu *menu
							,const char* title
							,const char* group
							,BMessage *msg
							, char shortcut
							, uint32 modifiers)
{
	BMenu *subMenu(NULL);
	HApp *app = (HApp*)be_app;
	MenuUtils utils;
	
	if(::strlen(group) > 0)
	{
		// Find group item
		int32 count = menu->CountItems();
		for(int32 i = 0;i < count;i++)
		{
			BMenuItem *tmpMenu = menu->ItemAt(i);
			if(tmpMenu && tmpMenu->Submenu())
			{
				if(::strcmp(tmpMenu->Label(),group) == 0)
				{
					subMenu = tmpMenu->Submenu();
					break;
				}
			}
		}
		// Add group item
		if(!subMenu)
		{
			subMenu = new BMenu(group);
			BMessage *message = new BMessage(M_SEL_GROUP);
			message->AddString("group",group);
			BTextControl *control;
			msg->FindPointer("pointer",(void**)&control);
			message->AddPointer("control",control);
			message->AddPointer("menu",subMenu);
			BFont font(be_plain_font);
			font.SetSize(10);
			subMenu->SetFont(&font);
			IconMenuItem *iconItem = new IconMenuItem(subMenu,message,0,0
						,app->GetIcon("OpenFolder"),false);
			iconItem->SetTarget(this,Window());
		
			menu->AddItem(iconItem);
		}
		// Add item
		utils.AddMenuItem(subMenu,title,msg,this,Window(),shortcut,modifiers
						,app->GetIcon("Person"),false);
		
	}else
		utils.AddMenuItem(menu,title,msg,this,Window(),shortcut,modifiers
						,app->GetIcon("Person"),false);
}
Beispiel #26
0
void URLView::MouseUp( BPoint point ) {
	// If the link isn't enabled, don't do anything.
	if( !IsEnabled() )
		return;

	// Do we want to show the right-click menu?
	if( inPopup  &&  GetTextRect().Contains( point ) ) {
		BPopUpMenu *popup = CreatePopupMenu();
			// Work around a current bug in Be's popup menus.
			point.y = point.y - 6;
			
			// Display the popup menu.
			BMenuItem *selected = popup->Go( ConvertToScreen( point ) , false, true );
			
			// Did the user select an item?
			if( selected ) {
				BString label( selected->Label() );
				// Did the user select the first item?  If so, launch the URL.
				if( label.FindFirst( "Open" ) != B_ERROR  ||
					label.FindFirst( "Send" ) != B_ERROR  ||
					label.FindFirst( "Connect" ) != B_ERROR ) {
					LaunchURL();
				}
				// Did the user select the second item?
				else if( label.FindFirst( "Copy" ) != B_ERROR ) {
					CopyToClipboard();
				}
			}
			// If not, restore the normal link color.
			else {
				SetHighColor( color );
				Redraw();
			}
		}

	// If the link was clicked on (and not dragged), run the program
	// that should handle the URL.
	if( selected  &&  GetTextRect().Contains( point )  &&
		!draggedOut  &&  !inPopup ) {
		LaunchURL();
	}
	selected = false;
	draggedOut = false;
	inPopup = false;
	
	// Should we restore the hovering-highlighted color or the original
	// link color?
	if( GetTextRect().Contains( point )  &&  !draggedOut  &&
		!inPopup  &&  hoverEnabled ) {
		SetHighColor( hoverColor );
	}
	else if( !hovering ) SetHighColor( color );
	Redraw();
}
Beispiel #27
0
static void populate_colors(BMenu* dest, const BMessage& src,
							const BMessage& names, const BMessage* initial)
{
	type_code type;
	int32 n;
	ssize_t size;
	rgb_color *col;
	const char *name;
	src.GetInfo ("color", &type, &n);
	for (int32 j = 0; j < n; j++) {
		names.FindString ("color", j, &name);
		if (src.FindData ("color", B_RGB_COLOR_TYPE, j, (const void **)(&col), &size) == B_OK)
		{
			// See if this field already exists in the menu.
			const int32 k = dest->CountItems();
			int32 i;
			bool found = false;
			for (i=0; i<k; i++) {
				BMenuItem* it = dest->ItemAt(i);
				const char* field;
				if (it && it->Message() &&
						it->Message()->FindString("field", &field) == B_OK
						&& strcmp(field, name) == 0) {
					ColorMenuItem* ci = dynamic_cast<ColorMenuItem*>(it);
					if (ci) ci->SetColor(*col);
					found = true;
					break;
				}
			}

			if (found) continue;

			// This color doesn't currently exist; add it in.
			BMessage* msg = new BMessage(CMD_CHOOSE_UI_COLOR);
			msg->AddString("field", name);
			msg->AddInt32("index", j);
			const char* label = name;

			// Alphabetical order.
			for (i=0; i<n; i++) {
				BMenuItem* it = dest->ItemAt(i);
				if (it && strcmp(it->Label(), label) > 0)
					break;
			}
			rgb_color *init_col;
			if (!initial || initial->FindData ("color", B_RGB_COLOR_TYPE, j,
				(const void **)&init_col, &size) != B_OK)
				*init_col = *col;

			ColorMenuItem* ci = new ColorMenuItem(label, msg, *col, *init_col);
			dest->AddItem(ci);
		}
	}
}
Beispiel #28
0
BString AmControlChangeInfoView::MenuStringForControl(uint32 control) const
{
	if (control > 127) return BString("?");
	BMenu*		menu = ControlMenu();
	if (!menu) return BString( am_control_name(control) );

	BMenuItem*	item;
	for (int32 index = 0; (item = menu->ItemAt( index )); index++) {
		if (index == (int32)control) return BString( item->Label() );
	}
	return BString( am_control_name(control) );
}
BString
LanguageConfigView::GetLanguageTag()
{
	BString languageTag("enUS");

	BMenuItem* firstMarkedItem = fLanguageMenu->FindMarked();
	if (NULL != firstMarkedItem) {
		languageTag = BString(firstMarkedItem->Label());
	}
	
	return languageTag;
}
Beispiel #30
0
void
PPPoEView::MessageReceived(BMessage *message)
{
	switch(message->what) {
		case kMsgSelectInterface: {
			BMenuItem *item = fInterface->Menu()->FindMarked();
			if(item)
				fInterfaceName = item->Label();
		} break;
		
		case kMsgSelectOther:
			(new TextRequestDialog("InterfaceName", NULL, kRequestInterfaceName,
				fInterfaceName.String()))->Go(new BInvoker(
				new BMessage(kMsgFinishSelectOther), this));
		break;
		
		case kMsgFinishSelectOther: {
			int32 which;
			message->FindInt32("which", &which);
			
			const char *name = message->FindString("text");
			BMenu *menu = fInterface->Menu();
			BMenuItem *item;
			if(which != 1 || !name || strlen(name) == 0) {
				item = menu->FindItem(fInterfaceName.String());
				if(item && menu->IndexOf(item) <= menu->CountItems() - 2)
					item->SetMarked(true);
				else
					fOtherInterface->SetMarked(true);
				
				return;
			}
			
			fInterfaceName = name;
			
			item = menu->FindItem(fInterfaceName.String());
			if(item && menu->IndexOf(item) <= menu->CountItems() - 2) {
				item->SetMarked(true);
				return;
			}
			
			BString label(kLabelOtherInterface);
			label << " " << name;
			fOtherInterface->SetLabel(label.String());
			fOtherInterface->SetMarked(true);
				// XXX: this is needed to tell the owning menu to update its label
		} break;
		
		default:
			BView::MessageReceived(message);
	}
}