Window::Window()
	:
	BWindow(BRect(100, 100, 620, 200), "Alert-Test", B_TITLED_WINDOW,
		B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS)
{
	BMenu* sizeMenu = new BMenu("Button size");
	sizeMenu->SetLabelFromMarked(true);
	sizeMenu->SetRadioMode(true);
	sizeMenu->AddItem(new BMenuItem("As usual", NULL));
	sizeMenu->AddItem(new BMenuItem("From widest", NULL));
	sizeMenu->AddItem(new BMenuItem("From label", NULL));
	sizeMenu->ItemAt(0)->SetMarked(true);
	fSizeField = new BMenuField("Button size", sizeMenu);

	BMenu* typeMenu = new BMenu("Alert type");
	typeMenu->SetLabelFromMarked(true);
	typeMenu->SetRadioMode(true);
	typeMenu->AddItem(new BMenuItem("Empty", NULL));
	typeMenu->AddItem(new BMenuItem("Info", NULL));
	typeMenu->AddItem(new BMenuItem("Idea", NULL));
	typeMenu->AddItem(new BMenuItem("Warning", NULL));
	typeMenu->AddItem(new BMenuItem("Stop", NULL));
	typeMenu->ItemAt(0)->SetMarked(true);
	fTypeField = new BMenuField("Alert type", typeMenu);

	BMenu* spacingMenu = new BMenu("Button spacing");
	spacingMenu->SetLabelFromMarked(true);
	spacingMenu->SetRadioMode(true);
	spacingMenu->AddItem(new BMenuItem("Even", NULL));
	spacingMenu->AddItem(new BMenuItem("Offset", NULL));
	spacingMenu->ItemAt(0)->SetMarked(true);
	fSpacingField = new BMenuField("Button spacing", spacingMenu);

	fCountSlider = new BSlider("count", "Button count", NULL, 1, 3,
		B_HORIZONTAL);
	fCountSlider->SetValue(3);
	fCountSlider->SetLimitLabels("1", "3");
	fCountSlider->SetHashMarkCount(3);
	fCountSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);

	fLastStringView = new BStringView("last pressed", "");
	fLastStringView->SetAlignment(B_ALIGN_CENTER);

	BButton* button = new BButton("Show alert", new BMessage(kMsgShowAlert));

	BLayoutBuilder::Group<>(this, B_VERTICAL)
		.Add(fSizeField)
		.Add(fTypeField)
		.Add(fSpacingField)
		.Add(fCountSlider)
		.AddGlue()
		.Add(fLastStringView)
		.Add(button)
		.SetInsets(B_USE_DEFAULT_SPACING);

	CenterOnScreen();
	SetFlags(Flags() | B_CLOSE_ON_ESCAPE);
}
Example #2
0
/***********************************************************
 * InitGUI
 ***********************************************************/
void
HCriteriaView::InitGUI()
{
	BRect rect = Bounds();
	rect.left += 5;
	rect.top += 2;
	rect.right = rect.left + 80;
	BMenu *menu = new BMenu("menu");
	menu->AddItem(new BMenuItem(_("Subject"),NULL));
	menu->AddItem(new BMenuItem(_("To"),NULL));
	menu->AddItem(new BMenuItem(_("From"),NULL));
	menu->AddItem(new BMenuItem(_("Cc"),NULL));
	menu->AddItem(new BMenuItem(_("Reply-To"),NULL));
	menu->AddItem(new BMenuItem(_("Account"),NULL));
	menu->ItemAt(0)->SetMarked(true);
	menu->SetRadioMode(true);
	menu->SetLabelFromMarked(true);
	fAttrMenu = new BMenuField(rect,"attr","",menu);
	fAttrMenu->SetDivider(0);
	AddChild(fAttrMenu);
	
	rect.OffsetBy(80,0);
	menu = new BMenu("menu");
	menu->AddItem(new BMenuItem(_("contains"),NULL));
	menu->AddItem(new BMenuItem(_("is"),NULL));
	menu->AddItem(new BMenuItem(_("begin with"),NULL));
	menu->AddItem(new BMenuItem(_("end with"),NULL));
	menu->ItemAt(0)->SetMarked(true);
	menu->SetRadioMode(true);
	menu->SetLabelFromMarked(true);
	fOpMenu = new BMenuField(rect,"op","",menu);
	fOpMenu->SetDivider(0);
	AddChild(fOpMenu);
	
	rect.OffsetBy(80,2);
	rect.right= Bounds().right - 70;
	fValue = new BTextControl(rect,"value","","",NULL);
	fValue->SetDivider(0);
	AddChild(fValue);
	
	rect.right = Bounds().right - 5;
	rect.left = Bounds().right - 65;
	menu = new BMenu("operator");
	menu->AddItem(new BMenuItem(_("and"),NULL));
	menu->AddItem(new BMenuItem(_("or"),NULL));
	menu->ItemAt(0)->SetMarked(true);
	menu->SetRadioMode(true);
	menu->SetLabelFromMarked(true);
	fOp2Menu= new BMenuField(rect,"op2","",menu);
	fOp2Menu->SetDivider(0);
	AddChild(fOp2Menu);
}
Example #3
0
/* static */
BMenu*
TermWindow::_MakeEncodingMenu()
{
	BMenu* menu = new (std::nothrow) BMenu(B_TRANSLATE("Text encoding"));
	if (menu == NULL)
		return NULL;

	BCharacterSetRoster roster;
	BCharacterSet charset;
	while (roster.GetNextCharacterSet(&charset) == B_OK) {
		int encoding = M_UTF8;
		const char* mime = charset.GetMIMEName();
		if (mime == NULL || strcasecmp(mime, "UTF-8") != 0)
			encoding = charset.GetConversionID();

		// filter out currently (???) not supported USC-2 and UTF-16
		if (encoding == B_UTF16_CONVERSION || encoding == B_UNICODE_CONVERSION)
			continue;

		BString name(charset.GetPrintName());
		if (mime)
			name << " (" << mime << ")";

		BMessage *message = new BMessage(MENU_ENCODING);
		if (message != NULL) {
			message->AddInt32("op", (int32)encoding);
			menu->AddItem(new BMenuItem(name, message));
		}
	}

	menu->SetRadioMode(true);

	return menu;
}
Example #4
0
int32
OggEncoder::LoadDefaultMenu() {
	PRINT(("OggEncoder::LoadDefaultMenu()\n"));

	BMenu* bitrateMenu;
	BMenuItem* item;

	menu = new BMenu(name.String());

	//Bitrate Menu
	bitrateMenu = new BMenu(BITRATE_STR);
	bitrateMenu->SetRadioMode(true);

	item = new BMenuItem(_112KBPS, NULL);
	bitrateMenu->AddItem(item);

	item = new BMenuItem(_128KBPS, NULL);
	item->SetMarked(true);
	bitrateMenu->AddItem(item);

	item = new BMenuItem(_160KBPS, NULL);
	bitrateMenu->AddItem(item);

	item = new BMenuItem(_192KBPS, NULL);
	bitrateMenu->AddItem(item);

	item = new BMenuItem(_256KBPS, NULL);
	bitrateMenu->AddItem(item);

	item = new BMenuItem(_350KBPS, NULL);
	bitrateMenu->AddItem(item);

	menu->AddItem(bitrateMenu);
}
/*!	\brief		Creates list of all Calendar Modules in the system.
 *		\attention	It is assumed that \c global_ListOfCalendarModules is set up
 *						before constructing this control.
 */
