LoadLayoutArchiveWindow(BRect frame) 
		:
		BWindow(frame, "Layout Loaded From Archive", B_TITLED_WINDOW, B_QUIT_ON_WINDOW_CLOSE
			| B_AUTO_UPDATE_SIZE_LIMITS)
	{
		fLayout = new BALMLayout(10, 10);
		BALM::BALMLayoutBuilder builder(this, fLayout);

		// Restore gui specifications. 
		BFile guiFile;
		_FindGUISpecifications(kGUIFileName, guiFile);

		LayoutArchive layoutArchive(fLayout);
		if (layoutArchive.RestoreFromFile(&guiFile) != B_OK) {
			BString text = "Can't find layout specification file: \"";
			text << kGUIFileName;
			text << "\"";
			BAlert* alert = new BAlert("Layout Specifications Not Found",
				text, "Quit");
			alert->Go();
			PostMessage(B_QUIT_REQUESTED);
		}

		// Access the views in the layout.

		BButton* button = layoutArchive.FindView<BButton>("ButtonTest");
		if (button != NULL)
			button->SetLabel("Hey");

		BRadioButton* radioButton
			= layoutArchive.FindView<BRadioButton>("RadioButtonTest");
		if (radioButton != NULL)
			radioButton->SetLabel("World");
	}
