当前位置: 首页>>代码示例>>C++>>正文


C++ BAlert类代码示例

本文整理汇总了C++中BAlert的典型用法代码示例。如果您正苦于以下问题:C++ BAlert类的具体用法?C++ BAlert怎么用?C++ BAlert使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了BAlert类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: D_MESSAGE

void ParameterWindow::MessageReceived(
    BMessage *message) {
    D_MESSAGE(("ParameterWindow::MessageReceived()\n"));

    switch (message->what) {
    case M_START_CONTROL_PANEL: {
        D_MESSAGE((" -> M_START_CONTROL_PANEL\n"));
        status_t error = _startControlPanel();
        if (error) {
            BString s = "Could not start control panel";
            s << " (" << strerror(error) << ")";
            BAlert *alert = new BAlert("", s.String(), "OK", 0, 0,
                                       B_WIDTH_AS_USUAL, B_WARNING_ALERT);
            alert->Go(0);
        }
        bool replace = false;
        if ((message->FindBool("replace", &replace) == B_OK)
                && (replace == true)) {
            PostMessage(B_QUIT_REQUESTED);
        }
        break;
    }
    case M_THEME_SELECTED: {
        D_MESSAGE((" -> M_THEME_SELECTED\n"));
        int32 themeID;
        if (message->FindInt32("themeID", &themeID) != B_OK) {
            return;
        }
        // not yet implemented
        break;
    }
    case B_MEDIA_WEB_CHANGED: {
        D_MESSAGE((" -> B_MEDIA_WEB_CHANGED\n"));
        _updateParameterView();
        _constrainToScreen();
        break;
    }
    default: {
        BWindow::MessageReceived(message);
    }
    }
}
开发者ID:nielx,项目名称:haiku-serviceskit,代码行数:42,代码来源:ParameterWindow.cpp

示例2: ErrorString

int Error::ShowError(string_slice msg1, string_slice msg2, int err)
{
	qstring msg = msg1;
	msg += msg2;
	if (err != 0) {
		msg += "  (";
		const char* errStr = ErrorString(err);
		if (errStr != NULL)
			msg += errStr;
		else
			msg += err;
		msg += ")";
		}
	BAlert* alert =
		new BAlert("Error alert", msg.c_str(), "OK");
	alert->SetShortcut(0, ' ');
	alert->Go();

	return err;
}
开发者ID:HaikuArchives,项目名称:Item,代码行数:20,代码来源:Error.cpp

示例3: sprintf

// CreateExistingProject -- Saves only the necessary bits - asks if you to recreate
void NewProjectWindow::CreateExistingProject(void) 
{
	char tmp[256];
	//char cmd[256];
	BAlert *alert;
    long result;
    
	sprintf(tmp,"Would you like to Recreate your Project \"%s\".\n\nPlease note this means all the existing files will be overwritten.\n\nIf you are unsure, click No.",ProjectName.String());
    alert = new BAlert("", tmp, " Yes ", " No ", NULL, B_WIDTH_FROM_WIDEST, B_WARNING_ALERT);
	alert->SetShortcut(0, B_ESCAPE);
	result = alert->Go();
    if (result == B_OK)
    {
    	// right - do the lot
    	CreateNewProject();	
	} else {
		// Only save necessary bits like project
		ptrFileWindow->SaveProject();
	}	
}
开发者ID:HaikuArchives,项目名称:Brie,代码行数:21,代码来源:NewProjectWindow.cpp

示例4: BAlert

bool
MainWindow::QuitRequested()
{
	int32 padWindowCount = 0;
	for (int32 i = 0; BWindow* window = be_app->WindowAt(i); i++) {
		if (dynamic_cast<MainWindow*>(window))
			padWindowCount++;
	}
	if (padWindowCount == 1) {
		be_app->PostMessage(B_QUIT_REQUESTED);
		return false;
	} else {
		BAlert* alert = new BAlert("last chance", "Really close this pad?\n"
			"(The pad will not be remembered.)",
			"Close", "Cancel", NULL);
		if (alert->Go() == 1)
			return false;
	}
	return true;
}
开发者ID:mmanley,项目名称:Antares,代码行数:20,代码来源:MainWindow.cpp

示例5: while

