예제 #1
0
HDialog::HDialog(BRect frame, const char *name, window_type type,
	int flags, BWindow *owner, BPositionIO* data)
	: BWindow(frame, name, type, flags)
	, fOwner(owner)
	, fPlacement(H_PLACE_LAST_POS)
{
	frame.OffsetTo(0, 0);

	AddChild(fMainView = new HDlogView(frame, "main"));

	if (data)
		_BuildIt(*data);

	AddCommonFilter(new BMessageFilter(B_KEY_DOWN,KeyDownFilter));

	if (fOwner)
	{
		BMessage m(msg_AddDialog);
		m.AddPointer("dialog", this);
		fOwner->PostMessage(&m);

		// [zooey]: let dialog float above owner:
		SetFeel(B_FLOATING_SUBSET_WINDOW_FEEL);
		AddToSubset(fOwner);
	}
} /* HDialog::HDialog */
예제 #2
0
MacScreen::MacScreen(const BeOS_monitor_desc& monitor, const char *name, int mode_bit, status_t *error)
	: BWindowScreen(name, 1 << mode_bit, error), tick_thread(-1)
	, monitor(monitor)
{
	// Set all variables
	frame_backup = NULL;
	palette_changed = false;
	screen_active = false;
	first_time = true;
	quitting = false;

	// Set relative mouse mode
	ADBSetRelMouseMode(true);

	// Create view to get mouse events
	main_view = new BView(Frame(), NULL, B_FOLLOW_NONE, 0);
	AddChild(main_view);

	// Start 60Hz interrupt
	tick_thread_active = true;
	tick_thread = spawn_thread(tick_func, "Polling sucks...", B_DISPLAY_PRIORITY, this);
	resume_thread(tick_thread);

	// Add filter for keyboard and mouse events
	BMessageFilter *filter = new BMessageFilter(B_ANY_DELIVERY, B_ANY_SOURCE, filter_func);
	AddCommonFilter(filter);
}
예제 #3
0
파일: Alert.cpp 프로젝트: tqh/haiku-efi
BAlert::BAlert(BMessage* data)
	:
	BWindow(data)
{
	fInvoker = NULL;
	fAlertSem = -1;
	fAlertValue = -1;

	fTextView = (BTextView*)FindView("_tv_");

	// TODO: window loses default button on dearchive!
	// TODO: ButtonAt() doesn't work afterwards (also affects shortcuts)

	TAlertView* view = (TAlertView*)FindView("_master_");
	if (view)
		view->SetBitmap(_CreateTypeIcon());

	// Get keys
	char key;
	for (int32 i = 0; i < 3; ++i) {
		if (data->FindInt8("_but_key", i, (int8*)&key) == B_OK)
			fKeys[i] = key;
	}

	AddCommonFilter(new(std::nothrow) _BAlertFilter_(this));
}
예제 #4
0
TipManager::TipManager() :
	
	BWindow(
		BRect(-100,-100,-100,-100),
		"TipManager",
		B_NO_BORDER_WINDOW_LOOK,
		B_FLOATING_ALL_WINDOW_FEEL,
		B_ASYNCHRONOUS_CONTROLS | B_AVOID_FOCUS),
	m_view(0) {
	
	AddCommonFilter(
		new BMessageFilter(
			B_PROGRAMMED_DELIVERY,
			B_ANY_SOURCE,
			&ignore_quit_key));
	
	m_view = new _TipManagerView(
		new TipWindow(),
		this,
		s_sleepPeriod,
		s_defIdleTime);
	AddChild(m_view);

	// start the window thread
	Show();
}
예제 #5
0
FindOpenFileWindow::FindOpenFileWindow(const char* panelText)
	:
	DWindow(BRect(0, 0, 0, 0), TR("Find and open file"), B_TITLED_WINDOW,
		B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS)
{
	AddCommonFilter(new EscapeCancelFilter());

	BView* top = GetBackgroundView();

	fNameTextControl = new AutoTextControl("nameText", TR("Open: "), "",
		new BMessage);
	fNameTextControl->SetExplicitMinSize(
		BSize(fNameTextControl->StringWidth("M") * 20, B_SIZE_UNSET));
	fSystemCheckBox = new BCheckBox("systembox", TR("Search only system folders"),
		new BMessage);

	BButton* cancel = new BButton("cancel", TR("Cancel"),
		new BMessage(B_QUIT_REQUESTED));

	BButton* open = new BButton("open", TR("Open"), new BMessage(M_FIND_FILE));

	BLayoutBuilder::Group<>(top, B_VERTICAL)
		.AddGrid(B_USE_DEFAULT_SPACING, B_USE_DEFAULT_SPACING)
			.Add(fNameTextControl->CreateLabelLayoutItem(), 0, 0)
			.Add(fNameTextControl->CreateTextViewLayoutItem(), 1, 0)
			.Add(fSystemCheckBox, 1, 1)
			.End()
		.AddGlue()
		.AddGroup(B_HORIZONTAL)
			.AddGlue()
			.Add(cancel)
			.Add(open)
			.End()
		.SetInsets(B_USE_WINDOW_INSETS)
		.End();

	BString text = panelText;
	if (text.CountChars() > 1) {
		fNameTextControl->SetText(text.String());
		int32 position = text.FindLast(".");
		if (position > 0)
			fNameTextControl->TextView()->Select(0, position);
		else
			fNameTextControl->TextView()->SelectAll();
	} else {
		fNameTextControl->SetText(".h");
		fNameTextControl->TextView()->GoToLine(0);
	}

	open->MakeDefault(true);

	fNameTextControl->MakeFocus(true);

	CenterOnScreen();
}
예제 #6
0
// constructor
PopupWindow::PopupWindow(PopupView* child, PopupControl* control)
	: MWindow(BRect(0.0, 0.0, 10.0, 10.0), "popup",
			  B_NO_BORDER_WINDOW_LOOK, B_FLOATING_ALL_WINDOW_FEEL,
			  B_ASYNCHRONOUS_CONTROLS),
	  fCanceled(true),
	  fControl(control)
{
	AddChild(child);
	child->SetPopupWindow(this);
	AddCommonFilter(new MouseDownFilter(this));
}
BStatusWindow::BStatusWindow()
	:
	BWindow(kStatusRect, B_TRANSLATE("Tracker status"),	B_TITLED_WINDOW,
		B_NOT_CLOSABLE | B_NOT_RESIZABLE | B_NOT_ZOOMABLE, B_ALL_WORKSPACES),
	fRetainDesktopFocus(false)
{
	SetSizeLimits(0, 100000, 0, 100000);
	fMouseDownFilter = new BStatusMouseFilter();
	AddCommonFilter(fMouseDownFilter);

	BView* view = new StatusBackgroundView(Bounds());
	AddChild(view);

	SetPulseRate(1000000);

	Hide();
	Show();
}
예제 #8
0
CreateParamsPanel::CreateParamsPanel(BWindow* window, BPartition* partition,
	off_t offset, off_t size)
	: BWindow(BRect(300.0, 200.0, 600.0, 300.0), 0, B_MODAL_WINDOW_LOOK,
		B_MODAL_SUBSET_WINDOW_FEEL,
		B_ASYNCHRONOUS_CONTROLS | B_AUTO_UPDATE_SIZE_LIMITS),
	fEscapeFilter(new EscapeFilter(this)),
	fExitSemaphore(create_sem(0, "CreateParamsPanel exit")),
	fWindow(window),
	fReturnValue(GO_CANCELED)
{
	AddCommonFilter(fEscapeFilter);

	// Scale offset, and size from bytes to megabytes (2^20)
	// so that we do not run over a signed int32.
	offset /= kMegaByte;
	size /= kMegaByte;
	_CreateViewControls(partition, offset, size);
}
예제 #9
0
CColorPicker::CColorPicker(BRect frame, const char *name, bool stayOpen)
	: BWindow(frame, name, stayOpen ? B_TITLED_WINDOW : B_MODAL_WINDOW,
		B_NOT_RESIZABLE | B_NOT_ZOOMABLE)
{
	fStayOpen = stayOpen;
	fCaller = NULL;
	
	BView *main = new BView(Bounds(), "main", 0, B_WILL_DRAW);
	AddChild(main);
	main->SetViewColor(kGray);
	
	BRect r(10, 10, 145, 130);
	fHSV = new CHSVView(r, "hsvview");
	main->AddChild(fHSV);
	
	r.Set(155, 10, 205, 130);
	fON = new CONView(r, "o&n");
	main->AddChild(fON);

	r.Set(215, 10, 380, 130);
	fRGB = new CRGBView(r, "rgbview");
	main->AddChild(fRGB);

	if (fStayOpen)
	{
		BRect b(Bounds());
		
		ResizeTo(b.Width(), b.Height() - 30);
	}
	else
	{
		r.Set(320, 140, 380, 160);
		BButton * ok = new BButton(r, "ok", "OK", new BMessage(msg_OK));
		main->AddChild(ok);
		ok->MakeDefault(true);
		
		r.Set(250, 140, 310, 160);
		main->AddChild(new BButton(r, "cancel", "Cancel", new BMessage(msg_Cancel)));

		// TPV 00-02-27
        KeyFilter * kf = new KeyFilter(B_ESCAPE, msg_Cancel) ;
        AddCommonFilter( kf ) ;
	}
} /* CColorPicker::CColorPicker */
예제 #10
0
파일: Alert.cpp 프로젝트: mmanley/Antares
BAlert::BAlert(BMessage* data)
	: BWindow(data)
{
	fInvoker = NULL;
	fAlertSem = -1;
	fAlertValue = -1;

	fTextView = (BTextView*)FindView("_tv_");

	fButtons[0] = (BButton*)FindView("_b0_");
	fButtons[1] = (BButton*)FindView("_b1_");
	fButtons[2] = (BButton*)FindView("_b2_");

	if (fButtons[2])
		SetDefaultButton(fButtons[2]);
	else if (fButtons[1])
		SetDefaultButton(fButtons[1]);
	else if (fButtons[0])
		SetDefaultButton(fButtons[0]);

	TAlertView* view = (TAlertView*)FindView("_master_");
	if (view)
		view->SetBitmap(_InitIcon());

	// Get keys
	char key;
	for (int32 i = 0; i < 3; ++i) {
		if (data->FindInt8("_but_key", i, (int8*)&key) == B_OK)
			fKeys[i] = key;
	}

	int32 temp;
	// Get alert type
	if (data->FindInt32("_atype", &temp) == B_OK)
		fMsgType = (alert_type)temp;

	// Get button width
	if (data->FindInt32("_but_width", &temp) == B_OK)
		fButtonWidth = (button_width)temp;

	AddCommonFilter(new(std::nothrow) _BAlertFilter_(this));
}
예제 #11
0
파일: Alert.cpp 프로젝트: tqh/haiku-efi
void
BAlert::_Init(const char* text, const char* button0, const char* button1,
	const char* button2, button_width buttonWidth, button_spacing spacing,
	alert_type type)
{
	fIconView = new TAlertView();

	fTextView = new BTextView("_tv_");
	fTextView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	rgb_color textColor = ui_color(B_PANEL_TEXT_COLOR);
	fTextView->SetFontAndColor(be_plain_font, B_FONT_ALL, &textColor);
	fTextView->MakeEditable(false);
	fTextView->MakeSelectable(false);
	fTextView->SetWordWrap(true);
	fTextView->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED, B_SIZE_UNLIMITED));

	fButtonLayout = new BGroupLayout(B_HORIZONTAL, B_USE_HALF_ITEM_SPACING);

	SetType(type);
	SetButtonWidth(buttonWidth);
	SetButtonSpacing(spacing);
	SetText(text);

	BLayoutBuilder::Group<>(this, B_HORIZONTAL, 0)
		.Add(fIconView)
		.AddGroup(B_VERTICAL, B_USE_HALF_ITEM_SPACING)
			.SetInsets(B_USE_HALF_ITEM_INSETS)
			.Add(fTextView)
			.AddGroup(B_HORIZONTAL, 0)
				.AddGlue()
				.Add(fButtonLayout);

	AddButton(button0);
	AddButton(button1);
	AddButton(button2);

	AddCommonFilter(new(std::nothrow) _BAlertFilter_(this));
}
예제 #12
0
RunArgsWindow::RunArgsWindow(Project *proj)
	:	DWindow(BRect(0,0,400,300),"Run Arguments",B_TITLED_WINDOW,
				B_ASYNCHRONOUS_CONTROLS | B_NOT_RESIZABLE),
		fProject(proj)
{
	AddCommonFilter(new EscapeCancelFilter());
	
	BView *top = GetBackgroundView();
	
	fArgText = new AutoTextControl(BRect(10,10,11,11),"argtext",TR("Arguments: "),
									fProject->GetRunArgs(), new BMessage,
									B_FOLLOW_LEFT_RIGHT | B_FOLLOW_TOP);
	top->AddChild(fArgText);
	fArgText->ResizeToPreferred();
	fArgText->ResizeTo(Bounds().Width() - 20,fArgText->Bounds().Height());
	fArgText->SetDivider(fArgText->StringWidth(TR("Arguments: ")) + 5);
	
	ResizeTo(Bounds().Width(),fArgText->Frame().bottom + 10);
	
	MakeCenteredOnShow(true);
	
	fArgText->MakeFocus(true);
	fArgText->TextView()->SelectAll();
}
예제 #13
0
ToolSelectionWindow::ToolSelectionWindow(BRect frame)
    : BWindow(frame, StringServer::ReturnString(TOOLS_STRING),
              B_FLOATING_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL, B_NOT_H_RESIZABLE |
              B_NOT_ZOOMABLE | B_WILL_ACCEPT_FIRST_CLICK | B_AVOID_FRONT)
{
    int32 pictureSize = LARGE_TOOL_ICON_SIZE + 4.0;

    window_feel feel = B_NORMAL_WINDOW_FEEL;
    if (SettingsServer* server = SettingsServer::Instance()) {
        server->SetValue(SettingsServer::Application, skSelectToolWindowVisible,
                         true);

        BMessage settings;
        server->GetApplicationSettings(&settings);
        settings.FindInt32(skSelectToolWindowFeel, (int32*)&feel);
    }

    fMatrixView = new MatrixView(pictureSize, pictureSize, kExtraEdge);

    _AddTool(ToolManager::Instance().ReturnTool(FREE_LINE_TOOL));
    _AddTool(ToolManager::Instance().ReturnTool(STRAIGHT_LINE_TOOL));
    _AddTool(ToolManager::Instance().ReturnTool(RECTANGLE_TOOL));
    _AddTool(ToolManager::Instance().ReturnTool(ELLIPSE_TOOL));

    // Here we could add a separator to the tool window.

    _AddTool(ToolManager::Instance().ReturnTool(BRUSH_TOOL));
    _AddTool(ToolManager::Instance().ReturnTool(HAIRY_BRUSH_TOOL));
    _AddTool(ToolManager::Instance().ReturnTool(AIR_BRUSH_TOOL));
    _AddTool(ToolManager::Instance().ReturnTool(BLUR_TOOL));
    _AddTool(ToolManager::Instance().ReturnTool(FILL_TOOL));
    _AddTool(ToolManager::Instance().ReturnTool(TEXT_TOOL));
    _AddTool(ToolManager::Instance().ReturnTool(TRANSPARENCY_TOOL));
    _AddTool(ToolManager::Instance().ReturnTool(ERASER_TOOL));
    _AddTool(ToolManager::Instance().ReturnTool(SELECTOR_TOOL));
    _AddTool(ToolManager::Instance().ReturnTool(COLOR_SELECTOR_TOOL));

    ToolMap::iterator it = gToolMap.find(ToolManager::Instance().ReturnActiveToolType());
    if (it != gToolMap.end())
        it->second->SetValue(B_CONTROL_ON);

    AddChild(fMatrixView);
    fMatrixView->ResizeTo(Bounds().Width(), Bounds().Height());

    SetFeel(feel);
    if (feel == B_NORMAL_WINDOW_FEEL)
        SetLook(B_TITLED_WINDOW_LOOK);
    else
        SetLook(B_FLOATING_WINDOW_LOOK);

    float minDimension = 2 * kExtraEdge + pictureSize;
    float maxDimension = 1 + kExtraEdge + fMatrixView->CountChildren() *
                         (pictureSize + kExtraEdge);
    SetSizeLimits(minDimension, maxDimension, minDimension, maxDimension);

    if (Lock()) {
        AddCommonFilter(new BMessageFilter(B_ANY_DELIVERY, B_ANY_SOURCE,
                                           B_MOUSE_DOWN, window_activation_filter));
        AddCommonFilter(new BMessageFilter(B_KEY_DOWN, AppKeyFilterFunction));
        Unlock();
    }

    Show();

    // NOTE: this is broken/ not implemented in Haiku, so the tools window
    //		 will not show up horizontal as it should be, enable if implemented
    //SetWindowAlignment(B_PIXEL_ALIGNMENT, 0, 0, picture_size + kExtraEdge,
    //	kExtraEdge + 1, 0, 0, picture_size + kExtraEdge, kExtraEdge + 1);

    // remove this if SetWindowAlignment is implemented
    ResizeBy(0.0, maxDimension - pictureSize);

    fSelectionWindow = this;
    FloaterManager::AddFloater(this);
}
예제 #14
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();
}
예제 #15
0
StartWindow::StartWindow(void)
	:	DWindow(BRect(0,0,400,300),"Paladin",B_DOCUMENT_WINDOW, B_NOT_ZOOMABLE)
{
	RegisterWindow();
	AddShortcut('O',B_COMMAND_KEY, new BMessage(M_SHOW_OPEN_PROJECT));
	AddShortcut('N',B_COMMAND_KEY, new BMessage(M_NEW_PROJECT));
	AddShortcut('I',B_COMMAND_KEY, new BMessage(M_SHOW_IMPORT));
	
	AddCommonFilter(new EscapeCancelFilter());
	
	MakeCenteredOnShow(true);
	
	BView *top = GetBackgroundView();
	
	fNewButton = MakeButton("new","NewProjectButtonUp.png","NewProjectButtonDown.png",
							M_NEW_PROJECT);
	top->AddChild(fNewButton);
	fNewButton->MoveTo(10,10);
		
	ClickableStringView *label = MakeLabel(fNewButton,TR("Create a new project"));
	top->AddChild(label);
	label->SetMessage(new BMessage(M_NEW_PROJECT));
	
	fOpenButton = MakeButton("open","OpenProjectButtonUp.png",
							"OpenProjectButtonDown.png", M_SHOW_OPEN_PROJECT);
	top->AddChild(fOpenButton);
	fOpenButton->MoveTo(10,fNewButton->Frame().bottom + 10.0);
	
	label = MakeLabel(fOpenButton,"Open a project");
	top->AddChild(label);
	label->SetMessage(new BMessage(M_SHOW_OPEN_PROJECT));
	
	fOpenRecentButton = MakeButton("openrecent","OpenRecentButtonUp.png",
									"OpenRecentButtonDown.png", M_OPEN_SELECTION);
	top->AddChild(fOpenRecentButton);
	fOpenRecentButton->MoveTo(10,fOpenButton->Frame().bottom + 10.0);
	SetToolTip(fOpenRecentButton,TR("Open a project in the list on the right. You "
									"can also press Command + a number key."));
	
	label = MakeLabel(fOpenRecentButton,TR("Open the selected project"));
	top->AddChild(label);
	label->SetMessage(new BMessage(M_OPEN_SELECTION));
	
	BRect r(Bounds());
	r.left = label->Frame().right + 20.0;
	r.right -= B_V_SCROLL_BAR_WIDTH + 10.0;
	r.top += 10.0;
	r.bottom -= 10.0;
	
	fListView = new StartWindowList(r);
	BScrollView *scrollView = new BScrollView("scroller",fListView,0,
											B_FOLLOW_ALL, false, true);
	top->AddChild(scrollView);
	fListView->SetInvocationMessage(new BMessage(M_OPEN_SELECTION));
	SetToolTip(fListView, "Open a recent project. You can also press Command + a number key.");
	
	fQuickImportButton = MakeButton("quickimport","QuickImportButtonUp.png",
									"QuickImportButtonDown.png",M_SHOW_IMPORT);
	top->AddChild(fQuickImportButton);
	fQuickImportButton->MoveTo(10,fOpenRecentButton->Frame().bottom + 10.0);
	
	label = MakeLabel(fQuickImportButton,"Import an existing project");
	top->AddChild(label);
	label->SetMessage(new BMessage(M_SHOW_IMPORT));
	SetToolTip(label,TR("Quickly make a project by importing all source files and resource files.\n"
						"You can also import a BeIDE project."));
	SetToolTip(fQuickImportButton,
				TR("Quickly make a project by importing all source files and resource files.\n"
					"You can also import a BeIDE project."));	
	fOnlineImportButton = MakeButton("onlineimport","OnlineImportButtonUp.png",
									"OnlineImportButtonDown.png",M_ONLINE_IMPORT);
	top->AddChild(fOnlineImportButton);
	fOnlineImportButton->MoveTo(10,fQuickImportButton->Frame().bottom + 10.0);
	
	label = MakeLabel(fOnlineImportButton,"Import a project from online");
	top->AddChild(label);
	label->SetMessage(new BMessage(M_ONLINE_IMPORT));
	SetToolTip(label,TR("Import a project from an online repository"));
	SetToolTip(fQuickImportButton,
				TR("Import a project from an online repository"));

	
	#ifdef DISABLE_ONLINE_IMPORT
	
	fOnlineImportButton->Hide();
	SetSizeLimits(scrollView->Frame().left + 110.0,30000,
				fQuickImportButton->Frame().bottom + 10.0,30000);
	ResizeTo(scrollView->Frame().left + 160.0,fQuickImportButton->Frame().bottom + 10.0);
	
	#else
	
	SetSizeLimits(scrollView->Frame().left + 110.0,30000,
				fOnlineImportButton->Frame().bottom + 10.0,30000);
	ResizeTo(scrollView->Frame().left + 160.0,fOnlineImportButton->Frame().bottom + 10.0);
	
	#endif
	
	BMessenger msgr(this);
	BEntry entry(gProjectPath.GetFullPath());
	entry_ref ref;
	entry.GetRef(&ref);
	fOpenPanel = new BFilePanel(B_OPEN_PANEL,&msgr,&ref,B_FILE_NODE,true,
								new BMessage(M_OPEN_PROJECT));
	BString titleString(TR("Open Project"));
	titleString.Prepend("Paladin: ");
	fOpenPanel->Window()->SetTitle(titleString.String());
	
	fImportPanel = new BFilePanel(B_OPEN_PANEL,&msgr,&ref,B_DIRECTORY_NODE,true,
								new BMessage(M_QUICK_IMPORT));
	titleString = TR("Choose Project Folder");
	titleString.Prepend("Paladin: ");
	fImportPanel->Window()->SetTitle(titleString.String());
	
	gSettings.Lock();
	int32 index = 0;
	while (gSettings.FindRef("recentitems",index++,&ref) == B_OK)
	{
		if (!BEntry(&ref).Exists())
		{
			index--;
			gSettings.RemoveData("recentitems",index);
		}
		else
			fListView->AddItem(new RefStringItem(ref),0);
	}
	gSettings.Unlock();
	
	// Alt + number opens that number project from the list
	int32 count = (fListView->CountItems() > 9) ? 9 : fListView->CountItems();
	for (int32 i = 0; i < count; i++)
	{
		BMessage *listMsg = new BMessage(M_OPEN_FROM_LIST);
		listMsg->AddInt32("index", i);
		AddShortcut('1' + i, B_COMMAND_KEY, listMsg);
	}
	
	fNewButton->MakeFocus(true);
}
예제 #16
0
TFilePanel::TFilePanel(file_panel_mode mode, BMessenger* target,
	const BEntry* startDir, uint32 nodeFlavors, bool multipleSelection,
	BMessage* message, BRefFilter* filter, uint32 containerWindowFlags,
	window_look look, window_feel feel, bool hideWhenDone)
	:
	BContainerWindow(0, containerWindowFlags, look, feel, 0,
		B_CURRENT_WORKSPACE),
	fDirMenu(NULL),
	fDirMenuField(NULL),
	fTextControl(NULL),
	fClientObject(NULL),
	fSelectionIterator(0),
	fMessage(NULL),
	fHideWhenDone(hideWhenDone),
	fIsTrackingMenu(false)
{
	InitIconPreloader();

	fIsSavePanel = (mode == B_SAVE_PANEL);

	BRect windRect(85, 50, 568, 296);
	MoveTo(windRect.LeftTop());
	ResizeTo(windRect.Width(), windRect.Height());

	fNodeFlavors = (nodeFlavors == 0) ? B_FILE_NODE : nodeFlavors;

	if (target)
		fTarget = *target;
	else
		fTarget = BMessenger(be_app);

	if (message)
		SetMessage(message);
	else if (fIsSavePanel)
		fMessage = new BMessage(B_SAVE_REQUESTED);
	else
		fMessage = new BMessage(B_REFS_RECEIVED);

	gLocalizedNamePreferred
		= BLocaleRoster::Default()->IsFilesystemTranslationPreferred();

	// check for legal starting directory
	Model* model = new Model();
	bool useRoot = true;

	if (startDir) {
		if (model->SetTo(startDir) == B_OK && model->IsDirectory())
			useRoot = false;
		else {
			delete model;
			model = new Model();
		}
	}

	if (useRoot) {
		BPath path;
		if (find_directory(B_USER_DIRECTORY, &path) == B_OK) {
			BEntry entry(path.Path(), true);
			if (entry.InitCheck() == B_OK && model->SetTo(&entry) == B_OK)
				useRoot = false;
		}
	}

	if (useRoot) {
		BVolume volume;
		BDirectory root;
		BVolumeRoster volumeRoster;
		volumeRoster.GetBootVolume(&volume);
		volume.GetRootDirectory(&root);

		BEntry entry;
		root.GetEntry(&entry);
		model->SetTo(&entry);
	}

	fTaskLoop = new PiggybackTaskLoop;

	AutoLock<BWindow> lock(this);
	CreatePoseView(model);
	fPoseView->SetRefFilter(filter);
	if (!fIsSavePanel)
		fPoseView->SetMultipleSelection(multipleSelection);

	fPoseView->SetFlags(fPoseView->Flags() | B_NAVIGABLE);
	fPoseView->SetPoseEditing(false);
	AddCommonFilter(new BMessageFilter(B_KEY_DOWN, key_down_filter));
	AddCommonFilter(new BMessageFilter(B_SIMPLE_DATA,
		TFilePanel::MessageDropFilter));
	AddCommonFilter(new BMessageFilter(B_NODE_MONITOR, TFilePanel::FSFilter));

	// inter-application observing
	BMessenger tracker(kTrackerSignature);
	BHandler::StartWatching(tracker, kDesktopFilePanelRootChanged);

	Init();
}
예제 #17
0
ProjectSettingsWindow::ProjectSettingsWindow(BRect frame, Project* project)
	:
	BWindow(frame, TR("Project settings"), B_TITLED_WINDOW,
		B_NOT_ZOOMABLE | B_NOT_RESIZABLE | B_AUTO_UPDATE_SIZE_LIMITS),
	fProject(project),
	fDirty(false)
{
	if (fProject == NULL)
		debugger("Bad project given to Project Settings window");

	fRefFilter = new TypedRefFilter(NULL, B_DIRECTORY_NODE);

	BMessenger messenger(this);
	entry_ref projectFolderRef;
	BEntry(fProject->GetPath().GetFolder()).GetRef(&projectFolderRef);
	fFilePanel = new BFilePanel(B_OPEN_PANEL, &messenger, &projectFolderRef,
		B_DIRECTORY_NODE, true, new BMessage(M_ADD_PATH), fRefFilter);

	fAutolock = new BAutolock(fProject);

	AddCommonFilter(new EscapeCancelFilter());

	fTargetText = new AutoTextControl("targetname", TR("Target name:"),
		fProject->GetTargetName(), new BMessage(M_TARGET_NAME_CHANGED));

	BPopUpMenu* targetTypeMenu = new BPopUpMenu(TR("Target type"));
	targetTypeMenu->AddItem(new BMenuItem(TR("Application"),
		new BMessage(M_SET_TARGET_TYPE)));
	targetTypeMenu->AddItem(new BMenuItem(TR("Shared library"),
		new BMessage(M_SET_TARGET_TYPE)));
	targetTypeMenu->AddItem(new BMenuItem(TR("Static library"),
		new BMessage(M_SET_TARGET_TYPE)));
	targetTypeMenu->AddItem(new BMenuItem(TR("Device driver"),
		new BMessage(M_SET_TARGET_TYPE)));

	fTypeField = new BMenuField("type", TR("Target type:"), targetTypeMenu);
	SetToolTip(fTypeField, TR("The kind of program you want to build"));

	BMenuItem* item = targetTypeMenu->ItemAt(fProject->TargetType());
	if (item != NULL)
		item->SetMarked(true);

	fIncludeList = new IncludeList(fProject->GetPath().GetFolder());
	SetToolTip(fIncludeList,
		TR("The folders you want Paladin to search for header files"));

	BScrollView* includeScrollView = new BScrollView("includescrollview",
		fIncludeList, B_WILL_DRAW, true, true);
	includeScrollView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	includeScrollView->SetExplicitMinSize(
		BSize(be_plain_font->StringWidth("M") * 34.0f,
			be_plain_font->StringWidth("M") * 12.0f));

	for (int32 i = 0; i < fProject->CountLocalIncludes(); i++) {
		fIncludeList->AddItem(new BStringItem(
			fProject->LocalIncludeAt(i).Relative().String()));
	}

	float buttonWidth = be_plain_font->StringWidth("+") * 2.0f + 3.0f;

	BButton* addButton = new BButton("addbutton", TR("+"),
		new BMessage(M_SHOW_ADD_PATH));
	addButton->SetExplicitSize(BSize(buttonWidth, buttonWidth));
	addButton->SetToolTip(TR("Add a file to the include path list"));

	BButton* removeButton = new BButton("removebutton", TR("−"),
		new BMessage(M_REMOVE_PATH));
	removeButton->SetExplicitSize(BSize(buttonWidth, buttonWidth));
	removeButton->SetToolTip(TR("Remove the selected path"));

	// general tab

	fGeneralView = new BView(TR("General"), B_WILL_DRAW);
	fGeneralView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));

	BLayoutBuilder::Group<>(fGeneralView, B_VERTICAL, 0)
		.AddGrid(B_USE_DEFAULT_SPACING, B_USE_SMALL_SPACING)
			.Add(fTargetText->CreateLabelLayoutItem(), 0, 0)
			.Add(fTargetText->CreateTextViewLayoutItem(), 1, 0)

			.Add(fTypeField->CreateLabelLayoutItem(), 0, 1)
			.AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING, 1, 1)
				.Add(fTypeField->CreateMenuBarLayoutItem())
				.AddGlue()
				.End()
			.End()
		.AddStrut(B_USE_DEFAULT_SPACING)
		.AddGroup(B_VERTICAL, 2.0f)
			.Add(new BStringView("include paths", TR("Include paths:")))
			.AddGroup(B_HORIZONTAL, B_USE_SMALL_SPACING)
				.Add(includeScrollView)
				.AddGroup(B_VERTICAL, B_USE_SMALL_SPACING)
					.Add(addButton)
					.Add(removeButton)
					.AddGlue()
					.End()
				.End()
			.End()
		.SetInsets(B_USE_DEFAULT_SPACING)
		.End();

	BPopUpMenu* optimizationMenu = new BPopUpMenu(TR("Optimization"));
	optimizationMenu->AddItem(new BMenuItem(TR("None"),
		new BMessage(M_SET_OP_VALUE)));
	optimizationMenu->AddItem(new BMenuItem(TR("Some"),
		new BMessage(M_SET_OP_VALUE)));
	optimizationMenu->AddItem(new BMenuItem(TR("More"),
		new BMessage(M_SET_OP_VALUE)));
	optimizationMenu->AddItem(new BMenuItem(TR("Full"),
		new BMessage(M_SET_OP_VALUE)));

	fOpField = new BMenuField("optimize", TR("Optimize:"), optimizationMenu);
	SetToolTip(fOpField, TR("Compiler optimization level. "
		"Disabled when debugging info is checked."));

	item = optimizationMenu->ItemAt(fProject->OpLevel());
	if (item != NULL)
		item->SetMarked(true);

	fOpSizeBox = new BCheckBox("opsizebox", TR("Optimize for size over speed"),
		new BMessage(M_TOGGLE_OPSIZE));

	if (fProject->OpForSize())
		fOpSizeBox->SetValue(B_CONTROL_ON);
	
	if (fProject->Debug()) {
		fOpField->SetEnabled(false);
		fOpSizeBox->SetEnabled(false);
	}

	fDebugBox = new BCheckBox("debugbox", TR("Build debugging information"),
		new BMessage(M_TOGGLE_DEBUG));
	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."));

	if (fProject->Debug())
		fDebugBox->SetValue(B_CONTROL_ON);

	fProfileBox = new BCheckBox("profilebox", TR("Build profiling information"),
		new BMessage(M_TOGGLE_PROFILE));
	SetToolTip(fProfileBox,
		TR("Check this if you want to use your program "
		   "with gprof or bprof for profiling."));

	if (fProject->Profiling())
		fProfileBox->SetValue(B_CONTROL_ON);

	fCompileText = new AutoTextControl("extracc", "Extra compiler options:",
		fProject->ExtraCompilerOptions(), new BMessage(M_CCOPTS_CHANGED));
	SetToolTip(fCompileText,
		TR("Extra GCC flags you wish included when each file is compiled."));

	fLinkText = new AutoTextControl("extrald" ,TR("Extra linker options:"),
		fProject->ExtraLinkerOptions(), new BMessage(M_LDOPTS_CHANGED));
	SetToolTip(fLinkText,
		TR("Extra GCC linker flags you wish included when your project "
		   "is linked."));

	// build tab

	fBuildView = new BView("Build", B_WILL_DRAW);
	fBuildView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));

	BLayoutBuilder::Group<>(fBuildView, B_VERTICAL)
		.AddGrid(B_USE_DEFAULT_SPACING, B_USE_SMALL_SPACING)
			.Add(fOpField->CreateLabelLayoutItem(), 0, 0)
			.AddGroup(B_HORIZONTAL, B_USE_DEFAULT_SPACING, 1, 0)
				.Add(fOpField->CreateMenuBarLayoutItem())
				.AddGlue()
				.End()
			.AddGroup(B_VERTICAL, 0.0f, 1, 2)
				.Add(fOpSizeBox)
				.AddStrut(B_USE_SMALL_SPACING)
				.Add(fDebugBox)
				.Add(fProfileBox)
				.End()
			.End()
		.AddGlue()
		.AddGroup(B_VERTICAL, 0)
			.Add(fCompileText->CreateLabelLayoutItem())
			.Add(fCompileText->CreateTextViewLayoutItem())
			.End()
		.AddGroup(B_VERTICAL, 0)
			.Add(fLinkText->CreateLabelLayoutItem())
			.Add(fLinkText->CreateTextViewLayoutItem())
			.End()
		.SetInsets(B_USE_DEFAULT_SPACING)
		.End();

	fTabView = new BTabView("tabview", B_WIDTH_FROM_LABEL);
	fTabView->SetBorder(B_NO_BORDER);
	fTabView->AddTab(fGeneralView);
	fTabView->AddTab(fBuildView);
	fTabView->Select(0L);

	BLayoutBuilder::Group<>(this, B_VERTICAL, 0)
		.AddStrut(B_USE_SMALL_SPACING)
		.Add(fTabView)
		.End();

	targetTypeMenu->SetTargetForItems(this);
	optimizationMenu->SetTargetForItems(this);

	fIncludeList->Select(0);
	fTargetText->MakeFocus(true);
}
예제 #18
0
CharacterWindow::CharacterWindow()
	: BWindow(BRect(100, 100, 700, 550), "CharacterMap", B_TITLED_WINDOW,
		B_ASYNCHRONOUS_CONTROLS | B_QUIT_ON_WINDOW_CLOSE
			| B_AUTO_UPDATE_SIZE_LIMITS)
{
	BMessage settings;
	_LoadSettings(settings);

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

	// create GUI

	SetLayout(new BGroupLayout(B_VERTICAL));

	BMenuBar* menuBar = new BMenuBar("menu");

	fFilterControl = new BTextControl("Filter:", NULL, NULL);
	fFilterControl->SetModificationMessage(new BMessage(kMsgFilterChanged));

	BButton* clearButton = new BButton("clear", "Clear",
		new BMessage(kMsgClearFilter));

	fUnicodeBlockView = new UnicodeBlockView("unicodeBlocks");
	fUnicodeBlockView->SetSelectionMessage(
		new BMessage(kMsgUnicodeBlockSelected));

	BScrollView* unicodeScroller = new BScrollView("unicodeScroller",
		fUnicodeBlockView, 0, false, true);

	fCharacterView = new CharacterView("characters");
	fCharacterView->SetTarget(this, kMsgCharacterChanged);

	// TODO: have a context object shared by CharacterView/UnicodeBlockView
	bool show;
	if (settings.FindBool("show private blocks", &show) == B_OK) {
		fCharacterView->ShowPrivateBlocks(show);
		fUnicodeBlockView->ShowPrivateBlocks(show);
	}
	if (settings.FindBool("show contained blocks only", &show) == B_OK) {
		fCharacterView->ShowContainedBlocksOnly(show);
		fUnicodeBlockView->ShowPrivateBlocks(show);
	}

	const char* family;
	const char* style;
	if (settings.FindString("font family", &family) == B_OK
		&& settings.FindString("font style", &style) == B_OK) {
		_SetFont(family, style);
	}

	int32 fontSize;
	if (settings.FindInt32("font size", &fontSize) == B_OK) {
		BFont font = fCharacterView->CharacterFont();
		if (fontSize < kMinFontSize)
			fontSize = kMinFontSize;
		else if (fontSize > kMaxFontSize)
			fontSize = kMaxFontSize;
		font.SetSize(fontSize);

		fCharacterView->SetCharacterFont(font);
	} else
		fontSize = (int32)fCharacterView->CharacterFont().Size();

	BScrollView* characterScroller = new BScrollView("characterScroller",
		fCharacterView, 0, false, true);

	fFontSizeSlider = new FontSizeSlider("fontSizeSlider", "Font size:",
		new BMessage(kMsgFontSizeChanged), kMinFontSize, kMaxFontSize);
	fFontSizeSlider->SetValue(fontSize);

	fCodeView = new BStringView("code", "-");
	fCodeView->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED,
		fCodeView->PreferredSize().Height()));

	AddChild(BGroupLayoutBuilder(B_VERTICAL)
		.Add(menuBar)
		.Add(BGroupLayoutBuilder(B_HORIZONTAL, 10)//BSplitLayoutBuilder()
			.Add(BGroupLayoutBuilder(B_VERTICAL, 10)
				.Add(BGroupLayoutBuilder(B_HORIZONTAL, 10)
					.Add(fFilterControl)
					.Add(clearButton))
				.Add(unicodeScroller))
			.Add(BGroupLayoutBuilder(B_VERTICAL, 10)
				.Add(characterScroller)
				.Add(fFontSizeSlider)
				.Add(fCodeView))
			.SetInsets(10, 10, 10, 10)));

	// Add menu

	// "File" menu
	BMenu* menu = new BMenu("File");
	BMenuItem* item;

	menu->AddItem(item = new BMenuItem("About CharacterMap" B_UTF8_ELLIPSIS,
		new BMessage(B_ABOUT_REQUESTED)));

	menu->AddSeparatorItem();

	menu->AddItem(new BMenuItem("Quit", new BMessage(B_QUIT_REQUESTED), 'Q'));
	menu->SetTargetForItems(this);
	item->SetTarget(be_app);
	menuBar->AddItem(menu);

	menu = new BMenu("View");
	menu->AddItem(item = new BMenuItem("Show private blocks",
		new BMessage(kMsgPrivateBlocks)));
	item->SetMarked(fCharacterView->IsShowingPrivateBlocks());
