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


C++ WindowApplication::LaunchFileDialog方法代码示例

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


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

示例1: Main

//----------------------------------------------------------------------------
int WindowApplication::Main (int, char**)
{
	// Initialize the extra data.  TODO:  Port the extra-data system of WM4
	// to WM5.
	memset(gsExtraData, 0, APP_EXTRA_DATA_QUANTITY*sizeof(char));

	InitCursor();

	WindowApplication* theApp =
	    (WindowApplication*)Application::TheApplication;
	theApp->KEY_TERMINATE = WindowApplication::KEY_ESCAPE;

	// OpenGL uses a projection matrix for depth in [-1,1].
	Camera::SetDefaultDepthType(Camera::PM_DEPTH_MINUS_ONE_TO_ONE);

	// Allocate temporary back buffer to be used for font management.
	GDHandle device = GetGDevice();
	PixMapHandle pixmap = (**device).gdPMap;
	Rect area;
	GetPixBounds(pixmap, &area);
	int depth = GetPixDepth(pixmap);
	GWorldPtr back;
	OSErr error = NewGWorld(&back, depth, &area, 0, 0, useTempMem | pixPurge);
	if (error != noErr || !back)
	{
		return -1;
	}

	SetExtraData(AGLAPP_BACK, sizeof(GWorldPtr), &back);

	// Assign desired font settings to back buffer.
	const int fontSize = 9;
	unsigned char fontName[256];
	fontName[0] = 6;
	strcpy((char*)&fontName[1], "Monaco");
	short fontNum;
	GetFNum(fontName, &fontNum);
	SetExtraData(AGLAPP_FONT, sizeof(short), &fontNum);

	GWorldPtr currentWorld;
	GDHandle currentDevice;
	GetGWorld(&currentWorld, &currentDevice);
	SetGWorld(back, 0);

	TextFont(fontNum);
	TextSize(fontSize);
	TextFace(normal);
	SetGWorld(currentWorld, currentDevice);

	// Add standard window menu.
	MenuRef menu = 0;
	CreateStandardWindowMenu(0, &menu);
	InsertMenu(menu, 0);

	// Change current directory into application bundle.
	FSRef processRef;
	FSCatalogInfo processInfo;
	ProcessSerialNumber serial = { 0, kCurrentProcess };
	GetProcessBundleLocation(&serial, &processRef);
	FSSpec fileSpec;
	FSGetCatalogInfo(&processRef, kFSCatInfoNodeFlags, &processInfo, 0,
	                 &fileSpec, 0);
	std::string appFile = GetStringPathname(fileSpec);
	const int maxPathLen = 1024;
	char path[maxPathLen];
	strcpy(path, appFile.c_str());
	char* last = strrchr(path, '/');
	*last = 0;
	int result = chdir(path);
	assertion(result == 0, "Cannot change directory.\n");

	// If the application is packaged, we have to get back up a couple of
	// levels such that the current working directory is the same as the
	// application's directory.
	char buffer[maxPathLen];
	char* currentDirectory = getcwd(buffer, maxPathLen);
	if (strstr(currentDirectory, "/Contents/MacOS"))
	{
		result = chdir("../../..");
		assertion(result == 0, "Cannot change directory.\n");
		currentDirectory = getcwd(buffer, maxPathLen);
	}

#if 0
	// TODO.  We had this in Wild Magic 4.  Add it to Wild Magic 5.
	//
	// Launch a file dialog, if requested, when the application needs to
	// select an input file.  The derived-class application should set
	// mLaunchFileDialog to 'true' in its constructor when the dialog is
	// needed.
	if (theApp->LaunchFileDialog())
	{
		char* arguments = GetCommandLine();
		if (arguments)
		{
			delete0(theApp->TheCommand);
			theApp->TheCommand = new0 Command(arguments);
			delete1(arguments);
		}
//.........这里部分代码省略.........
开发者ID:bazhenovc,项目名称:WildMagic,代码行数:101,代码来源:Wm5AglApplication.cpp


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