BMenu*		CalendarControl::CreateMenuOfCalendarModules()
{
	BMenu* toReturn = new BMenu( "Calendar Modules" , B_ITEMS_IN_COLUMN );
	if ( !toReturn ) { return NULL; }
	toReturn->SetRadioMode( true );
	toReturn->SetLabelFromMarked( true );
	
	BMenuItem* item;
	BMessage*  toSend;
	BString	  tempNameOfModule;
	CalendarModule* module;
	
	// Fill the menu
	for ( int i = 0; i < NUMBER_OF_CALENDAR_MODULES; ++i ) {
		module = ( CalendarModule* )global_ListOfCalendarModules.ItemAt( i );
		
		if ( !module ) { continue; }
		tempNameOfModule.SetTo( module->Identify() );
		
		toSend = new BMessage( kCalendarModuleChosen );
		if ( !toSend ) { continue; }
		toSend->AddString( "Name of calendar module", tempNameOfModule );
		
		item = new BMenuItem( tempNameOfModule.String(), toSend );
		if ( !item ) { continue; }
		
		toReturn->AddItem( item );
		
		if ( tempNameOfModule == fRepresentedTime.GetCalendarModule() ) {
			item->SetMarked( true );
		}
	}
	return toReturn;
}	// <-- end of function CalendarControl::CreateMenuOfCalendarModules
Example #6
0
// ----------------------------------------------------------------------- RHTML_Preferences_Win - FTSetFont -
void RHTMLPreferencesWin::FTSetFont(const char *font,const char *style ="")
{
 fFTFontsBox->RemoveChild(fFTDFStyle);

 font_family fFamily;
 font_style fStyle;
 BMenu *fSMenu;
 
 strcpy(fFamily,font);
 int32 styleNum = count_font_styles(fFamily);
 if (style!="")
 {
  fSMenu = new BMenu(fOptions->GetLocaleString("Preferences_Window_FileTypes",style));
 } else
 if (styleNum>0)
 {
  get_font_style(fFamily, 0, &fStyle);
  fSMenu = new BMenu(fOptions->GetLocaleString("Preferences_Window_FileTypes",fStyle));
 } else fSMenu = new BMenu("");

 fSMenu->SetRadioMode(false);
 fSMenu->SetLabelFromMarked(true);

 for (int32 ii = 0; ii < styleNum; ii++)
 {
  get_font_style(fFamily, ii, &fStyle);
  BMessage*	msg = new BMessage('FTFS');
  msg->AddString("font_style", fStyle);  
  fSMenu->AddItem(new BMenuItem(fOptions->GetLocaleString("Preferences_Window_FileTypes",fStyle),msg));
 }

 fFTDFStyle= new BMenuField(BRect(10,45,180,75),"Font Style",fOptions->GetLocaleString("Preferences_Window_FileTypes","Style"),fSMenu);
 fFTDFStyle->SetDivider(60);
 fFTFontsBox->AddChild(fFTDFStyle);
}
BMenu *CreateColorMenu(const char *name, int columns, int n, rgb_color *colors, BMessage *msg) {
	if (columns > n) columns = n;
	int rows = (n + columns-1) / columns; // ceil((float)n / (float)columns)

	ColorMenuItem cmi(colors[0], NULL);
	float w, h;
	cmi.GetSize(w, h);
	
	BMenu *menu = new BMenu(name, columns * w, rows * h); 
	menu->SetRadioMode(true);
	
	BRect frame; float left, top;
	int i = 0, x, y; BMessage *m = NULL; 
	for (y = 0; y < rows; y++)
		for (x = 0; x < columns; x++) {
			left = x * w;
			top = y * h;
			frame.Set(left, top, left + w - 1, top + h - 1);
			
			if (msg != NULL) {
				m = new BMessage(*msg);
				ArchiveColor(NULL, m, colors[i]);
			}
			menu->AddItem(new ColorMenuItem(colors[i], m), frame);
			i++; if (i == n) return menu;
		}
	return menu;
}
Example #8
0
void
ControlView::_UpdateFontmenus(bool setInitialfont)
{
    BFont font;
    BMenu* stylemenu = NULL;

    font_family fontFamilyName, currentFamily;
    font_style fontStyleName, currentStyle;

    GetFont(&font);
    font.GetFamilyAndStyle(&currentFamily, &currentStyle);

    const int32 fontfamilies = count_font_families();

    fFontFamilyMenu->RemoveItems(0, fFontFamilyMenu->CountItems(), true);

    for (int32 i = 0; i < fontfamilies; i++) {
        if (get_font_family(i, &fontFamilyName) == B_OK) {
            stylemenu = new BMenu(fontFamilyName);
            const int32 styles = count_font_styles(fontFamilyName);

            BMessage* familyMsg = new BMessage(FONTFAMILY_CHANGED_MSG);
            familyMsg->AddString("_family", fontFamilyName);
            BMenuItem* familyItem = new BMenuItem(stylemenu, familyMsg);
            fFontFamilyMenu->AddItem(familyItem);

            for (int32 j = 0; j < styles; j++) {
                if (get_font_style(fontFamilyName, j, &fontStyleName) == B_OK) {
                    BMessage* fontMsg = new BMessage(FONTSTYLE_CHANGED_MSG);
                    fontMsg->AddString("_family", fontFamilyName);
                    fontMsg->AddString("_style", fontStyleName);

                    BMenuItem* styleItem = new BMenuItem(fontStyleName, fontMsg);
                    styleItem->SetMarked(false);

                    // setInitialfont is used when we attach the FontField
                    if (!strcmp(fontStyleName, currentStyle)
                            && !strcmp(fontFamilyName, currentFamily)
                            && setInitialfont) {
                        styleItem->SetMarked(true);
                        familyItem->SetMarked(true);

                        BString string;
                        string << currentFamily << " " << currentStyle;

                        if (fFontMenuField)
                            fFontMenuField->MenuItem()->SetLabel(string.String());
                    }
                    stylemenu->AddItem(styleItem);
                }
            }
        }
        stylemenu->SetRadioMode(true);
        stylemenu->SetTargetForItems(this);
    }

    fFontFamilyMenu->SetLabelFromMarked(true);
    fFontFamilyMenu->SetTargetForItems(this);
}
Example #9
0
GDWindow::GDWindow(BRect frame)
				: BWindow(frame, "GrafDemo 4.6", B_DOCUMENT_WINDOW,0)
{
	Lock();
	// Add the graph to the window
	BRect grafRect = Bounds();
	grafRect.top += mb_height + 2;
	mGraphView= new GDView(grafRect);
	AddChild(mGraphView);
	SetSizeLimits(frame.right - frame.left,9999,frame.bottom - frame.top,9999);

	// Add the main menu bar and menus
	BRect menuRect(0,0,1000,mb_height);
	BMenuBar* menuBar = new BMenuBar(menuRect,"MB");
	
	BMenu*	fileMenu = new BMenu("File");
	BMenuItem* aboutItem = new BMenuItem("About...",new BMessage(B_ABOUT_REQUESTED));
	aboutItem->SetTarget(be_app);
	fileMenu->AddItem(aboutItem);
	fileMenu->AddSeparatorItem();
	fileMenu->AddItem(new BMenuItem("Quit",new BMessage(B_QUIT_REQUESTED)));
	menuBar->AddItem(fileMenu);
	
	BMenu*	editMenu = new BMenu("Edit");
	editMenu->AddItem(new BMenuItem("Erase",new BMessage(G_erase_data)));
	editMenu->AddItem(new BMenuItem("Reset Axes",new BMessage(G_reset_axes)));
	editMenu->SetTargetForItems(mGraphView);
	menuBar->AddItem(editMenu);
	
	BMenu*	paramsMenu = new BMenu("Params");
	BMessage* cFitMesg = new BMessage(G_set_params);
	cFitMesg->AddInt16(pName,0);
	BMessage* p2Mesg = new BMessage(G_set_params);
	p2Mesg->AddInt16(pName,2);
	BMessage* p3Mesg = new BMessage(G_set_params);
	p3Mesg->AddInt16(pName,3);
	BMessage* p4Mesg = new BMessage(G_set_params);
	p4Mesg->AddInt16(pName,4);
	paramsMenu->AddItem(new BMenuItem("Cubic Spline",cFitMesg));
	paramsMenu->AddSeparatorItem();
	paramsMenu->AddItem(new BMenuItem("1st Order",p2Mesg));
	paramsMenu->AddItem(new BMenuItem("2nd Order",p3Mesg));
	paramsMenu->AddItem(new BMenuItem("3rd Order",p4Mesg));
	paramsMenu->SetRadioMode(true);
	paramsMenu->FindItem("2nd Order")->SetMarked(true);
	paramsMenu->SetTargetForItems(mGraphView);
	menuBar->AddItem(paramsMenu);

	BMenu*	axisMenu = new BMenu("Axes");
	axisMenu->AddItem(new BMenuItem("Set Axes"B_UTF8_ELLIPSIS,new BMessage(G_change_axis)));
	axisMenu->SetTargetForItems(mGraphView);
	menuBar->AddItem(axisMenu);

	AddChild(menuBar);
	
	Unlock();
}
Example #10
0
void
HWindow::_InitGUI()
{
	fEventList = new HEventList();
	fEventList->SetType(BMediaFiles::B_SOUNDS);
	fEventList->SetSelectionMode(B_SINGLE_SELECTION_LIST);

	BMenu* menu = new BMenu("file");
	menu->SetRadioMode(true);
	menu->SetLabelFromMarked(true);
	menu->AddSeparatorItem();
	menu->AddItem(new BMenuItem(B_TRANSLATE("<none>"),
		new BMessage(M_NONE_MESSAGE)));
	menu->AddItem(new BMenuItem(B_TRANSLATE("Other" B_UTF8_ELLIPSIS),
		new BMessage(M_OTHER_MESSAGE)));

	BString label(B_TRANSLATE("Sound file:"));
	BMenuField* menuField = new BMenuField("filemenu", label, menu);
	menuField->SetDivider(menuField->StringWidth(label) + 10);

	BSize buttonsSize(be_plain_font->Size() * 2.5, be_plain_font->Size() * 2.5);

	BButton* stopbutton = new BButton("stop", "\xE2\x96\xA0",
		new BMessage(M_STOP_MESSAGE));
	stopbutton->SetEnabled(false);
	stopbutton->SetExplicitSize(buttonsSize);

	// We need at least one view to trigger B_PULSE_NEEDED events which we will
	// intercept in DispatchMessage to trigger the buttons enabling or disabling.
	stopbutton->SetFlags(stopbutton->Flags() | B_PULSE_NEEDED);

	BButton* playbutton = new BButton("play", "\xE2\x96\xB6",
		new BMessage(M_PLAY_MESSAGE));
	playbutton->SetEnabled(false);
	playbutton->SetExplicitSize(buttonsSize);

	BLayoutBuilder::Group<>(this, B_VERTICAL)
		.SetInsets(B_USE_WINDOW_SPACING)
		.Add(fEventList)
		.AddGroup(B_HORIZONTAL)
			.Add(menuField)
			.AddGroup(B_HORIZONTAL, 0)
				.Add(playbutton)
				.Add(stopbutton)
			.End()
		.End();

	// setup file menu
	_SetupMenuField();
	BMenuItem* noneItem = menu->FindItem(B_TRANSLATE("<none>"));
	if (noneItem != NULL)
		noneItem->SetMarked(true);

	_UpdateZoomLimits();
}
Example #11
0
void
AddPrinterDialog::_FillTransportMenu(BMenu* menu)
{
	BMessenger msgr;
	if (GetPrinterServerMessenger(msgr) != B_OK)
		return;

	for (long idx = 0; ; idx++) {
		BMessage reply, msg(B_GET_PROPERTY);
		msg.AddSpecifier("Transport", idx);
		if (msgr.SendMessage(&msg, &reply) != B_OK)
			break;

		BMessenger transport;
		if (reply.FindMessenger("result", &transport) != B_OK)
			break;

		// Got messenger to transport now
		msg.MakeEmpty();
		msg.what = B_GET_PROPERTY;
		msg.AddSpecifier("Name");
		if (transport.SendMessage(&msg, &reply) != B_OK)
			continue;

		BString transportName;
		if (reply.FindString("result", &transportName) != B_OK)
			continue;

		// Now get ports...
		BString portId, portName;
		int32 error;
		msg.MakeEmpty();
		msg.what = B_GET_PROPERTY;
		msg.AddSpecifier("Ports");
		if (transport.SendMessage(&msg, &reply) != B_OK
				|| reply.FindInt32("error", &error) != B_OK
				|| error != B_OK
				|| (transportName == "IPP"
						&& reply.FindString("port_id", &portId) != B_OK)) {
			// Transport does not provide list of ports
			BMessage* menuMsg = new BMessage(kTransportSelectedMsg);
			menuMsg->AddString("name", transportName);
			menu->AddItem(new BMenuItem(transportName.String(), menuMsg));
			continue;
		}

		// Create submenu
		BMenu* transportMenu = new TransportMenu(transportName.String(),
			kTransportSelectedMsg, transport, transportName);
		menu->AddItem(transportMenu);
		transportMenu->SetRadioMode(true);
		menu->ItemAt(menu->IndexOf(transportMenu))->
			SetMessage(new BMessage(kTransportSelectedMsg));
	}
}
Example #12
0
static BMenuField* new_device_control(BRect f)
{
	BMenu*						menu = new BMenu("device_menu");
	if (!menu) return NULL;
	menu->SetLabelFromMarked(true);
	menu->SetRadioMode(true);
	add_device_menu_items(menu);
	BMenuField*	field = new BMenuField(f, "device_field", "Device:", menu, B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
	if (!field) {
		delete menu;
		return NULL;
	}
	return field;
}
Example #13
0
// --------------------------------------------------------------------- RHTML_Preferences_Win - FTHSetFSize -
void RHTMLPreferencesWin::FTHSetFSize(uint FontColor)
{
 fFTHFontBox->RemoveChild(fFTHStyle);

 font_family fFamily;
 font_style	fStyle;
  BMessage *msg;

// - Style

 BMenu *fStyleMenu;
 
 fOptions->DefaultFont->GetFamilyAndStyle(&fFamily,&fStyle);
 int32 styleNum = count_font_styles(fFamily);

 if (fOptions->FileTypes[fFTHFileTypes]->Font[FontColor]->Style.ICompare("Default style")==0)
 {
  fStyleMenu = new BMenu(fOptions->GetLocaleString("Preferences_Window_FileTypes","Default style"));
 } else
  fStyleMenu = new BMenu(fOptions->GetLocaleString("Preferences_Window_FileTypes",fOptions->FileTypes[fFTHFileTypes]->Font[FontColor]->Style.String()));

 fStyleMenu->SetRadioMode(false);
 fStyleMenu->SetLabelFromMarked(true);

 msg = new BMessage(R_FTH_Style_MSG);
 msg->AddString("font_style","Default style");
 fStyleMenu->AddItem(new BMenuItem(fOptions->GetLocaleString("Preferences_Window_FileTypes","Default style"),msg));

 for (int32 ii = 0; ii < styleNum; ii++)
 {
  get_font_style(fFamily, ii, &fStyle);
  msg = new BMessage(R_FTH_Style_MSG);
  msg->AddString("font_style", fStyle);  
  fStyleMenu->AddItem(new BMenuItem(fOptions->GetLocaleString("Preferences_Window_FileTypes",fStyle),msg));
 }
 
 fFTHStyle= new BMenuField(BRect(10,15,210,40),"Style",fOptions->GetLocaleString("Preferences_Window_FileTypes","Style"),fStyleMenu);
 fFTHStyle->SetDivider(80);
 fFTHFontBox->AddChild(fFTHStyle);
  
// - Color

 rgb_color rgb;
 rgb.alpha=fOptions->FileTypes[fFTHFileTypes]->Color[FontColor]->alpha;
 rgb.red=fOptions->FileTypes[fFTHFileTypes]->Color[FontColor]->red;
 rgb.green=fOptions->FileTypes[fFTHFileTypes]->Color[FontColor]->green;
 rgb.blue=fOptions->FileTypes[fFTHFileTypes]->Color[FontColor]->blue;
 fFTHCC->SetValue(rgb);
}
Example #14
0
/*static*/ BMenu*
AppearancePrefView::_MakeFontSizeMenu(const char* label, uint32 command,
	const char* family, const char* style, const char* size)
{
	BMenu* menu = new BMenu(label);
	menu->SetRadioMode(true);
	menu->SetLabelFromMarked(false);

	int32 sizes[] = {
		8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 28, 32, 36, 0
	};

	bool found = false;

	for (uint32 i = 0; sizes[i]; i++) {
		BString fontSize;
		fontSize << sizes[i];
		BMessage* message = new BMessage(command);
		message->AddString("font_family", family);
		message->AddString("font_style", style);
		message->AddString("font_size", fontSize.String());
		BMenuItem* item = new BMenuItem(fontSize.String(), message);
		menu->AddItem(item);
		if (sizes[i] == atoi(size)) {
			item->SetMarked(true);
			found = true;
		}
	}

	if (!found) {
		for (uint32 i = 0; sizes[i]; i++) {
			if (sizes[i] > atoi(size)) {
				BMessage* message = new BMessage(command);
				message->AddString("font_family", family);
				message->AddString("font_style", style);
				message->AddString("font_size", size);
				BMenuItem* item = new BMenuItem(size, message);
				item->SetMarked(true);
				menu->AddItem(item, i);
				break;
			}
		}
	}

	return menu;
}
Example #15
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;
}
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 #17
0
// ------------------------------------------------------------------------ RHTML_Preferences_Win - FTHSetFT -
void RHTMLPreferencesWin::FTHSetFT(uint FileType)
{
 fFTHFTBox->RemoveChild(fFTHFC);

 BMenu *fFCMenu = new BMenu(fOptions->GetLocaleString("FileTypes_FontColorName",fOptions->FileTypes[FileType]->FCName[0]->String()));
 fFCMenu->SetLabelFromMarked(true);
 fFCMenu->SetRadioMode(true);
 for (int32 i=0;i<(int32)fOptions->FileTypes[FileType]->FontColorDb;i++)
 {
  BMessage* msg = new BMessage('FTHT');
  msg->AddInt32("FontColor",i);
  BMenuItem *item;
  fFCMenu->AddItem(item=new BMenuItem(fOptions->GetLocaleString("FileTypes_FontColorName",fOptions->FileTypes[FileType]->FCName[i]->String()),msg));
  item->SetTarget(this);
 }
 
 fFTHFC= new BMenuField(BRect(10,40,210,65),"FileTypesMenu",fOptions->GetLocaleString("Preferences_Window_FileTypes","Element"),fFCMenu);
 fFTHFC->SetDivider(100);
 fFTHFTBox->AddChild(fFTHFC);
 FTHSetFSize(0);
}
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 #19
0
// ------------------------------------------------------------- RHTML_Preferences_Win - RHTMLPreferencesWin -
RHTMLPreferencesWin::RHTMLPreferencesWin(BRect fRect,BWindow *parent): BWindow(fRect,fOptions->GetLocaleString("Preferences_Window","Preferences"),B_FLOATING_WINDOW,B_UNTYPED_WINDOW)
{
 fParent=parent;
 IsQuit=false;
 fList = new BOutlineListView(BRect(0,0,150,Bounds().bottom),"List",B_SINGLE_SELECTION_LIST,B_FOLLOW_TOP_BOTTOM,B_WILL_DRAW);
 BView *view1= new BView(BRect(151,0,151,Bounds().bottom),"view",B_FOLLOW_TOP_BOTTOM,B_WILL_DRAW);
 fView=new BView(BRect(152,0,Bounds().right,Bounds().bottom),"view",B_FOLLOW_ALL,B_WILL_DRAW);
 AddChild(fList);
 AddChild(view1);
 AddChild(fView);
 fView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
 view1->SetViewColor(184,184,184,0);
 fList->SetSelectionMessage(new BMessage('LIST'));

 JViewDb=5;
 fJView = (BView**) calloc(JViewDb,sizeof(BView));

// - Create Languages
 fList->AddItem(new BStringItem(fOptions->GetLocaleString("Preferences_Window_List","Languages")));

 fJView[0] = new BView(fView->Bounds(),"LangView",B_FOLLOW_TOP_BOTTOM,B_WILL_DRAW);
 fJView[0]->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
 fView->AddChild(fJView[0]);
 fLangMenu = new BMenu(fOptions->Locale[fOptions->CurrentLocale]->Lang.String());
 fLangMenu->SetLabelFromMarked(true);
 fLangMenu->SetRadioMode(true);
 for (int32 i=0;i<(int32)fOptions->LocaleDb;i++)
 {
  BMessage* msg = new BMessage('LANG');
  msg->AddInt32("Lang",i);
  BMenuItem *item;
  fLangMenu->AddItem(item=new BMenuItem(fOptions->Locale[i]->Lang.String(),msg));
  item->SetTarget(this);
 }
 fLanguages= new BMenuField(BRect(10,10,250,30),"LanguagesMenu",fOptions->GetLocaleString("Preferences_Window_Languages","Languages"),fLangMenu);
 fJView[0]->AddChild(fLanguages);
 
 fView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));

 fStrView1 = new BStringView(BRect(10,50,250,100),"strview1","Language:");
 fJView[0]->AddChild(fStrView1);

 fStrView2 = new BStringView(BRect(10,50,250,120),"strview1","");
 fJView[0]->AddChild(fStrView2);

 fStrView3 = new BStringView(BRect(10,50,250,150),"strview1","Author:");
 fJView[0]->AddChild(fStrView3);

 author = new URLView( BRect(0,50,250,170),"author","","");
 fJView[0]->AddChild(author);

 fStrView4 = new BStringView(BRect(10,50,250,200),"strview4","Language version:");
 fJView[0]->AddChild(fStrView4);
 
 fStrView5 = new BStringView(BRect(10,50,300,220),"strview5","");
 fJView[0]->AddChild(fStrView5);

 fStrView6 = new BStringView(BRect(10,50,300,250),"strview6","Language create to:");
 fJView[0]->AddChild(fStrView6);
 
 fStrView7 = new BStringView(BRect(10,50,300,270),"strview7","");
 fJView[0]->AddChild(fStrView7);

 LSetAuthor();

