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
// ----------------------------------------------------------------------- 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);
}
S9xRefreshWindow::S9xRefreshWindow(BRect rect, BWindow *parent, uint32 closemsg)
	: BWindow(rect, "FullScreen - Refresh Rate", B_FLOATING_WINDOW, B_NOT_ZOOMABLE | B_NOT_RESIZABLE),
	fWindow(parent),
	fS9xMsg(closemsg)
{
	display_mode *modes;
	uint32 mode_count;
	
	if(BScreen().GetModeList(&modes, &mode_count) == B_NO_ERROR) {
		BMenu *menu = new BMenu("menu");
		for(unsigned int i = 0; i < mode_count; i++) {
		//	if((modes[i].virtual_width == 640) && (modes[i].space == B_RGB16)) {
				BMessage *msg = new BMessage(ID_REFRESH);
				msg->AddPointer("refr_rate", (void *)&modes[i]);
				BString item_name;
				item_name << (modes[i].timing.pixel_clock * 1000)
					/ (modes[i].timing.h_total * modes[i].timing.v_total) << " Hz";
				menu->AddItem(new BMenuItem(item_name.String(), msg));
		//	}
		}
		BRect r(20, 20, 200, 60);
		BMenuField *field = new BMenuField(r, "field", "Refresh Rate:", menu);
		AddChild(field);
		menu->SetLabelFromMarked(true);
		menu->ItemAt(0)->SetMarked(true);
		menu->SetTargetForItems(fWindow);
	}
	Show();
}
static BMenu* new_menu()
{
	BMenu*	m = new BMenu("program menu");
	if( !m ) return 0;
	m->SetLabelFromMarked( true );
	return m;
}
static BMenu* new_bank_menu()
{
	BMenu*	m = new BMenu("bank menu");
	if( !m ) return 0;
	m->SetLabelFromMarked( true );
	return m;
}
/*!	\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 #8
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 #9
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 #10
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 #11
0
/*******************************************************
 * ARP-FONT-CONTROL
 *******************************************************/
ArpFontControl::ArpFontControl(	BRect frame,
								const char* name,
								const BString16* label,
								uint32 message,
								float divider)
		: inherited(frame, name, 0, new BMessage(message),
					B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP, B_WILL_DRAW),
		  mFontCtrl(0), mSizeCtrl(0), mMsgWhat(message)
{
	if (label) {
		if (divider <= 0) divider = StringWidth(label);
		BRect			f(0, 0, divider, frame.Height());
		BStringView*	sv = new BStringView(f, "sv", label);
		if (sv) AddChild(sv);
	}

	float				sizeW = StringWidth("000") + 5;
	float				sizeL = frame.Width() - sizeW;
	BRect				f(divider + 1, 0, sizeL - 1, frame.Height());
	mFontCtrl = new BMenuField(f, "fonts", 0, new BMenu("font"), true,
								B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
	if (!mFontCtrl) return;

	mFontCtrl->SetDivider(0);
	BMenu*		m = mFontCtrl->Menu();
	if (m) {
		m->SetLabelFromMarked(true);
		_ArpFontControlFamilies		families(m);
		families.ForEach();
	}
	AddChild(mFontCtrl);

	float		iH = float(Prefs().GetInt32(ARP_INTCTRL_Y));
	float		iT = 0, iB = frame.Height();
	if (iH < frame.Height()) {
		iT = (frame.Height() - iH) / 2;
		iB = iT + iH;
	}
	f.Set(sizeL, iT, sizeL + sizeW, iB);
	mSizeCtrl = new ArpIntControl(	f, "size", 0, new BMessage(SIZE_IMSG),
									B_FOLLOW_RIGHT | B_FOLLOW_TOP);
	if (mSizeCtrl) {
		mSizeCtrl->SetLimits(1, 512);
		AddChild(mSizeCtrl);
	}

}
Example #12
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;
}
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);
}
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 #15
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);
}
Example #16
0
void
BreakConditionConfigWindow::_Init()
{
	fExceptionSettingsBox = new BBox("exceptionBox");
	fExceptionSettingsBox->SetLabel("Exceptions");
	fExceptionSettingsBox->AddChild(BLayoutBuilder::Group<>(B_VERTICAL,
			B_USE_DEFAULT_SPACING)
		.Add(fExceptionThrown = new BCheckBox("exceptionThrown",
			"Stop when an exception is thrown",
			new BMessage(MSG_STOP_ON_THROWN_EXCEPTION_CHANGED)))
		.Add(fExceptionCaught = new BCheckBox("exceptionCaught",
			"Stop when an exception is caught",
			new BMessage(MSG_STOP_ON_CAUGHT_EXCEPTION_CHANGED)))
		.View());

	fExceptionThrown->SetTarget(this);
	fExceptionCaught->SetTarget(this);

	// TODO: enable once implemented
	fExceptionCaught->SetEnabled(false);


	fImageSettingsBox = new BBox("imageBox");
	fImageSettingsBox->SetLabel("Images");
	BMenu* stopImageMenu = new BMenu("stopImageTypesMenu");

	stopImageMenu->AddItem(new BMenuItem("All",
		new BMessage(MSG_SET_STOP_FOR_ALL_IMAGES)));
	stopImageMenu->AddItem(new BMenuItem("Custom",
		new BMessage(MSG_SET_STOP_FOR_CUSTOM_IMAGES)));

	fStopImageNames = new BListView("customImageList",
		B_MULTIPLE_SELECTION_LIST);
	fStopImageNames->SetSelectionMessage(
		new BMessage(MSG_IMAGE_NAME_SELECTION_CHANGED));

	fCustomImageGroup = new BGroupView();
	BLayoutBuilder::Group<>(fCustomImageGroup, B_VERTICAL, 0.0)
		.Add(new BScrollView("stopImageScroll", fStopImageNames,
			0, false, true))
		.Add(fStopImageNameInput = new BTextControl("stopImageName",
			"Image:", NULL,	NULL))
		.AddGroup(B_HORIZONTAL)
			.AddGlue()
			.Add(fAddImageNameButton = new BButton("Add",
				new BMessage(MSG_ADD_IMAGE_NAME)))
			.Add(fRemoveImageNameButton = new BButton("Remove",
				new BMessage(MSG_REMOVE_IMAGE_NAME)))
		.End();

	fImageSettingsBox->AddChild(BLayoutBuilder::Group<>(B_VERTICAL)
		.SetInsets(B_USE_DEFAULT_SPACING)
		.Add(fStopOnImageLoad = new BCheckBox("stopOnImage",
			"Stop when an image is loaded",
			new BMessage(MSG_STOP_ON_IMAGE_LOAD)))
		.Add(fStopImageConstraints = new BMenuField(
			"stopTypes", "Types:", stopImageMenu))
		.Add(fCustomImageGroup)
		.View());

	font_height fontHeight;
	be_plain_font->GetHeight(&fontHeight);
	float minListHeight = 5 * (fontHeight.ascent + fontHeight.descent
			+ fontHeight.leading);
	fStopImageNames->SetExplicitMinSize(BSize(B_SIZE_UNSET, minListHeight));

	BLayoutBuilder::Group<>(this, B_VERTICAL)
		.SetInsets(B_USE_DEFAULT_SPACING)
		.Add(fExceptionSettingsBox)
		.Add(fImageSettingsBox)
		.AddGroup(B_HORIZONTAL)
			.AddGlue()
			.Add(fCloseButton = new BButton("Close", new BMessage(
					B_QUIT_REQUESTED)))
		.End();


	fCloseButton->SetTarget(this);
	fAddImageNameButton->SetEnabled(false);
	fRemoveImageNameButton->SetEnabled(false);
	stopImageMenu->SetTargetForItems(this);
	stopImageMenu->SetLabelFromMarked(true);
	fStopImageNameInput->SetModificationMessage(
		new BMessage(MSG_IMAGE_NAME_INPUT_CHANGED));

	fCustomImageGroup->Hide();

	AutoLocker< ::Team> teamLocker(fTeam);
	_UpdateStopImageState();
	_UpdateExceptionState();

}
Example #17
0
ProjectSettingsWindow::ProjectSettingsWindow(BRect frame, Project *proj)
	:	DWindow(frame,TR("Project Settings"),B_TITLED_WINDOW,
				B_ASYNCHRONOUS_CONTROLS | B_NOT_ZOOMABLE | B_NOT_H_RESIZABLE),
		fProject(proj),
		fDirty(false)
	