// TODO: this feature is not yet supported by Haiku!
#if 0
	menu->AddItem(item = new BMenuItem("Only show blocks contained in font",
		new BMessage(kMsgContainedBlocks)));
	item->SetMarked(fCharacterView->IsShowingContainedBlocksOnly());
#endif
	menuBar->AddItem(menu);

	menuBar->AddItem(_CreateFontMenu());

	AddCommonFilter(new EscapeMessageFilter(kMsgClearFilter));
	AddCommonFilter(new RedirectUpAndDownFilter(fUnicodeBlockView));

	// TODO: why is this needed?
	fUnicodeBlockView->SetTarget(this);

	fFilterControl->MakeFocus();
}
예제 #19
0
CharacterWindow::CharacterWindow()
	:
	BWindow(BRect(100, 100, 700, 550), B_TRANSLATE_SYSTEM_NAME("CharacterMap"),
		B_TITLED_WINDOW, B_ASYNCHRONOUS_CONTROLS | B_QUIT_ON_WINDOW_CLOSE
			| B_AUTO_UPDATE_SIZE_LIMITS)
{
	BMessage settings;
	_LoadSettings(settings);

	BRect frame;
	if (settings.FindRect("window frame", &frame) == B_OK) {
		MoveTo(frame.LeftTop());
		ResizeTo(frame.Width(), frame.Height());
	} else {
		float scaling = be_plain_font->Size() / 12.0f;
		ResizeTo(Frame().Width() * scaling, Frame().Height() * scaling);
		CenterOnScreen();
	}

	// create GUI
	BMenuBar* menuBar = new BMenuBar("menu");

	fFilterControl = new BTextControl(B_TRANSLATE("Filter:"), NULL, NULL);
	fFilterControl->SetModificationMessage(new BMessage(kMsgFilterChanged));

	BButton* clearButton = new BButton("clear", B_TRANSLATE("Clear"),
		new BMessage(kMsgClearFilter));

	fUnicodeBlockView = new UnicodeBlockView("unicodeBlocks");
	fUnicodeBlockView->SetSelectionMessage(
		new BMessage(kMsgUnicodeBlockSelected));

	BScrollView* unicodeScroller = new BScrollView("unicodeScroller",
		fUnicodeBlockView, 0, false, true);

	fCharacterView = new CharacterView("characters");
	fCharacterView->SetTarget(this, kMsgCharacterChanged);

	fGlyphView = new BStringView("glyph", "");
	fGlyphView->SetExplicitMaxSize(BSize(B_SIZE_UNSET,
		fGlyphView->PreferredSize().Height()));

	// TODO: have a context object shared by CharacterView/UnicodeBlockView
	bool show;
	if (settings.FindBool("show private blocks", &show) == B_OK) {
		fCharacterView->ShowPrivateBlocks(show);
		fUnicodeBlockView->ShowPrivateBlocks(show);
	}
	if (settings.FindBool("show contained blocks only", &show) == B_OK) {
		fCharacterView->ShowContainedBlocksOnly(show);
		fUnicodeBlockView->ShowPrivateBlocks(show);
	}

	const char* family;
	const char* style;
	BString displayName;

	if (settings.FindString("font family", &family) == B_OK
		&& settings.FindString("font style", &style) == B_OK) {
		_SetFont(family, style);
		displayName << family << " " << style;
	} else {
		font_family currentFontFamily;
		font_style currentFontStyle;
		fCharacterView->CharacterFont().GetFamilyAndStyle(&currentFontFamily,
			&currentFontStyle);
		displayName << currentFontFamily << " " << currentFontStyle;
	}

	int32 fontSize;
	if (settings.FindInt32("font size", &fontSize) == B_OK) {
		BFont font = fCharacterView->CharacterFont();
		if (fontSize < kMinFontSize)
			fontSize = kMinFontSize;
		else if (fontSize > kMaxFontSize)
			fontSize = kMaxFontSize;
		font.SetSize(fontSize);

		fCharacterView->SetCharacterFont(font);
	} else
		fontSize = (int32)fCharacterView->CharacterFont().Size();

	BScrollView* characterScroller = new BScrollView("characterScroller",
		fCharacterView, 0, false, true);

	fFontSizeSlider = new FontSizeSlider("fontSizeSlider",
		displayName,
		new BMessage(kMsgFontSizeChanged), kMinFontSize, kMaxFontSize);
	fFontSizeSlider->SetValue(fontSize);

	fCodeView = new BStringView("code", "-");
	fCodeView->SetExplicitMaxSize(BSize(B_SIZE_UNLIMITED,
		fCodeView->PreferredSize().Height()));

	// Set minimum width for character pane to prevent UI
	// from jumping when longer code strings are displayed.
	// use 'w' character for sizing as it's likely the widest
	// character for a Latin font.  40 characters is a little
	// wider than needed so hopefully this covers other
	// non-Latin fonts that may be wider.
	BFont viewFont;
	fCodeView->GetFont(&viewFont);
	fCharacterView->SetExplicitMinSize(BSize(viewFont.StringWidth("w") * 40,
		B_SIZE_UNSET));

	BLayoutBuilder::Group<>(this, B_VERTICAL, 0)
		.Add(menuBar)
		.AddGroup(B_HORIZONTAL)
			.SetInsets(B_USE_WINDOW_SPACING)
			.AddGroup(B_VERTICAL)
				.AddGroup(B_HORIZONTAL)
					.Add(fFilterControl)
					.Add(clearButton)
				.End()
				.Add(unicodeScroller)
			.End()
			.AddGroup(B_VERTICAL)
				.Add(characterScroller)
				.Add(fFontSizeSlider)
				.AddGroup(B_HORIZONTAL)
					.Add(fGlyphView)
					.Add(fCodeView);

	// Add menu

	// "File" menu
	BMenu* menu = new BMenu(B_TRANSLATE("File"));
	BMenuItem* item;

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

	menu = new BMenu(B_TRANSLATE("View"));
	menu->AddItem(item = new BMenuItem(B_TRANSLATE("Show private blocks"),
		new BMessage(kMsgPrivateBlocks)));
	item->SetMarked(fCharacterView->IsShowingPrivateBlocks());
// TODO: this feature is not yet supported by Haiku!
#if 0
	menu->AddItem(item = new BMenuItem("Only show blocks contained in font",
		new BMessage(kMsgContainedBlocks)));
	item->SetMarked(fCharacterView->IsShowingContainedBlocksOnly());
#endif
	menuBar->AddItem(menu);

	fFontMenu = _CreateFontMenu();
	menuBar->AddItem(fFontMenu);

	AddCommonFilter(new EscapeMessageFilter(kMsgClearFilter));
	AddCommonFilter(new RedirectUpAndDownFilter(fUnicodeBlockView));

	// TODO: why is this needed?
	fUnicodeBlockView->SetTarget(this);

	fFilterControl->MakeFocus();

	fUnicodeBlockView->SelectBlockForCharacter(0);
}
예제 #20
0
void
HWindow::Init(uint32 escape_msg)
{
	AddShortcut('i', 0, new BMessage(B_ABOUT_REQUESTED));
	AddCommonFilter(new EscapeMessageFilter(this, escape_msg));	
}
예제 #21
0
TextEntryAlert::TextEntryAlert(const char* title, const char* info_text, const char* initial_entry_text,
	const char* button_0_label, const char* button_1_label, bool inline_label, float min_text_box_width,
	int min_text_box_rows, button_width width_style, bool multi_line, const BRect* frame,
	window_look look, window_feel feel, uint32 flags)