// - Create FileTypes

 fJView[1] = new BView(fView->Bounds(),"FTView",B_FOLLOW_TOP_BOTTOM,B_WILL_DRAW);
 fJView[1]->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
 fView->AddChild(fJView[1]);

// - Create FileTypes/Fonts

 fFTFontsBox= new BBox(BRect(10,10,200,120));
 fFTFontsBox->SetLabel(fOptions->GetLocaleString("Preferences_Window_FileTypes","Default font"));
 fFTFontsBox->SetFont(new BFont(be_plain_font));
 fJView[1]->AddChild(fFTFontsBox);


 BString stmp;
 stmp << (int32) fOptions->DefaultFont->Size();
 BMenu *fSizeMenu = new BMenu(stmp.String());
 fSizeMenu->SetRadioMode(false);
 fSizeMenu->SetLabelFromMarked(true);
 
 for (int32 o=8;o<15;o++)
 {
  BMessage *msg2;
  msg2 = new BMessage('FTSZ');
  msg2->AddInt32("font_size",o);
  BString tmp;
  tmp << o;
  fSizeMenu->AddItem(new BMenuItem(tmp.String(),msg2));
 }
 fFTDFSize= new BMenuField(BRect(10,75,180,105),"Font Size",fOptions->GetLocaleString("Preferences_Window_FileTypes","Size"),fSizeMenu);
 fFTDFSize->SetDivider(60);
 fFTFontsBox->AddChild(fFTDFSize);

 font_family fFamily;
 font_style	fStyle;

 fOptions->DefaultFont->GetFamilyAndStyle(&fFamily,&fStyle);
 fFTDFStyle= new BMenuField(BRect(10,45,180,75),"Font Style",fOptions->GetLocaleString("Preferences_Window_FileTypes","Style"),new BMenu("Style"));
 fFTDFStyle->SetDivider(60);
 fFTFontsBox->AddChild(fFTDFStyle);
 FTSetFont(fFamily,fStyle);
 BMenu *fMenu = new BMenu(fFamily);
 fMenu->SetRadioMode(false);
 fMenu->SetLabelFromMarked(true);

 const int32 fontNum = count_font_families();

 for(int32 i = 0; i < fontNum; i++)
 {
  get_font_family(i,&fFamily);
  BMessage*	msg = new BMessage('FTDF');
  msg->AddString("font_family", fFamily);
  fMenu->AddItem(new BMenuItem(fFamily,msg));
 }

 fFTDFont= new BMenuField(BRect(10,15,180,35),"Default font",fOptions->GetLocaleString("Preferences_Window_FileTypes","Font"),fMenu);
 fFTDFont->SetDivider(60);
 fFTFontsBox->AddChild(fFTDFont);