{
	if (!fProject)
		debugger("Bad project given to Project Settings window");
	
	fRefFilter = new TypedRefFilter(NULL,B_DIRECTORY_NODE);
	
	BMessenger msgr(this);
	entry_ref projfolder_ref;
	BEntry(fProject->GetPath().GetFolder()).GetRef(&projfolder_ref);
	fFilePanel = new BFilePanel(B_OPEN_PANEL,&msgr,&projfolder_ref,B_DIRECTORY_NODE,
								true, new BMessage(M_ADD_PATH),fRefFilter);
	
	fAutolock = new BAutolock(fProject);
	
	AddCommonFilter(new EscapeCancelFilter());
	
	BView *top = GetBackgroundView();
	
	BRect r(Bounds());
	fTabView = new BTabView(r,"tabview");
	top->AddChild(fTabView);
	
	r.InsetBy(5,5);
	r.bottom -= fTabView->TabHeight();
	
	BRect bounds = r.OffsetToCopy(0,0);
	
	fGeneralView = new BView(r,TR("General"),B_FOLLOW_ALL,B_WILL_DRAW);
	fGeneralView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	fTabView->AddTab(fGeneralView);
	
	r.right -= 10.0;
	fTargetText = new AutoTextControl(r,"targetname",TR("Target Name:"),
										fProject->GetTargetName(),
										new BMessage(M_TARGET_NAME_CHANGED),
										B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
	fGeneralView->AddChild(fTargetText);
	
	float pwidth, pheight;
	fTargetText->GetPreferredSize(&pwidth, &pheight);
	fTargetText->ResizeTo(r.Width(),pheight);
	r.bottom = r.top + pheight;
	fTargetText->SetDivider(fTargetText->StringWidth(TR("Target Name:")) + 5.0);
	
	r = fTargetText->Frame();
	r.OffsetBy(0,r.Height() + 10.0);
	
	BMenu *menu = new BMenu(TR("Target Type"));
	menu->AddItem(new BMenuItem(TR("Application"),new BMessage(M_SET_TARGET_TYPE)));
	menu->AddItem(new BMenuItem(TR("Shared Library"),new BMessage(M_SET_TARGET_TYPE)));
	menu->AddItem(new BMenuItem(TR("Static Library"),new BMessage(M_SET_TARGET_TYPE)));
	menu->AddItem(new BMenuItem(TR("Device Driver"),new BMessage(M_SET_TARGET_TYPE)));
	
	r.right = (bounds.right - 5.0) / 2.0;
	r.bottom = r.top + 25;
	fTypeField = new BMenuField(r,"type",TR("Target Type:"),menu);
	fGeneralView->AddChild(fTypeField);
	fTypeField->SetDivider(fTypeField->StringWidth(TR("Target Type:")) + 5.0);
	
	SetToolTip(fTypeField,TR("The kind of program you want to build"));
	
	menu->SetTargetForItems(this);
	menu->SetLabelFromMarked(true);
	
	BMenuItem *item = menu->ItemAt(fProject->TargetType());
	if (item)
		item->SetMarked(true);
	
	r.OffsetBy(0,r.Height() + 10.0);
	
	BStringView *label = new BStringView(r,"label",TR("Include Paths:"));
	label->ResizeToPreferred();
	fGeneralView->AddChild(label);
	
	r = label->Frame();
	r.OffsetBy(0,r.Height() + 5.0);
	
	// We create a button now so that the list expands to fill the entire window
	// while leaving space for the two buttons at the bottom. Note that we do not
	// actually add the button to the window until later to preserve proper
	// keyboard navigation order
	BButton *add = new BButton(BRect(0,0,1,1),"addbutton",TR("Add…"),
								new BMessage(M_SHOW_ADD_PATH),
								B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
	add->ResizeToPreferred();
	add->MoveTo(5,fGeneralView->Bounds().bottom - 10.0 - add->Frame().Height());
	
	r.right = bounds.right - 10.0 - B_V_SCROLL_BAR_WIDTH;
	r.bottom = add->Frame().top - 10.0 - B_H_SCROLL_BAR_HEIGHT;
	fIncludeList = new IncludeList(r,fProject->GetPath().GetFolder());
	BScrollView *scrollView = new BScrollView("scrollview",fIncludeList,
											B_FOLLOW_ALL,0, true, true);
	scrollView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	fGeneralView->AddChild(scrollView);
	
	float width = 0.0;
	for (int32 i = 0; i < fProject->CountLocalIncludes(); i++)
	{
		BStringItem *item = new BStringItem(fProject->LocalIncludeAt(i).Relative().String());
		float strwidth = fIncludeList->StringWidth(item->Text());
		width = MAX(width, strwidth);
		fIncludeList->AddItem(item);
	}
	
	if (width > fIncludeList->Bounds().Width())
	{
		BScrollBar *hbar = scrollView->ScrollBar(B_HORIZONTAL);
		hbar->SetRange(0.0, width - fIncludeList->Bounds().Width());
	}
	
	SetToolTip(fIncludeList,TR("The folders you want Paladin to search for header files"));
	
	fGeneralView->AddChild(add);
	
	BButton *remove = new BButton(BRect(0,0,1,1),"removebutton",TR("Remove"),
								new BMessage(M_REMOVE_PATH), 
								B_FOLLOW_LEFT | B_FOLLOW_BOTTOM);
	remove->ResizeToPreferred();
	remove->MoveTo(add->Frame().right + 10.0, add->Frame().top);
	fGeneralView->AddChild(remove);
	
	r = bounds;
	fBuildView = new BView(bounds.OffsetByCopy(5,5),TR("Build"),B_FOLLOW_ALL,B_WILL_DRAW);
	fBuildView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	fTabView->AddTab(fBuildView);
	
	menu = new BMenu(TR("Optimization"));
	menu->AddItem(new BMenuItem(TR("None"),new BMessage(M_SET_OP_VALUE)));
	menu->AddItem(new BMenuItem(TR("Some"),new BMessage(M_SET_OP_VALUE)));
	menu->AddItem(new BMenuItem(TR("More"),new BMessage(M_SET_OP_VALUE)));
	menu->AddItem(new BMenuItem(TR("Full"),new BMessage(M_SET_OP_VALUE)));
	
	r.right = (bounds.right - 5.0) / 2.0;
	r.bottom = r.top + 25;
	fOpField = new BMenuField(r,"optimize",TR("Optimize"),menu);
	fBuildView->AddChild(fOpField);
	fOpField->SetDivider(fOpField->StringWidth(TR("Optimize")) + 5.0);
	
	SetToolTip(fOpField,TR("Compiler optimization level. Disabled when debugging info is checked."));
	
	menu->SetTargetForItems(this);
	menu->SetLabelFromMarked(true);
	
	item = menu->ItemAt(fProject->OpLevel());
	if (item)
		item->SetMarked(true);
	
	r.right = bounds.right - 10.0;
	r.OffsetTo(5, fOpField->Frame().bottom + 5);
	fOpSizeBox = new BCheckBox(r,"opsizebox",TR("Optimize for size over speed"),
								new BMessage(M_TOGGLE_OPSIZE));
	fOpSizeBox->ResizeToPreferred();
	fBuildView->AddChild(fOpSizeBox);
	r = fOpSizeBox->Frame();
	if (fProject->OpForSize())
		fOpSizeBox->SetValue(B_CONTROL_ON);
	
	if (fProject->Debug())
	{
		fOpField->SetEnabled(false);
		fOpSizeBox->SetEnabled(false);
	}
	
	r.OffsetBy(0, r.Height() + 10);
	fDebugBox = new BCheckBox(r,"debugbox",TR("Build debugging information"),
								new BMessage(M_TOGGLE_DEBUG));
	fDebugBox->ResizeToPreferred();
	if (fProject->Debug())
		fDebugBox->SetValue(B_CONTROL_ON);
	fBuildView->AddChild(fDebugBox);
	SetToolTip(fDebugBox,TR("Check this if you want to use your program in a debugger during development."
							"You'll want to rebuild your project after change this."));
	
	r.OffsetBy(0, r.Height());
	fProfileBox = new BCheckBox(r,"profilebox",TR("Build profiling information"),
								new BMessage(M_TOGGLE_PROFILE));
	fProfileBox->ResizeToPreferred();
	if (fProject->Profiling())
		fProfileBox->SetValue(B_CONTROL_ON);
	fBuildView->AddChild(fProfileBox);
	SetToolTip(fProfileBox,TR("Check this if you want to use your program "
								"with gprof or bprof for profiling."));
	
	
	r.OffsetBy(0, r.Height() + 10.0);
	r.right = bounds.right - 10.0;
	fCompileText = new AutoTextControl(r,"extracc","Extra Compiler Options:",
										fProject->ExtraCompilerOptions(),
										new BMessage(M_CCOPTS_CHANGED),
										B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
	fBuildView->AddChild(fCompileText);
	fCompileText->SetDivider(fCompileText->StringWidth(fCompileText->Label()) + 5.0);
	SetToolTip(fCompileText,TR("Extra GCC flags you wish included when each file is compiled."));
	
	r = fCompileText->Frame();
	r.OffsetBy(0,r.Height() + 10);
	fLinkText = new AutoTextControl(r,"extrald",TR("Extra Linker Options:"),
										fProject->ExtraLinkerOptions(),
										new BMessage(M_LDOPTS_CHANGED),
										B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
	fBuildView->AddChild(fLinkText);
	fLinkText->SetDivider(fCompileText->Divider());
	SetToolTip(fLinkText,TR("Extra GCC linker flags you wish included when your project is linked."));
	
	fTabView->Select(0L);
	
	fBuildView->ResizeTo(fGeneralView->Bounds().Width(),fGeneralView->Bounds().Height());

	fTargetText->MakeFocus(true);
}
Example #18
0
SelectionWindow::SelectionWindow(BContainerWindow* window)
	:
	BWindow(BRect(0, 0, 270, 0), B_TRANSLATE("Select"),	B_TITLED_WINDOW,
		B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE | B_NOT_V_RESIZABLE
			| B_NO_WORKSPACE_ACTIVATION | B_ASYNCHRONOUS_CONTROLS
			| B_NOT_ANCHORED_ON_ACTIVATE),
	fParentWindow(window)
{
	if (window->Feel() & kDesktopWindowFeel) {
		// The window will not show up if we have
		// B_FLOATING_SUBSET_WINDOW_FEEL and use it with the desktop window
		// since it's never in front.
		SetFeel(B_NORMAL_WINDOW_FEEL);
	}

	AddToSubset(fParentWindow);

	BView* backgroundView = new BView(Bounds(), "bgView", B_FOLLOW_ALL,
		B_WILL_DRAW);
	backgroundView->SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
	AddChild(backgroundView);

	BMenu* menu = new BPopUpMenu("");
	menu->AddItem(new BMenuItem(B_TRANSLATE("starts with"),	NULL));
	menu->AddItem(new BMenuItem(B_TRANSLATE("ends with"), NULL));
	menu->AddItem(new BMenuItem(B_TRANSLATE("contains"), NULL));
	menu->AddItem(new BMenuItem(B_TRANSLATE("matches wildcard expression"),
		NULL));
	menu->AddItem(new BMenuItem(B_TRANSLATE("matches regular expression"),
		NULL));

	menu->SetLabelFromMarked(true);
	menu->ItemAt(3)->SetMarked(true);
		// Set wildcard matching to default.

	// Set up the menu field
	fMatchingTypeMenuField = new BMenuField(BRect(7, 6,
		Bounds().right - 5, 0), NULL, B_TRANSLATE("Name"), menu);
	backgroundView->AddChild(fMatchingTypeMenuField);
	fMatchingTypeMenuField->SetDivider(fMatchingTypeMenuField->StringWidth(
		B_TRANSLATE("Name")) + 8);
	fMatchingTypeMenuField->ResizeToPreferred();

	// Set up the expression text control
	fExpressionTextControl = new BTextControl(BRect(7,
			fMatchingTypeMenuField->Bounds().bottom + 11,
			Bounds().right - 6, 0),
		NULL, NULL, NULL, NULL, B_FOLLOW_LEFT_RIGHT);
	backgroundView->AddChild(fExpressionTextControl);
	fExpressionTextControl->ResizeToPreferred();
	fExpressionTextControl->MakeFocus(true);

	// Set up the Invert checkbox
	fInverseCheckBox = new BCheckBox(
		BRect(7, fExpressionTextControl->Frame().bottom + 6, 6, 6), NULL,
		B_TRANSLATE("Invert"), NULL);
	backgroundView->AddChild(fInverseCheckBox);
	fInverseCheckBox->ResizeToPreferred();

	// Set up the Ignore Case checkbox
	fIgnoreCaseCheckBox = new BCheckBox(
		BRect(fInverseCheckBox->Frame().right + 10,
			fInverseCheckBox->Frame().top, 6, 6),
		NULL, B_TRANSLATE("Ignore case"), NULL);
	fIgnoreCaseCheckBox->SetValue(1);
	backgroundView->AddChild(fIgnoreCaseCheckBox);
	fIgnoreCaseCheckBox->ResizeToPreferred();

	// Set up the Select button
	fSelectButton = new BButton(BRect(0, 0, 5, 5), NULL,
		B_TRANSLATE("Select"), new BMessage(kSelectButtonPressed),
		B_FOLLOW_RIGHT);

	backgroundView->AddChild(fSelectButton);
	fSelectButton->ResizeToPreferred();
	fSelectButton->MoveTo(Bounds().right - 10 - fSelectButton->Bounds().right,
		fExpressionTextControl->Frame().bottom + 9);
	fSelectButton->MakeDefault(true);
#if !B_BEOS_VERSION_DANO
	fSelectButton->SetLowColor(backgroundView->ViewColor());
	fSelectButton->SetViewColor(B_TRANSPARENT_COLOR);
#endif

	font_height fh;
	be_plain_font->GetHeight(&fh);
	// Center the checkboxes vertically to the button
	float topMiddleButton =
		(fSelectButton->Bounds().Height() / 2 -
		(fh.ascent + fh.descent + fh.leading + 4) / 2)
		+ fSelectButton->Frame().top;
	fInverseCheckBox->MoveTo(fInverseCheckBox->Frame().left, topMiddleButton);
	fIgnoreCaseCheckBox->MoveTo(fIgnoreCaseCheckBox->Frame().left,
		topMiddleButton);

	float bottomMinWidth = 32 + fSelectButton->Bounds().Width()
		+ fInverseCheckBox->Bounds().Width()
		+ fIgnoreCaseCheckBox->Bounds().Width();
	float topMinWidth = be_plain_font->StringWidth(
		B_TRANSLATE("Name matches wildcard expression:###"));
	float minWidth = bottomMinWidth > topMinWidth
		? bottomMinWidth : topMinWidth;

	class EscapeFilter : public BMessageFilter {
	public:
		EscapeFilter(BWindow* target)
			:
			BMessageFilter(B_KEY_DOWN),
			fTarget(target)
		{
		}

		virtual filter_result Filter(BMessage* message, BHandler** _target)
		{
			int8 byte;
			if (message->what == B_KEY_DOWN
				&& message->FindInt8("byte", &byte) == B_OK
				&& byte == B_ESCAPE) {
				fTarget->Hide();
				return B_SKIP_MESSAGE;
			}
			return B_DISPATCH_MESSAGE;
		}

	private:
		BWindow* fTarget;
	};
	AddCommonFilter(new(std::nothrow) EscapeFilter(this));

	Run();

	Lock();
	ResizeTo(minWidth, fSelectButton->Frame().bottom + 6);

	SetSizeLimits(minWidth, 1280, Bounds().bottom, Bounds().bottom);

	MoveCloseToMouse();
	Unlock();
}
Example #19
0
void
InspectorWindow::_Init()
{
	fLanguage = new CppLanguage();
	fExpressionInfo = new ExpressionInfo();
	fExpressionInfo->AddListener(this);

	BScrollView* scrollView;

	BMenu* hexMenu = new BMenu("Hex Mode");
	BMessage* message = new BMessage(MSG_SET_HEX_MODE);
	message->AddInt32("mode", HexModeNone);
	BMenuItem* item = new BMenuItem("<None>", message, '0');
	hexMenu->AddItem(item);
	message = new BMessage(*message);
	message->ReplaceInt32("mode", HexMode8BitInt);
	item = new BMenuItem("8-bit integer", message, '1');
	hexMenu->AddItem(item);
	message = new BMessage(*message);
	message->ReplaceInt32("mode", HexMode16BitInt);
	item = new BMenuItem("16-bit integer", message, '2');
	hexMenu->AddItem(item);
	message = new BMessage(*message);
	message->ReplaceInt32("mode", HexMode32BitInt);
	item = new BMenuItem("32-bit integer", message, '3');
	hexMenu->AddItem(item);
	message = new BMessage(*message);
	message->ReplaceInt32("mode", HexMode64BitInt);
	item = new BMenuItem("64-bit integer", message, '4');
	hexMenu->AddItem(item);

	BMenu* endianMenu = new BMenu("Endian Mode");
	message = new BMessage(MSG_SET_ENDIAN_MODE);
	message->AddInt32("mode", EndianModeLittleEndian);
	item = new BMenuItem("Little Endian", message, 'L');
	endianMenu->AddItem(item);
	message = new BMessage(*message);
	message->ReplaceInt32("mode", EndianModeBigEndian);
	item = new BMenuItem("Big Endian", message, 'B');
	endianMenu->AddItem(item);

	BMenu* textMenu = new BMenu("Text Mode");
	message = new BMessage(MSG_SET_TEXT_MODE);
	message->AddInt32("mode", TextModeNone);
	item = new BMenuItem("<None>", message, 'N');
	textMenu->AddItem(item);
	message = new BMessage(*message);
	message->ReplaceInt32("mode", TextModeASCII);
	item = new BMenuItem("ASCII", message, 'A');
	textMenu->AddItem(item);

	BLayoutBuilder::Group<>(this, B_VERTICAL)
		.SetInsets(B_USE_DEFAULT_SPACING)
		.AddGroup(B_HORIZONTAL)
			.Add(fAddressInput = new BTextControl("addrInput",
			"Target Address:", "",
			new BMessage(MSG_INSPECT_ADDRESS)))
			.Add(fPreviousBlockButton = new BButton("navPrevious", "<",
				new BMessage(MSG_NAVIGATE_PREVIOUS_BLOCK)))
			.Add(fNextBlockButton = new BButton("navNext", ">",
				new BMessage(MSG_NAVIGATE_NEXT_BLOCK)))
		.End()
		.AddGroup(B_HORIZONTAL)
			.Add(fHexMode = new BMenuField("hexMode", "Hex Mode:",
				hexMenu))
			.AddGlue()
			.Add(fEndianMode = new BMenuField("endianMode", "Endian Mode:",
				endianMenu))
			.AddGlue()
			.Add(fTextMode = new BMenuField("viewMode",  "Text Mode:",
				textMenu))
		.End()
		.Add(scrollView = new BScrollView("memory scroll",
			NULL, 0, false, true), 3.0f)
		.AddGroup(B_HORIZONTAL)
			.Add(fWritableBlockIndicator = new BStringView("writableIndicator",
				_GetCurrentWritableIndicator()))
			.AddGlue()
			.Add(fEditBlockButton = new BButton("editBlock", "Edit",
				new BMessage(MSG_EDIT_CURRENT_BLOCK)))
			.Add(fCommitBlockButton = new BButton("commitBlock", "Commit",
				new BMessage(MSG_COMMIT_MODIFIED_BLOCK)))
			.Add(fRevertBlockButton = new BButton("revertBlock", "Revert",
				new BMessage(MSG_REVERT_MODIFIED_BLOCK)))
		.End()
	.End();

	fHexMode->SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
	fEndianMode->SetViewUIColor(B_PANEL_BACKGROUND_COLOR);
	fTextMode->SetViewUIColor(B_PANEL_BACKGROUND_COLOR);

	int32 targetEndian = fTeam->GetArchitecture()->IsBigEndian()
		? EndianModeBigEndian : EndianModeLittleEndian;

	scrollView->SetTarget(fMemoryView = MemoryView::Create(fTeam, this));

	fAddressInput->SetTarget(this);
	fPreviousBlockButton->SetTarget(this);
	fNextBlockButton->SetTarget(this);
	fPreviousBlockButton->SetEnabled(false);
	fNextBlockButton->SetEnabled(false);

	fEditBlockButton->SetTarget(this);
	fCommitBlockButton->SetTarget(this);
	fRevertBlockButton->SetTarget(this);

	fEditBlockButton->SetEnabled(false);
	fCommitBlockButton->Hide();
	fRevertBlockButton->Hide();

	hexMenu->SetLabelFromMarked(true);
	hexMenu->SetTargetForItems(fMemoryView);
	endianMenu->SetLabelFromMarked(true);
	endianMenu->SetTargetForItems(fMemoryView);
	textMenu->SetLabelFromMarked(true);
	textMenu->SetTargetForItems(fMemoryView);

	// default to 8-bit format w/ text display
	hexMenu->ItemAt(1)->SetMarked(true);
	textMenu->ItemAt(1)->SetMarked(true);

	if (targetEndian == EndianModeBigEndian)
		endianMenu->ItemAt(1)->SetMarked(true);
	else
		endianMenu->ItemAt(0)->SetMarked(true);

	fAddressInput->TextView()->MakeFocus(true);

	AddShortcut(B_LEFT_ARROW, B_COMMAND_KEY, new BMessage(
			MSG_NAVIGATE_PREVIOUS_BLOCK));
	AddShortcut(B_RIGHT_ARROW, B_COMMAND_KEY, new BMessage(
			MSG_NAVIGATE_NEXT_BLOCK));
}
Example #20
0
BView* SeqPrefWin::NewFileView(BRect bounds, const BMessage& prefs) const
{
	BView*		v = new BView( bounds, FILE_STR, B_FOLLOW_ALL, 0 );
	if( !v ) return v;
	v->SetViewColor( Prefs().Color(AM_AUX_WINDOW_BG_C) );
	float		fh = view_font_height(v);
	float		bfh = bold_font_height();
	float		openH = bfh + 5 + fh + 5 + fh + 5 + fh;
	/* The Remember Open Songs preference.
	 */
	float		w = v->StringWidth("Remember open songs") + 25;
	BRect		f(bounds.left + 5, bounds.top + 5, bounds.left + 5 + w, bounds.top + 5 + fh);
	BCheckBox*	cb = new BCheckBox( f, REMEMBER_OPEN_STR, "Remember open songs", new BMessage(REMEMBER_OPEN_MSG) );
	if( cb ) {
		bool	b;
		if( prefs.FindBool(REMEBER_OPEN_SONGS_PREF, &b) != B_OK ) b = false;
		cb->SetValue( (b) ? B_CONTROL_ON : B_CONTROL_OFF );
		v->AddChild( cb );
	}
	/* The Skin preference.
	 */
	BMenu*		menu = new BMenu("skin_menu");
	BMessage	skinMsg(CHANGE_SKIN_MSG);
	BMenuItem*	item = new BMenuItem( "Default", new BMessage(CHANGE_SKIN_TO_DEFAULT_MSG) );
	item->SetMarked(true);
	menu->AddItem(item);
	menu->AddSeparatorItem();
	menu->SetLabelFromMarked(true);
	if( seq_make_skin_menu(menu, &skinMsg) == B_OK ) {
		const char*	label = "Choose skin:";
		f.Set(f.left, f.bottom + 8, bounds.right - 5, f.bottom + 8 + fh + 10);
		BMenuField*	field = new BMenuField(f, "skin_field", label, menu);
		if (field) {
			field->SetDivider( v->StringWidth(label) + 10 );
			v->AddChild(field);
		} else delete menu;
	} else delete menu;

	/* The Open New Songs preferences.
	 */
	f.Set(bounds.left + 5, f.bottom + 10, bounds.right - 5, f.bottom + 10 + openH + 10);
	BBox*		box = new BBox( f,
								"open_new_songs",
								B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
	if( box ) {
		box->SetLabel( "Open New Songs" );
		BRect		boxB = box->Bounds();
		BRect		sf(boxB.left + 5, boxB.top + 5 + bfh, boxB.right - 5, boxB.top + 5 + bfh + fh);
		const char*	choice;
		if( prefs.FindString(OPEN_NEW_SONG_PREF, &choice) != B_OK ) choice = 0;
		BRadioButton*	button = new BRadioButton( sf, OPEN_BLANK_STR, "Blank", new BMessage(OPEN_BLANK_MSG), B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP );
		if( button ) {
			if( choice && strcmp(choice, "blank") == 0 ) button->SetValue( B_CONTROL_ON );
			box->AddChild( button );
		}
		sf.OffsetBy( 0, 5 + fh );
		button = new BRadioButton( sf, OPEN_FOUR_STR, "With two channels of each device", new BMessage(OPEN_FOUR_MSG), B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP );
		if( button ) {
			if( choice && strcmp(choice, "channels") == 0 ) button->SetValue( B_CONTROL_ON );
			box->AddChild( button );
		}
		sf.OffsetBy( 0, 5 + fh );
		button = new BRadioButton( sf, OPEN_FILE_STR, "From file: <click to select>", new BMessage(OPEN_FILE_MSG), B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP );
		if( button ) {
			if( choice && strcmp(choice, "file") == 0 ) button->SetValue( B_CONTROL_ON );
			entry_ref	ref;
			if( prefs.FindRef(OPEN_NEW_SONG_FILE_PREF, &ref) == B_OK )
				button->SetLabel( label_for_open_new_from_file(&ref).String() );
			box->AddChild( button );
		}
		v->AddChild( box );
		f.OffsetBy(0, f.bottom - f.top + 10 );
	}
	/* The Open From Query preferences
	 */
	f.bottom = bounds.bottom - 27;
	box = new BBox( f, "open_from_query", B_FOLLOW_ALL);
	if( box ) {
		box->SetLabel("Open From Query");

		BRect			boxB = box->Bounds();
		BRect			tableF(boxB.left + 5, boxB.top + 5 + bfh, boxB.right - 5, boxB.bottom - 35);
		mOwqTable = new _OwqList( tableF, mPreferences );
		if( mOwqTable ) {
			mOwqTable->SetLatchWidth( 0 );
			box->AddChild( mOwqTable );
			mOwqTable->AddColumn( new BStringColumn(ON_STR, 40, 20, 100, B_TRUNCATE_END), 0 );
			mOwqTable->AddColumn( new BStringColumn(NAME_STR, 100, 20, 150, B_TRUNCATE_END), 1 );
			mOwqTable->AddColumn( new BStringColumn(QUERY_STR, 180, 20, 450, B_TRUNCATE_MIDDLE), 2 );
//			mOwqTable->AddColumn( new BStringColumn(SKIP_TOP_LEVEL_STR, 100, 20, 250, B_TRUNCATE_END), 3 );
			mOwqTable->SetSortColumn(mOwqTable->ColumnAt(1), false, true);
//			mOwqTable->SetSortColumn(mOwqTable->ColumnAt(), true, true);
			mOwqTable->SetSelectionMode( B_SINGLE_SELECTION_LIST );

			BRect		bF(tableF.left, tableF.bottom + 5, tableF.left + 55, tableF.Height() - 10);
			BButton*	add = new BButton( bF, "owq_add", "Add", new BMessage(OWQ_INVOKE_ADD), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM );
			if( add ) box->AddChild( add );
			bF.OffsetBy( bF.Width() + 5, 0 );
			BButton*	change = new BButton( bF, "owq_change", "Change", new BMessage(OWQ_CHANGE), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM );
			if( change ) {
				change->SetEnabled( false );
				box->AddChild( change );
			}
			bF.OffsetBy( bF.Width() + 5, 0 );
			BButton*	remove = new BButton( bF, "owq_remove", "Remove", new BMessage(OWQ_REMOVE), B_FOLLOW_LEFT | B_FOLLOW_BOTTOM );
			if( remove ) {
				remove->SetEnabled( false );
				box->AddChild( remove );
			}
			mOwqTable->SetButtons( add, change, remove );
		}
		v->AddChild( box );
	}
	return v;
}
Example #21
0
SCMImportWindow::SCMImportWindow(void)
  :	DWindow(BRect(0,0,350,300), "Import from Repository")
{
	MakeCenteredOnShow(true);
	
	BView *top = GetBackgroundView();
	
	BMenu *menu = new BMenu("Providers");
	
	for (int32 i = 0; i < fProviderMgr.CountImporters(); i++)
	{
		SCMProjectImporter *importer = fProviderMgr.ImporterAt(i);
		if (!importer)
			continue;
		
		BMessage *msg = new BMessage(M_USE_PROVIDER);
		menu->AddItem(new BMenuItem(importer->GetName(), msg));
	}
	
	// Disable custom commands for now	
//	menu->AddSeparatorItem();
//	menu->AddItem(new BMenuItem("Custom", new BMessage(M_USE_CUSTOM_PROVIDER)));
	
	menu->SetLabelFromMarked(true);
	menu->ItemAt(0L)->SetMarked(true);
	
	BRect r(Bounds());
	r.InsetBy(10.0, 10.0);
	r.bottom = 40.0;
	fProviderField = new BMenuField(r, "repofield", "Provider: ", menu,
								B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
	float pw, ph;
	fProviderField->GetPreferredSize(&pw, &ph);
	fProviderField->ResizeTo(r.Width(), ph);
	top->AddChild(fProviderField);
	r = fProviderField->Frame();
	
	menu = new BMenu("Methods");
	if (gHgAvailable)
		menu->AddItem(new BMenuItem("Mercurial", new BMessage(M_UPDATE_COMMAND)));
	
	if (gGitAvailable)
		menu->AddItem(new BMenuItem("Git", new BMessage(M_UPDATE_COMMAND)));
	
	if (gSvnAvailable)
		menu->AddItem(new BMenuItem("Subversion", new BMessage(M_UPDATE_COMMAND)));
	menu->SetLabelFromMarked(true);
	menu->ItemAt(0L)->SetMarked(true);
	fProvider = fProviderMgr.ImporterAt(0);
		
	r.OffsetBy(0.0, r.Height() + 10.0);
	fSCMField = new BMenuField(r, "scmfield", "Method: ", menu,
								B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
	top->AddChild(fSCMField);
		
	r.OffsetBy(0.0, r.Height() + 10.0);
	fProjectBox = new AutoTextControl(r, "project", "Project: ", "",
									new BMessage(M_UPDATE_COMMAND),
									B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
	fProjectBox->GetPreferredSize(&pw, &ph);
	fProjectBox->ResizeTo(r.Width(), ph);
	r = fProjectBox->Frame();
	top->AddChild(fProjectBox);
	
	r.OffsetBy(0.0, r.Height() + 10.0);
	fAnonymousBox = new BCheckBox(r, "anonymous", "Anonymous check-out",
									new BMessage(M_TOGGLE_ANONYMOUS));
	top->AddChild(fAnonymousBox);
	fAnonymousBox->ResizeToPreferred();
	fAnonymousBox->SetValue(B_CONTROL_ON);
	
	r.OffsetBy(0.0, fAnonymousBox->Bounds().Height() + 10.0);
	fUserNameBox = new AutoTextControl(r, "username", "Username: ", "",
									new BMessage(M_UPDATE_COMMAND),
									B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
	top->AddChild(fUserNameBox);
	fUserNameBox->SetEnabled(false);
	
	r.OffsetBy(0.0, r.Height() + 10.0);
	fRepository = new AutoTextControl(r, "repository", "Repository (opt.): ", "",
									new BMessage(M_UPDATE_COMMAND),
									B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
	fRepository->GetPreferredSize(&pw, &ph);
	fRepository->ResizeTo(r.Width(), ph);
	r = fRepository->Frame();
	top->AddChild(fRepository);
	
	r.OffsetBy(0.0, r.Height() + 10.0);
	fCommandLabel = new BStringView(r, "commandlabel", "Command: ",
									B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
	fCommandLabel->ResizeToPreferred();
	top->AddChild(fCommandLabel);
	
	r.OffsetBy(0.0, fCommandLabel->Bounds().Height() + 5.0);
	r.bottom = r.top + 75.0;
	r.right -= B_V_SCROLL_BAR_WIDTH;
	BRect textRect = r.OffsetToCopy(0.0, 0.0).InsetByCopy(10.0, 10.0);
	fCommandView = new BTextView(r, "command", textRect, B_FOLLOW_ALL);
	
	BScrollView *scroll = new BScrollView("scrollview", fCommandView,
											B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP,
											0, false, true);
	top->AddChild(scroll);
	fCommandView->MakeEditable(false);
	
	fOK = new BButton(r, "ok", "Import", new BMessage(M_SCM_IMPORT),
					B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
	fOK->ResizeToPreferred();
	fOK->MoveTo(Bounds().right - 10.0 - fOK->Bounds().Width(),
				scroll->Frame().bottom + 10.0);
	
	ResizeTo(Bounds().Width(),  fOK->Frame().bottom + 10.0);
	scroll->SetResizingMode(B_FOLLOW_ALL);
	
	top->AddChild(fOK);
	fOK->MakeDefault(true);
	fOK->SetEnabled(false);
	
	UpdateCommand();
	fProviderField->MakeFocus(true);
}
Example #22
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);
}
Example #23
0
void
TeamsWindow::_Init()
{
	BMessage settings;
	_LoadSettings(settings);

	BRect frame;
	if (settings.FindRect("teams window frame", &frame) == B_OK) {
		MoveTo(frame.LeftTop());
		ResizeTo(frame.Width(), frame.Height());
	}

	BMenu* connectionMenu = new BMenu("Connection");
	ObjectDeleter<BMenu> menuDeleter(connectionMenu);
	connectionMenu->SetLabelFromMarked(true);

	TargetHostInterfaceRoster* roster = TargetHostInterfaceRoster::Default();
	for (int32 i = 0; i < roster->CountActiveInterfaces(); i++) {
		TargetHostInterface* interface = roster->ActiveInterfaceAt(i);
		BMenuItem* item = new BMenuItem(interface->GetTargetHost()->Name(),
			new BMessage(MSG_SWITCH_TARGET_CONNECTION));
		if (item->Message()->AddPointer("interface", interface) != B_OK) {
			delete item;
			throw std::bad_alloc();
		}

		if (interface->IsLocal()) {
			item->SetMarked(true);
			fTargetHostInterface = interface;
		}

		connectionMenu->AddItem(item);
	}

	BGroupLayout* connectionLayout = NULL;

	BLayoutBuilder::Group<>(this, B_VERTICAL)
		.AddGroup(B_HORIZONTAL)
			.SetInsets(B_USE_DEFAULT_SPACING)
			.GetLayout(&connectionLayout)
			.Add(fConnectionField = new BMenuField("Connected to:",
				connectionMenu))
			.AddGlue()
			.Add(fCreateConnectionButton = new BButton("Create new connection"
					B_UTF8_ELLIPSIS, new BMessage(
						MSG_SHOW_CONNECTION_CONFIG_WINDOW)))
		.End()
		.Add(fTeamsListView = new TeamsListView("TeamsList"))
		.SetInsets(1.0f, 1.0f, 1.0f, 5.0f)
		.AddGroup(B_HORIZONTAL)
			.SetInsets(B_USE_DEFAULT_SPACING)
			.Add(fAttachTeamButton = new BButton("Attach", new BMessage(
					MSG_DEBUG_THIS_TEAM)))
			.AddGlue()
			.Add(fCreateTeamButton = new BButton("Start new team"
					B_UTF8_ELLIPSIS, new BMessage(MSG_SHOW_START_TEAM_WINDOW)))
			.Add(fLoadCoreButton = new BButton("Load core" B_UTF8_ELLIPSIS,
					new BMessage(MSG_LOAD_CORE_TEAM)))
			.End()
		.End();

	connectionLayout->SetVisible(false);

	menuDeleter.Detach();

	AddListener(fTeamsListView);

	connectionMenu->SetTargetForItems(this);

	fTeamsListView->SetInvocationMessage(new BMessage(MSG_DEBUG_THIS_TEAM));
	fTeamsListView->SetSelectionMessage(new BMessage(
			MSG_TEAM_SELECTION_CHANGED));

	fAttachTeamButton->SetEnabled(false);
	fCreateTeamButton->SetTarget(this);
	fLoadCoreButton->SetTarget(this);
	fCreateConnectionButton->SetTarget(be_app);

	_NotifySelectedInterfaceChanged(fTargetHostInterface);
}
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 #25
0
SelectionWindow::SelectionWindow(BContainerWindow *window)
	:	BWindow(BRect(0, 0, 270, 0),
			"Select", B_TITLED_WINDOW,
			B_NOT_ZOOMABLE | B_NOT_MINIMIZABLE | B_NOT_V_RESIZABLE
			| B_NO_WORKSPACE_ACTIVATION | B_ASYNCHRONOUS_CONTROLS
			| B_NOT_ANCHORED_ON_ACTIVATE),
		fParentWindow(window)
{
	if (window->Feel() & kPrivateDesktopWindowFeel)
		// The window will not show up if we have B_FLOATING_SUBSET_WINDOW_FEEL
		// and use it with the desktop window since it's never in front.
		SetFeel(B_NORMAL_WINDOW_FEEL);
	
	AddToSubset(fParentWindow);

	BRect backgroundRect = Bounds();
	backgroundRect.InsetBy(-1, -1);
	BView *backgroundView = new BBox(backgroundRect, "bgView", B_FOLLOW_ALL);
	AddChild(backgroundView);

	BMenu *menu = new BPopUpMenu("");
	
	menu->AddItem(new BMenuItem("starts with", NULL));
	menu->AddItem(new BMenuItem("ends with", NULL));
	menu->AddItem(new BMenuItem("contains", NULL));
	menu->AddItem(new BMenuItem("matches wildcard expression", NULL));
	menu->AddItem(new BMenuItem("matches regular expression", NULL));

	menu->SetLabelFromMarked(true);
	menu->ItemAt(3)->SetMarked(true);
		// Set wildcard matching to default.
	
	// Set up the menu field
	fMatchingTypeMenuField = new BMenuField(BRect(7, 6, Bounds().right - 5, 0),
		NULL, "Name", menu);
	backgroundView->AddChild(fMatchingTypeMenuField);
	fMatchingTypeMenuField->SetDivider(fMatchingTypeMenuField->StringWidth("Name") + 8);
	fMatchingTypeMenuField->ResizeToPreferred();
	
	// Set up the expression text control
	fExpressionTextControl = new BTextControl(BRect(7, fMatchingTypeMenuField->
		Bounds().bottom + 11, Bounds().right - 6, 0), NULL, NULL, NULL, NULL,
		B_FOLLOW_LEFT_RIGHT);
	backgroundView->AddChild(fExpressionTextControl);
	fExpressionTextControl->ResizeToPreferred();
	fExpressionTextControl->MakeFocus(true);
	
	// Set up the Invert checkbox
	fInverseCheckBox = new BCheckBox(BRect(7, fExpressionTextControl->Frame().bottom
		+ 6, 6, 6), NULL, "Invert", NULL);
	backgroundView->AddChild(fInverseCheckBox);
	fInverseCheckBox->ResizeToPreferred();
	
	// Set up the Ignore Case checkbox
	fIgnoreCaseCheckBox = new BCheckBox(BRect(fInverseCheckBox->Frame().right + 10,
		fInverseCheckBox->Frame().top, 6, 6), NULL, "Ignore case", NULL);
	fIgnoreCaseCheckBox->SetValue(1);
	backgroundView->AddChild(fIgnoreCaseCheckBox);
	fIgnoreCaseCheckBox->ResizeToPreferred();

	// Set up the Select button
	fSelectButton = new BButton(BRect(0, 0, 5, 5), NULL, "Select",
		new BMessage(kSelectButtonPressed), B_FOLLOW_RIGHT);
		
	backgroundView->AddChild(fSelectButton);
	fSelectButton->ResizeToPreferred();
	fSelectButton->MoveTo(Bounds().right - 10 - fSelectButton->Bounds().right,
		fExpressionTextControl->Frame().bottom + 9);
	fSelectButton->MakeDefault(true);
	#if !B_BEOS_VERSION_DANO
	fSelectButton->SetLowColor(backgroundView->ViewColor());
	fSelectButton->SetViewColor(B_TRANSPARENT_COLOR);
	#endif
	
	font_height fh;
	be_plain_font->GetHeight(&fh);
	// Center the checkboxes vertically to the button
	float topMiddleButton =
		(fSelectButton->Bounds().Height() / 2 -
		(fh.ascent + fh.descent + fh.leading + 4) / 2) + fSelectButton->Frame().top;
	fInverseCheckBox->MoveTo(fInverseCheckBox->Frame().left, topMiddleButton);
	fIgnoreCaseCheckBox->MoveTo(fIgnoreCaseCheckBox->Frame().left, topMiddleButton);

	float bottomMinWidth = 32 + fSelectButton->Bounds().Width() +
		fInverseCheckBox->Bounds().Width() + fIgnoreCaseCheckBox->Bounds().Width();
	float topMinWidth = be_plain_font->StringWidth("Name matches wildcard expression:###");
	float minWidth = bottomMinWidth > topMinWidth ? bottomMinWidth : topMinWidth;

	Run();

	Lock();
	ResizeTo(minWidth, fSelectButton->Frame().bottom + 6);

	SetSizeLimits(
		/* Minimum Width */ minWidth,
		/* Maximum Width */ 1280,
		/* Minimum Height */ Bounds().bottom,
		/* Maximum Height */ Bounds().bottom);

	MoveCloseToMouse();	
	Unlock();
}
Example #26
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 #27
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 #28
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 #29
0
SCMImportWindow::SCMImportWindow(void)
  :	DWindow(BRect(0,0,350,350), B_TRANSLATE("Import from repository"))
{
	MakeCenteredOnShow(true);
	
	BMenu *menu = new BMenu(B_TRANSLATE("Providers"));
	
	for (int32 i = 0; i < fProviderMgr.CountImporters(); i++)
	{
		SCMProjectImporter *importer = fProviderMgr.ImporterAt(i);
		if (!importer)
			continue;
		
		BMessage *msg = new BMessage(M_USE_PROVIDER);
		menu->AddItem(new BMenuItem(importer->GetName(), msg));
	}
	
	// Disable custom commands for now	
//	menu->AddSeparatorItem();
//	menu->AddItem(new BMenuItem("Custom", new BMessage(M_USE_CUSTOM_PROVIDER)));
	
	menu->SetLabelFromMarked(true);
	menu->ItemAt(0L)->SetMarked(true);
	
	fProviderField = new BMenuField("repofield", B_TRANSLATE("Provider:"), menu);
	
	menu = new BMenu(B_TRANSLATE("Methods"));
	if (gHgAvailable)
		menu->AddItem(new BMenuItem(B_TRANSLATE("Mercurial"), new BMessage(M_UPDATE_COMMAND)));
	
	if (gGitAvailable)
		menu->AddItem(new BMenuItem(B_TRANSLATE("Git"), new BMessage(M_UPDATE_COMMAND)));
	
	if (gSvnAvailable)
		menu->AddItem(new BMenuItem(B_TRANSLATE("Subversion"), new BMessage(M_UPDATE_COMMAND)));
	menu->SetLabelFromMarked(true);
	menu->ItemAt(0L)->SetMarked(true);
	fProvider = fProviderMgr.ImporterAt(0);
		
	fSCMField = new BMenuField("scmfield", B_TRANSLATE("Method:"), menu);
		
	fProjectBox = new AutoTextControl("project", B_TRANSLATE("Project:"), "",
									new BMessage(M_UPDATE_COMMAND));
	
	fAnonymousBox = new BCheckBox("anonymous", B_TRANSLATE("Anonymous check-out"),
									new BMessage(M_TOGGLE_ANONYMOUS));
	fAnonymousBox->SetValue(B_CONTROL_ON);
	
	fUserNameBox = new AutoTextControl("username", B_TRANSLATE("Username:"), "",
									new BMessage(M_UPDATE_COMMAND));
	fUserNameBox->SetEnabled(false);
	
	fRepository = new AutoTextControl("repository", B_TRANSLATE("Repository owner:"), "",
									new BMessage(M_UPDATE_COMMAND));	
	
	fCommandLabel = new BStringView("commandlabel", B_TRANSLATE("Command:"));	
	fCommandView = new BTextView("command");
	
	BScrollView *scroll = new BScrollView("scrollview", fCommandView,
											0, false, true);
	fCommandView->MakeEditable(false);
	
	fOK = new BButton("ok", B_TRANSLATE("Import"), new BMessage(M_SCM_IMPORT));
	
	BLayoutBuilder::Group<>(this, B_VERTICAL)
		.SetInsets(10)
		.Add(fProviderField)
		.Add(fSCMField)
		.Add(fRepository)
		.Add(fProjectBox)
		.Add(fAnonymousBox)
		.Add(fUserNameBox)
		.Add(fCommandLabel)
		.Add(scroll)
		.Add(fOK)
	.End();
		
	fOK->MakeDefault(true);
	fOK->SetEnabled(false);
	
	UpdateCommand();
	fProviderField->MakeFocus(true);
	
}
Example #30
0
void
InspectorWindow::_Init()
{
	BScrollView* scrollView;

	BMenu* hexMenu = new BMenu("Hex Mode");
	BMessage* message = new BMessage(MSG_SET_HEX_MODE);
	message->AddInt32("mode", HexModeNone);
	BMenuItem* item = new BMenuItem("<None>", message, '0');
	hexMenu->AddItem(item);
	message = new BMessage(*message);
	message->ReplaceInt32("mode", HexMode8BitInt);
	item = new BMenuItem("8-bit integer", message, '1');
	hexMenu->AddItem(item);
	message = new BMessage(*message);
	message->ReplaceInt32("mode", HexMode16BitInt);
	item = new BMenuItem("16-bit integer", message, '2');
	hexMenu->AddItem(item);
	message = new BMessage(*message);
	message->ReplaceInt32("mode", HexMode32BitInt);
	item = new BMenuItem("32-bit integer", message, '3');
	hexMenu->AddItem(item);
	message = new BMessage(*message);
	message->ReplaceInt32("mode", HexMode64BitInt);
	item = new BMenuItem("64-bit integer", message, '4');
	hexMenu->AddItem(item);

	BMenu* endianMenu = new BMenu("Endian Mode");
	message = new BMessage(MSG_SET_ENDIAN_MODE);
	message->AddInt32("mode", EndianModeLittleEndian);
	item = new BMenuItem("Little Endian", message, 'L');
	endianMenu->AddItem(item);
	message = new BMessage(*message);
	message->ReplaceInt32("mode", EndianModeBigEndian);
	item = new BMenuItem("Big Endian", message, 'B');
	endianMenu->AddItem(item);

	BMenu* textMenu = new BMenu("Text Mode");
	message = new BMessage(MSG_SET_TEXT_MODE);
	message->AddInt32("mode", TextModeNone);
	item = new BMenuItem("<None>", message, 'N');
	textMenu->AddItem(item);
	message = new BMessage(*message);
	message->ReplaceInt32("mode", TextModeASCII);
	item = new BMenuItem("ASCII", message, 'A');
	textMenu->AddItem(item);

	BLayoutBuilder::Group<>(this, B_VERTICAL)
		.SetInsets(4.0f, 4.0f, 4.0f, 4.0f)
		.AddGroup(B_HORIZONTAL, 4.0f)
			.Add(fAddressInput = new BTextControl("addrInput",
			"Target Address:", "",
			new BMessage(MSG_INSPECT_ADDRESS)))
			.Add(fPreviousBlockButton = new BButton("navPrevious", "<",
				new BMessage(MSG_NAVIGATE_PREVIOUS_BLOCK)))
			.Add(fNextBlockButton = new BButton("navNext", ">",
				new BMessage(MSG_NAVIGATE_NEXT_BLOCK)))
		.End()
		.AddGroup(B_HORIZONTAL, 4.0f)
			.Add(fHexMode = new BMenuField("hexMode", "Hex Mode:",
				hexMenu))
			.AddGlue()
			.Add(fEndianMode = new BMenuField("endianMode", "Endian Mode:",
				endianMenu))
			.AddGlue()
			.Add(fTextMode = new BMenuField("viewMode",  "Text Mode:",
				textMenu))
		.End()
		.Add(scrollView = new BScrollView("memory scroll",
			NULL, 0, false, true), 3.0f)
	.End();

	fHexMode->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	fEndianMode->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	fTextMode->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));

	int32 targetEndian = fTeam->GetArchitecture()->IsBigEndian()
		? EndianModeBigEndian : EndianModeLittleEndian;

	scrollView->SetTarget(fMemoryView = MemoryView::Create(fTeam));

	fAddressInput->SetTarget(this);
	fPreviousBlockButton->SetTarget(this);
	fNextBlockButton->SetTarget(this);
	fPreviousBlockButton->SetEnabled(false);
	fNextBlockButton->SetEnabled(false);

	hexMenu->SetLabelFromMarked(true);
	hexMenu->SetTargetForItems(fMemoryView);
	endianMenu->SetLabelFromMarked(true);
	endianMenu->SetTargetForItems(fMemoryView);
	textMenu->SetLabelFromMarked(true);
	textMenu->SetTargetForItems(fMemoryView);

	// default to 8-bit format w/ text display
	hexMenu->ItemAt(1)->SetMarked(true);
	textMenu->ItemAt(1)->SetMarked(true);

	if (targetEndian == EndianModeBigEndian)
		endianMenu->ItemAt(1)->SetMarked(true);
	else
		endianMenu->ItemAt(0)->SetMarked(true);

	fAddressInput->TextView()->MakeFocus(true);
}