Beispiel #2
0
void
TFilePanel::SetButtonLabel(file_panel_button selector, const char* text)
{
	switch (selector) {
		case B_CANCEL_BUTTON:
			{
				BButton* button
					= dynamic_cast<BButton*>(FindView("cancel button"));
				if (button == NULL)
					break;

				float old_width = button->StringWidth(button->Label());
				button->SetLabel(text);
				float delta = old_width - button->StringWidth(text);
				if (delta) {
					button->MoveBy(delta, 0);
					button->ResizeBy(-delta, 0);
				}
			}
			break;

		case B_DEFAULT_BUTTON:
			{
				fButtonText = text;
				float delta = 0;
				BButton* button
					= dynamic_cast<BButton*>(FindView("default button"));
				if (button != NULL) {
					float old_width = button->StringWidth(button->Label());
					button->SetLabel(text);
					delta = old_width - button->StringWidth(text);
					if (delta) {
						button->MoveBy(delta, 0);
						button->ResizeBy(-delta, 0);
					}
				}

				// now must move cancel button
				button = dynamic_cast<BButton*>(FindView("cancel button"));
				if (button != NULL)
					button->MoveBy(delta, 0);
			}
			break;
	}
}
Beispiel #3
0
void
BToolBar::AddAction(BMessage* message, BHandler* target,
	const BBitmap* icon, const char* toolTipText, const char* text,
	bool lockable)
{
	BButton* button;
	if (lockable)
		button = new LockableButton(NULL, NULL, message);
	else
		button = new BButton(NULL, NULL, message);
	button->SetIcon(icon);
	button->SetFlat(true);
	if (toolTipText != NULL)
		button->SetToolTip(toolTipText);
	if (text != NULL)
		button->SetLabel(text);
	AddView(button);
	button->SetTarget(target);
}
Beispiel #4
0
void
TFilePanel::AdjustButton()
{
	// adjust button state
	BButton* button = dynamic_cast<BButton*>(FindView("default button"));
	if (button == NULL)
		return;

	BTextControl* textControl
		= dynamic_cast<BTextControl*>(FindView("text view"));
	BObjectList<BPose>* selectionList = fPoseView->SelectionList();
	BString buttonText = fButtonText;
	bool enabled = false;

	if (fIsSavePanel && textControl != NULL) {
		enabled = textControl->Text()[0] != '\0';
		if (fPoseView->IsFocus()) {
			fPoseView->ShowSelection(true);
			if (selectionList->CountItems() == 1) {
				Model* model = selectionList->FirstItem()->TargetModel();
				if (model->ResolveIfLink()->IsDirectory()) {
					enabled = true;
					buttonText = B_TRANSLATE("Open");
				} else {
					// insert the name of the selected model into
					// the text field
					textControl->SetText(model->Name());
					textControl->MakeFocus(true);
				}
			}
		} else
			fPoseView->ShowSelection(false);
	} else {
		int32 count = selectionList->CountItems();
		if (count) {
			enabled = true;

			// go through selection list looking at content
			for (int32 index = 0; index < count; index++) {
				Model* model = selectionList->ItemAt(index)->TargetModel();

				uint32 modelFlavor = GetLinkFlavor(model, false);
				uint32 linkFlavor = GetLinkFlavor(model, true);

				// if only one item is selected and we're not in dir
				// selection mode then we don't disable button ever
				if ((modelFlavor == B_DIRECTORY_NODE
						|| linkFlavor == B_DIRECTORY_NODE)
					&& count == 1)
				  break;

				if ((fNodeFlavors & modelFlavor) == 0
					&& (fNodeFlavors & linkFlavor) == 0) {
		    		enabled = false;
					break;
				}
			}
		}
	}

	button->SetLabel(buttonText.String());
	button->SetEnabled(enabled);
}
ScheduleAddWindow::ScheduleAddWindow(const BRect &frame, const TransactionData &data)
 :	BWindow(frame,TRANSLATE("Schedule Transaction"),B_TITLED_WINDOW_LOOK,
 			B_MODAL_APP_WINDOW_FEEL,B_NOT_ZOOMABLE | B_NOT_RESIZABLE | 
			B_NOT_MINIMIZABLE | B_AUTO_UPDATE_SIZE_LIMITS),
	fTransData(data)
{
	AddShortcut('W',B_COMMAND_KEY,new BMessage(B_QUIT_REQUESTED));
	
	BView *back = new BView("backview",B_WILL_DRAW);
	BLayoutBuilder::Group<>(this, B_VERTICAL, 0)
		.SetInsets(0)
		.Add(back)
	.End();
	back->SetViewColor(240,240,240);
	
	BString label;
	label << TRANSLATE("Type") << ": " << data.Type().Type();
	BStringView *typelabel = new BStringView("typelabel", label.String());
	
	label = TRANSLATE("Payee");
	label << ": " << data.Payee();
	BStringView *payeelabel = new BStringView("payeelabel",label.String());
	
	BString temp;
	gCurrentLocale.CurrencyToString(data.Amount().AbsoluteValue(),temp);
	label = TRANSLATE("Amount");
	label << ": " << temp;
	
	BStringView *amountlabel = new BStringView("amountlabel",label.String());
	
	label = TRANSLATE("Category"); label+=": ";
	if(data.CountCategories()>1)
		label << TRANSLATE("Split");
	else
		label << data.NameAt(0);
	
	BStringView *categorylabel = new BStringView("categorylabel",label.String());
	
	label = TRANSLATE("Memo");
	label << ": " << data.Memo();
	BStringView *memolabel = new BStringView("memolabel",label.String());

//	Since layout-api, we need other way to make divider	
//	BBox *divider = new BBox(r);
//	AddChild(divider);
	
	fIntervalMenu = new BMenu(TRANSLATE("Frequency"));
	fIntervalMenu->AddItem(new BMenuItem(TRANSLATE("Monthly"),
										new BMessage(M_SCHEDULED_MONTHLY)));
	fIntervalMenu->AddItem(new BMenuItem(TRANSLATE("Quarterly"),
										new BMessage(M_SCHEDULED_QUARTERLY)));
	fIntervalMenu->AddItem(new BMenuItem(TRANSLATE("Annually"),
										new BMessage(M_SCHEDULED_ANNUALLY)));
	fIntervalMenu->ItemAt(0)->SetMarked(true);
	fIntervalMenu->SetLabelFromMarked(true);
	
	temp = TRANSLATE("Frequency"); temp += ": ";
	BMenuField *intervalfield = new BMenuField("intervalfield",
											temp.String(),fIntervalMenu);
		
	temp = TRANSLATE("Starting Date"); temp += ": ";
	fStartDate = new DateBox("startdate",temp.String(),"",
							new BMessage(M_DATE_CHANGED));
	fStartDate->UseTabFiltering(false);
	gDefaultLocale.DateToString(data.Date(),temp);
	fStartDate->SetText(temp.String());
	
	fRepeatAlways = new BRadioButton("inftimes",TRANSLATE("Indefinitely"),
										new BMessage(M_REPEAT_ALWAYS));
	
	fRepeatLimited = new BRadioButton("limitedtimes","",new BMessage(M_REPEAT_LIMITED));
	
	fRepeatCount = new NumBox("repeatcount",NULL,"999",
							new BMessage(M_COUNT_CHANGED));
	fRepeatCount->UseTabFiltering(false);
	fRepeatCount->SetEnabled(false);
	
	BStringView *timeslabel = new BStringView("timeslabel",TRANSLATE("times"));
	
	fRepeatAlways->SetValue(B_CONTROL_ON);
	
	intervalfield->MakeFocus(true);
	
	BButton *okbutton = new BButton("okbutton",TRANSLATE("Cancel"),
									new BMessage(M_SCHEDULE_TRANSACTION));
	okbutton->MakeDefault(true);
	okbutton->SetLabel(TRANSLATE("OK"));
	
	BButton *cancelbutton = new BButton("cancelbutton",
									TRANSLATE("Cancel"),
									new BMessage(B_QUIT_REQUESTED));
	cancelbutton->MakeDefault(true);
	
	BLayoutBuilder::Group<>(back, B_VERTICAL)
		.SetInsets(10)
		.AddGrid(8.0f, 1.0f)
			.Add(typelabel, 0, 0)
			.Add(payeelabel, 1, 0)
			.Add(amountlabel, 2, 0)
			.Add(categorylabel, 0, 1)
			.Add(memolabel, 1, 1)
		.End()
		.AddGrid(1.0f, 1.0f)
			.Add(intervalfield, 0, 0)
			.Add(fRepeatAlways, 1, 0)
			.Add(fStartDate, 0, 1)
			.AddGrid(1.0f, 1.0f, 1, 1)
				.Add(fRepeatLimited, 0, 0)
				.Add(fRepeatCount, 1, 0)
			.End()			
		.End()
		.AddGrid(1.0f, 1.0f)
			.AddGlue(0, 0)
			.Add(cancelbutton, 1, 0)
			.Add(okbutton, 2, 0)
		.End()
	.End();
}
/**
 *	@brief	Called when language setting is changed by LocaleKit.
 */
