Beispiel #1
0
BPopUpMenu*	AmTrackInfoView::NewPropertiesMenu() const
{
	BPopUpMenu*				menu = new BPopUpMenu( "properties menu" );
	if( !menu ) return 0;
	BMenuItem*				item;
	/* The Duplicate menu item.
	 */
	BMessage*				msg = new BMessage( DUPLICATE_INFO_MSG );
	if( msg && (item = new BMenuItem( "Duplicate", msg )) ) {
		msg->AddPointer( SZ_VIEW_ID, this );
		msg->AddString( SZ_FACTORY_SIGNATURE, mFactorySignature.String() );
		msg->AddString( SZ_FACTORY_VIEW_NAME, mViewName.String() );
		menu->AddItem( item );
	}
	/* The Change View menu item.
	 */
	if( (item = NewChangeViewItem()) ) menu->AddItem( item );
	/* The Remove menu item.
	 */
	msg = new BMessage( REMOVE_INFO_MSG );
	if( msg && (item = new BMenuItem( "Remove", msg )) ) {
		msg->AddPointer( SZ_VIEW_ID, this );
		menu->AddItem( item );
	}
	return menu;
}
BPopUpMenu* AmControlChangeInfoView::NewPropertiesMenu() const
{
	BPopUpMenu*		menu = inherited::NewPropertiesMenu();
	if (!menu) return menu;
	mCachedControlMenu = NewControlMenu();

	if (!mCachedControlMenu) return menu;
	BMenuItem*		item;
	if (mCachedControlMenu->CountItems() < 1 ) {
		item = new _AmActiveControlItem( "<track has no output filter>", new BMessage('null') );
		if (item) {
			item->SetEnabled( false );
			mCachedControlMenu->AddItem(item);
		}
	}
	item = new BMenuItem(mCachedControlMenu);
	if (!item) {
		delete mCachedControlMenu;
		mCachedControlMenu = NULL;
		return menu;
	}
	menu->AddSeparatorItem();
	menu->AddItem(item);
	return menu;
}
Beispiel #3
0
void
Panel::RunControlMenu(BPoint where)
{
	BPopUpMenu	*qMenu = new BPopUpMenu("env sel", true, FALSE);
	
	BPoint			orig = where;
	ConvertToScreen(&where);
	
	BMessage	*msg;
	BMenuItem	*item;
	
	if (displayMode != PANEL_DISPLAY_SMALL) {
		msg = new BMessage(SET_DISPLAY_MODE);
		msg->AddInt32("display mode", PANEL_DISPLAY_SMALL);
		item = new BMenuItem("Close", msg);
		qMenu->AddItem(item);
		item->SetTarget(this);
	}
	if (displayMode != PANEL_DISPLAY_BIG) {
		msg = new BMessage(SET_DISPLAY_MODE);
		msg->AddInt32("display mode", PANEL_DISPLAY_BIG);
		item = new BMenuItem("Open", msg);
		qMenu->AddItem(item);
		item->SetTarget(this);
	}
		
	qMenu->SetAsyncAutoDestruct(true);
	qMenu->Go(where, true, false, true);
}
Beispiel #4
0
BPopUpMenu *TPrefsWindow::BuildFontMenu(BFont *font)
{
	char		label[512];
	int32		family_count;
	int32		family_loop;
	int32		style_count;
	int32		style_loop;
	BMenuItem	*item;
	BMessage	*msg;
	BPopUpMenu	*menu;
	font_family	def_family;
	font_family	f_family;
	font_style	def_style;
	font_style	f_style;

	menu = new BPopUpMenu("");
	font->GetFamilyAndStyle(&def_family, &def_style);
	family_count = count_font_families();
	for (family_loop = 0; family_loop < family_count; family_loop++) {
		get_font_family(family_loop, &f_family);
		style_count = count_font_styles(f_family);
		for (style_loop = 0; style_loop < style_count; style_loop++) {
			get_font_style(f_family, style_loop, &f_style);
			msg = new BMessage(P_FONT);
			msg->AddString("font", f_family);
			msg->AddString("style", f_style);
			sprintf(label, "%s %s", f_family, f_style);
			menu->AddItem(item = new BMenuItem(label, msg));
			if ((!strcmp(def_family, f_family)) && (!strcmp(def_style, f_style)))
				item->SetMarked(true);
			item->SetTarget(this);
		}
	}
	return menu;
}
Beispiel #5
0
ConfigView::ConfigView()
	:	BView(BRect(0,0,10,10),"notifier_config",B_FOLLOW_LEFT | B_FOLLOW_TOP,0)
{
	SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));

	// determine font height
	font_height fontHeight;
	GetFontHeight(&fontHeight);
	float itemHeight = (int32)(fontHeight.ascent + fontHeight.descent + fontHeight.leading) + 6;
	
	BRect frame(5,2,250,itemHeight + 2);
	BPopUpMenu *menu = new BPopUpMenu(B_EMPTY_STRING,false,false);

	const char *notifyMethods[] = {
		MDR_DIALECT_CHOICE ("Beep","音"),
		MDR_DIALECT_CHOICE ("Alert","窓(メール毎)"),
		MDR_DIALECT_CHOICE ("Keyboard LEDs","キーボードLED"),
		MDR_DIALECT_CHOICE ("Central alert","窓(一括)"),
		"Central beep","Log window"};
	for (int32 i = 0,j = 1;i < 6;i++,j *= 2)
		menu->AddItem(new BMenuItem(notifyMethods[i],new BMessage(kMsgNotifyMethod)));

	BMenuField *field = new BMenuField(frame,"notify",
		MDR_DIALECT_CHOICE ("Method:","方法:"),menu);
	field->ResizeToPreferred();
	field->SetDivider(field->StringWidth(
		MDR_DIALECT_CHOICE ("Method:","方法:")) + 6);
	AddChild(field);

	ResizeToPreferred();
}		
Beispiel #6
0
BPopUpMenu*
TPrefsWindow::_BuildButtonBarMenu(uint8 show)
{
	BMenuItem* item;
	BMessage* msg;
	BPopUpMenu* menu = new BPopUpMenu("");

	msg = new BMessage(P_BUTTON_BAR);
	msg->AddInt8("bar", kShowToolBar);
	menu->AddItem(item = new BMenuItem(
		B_TRANSLATE("Show icons & labels"), msg));
	if (show & 1)
		item->SetMarked(true);

	msg = new BMessage(P_BUTTON_BAR);
	msg->AddInt8("bar", kShowToolBarIconsOnly);
	menu->AddItem(item = new BMenuItem(B_TRANSLATE("Show icons only"), msg));
	if (show & 2)
		item->SetMarked(true);

	msg = new BMessage(P_BUTTON_BAR);
	msg->AddInt8("bar", kHideToolBar);
	menu->AddItem(item = new BMenuItem(B_TRANSLATE("Hide"), msg));
	if (!show)
		item->SetMarked(true);

	return menu;
}
Beispiel #7
0
void SplitWindow::AddCat()
{
	ResizeBy(0, 25);
	uint16 xpos = 20;
	uint16 width = 150;
	BTextControl* tc = new BTextControl(BRect(xpos - 5, ypos + 10, 
		xpos + width, ypos + 10), "CatField", "", "", 0);
	xpos += width;
	tc->SetDivider(0);
	catTexts.push_back(tc);
	v->AddChild(tc);
	BPopUpMenu* pu = new BPopUpMenu("", true, false);
	BMenuField* mf = new BMenuField(BRect(xpos + 2, ypos + 9, 
		xpos + 2, ypos + 9), "CatMenu", "", pu);
	mf->SetDivider(0);
	v->AddChild(mf);
	xpos += 30;
	tc = new BTextControl(BRect(xpos - 5, ypos + 10, 
		xpos + 75, ypos + 10), "AmountField", "", "", 0);
	tc->SetDivider(0);
	tc->SetAlignment(B_ALIGN_LEFT, B_ALIGN_RIGHT);
	tc->SetModificationMessage(new BMessage(AmountModifiedMSG));
	amtTexts.push_back(tc);
	v->AddChild(tc);
	ypos += 25;

	for (cas::iterator ci = catS->begin(); ci != catS->end(); ci++)
	{
		if ((*ci)->IsRoot())
		{
			pu->AddItem(MakeCatMenu(*ci));
		}
	}
	catnum++;
}
BPopUpMenu*
DefaultPartitionPage::_CreatePopUpMenu()
{
	int32 defaultPartitionIndex;
	fSettings->FindInt32("defaultPartition", &defaultPartitionIndex);

	BMenuItem* selectedItem = NULL;
	int32 selectedItemIndex = 0;

	BPopUpMenu* menu = new BPopUpMenu(B_TRANSLATE_COMMENT("Partitions",
		"Pop up menu title"));
	BMessage message;
	for (int32 i = 0; fSettings->FindMessage("partition", i, &message) == B_OK;
			i++) {
		bool show;
		if (message.FindBool("show", &show) != B_OK || !show)
			continue;

		BString name;
		message.FindString("name", &name);

		BMessage* msg = new BMessage(kMsgPartition);
		msg->AddInt32("index", i);
		BMenuItem* item = new BMenuItem(name.String(), msg);
		menu->AddItem(item);
		if (defaultPartitionIndex == i || selectedItem == NULL) {
			selectedItem = item;
			selectedItemIndex = i;
		}
	}
	fSettings->ReplaceInt32("defaultPartition", selectedItemIndex);
	selectedItem->SetMarked(true);
	return menu;
}
Beispiel #9
0
/*static*/ BPopUpMenu*
AppearancePrefView::_MakeMenu(uint32 msg, const char** items,
	const char* defaultItemName)
{
	BPopUpMenu* menu = new BPopUpMenu("");

	int32 i = 0;
	while (*items) {
		if (!strcmp((*items), ""))
			menu->AddSeparatorItem();
		else {
			BMessage* message = new BMessage(msg);
			menu->AddItem(new BMenuItem((*items), message));
		}

		items++;
		i++;
	}

	BMenuItem* defaultItem = menu->FindItem(defaultItemName);
	if (defaultItem)
		defaultItem->SetMarked(true);

	return menu;
}
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
JobSetupView::AddPopUpMenu(const DriverSpecificCap* capability,
	BGridLayout* gridLayout, int& row)
{
	const char* label = capability->fLabel.c_str();
	BPopUpMenu* popUpMenu = new BPopUpMenu(label);
	popUpMenu->SetRadioMode(true);

	PrinterCap::CapID category = static_cast<PrinterCap::CapID>(
		capability->ID());

	const BaseCap** categoryCapabilities = fPrinterCap->GetCaps(category);

	int categoryCount = fPrinterCap->CountCap(category);

	string value = GetDriverSpecificValue(category, capability->Key());
	PrinterCap::KeyPredicate predicate(value.c_str());

	FillCapabilityMenu(popUpMenu, kMsgNone, categoryCapabilities,
		categoryCount, predicate);

	BString menuLabel = label;
	menuLabel << ":";
	BMenuField* menuField = new BMenuField(label, menuLabel.String(),
		popUpMenu);
	popUpMenu->SetTargetForItems(this);

	gridLayout->AddItem(menuField->CreateLabelLayoutItem(),
		0, row);
	gridLayout->AddItem(menuField->CreateMenuBarLayoutItem(),
		1, row);
	row ++;

	fDriverSpecificPopUpMenus[category] = popUpMenu;
}
Beispiel #12
0
int GSubMenu::Float(GView *Parent, int x, int y, bool Left)
{
	if (Info)
	{
		BPopUpMenu *Popup = new BPopUpMenu("PopUpMenu");
		if (Popup)
		{
			_CopyMenu(Popup, this);
		
			BPoint Pt(x, y);
			BMenuItem *Item = Popup->Go(Pt);
			if (Item)
			{
				#undef Message
				BMessage *Msg = Item->Message();
				int32 i;
				if (Msg && Msg->FindInt32("Cmd", &i) == B_OK)
				{
					return i;
				}
			}
		}
	}
	
	return 0;
}
Beispiel #13
0
BPopUpMenu*
TPrefsWindow::_BuildAccountMenu(uint32 account)
{
    BPopUpMenu* menu = new BPopUpMenu("");
    BMenuItem* item;

    //menu->SetRadioMode(true);
    BList chains;
    if (GetOutboundMailChains(&chains) < B_OK) {
        menu->AddItem(item = new BMenuItem("<no account found>", NULL));
        item->SetEnabled(false);
        return menu;
    }

    BMessage* msg;
    for (int32 i = 0; i < chains.CountItems(); i++) {
        BMailChain* chain = (BMailChain*)chains.ItemAt(i);
        item = new BMenuItem(chain->Name(), msg = new BMessage(P_ACCOUNT));

        msg->AddInt32("id",chain->ID());

        if (account == chain->ID())
            item->SetMarked(true);

        menu->AddItem(item);
        delete chain;
    }
    return menu;
}
Beispiel #14
0
BPopUpMenu*
MenuBuilder::_BuildPopUpMenu(KeyBind* bind, BView* target)
{
	if (bind == NULL)
		return NULL;

	// The first item describe the menu
	BPopUpMenu* menu = new BPopUpMenu(bind[0].label);
	BObjectList<BPopUpMenu> menuList(false);
	menuList.AddItem(menu);

	for (int i = 1; bind[i].message != FABER_EOF; i++) {

		menu = menuList.ItemAt(menuList.CountItems()-1);

		if (bind[i].message == FABER_ITEM_START) {
			BPopUpMenu* subMenu = new BPopUpMenu(bind[i].label);
			menu->AddItem(subMenu);
			menuList.AddItem(subMenu);
		}  else if (bind[i].message == FABER_ITEM_END) {
			if (menuList.CountItems() > 1)
				menuList.RemoveItemAt(menuList.CountItems()-1);
		} else {
			BMenuItem* item = _BuildMenuItem(bind[i].message, bind[i].label);
			if (target != NULL)
				item->SetTarget(target);

			menu->AddItem(item);
		}
	}
	return menuList.ItemAt(0);
}
Beispiel #15
0
BPopUpMenu*
TPrefsWindow::_BuildAccountMenu(int32 account)
{
	BPopUpMenu* menu = new BPopUpMenu("");
	BMenuItem* item;

	//menu->SetRadioMode(true);
	BMailAccounts accounts;
	if (accounts.CountAccounts() == 0) {
		menu->AddItem(item = new BMenuItem(B_TRANSLATE("<no account found>"), NULL));
		item->SetEnabled(false);
		return menu;
	}

	BMessage* msg;
	for (int32 i = 0; i < accounts.CountAccounts(); i++) {
		BMailAccountSettings* settings = accounts.AccountAt(i);
		item = new BMenuItem(settings->Name(), msg = new BMessage(P_ACCOUNT));

		msg->AddInt32("id", settings->AccountID());

		if (account == settings->AccountID())
			item->SetMarked(true);

		menu->AddItem(item);
	}
	return menu;
}
Beispiel #16
0
void
StatusView::MouseDown(BPoint where)
{
	if (!fReadOnly)
		return;

	float left = fCellWidth[kPositionCell] + fCellWidth[kEncodingCell];
	if (where.x < left)
		return;

	int32 clicks = 0;
	BMessage* message = Window()->CurrentMessage();
	if (message != NULL
		&& message->FindInt32("clicks", &clicks) == B_OK && clicks > 1)
			return;

	BPopUpMenu *menu = new BPopUpMenu(B_EMPTY_STRING, false, false);
	menu->AddItem(new BMenuItem(B_TRANSLATE("Unlock file"),
					new BMessage(UNLOCK_FILE)));
	where.x = left;
	where.y = Bounds().bottom;

	ConvertToScreen(&where);
	menu->SetTargetForItems(this);
	menu->Go(where, true, true,	true);
}
ExpMixerUI::ExpMixerUI(BRect frame, const char *name, ExpMix *mix)
: BView(frame, name, B_FOLLOW_ALL, B_WILL_DRAW)
{
	BMessage *msg;
	BRect rect;
	
	// build a BStringView
	rect.Set(5.0,5.0, frame.Width()/2.0, 20.0);
	AddChild(new BStringView(rect, "string", "Background:"));
	
	// build our radio buttons
	// source 1
	rect.Set(rect.left, rect.bottom + 5.0, rect.right, rect.bottom + 20.0);
	msg = new BMessage(EM_SET_BACKGROUND);
	msg->AddInt32("which", 0);
	AddChild(radio1 = new BRadioButton(rect, "radio1", "Source 1", msg));
	// source 2
	rect.Set(rect.left, rect.bottom + 5.0, rect.right, rect.bottom + 20.0);
	msg = new BMessage(EM_SET_BACKGROUND);
	msg->AddInt32("which", 1);
	AddChild(radio2 = new BRadioButton(rect, "radio2", "Source 2", msg));
	// turn radio1 on
	radio1->SetValue(1);
	
	// build our op menu
	BPopUpMenu *menu = new BPopUpMenu("op menu");
	// add op
	msg = new BMessage(EM_SET_OP);
	msg->AddInt32("which", 0);
	menu->AddItem(new BMenuItem("add", msg));
	// sub op
	msg = new BMessage(EM_SET_OP);
	msg->AddInt32("which", 1);
	menu->AddItem(new BMenuItem("sub", msg));
	// max op
	msg = new BMessage(EM_SET_OP);
	msg->AddInt32("which", 2);
	menu->AddItem(new BMenuItem("max", msg));
	// min op
	msg = new BMessage(EM_SET_OP);
	msg->AddInt32("which", 3);
	menu->AddItem(new BMenuItem("min", msg));
	// now add it to a menu field
	rect.Set(frame.Width()/2. + 20., 25., frame.Width() - 10., 50.);
	AddChild(opMenu = new BMenuField(rect, "menu", "Op: ", menu));
	
	// cache our initial width and height
	width = frame.Width();
	height = frame.Height();
	
	// background defaults to 0 (source 1)
	backWhich = 0;
	
	// know thy mixer
	theMixer = mix;
	
	// set the view color
	SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
}
/*!	\function		CalendarModulePreferencesView::PopulateModulesMenu
 *	\brief			Create a menu to select the module user is setting up.
 *	\note			This is an internal function.
 */