: BWindow((frame?*frame:BRect(50,50,60,60)),title,look,feel,flags)
{
	//Get unadjusted sizes of the two text boxes
	BRect info_text_box;
	BRect entry_text_rect;
	const char* strings[2] = {info_text?info_text:"",initial_entry_text?initial_entry_text:""};
	escapement_delta zero_escapements[2] = {{0,0},{0,0}};
	BRect result_rects[2];
	be_plain_font->GetBoundingBoxesForStrings(strings,2,B_SCREEN_METRIC,zero_escapements,result_rects);
	struct font_height plain_font_height;
	be_plain_font->GetHeight(&plain_font_height);
	info_text_box = result_rects[0];

	//Position and create label
	m_label_view = NULL;
	if(info_text)
	{
		info_text_box.OffsetTo(c_item_spacing,c_item_spacing);
		if(inline_label)
			info_text_box.OffsetBy(0,c_text_border_width+c_text_margin);
		else
			info_text_box.OffsetBy(c_non_inline_label_spacing,-2);
		info_text_box.bottom += 2;		//Compensate for offset used by BTextView
		info_text_box.right += 1;
		m_label_view = new BTextView(info_text_box,NULL,info_text_box.OffsetToCopy(0,0),
			B_FOLLOW_LEFT|B_FOLLOW_TOP,B_WILL_DRAW);
		m_label_view->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
		m_label_view->SetText(info_text);
		m_label_view->MakeEditable(false);
		m_label_view->MakeSelectable(false);
		m_label_view->SetWordWrap(false);
		float textHeight = m_label_view->TextHeight( 0, 10000);
		info_text_box.bottom = info_text_box.top + textHeight;
		m_label_view->ResizeTo( m_label_view->Bounds().Width(), textHeight+4);
	}
	else
	{
		info_text_box.Set(0,0,0,0);
		inline_label = false;
	}

//	info_text_box.bottom = info_text_box.top + ceil(plain_font_height.ascent) +
//		ceil(plain_font_height.descent);
	entry_text_rect = result_rects[1].IsValid() ? result_rects[1] : BRect(0, 0, min_text_box_width - 1, 0);
	entry_text_rect.bottom = entry_text_rect.top +
		(ceilf(plain_font_height.ascent)+ceilf(plain_font_height.descent))*float(min_text_box_rows) +
		ceilf(plain_font_height.leading)*float(min_text_box_rows-1);
	entry_text_rect.InsetBy(0-(c_text_margin+c_text_border_width),
		0-(c_text_margin+c_text_border_width));
	if(entry_text_rect.Width() < min_text_box_width)
		entry_text_rect.right = entry_text_rect.left+min_text_box_width;
	entry_text_rect.bottom -= 1;			//To make it look like BTextControl


	//Create buttons
	m_buttons[0] = NULL;
	m_buttons[1] = NULL;
	BMessage* message;
	float button_0_width, button_1_width, buttons_height;
	float max_buttons_width = 0;
	if(button_0_label != NULL)
	{
		message = new BMessage(c_button_pressed);
		message->AddInt32("which",0);
		m_buttons[0] = new BButton(BRect(0,0,0,0),button_0_label,button_0_label,message,B_FOLLOW_LEFT|
			B_FOLLOW_BOTTOM);
		m_buttons[0]->GetPreferredSize(&button_0_width,&buttons_height);
		max_buttons_width = button_0_width;
	}
	if(button_1_label != NULL)
	{
		message = new BMessage(c_button_pressed);
		message->AddInt32("which",1);
		m_buttons[1] = new BButton(BRect(0,0,0,0),button_1_label,button_1_label,message,B_FOLLOW_RIGHT|
			B_FOLLOW_BOTTOM);
		m_buttons[1]->GetPreferredSize(&button_1_width,&buttons_height);
		if(max_buttons_width < button_1_width)
			max_buttons_width = button_1_width;
	}
	
	//Position and create text entry box
	if(inline_label)
		entry_text_rect.OffsetTo(info_text_box.right+c_inline_label_spacing,c_item_spacing);
	else
		entry_text_rect.OffsetTo(c_item_spacing,info_text_box.bottom+c_non_inline_label_spacing);
	if(frame != NULL)
	{
		if(entry_text_rect.left + min_text_box_width < frame->Width()-c_item_spacing)
			entry_text_rect.right = frame->Width()+c_item_spacing;
		else
			entry_text_rect.right = entry_text_rect.left + min_text_box_width;
		if(min_text_box_rows > 1)
		{
			float bottom = frame->Height()-c_item_spacing;
			if(button_0_label != NULL || button_1_label != NULL)
				bottom -= (buttons_height+c_item_spacing);
			if(bottom > entry_text_rect.bottom)
				entry_text_rect.bottom = bottom;
		}
	}

	m_text_entry_view = new TextEntryAlertTextEntryView(entry_text_rect.InsetByCopy(c_text_border_width,
		c_text_border_width),multi_line);
	if(initial_entry_text)
		m_text_entry_view->SetText(initial_entry_text);

	//Position the buttons
	BButton* right_button = NULL;
	if(m_buttons[1] != NULL)
		right_button = m_buttons[1];
	else if(m_buttons[0] != NULL)
		right_button = m_buttons[0];
	if(right_button != NULL)
	{
		if(width_style == B_WIDTH_AS_USUAL)
			right_button->ResizeTo(c_usual_button_width,buttons_height);
		else if(width_style == B_WIDTH_FROM_LABEL)
			right_button->ResizeTo(right_button==m_buttons[1]?button_1_width:button_0_width,
				buttons_height);
		else //(width_style == B_WIDTH_FROM_WIDEST)
			right_button->ResizeTo(max_buttons_width,buttons_height);
		right_button->MoveTo(entry_text_rect.right-right_button->Frame().Width()+1,
			entry_text_rect.bottom+c_item_spacing);
		if(!multi_line)
			right_button->MakeDefault(true);
	}
	if(m_buttons[0] != NULL && m_buttons[1] != NULL)
	{
		float button_left;
		if(width_style == B_WIDTH_AS_USUAL)
			m_buttons[0]->ResizeTo(c_usual_button_width,buttons_height);
		else if(width_style == B_WIDTH_FROM_LABEL)
			m_buttons[0]->ResizeTo(button_0_width,buttons_height);
		else //if(width_style == B_WIDTH_FROM_WIDEST)
			m_buttons[0]->ResizeTo(max_buttons_width,buttons_height);
		button_left = right_button->Frame().left-m_buttons[0]->Frame().Width()-10;
		m_buttons[0]->MoveTo(button_left,entry_text_rect.bottom+c_item_spacing);
	}

	//Resize the window
	float height;
	if(m_buttons[0])
		height = m_buttons[0]->Frame().bottom+c_item_spacing-1;
	else if(m_buttons[1])
		height = m_buttons[1]->Frame().bottom+c_item_spacing-1;
	else
		height = entry_text_rect.bottom+c_item_spacing-1;
	ResizeTo(entry_text_rect.right+c_item_spacing,height);

	BRect bounds = Bounds();
	if(frame == NULL)
	{
		BRect screen_frame = BScreen().Frame();
		MoveTo(ceilf((screen_frame.Width()-bounds.Width())/2),
			ceilf((screen_frame.Height()-bounds.Height()-19)/2));
	}

	//Create the background view and add the children
	BView* filler = new TextEntryAlertBackgroundView(bounds,entry_text_rect);
	if(m_label_view)
		filler->AddChild(m_label_view);
	filler->AddChild(m_text_entry_view);
	if(m_buttons[0])
		filler->AddChild(m_buttons[0]);
	if(m_buttons[1])
		filler->AddChild(m_buttons[1]);
	AddChild(filler);

	//Complete the setup
	m_invoker = NULL;
	m_done_mutex = B_ERROR;
	m_button_pressed = NULL;
	float min_width = c_item_spacing;
	if(m_buttons[0])
		min_width += (m_buttons[0]->Frame().Width() + c_item_spacing);
	if(m_buttons[1])
		min_width += (m_buttons[0]->Frame().Width() + c_item_spacing);
	if(min_width < 120)
		min_width = 120;
	float min_height = entry_text_rect.top;
	min_height += (ceilf(plain_font_height.ascent)+ceilf(plain_font_height.descent));
	min_height += ((c_text_margin+c_text_border_width)*2 + c_item_spacing);
	if(m_buttons[0] || m_buttons[1])
		min_height += (buttons_height + c_item_spacing);
	min_width -= 2;		//Need this for some reason
	min_height -= 2;
	m_text_entry_buffer = NULL;
	SetSizeLimits(min_width,100000,min_height,100000);
	AddCommonFilter(new BMessageFilter(B_KEY_DOWN,KeyDownFilterStatic));
	m_shortcut[0] = 0;
	m_shortcut[1] = 0;
}
예제 #22
0
파일: Alert.cpp 프로젝트: mmanley/Antares
void
BAlert::_InitObject(const char* text, const char* button0, const char* button1,
	const char* button2, button_width buttonWidth, button_spacing spacing,
	alert_type type)
{
	fInvoker = NULL;
	fAlertSem = -1;
	fAlertValue = -1;
	fButtons[0] = fButtons[1] = fButtons[2] = NULL;
	fTextView = NULL;
	fKeys[0] = fKeys[1] = fKeys[2] = 0;
	fMsgType = type;
	fButtonWidth = buttonWidth;

	// Set up the "_master_" view
	TAlertView* view = new(std::nothrow) TAlertView(Bounds());
	if (view == NULL)
		return;

	AddChild(view);
	view->SetBitmap(_InitIcon());

	// Must have at least one button
	if (button0 == NULL) {
		debugger("BAlerts must have at least one button.");
		button0 = "";
	}

	// Set up the buttons

	int32 buttonCount = 1;
	view->AddChild(fButtons[0] = _CreateButton(0, button0));

	if (button1 != NULL) {
		view->AddChild(fButtons[1] = _CreateButton(1, button1));
		buttonCount++;
	}

	if (button2 != NULL) {
		view->AddChild(fButtons[2] = _CreateButton(2, button2));
		buttonCount++;
	}

	// Find the widest button only if the widest value needs to be known.

	if (fButtonWidth == B_WIDTH_FROM_WIDEST) {
		float maxWidth = 0;
		for (int i = 0; i < buttonCount; i++) {
			float width = fButtons[i]->Bounds().Width();
			if (width > maxWidth)
				maxWidth = width;
		}

		// resize buttons
		for (int i = 0; i < buttonCount; i++) {
			fButtons[i]->ResizeTo(maxWidth, fButtons[i]->Bounds().Height());
		}
	}

	float defaultButtonFrameWidth = -fButtons[buttonCount - 1]->Bounds().Width() / 2.0f;
	SetDefaultButton(fButtons[buttonCount - 1]);
	defaultButtonFrameWidth += fButtons[buttonCount - 1]->Bounds().Width() / 2.0f;

	// Layout buttons

	float fontFactor = be_plain_font->Size() / 11.0f;

	for (int i = buttonCount - 1; i >= 0; --i) {
		float x = -fButtons[i]->Bounds().Width();
		if (i + 1 == buttonCount)
			x += Bounds().right - kRightOffset + defaultButtonFrameWidth;
		else
			x += fButtons[i + 1]->Frame().left - kButtonSpacing;

		if (buttonCount > 1 && i == 0 && spacing == B_OFFSET_SPACING)
			x -= kButtonOffsetSpacing * fontFactor;

		fButtons[i]->MoveTo(x, fButtons[i]->Frame().top);
	}

	// Adjust the window's width, if necessary

	int32 iconLayoutScale = icon_layout_scale();
	float totalWidth = kRightOffset + fButtons[buttonCount - 1]->Frame().right
		- defaultButtonFrameWidth - fButtons[0]->Frame().left;
	if (view->Bitmap()) {
		totalWidth += (kIconStripeWidth + kWindowIconOffset) * iconLayoutScale;
	} else
		totalWidth += kWindowMinOffset;

	float width = (spacing == B_OFFSET_SPACING
		? kWindowOffsetMinWidth : kWindowMinWidth) * fontFactor;

	ResizeTo(max_c(totalWidth, width), Bounds().Height());

	// Set up the text view

	BRect textViewRect(kLeftOffset, kTopOffset,
		Bounds().right - kRightOffset,
		fButtons[0]->Frame().top - kTextButtonOffset);
	if (view->Bitmap())
		textViewRect.left = (kWindowIconOffset
			+ kIconStripeWidth) * iconLayoutScale - 2;

	fTextView = new(std::nothrow) BTextView(textViewRect, "_tv_",
		textViewRect.OffsetByCopy(B_ORIGIN),
		B_FOLLOW_LEFT | B_FOLLOW_TOP, B_WILL_DRAW);
	if (fTextView == NULL)
		return;

	fTextView->SetViewColor(ui_color(B_PANEL_BACKGROUND_COLOR));
	rgb_color textColor = ui_color(B_PANEL_TEXT_COLOR);
	fTextView->SetFontAndColor(be_plain_font, B_FONT_ALL, &textColor);
	fTextView->SetText(text, strlen(text));
	fTextView->MakeEditable(false);
	fTextView->MakeSelectable(false);
	fTextView->SetWordWrap(true);
	view->AddChild(fTextView);

	// Now resize the TextView vertically so that all the text is visible
	float textHeight = fTextView->TextHeight(0, fTextView->CountLines());
	textViewRect.OffsetTo(0, 0);
	textHeight -= textViewRect.Height();
	ResizeBy(0, textHeight);
	fTextView->ResizeBy(0, textHeight);
	textViewRect.bottom += textHeight;
	fTextView->SetTextRect(textViewRect);

	AddCommonFilter(new(std::nothrow) _BAlertFilter_(this));

	MoveTo(AlertPosition(Frame().Width(), Frame().Height()));
}
예제 #23
0
OpenWithContainerWindow::OpenWithContainerWindow(BMessage* entriesToOpen,
	LockingList<BWindow>* windowList, window_look look, window_feel feel,
	uint32 flags, uint32 workspace)
	:
	BContainerWindow(windowList, 0, look, feel, flags, workspace),
	fEntriesToOpen(entriesToOpen)
{
	AutoLock<BWindow> lock(this);

	BRect windowRect(85, 50, 718, 296);
	MoveTo(windowRect.LeftTop());
	ResizeTo(windowRect.Width(), windowRect.Height());

	// add a background view; use the standard BackgroundView here, the same
	// as the file panel is using
	BRect rect(Bounds());
	BackgroundView* backgroundView = new BackgroundView(rect);
	AddChild(backgroundView);

	rect = Bounds();

	// add buttons

	fLaunchButton = new BButton(rect, "ok",	B_TRANSLATE("Open"),
		new BMessage(kDefaultButton), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
	fLaunchButton->ResizeToPreferred();
	fLaunchButton->MoveTo(rect.right - 10 - kDocumentKnobWidth
		- fLaunchButton->Bounds().Width(),
		rect.bottom - 10.0f - fLaunchButton->Bounds().Height());
	backgroundView->AddChild(fLaunchButton);

	BRect buttonRect = fLaunchButton->Frame();
	fLaunchAndMakeDefaultButton = new BButton(buttonRect, "make default",
		B_TRANSLATE("Open and make preferred"),
		new BMessage(kOpenAndMakeDefault), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
	// wide button, have to resize to fit text
	fLaunchAndMakeDefaultButton->ResizeToPreferred();
	fLaunchAndMakeDefaultButton->MoveBy(-10.0f
		- fLaunchAndMakeDefaultButton->Bounds().Width(), 0.0f);
	backgroundView->AddChild(fLaunchAndMakeDefaultButton);
	fLaunchAndMakeDefaultButton->SetEnabled(false);

	buttonRect = fLaunchAndMakeDefaultButton->Frame();
	BButton* button = new BButton(buttonRect, "cancel", B_TRANSLATE("Cancel"),
		new BMessage(kCancelButton), B_FOLLOW_RIGHT | B_FOLLOW_BOTTOM);
	button->ResizeToPreferred();
	button->MoveBy(-10.0f - button->Bounds().Width(), 0.0f);
	backgroundView->AddChild(button);

	fMinimalWidth = button->Bounds().Width() + fLaunchButton->Bounds().Width()
		+ fLaunchAndMakeDefaultButton->Bounds().Width() + kDocumentKnobWidth
		+ 40.0f;

	fLaunchButton->MakeDefault(true);

	// add pose view

	rect.OffsetTo(10.0f, 10.0f);
	rect.bottom = buttonRect.top - 15.0f;

	rect.right -= B_V_SCROLL_BAR_WIDTH + 20.0f;
	rect.bottom -= B_H_SCROLL_BAR_HEIGHT;
		// make room for scrollbars and a margin
	fPoseView = NewPoseView(0, rect, kListMode);
	backgroundView->AddChild(fPoseView);

	fPoseView->SetFlags(fPoseView->Flags() | B_NAVIGABLE);
	fPoseView->SetPoseEditing(false);

	// set the window title
	if (CountRefs(fEntriesToOpen) == 1) {
		// if opening just one file, use it in the title
		entry_ref ref;
		fEntriesToOpen->FindRef("refs", &ref);
		BString buffer(B_TRANSLATE("Open %name with:"));
		buffer.ReplaceFirst("%name", ref.name);

		SetTitle(buffer.String());
	} else {
		// use generic title
		SetTitle(B_TRANSLATE("Open selection with:"));
	}

	AddCommonFilter(new BMessageFilter(B_KEY_DOWN,
		&OpenWithContainerWindow::KeyDownFilter));
}
예제 #24
0
StartWindow::StartWindow(void)
	:
	BWindow(BRect(0, 0, -1, -1), "Paladin", B_TITLED_WINDOW,
		B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS)
{
	RegisterWindow();

	AddShortcut('O', B_COMMAND_KEY, new BMessage(M_SHOW_OPEN_PROJECT));
	AddShortcut('N', B_COMMAND_KEY, new BMessage(M_NEW_PROJECT));
	AddShortcut('I', B_COMMAND_KEY, new BMessage(M_SHOW_IMPORT));

	AddCommonFilter(new EscapeCancelFilter());

	// new button and label

	fNewButton = make_button("new", "NewProjectButtonUp.png",
		"NewProjectButtonDown.png", M_NEW_PROJECT);

	ClickableStringView* newLabel = make_label(fNewButton, TR("Create a new project"));
	newLabel->SetMessage(new BMessage(M_NEW_PROJECT));

	// open button and label

	fOpenButton = make_button("open", "OpenProjectButtonUp.png",
		"OpenProjectButtonDown.png", M_SHOW_OPEN_PROJECT);

	ClickableStringView* openLabel = make_label(fOpenButton, "Open a project");
	openLabel->SetMessage(new BMessage(M_SHOW_OPEN_PROJECT));

	// open recent button and label

	fOpenRecentButton = make_button("openrecent", "OpenRecentButtonUp.png",
		"OpenRecentButtonDown.png", M_OPEN_SELECTION);
	SetToolTip(fOpenRecentButton,
		TR("Open a project in the list on the right. You "
		   "can also press Command + a number key."));

	ClickableStringView* openRecentLabel = make_label(fOpenRecentButton,
		TR("Open the selected project"));
	openRecentLabel->SetMessage(new BMessage(M_OPEN_SELECTION));

	// quick import button and label

	fQuickImportButton = make_button("quickimport", "QuickImportButtonUp.png",
		"QuickImportButtonDown.png", M_SHOW_IMPORT);
	SetToolTip(fQuickImportButton,
		TR("Quickly make a project by importing all source files and resource files.\n"
		   "You can also import a BeIDE project."));

	ClickableStringView* quickImportLabel = make_label(fQuickImportButton,
		"Import an existing project");
	quickImportLabel->SetMessage(new BMessage(M_SHOW_IMPORT));
	SetToolTip(quickImportLabel,
		TR("Quickly make a project by importing all source files "
		   "and resource files.\n You can also import a BeIDE project."));

	// online import button and label

	fOnlineImportButton = make_button("onlineimport", "OnlineImportButtonUp.png",
		"OnlineImportButtonDown.png", M_ONLINE_IMPORT);
	SetToolTip(fQuickImportButton,
		TR("Import a project from an online repository"));

	ClickableStringView* onlineImportLabel = make_label(fOnlineImportButton,
		"Import a project from online");
	onlineImportLabel->SetMessage(new BMessage(M_ONLINE_IMPORT));
	SetToolTip(onlineImportLabel, TR("Import a project from an online repository"));

	// recent projects list view and scroller

	fRecentProjectsListView = new RecentProjectsList();
	// set the minimum width to 16em
	float minWidth = fRecentProjectsListView->StringWidth("M") * 16;
	fRecentProjectsListView->SetExplicitMinSize(BSize(minWidth, B_SIZE_UNSET));
	fRecentProjectsListView->SetInvocationMessage(new BMessage(M_OPEN_SELECTION));
	SetToolTip(fRecentProjectsListView,
		"Open a recent project. You can also press Command + a number key.");

	BLayoutBuilder::Group<>(this, B_HORIZONTAL)
		.AddGrid(B_USE_DEFAULT_SPACING, B_USE_SMALL_SPACING)
			.Add(fNewButton, 0, 0)
			.Add(newLabel, 1, 0)

			.Add(fOpenButton, 0, 1)
			.Add(openLabel, 1, 1)

			.Add(fOpenRecentButton, 0, 2)
			.Add(openRecentLabel, 1, 2)

			.Add(fQuickImportButton, 0, 3)
			.Add(quickImportLabel, 1, 3)

			.Add(fOnlineImportButton, 0, 4)
			.Add(onlineImportLabel, 1, 4)
			.End()
		.AddStrut(20)
		.AddGroup(B_VERTICAL, B_USE_SMALL_SPACING)
			.Add(new BStringView("recentProjectsLabel", TR("Recent projects:")))
			.Add(new BScrollView("recentProjectsScroller", fRecentProjectsListView, 0,
				false, true))
			.End()
		.SetInsets(B_USE_DEFAULT_SPACING)
		.End();

#ifdef DISABLE_ONLINE_IMPORT
	fOnlineImportButton->Hide();
#endif

	BMessenger messager(this);
	BEntry entry(gProjectPath.GetFullPath());
	entry_ref ref;
	entry.GetRef(&ref);
	fOpenPanel = new BFilePanel(B_OPEN_PANEL, &messager, &ref, B_FILE_NODE, true,
		new BMessage(M_OPEN_PROJECT));
	BString titleString(TR("Open Project"));
	titleString.Prepend("Paladin: ");
	fOpenPanel->Window()->SetTitle(titleString.String());

	fImportPanel = new BFilePanel(B_OPEN_PANEL, &messager, &ref, B_DIRECTORY_NODE,
		true, new BMessage(M_QUICK_IMPORT));
	titleString = TR("Choose Project Folder");
	titleString.Prepend("Paladin: ");
	fImportPanel->Window()->SetTitle(titleString.String());

	gSettings.Lock();
	int32 index = 0;
	while (gSettings.FindRef("recentitems", index++, &ref) == B_OK) {
		if (!BEntry(&ref).Exists()) {
			index--;
			gSettings.RemoveData("recentitems",index);
		} else
			fRecentProjectsListView->AddItem(new RefStringItem(ref),0);
	}
	gSettings.Unlock();

	// Alt + number opens that number project from the list
	int32 count = (fRecentProjectsListView->CountItems() > 9) ? 9 : fRecentProjectsListView->CountItems();
	for (int32 i = 0; i < count; i++) {
		BMessage* listMessage = new BMessage(M_OPEN_FROM_LIST);
		listMessage->AddInt32("index", i);
		AddShortcut('1' + i, B_COMMAND_KEY, listMessage);
	}

	fNewButton->MakeFocus(true);

	CenterOnScreen();
}
예제 #25
0
FindTextWindow::FindTextWindow(GlobalSettings *settings, const char *text,
	BLooper *looper)
	: BWindow(BRect(0, 0, 0, 0),
		B_TRANSLATE("Find text"),
		B_FLOATING_WINDOW_LOOK,
		B_MODAL_APP_WINDOW_FEEL,
		B_NOT_ZOOMABLE | B_AUTO_UPDATE_SIZE_LIMITS),
		mLooper(looper),
		mSettings(settings)
{

	mSearching = false;

	MoveTo(settings->GetFindWindowPosition());
	float w, h;
	settings->GetFindWindowSize(w, h);
	ResizeTo(w, h);

	AddCommonFilter(new EscapeMessageFilter(this, FIND_ABORT_MSG));

	mText = new BTextControl("mText", B_TRANSLATE("Find: "), text, NULL);
	mText->TextView()->DisallowChar(B_ESCAPE);

	mPage = new BStringView("mPage", B_TRANSLATE("Page:"));

	mFindStop = new BButton("mFindStop", B_TRANSLATE("Find"),
		new BMessage(FIND_MSG));

	mIgnoreCase = new BCheckBox("mIgnoreCase", B_TRANSLATE("Ignore case"),
		new BMessage(FIND_IGNORE_CASE_MSG));
	mIgnoreCase->SetValue(settings->GetFindIgnoreCase());

	mBackward = new BCheckBox("mBackward", B_TRANSLATE("Search backwards"),
		new BMessage(FIND_BACKWARD_MSG));
	mBackward->SetValue(settings->GetFindBackward());

	BGroupLayout *optBox = BLayoutBuilder::Group<>(B_HORIZONTAL)
		.SetInsets(B_USE_SMALL_SPACING)
		.AddGroup(B_VERTICAL, 0)
			.SetInsets(B_USE_SMALL_INSETS, 0, B_USE_SMALL_INSETS, 0)
			.Add(mIgnoreCase)
			.Add(mBackward)
		.End()
		.AddGlue();

	BBox *options = new BBox("options");
	options->SetLabel(B_TRANSLATE("Options"));
	options->AddChild(optBox->View());

	BLayoutBuilder::Group<>(this, B_VERTICAL)
		.SetInsets(B_USE_WINDOW_INSETS)
		.Add(mText)
		.AddGroup(B_HORIZONTAL)
			.Add(options)
			.AddGroup(B_VERTICAL)
				.Add(mFindStop)
				.Add(mPage)
				.AddGlue()
			.End()
		.End();

	SetDefaultButton(mFindStop);

	mText->MakeFocus();
	Show();
}
예제 #26
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);
}
예제 #27
0
ProjectWindow::ProjectWindow(BRect frame, Project *project)
	:	DWindow(frame, "Paladin", B_DOCUMENT_WINDOW, B_NOT_ZOOMABLE |
													B_WILL_ACCEPT_FIRST_CLICK),
		fErrorWindow(NULL),
		fFilePanel(NULL),
		fProject(project),
		fSourceControl(NULL),
		fShowingLibs(false),
		fMenusLocked(false),
		fBuilder(BMessenger(this))
{
	AddCommonFilter(new AltTabFilter());
	SetSizeLimits(200,30000,200,30000);
	RegisterWindow();
	
	// This is for our in-program debug menu which comes in handy now and then.
	// Paladin -d doesn't always get the job done
	AddShortcut('9', B_COMMAND_KEY | B_SHIFT_KEY | B_CONTROL_KEY,
				new BMessage(M_TOGGLE_DEBUG_MENU));
	
	if (fProject)
	{
		fSourceControl = GetSCM(fProject->SourceControl());
		if (fSourceControl)
		{
			if (gPrintDebugMode > 0)
				fSourceControl->SetDebugMode(true);
			
			fSourceControl->SetUpdateCallback(SCMOutputCallback);
			fSourceControl->SetWorkingDirectory(fProject->GetPath().GetFolder());
			
			if (fSourceControl->NeedsInit(fProject->GetPath().GetFolder()))
				fSourceControl->CreateRepository(fProject->GetPath().GetFolder());
		}
	}
	
	BView *top = GetBackgroundView();
	
	BRect bounds(Bounds());
	BRect r(bounds);
	
	r.bottom = 16;
	fMenuBar = new BMenuBar(r,"documentbar");
	top->AddChild(fMenuBar);
	
	r = bounds;
	r.top = fMenuBar->Frame().bottom + 1;
	r.right -= B_V_SCROLL_BAR_WIDTH;
	r.bottom -= B_H_SCROLL_BAR_HEIGHT;
	
	fProjectList = new ProjectList(fProject, r,"filelist",B_FOLLOW_ALL);
	fProjectList->SetInvocationMessage(new BMessage(M_EDIT_FILE));
	
	BScrollView *scrollView = new BScrollView("scrollView",fProjectList,
											B_FOLLOW_ALL,0,false,true);
	top->AddChild(scrollView);
	fProjectList->SetTarget(this);
	
	r.top = r.bottom + 1;
	r.bottom = Bounds().bottom;
	fStatusBar = new BStringView(r,"statusbar", NULL, B_FOLLOW_LEFT_RIGHT |
														B_FOLLOW_BOTTOM);
	top->AddChild(fStatusBar);
	
	fStatusBar->SetViewColor(235,235,235);
	fStatusBar->SetFontSize(10.0);
	
	SetupMenus();
	
	if (project)
	{
		BString title("Paladin: ");
		title << project->GetName();
		SetTitle(title.String());
		
		for (int32 i = 0; i < project->CountGroups(); i++)
		{
			SourceGroup *group = project->GroupAt(i);
			SourceGroupItem *groupitem = new SourceGroupItem(group);
			fProjectList->AddItem(groupitem);
			groupitem->SetExpanded(group->expanded);
			
			for (int32 j = 0; j < group->filelist.CountItems(); j++)
			{
				SourceFile *file = group->filelist.ItemAt(j);
				SourceFileItem *fileitem = new SourceFileItem(file,1);
				
//				fProjectList->AddUnder(fileitem,groupitem);
				fProjectList->AddItem(fileitem);
				
				BString abspath = file->GetPath().GetFullPath();
				if (abspath[0] != '/')
				{
					abspath.Prepend("/");
					abspath.Prepend(project->GetPath().GetFolder());
				}
				BEntry entry(abspath.String());
				if (entry.Exists())
				{
					if (project->CheckNeedsBuild(file,false))
					{
						fileitem->SetDisplayState(SFITEM_NEEDS_BUILD);
						fProjectList->InvalidateItem(fProjectList->IndexOf(fileitem));
					}
					else
						file->SetBuildFlag(BUILD_NO);
				}
				else
				{
					fileitem->SetDisplayState(SFITEM_MISSING);
					fProjectList->InvalidateItem(fProjectList->IndexOf(fileitem));
				}
			}
		}
	}
	
	BNode node(fProject->GetPath().GetFullPath());
	if (node.ReadAttr("project_frame",B_RECT_TYPE,0,&r,sizeof(BRect)) == sizeof(BRect))
	{
		if (r.Width() < 200)
			r.right = r.left + 200;
		if (r.Height() < 200)
			r.top = r.bottom + 200;
		MoveTo(r.left,r.top);
		ResizeTo(r.Width(),r.Height());
	}
	
	fProjectList->MakeFocus(true);
	
	if (gShowFolderOnOpen)
	{
		// Duplicated code from MessageReceived::M_SHOW_PROJECT_FOLDER. Doing
		// it here in combo with snooze() makes it much more likely that the
		// opened project window is frontmost instead of the project folder's window
		entry_ref ref;
		BEntry(fProject->GetPath().GetFolder()).GetRef(&ref);
		BMessenger msgr("application/x-vnd.Be-TRAK");
		
		BMessage reply;
		BMessage openmsg(B_REFS_RECEIVED);
		openmsg.AddRef("refs",&ref);
		msgr.SendMessage(&openmsg);
		snooze(50000);
	}
	
	if (gAutoSyncModules)
		PostMessage(M_SYNC_MODULES);
}
예제 #28
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));
}
GenesisCopyWindow::GenesisCopyWindow(CustomListView *list, PanelView *destpanel, const char *destination, BLooper* looper, BWindow *mainwindow) :
	BWindow(BRect(0,0,320,140), "Copy...", B_TITLED_WINDOW , B_WILL_DRAW)
