Example #1
0
void
TemplateWindow::MessageReceived(BMessage* message)
{
	switch (message->what) {
		case M_NAME_CHANGED:
		case M_TARGET_CHANGED:
		{
			if (fNameBox->Text() && strlen(fNameBox->Text()) > 0 &&
				fTargetBox->Text() && strlen(fTargetBox->Text()) > 0)
				fCreateProjectButton->SetEnabled(true);
			else
				fCreateProjectButton->SetEnabled(false);
			break;
		}

		case M_CREATE_PROJECT:
		{
			BMenu* menu = fTemplateField->Menu();
			BMenuItem* item = menu->FindMarked();
			if (item == NULL)
				break;

			int32 selection = menu->IndexOf(item);
			ProjectTemplate* ptemp = fTempList.TemplateAt(selection);

			BMessage projectMessage(M_CREATE_PROJECT), reply;
			projectMessage.AddString("name", fNameBox->Text());
			projectMessage.AddString("target", fTargetBox->Text());
			projectMessage.AddInt32("type", ptemp->TargetType());
			projectMessage.AddString("path", fPathBox->Path());
			projectMessage.AddString("template", ptemp->GetRef().name);
			projectMessage.AddString("pldfile", ptemp->ProjectFileName());

			BMenu* scmMenu = fSCMChooser->Menu();
			int32 scm = scmMenu->IndexOf(scmMenu->FindMarked());
			projectMessage.AddInt32("scmtype",scm);

			if (!ptemp->ProjectFileName()) {
				for (int32 i = 0; i < ptemp->CountFiles(); i++)
					projectMessage.AddRef("refs", ptemp->FileAt(i));

				for (int32 i = 0; i < ptemp->CountLibs(); i++)
					projectMessage.AddRef("libs", ptemp->LibAt(i));
			}

			if (!BEntry(PROJECT_PATH).Exists())
				create_directory(PROJECT_PATH, 0755);

			projectMessage.AddBool("createfolder", (fCreateFolder->Value() == B_CONTROL_ON));
			be_app_messenger.SendMessage(&projectMessage, &reply);
			PostMessage(B_QUIT_REQUESTED);
			break;
		}

		default:
			BWindow::MessageReceived(message);
	}
}
Example #2
0
void
AppearancePrefView::AttachedToWindow()
{
	fTabTitle->SetTarget(this);
	fWindowTitle->SetTarget(this);
	fBlinkCursor->SetTarget(this);
	fWarnOnExit->SetTarget(this);

	fFontField->Menu()->SetTargetForItems(this);
	for (int32 i = 0; i < fFontField->Menu()->CountItems(); i++) {
		BMenu* fontSizeMenu = fFontField->Menu()->SubmenuAt(i);
		if (fontSizeMenu == NULL)
			continue;

		fontSizeMenu->SetTargetForItems(this);
	}

	fColorControl->SetTarget(this);
	fColorField->Menu()->SetTargetForItems(this);
	fColorSchemeField->Menu()->SetTargetForItems(this);

	_SetCurrentColorScheme();
}
Example #3
0
void
AppearancePrefView::_MarkSelectedFont(const char* family, const char* style,
	const char* size)
{
	char fontMenuLabel[134];
	snprintf(fontMenuLabel, sizeof(fontMenuLabel), "%s - %s", family, style);

	// mark the selected font
	BMenuItem* selectedFont = fFontField->Menu()->FindItem(fontMenuLabel);
	if (selectedFont != NULL)
		selectedFont->SetMarked(true);

	// mark the selected font size on all font menus
	for (int32 i = 0; i < fFontField->Menu()->CountItems(); i++) {
		BMenu* fontSizeMenu = fFontField->Menu()->SubmenuAt(i);
		if (fontSizeMenu == NULL)
			continue;

		BMenuItem* item = fontSizeMenu->FindItem(size);
		if (item != NULL)
			item->SetMarked(true);
	}
}
Example #4
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);
	}
}
Example #5
0
void
MainWindow::_BuildMenu(BMenuBar* menuBar)
{
	BMenu* menu = new BMenu(B_TRANSLATE("Tools"));
	menu->AddItem(new BMenuItem(B_TRANSLATE("Refresh depots"),
			new BMessage(MSG_REFRESH_DEPOTS)));

	menuBar->AddItem(menu);

	menu = new BMenu(B_TRANSLATE("Show"));

	fShowFeaturedPackagesItem = new BMenuItem(
		B_TRANSLATE("Only featured packages"),
		new BMessage(MSG_SHOW_FEATURED_PACKAGES));
	menu->AddItem(fShowFeaturedPackagesItem);

	menu->AddSeparatorItem();

	fShowAvailablePackagesItem = new BMenuItem(
		B_TRANSLATE("Available packages"),
		new BMessage(MSG_SHOW_AVAILABLE_PACKAGES));
	menu->AddItem(fShowAvailablePackagesItem);

	fShowInstalledPackagesItem = new BMenuItem(
		B_TRANSLATE("Installed packages"),
		new BMessage(MSG_SHOW_INSTALLED_PACKAGES));
	menu->AddItem(fShowInstalledPackagesItem);

	menu->AddSeparatorItem();

	fShowDevelopPackagesItem = new BMenuItem(
		B_TRANSLATE("Develop packages"),
		new BMessage(MSG_SHOW_DEVELOP_PACKAGES));
	menu->AddItem(fShowDevelopPackagesItem);

	fShowSourcePackagesItem = new BMenuItem(
		B_TRANSLATE("Source packages"),
		new BMessage(MSG_SHOW_SOURCE_PACKAGES));
	menu->AddItem(fShowSourcePackagesItem);

	menuBar->AddItem(menu);
}
Example #6
0
void SeqStudioWindow::MenusBeginning()
{
	inherited::MenusBeginning();
	BMenuBar*			bar = KeyMenuBar();
	if (!bar) return;
	BColumnListView*	table = dynamic_cast<BColumnListView*>( FindView(ENDPOINT_LIST_STR) );
	if (!table) return;

	if (mDeviceCtrl && mDeviceCtrl->Menu() ) add_device_menu_items(mDeviceCtrl->Menu() );

	// MIDI Port menu
	if (mPortMenu) {
		bool				deleteEnabled = false;
		_EndpointRow*	r = dynamic_cast<_EndpointRow*>(table->CurrentSelection() );
		if (r && !r->mIsValid && r->mEndpoint.channel < 0) deleteEnabled = true;

		BMenuItem*			deleteItem = mPortMenu->FindItem(DELETE_STR);
		if (deleteItem && deleteItem->IsEnabled() != deleteEnabled) deleteItem->SetEnabled(deleteEnabled);
	}

	// Attributes menu
	BMenu*					menu;
	BMenuItem*				item;
	if ( (menu = bar->SubmenuAt(ATTRIBUTES_MENU_INDEX)) != NULL) {
		for (int32 k = 0; (item = menu->ItemAt(k)) != NULL; k++) {
			const char*		n;
			if (item->Message() && item->Message()->FindString(COLUMN_NAME_STR, &n) == B_OK) {
				BColumn*	col = column_named(n, table);
				if (col && col->IsVisible() ) {
					if (!item->IsMarked() ) item->SetMarked(true);
				} else {
					if (item->IsMarked() ) item->SetMarked(false);
				}
			}
		}
	}
}
Example #7
0
// PopulateMenu
void
FontValueView::_PolulateMenu(BMenu* menu, BHandler* target,
							 const char* markedFamily,
							 const char* markedStyle)
{
	if (!menu)
		return;

	FontManager* manager = FontManager::Default();

	if (!manager->Lock())
		return;

	BMenu* fontMenu = NULL;

	font_family family;
	font_style style;

	int32 count = manager->CountFontFiles();
	for (int32 i = 0; i < count; i++) {
		if (!manager->GetFontAt(i, family, style))
			break;

		BMessage* message = new BMessage(MSG_FONT_CHANGED);
		message->AddString("font family", family);
		message->AddString("font style", style);

		FontMenuItem* item = new FontMenuItem(style, family, style,
											  message);
		item->SetTarget(target);

		bool markStyle = false;
		if (!fontMenu
			|| (fontMenu->Name()
				&& strcmp(fontMenu->Name(), family) != 0)) {
			// create new entry
			fontMenu = new BMenu(family);
			fontMenu->AddItem(item);
			menu->AddItem(fontMenu);
			// mark the menu if necessary
			if (markedFamily && strcmp(markedFamily, family) == 0) {
				if (BMenuItem* superItem = fontMenu->Superitem())
					superItem->SetMarked(true);
				markStyle = true;
			}
		} else {
			// reuse old entry
			fontMenu->AddItem(item);
		}
		// mark the item if necessary
		if (markStyle && markedStyle && strcmp(markedStyle, style) == 0)
			item->SetMarked(true);
	}
	
	manager->Unlock();
}
Example #8
0
static ArpMenuField* new_rhythm_menu_field()
{
	BMenu*		menu = new BMenu("motion_menu");
	if (!menu) return NULL;
	BString		label, key;
	for (uint32 k = 0; AmGlobals().GetMotionInfo(k, label, key) == B_OK; k++) {
		BMessage*		msg = new BMessage(MOTION_MSG);
		if (msg) {
			msg->AddString(MOTION_KEY_STR, key);
			BMenuItem*	item = new BMenuItem(label.String(), msg);
			if (!item) delete msg;
			else menu->AddItem(item);
		}
	}

//	menu->SetLabelFromMarked(true);
//	menu->SetRadioMode(true);	
	ArpMenuField*	field = new ArpMenuField("rhythm_field", "Motion:", menu);
	if (!field) {
		delete menu;
		return NULL;
	}
	return field;
}
Example #9
0
BMenuItem* SplitWindow::MakeCatMenu(Cat* cat)
{
	BMenuItem* mi;
	BMessage* msgs = new BMessage(CatPopUpMSG);
	msgs->AddString("text", cat->Name().c_str());
	msgs->AddInt8("num", catnum);
	cas* childcats = cat->SetOfChildren();
	
	if (childcats->empty())
	{
		mi = new BMenuItem(cat->LeafName().c_str(), msgs);
	}
	else
	{
		BMenu* m = new BMenu(cat->LeafName().c_str());
		mi = new BMenuItem(m, msgs);
		for (cas::iterator ci = childcats->begin();	ci != childcats->end(); ci++)
		{
			m->AddItem(MakeCatMenu(*ci));
		}
	}
	
	return mi;
}
void
Renamer_Remove::AttachedToWindow()
{
	BMessage msg;
	ReadPreferences("ren_remove", msg);
	
	BString string = "";
	int32 integer = 0;
	bool boolean = 0;
	if (msg.FindInt32("pos1", &integer) == B_OK)
		fPosition1->SetValue(integer);
	if (msg.FindInt32("pos2", &integer) == B_OK)
		fPosition2->SetValue(integer);
	if (msg.FindBool("direction1", &boolean) == B_OK) {
		BMenu* menu = fDirection1->Menu();
		for (int i = 0; i < 2; ++i)
			menu->ItemAt(i)->SetMarked(i == (int)boolean);
	}
	if (msg.FindBool("direction2", &boolean) == B_OK) {
		BMenu* menu = fDirection2->Menu();
		for (int i = 0; i < 2; ++i)
			menu->ItemAt(i)->SetMarked(i == (int)boolean);
	}
}
OpenGLView::OpenGLView()
	:
	BGroupView("OpenGLView", B_VERTICAL)
{

	BGLView* glView = new BGLView(BRect(0, 0, 1, 1), "gl info", B_FOLLOW_NONE, 0,
		BGL_RGB | BGL_DOUBLE);
	glView->Hide();
	AddChild(glView);

	glView->LockGL();

    BMenu* menu = new BMenu(B_TRANSLATE("Automatic"));
    menu->SetRadioMode(true);
    menu->SetLabelFromMarked(true);
    menu->AddItem(new BMenuItem(B_TRANSLATE("Automatic"),
        new BMessage(MENU_AUTO_MESSAGE)));
    menu->AddSeparatorItem();
    menu->AddItem(new BMenuItem(B_TRANSLATE("Software Rasterizer"),
        new BMessage(MENU_SWRAST_MESSAGE)));
    menu->AddItem(new BMenuItem(B_TRANSLATE("Gallium Software Pipe"),
        new BMessage(MENU_SWPIPE_MESSAGE)));
    menu->AddItem(new BMenuItem(B_TRANSLATE("Gallium LLVM Pipe"),
        new BMessage(MENU_SWLLVM_MESSAGE)));
    BMenuField* menuField = new BMenuField("renderer",
        B_TRANSLATE("3D Rendering Engine:"), menu);
	// TODO:  Set current Renderer
	menuField->SetEnabled(false);

	BTabView *tabView = new BTabView("tab view", B_WIDTH_FROM_LABEL);
	tabView->AddTab(new InfoView());
	tabView->AddTab(new CapabilitiesView());
	tabView->AddTab(new ExtensionsView());

	glView->UnlockGL();

	GroupLayout()->SetSpacing(0);
	BLayoutBuilder::Group<>(this)
		.SetInsets(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING,
			B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING)
		.Add(menuField)
		.AddGroup(B_HORIZONTAL)
			.Add(tabView)
			.SetInsets(0, B_USE_DEFAULT_SPACING, 0, 0);
}
Example #12
0
BMenuBar*
KeymapWindow::_CreateMenu()
{
	BMenuBar* menuBar = new BMenuBar(Bounds(), "menubar");

	// Create the File menu
	BMenu* menu = new BMenu(B_TRANSLATE("File"));
	menu->AddItem(new BMenuItem(B_TRANSLATE("Open" B_UTF8_ELLIPSIS),
		new BMessage(kMsgMenuFileOpen), 'O'));
	menu->AddItem(new BMenuItem(B_TRANSLATE("Save as" B_UTF8_ELLIPSIS),
		new BMessage(kMsgMenuFileSaveAs)));
	menu->AddSeparatorItem();
	menu->AddItem(new BMenuItem(
		B_TRANSLATE("Set modifier keys" B_UTF8_ELLIPSIS),
		new BMessage(kMsgShowModifierKeysWindow)));
	menu->AddSeparatorItem();
	menu->AddItem(new BMenuItem(B_TRANSLATE("Quit"),
		new BMessage(B_QUIT_REQUESTED), 'Q'));
	menuBar->AddItem(menu);

	// Create keyboard layout menu
	fLayoutMenu = new BMenu(B_TRANSLATE("Layout"));
	_AddKeyboardLayouts(fLayoutMenu);
	menuBar->AddItem(fLayoutMenu);

	// Create the Font menu
	fFontMenu = new BMenu(B_TRANSLATE("Font"));
	fFontMenu->SetRadioMode(true);
	int32 numFamilies = count_font_families();
	font_family family, currentFamily;
	font_style currentStyle;
	uint32 flags;

	be_plain_font->GetFamilyAndStyle(&currentFamily, &currentStyle);

	for (int32 i = 0; i < numFamilies; i++) {
		if (get_font_family(i, &family, &flags) == B_OK) {
			BMenuItem *item =
				new BMenuItem(family, new BMessage(kMsgMenuFontChanged));
			fFontMenu->AddItem(item);

			if (!strcmp(family, currentFamily))
				item->SetMarked(true);
		}
	}
	menuBar->AddItem(fFontMenu);

	return menuBar;
}
Example #13
0
void TCueSheetWindow::AdjustEditMenu()
{

	BMenu* theMenu = fAppMenu->GetEditMenu();
	if (theMenu) {
		//      Undo Item
		BMenuItem* undoItem = theMenu->FindItem(EDIT_UNDO_MSG);
		if (undoItem) {
			if (fUndoEngine->CanUndo())
				undoItem->SetEnabled(true);
			else
				undoItem->SetEnabled(false);
		}

		// Cut
		// Enable if any items are selected
		BMenuItem* cutItem = theMenu->FindItem(EDIT_CUT_MSG);
		if (cutItem)
			cutItem->SetEnabled( fCueSheetView->ItemsSelected() );

		// Copy
		// Enable if any items are selected
		BMenuItem* copyItem = theMenu->FindItem(EDIT_COPY_MSG);
		if (copyItem)
			copyItem->SetEnabled( fCueSheetView->ItemsSelected() );

		// Paste
		// Enable if there is anything on the clipboard
		BMenuItem* pasteItem = theMenu->FindItem(EDIT_PASTE_MSG);
		if (pasteItem)
			pasteItem->SetEnabled( static_cast<MuseumApp*>(be_app)->fClipboard->HasData() );

		// Clear
		BMenuItem* clearItem = theMenu->FindItem(EDIT_CLEAR_MSG);
		if (clearItem)
			clearItem->SetEnabled( fCueSheetView->ItemsSelected() );

		// Select All
		// Enable if there is anything to be selected
		BMenuItem* selectAllItem = theMenu->FindItem(EDIT_SELECTALL_MSG);
		if (selectAllItem) {
			// Enable this item if there are any cues to be selected
			selectAllItem->SetEnabled( fCueSheetView->HasCues() );
		}
	}
}
Example #14
0
void BitmapMenuItem::Draw(void)
{
	BMenu* menu = Menu();
	if (menu) {
		BRect itemFrame = Frame();
		BRect bitmapFrame = itemFrame;
		bitmapFrame.InsetBy(2, 2); // account for 2-pixel margin
		
		menu->SetDrawingMode(B_OP_COPY);
		menu->SetHighColor(BKG_GREY);
		menu->FillRect(itemFrame);
		menu->DrawBitmap(&m_bitmap, bitmapFrame);
		
		if (IsSelected()) {
			// a nonstandard but simple way to draw highlights
			menu->SetDrawingMode(B_OP_INVERT);
			menu->SetHighColor(0,0,0);
			menu->FillRect(itemFrame);
		}
	}
}
Example #15
0
void
BSeparatorItem::Draw()
{
	BMenu *menu = Menu();
	if (menu == NULL)
		return;

	BRect bounds = Frame();
	rgb_color oldColor = menu->HighColor();
	rgb_color lowColor = menu->LowColor();

	const float startTop = bounds.top + (floor(bounds.Height())) / 2;
	menu->SetHighColor(tint_color(lowColor, B_DARKEN_1_TINT));
	menu->StrokeLine(BPoint(bounds.left + 1.0f, startTop),
		BPoint(bounds.right - 1.0f, startTop));
	menu->SetHighColor(tint_color(lowColor, B_LIGHTEN_2_TINT));
	menu->StrokeLine(BPoint(bounds.left + 1.0f, startTop + 1.0f),
		BPoint(bounds.right - 1.0f, startTop + 1.0f));

	menu->SetHighColor(oldColor);
}
Example #16
0
bool
SourceVisitor::Visit(BPartition *partition, int32 level)
{
	BPath path;
	if (partition->GetPath(&path) == B_OK)
		printf("SourceVisitor::Visit(BPartition *) : %s\n", path.Path());
	printf("SourceVisitor::Visit(BPartition *) : %s\n",
		partition->ContentName());

	if (partition->ContentType() == NULL)
		return false;

	bool isBootPartition = false;
	if (partition->IsMounted()) {
		BPath mountPoint;
		partition->GetMountPoint(&mountPoint);
		isBootPartition = strcmp(BOOT_PATH, mountPoint.Path()) == 0;
	}

	if (!isBootPartition
		&& strcmp(partition->ContentType(), kPartitionTypeBFS) != 0) {
		// Except only BFS partitions, except this is the boot partition
		// (ISO9660 with write overlay for example).
		return false;
	}

	// TODO: We could probably check if this volume contains
	// the Haiku kernel or something. Does it make sense to "install"
	// from your BFS volume containing the music collection?
	// TODO: Then the check for BFS could also be removed above.

	char label[255];
	char menuLabel[255];
	make_partition_label(partition, label, menuLabel, false);
	PartitionMenuItem* item = new PartitionMenuItem(partition->ContentName(),
		label, menuLabel, new BMessage(SOURCE_PARTITION), partition->ID());
	item->SetMarked(isBootPartition);
	fMenu->AddItem(item);
	return false;
}
Example #17
0
void ArpMenuField::copy_attrs(BMenu* menu)
{
	if( !menu ) return;
	int32 num = menu->CountItems();
	for( int32 i=0; i<num; i++ ) {
		BMenu* child = menu->SubmenuAt(i);
		if( child ) {
			copy_attrs(child);
			// the menu doesn't seem to see this.
			child->SetFont(&PV_MenuFont);
			child->SetHighColor(PV_MenuForeColor);
			child->SetLowColor(PV_MenuBackColor);
			child->SetViewColor(PV_MenuBackColor);
			child->InvalidateLayout();
		}
	}
}
Example #18
0
BMenu*
CharacterWindow::_CreateFontMenu()
{
	BMenu* menu = new BMenu(B_TRANSLATE("Font"));
	BMenuItem* item;

	font_family currentFamily;
	font_style currentStyle;
	fCharacterView->CharacterFont().GetFamilyAndStyle(&currentFamily,
		&currentStyle);

	int32 numFamilies = count_font_families();

	menu->SetRadioMode(true);

	for (int32 i = 0; i < numFamilies; i++) {
		font_family family;
		if (get_font_family(i, &family) == B_OK) {
			BMenu* subMenu = new BMenu(family);
			menu->AddItem(new BMenuItem(subMenu,
				new BMessage(kMsgFontSelected)));

			int numStyles = count_font_styles(family);
			for (int32 j = 0; j < numStyles; j++) {
				font_style style;
				uint32 flags;
				if (get_font_style(family, j, &style, &flags) == B_OK) {
					item = new BMenuItem(style, new BMessage(kMsgFontSelected));
					subMenu->AddItem(item);

					if (!strcmp(family, currentFamily)
						&& !strcmp(style, currentStyle)) {
						fSelectedFontItem = item;
						item->SetMarked(true);
					}
				}
			}
		}
	}

	item = menu->FindItem(currentFamily);
	item->SetMarked(true);

	return menu;
}
Example #19
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);
}
Example #20
0
MainWindow::MainWindow(BRect frame)
	:
	BWindow(frame, B_TRANSLATE_SYSTEM_NAME("PecoRename"),
		B_TITLED_WINDOW, B_AUTO_UPDATE_SIZE_LIMITS) {

	BMenuBar* MenuBar = new BMenuBar("MenuBar");
	BMenu* Menu;

	Menu = new BMenu(B_TRANSLATE("File"));
	MenuBar->AddItem(Menu);
//	Maybe in the future...Multi directories support
//	Menu->AddItem(new BMenuItem(B_TRANSLATE("New"),
//		new BMessage(MSG_MENU_NEW), 'N'));

	Menu->AddItem(new BMenuItem(B_TRANSLATE("Select files" B_UTF8_ELLIPSIS),
		new BMessage(MSG_SELECT_FILES), 'O'));
	Menu->AddSeparatorItem();

	Menu->AddItem(new BMenuItem(B_TRANSLATE("Show documentation"),
	new BMessage(MSG_MENU_DOCU)));

	Menu->AddItem(new BMenuItem(B_TRANSLATE("About PecoRename"),
		new BMessage(B_ABOUT_REQUESTED)));

//	Menu = new BMenu(B_TRANSLATE("Help"));
//	MenuBar->AddItem(Menu);

	Menu->AddSeparatorItem();
	Menu->AddItem(new BMenuItem(B_TRANSLATE("Quit"),
		new BMessage(B_QUIT_REQUESTED), 'Q'));

	MainView* mainView = new MainView();

	BLayoutBuilder::Group<>(this, B_VERTICAL, 0)
		.Add(MenuBar)
		.Add(mainView);
}
static BMenuField* new_color_field(BRect f)
{
	BMenu*		menu = new BMenu("colors_menu");
	if (!menu) return NULL;
	BMenuItem*	item = new BMenuItem(BACKGROUND_STR, new BMessage(BACKGROUND_C_MSG));
	if (item) menu->AddItem(item);
	item = new BMenuItem(FOREGROUND_STR, new BMessage(FOREGROUND_C_MSG));
	if (item) menu->AddItem(item);
	
	item = menu->ItemAt(0);
	if (item) item->SetMarked(true);

	menu->SetLabelFromMarked(true);
	menu->SetRadioMode(true);	
	BMenuField*	field = new BMenuField(f, "colors_field", "Color:", menu, B_FOLLOW_LEFT | B_FOLLOW_TOP);
	if (!field) {
		delete menu;
		return NULL;
	}
	return field;
}
Example #22
0
BMenu*
TPrefsWindow::_BuildReplyPreambleMenu()
{
	BMenu *menu = new BMenu(B_EMPTY_STRING);

	menu->AddItem(new BMenuItem(B_TRANSLATE("%n - Full name"),
		new BMessage(P_REPLY_PREAMBLE)));

	menu->AddItem(new BMenuItem(B_TRANSLATE("%e - E-mail address"),
		new BMessage(P_REPLY_PREAMBLE)));

	menu->AddItem(new BMenuItem(B_TRANSLATE("%d - Date"),
		new BMessage(P_REPLY_PREAMBLE)));

	menu->AddSeparatorItem();

	menu->AddItem(new BMenuItem(B_TRANSLATE("\\n - Newline"),
		new BMessage(P_REPLY_PREAMBLE)));

	return menu;
}
Example #23
0
void
MemoryBarMenuItem::DrawIcon()
{
	// TODO: exact code duplication with TeamBarMenuItem::DrawIcon()
	if (!fIcon)
		return;

	BPoint loc = ContentLocation();
	BRect frame = Frame();

	loc.y = frame.top + (frame.bottom - frame.top - 15) / 2;

	BMenu* menu = Menu();

	if (fIcon->ColorSpace() == B_RGBA32) {
		menu->SetDrawingMode(B_OP_ALPHA);
		menu->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY);
	} else
		menu->SetDrawingMode(B_OP_OVER);

	menu->DrawBitmap(fIcon, loc);

	menu->SetDrawingMode(B_OP_COPY);
}
Example #24
0
void
TTeamMenuItem::DrawContent()
{
	BMenu* menu = Menu();
	if (fIcon != NULL) {
		if (fIcon->ColorSpace() == B_RGBA32) {
			menu->SetDrawingMode(B_OP_ALPHA);
			menu->SetBlendingMode(B_PIXEL_ALPHA, B_ALPHA_OVERLAY);
		} else
			menu->SetDrawingMode(B_OP_OVER);

		BRect frame(Frame());
		BRect iconBounds(fIcon->Bounds());
		BRect dstRect(iconBounds);
		float extra = fVertical ? 0.0f : -1.0f;
		BPoint contLoc = ContentLocation();
		BPoint drawLoc = contLoc + BPoint(kHPad, kVPad);

		if (!fDrawLabel || (fVertical && iconBounds.Width() > 32)) {
			float offsetx = contLoc.x
				+ ((frame.Width() - iconBounds.Width()) / 2) + extra;
			float offsety = contLoc.y + 3.0f + extra;

			dstRect.OffsetTo(BPoint(offsetx, offsety));
			menu->DrawBitmapAsync(fIcon, dstRect);

			drawLoc.x = ((frame.Width() - LabelWidth()) / 2);
			drawLoc.y = frame.top + iconBounds.Height() + 4.0f;
		} else {
			float offsetx = contLoc.x + kHPad;
			float offsety = contLoc.y + 
				((frame.Height() - iconBounds.Height()) / 2) + extra;

			dstRect.OffsetTo(BPoint(offsetx, offsety));
			menu->DrawBitmapAsync(fIcon, dstRect);

			float labelHeight = fLabelAscent + fLabelDescent;
			drawLoc.x += iconBounds.Width() + kLabelOffset;
			drawLoc.y = frame.top + ((frame.Height() - labelHeight) / 2) + extra;
		}

		menu->MovePenTo(drawLoc);
	}

	// set the pen to black so that either method will draw in the same color
	// low color is set in inherited::DrawContent, override makes sure its
	// what we want
	if (fDrawLabel) {
		menu->SetDrawingMode(B_OP_OVER);
		menu->SetHighColor(ui_color(B_MENU_ITEM_TEXT_COLOR));

		// override the drawing of the content when the item is disabled
		// the wrong lowcolor is used when the item is disabled since the
		// text color does not change
		DrawContentLabel();
	}

	// Draw the expandable icon.
	TBarView* barView = (static_cast<TBarApp*>(be_app))->BarView();
	if (fVertical && static_cast<TBarApp*>(be_app)->Settings()->superExpando
		&& barView->ExpandoState()) {
		BRect frame(Frame());
		BRect rect(0, 0, kSwitchWidth, 10);
		rect.OffsetTo(BPoint(frame.right - rect.Width(),
			ContentLocation().y + ((frame.Height() - rect.Height()) / 2)));

		if (be_control_look != NULL) {
			uint32 arrowDirection = fExpanded
				? BControlLook::B_UP_ARROW : BControlLook::B_DOWN_ARROW;
			be_control_look->DrawArrowShape(menu, rect, rect, menu->LowColor(),
				arrowDirection, 0, B_DARKEN_3_TINT);
		} else {
			rgb_color outlineColor = {80, 80, 80, 255};
			rgb_color middleColor = {200, 200, 200, 255};

			menu->SetDrawingMode(B_OP_OVER);

			if (!fExpanded) {
				menu->BeginLineArray(6);

				menu->AddLine(BPoint(rect.left + 3, rect.top + 1),
					BPoint(rect.left + 3, rect.bottom - 1), outlineColor);
				menu->AddLine(BPoint(rect.left + 3, rect.top + 1),
					BPoint(rect.left + 7, rect.top + 5), outlineColor);
				menu->AddLine(BPoint(rect.left + 7, rect.top + 5),
					BPoint(rect.left + 3, rect.bottom - 1), outlineColor);

				menu->AddLine(BPoint(rect.left + 4, rect.top + 3),
					BPoint(rect.left + 4, rect.bottom - 3), middleColor);
				menu->AddLine(BPoint(rect.left + 5, rect.top + 4),
					BPoint(rect.left + 5, rect.bottom - 4), middleColor);
				menu->AddLine(BPoint(rect.left + 5, rect.top + 5),
					BPoint(rect.left + 6, rect.top + 5), middleColor);
				menu->EndLineArray();
			} else {
				// expanded state

				menu->BeginLineArray(6);
				menu->AddLine(BPoint(rect.left + 1, rect.top + 3),
					BPoint(rect.right - 3, rect.top + 3), outlineColor);
				menu->AddLine(BPoint(rect.left + 1, rect.top + 3),
					BPoint(rect.left + 5, rect.top + 7), outlineColor);
				menu->AddLine(BPoint(rect.left + 5, rect.top + 7),
					BPoint(rect.right - 3, rect.top + 3), outlineColor);

				menu->AddLine(BPoint(rect.left + 3, rect.top + 4),
					BPoint(rect.right - 5, rect.top + 4), middleColor);
				menu->AddLine(BPoint(rect.left + 4, rect.top + 5),
					BPoint(rect.right - 6, rect.top + 5), middleColor);
				menu->AddLine(BPoint(rect.left + 5, rect.top + 5),
					BPoint(rect.left + 5, rect.top + 6), middleColor);
				menu->EndLineArray();
			}
		}
	}
}
Example #25
0
void
TTeamMenuItem::DrawContentLabel()
{
	BMenu* menu = Menu();
	menu->MovePenBy(0, fLabelAscent);

	float cachedWidth = menu->StringWidth(Label());
	if (Submenu() && fVertical)
		cachedWidth += 18;

	const char* label = Label();
	char* truncLabel = NULL;
	float max = 0;

	if (fVertical && static_cast<TBarApp*>(be_app)->Settings()->superExpando)
		max = menu->MaxContentWidth() - kSwitchWidth;
	else
		max = menu->MaxContentWidth() - 4.0f;

	if (max > 0) {
		BPoint penloc = menu->PenLocation();
		BRect frame = Frame();
		float offset = penloc.x - frame.left;
		if (cachedWidth + offset > max) {
			truncLabel = (char*)malloc(strlen(label) + 4);
			if (!truncLabel)
				return;
			TruncateLabel(max-offset, truncLabel);
			label = truncLabel;
		}
	}

	if (!label)
		label = Label();

	TBarView* barview = (static_cast<TBarApp*>(be_app))->BarView();
	bool canHandle = !barview->Dragging()
		|| barview->AppCanHandleTypes(Signature());
	if (_IsSelected() && IsEnabled() && canHandle)
		menu->SetLowColor(tint_color(menu->LowColor(),
			B_HIGHLIGHT_BACKGROUND_TINT));
	else
		menu->SetLowColor(menu->LowColor());

	menu->DrawString(label);

	free(truncLabel);
}
Example #26
0
void
TTeamMenuItem::Draw()
{
	BRect frame(Frame());
	BMenu* menu = Menu();
	menu->PushState();
	rgb_color menuColor = menu->LowColor();
	TBarView* barView = (static_cast<TBarApp*>(be_app))->BarView();

	bool canHandle = !barView->Dragging()
		|| barView->AppCanHandleTypes(Signature());

	if (be_control_look != NULL) {
		uint32 flags = 0;
		if (_IsSelected() && canHandle)
			flags |= BControlLook::B_ACTIVATED;

		uint32 borders = BControlLook::B_TOP_BORDER;
		if (fVertical) {
			menu->SetHighColor(tint_color(menuColor, B_DARKEN_1_TINT));
			borders |= BControlLook::B_LEFT_BORDER
				| BControlLook::B_RIGHT_BORDER;
			menu->StrokeLine(frame.LeftBottom(), frame.RightBottom());
			frame.bottom--;

			be_control_look->DrawMenuBarBackground(menu, frame, frame,
				menuColor, flags, borders);
		} else {
			if (flags & BControlLook::B_ACTIVATED)
				menu->SetHighColor(tint_color(menuColor, B_DARKEN_3_TINT));
			else
				menu->SetHighColor(tint_color(menuColor, 1.22));
			borders |= BControlLook::B_BOTTOM_BORDER;
			menu->StrokeLine(frame.LeftTop(), frame.LeftBottom());
			frame.left++;

			be_control_look->DrawButtonBackground(menu, frame, frame,
				menuColor, flags, borders);
		}

		menu->MovePenTo(ContentLocation());
		DrawContent();
		menu->PopState();
		return;
	}

	// if not selected or being tracked on, fill with gray
	if ((!_IsSelected() && !menu->IsRedrawAfterSticky()) || !canHandle
		|| !IsEnabled()) {
		frame.InsetBy(1, 1);
		menu->SetHighColor(menuColor);
		menu->FillRect(frame);
	}

	// draw the gray, unselected item, border
	if (!_IsSelected() || !IsEnabled()) {
		rgb_color shadow = tint_color(menuColor, B_DARKEN_1_TINT);
		rgb_color light = tint_color(menuColor, B_LIGHTEN_2_TINT);

		frame = Frame();

		menu->SetHighColor(shadow);
		if (fVertical)
			menu->StrokeLine(frame.LeftBottom(), frame.RightBottom());
		else
			menu->StrokeLine(frame.LeftBottom() + BPoint(1, 0),
				frame.RightBottom());

		menu->StrokeLine(frame.RightBottom(), frame.RightTop());

		menu->SetHighColor(light);
		menu->StrokeLine(frame.RightTop() + BPoint(-1, 0), frame.LeftTop());
		if (fVertical)
			menu->StrokeLine(frame.LeftTop(), frame.LeftBottom()
				+ BPoint(0, -1));
		else
			menu->StrokeLine(frame.LeftTop(), frame.LeftBottom());
	}

	// if selected or being tracked on, fill with the hilite gray color
	if (IsEnabled() && _IsSelected() && !menu->IsRedrawAfterSticky()
		&& canHandle) {
		// fill
		menu->SetHighColor(tint_color(menuColor, B_HIGHLIGHT_BACKGROUND_TINT));
		menu->FillRect(frame);

		// these continue the dark grey border on the left or top edge
		menu->SetHighColor(tint_color(menuColor, B_DARKEN_4_TINT));
		if (fVertical) {
			// dark line at top
			menu->StrokeLine(frame.LeftTop(), frame.RightTop());
		} else {
			// dark line on the left
			menu->StrokeLine(frame.LeftTop(), frame.LeftBottom());
		}
	} else
		menu->SetLowColor(menuColor);

	menu->MovePenTo(ContentLocation());
	DrawContent();
	menu->PopState();
}
Example #27
0
BPopUpMenu*
DeskbarView::_BuildMenu()
{
	BPopUpMenu* menu = new BPopUpMenu(B_EMPTY_STRING, false, false);
	menu->SetFont(be_plain_font);

	menu->AddItem(new BMenuItem(MDR_DIALECT_CHOICE (
		"Create new message", "N) 新規メッセージ作成")B_UTF8_ELLIPSIS,
		new BMessage(MD_OPEN_NEW)));
	menu->AddSeparatorItem();

	BMessenger tracker(kTrackerSignature);
	BNavMenu* navMenu;
	BMenuItem* item;
	BMessage* msg;
	entry_ref ref;

	BPath path;
	find_directory(B_USER_SETTINGS_DIRECTORY, &path);
	path.Append("Mail/Menu Links");

	BDirectory directory;
	if (_CreateMenuLinks(directory, path)) {
		int32 count = 0;

		while (directory.GetNextRef(&ref) == B_OK) {
			count++;

			path.SetTo(&ref);
			// the true here dereferences the symlinks all the way :)
			BEntry entry(&ref, true);

			// do we want to use the NavMenu, or just an ordinary BMenuItem?
			// we are using the NavMenu only for directories and queries
			bool useNavMenu = false;

			if (entry.InitCheck() == B_OK) {
				if (entry.IsDirectory())
					useNavMenu = true;
				else if (entry.IsFile()) {
					// Files should use the BMenuItem unless they are queries
					char mimeString[B_MIME_TYPE_LENGTH];
					BNode node(&entry);
					BNodeInfo info(&node);
					if (info.GetType(mimeString) == B_OK
						&& strcmp(mimeString, "application/x-vnd.Be-query")
							== 0)
						useNavMenu = true;
				}
				// clobber the existing ref only if the symlink derefernces
				// completely, otherwise we'll stick with what we have
				entry.GetRef(&ref);
			}

			msg = new BMessage(B_REFS_RECEIVED);
			msg->AddRef("refs", &ref);

			if (useNavMenu) {
				item = new BMenuItem(navMenu = new BNavMenu(path.Leaf(),
					B_REFS_RECEIVED, tracker), msg);
				navMenu->SetNavDir(&ref);
			} else
				item = new BMenuItem(path.Leaf(), msg);

			menu->AddItem(item);
			if(entry.InitCheck() != B_OK)
				item->SetEnabled(false);
		}
		if (count > 0)
			menu->AddSeparatorItem();
	}

	// Hack for R5's buggy Query Notification
	#ifdef HAIKU_TARGET_PLATFORM_BEOS
		menu->AddItem(new BMenuItem(
			MDR_DIALECT_CHOICE("Refresh New Mail Count",
				"未読メールカウントを更新"),
			new BMessage(MD_REFRESH_QUERY)));
	#endif

	// The New E-mail query

	if (fNewMessages > 0) {
		BString string;
		MDR_DIALECT_CHOICE(
			string << fNewMessages << " new message"
				<< (fNewMessages != 1 ? "s" : B_EMPTY_STRING),
			string << fNewMessages << " 通の未読メッセージ");

		_GetNewQueryRef(ref);

		item = new BMenuItem(navMenu = new BNavMenu(string.String(),
			B_REFS_RECEIVED, BMessenger(kTrackerSignature)),
			msg = new BMessage(B_REFS_RECEIVED));
		msg->AddRef("refs", &ref);
		navMenu->SetNavDir(&ref);

		menu->AddItem(item);
	} else {
		menu->AddItem(item = new BMenuItem(
			MDR_DIALECT_CHOICE ("No new messages","未読メッセージなし"), NULL));
		item->SetEnabled(false);
	}

	BMailAccounts accounts;
	if (modifiers() & B_SHIFT_KEY) {
		BMenu *accountMenu = new BMenu(
			MDR_DIALECT_CHOICE ("Check for mails only","R) メール受信のみ"));
		BFont font;
		menu->GetFont(&font);
		accountMenu->SetFont(&font);

		for (int32 i = 0; i < accounts.CountAccounts(); i++) {
			BMailAccountSettings* account = accounts.AccountAt(i);

			BMessage* message = new BMessage(MD_CHECK_FOR_MAILS);
			message->AddInt32("account", account->AccountID());

			accountMenu->AddItem(new BMenuItem(account->Name(), message));
		}
		if (accounts.CountAccounts() == 0) {
			item = new BMenuItem("<no accounts>", NULL);
			item->SetEnabled(false);
			accountMenu->AddItem(item);
		}
		accountMenu->SetTargetForItems(this);
		menu->AddItem(new BMenuItem(accountMenu,
			new BMessage(MD_CHECK_FOR_MAILS)));

		// Not used:
		// menu->AddItem(new BMenuItem(MDR_DIALECT_CHOICE (
		// "Check For Mails Only","メール受信のみ"), new BMessage(MD_CHECK_FOR_MAILS)));
		menu->AddItem(new BMenuItem(
			MDR_DIALECT_CHOICE ("Send pending mails", "M) 保留メールを送信"),
		new BMessage(MD_SEND_MAILS)));
	} else {
		menu->AddItem(item = new BMenuItem(
			MDR_DIALECT_CHOICE ("Check for mail now", "C) メールチェック"),
			new BMessage(MD_CHECK_SEND_NOW)));
		if (accounts.CountAccounts() == 0)
			item->SetEnabled(false);
	}

	menu->AddSeparatorItem();
	menu->AddItem(new BMenuItem(
		MDR_DIALECT_CHOICE ("Preferences", "P) メール環境設定") B_UTF8_ELLIPSIS,
		new BMessage(MD_OPEN_PREFS)));

	if (modifiers() & B_SHIFT_KEY) {
		menu->AddItem(new BMenuItem(
			MDR_DIALECT_CHOICE ("Shutdown mail services", "Q) 終了"),
			new BMessage(B_QUIT_REQUESTED)));
	}

	// Reset Item Targets (only those which aren't already set)

	for (int32 i = menu->CountItems(); i-- > 0;) {
		item = menu->ItemAt(i);
		if (item && (msg = item->Message()) != NULL) {
			if (msg->what == B_REFS_RECEIVED)
				item->SetTarget(tracker);
			else
				item->SetTarget(this);
		}
	}
	return menu;
}
Example #28
0
void TCueSheetWindow::AdjustCueSheetMenu()
{

	BMenu* theMenu = fAppMenu->GetCueSheetMenu();
	if (theMenu) {
		//      Setup Item
		BMenuItem* setupItem = theMenu->FindItem(CUE_SETUP_MSG);
		if (setupItem)
			;

		//      Time Base Item
		BMenuItem* timeBaseItem = theMenu->FindItem(CUE_TIMEBASE_MSG);
		if (timeBaseItem)
			;

		//      Zoom In Item
		BMenuItem* zoomInItem = theMenu->FindItem(CUE_ZOOMIN_MSG);
		if (zoomInItem)
			;

		//      Zoom Out Item
		BMenuItem* zoomOutItem = theMenu->FindItem(CUE_ZOOMOUT_MSG);
		if (zoomOutItem)
			;

		//      Show Durations Item
		//      Enable if there are any cues in the cue sheet
		BMenuItem* showDurationsItem = theMenu->FindItem(CUE_SHOWDURATIONS_MSG);
		if (showDurationsItem) {
			// Enable this item if there are any cues to be selected
			showDurationsItem->SetEnabled( fCueSheetView->HasCues() );
		}

		//      Show Stop Time Item
		BMenuItem* showStopTimeItem = theMenu->FindItem(CUE_SHOWSTOPTIMES_MSG);
		if (showStopTimeItem) {
			// Enable this item if there are any cues to be selected
			showStopTimeItem->SetEnabled( fCueSheetView->HasCues() );
		}


		//      Insert Channels Item
		BMenuItem* insertItem = theMenu->FindItem(CUE_INSERTCHANNELS_MSG);
		if (insertItem)
			;

		//      Delete Channels Item
		BMenuItem* deleteItem = theMenu->FindItem(CUE_DELETECHANNELS_MSG);
		if (deleteItem) {
			//  If we only have one channel, disable this item
			if (fCueSheetView->GetTotalChannels() > 1)
				deleteItem->SetEnabled(true);
			else
				deleteItem->SetEnabled(false);
		}

		//      Insert Time Item
		BMenuItem* insertTimeItem = theMenu->FindItem(CUE_INSERTTIME_MSG);
		if (insertTimeItem) {
			insertTimeItem->SetEnabled(false);
		}

		//      Align Start Item
		BMenuItem* startItem = theMenu->FindItem(CUE_ALIGNSTART_MSG);
		if (startItem) {
			//  A cue in two or more distinct channels must be selected for this
			//	command to be enable
			if ( fCueSheetView->HasMultipleCueChannelsSelected() )
				startItem->SetEnabled(true);
			else
				startItem->SetEnabled(false);
		}

		//      Align End Item
		BMenuItem* endItem = theMenu->FindItem(CUE_ALIGNEND_MSG);
		if (endItem) {
			//  A cue in two or more distinct channels must be selected for this
			//	command to be enable
			if ( fCueSheetView->HasMultipleCueChannelsSelected() )
				endItem->SetEnabled(true);
			else
				endItem->SetEnabled(false);
		}

		//      Collapse Item
		BMenuItem* collapseItem = theMenu->FindItem(CUE_COLLAPSEALL_MSG);
		if (collapseItem)
			;

		//      Jump To Item
		BMenuItem* jumpToItem = theMenu->FindItem(CUE_JUMPTO_MSG);
		if (jumpToItem)
			;


	}
}
Example #29
0
CInfoDialog::CInfoDialog(BRect frame, const char *name, window_type type, int flags,
			BWindow *owner, BPositionIO* data)
	: HDialog(frame, name, type, flags, owner, data)
{
	fDoc = dynamic_cast<PDoc*>(owner);
	FailNil(fDoc);

	SetText("name", owner->Title());

	char s[32];
	sprintf(s, "%d", fDoc->TextView()->Size());
	SetText("docsize", s);

	sprintf(s, "%d", fDoc->TextView()->LineCount());
	SetText("lines", s);

	BMenuField *mf = dynamic_cast<BMenuField*>(FindView("mime"));
	FailNil(mf);
	fTypes = mf->Menu();

	const char *p;
	int i = 0;
	while ((p = gPrefs->GetIxPrefString(prf_X_Mimetype, i++)) != NULL)
		fTypes->AddItem(new BMenuItem(p, new BMessage(msg_FieldChanged)));

	if (i == 1)
		fTypes->AddItem(new BMenuItem("text/plain", new BMessage(msg_FieldChanged)));

	const char *mime = fDoc->MimeType();

	if (mime && mime[0])
	{
		for (i = 0; i < fTypes->CountItems(); i++)
		{
			BMenuItem *item = fTypes->ItemAt(i);
			if (strcmp(item->Label(), mime) == 0)
			{
				item->SetMarked(true);
				break;
			}
		}

		if (i == fTypes->CountItems())
		{
			fTypes->AddSeparatorItem();
			fTypes->AddItem(new BMenuItem(mime, new BMessage(msg_FieldChanged)));
			fTypes->ItemAt(fTypes->CountItems() - 1)->SetMarked(true);
		}
	}
	else
	{
		BMenuItem *item;
		fTypes->AddSeparatorItem();
		fTypes->AddItem(item = new BMenuItem("<undefined>", new BMessage(msg_FieldChanged)));
		item->SetMarked(true);
	}

	if (fDoc->EntryRef())
	{
		BNode node;
		FailOSErr(node.SetTo(fDoc->EntryRef()));

		time_t t;
		node.GetModificationTime(&t);

		char time[256];
		strcpy(time, ctime(&t));
		time[strlen(time) - 1] = 0;

		SetText("time", time);
	}
	else
	{
		//SetEnabled("mime", false);
		SetText("time", "Not Saved");
	}

	mf = dynamic_cast<BMenuField*>(FindView("font"));
	FailNil(mf);

	fMenu = mf->Menu();
	FailNil(fMenu);

	font_family ff;
	font_style fs;

	for (int i = 0; i < count_font_families(); i++)
	{
		get_font_family(i, &ff);
		BMenu *fontItem = new BMenu(ff);
		FailNil(fontItem);
		fMenu->AddItem(new BMenuItem(fontItem, new BMessage(msg_FieldChanged)));
		fontItem->SetFont(be_plain_font);

		for (int j = 0; j < count_font_styles(ff); j++)
		{
			get_font_style(ff, j, &fs);

			BMessage *msg = new BMessage(msg_FieldChanged);
			msg->AddString("family", ff);
			msg->AddString("style", fs);
			fontItem->AddItem(new BMenuItem(fs, msg));
		}
	}

	fMenu->SetRadioMode(true);

	mf = dynamic_cast<BMenuField*>(FindView("encoding"));
	FailNil(mf);
	fEncoding = mf->Menu();
	FailNil(fEncoding);
	fEncoding->SetRadioMode(true);

	mf = dynamic_cast<BMenuField*>(FindView("source encoding"));
	FailNil(mf);
	fSourceEncoding = mf->Menu();
	FailNil(fSourceEncoding);
	fSourceEncoding->SetRadioMode(true);

	mf = dynamic_cast<BMenuField*>(FindView("linebreaks"));
	FailNil(mf);
	fLineBreaks = mf->Menu();
	FailNil(fLineBreaks);
	fLineBreaks->SetRadioMode(true);

	BTextControl *tc = dynamic_cast<BTextControl*>(FindView("tabs"));
	if (tc) tc->SetDivider(be_plain_font->StringWidth(tc->Label()) + 4);

	BMenu *lang;
	mf = dynamic_cast<BMenuField*>(FindView("language"));
	FailNil(mf);
	lang = mf->Menu();

	CLanguageInterface *intf;
	int cookie = 0;
	while ((intf = CLanguageInterface::NextIntf(cookie)) != NULL)
		lang->AddItem(new BMenuItem(intf->Name(), new BMessage(msg_FieldChanged)));

	lang->SetRadioMode(true);
	int curLang = fDoc->TextView()->Language();
	SetValue("language", curLang >= 0 ? curLang + 3 : 1);

	CancelClicked();
} /* CInfoDialog::CInfoDialog */
Example #30
0
void TCueSheetWindow::AdjustWindowsMenu()
{

	//	Set up string buffers
	bool retVal;
	char* menuStr   = (char*)malloc( sizeof(char) * 256);

	// Get application
	MuseumApp* theApp = static_cast<MuseumApp*>(be_app);

	BMenu* theMenu = fAppMenu->GetWindowsMenu();
	if (theMenu) {
		//      Stage Item
		BMenuItem* stageItem = theMenu->FindItem(WINDOWS_STAGE_MSG);
		if (stageItem) {
			TStageWindow* stage = fStageWindow;
			if (stage) {
				stage->Lock();
				if (stage->IsHidden())
					retVal = GetString("WindowsMenuStrings", kWindowsShowStageItem, menuStr);
				else
					retVal = GetString("WindowsMenuStrings", kWindowsHideStageItem, menuStr);
				stage->Unlock();

				stageItem->SetLabel(menuStr);
			} else {
				retVal = GetString("WindowsMenuStrings", kWindowsShowStageItem, menuStr);
				stageItem->SetLabel(menuStr);
			}
		}

		// Browser Item
		BMenuItem* browserItem = theMenu->FindItem(WINDOWS_BROWSER_MSG);
		if (stageItem) {
			TBrowserWindow* browser = theApp->GetBrowser();
			if (browser) {
				browser->Lock();
				if (browser->IsHidden())
					retVal = GetString("WindowsMenuStrings", kWindowsShowBrowserItem, menuStr);
				else
					retVal = GetString("WindowsMenuStrings", kWindowsHideBrowserItem, menuStr);
				browser->Unlock();

				browserItem->SetLabel(menuStr);
			} else {
				retVal = GetString("WindowsMenuStrings", kWindowsShowBrowserItem, menuStr);
				browserItem->SetLabel(menuStr);
			}
		}

		//      Transport Item
		BMenuItem* transportItem = theMenu->FindItem(WINDOWS_TRANSPORT_MSG);
		if (transportItem) {
			TTransportPalette* transport = theApp->GetTransport();
			if (transport) {
				transport->Lock();
				if (transport->IsHidden())
					retVal = GetString("WindowsMenuStrings", kWindowsShowTransportItem, menuStr);
				else
					retVal = GetString("WindowsMenuStrings", kWindowsHideTransportItem, menuStr);
				transport->Unlock();

				transportItem->SetLabel(menuStr);
			} else {
				retVal = GetString("WindowsMenuStrings", kWindowsShowTransportItem, menuStr);
				transportItem->SetLabel(menuStr);
			}
		}

		//      Locator Item
		BMenuItem* counterItem = theMenu->FindItem(WINDOWS_COUNTER_MSG);
		if (counterItem) {
			TTimePalette* time = theApp->GetTimePalette();
			if (time) {
				time->Lock();
				if (time->IsHidden())
					retVal = GetString("WindowsMenuStrings", kWindowsShowLocatorItem, menuStr);
				else
					retVal = GetString("WindowsMenuStrings", kWindowsHideLocatorItem, menuStr);
				time->Unlock();

				counterItem->SetLabel(menuStr);
			} else {
				retVal = GetString("WindowsMenuStrings", kWindowsShowLocatorItem, menuStr);
				counterItem->SetLabel(menuStr);
			}
		}

		//      Media Cue Item
		BMenuItem* mediaItem = theMenu->FindItem(WINDOWS_MEDIA_MSG);
		if (mediaItem) {
			TMediaCuePalette* mediaPalette = theApp->GetMediaPalette();
			if (mediaPalette) {
				mediaPalette->Lock();
				if (mediaPalette->IsHidden())
					retVal = GetString("WindowsMenuStrings", kWindowsShowMediaItem, menuStr);
				else
					retVal = GetString("WindowsMenuStrings", kWindowsHideMediaItem, menuStr);
				mediaPalette->Unlock();

				mediaItem->SetLabel(menuStr);
			} else {
				retVal = GetString("WindowsMenuStrings", kWindowsShowMediaItem, menuStr);
				mediaItem->SetLabel(menuStr);
			}
		}
	}
}