// - Create FileTypes/Extensions

 fFTBox= new BBox(BRect(10,130,200,290));
 fFTBox->SetLabel(fOptions->GetLocaleString("Preferences_Window_FileTypes","Extension"));
 fFTBox->SetFont(new BFont(be_plain_font));
 fJView[1]->AddChild(fFTBox);

 BListItem *FTUitem;
 fList->AddItem(FTUitem=new BStringItem(fOptions->GetLocaleString("Preferences_Window_List","Filetypes")));

 fFTFTMenu = new BMenu(fOptions->FileTypes[0]->Name->String());
 fFTFTMenu->SetLabelFromMarked(true);
 fFTFTMenu->SetRadioMode(true);
 for (int32 i=0;i<(int32)fOptions->FileTypesDb;i++)
 {
  BMessage* msg = new BMessage('FTFT');
  msg->AddInt32("FileType",i);
  BMenuItem *item;
  fFTFTMenu->AddItem(item=new BMenuItem(fOptions->FileTypes[i]->Name->String(),msg));
  item->SetTarget(this);
 }
 fFTFT= new BMenuField(BRect(10,15,180,35),"FileTypesMenu",fOptions->GetLocaleString("Preferences_Window_FileTypes","Filetype"),fFTFTMenu);
 fFTFT->SetDivider(80);
 fFTBox->AddChild(fFTFT); 
 
 fFTKit = new BListView(BRect(10,40,54,120),"KitList",B_SINGLE_SELECTION_LIST,B_FOLLOW_NONE,B_WILL_DRAW);
 BScrollView *fScrollView = new BScrollView("List",fFTKit,B_FOLLOW_ALL_SIDES,B_WILL_DRAW, false, true,B_FANCY_BORDER);
 fFTBox->AddChild(fScrollView);
 
 fFTKit->TargetedByScrollView(fScrollView);
 fFTKit->SetSelectionMessage(new BMessage('FTSL'));
 
 fFTAddButton = new BButton(BRect(90,40,170,60),"Add",fOptions->GetLocaleString("Preferences_Window_FileTypes","Add"),new BMessage('FTAD'));
 fFTEditButton = new BButton(BRect(90,80,170,100),"Edit",fOptions->GetLocaleString("Preferences_Window_FileTypes","Edit"),new BMessage('FTED'));
 fFTRemoveButton = new BButton(BRect(90,120,170,140),"Remove",fOptions->GetLocaleString("Preferences_Window_FileTypes","Remove"),new BMessage('FTRM'));
 fFTBox->AddChild(fFTAddButton);
 fFTBox->AddChild(fFTEditButton);
 fFTBox->AddChild(fFTRemoveButton);
 
 fFTStrView = new BTextControl(BRect(5,130,70,150),"Név","","",new BMessage('FTST'));
 fFTStrView->SetDivider(0);
 fFTBox->AddChild(fFTStrView);
 FTCreateKitList(0);

// - Create FileTypes - Highlighting

 fList->AddUnder(new BStringItem(fOptions->GetLocaleString("Preferences_Window_List","Highlighting")), FTUitem);

 fJView[2] = new BView(fView->Bounds(),"FTView",B_FOLLOW_TOP_BOTTOM,B_WILL_DRAW);
 fJView[2]->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
 fView->AddChild(fJView[2]);

  // - FT
 fFTHFileTypes=0;
 fFTHFTBox= new BBox(BRect(10,10,320,260));
 fFTHFTBox->SetLabel(fOptions->GetLocaleString("Preferences_Window_FileTypes","Highlighting"));
 fFTHFTBox->SetFont(new BFont(be_plain_font));
 fJView[2]->AddChild(fFTHFTBox);

 fFTFTMenu = new BMenu(fOptions->FileTypes[0]->Name->String());
 fFTFTMenu->SetLabelFromMarked(true);
 fFTFTMenu->SetRadioMode(true);
 for (int32 i=0;i<(int32)fOptions->FileTypesDb;i++)
 {
  BMessage* msg = new BMessage('FTHF');
  msg->AddInt32("FileType",i);
  BMenuItem *item;
  fFTFTMenu->AddItem(item=new BMenuItem(fOptions->FileTypes[i]->Name->String(),msg));
  item->SetTarget(this);
 }

 fFTHFT= new BMenuField(BRect(10,15,210,30),"FileTypesMenu",fOptions->GetLocaleString("Preferences_Window_FileTypes","Filetype"),fFTFTMenu);
 fFTHFT->SetDivider(100);
 fFTHFTBox->AddChild(fFTHFT);

 fFTHFC= new BMenuField(BRect(10,40,210,65),"FileTypesMenu",fOptions->GetLocaleString("Preferences_Window_FileTypes","Syntax styles"),new BMenu(""));
 fFTHFC->SetDivider(100);
 fFTHFTBox->AddChild(fFTHFC);
 
  // - Font
 fFTHFontColor=0;
 fFTHFontBox= new BBox(BRect(10,80,230,130));
 fFTHFontBox->SetLabel(fOptions->GetLocaleString("Preferences_Window_FileTypes","Font"));
 fFTHFontBox->SetFont(new BFont(be_plain_font));
 fFTHFTBox->AddChild(fFTHFontBox);

 fFTHStyle= new BMenuField(BRect(10,15,210,40),"Size",fOptions->GetLocaleString("Preferences_Window_FileTypes","Style"),new BMenu("Style"));
 fFTHFontBox->AddChild(fFTHStyle);


  // - Color
 
 fFTHColorBox= new BBox(BRect(10,150,300,240));
 fFTHColorBox->SetLabel(fOptions->GetLocaleString("Preferences_Window_FileTypes","Color"));
 fFTHColorBox->SetFont(new BFont(be_plain_font));
 fFTHFTBox->AddChild(fFTHColorBox);

 fFTHCC = new BColorControl(BPoint(10,20),B_CELLS_32x8,1,"CC",new BMessage(R_FTH_Color_MSG));
 fFTHColorBox->AddChild(fFTHCC);

// - Default Folder
 fList->AddItem(new BStringItem(fOptions->GetLocaleString("Preferences_Window_List","Default Folder")));

 fJView[3] = new BView(fView->Bounds(),"OpenSaveView",B_FOLLOW_TOP_BOTTOM,B_WILL_DRAW);
 fJView[3]->SetViewColor(216,216,216,0);
 fView->AddChild(fJView[3]);

 fDFDefaultFolder = new BTextControl(BRect(10,10,260,30),"DFDefaultFolder",fOptions->GetLocaleString("Preferences_Window_DefaultFolder","Default Folder"),fOptions->DefaultFolder.String(),new BMessage('DFFN'));
 fDFDefaultFolder->SetDivider(100);
 fJView[3]->AddChild(fDFDefaultFolder);

 BButton *fDFButton = new BButton(BRect(270,8,330,30),"DFButton",fOptions->GetLocaleString("Preferences_Window_DefaultFolder","Browse"),new BMessage('DFBB'));
 fJView[3]->AddChild(fDFButton);
 fDFFilePanel = new BFilePanel(B_OPEN_PANEL,new BMessenger(this,this), NULL,
				   B_DIRECTORY_NODE, false,new BMessage('DFFP'));
 fDFCheckBox = new BCheckBox(BRect(150,40,280,60),"DFCheckBox",fOptions->GetLocaleString("Preferences_Window_DefaultFolder","Only Start"),new BMessage('DFCK'));
 fJView[3]->AddChild(fDFCheckBox);
 fDFCheckBox->SetValue(fOptions->DFOnlyStart);