////////////////////////////////////////////////////////////////////////
{
	BRect rect;

	m_CustomListView = list;
	m_DestPanel = destpanel;
	m_DestPath.SetTo(destination);
	m_Looper = looper;
	m_Window = mainwindow;

	m_SingleCopy = false;
	m_Paused = false;
	m_SkipAllCopyError = false;
	m_OverwriteAll = false;
	m_SkipSymLinkCreationError = false;

	// After the delete process we have to select an item if no item selected...
	m_Selection = GetFirstSelection();

	// First we have to remove the parent selection if selected...
//	RemoveParentSelection();

	m_FileCount = m_CustomListView->CountSelectedEntries(CT_WITHOUTPARENT);			

	if (m_FileCount == 1)
		m_SingleCopy = true;

	SetType(B_FLOATING_WINDOW);
	SetFeel(B_MODAL_SUBSET_WINDOW_FEEL);
	SetFlags(B_NOT_RESIZABLE | B_NOT_ZOOMABLE | B_NOT_CLOSABLE);

	AddToSubset(mainwindow);

	m_View = new BView(Bounds(), "copyview", B_FOLLOW_ALL, B_WILL_DRAW);
	m_View->SetViewColor(216, 216, 216, 0);
	AddChild(m_View);

	// Bottom View	
	rect = Bounds();
	rect.top = rect.bottom-44;
	BView *BottomView = new BView(rect, "infobottomview", B_FOLLOW_BOTTOM, B_WILL_DRAW);
	BottomView->SetViewColor(180, 190, 200, 0);
	m_View->AddChild(BottomView);	
/*
	// More checkbox
	rect = BottomView->Bounds();
	rect.top = rect.bottom-30;
	rect.bottom = rect.bottom-14;
	rect.left = 20;
	rect.right = rect.left+40;	
	m_MoreCB = new BCheckBox(rect,"more","Show more",new BMessage(COPY_MORE), B_FOLLOW_BOTTOM, B_WILL_DRAW);
	m_MoreCB->ResizeToPreferred();
	BottomView->AddChild(m_MoreCB);
*/	
	// OK Button	
	rect = BottomView->Bounds();
	rect.top = rect.bottom-34;
	rect.bottom = rect.bottom-14;
	rect.left = rect.right-80;
	rect.right = rect.right-20;	
	m_CopyButton = new BButton(rect,"copy","Copy",new BMessage(BUTTON_MSG_COPY),B_FOLLOW_BOTTOM,B_WILL_DRAW);
	BottomView->AddChild(m_CopyButton);

	//Cancel Button
	rect = BottomView->Bounds();
	rect.top = rect.bottom-34;
	rect.bottom = rect.bottom-14;
	rect.left = rect.right-160;
	rect.right = rect.right-100;	
	m_CancelButton = new BButton(rect,"cancel","Cancel",new BMessage(BUTTON_MSG_CANCELCOPY),B_FOLLOW_BOTTOM,B_WILL_DRAW);
	BottomView->AddChild(m_CancelButton);

	SetDefaultButton(m_CopyButton);

	// Info string
	rect = Bounds();
	rect.left += 24;
	rect.right -= 24;
	if (m_SingleCopy)
		rect.top += 8;
	else
		rect.top += 16;
	rect.bottom = rect.top+20;
	m_Label = new BStringView(rect,"filename","Copy");
	m_Label->SetAlignment(B_ALIGN_CENTER);
	m_Label->SetViewColor(216,216,216);
	m_Label->SetLowColor(216,216,216);
	m_Label->SetHighColor(0,0,0);
	AddChild(m_Label);

	// Edit field
	rect = BottomView->Bounds();
	if (m_SingleCopy)
		rect.top = rect.top+36;
	else
		rect.top = rect.top+56;
	rect.bottom = rect.top+32;
	rect.left += 20;
	rect.right -= 20;
	m_DirName = new BTextControl( rect, "destname", "to", "", NULL );
	m_DirName->SetDivider(m_View->StringWidth("to")+4);
	m_DirName->SetModificationMessage(new BMessage(COPYNAME_CHANGED));
	m_DirName->SetText(m_DestPath.String());
	m_View->AddChild(m_DirName);

	// "as" field
	if (m_SingleCopy)
	{
		rect = BottomView->Bounds();
		rect.top = rect.top+64;
		rect.bottom = rect.top+32;
		rect.left += 20;
		rect.right -= 20;

		m_FileAsName = new BTextControl( rect, "destfilename", "as", "", NULL );
		m_FileAsName->SetDivider(m_View->StringWidth("to")+4);
		m_FileAsName->SetModificationMessage(new BMessage(COPYNAME_CHANGED));

		if (((CustomListItem *)m_CustomListView->GetSelectedEntry(0))->m_Type == FT_PARENT)
			m_FileAsName->SetText( ((CustomListItem *)m_CustomListView->GetSelectedEntry(1))->m_FileName.String() );
		else
			m_FileAsName->SetText( ((CustomListItem *)m_CustomListView->GetSelectedEntry(0))->m_FileName.String() );
		
		m_View->AddChild(m_FileAsName);
	}

	m_DirName->MakeFocus(true);	
	
	// Ctrl + Q closes the window...
	AddShortcut('Q', 0, new BMessage(BUTTON_MSG_CANCELCOPY));

	// Set copy label...
	if (m_SingleCopy)
	{
		BString text;
		text.SetTo("Copy '");
		if (((CustomListItem *)m_CustomListView->GetSelectedEntry(0))->m_Type == FT_PARENT)
			text << ((CustomListItem *)m_CustomListView->GetSelectedEntry(1))->m_FileName;
		else
			text << ((CustomListItem *)m_CustomListView->GetSelectedEntry(0))->m_FileName;
		text << "'";
	
		m_Label->SetText(text.String());
	}
	else
	{
		BString text;
		text.SetTo("Copy ");
		text << m_FileCount << " files";
		
		m_Label->SetText(text.String());
	}
	
	AddCommonFilter(new EscapeFilter(this, new BMessage(BUTTON_MSG_CANCELCOPY)));
	
	// If there is a given window, let's align our window to its center...
	if (mainwindow)
	{
		BRect myrect = Bounds();
		
		rect = mainwindow->Frame();
		float w = rect.right - rect.left;
		float h = rect.bottom - rect.top;
		MoveTo(rect.left + w/2 - (myrect.right-myrect.left)/2, rect.top + h/2 - (myrect.bottom-myrect.top)/2);
	}
}