void
App::_CheckPackageDaemonRuns()
{
    while (!be_roster->IsRunning(kPackageDaemonSignature)) {
        BAlert* alert = new BAlert("start_package_daemon",
                                   B_TRANSLATE("HaikuDepot needs the package daemon to function, "
                                               "and it appears to be not running.\n"
                                               "Would you like to start it now?"),
                                   B_TRANSLATE("No, quit HaikuDepot"),
                                   B_TRANSLATE("Start package daemon"), NULL, B_WIDTH_AS_USUAL,
                                   B_WARNING_ALERT);
        alert->SetShortcut(0, B_ESCAPE);

        if (alert->Go() == 0)
            exit(1);

        if (!_LaunchPackageDaemon())
            break;
    }
}
开发者ID:,项目名称:,代码行数:20,代码来源:

示例6: BAlert

void
WorkspacesView::_AboutRequested()
{
	BAlert *alert = new BAlert("about", "Workspaces\n"
		"written by François Revol, Axel Dörfler, and Matt Madia.\n\n"
		"Copyright 2002-2008, Antares.\n\n"
		"Send windows behind using the Option key. "
		"Move windows to front using the Control key.\n", "OK");
	BTextView *view = alert->TextView();
	BFont font;

	view->SetStylable(true);

	view->GetFont(&font);
	font.SetSize(18);
	font.SetFace(B_BOLD_FACE);
	view->SetFontAndColor(0, 10, &font);

	alert->Go();
}
开发者ID:mmanley,项目名称:Antares,代码行数:20,代码来源:Workspaces.cpp

示例7: BAlert

void
OverlayView::OverlayAboutRequested()
{
	BAlert *alert = new BAlert("about",
		"OverlayImage\n"
		"Copyright 1999-2010\n\n\t"
		"originally by Seth Flaxman\n\t"
		"modified by Hartmuth Reh\n\t"
		"further modified by Humdinger\n",
		"OK");	
	BTextView *view = alert->TextView();
	BFont font;
	view->SetStylable(true);
	view->GetFont(&font);
	font.SetSize(font.Size() + 7.0f);
	font.SetFace(B_BOLD_FACE);
	view->SetFontAndColor(0, 12, &font);
	alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);	
	alert->Go();
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:20,代码来源:OverlayView.cpp

示例8: PRINT

void
AppWindow::AboutRequested()
{
	PRINT(("AppWindow::AboutRequested()\n"));
	BString msg;
	msg = APPLICATION " " VERSION "\n\n"
		"Created by Jason Burgess of now defunct FlipSide Software. "
		"His former website has since been taken over by "
		"another company by the same name.\n\n"

		"The FlipSide Software applications are hosted by HaikuArchives at github.com/Haiku/Archives\n\n"

		MAINTAINER " is the current maintainer.\n"

		"To request new features, or to report bugs, file a new issue at:\n"
		"http://github.com/HaikuArchives/ArmyKnife/issues";

	BAlert* alert = new BAlert("AboutBox", msg.String(), ABOUT_BTN);
	alert->Go(NULL);
}
开发者ID:HaikuArchives,项目名称:ArmyKnife,代码行数:20,代码来源:appwindow.cpp

示例9: ShowAlert

int32
ShowAlert(const char *message, const char *button1, const char *button2,
			const char *button3, alert_type type)
{
	int32 result;
	
	if (gBuildMode)
	{
		printf("%s\n", message);
		result = -1;
	}
	else
	{
		BString label1 = button1 ? button1 : "OK";
		BAlert *alert = new BAlert("Paladin", message, label1.String(),
									button2, button3, B_WIDTH_AS_USUAL, type);
		result = alert->Go();
	}
	return result;
}
开发者ID:jscipione,项目名称:Paladin,代码行数:20,代码来源:Globals.cpp

示例10: atof