void BePreferencesDlg::languageChanged()
{
    NativeStringLoader* nsl = CoveredCalcApp::GetInstance();

    // dialog title
    SetTitle(nsl->LoadNativeString(NSID_PREFERENCES_TITLE));

    // LangBox
    BBox* langBox = dynamic_cast<BBox*>(FindView(PREFERENCES_DIALOG_VIEW_LANG_BOX));
    if (NULL != langBox)
    {
        langBox->SetLabel(nsl->LoadNativeString(NSID_PREFERENCES_GROUP_LANGUAGE));
    }

    // LangPopup
    BMenuField* langPopup = dynamic_cast<BMenuField*>(FindView(PREFERENCES_DIALOG_VIEW_LANG_POPUP));
    if (NULL != langPopup)
    {
        langPopup->SetLabel(nsl->LoadNativeString(NSID_PREFERENCES_LANGUAGE));
    }

    // LangNotice
    BTextView* langNotice = dynamic_cast<BTextView*>(FindView(PREFERENCES_DIALOG_VIEW_LANG_NOTICE));
    if (NULL != langNotice)
    {
        langNotice->SetText(nsl->LoadNativeString(NSID_PREFERENCES_LANGUAGE_MESSAGE));
    }

    // KeyMappingBox
    BBox* keyMappingBox = dynamic_cast<BBox*>(FindView(PREFERENCES_DIALOG_VIEW_KEYMAPPING_BOX));
    if (NULL != keyMappingBox)
    {
        keyMappingBox->SetLabel(nsl->LoadNativeString(NSID_PREFERENCES_GROUP_KEYMAP));
    }

    // KeyMappingPopup
    BMenuField* keyMappingPopup = dynamic_cast<BMenuField*>(FindView(PREFERENCES_DIALOG_VIEW_KEYMAPPING_POPUP));
    if (NULL != keyMappingPopup)
    {
        keyMappingPopup->SetLabel(nsl->LoadNativeString(NSID_PREFERENCES_KEYMAP));
    }

    // EditKeyMappingButton
    BButton* editKeymapButton = dynamic_cast<BButton*>(FindView(PREFERENCES_DIALOG_VIEW_EDIT_KEYMAPPING_BUTTON));
    if (NULL != editKeymapButton)
    {
        editKeymapButton->SetLabel(nsl->LoadNativeString(NSID_PREFERENCES_EDIT_KEYMAP));
    }

    // DuplicateKeyMappingButton
    BButton* dupKeymapButton = dynamic_cast<BButton*>(FindView(PREFERENCES_DIALOG_VIEW_DUPLICATE_KEYMAPPING_BUTTON));
    if (NULL != dupKeymapButton)
    {
        dupKeymapButton->SetLabel(nsl->LoadNativeString(NSID_PREFERENCES_DUPLICATE_KEYMAP));
    }

    // DeleteKeyMappingButton
    BButton* delKeymapButton = dynamic_cast<BButton*>(FindView(PREFERENCES_DIALOG_VIEW_DELETE_KEYMAPPING_BUTTON));
    if (NULL != delKeymapButton)
    {
        delKeymapButton->SetLabel(nsl->LoadNativeString(NSID_PREFERENCES_DELETE_KEYMAP));
    }

    // CancelButton
    BButton* cancelButton = dynamic_cast<BButton*>(FindView(PREFERENCES_DIALOG_VIEW_CANCEL));
    if (NULL != cancelButton)
    {
        cancelButton->SetLabel(nsl->LoadNativeString(NSID_PREFERENCES_OK));
    }

    // OKButton
    BButton* okButton = dynamic_cast<BButton*>(FindView(PREFERENCES_DIALOG_VIEW_OK));
    if (NULL != okButton)
    {
        okButton->SetLabel(nsl->LoadNativeString(NSID_PREFERENCES_CANCEL));
    }
}