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


C++ BAlert::Activate方法代码示例

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


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

示例1: WindowAt

bool
ZipOMatic::QuitRequested(void)
{
	if (CountWindows() <= 0)
		return true;
	
	BWindow* window;
	ZippoWindow* zippo;
	ZippoWindow* lastFoundZippo = NULL;
	int32 zippoCount = 0;
	
	for (int32 i = 0;; i++) {
		window = WindowAt(i);
		if (window == NULL)
			break;
		
		zippo = dynamic_cast<ZippoWindow*>(window);
		if (zippo == NULL)
			continue;
		
		lastFoundZippo = zippo;
		
		if (zippo->Lock()) {
			if (zippo->IsZipping())
				zippoCount++;
			else
				zippo->PostMessage(B_QUIT_REQUESTED);
				
			zippo->Unlock();
		}
	}
	
	if (zippoCount == 1) {
		// This is likely the most frequent case - a single zipper.
		// We post a message to the window so it can put up its own
		// BAlert instead of the app-wide BAlert. This avoids making
		// a difference between having pressed Commmand-W or Command-Q.
		// Closing or quitting, it doesn't matter for a single window.

		if (lastFoundZippo->Lock()) {
			lastFoundZippo->Activate();
			lastFoundZippo->PostMessage(B_QUIT_REQUESTED);
			lastFoundZippo->Unlock();
		}
		return false;
	}

	if (zippoCount > 0) {
		// The multi-zipper case differs from the single-zipper case
		// in that zippers are not paused while the BAlert is up.

		BString question;
		question << TR("You have %ld Zip-O-Matic running.\n\n");
		question << TR("Do you want to stop them?");
		
		BString temp;
		temp << zippoCount;
		question.ReplaceFirst("%ld", temp.String());

		BAlert* alert = new BAlert(NULL, question.String(),
			TR("Stop them"), TR("Let them continue"), NULL, B_WIDTH_AS_USUAL,
			B_WARNING_ALERT);
		alert->Go(fInvoker);
		alert->Activate();
			// BAlert, being modal, does not show on the current workspace
			// if the application has no window there. Activate() triggers
			// a switch to a workspace where it does have a window.
			
			// TODO: See if AS_ACTIVATE_WINDOW should be handled differently
			// in src/servers/app/Desktop.cpp Desktop::ActivateWindow()
			// or if maybe BAlert should (and does not?) activate itself.
			
		return false;
	}

	if (CountWindows() <= 0)
		return true;
	
	return false;
}
开发者ID:mmanley,项目名称:Antares,代码行数:80,代码来源:ZipOMatic.cpp


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