status_t
DisplayView::Save()
{
	BPath path;

	if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) != B_OK)
		return B_ERROR;

	path.Append(kSettingsDirectory);
	path.Append(kDisplaySettings);

	BMessage settings;

	float width = atof(fWindowWidth->Text());
	settings.AddFloat(kWidthName, width);

	icon_size iconSize = kDefaultIconSize;
	switch (fIconSize->IndexOf(fIconSize->FindMarked())) {
		case 0:
			iconSize = B_MINI_ICON;
			break;
		default:
			iconSize = B_LARGE_ICON;
	}
	settings.AddInt32(kIconSizeName, (int32)iconSize);

	// Save settings file
	BFile file(path.Path(), B_WRITE_ONLY | B_CREATE_FILE | B_ERASE_FILE);
	status_t ret = settings.Flatten(&file);
	if (ret != B_OK) {
		BAlert* alert = new BAlert("",
			B_TRANSLATE("Can't save preferenes, you probably don't have "
				"write access to the settings directory or the disk is full."),
				B_TRANSLATE("OK"), NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT);
		alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
		(void)alert->Go();
		return ret;
	}

	return B_OK;
}
开发者ID:Barrett17,项目名称:haiku-contacts-kit-old,代码行数:41,代码来源:DisplayView.cpp

示例11: switch

void 
PasswordWindow::MessageReceived(BMessage *message) 
{
	switch (message->what) {
		case kMsgDone:
			fSettings.SetLockMethod(fUseCustom->Value() ? "custom" : "network");
			if (fUseCustom->Value()) {
				if (strcmp(fPasswordControl->Text(), fConfirmControl->Text())) {
					BAlert *alert = new BAlert("noMatch",
						"Passwords don't match. Please try again.","OK");
					alert->Go();
					break;
				}
				const char *salt = _SanitizeSalt(fPasswordControl->Text());
				fSettings.SetPassword(crypt(fPasswordControl->Text(), salt));
				delete salt;
			} else {
				fSettings.SetPassword("");
			}
			fPasswordControl->SetText("");
			fConfirmControl->SetText("");
			fSettings.Save();
			Hide();
			break;

	case B_CANCEL:
		fPasswordControl->SetText("");
		fConfirmControl->SetText("");
		Hide();
		break;

	case kMsgPasswordTypeChanged:
		fSettings.SetLockMethod(fUseCustom->Value() > 0 ? "custom" : "network");
		Update();
		break;

	default:
		BWindow::MessageReceived(message);
		break;
 	}
}
开发者ID:mariuz,项目名称:haiku,代码行数:41,代码来源:PasswordWindow.cpp

示例12: rect