BPopUpMenu*		CalendarModulePreferencesView::PopulateModulesMenu( void )
{
	BPopUpMenu* toReturn = NULL;
	BMenuItem* 	toAdd = NULL;
	BMessage*  	toSend = NULL;
	BString		moduleId;	// Note: this is not a pointer!
	CalendarModule* currentCalModule = NULL;
	
	toReturn = new BPopUpMenu("Calendar Modules");
	if ( ! toReturn )
	{ 
		/* Panic! */
		exit (1);
	}
	
	// Looping on all calendar modules available in the system.
	for ( uint i=0; i < NUMBER_OF_CALENDAR_MODULES; ++i )
	{
		// Obtain the next calendar module
		currentCalModule = (CalendarModule *)listOfCalendarModules->ItemAt( i );
		if ( !currentCalendarModule )
		{
			continue;	// Skipping unavailable ones
		}
		
		// Create the message
		toSend = new BMessage( kCalendarModuleChosen );
		if ( !toSend )
		{
			/* Panic! */
			exit(1);
		}
		
		// Add the ID of the module to the message
		moduleId = currentCalModule->Identify();
		toSend->AddString( "Module ID", moduleId );
		
		// Create the menu item
		toAdd = new BMenuItem( moduleId.String(), toSend );
		if ( ! toAdd )
		{
			/* Panic! */
			exit(1);
		}
		
		// Add the newly created item to the menu
		toReturn->AddItem( toAdd );
		
		// Gregorian calendar module is the default one
		if ( moduleId == "Gregorian" )
		{
			toAdd->SetMarked( true );
		}
		
	}	/* <-- end of "for ( every calendar module )" */
	
	return toReturn;
}	// <-- end of function "CalendarModulePreferencesView::PopulateModulesMenu"
Beispiel #19
0
void
QuaSymbolBridge::MouseDown(BPoint where)
{
	long		channel, quant;
	BRect		area = Bounds();

	ulong		mods = modifiers(); // Key mods???
	ulong		buts;
	BMessage	*msg;
	BPoint		pt;
	drawing_mode	cur_mode = DrawingMode();
	long		clicks;
	
	GetMouse(&pt, &buts);
	msg = Window()->CurrentMessage();
	
	if ((clicks=msg->FindInt32("clicks")) == 1) {
		if (buts & B_SECONDARY_MOUSE_BUTTON) {
			BPopUpMenu	*qMenu = new BPopUpMenu("env sel", true, FALSE);
			
			BPoint			orig = where;
			ConvertToScreen(&where);
			
			BMessage	*msg = new BMessage(SET_DISPLAY_MODE);
			msg->AddInt32("display mode", OBJECT_DISPLAY_SMALL);
			BMenuItem	*item = new BMenuItem("Small", msg);
			qMenu->AddItem(item);
			item->SetTarget(this);
		
			msg = new BMessage(SET_DISPLAY_MODE);
			msg->AddInt32("display mode", OBJECT_DISPLAY_BIG);
			item = new BMenuItem("Large", msg);
			qMenu->AddItem(item);
			item->SetTarget(this);
		
			qMenu->SetAsyncAutoDestruct(true);
			qMenu->Go(where, true, false, true);
		} else {
			msg = new BMessage(MOVE_OBJECT);
		 	msg->AddPointer("sym_object", this);
		 	
			if (mods & B_SHIFT_KEY) {
				((ObjectViewContainer *)Parent())->AddSelection(this);
			} else {
				((ObjectViewContainer *)Parent())->Select(this);
			}
		
			DragMessage(msg, area);
		}
	} else if (clicks > 1) {	// edit object
		Edit();
	} else {
	}
}
Beispiel #20
0
static BPopUpMenu* CreateMetaPopUp(int col)
{
	MetaKeyStateMap& map = GetNthKeyMap(col);
	BPopUpMenu * popup = new BPopUpMenu(NULL, false);
	int numStates = map.GetNumStates();
	
	for (int i = 0; i < numStates; i++) 
		popup->AddItem(new BMenuItem(map.GetNthStateDesc(i), NULL));
	
	return popup;
}
Beispiel #21
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();
}
void
InitializeBFSEditor::_CreateViewControls()
{
	fNameControl = new BTextControl(B_TRANSLATE("Name:"), "Haiku", NULL);
	fNameControl->SetModificationMessage(new BMessage(MSG_NAME_CHANGED));
	fNameControl->TextView()->SetMaxBytes(31);

	BPopUpMenu* blocksizeMenu = new BPopUpMenu("blocksize");
	BMessage* message = new BMessage(MSG_BLOCK_SIZE);
	message->AddString("size", "1024");
	blocksizeMenu->AddItem(new BMenuItem(
		B_TRANSLATE("1024 (Mostly small files)"), message));
	message = new BMessage(MSG_BLOCK_SIZE);
	message->AddString("size", "2048");
	BMenuItem* defaultItem = new BMenuItem(B_TRANSLATE("2048 (Recommended)"),
		message);
	blocksizeMenu->AddItem(defaultItem);
	message = new BMessage(MSG_BLOCK_SIZE);
	message->AddString("size", "4096");
	blocksizeMenu->AddItem(new BMenuItem("4096", message));
	message = new BMessage(MSG_BLOCK_SIZE);
	message->AddString("size", "8192");
	blocksizeMenu->AddItem(new BMenuItem(
		B_TRANSLATE("8192 (Mostly large files)"), message));

	fBlockSizeMenuField = new BMenuField(B_TRANSLATE("Blocksize:"),
		blocksizeMenu);
	defaultItem->SetMarked(true);

	fUseIndicesCheckBox = new BCheckBox(B_TRANSLATE("Enable query support"),
		NULL);
	fUseIndicesCheckBox->SetValue(true);
	fUseIndicesCheckBox->SetToolTip(B_TRANSLATE("Disabling query support may "
		"speed up certain file system operations, but should only be used "
		"if one is absolutely certain that one will not need queries.\n"
		"Any volume that is intended for booting Haiku must have query "
		"support enabled."));

	float spacing = be_control_look->DefaultItemSpacing();

	fView = BGridLayoutBuilder(spacing, spacing)
		// row 1
		.Add(fNameControl->CreateLabelLayoutItem(), 0, 0)
		.Add(fNameControl->CreateTextViewLayoutItem(), 1, 0)

		// row 2
		.Add(fBlockSizeMenuField->CreateLabelLayoutItem(), 0, 1)
		.Add(fBlockSizeMenuField->CreateMenuBarLayoutItem(), 1, 1)

		// row 3
		.Add(fUseIndicesCheckBox, 0, 2, 2).View()
	;
}
Beispiel #23
0
// ---------------------------------------------------------------
// Constructor
//
// Sets up the view settings
//
// Preconditions:
//
// Parameters:
//
// Postconditions:
//
// Returns:
// ---------------------------------------------------------------
SGIView::SGIView(const BRect &frame, const char *name,
	uint32 resize, uint32 flags, TranslatorSettings *settings)
	:	BView(frame, name, resize, flags),
		fSettings(settings)
{
	SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	SetLowColor(ViewColor());

	BPopUpMenu* menu = new BPopUpMenu("pick compression");

	uint32 currentCompression = fSettings->SetGetInt32(SGI_SETTING_COMPRESSION);
	// create the menu items with the various compression methods
	add_menu_item(menu, SGI_COMP_NONE, "None", currentCompression);
//	menu->AddSeparatorItem();
	add_menu_item(menu, SGI_COMP_RLE, "RLE", currentCompression);

// DON'T turn this on, it's so slow that I didn't wait long enough
// the one time I tested this. So I don't know if the code even works.
// Supposedly, this would look for an already written scanline, and
// modify the scanline tables so that the current row is not written
// at all...

//	add_menu_item(menu, SGI_COMP_ARLE, "Agressive RLE", currentCompression);

	BRect menuFrame = Bounds();
	menuFrame.bottom = menuFrame.top + menu->Bounds().Height();
	fCompressionMF = new BMenuField(menuFrame, "compression",
									"Use compression:", menu, true/*,
									B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP*/);
	if (fCompressionMF->MenuBar())
		fCompressionMF->MenuBar()->ResizeToPreferred();
	fCompressionMF->ResizeToPreferred();

	// figure out where the text ends
	font_height fh;
	be_bold_font->GetHeight(&fh);
	float xbold, ybold;
	xbold = fh.descent + 1;
	ybold = fh.ascent + fh.descent * 2 + fh.leading;

	font_height plainh;
	be_plain_font->GetHeight(&plainh);
	float yplain;
	yplain = plainh.ascent + plainh.descent * 2 + plainh.leading;

	// position the menu field below all the text we draw in Draw()
	BPoint textOffset(0.0, yplain * 2 + ybold);
	fCompressionMF->MoveTo(textOffset);

	AddChild(fCompressionMF);

	ResizeToPreferred();
}
Beispiel #24
0
static BPopUpMenu* CreateKeysPopUp()
{
	BPopUpMenu* popup = new BPopUpMenu(NULL, false);
	int numKeys = GetNumKeyIndices();
	for (int i = 0; i < numKeys; i++) {
		const char* next = GetKeyName(i);
		
		if (next) 
			popup->AddItem(new BMenuItem(next, NULL));
	}
	return popup;
}
void
MediaReplicant::MouseDown(BPoint point)
{
	int32 buttons = B_PRIMARY_MOUSE_BUTTON;
	if (Looper() != NULL && Looper()->CurrentMessage() != NULL)
		Looper()->CurrentMessage()->FindInt32("buttons", &buttons);

	BPoint where = ConvertToScreen(point);

	if ((buttons & B_SECONDARY_MOUSE_BUTTON) != 0) {
		BPopUpMenu* menu = new BPopUpMenu("", false, false);
		menu->SetFont(be_plain_font);

		menu->AddItem(new BMenuItem(
			B_TRANSLATE("Media preferences" B_UTF8_ELLIPSIS),
			new BMessage(kMsgOpenMediaSettings)));
		menu->AddItem(new BMenuItem(
			B_TRANSLATE("Sound preferences" B_UTF8_ELLIPSIS),
			new BMessage(kMsgOpenSoundSettings)));

		menu->AddSeparatorItem();

		menu->AddItem(new BMenuItem(B_TRANSLATE("Open MediaPlayer"),
			new BMessage(kMsgOpenMediaPlayer)));

		menu->AddSeparatorItem();

		BMenu* subMenu = new BMenu(B_TRANSLATE("Options"));
		menu->AddItem(subMenu);

		BMenuItem* item = new BMenuItem(B_TRANSLATE("Control physical output"),
			new BMessage(kMsgVolumeWhich));
		item->SetMarked(fVolumeWhich == VOLUME_USE_PHYS_OUTPUT);
		subMenu->AddItem(item);

		item = new BMenuItem(B_TRANSLATE("Beep"),
			new BMessage(kMsgToggleBeep));
		item->SetMarked(!fDontBeep);
		subMenu->AddItem(item);

		menu->SetTargetForItems(this);
		subMenu->SetTargetForItems(this);

		menu->Go(where, true, true, BRect(where - BPoint(4, 4),
			where + BPoint(4, 4)));
	} else {
		// Show VolumeWindow
		fVolumeSlider = new VolumeWindow(BRect(where.x, where.y,
			where.x + 207, where.y + 19), fDontBeep, fVolumeWhich);
		fVolumeSlider->Show();
	}
}
Beispiel #26
0
BPopUpMenu*
TPrefsWindow::_BuildFontMenu(BFont* font)
{
	font_family	def_family;
	font_style	def_style;
	font_family	f_family;
	font_style	f_style;

	BPopUpMenu *menu = new BPopUpMenu("");
	font->GetFamilyAndStyle(&def_family, &def_style);

	int32 family_menu_index = 0;
	int family_count = count_font_families();
	for (int family_loop = 0; family_loop < family_count; family_loop++) {
		get_font_family(family_loop, &f_family);
		BMenu *family_menu = new BMenu(f_family);

		int style_count = count_font_styles(f_family);
		for (int style_loop = 0; style_loop < style_count; style_loop++) {
			get_font_style(f_family, style_loop, &f_style);

			BMessage *msg = new BMessage(P_FONT);
			msg->AddString("font", f_family);
			msg->AddString("style", f_style);
			// we send this to make setting the Family easier when things
			// change
			msg->AddInt32("parent_index", family_menu_index);

			BMenuItem *item = new BMenuItem(f_style, msg);
			family_menu->AddItem(item);
			if ((strcmp(def_family, f_family) == 0)
				&& (strcmp(def_style, f_style) == 0)) {
				item->SetMarked(true);
			}

			item->SetTarget(this);
		}

		menu->AddItem(family_menu);
		BMenuItem *item = menu->ItemAt(family_menu_index);
		BMessage *msg = new BMessage(P_FONT);
		msg->AddString("font", f_family);

		item->SetMessage(msg);
		item->SetTarget(this);
		if (strcmp(def_family, f_family) == 0)
			item->SetMarked(true);

		family_menu_index++;
	}
	return menu;
}
Beispiel #27
0
void
DeskbarView::MouseDown(BPoint pos)
{
	Looper()->CurrentMessage()->FindInt32("buttons", &fLastButtons);

	if ((fLastButtons & B_SECONDARY_MOUSE_BUTTON) != 0) {
		ConvertToScreen(&pos);

		BPopUpMenu* menu = _BuildMenu();
		menu->Go(pos, true, true, BRect(pos.x - 2, pos.y - 2,
			pos.x + 2, pos.y + 2), true);
	}
}
Beispiel #28
0
void BWebPage::handleMouseEvent(const BMessage* message)
{
    WebCore::Frame* frame = fMainFrame->Frame();
    if (!frame->view() || !frame->document())
        return;

    PlatformMouseEvent event(message);
    switch (message->what) {
    case B_MOUSE_DOWN:
        // Handle context menus, if necessary.
        if (event.button() == RightButton) {
            fPage->contextMenuController()->clearContextMenu();

            WebCore::Frame* focusedFrame = fPage->focusController()->focusedOrMainFrame();
            focusedFrame->eventHandler()->sendContextMenuEvent(event);
            // If the web page implements it's own context menu handling, then
            // the contextMenu() pointer will be zero. In this case, we should
            // also swallow the event.
            ContextMenu* contextMenu = fPage->contextMenuController()->contextMenu();
            if (contextMenu) {
            	BMenu* platformMenu = contextMenu->releasePlatformDescription();
            	if (platformMenu) {
            		// Need to convert the BMenu into BPopUpMenu.
	            	BPopUpMenu* popupMenu = new BPopUpMenu("context menu");
					for (int32 i = platformMenu->CountItems() - 1; i >= 0; i--) {
					    BMenuItem* item = platformMenu->RemoveItem(i);
					    popupMenu->AddItem(item, 0);
					}
					BPoint screenLocation(event.globalPosition().x() + 2,
					    event.globalPosition().y() + 2);
            	    popupMenu->Go(screenLocation, true, true, true);
            	    delete platformMenu;
            	}
            }
            break;
    	}
    	// Handle regular mouse events.
        frame->eventHandler()->handleMousePressEvent(event);
        break;
    case B_MOUSE_UP:
        frame->eventHandler()->handleMouseReleaseEvent(event);
        break;
    case B_MOUSE_MOVED:
    default:
        frame->eventHandler()->mouseMoved(event);
        break;
    }
}
Beispiel #29
0
SpaceBarSettingsView::SpaceBarSettingsView()
	:
	SettingsView("SpaceBarSettingsView")
{
	fSpaceBarShowCheckBox = new BCheckBox("",
		B_TRANSLATE("Show space bars on volumes"),
		new BMessage(kUpdateVolumeSpaceBar));

	BPopUpMenu* menu = new BPopUpMenu(B_EMPTY_STRING);
	menu->SetFont(be_plain_font);

	BMenuItem* item;
	menu->AddItem(item = new BMenuItem(
		B_TRANSLATE("Used space color"),
		new BMessage(kSpaceBarSwitchColor)));
	item->SetMarked(true);
	fCurrentColor = 0;
	menu->AddItem(new BMenuItem(
		B_TRANSLATE("Free space color"),
		new BMessage(kSpaceBarSwitchColor)));
	menu->AddItem(new BMenuItem(
		B_TRANSLATE("Warning space color"),
		new BMessage(kSpaceBarSwitchColor)));

	BBox* box = new BBox("box");
	box->SetLabel(fColorPicker = new BMenuField("menu", NULL, menu));

	fColorControl = new BColorControl(BPoint(8,
			fColorPicker->Bounds().Height() + 8 + kItemExtraSpacing),
		B_CELLS_16x16, 1, "SpaceColorControl",
		new BMessage(kSpaceBarColorChanged));
	fColorControl->SetValue(TrackerSettings().UsedSpaceColor());
	box->AddChild(fColorControl);

	const float spacing = be_control_look->DefaultItemSpacing();

	BGroupLayout* layout = GroupLayout();
	layout->SetOrientation(B_VERTICAL);
	layout->SetSpacing(0);
	BGroupLayoutBuilder(layout)
		.Add(fSpaceBarShowCheckBox)
		.Add(box)
		.AddGlue()
		.SetInsets(spacing, spacing, spacing, spacing);

}
Beispiel #30
0
void
DownloadProgressView::ShowContextMenu(BPoint screenWhere)
{
	screenWhere += BPoint(2, 2);

	BPopUpMenu* contextMenu = new BPopUpMenu("download context");
	BMenuItem* copyURL = new BMenuItem("Copy URL to clipboard",
		new BMessage(COPY_URL_TO_CLIPBOARD));
	copyURL->SetEnabled(fURL.Length() > 0);
	contextMenu->AddItem(copyURL);
	BMenuItem* openFolder = new BMenuItem("Open containing folder",
		new BMessage(OPEN_CONTAINING_FOLDER));
	contextMenu->AddItem(openFolder);

	contextMenu->SetTargetForItems(this);
	contextMenu->Go(screenWhere, true, true, true);
}