// - Advanced Prefs
 fList->AddItem(new BStringItem(fOptions->GetLocaleString("Preferences_Window_List","Advanced preferences")));

 fJView[4] = new BView(fView->Bounds(),"AdvancedPrefs",B_FOLLOW_TOP_BOTTOM,B_WILL_DRAW);
 fJView[4]->SetViewColor(216,216,216,0);
 fView->AddChild(fJView[4]);
 
 fAPSlider = new BSlider(BRect(10,10,330,50),"slider",fOptions->GetLocaleString("Preferences_Window_AdvancedPrefs","Parameter-Menu reaction time"),new BMessage('APRT'), 0, 1000);
 fAPSlider->SetLimitLabels("0ms", "1000ms");
 fAPSlider->SetValue(fOptions->ReakcioIdo);
 fAPSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
 fAPSlider->SetHashMarkCount(5);
 fJView[4]->AddChild(fAPSlider);

 fAPTMSlider = new BSlider(BRect(10,100,330,150),"slider",fOptions->GetLocaleString("Preferences_Window_AdvancedPrefs","Tag-Menu reaction time"),new BMessage('APTM'), 0, 3000);
 fAPTMSlider->SetLimitLabels("0ms", "3000ms");
 fAPTMSlider->SetValue(fOptions->ReakcioIdo);
 fAPTMSlider->SetHashMarks(B_HASH_MARKS_BOTTOM);
 fAPTMSlider->SetHashMarkCount(5);
 fJView[4]->AddChild(fAPTMSlider);

 // -
 FTHSetFT(0);

 fList->Select(0);
 for (uint i=0;i<JViewDb;i++)fJView[i]->ResizeTo(0,0);
 fJView[0]->ResizeTo(fView->Bounds().right,fView->Bounds().bottom);
}
Example #20
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 #21
0
MainWindow::MainWindow(BRect frame)
	:	BWindow(frame,B_TRANSLATE_SYSTEM_NAME("BeMines"),B_TITLED_WINDOW, B_NOT_RESIZABLE),
		fSmileyState(FACE_NORMAL)
{
	LoadSettings();

	BView *top = new BView(Bounds(),"back",B_FOLLOW_ALL,B_WILL_DRAW);
	top->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	AddChild(top);

	BRect r(Bounds());
	r.bottom = 20;
	fMenuBar = new BMenuBar(r, "menubar");

	BMenu *menu = new BMenu(B_TRANSLATE("Game"));
	menu->AddItem(new BMenuItem(B_TRANSLATE("New"),new BMessage(M_NEW_GAME),'N'));

	BMenu *submenu = NULL;

	menu->AddItem(new BMenuItem(B_TRANSLATE("Pause"),new BMessage(M_PAUSE_GAME),'P',
								B_COMMAND_KEY));

	menu->AddSeparatorItem();

	menu->AddItem(new BMenuItem(B_TRANSLATE("High scores"),new BMessage(M_SHOW_SCORES)));

	menu->AddSeparatorItem();

	menu->AddItem(new BMenuItem(B_TRANSLATE("Help"),new BMessage(M_SHOW_HELP)));
	menu->AddItem(new BMenuItem(B_TRANSLATE("About BeMines"),new BMessage(B_ABOUT_REQUESTED)));

	menu->AddSeparatorItem();

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

	fMenuBar->AddItem(menu);

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

	submenu = new BMenu(B_TRANSLATE("Difficulty"));

	BMessage *menumsg = new BMessage(M_SET_DIFFICULTY);
	menumsg->AddInt32("level",DIFFICULTY_BEGINNER);
	submenu->AddItem(new BMenuItem(B_TRANSLATE("Beginner"),menumsg));

	menumsg = new BMessage(M_SET_DIFFICULTY);
	menumsg->AddInt32("level",DIFFICULTY_INTERMEDIATE);
	submenu->AddItem(new BMenuItem(B_TRANSLATE("Intermediate"),menumsg));

	menumsg = new BMessage(M_SET_DIFFICULTY);
	menumsg->AddInt32("level",DIFFICULTY_EXPERT);
	submenu->AddItem(new BMenuItem(B_TRANSLATE("Expert"),menumsg));

	menumsg = new BMessage(M_SHOW_CUSTOM);
	submenu->AddItem(new BMenuItem(B_TRANSLATE("Custom" B_UTF8_ELLIPSIS),menumsg));
	menu->AddItem(submenu);

	BMenuItem *item = submenu->ItemAt(gDifficulty);
	if (item)
		item->SetMarked(true);

	submenu = new BMenu(B_TRANSLATE("Theme"));
	for (int32 i = 0; i < gGameStyle->CountStyles(); i++)
	{
		menumsg = new BMessage(M_SET_THEME);
		menumsg->AddString("name",gGameStyle->StyleAt(i));
		submenu->AddItem(new BMenuItem(TranslateWellKnownThemes(gGameStyle->StyleAt(i)),menumsg));
	}
	menu->AddItem(submenu);
	submenu->SetRadioMode(true);
	item = submenu->FindItem(TranslateWellKnownThemes(gGameStyle->StyleName()));
	if (item)
		item->SetMarked(true);

	menu->AddSeparatorItem();

	item = new BMenuItem(B_TRANSLATE("Sound effects"),new BMessage(M_TOGGLE_SOUNDS));
	menu->AddItem(item);
	item->SetMarked(gPlaySounds);

	fMenuBar->AddItem(menu);

	top->AddChild(fMenuBar);

	fCounterView = new CounterView();
	fCounterView->MoveTo(10,fMenuBar->Frame().bottom + 10);
	top->AddChild(fCounterView);

	r = gGameStyle->SmileyUp()->Bounds();
	fSmileyButton = new BitmapButton(r,"smiley",gGameStyle->SmileyUp(),
									gGameStyle->SmileyDown(), new BMessage(M_NEW_GAME),false,
									B_FOLLOW_TOP | B_FOLLOW_H_CENTER);
	top->AddChild(fSmileyButton);

	fTimerView = new TimerView();
	fTimerView->SetResizingMode(B_FOLLOW_RIGHT | B_FOLLOW_TOP);
	top->AddChild(fTimerView);

	fFieldView = new FieldView(gDifficulty);
	top->AddChild(fFieldView);
	fFieldView->MakeFocus(true);

	fCounterView->SetCount(fFieldView->MineCount());
	ResetLayout();

	AddCommonFilter(new SpaceBarFilter(M_NEW_GAME));
}
Example #22
0
TemplateWindow::TemplateWindow(const BRect &frame)
	:	DWindow(frame,TR("Choose a Project Type"),B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS |
				B_NOT_V_RESIZABLE)
{
	RegisterWindow();
	
	MakeCenteredOnShow(true);
	
	CheckTemplates();
	
	DPath templatePath(gAppPath.GetFolder());
	templatePath << TR("Templates");
	fTempList.ScanFolder(templatePath.GetFullPath());
	
	BView *top = GetBackgroundView();
	
	if (Bounds().Height() < 100)
		ResizeTo(Bounds().Width(),100);
	if (Bounds().Width() < 100)
		ResizeTo(100,Bounds().Height());
	
	BRect r(Bounds());
	BRect bounds(r);
	
	float divider = be_plain_font->StringWidth(TR("Source Control:")) + 5.0;
	
	BMenu *menu = new BMenu("Project Type");
	for (int32 i = 0; i < fTempList.CountTemplates(); i++)
	{
		ProjectTemplate *ptemp = fTempList.TemplateAt(i);
		entry_ref ref = ptemp->GetRef();
		menu->AddItem(new BMenuItem(ref.name,new BMessage(M_TEMPLATE_SELECTED)));
	}
	
	menu->SetRadioMode(true);
	menu->SetLabelFromMarked(true);
	menu->ItemAt(0L)->SetMarked(true);
	
	font_height fh;
	be_plain_font->GetHeight(&fh);
	float fontHeight = fh.ascent + fh.descent + fh.leading;
	r.bottom = MAX(fontHeight,20.0);
	
	r.OffsetBy(10,10);
	fTemplateField = new BMenuField(r,"templatefield",TR("Project Type: "), menu);
	fTemplateField->SetDivider(be_plain_font->StringWidth(TR("Project Type:")) + 5);
	top->AddChild(fTemplateField);
	
	// controls for the options for all project types
	r.OffsetBy(0,r.IntegerHeight() + 10);
	fNameBox = new AutoTextControl(r,"namebox",TR("Project Name:"),NULL,
									new BMessage(M_NAME_CHANGED),
									B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
	top->AddChild(fNameBox);
	fNameBox->ResizeToPreferred();
	r.bottom = r.top + fNameBox->Bounds().Height();
	fNameBox->ResizeTo(bounds.Width() - 20.0,r.Height());
	fNameBox->SetDivider(divider);
	SetToolTip(fNameBox, "The name of your project. It can be the same as the Target Name, "
						"but it does not have to be.");
	
	r.OffsetBy(0,r.IntegerHeight() + 10);
	fTargetBox = new AutoTextControl(r,"targetbox",TR("Target Name:"),"BeApp",
									new BMessage(M_TARGET_CHANGED),
									B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
	top->AddChild(fTargetBox);
	fTargetBox->ResizeToPreferred();
	r.bottom = r.top + fTargetBox->Bounds().Height();
	fTargetBox->ResizeTo(bounds.Width() - 20.0,r.Height());
	fTargetBox->SetDivider(divider);
	SetToolTip(fTargetBox, "The name of the compiled application or library");
	
	if (!BEntry(PROJECT_PATH).Exists())
		create_directory(PROJECT_PATH,0777);
	
	r.OffsetBy(0,r.Height() + 10);
	fPathBox = new PathBox(r,"pathbox",gProjectPath.GetFullPath(),TR("Location:"),
							B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
	top->AddChild(fPathBox);
	fPathBox->ResizeToPreferred();
	r.bottom = r.top + fPathBox->Bounds().Height();
	fPathBox->ResizeTo(bounds.Width() - 20.0,r.Height());
	fPathBox->SetDivider(divider);
	SetToolTip(fPathBox, "Set the location for your project.");
	
	menu = new BMenu("SCM Chooser");
	menu->AddItem(new BMenuItem("Mercurial", new BMessage()));
	menu->AddItem(new BMenuItem("Git", new BMessage()));
	menu->AddItem(new BMenuItem("Subversion", new BMessage()));
	menu->AddItem(new BMenuItem("None", new BMessage()));
	
	if (!gHgAvailable)
	{
		menu->ItemAt(0)->SetEnabled(false);
		menu->ItemAt(0)->SetLabel("Mercurial Unavailable");
	}
	
	if (!gGitAvailable)
	{
		menu->ItemAt(1)->SetEnabled(false);
		menu->ItemAt(1)->SetLabel("Git Unavailable");
	}
	
	if (!gSvnAvailable)
	{
		menu->ItemAt(2)->SetEnabled(false);
		menu->ItemAt(2)->SetLabel("Subversion Unavailable");
	}
	
	
	r.OffsetBy(0,r.Height() + 5.0);
	fSCMChooser = new BMenuField(r, "scmchooser", "Source Control: ", menu);
	top->AddChild(fSCMChooser);
	fSCMChooser->SetDivider(divider);
	SetToolTip(fSCMChooser, "Choose the source control manager for your project, if any.");
	
	menu->SetLabelFromMarked(true);
	menu->ItemAt(gDefaultSCM)->SetMarked(true);
	
	BMenuItem *item = menu->FindMarked();
	if (!item->IsEnabled())
	{
		item->SetMarked(false);
		for (int32 i = 0; i < menu->CountItems(); i++)
		{
			if (menu->ItemAt(i)->IsEnabled())
			{
				menu->ItemAt(i)->SetMarked(true);
				break;
			}
		}
	}
	menu->SetLabelFromMarked(true);
	
	r.OffsetBy(0,r.Height() + 5.0);
	fCreateFolder = new BCheckBox(r,"createfolder",TR("Create Project Folder"),NULL);
	fCreateFolder->MoveTo(divider + 10.0, r.top);
	fCreateFolder->SetValue(B_CONTROL_ON);
	top->AddChild(fCreateFolder);
	SetToolTip(fCreateFolder, "If checked, a folder for your project will be created "
							"in the folder in the Location box above.");
	
	r.OffsetBy(0,r.Height() + 5.0);
	fOK = new BButton(r,"ok",TR("Create Project…"), new BMessage(M_CREATE_PROJECT));
	fOK->ResizeToPreferred();
	top->AddChild(fOK);
	fOK->SetEnabled(false);
	fOK->MakeDefault(true);
	
	float offset = fPathBox->Divider();
	fOK->MoveBy(offset,0);
	
	float minwidth = Bounds().Width();
	float minheight = fOK->Frame().bottom + 10.0;
	SetSizeLimits(minwidth,30000,minheight,30000);
	
	gSettings.Lock();
	BRect savedframe;
	if (gSettings.FindRect("template_frame",&savedframe) == B_OK)
		ResizeTo(savedframe.Width(),savedframe.Height());
	else
		ResizeTo(minwidth,minheight);
	gSettings.Unlock();
		
	fNameBox->MakeFocus(true);
}
Example #23
0
BMenuBar*
MainWindow::_CreateMenuBar()
{
    BMenuBar* menuBar = new BMenuBar("main menu");


#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "Icon-O-Matic-Menus"


    BMenu* fileMenu = new BMenu(B_TRANSLATE("File"));
    BMenu* editMenu = new BMenu(B_TRANSLATE("Edit"));
    BMenu* settingsMenu = new BMenu(B_TRANSLATE("Settings"));
    fPathMenu = new BMenu(B_TRANSLATE("Path"));
    fStyleMenu = new BMenu(B_TRANSLATE("Style"));
    fShapeMenu = new BMenu(B_TRANSLATE("Shape"));
    fTransformerMenu = new BMenu(B_TRANSLATE("Transformer"));
    fPropertyMenu = new BMenu(B_TRANSLATE("Properties"));
    fSwatchMenu = new BMenu(B_TRANSLATE("Swatches"));

    menuBar->AddItem(fileMenu);
    menuBar->AddItem(editMenu);
    menuBar->AddItem(settingsMenu);


    // File
#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "Icon-O-Matic-Menu-File"


    BMenuItem* item = new BMenuItem(B_TRANSLATE("New"),
                                    new BMessage(MSG_NEW), 'N');
    fileMenu->AddItem(item);
    item->SetTarget(be_app);
    item = new BMenuItem(B_TRANSLATE("Open" B_UTF8_ELLIPSIS),
                         new BMessage(MSG_OPEN), 'O');
    fileMenu->AddItem(item);
    BMessage* appendMessage = new BMessage(MSG_APPEND);
    appendMessage->AddPointer("window", this);
    item = new BMenuItem(B_TRANSLATE("Append" B_UTF8_ELLIPSIS),
                         appendMessage, 'O', B_SHIFT_KEY);
    fileMenu->AddItem(item);
    item->SetTarget(be_app);
    fileMenu->AddSeparatorItem();
    fileMenu->AddItem(new BMenuItem(B_TRANSLATE("Save"),
                                    new BMessage(MSG_SAVE), 'S'));
    fileMenu->AddItem(new BMenuItem(B_TRANSLATE("Save as" B_UTF8_ELLIPSIS),
                                    new BMessage(MSG_SAVE_AS), 'S', B_SHIFT_KEY));
    fileMenu->AddSeparatorItem();
    fileMenu->AddItem(new BMenuItem(B_TRANSLATE("Export"),
                                    new BMessage(MSG_EXPORT), 'P'));
    fileMenu->AddItem(new BMenuItem(B_TRANSLATE("Export as" B_UTF8_ELLIPSIS),
                                    new BMessage(MSG_EXPORT_AS), 'P', B_SHIFT_KEY));
    fileMenu->AddSeparatorItem();
    fileMenu->AddItem(new BMenuItem(B_TRANSLATE("Close"),
                                    new BMessage(B_QUIT_REQUESTED), 'W'));
    item = new BMenuItem(B_TRANSLATE("Quit"),
                         new BMessage(B_QUIT_REQUESTED), 'Q');
    fileMenu->AddItem(item);
    item->SetTarget(be_app);

    // Edit
#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "Icon-O-Matic-Menu-Edit"


    fUndoMI = new BMenuItem(B_TRANSLATE("<nothing to undo>"),
                            new BMessage(MSG_UNDO), 'Z');
    fRedoMI = new BMenuItem(B_TRANSLATE("<nothing to redo>"),
                            new BMessage(MSG_REDO), 'Z', B_SHIFT_KEY);

    fUndoMI->SetEnabled(false);
    fRedoMI->SetEnabled(false);

    editMenu->AddItem(fUndoMI);
    editMenu->AddItem(fRedoMI);


    // Settings
#undef B_TRANSLATION_CONTEXT
#define B_TRANSLATION_CONTEXT "Icon-O-Matic-Menu-Settings"


    BMenu* filterModeMenu = new BMenu(B_TRANSLATE("Snap to grid"));
    BMessage* message = new BMessage(MSG_MOUSE_FILTER_MODE);
    message->AddInt32("mode", SNAPPING_OFF);
    fMouseFilterOffMI = new BMenuItem(B_TRANSLATE("Off"), message, '4');
    filterModeMenu->AddItem(fMouseFilterOffMI);

    message = new BMessage(MSG_MOUSE_FILTER_MODE);
    message->AddInt32("mode", SNAPPING_64);
    fMouseFilter64MI = new BMenuItem("64 x 64", message, '3');
    filterModeMenu->AddItem(fMouseFilter64MI);

    message = new BMessage(MSG_MOUSE_FILTER_MODE);
    message->AddInt32("mode", SNAPPING_32);
    fMouseFilter32MI = new BMenuItem("32 x 32", message, '2');
    filterModeMenu->AddItem(fMouseFilter32MI);

    message = new BMessage(MSG_MOUSE_FILTER_MODE);
    message->AddInt32("mode", SNAPPING_16);
    fMouseFilter16MI = new BMenuItem("16 x 16", message, '1');
    filterModeMenu->AddItem(fMouseFilter16MI);

    filterModeMenu->SetRadioMode(true);

    settingsMenu->AddItem(filterModeMenu);

    return menuBar;
}
Example #24
0
void
ShowImageWindow::_BuildViewMenu(BMenu *menu, bool popupMenu)
{
	_AddItemMenu(menu, "Slide show", MSG_SLIDE_SHOW, 0, 0, this);
	_MarkMenuItem(menu, MSG_SLIDE_SHOW, fImageView->SlideShowStarted());
	BMenu* delayMenu = new BMenu("Slide delay");
	if (fSlideShowDelay == NULL)
		fSlideShowDelay = delayMenu;

	delayMenu->SetRadioMode(true);
	// Note: ShowImage loads images in window thread so it becomes unresponsive
	//		 if slide show delay is too short! (Especially if loading the image
	//		 takes as long as or longer than the slide show delay). Should load
	//		 in background thread!
	_AddDelayItem(delayMenu, "3 seconds", 3);
	_AddDelayItem(delayMenu, "4 seconds", 4);
	_AddDelayItem(delayMenu, "5 seconds", 5);
	_AddDelayItem(delayMenu, "6 seconds", 6);
	_AddDelayItem(delayMenu, "7 seconds", 7);
	_AddDelayItem(delayMenu, "8 seconds", 8);
	_AddDelayItem(delayMenu, "9 seconds", 9);
	_AddDelayItem(delayMenu, "10 seconds", 10);
	_AddDelayItem(delayMenu, "20 seconds", 20);
	menu->AddItem(delayMenu);

	menu->AddSeparatorItem();

	_AddItemMenu(menu, "Original size", MSG_ORIGINAL_SIZE, '1', 0, this);
	_AddItemMenu(menu, "Zoom in", MSG_ZOOM_IN, '+', 0, this);
	_AddItemMenu(menu, "Zoom out", MSG_ZOOM_OUT, '-', 0, this);

	menu->AddSeparatorItem();

	_AddItemMenu(menu, "High-quality zooming", MSG_SCALE_BILINEAR, 0, 0, this);

	menu->AddSeparatorItem();

	_AddItemMenu(menu, "Shrink to window", MSG_SHRINK_TO_WINDOW, 0, 0, this);
	_AddItemMenu(menu, "Zoom to window", MSG_ZOOM_TO_WINDOW, 0, 0, this);

	menu->AddSeparatorItem();

	_AddItemMenu(menu, "Full screen", MSG_FULL_SCREEN, B_ENTER, 0, this);
	_MarkMenuItem(menu, MSG_FULL_SCREEN, fFullScreen);

	_AddItemMenu(menu, "Show caption in full screen mode", MSG_SHOW_CAPTION, 0,
		0, this);
	_MarkMenuItem(menu, MSG_SHOW_CAPTION, fShowCaption);

	_MarkMenuItem(menu, MSG_SCALE_BILINEAR, fImageView->GetScaleBilinear());

	bool shrink, zoom, enabled;

	shrink = fImageView->GetShrinkToBounds();
	zoom = fImageView->GetZoomToBounds();
	_MarkMenuItem(menu, MSG_SHRINK_TO_WINDOW, shrink);
	_MarkMenuItem(menu, MSG_ZOOM_TO_WINDOW, zoom);

	enabled = !(shrink || zoom);
	_EnableMenuItem(menu, MSG_ORIGINAL_SIZE, enabled);
	_EnableMenuItem(menu, MSG_ZOOM_IN, enabled);
	_EnableMenuItem(menu, MSG_ZOOM_OUT, enabled);

	if (popupMenu) {
		menu->AddSeparatorItem();
		_AddItemMenu(menu, "Use as background" B_UTF8_ELLIPSIS, MSG_DESKTOP_BACKGROUND, 0, 0,
			this);
	}
}
Example #25
0
int
main(int argc, char** argv)
{
	BApplication app("application/x-vnd.antares-look");

	BWindow* window = new Window(BRect(50, 50, 100, 100),
		"Look at these pretty controls!", B_TITLED_WINDOW,
		B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS
			| B_QUIT_ON_WINDOW_CLOSE);

	window->SetLayout(new BGroupLayout(B_HORIZONTAL));

	// create some controls

	// BListView
	BListView* listView = new BListView();
	for (int32 i = 0; i < 20; i++) {
		BString itemLabel("List item ");
		itemLabel << i + 1;
		listView->AddItem(new BStringItem(itemLabel.String()));
	}
	BScrollView* scrollView = new BScrollView("scroller", listView, 0,
		true, true);
	scrollView->SetExplicitMinSize(BSize(300, 140));

	// BColumnListView
	BColumnListView* columnListView = new BColumnListView("clv", 0,
		B_FANCY_BORDER);
//	for (int32 i = 0; i < 20; i++) {
//		BString itemLabel("List Item ");
//		itemLabel << i + 1;
//		columnListView->AddItem(new BStringItem(itemLabel.String()));
//	}


	BGridView* controls = new BGridView(kInset, kInset);
	BGridLayout* layout = controls->GridLayout();
	controls->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED));

	int32 row = 0;
	add_controls<BButton>(layout, row);
	add_controls<BCheckBox>(layout, row);
	add_controls<BRadioButton>(layout, row);
	add_menu_fields(layout, row);
	add_text_controls(layout, row);
	add_sliders(layout, row);
	add_status_bars(layout, row);

	BColorControl* colorControl = new BColorControl(B_ORIGIN, B_CELLS_32x8,
		8.0f, "color control");
	layout->AddView(colorControl, 0, row, 4);

	BTabView* tabView = new BTabView("tab view", B_WIDTH_FROM_WIDEST);
	BView* content = BGroupLayoutBuilder(B_VERTICAL, kInset)
		.Add(scrollView)
		.Add(columnListView)
		.Add(controls)
		.SetInsets(kInset, kInset, kInset, kInset);

	content->SetName("Tab 1");

	tabView->AddTab(content);
	BView* tab2 = new BView("Tab 2", 0);
	tab2->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	tabView->AddTab(tab2);
	tabView->AddTab(new BView("Tab 3", 0));

	BMenuBar* menuBar = new BMenuBar("menu bar");
	BMenu* menu = new BMenu("File");
	menu->AddItem(new BMenuItem("Test Open BFilePanel",
		new BMessage(MSG_TEST_OPEN_FILE_PANEL)));
	menu->AddItem(new BMenuItem("Test Save BFilePanel",
		new BMessage(MSG_TEST_SAVE_FILE_PANEL)));
	menu->AddItem(new BMenuItem("Click me!", NULL));
	menu->AddItem(new BMenuItem("Another option", NULL));
	menu->AddSeparatorItem();
	menu->AddItem(new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED)));
	menuBar->AddItem(menu);
	menu = new BMenu("Edit");
	menu->SetEnabled(false);
	menu->AddItem(new BMenuItem("Cut", NULL));
	menu->AddItem(new BMenuItem("Copy", NULL));
	menu->AddSeparatorItem();
	menu->AddItem(new BMenuItem("Past", NULL));
	menuBar->AddItem(menu);
	menu = new BMenu("One Item");
	menu->AddItem(new BMenuItem("Only", NULL));
	menuBar->AddItem(menu);
	menu = new BMenu("Sub Menu");
	BMenu* subMenu = new BMenu("Click me");
	subMenu->AddItem(new BMenuItem("Either", NULL));
	subMenu->AddItem(new BMenuItem("Or", NULL));
	subMenu->SetRadioMode(true);
	menu->AddItem(subMenu);
	menuBar->AddItem(menu);

	BButton* okButton = new BButton("OK", new BMessage(B_QUIT_REQUESTED));

	window->AddChild(BGroupLayoutBuilder(B_VERTICAL)
		.Add(menuBar)
		.Add(BGroupLayoutBuilder(B_VERTICAL, kInset)
			.Add(tabView)
			.Add(BGroupLayoutBuilder(B_HORIZONTAL, kInset)
				.Add(new BButton("Revert", new BMessage(MSG_TOGGLE_LOOK)))
				.Add(BSpaceLayoutItem::CreateGlue())
				.Add(new BButton("Cancel", NULL))
				.Add(okButton)
			)
			.SetInsets(kInset, kInset, kInset, kInset)
		)
	);

	window->SetDefaultButton(okButton);

	window->Show();
	app.Run();
	return 0;
}
Example #26
0
void
ShowImageWindow::_BuildViewMenu(BMenu* menu, bool popupMenu)
{
	_AddItemMenu(menu, B_TRANSLATE("Slide show"), MSG_SLIDE_SHOW, 0, 0, this);
	_MarkMenuItem(menu, MSG_SLIDE_SHOW, fSlideShowRunner != NULL);
	BMenu* delayMenu = new BMenu(B_TRANSLATE("Slide delay"));
	if (fSlideShowDelayMenu == NULL)
		fSlideShowDelayMenu = delayMenu;

	delayMenu->SetRadioMode(true);

	int32 kDelays[] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 20};
	for (uint32 i = 0; i < sizeof(kDelays) / sizeof(kDelays[0]); i++) {
		BString text;
		BDurationFormat format;
		text.Truncate(0);
		format.Format(text, 0, kDelays[i] * 1000000LL);

		_AddDelayItem(delayMenu, text.String(), kDelays[i] * 1000000LL);
	}
	menu->AddItem(delayMenu);

	menu->AddSeparatorItem();

	_AddItemMenu(menu, B_TRANSLATE("Original size"),
		kMsgOriginalSize, '1', 0, this);
	_AddItemMenu(menu, B_TRANSLATE("Fit to window"),
		kMsgFitToWindow, '0', 0, this);
	_AddItemMenu(menu, B_TRANSLATE("Zoom in"), MSG_ZOOM_IN, '+', 0, this);
	_AddItemMenu(menu, B_TRANSLATE("Zoom out"), MSG_ZOOM_OUT, '-', 0, this);

	menu->AddSeparatorItem();

	if (!popupMenu || fFullScreen) {
		_AddItemMenu(menu, B_TRANSLATE("High-quality zooming"),
			MSG_SCALE_BILINEAR, 0, 0, this);
		_AddItemMenu(menu, B_TRANSLATE("Stretch to window"),
			kMsgStretchToWindow, 0, 0, this);

		menu->AddSeparatorItem();
	}

	_AddItemMenu(menu, B_TRANSLATE("Full screen"),
		MSG_FULL_SCREEN, B_ENTER, 0, this);
	_MarkMenuItem(menu, MSG_FULL_SCREEN, fFullScreen);

	_AddItemMenu(menu, B_TRANSLATE("Show caption in full screen mode"),
		MSG_SHOW_CAPTION, 0, 0, this);
	_MarkMenuItem(menu, MSG_SHOW_CAPTION, fShowCaption);

	_MarkMenuItem(menu, MSG_SCALE_BILINEAR, fImageView->ScaleBilinear());
	_MarkMenuItem(menu, kMsgStretchToWindow, fImageView->StretchesToBounds());

	if (!popupMenu) {
		_AddItemMenu(menu, B_TRANSLATE("Show tool bar"), kMsgToggleToolBar,
			'B', 0, this);
		_MarkMenuItem(menu, kMsgToggleToolBar,
			!fToolBar->IsHidden(fToolBar));
	}

	if (popupMenu) {
		menu->AddSeparatorItem();
		_AddItemMenu(menu, B_TRANSLATE("Use as background" B_UTF8_ELLIPSIS),
			MSG_DESKTOP_BACKGROUND, 0, 0, this);
	}
}
void
TextDocumentTest::_UpdateFontmenus(bool setInitialfont)
{
	BFont font = BFont();
	BMenu* stylemenu = NULL;

	font_family fontFamilyName, currentFamily;
	font_style fontStyleName, currentStyle;

	//GetFont(&font);
	font.GetFamilyAndStyle(&currentFamily, &currentStyle);

	const int32 fontfamilies = count_font_families();

	fFontFamilyMenu->RemoveItems(0, fFontFamilyMenu->CountItems(), true);

	for (int32 i = 0; i < fontfamilies; i++) {
		if (get_font_family(i, &fontFamilyName) == B_OK) {
			stylemenu = new BPopUpMenu(fontFamilyName);
			stylemenu->SetLabelFromMarked(false);
			const int32 styles = count_font_styles(fontFamilyName);
			//TODO change msg.. to a suitable msg
			BMessage* familyMsg = new BMessage('todo');
			familyMsg->AddString("_family", fontFamilyName);
			BMenuItem* familyItem = new BMenuItem(stylemenu, familyMsg);
			fFontFamilyMenu->AddItem(familyItem);

			for (int32 j = 0; j < styles; j++) {
				if (get_font_style(fontFamilyName, j, &fontStyleName) == B_OK) {
					//TODO change msg.. to a suitable msg
					BMessage* fontMsg = new BMessage('todo');
					fontMsg->AddString("_family", fontFamilyName);
					fontMsg->AddString("_style", fontStyleName);

					BMenuItem* styleItem = new BMenuItem(fontStyleName, fontMsg);
					styleItem->SetMarked(false);

					// setInitialfont is used when we attach the FontField
					if (!strcmp(fontStyleName, currentStyle)
						&& !strcmp(fontFamilyName, currentFamily)
						&& setInitialfont) {
						styleItem->SetMarked(true);
						familyItem->SetMarked(true);

						BString string;
						string << currentFamily << " " << currentStyle;

						if (fFontMenuField)
							fFontMenuField->MenuItem()->SetLabel(string.String());
					}
					stylemenu->AddItem(styleItem);
				}
			}

			stylemenu->SetRadioMode(true);
			stylemenu->SetTargetForItems(this);
		}
	}

	fFontFamilyMenu->SetLabelFromMarked(false);
	fFontFamilyMenu->SetTargetForItems(this);
}
Example #28
0
void
HWindow::InitGUI()
{
	fEventList = new HEventList();
	fEventList->SetType(BMediaFiles::B_SOUNDS);
	fEventList->SetSelectionMode(B_SINGLE_SELECTION_LIST);

	BGroupView* view = new BGroupView();
	BBox* box = new BBox("", B_WILL_DRAW | B_FRAME_EVENTS
		| B_NAVIGABLE_JUMP | B_PULSE_NEEDED);

	BMenu* menu = new BMenu("file");
	menu->SetRadioMode(true);
	menu->SetLabelFromMarked(true);
	menu->AddSeparatorItem();
	menu->AddItem(new BMenuItem(B_TRANSLATE("<none>"),
		new BMessage(M_NONE_MESSAGE)));
	menu->AddItem(new BMenuItem(B_TRANSLATE("Other" B_UTF8_ELLIPSIS),
		new BMessage(M_OTHER_MESSAGE)));

	BString label(B_TRANSLATE("Sound file:"));
	BMenuField* menuField = new BMenuField("filemenu", label, menu);
	menuField->SetDivider(menuField->StringWidth(label) + 10);

	BButton* stopbutton = new BButton("stop", B_TRANSLATE("Stop"),
		new BMessage(M_STOP_MESSAGE));
	stopbutton->SetEnabled(false);

	BButton* playbutton = new BButton("play", B_TRANSLATE("Play"),
		new BMessage(M_PLAY_MESSAGE));
	playbutton->SetEnabled(false);

	const float kInset = be_control_look->DefaultItemSpacing();
	view->SetLayout(new BGroupLayout(B_HORIZONTAL));
	view->AddChild(BGroupLayoutBuilder(B_VERTICAL, kInset)
		.AddGroup(B_HORIZONTAL)
			.Add(menuField)
			.AddGlue()
		.End()
		.AddGroup(B_HORIZONTAL, kInset)
			.AddGlue()
			.Add(playbutton)
			.Add(stopbutton)
		.End()
		.SetInsets(kInset, kInset, kInset, kInset)
	);

	box->AddChild(view);

	SetLayout(new BGroupLayout(B_HORIZONTAL));
	AddChild(BGroupLayoutBuilder(B_VERTICAL)
		.AddGroup(B_VERTICAL, kInset)
			.Add(fEventList)
			.Add(box)
		.End()
		.SetInsets(kInset, kInset, kInset, kInset)
	);

	// setup file menu
	SetupMenuField();
	BMenuItem* noneItem = menu->FindItem(B_TRANSLATE("<none>"));
	if (noneItem != NULL)
		noneItem->SetMarked(true);
}
Example #29
0
BMenuBar*
BoardWindow::_CreateMenuBar(void)
{
	BMenuBar* menuBar = new BMenuBar("BoardWindowMenuBar");
	BMenuItem*	menuItem;

	BMenu*	applicationMenu = new BMenu("Application");
	menuBar->AddItem(applicationMenu);
	BMenu*  newSubMenu = new BMenu("New");
	applicationMenu->AddItem(newSubMenu);
        menuItem = new BMenuItem("Blitz Game" B_UTF8_ELLIPSIS, NULL, 'B');
		newSubMenu->AddItem(menuItem);
		menuItem->SetEnabled(false);
        menuItem = new BMenuItem("Long Game" B_UTF8_ELLIPSIS, NULL, 'L');
		newSubMenu->AddItem(menuItem);
		menuItem->SetEnabled(false);
		newSubMenu->AddSeparatorItem();
        menuItem = new BMenuItem("Position Setup" B_UTF8_ELLIPSIS, NULL, 'P');
		newSubMenu->AddItem(menuItem);
		menuItem->SetEnabled(false);
        menuItem = new BMenuItem("Engine Match" B_UTF8_ELLIPSIS, NULL, 'E');
		newSubMenu->AddItem(menuItem);
		menuItem->SetEnabled(false);
		BMenu*  openSubMenu = new BMenu("Open");
		applicationMenu->AddItem(openSubMenu);
        menuItem = new BMenuItem("PGN File" B_UTF8_ELLIPSIS, NULL, 'O');
		openSubMenu->AddItem(menuItem);
		menuItem->SetEnabled(false);
        menuItem = new BMenuItem("Database" B_UTF8_ELLIPSIS, NULL, 'D');
		openSubMenu->AddItem(menuItem);
		menuItem->SetEnabled(false);

	applicationMenu->AddSeparatorItem();
	menuItem = new BMenuItem("Save" B_UTF8_ELLIPSIS, NULL, 'S');
    applicationMenu->AddItem(menuItem);
	menuItem->SetEnabled(false);
	applicationMenu->AddSeparatorItem();
    menuItem = new BMenuItem("Quit", new BMessage(MENU_APP_QUIT), 'Q');
	applicationMenu->AddItem(menuItem);

	BMenu*	editMenu = new BMenu("Edit");
	menuBar->AddItem(editMenu);

    menuItem = new BMenuItem("Copy Position", NULL, 'C');
	editMenu->AddItem(menuItem);
	menuItem->SetEnabled(false);
    menuItem = new BMenuItem("Paste Position", NULL, 'V');
	editMenu->AddItem(menuItem);
	menuItem->SetEnabled(false);

    editMenu->AddSeparatorItem();
    menuItem = new BMenuItem("Edit Game Data" B_UTF8_ELLIPSIS, NULL, 'E');
	editMenu->AddItem(menuItem);
	menuItem->SetEnabled(false);

	BMenu*	viewMenu = new BMenu("View");
	menuBar->AddItem(viewMenu);
    fFlipBoardMI = new BMenuItem("Flip Board", new BMessage(MENU_VIEW_FLIPBOARD));
    viewMenu->AddItem(fFlipBoardMI);
    fFlipBoardMI->SetShortcut('R', B_COMMAND_KEY);
    fFlipBoardMI->SetMarked(false);

	viewMenu->AddSeparatorItem();
    fMinIfMenuItem = new BMenuItem("Minimal Interface",
        new BMessage(MENU_VIEW_MININTERFACE), '1');
	f3DMI = new BMenuItem("3D", new BMessage(MENU_VIEW_3D));
    viewMenu->AddItem(f3DMI);
    f3DMI->SetShortcut('3', B_COMMAND_KEY);
    f3DMI->SetMarked(false);

    fFullScrMI = new BMenuItem("Fullscreen",
        new BMessage(MENU_VIEW_FULLSCREEN), 'F');
    viewMenu->AddItem(fFullScrMI);
    fFullScrMI->SetMarked(false);
    fFullScrMI->SetEnabled(true);
	viewMenu->AddSeparatorItem();
    fShowClockMenuItem = new BMenuItem("Show Clock",
        new BMessage(MENU_VIEW_SHOWCLOCK));
    viewMenu->AddItem(fShowClockMenuItem);
    fShowClockMenuItem->SetShortcut('T', B_COMMAND_KEY);
    fShowClockMenuItem->SetMarked(true);
    fShowMBarMenuItem = new BMenuItem("Show Menubar",
        new BMessage(MENU_VIEW_SHOWMENU));
	viewMenu->AddItem(fShowMBarMenuItem);
    fShowMBarMenuItem->SetShortcut('M', B_COMMAND_KEY);
    fShowMBarMenuItem->SetMarked(true);
    fSidebarMenuItem = new BMenuItem("Show Sidebar",
        new BMessage(MENU_VIEW_SIDEBAR));
    viewMenu->AddItem(fSidebarMenuItem);
    fSidebarMenuItem->SetShortcut('4', B_COMMAND_KEY);
    fSidebarMenuItem->SetMarked(true);
    fShowborderMenuItem = new BMenuItem("Show Window Frame",
        new BMessage(MENU_VIEW_SHOWBORDER));
    viewMenu->AddItem(fShowborderMenuItem);
    fShowborderMenuItem->SetShortcut('Y', B_COMMAND_KEY);
    fShowborderMenuItem->SetMarked(true);
    fAutohidingMenuItem = new BMenuItem("Autohiding",
        new BMessage(MENU_VIEW_AUTOHIDING));
    viewMenu->AddItem(fAutohidingMenuItem);
    fAutohidingMenuItem->SetShortcut('X', B_COMMAND_KEY);
    fAutohidingMenuItem->SetMarked(false);
    viewMenu->AddSeparatorItem();
    fAlwaysOnTopMenuItem = new BMenuItem("Always on top",
        new BMessage(MENU_VIEW_ALWAYSONTOP));
    viewMenu->AddItem(fAlwaysOnTopMenuItem);
    fAlwaysOnTopMenuItem->SetShortcut('A', B_COMMAND_KEY);
    fAlwaysOnTopMenuItem->SetMarked(false);
    //PostMessage(new BMessage(MENU_VIEW_AUTOHIDING));

	BMenu*	gameMenu = new BMenu("Game");
	menuBar->AddItem(gameMenu);
	gameMenu->AddItem(new BMenuItem("New Game",
        new BMessage(MENU_GAME_NEWGAME), 'N'));
	gameMenu->AddSeparatorItem();
    menuItem = new BMenuItem("Move Now", new BMessage(MENU_GAME_MOVENOW), ' ');
	gameMenu->AddItem(menuItem);
	menuItem->SetEnabled(true);
    menuItem = new BMenuItem("Repley" B_UTF8_ELLIPSIS, NULL);
	gameMenu->AddItem(menuItem);
	menuItem->SetEnabled(false);
	gameMenu->AddSeparatorItem();
		BMenu*  levelsSubMenu = new BMenu("Levels");
		levelsSubMenu->SetRadioMode(true);
		gameMenu->AddItem(levelsSubMenu);
        menuItem = new BMenuItem("Fixed depth" B_UTF8_ELLIPSIS, NULL);
		levelsSubMenu->AddItem(menuItem);
		menuItem->SetEnabled(false);
        menuItem = new BMenuItem("Fixed time" B_UTF8_ELLIPSIS, NULL);
		levelsSubMenu->AddItem(menuItem);
		menuItem->SetEnabled(false);
	gameMenu->AddSeparatorItem();
    fPauseMenuItem = new BMenuItem("Pause", NULL);
	gameMenu->AddItem(fPauseMenuItem);
	fPauseMenuItem->SetEnabled(false);
    menuItem = new BMenuItem("Offer Draw", NULL);
	gameMenu->AddItem(menuItem);
	menuItem->SetEnabled(false);
    menuItem = new BMenuItem("Resign", NULL, '0');
	gameMenu->AddItem(menuItem);
	menuItem->SetEnabled(false);

	BMenu*	engineMenu = new BMenu("Engine");
	menuBar->AddItem(engineMenu);
    menuItem = new BMenuItem("Change Engine" B_UTF8_ELLIPSIS, NULL);
	engineMenu->AddItem(menuItem);
	menuItem->SetEnabled(false);
    fEngineOffMenuItem = new BMenuItem("Switch off Engine",
        new BMessage(MENU_ENGINE_SOENGINE));
	engineMenu->AddItem(fEngineOffMenuItem);
	fEngineOffMenuItem->SetShortcut('P', B_COMMAND_KEY);
    fEngineOffMenuItem->SetEnabled(true);
    fEngineOffMenuItem->SetMarked(false);
	engineMenu->AddSeparatorItem();
    menuItem = new BMenuItem("Engine Management" B_UTF8_ELLIPSIS, NULL);
	engineMenu->AddItem(menuItem);
	menuItem->SetEnabled(false);

	BMenu*	toolsMenu = new BMenu("Tools");
	menuBar->AddItem(toolsMenu);
    menuItem = new BMenuItem("User Info" B_UTF8_ELLIPSIS, NULL);
	toolsMenu->AddItem(menuItem);
	menuItem->SetEnabled(false);
	toolsMenu->AddSeparatorItem();
    menuItem = new BMenuItem("Options" B_UTF8_ELLIPSIS, NULL);
	toolsMenu->AddItem(menuItem);
	menuItem->SetEnabled(false);
	toolsMenu->AddSeparatorItem();
    menuItem = new BMenuItem("Factory Settings" B_UTF8_ELLIPSIS, NULL);
	toolsMenu->AddItem(menuItem);
	menuItem->SetEnabled(false);

    //BMenu*  serverMenu = new BMenu("Server");
    //menuBar->AddItem(serverMenu);
    fICSConnectMI = new BMenuItem("Connect" B_UTF8_ELLIPSIS,
        new BMessage(MENU_SERVER_CONNECT));
   // serverMenu->AddItem(fICSConnectMI);
   // fICSConnectMI->SetShortcut('S', B_CONTROL_KEY);

	BMenu*	helpMenu = new BMenu("Help");
	menuBar->AddItem(helpMenu);

    fMoveAssistantMenuItem = new BMenuItem("Move Assistant",
        new BMessage(MENU_HELP_MOVEASSISTANT));
    helpMenu->AddItem(fMoveAssistantMenuItem);
    fMoveAssistantMenuItem->SetShortcut('J', B_COMMAND_KEY);
    fMoveAssistantMenuItem->SetMarked(false);
    menuItem = new BMenuItem("Hint" B_UTF8_ELLIPSIS,
        new BMessage(MENU_HELP_HINT), 'H');
	helpMenu->AddItem(menuItem);
	menuItem->SetEnabled(false);
	helpMenu->AddSeparatorItem();
    menuItem = new BMenuItem("Help" B_UTF8_ELLIPSIS,
        new BMessage(MENU_HELP_HELP));
	helpMenu->AddItem(menuItem);
	menuItem->SetEnabled(true);
	helpMenu->AddSeparatorItem();
    menuItem = new BMenuItem("About Puri" B_UTF8_ELLIPSIS,
        new BMessage(MENU_HELP_ABOUT));
	helpMenu->AddItem(menuItem);

	return menuBar;
}
Example #30
0
//------------------------------------------------------------------------------
void MenuEditor::AttachedToWindow()
{
	if (!fInit)
	{
		BRect rect(Frame());
		BRect frame(10, 110, rect.Width() - 10, 130);
		fLabelText = new BTextControl(frame, "label", "Label: ", "",
									  new BMessage(MSG_MENU_SET_ITEM_LABEL));
		fLabelText->SetDivider(be_plain_font->StringWidth("Label: "));
		fLabelText->SetEnabled(false);
		AddChild(fLabelText);

		char msg[5];
		msg[0] = 0;
		strcpy(msg,"none");
		/*if (((BControl *)(pointer))->Message() != NULL)
			strncpy(msg,(char *)(new int32(((BControl *)(pointer))->Message()->what)),4);*/

		frame.Set(10, 130, rect.Width() - 10, 150);
		fMsgText = new BTextControl(frame, "msg", "Message: ", msg,
									new BMessage(MSG_MENU_SET_ITEM_MSG));
		fMsgText->TextView()->SetMaxBytes(4);
		fMsgText->SetDivider(be_plain_font->StringWidth("Message: "));
		fMsgText->SetEnabled(false);
		AddChild(fMsgText);

		frame.Set(10, 150, be_plain_font->StringWidth("Shortcut: ") + 40, 170);
		fShortcutText = new BTextControl(frame, "shrtct", "Shortcut: ", "",
										 new BMessage(MSG_MENU_SET_ITEM_SHORTCUT));
		fShortcutText->SetDivider(be_plain_font->StringWidth("Shortcut: "));
		fShortcutText->SetEnabled(false);
		fShortcutText->TextView()->SetMaxBytes(1);
		AddChild(fShortcutText);

		BMenu *meniu = new BMenu("Modifier Keys");
		meniu->AddItem(new BMenuItem("Option", new BMessage(MSG_MENU_SET_ITEM_MARKED)));
		meniu->AddItem(new BMenuItem("Shift", new BMessage(MSG_MENU_SET_ITEM_MARKED)));
		meniu->AddItem(new BMenuItem("Control", new BMessage(MSG_MENU_SET_ITEM_MARKED)));
		frame.Set(be_plain_font->StringWidth("Shortcut: ") + 50, 150,
					rect.Width() - 10, 170);
		fModifierField = new BMenuField(frame, "modchoice", NULL, meniu);
		fModifierField->SetEnabled(false);
		meniu->SetRadioMode(false);
		meniu->SetLabelFromMarked(false);
		AddChild(fModifierField);

		frame.Set(10, 175, rect.Width() - 10, 195);
		fEnabledBox = new BCheckBox(frame, "enabled", "Enabled",
									new BMessage(MSG_MENU_SET_ITEM_ENABLED));
		fEnabledBox->SetEnabled(false);
		AddChild(fEnabledBox);

		frame.Set(10, 200, (rect.Width() / 2) - 10, 220);
		fAddItemBtn = new BButton(frame, "addiantem", "Add Item",
								  new BMessage(MSG_MENU_NEW_ITEM));
		AddChild(fAddItemBtn);
		frame.Set((rect.Width() / 2) + 10, 200, rect.Width() - 10, 220);
		fAddSeparatorBtn = new BButton(frame, "addsepitem", "Add Separator",
									   new BMessage(MSG_MENU_ADD_SEPARATOR));
		AddChild(fAddSeparatorBtn);
	}

	fListView->SetTarget(this);
	fLabelText->SetTarget(this);
	fMsgText->SetTarget(this);
	fShortcutText->SetTarget(this);
	fModifierField->Menu()->SetTargetForItems(this);
	fEnabledBox->SetTarget(this);
	fAddItemBtn->SetTarget(this);
	fAddSeparatorBtn->SetTarget(this);
}