void
ScreenshotWindow::_ShowSettings(bool activate)
{
	if (!fSettingsWindow && !activate)
		return;

	// Find a translator
	translator_id translator;
	if (fUtility.FindTranslator(fImageFileType, translator) != B_OK)
		return;

	// Create a window with a configuration view
	BView* view;
	BRect rect(0, 0, 239, 239);

	status_t status = BTranslatorRoster::Default()->MakeConfigurationView(
		translator, NULL, &view, &rect);
	if (status != B_OK || view == NULL) {
		// TODO: proper translation, better error dialog
		BAlert* alert = new BAlert(NULL, strerror(status), "OK");
		alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
		alert->Go();
	} else if (fSettingsWindow != NULL) {
		fSettingsWindow->RemoveChild(fSettingsWindow->ChildAt(0));
		float width, height;
		view->GetPreferredSize(&width, &height);
		fSettingsWindow->ResizeTo(width, height);
		fSettingsWindow->AddChild(view);
		if (activate)
			fSettingsWindow->Activate();
	} else {
		fSettingsWindow = new BWindow(rect,
			B_TRANSLATE("Translator Settings"),
			B_TITLED_WINDOW_LOOK, B_NORMAL_WINDOW_FEEL,
			B_NOT_ZOOMABLE | B_NOT_RESIZABLE);
		fSettingsWindow->AddFilter(new QuitMessageFilter(this));
		fSettingsWindow->AddChild(view);
		fSettingsWindow->CenterOnScreen();
		fSettingsWindow->Show();
	}
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:41,代码来源:ScreenshotWindow.cpp

示例13: find_directory

void
TTracker::InstallTemporaryBackgroundImages()
{
	// make the large Haiku Logo the default background

	BPath path;
	status_t status = find_directory(B_SYSTEM_DATA_DIRECTORY, &path);
	if (status < B_OK) {
		// TODO: this error shouldn't be shown to the regular user
		BString errorMessage(B_TRANSLATE("At %func \nfind_directory() "
			"failed. \nReason: %error"));
		errorMessage.ReplaceFirst("%func", __PRETTY_FUNCTION__);
		errorMessage.ReplaceFirst("%error", strerror(status));
		BAlert* alert = new BAlert("AlertError", errorMessage.String(),
			B_TRANSLATE("OK"), NULL, NULL, B_WIDTH_AS_USUAL, B_STOP_ALERT);
		alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
		alert->Go();
		return;
	}
	path.Append("artwork");

	BString defaultBackgroundImage("/HAIKU logo - white on blue - big.png");

	BDirectory dir;
	if (FSGetBootDeskDir(&dir) == B_OK) {
		// install a default background if there is no background defined yet
		attr_info info;
		if (dir.GetAttrInfo(kBackgroundImageInfo, &info) != B_OK) {
			BScreen screen(B_MAIN_SCREEN_ID);
			BPoint logoPos;
			logoPos.x
				= floorf((screen.Frame().Width() - 605) * (sqrtf(5) - 1) / 2);
			logoPos.y = floorf((screen.Frame().Height() - 190) * 0.9);
			BMessage message;
			AddTemporaryBackgroundImages(&message,
				(BString(path.Path()) << defaultBackgroundImage).String(),
				BackgroundImage::kAtOffset, logoPos, 0xffffffff, false);
			::InstallTemporaryBackgroundImages(&dir, &message);
		}
	}
}
开发者ID:looncraz,项目名称:haiku,代码行数:41,代码来源:TrackerInitialState.cpp

示例14: switch

void
TPeopleApp::MessageReceived(BMessage* message)
{
	switch (message->what) {
		case M_NEW:
		case B_SILENT_RELAUNCH:
			_NewWindow();
			break;

		case M_WINDOW_QUITS:
			_SavePreferences(message);
			fWindowCount--;
			if (fWindowCount < 1)
				PostMessage(B_QUIT_REQUESTED);
			break;

		case M_CONFIGURE_ATTRIBUTES:
		{
			const char* arguments[] = { "-type", B_PERSON_MIMETYPE, 0 };
			status_t ret = be_roster->Launch(
				"application/x-vnd.Haiku-FileTypes",
				sizeof(arguments) / sizeof(const char*) - 1,
				const_cast<char**>(arguments));
			if (ret != B_OK && ret != B_ALREADY_RUNNING) {
				BString errorMsg(B_TRANSLATE("Launching the FileTypes "
					"preflet to configure Person attributes has failed."
					"\n\nError: "));
				errorMsg << strerror(ret);
				BAlert* alert = new BAlert(B_TRANSLATE("Error"),
					errorMsg.String(), B_TRANSLATE("OK"), NULL, NULL,
					B_WIDTH_AS_USUAL, B_STOP_ALERT);
				alert->SetFlags(alert->Flags() | B_CLOSE_ON_ESCAPE);
				alert->Go(NULL);
			}
			break;
		}

		default:
			BApplication::MessageReceived(message);
	}
}
开发者ID:Barrett17,项目名称:haiku-contacts-kit-old,代码行数:41,代码来源:PeopleApp.cpp

示例15: file

void
NotificationWindow::_LoadGeneralSettings(bool startMonitor)
{
    BPath path;
    BMessage settings;

    if (find_directory(B_USER_SETTINGS_DIRECTORY, &path) != B_OK)
        return;

    path.Append(kSettingsDirectory);
    if (create_directory(path.Path(), 0755) == B_OK) {
        path.Append(kGeneralSettings);

        BFile file(path.Path(), B_READ_ONLY);
        settings.Unflatten(&file);
    }

    if (settings.FindInt32(kTimeoutName, &fTimeout) != B_OK)
        fTimeout = kDefaultTimeout;

    // Notify the view about the change
    views_t::iterator it;
    for (it = fViews.begin(); it != fViews.end(); ++it) {
        NotificationView* view = (*it);
        view->SetText(view->Application(), view->Title(), view->Text());
        view->Invalidate();
    }

    if (startMonitor) {
        node_ref nref;
        BEntry entry(path.Path());
        entry.GetNodeRef(&nref);

        if (watch_node(&nref, B_WATCH_ALL, BMessenger(this)) != B_OK) {
            BAlert* alert = new BAlert(B_TRANSLATE("Warning"),
                                       B_TRANSLATE("Couldn't start general settings monitor.\n"
                                                   "Live filter changes disabled."), B_TRANSLATE("OK"));
            alert->Go();
        }
    }
}
开发者ID:,项目名称:,代码行数:41,代码来源:


注:本文中的BAlert类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。