示例#1
0
	void CWindowsWin32Window::SetTitle(char const * title)
	{
		_title = title;
		std::wstring wtitle{};
		atow(_title, wtitle);
		SetWindowTextW(_win, wtitle.c_str());
	}
示例#2
0
	void CWindowsWin32Window::_InitWindow(HINSTANCE hInst, IConfigObject const * cfg)
	{
		//_rect stores the dimensions of the client area of the window.
		_rect.SetX(static_cast<s16>(cfg->GetProperty("dims.x", s64{})));
		_rect.SetY(static_cast<s16>(cfg->GetProperty("dims.y", s64{})));
		_rect.SetWidth(static_cast<u16>(cfg->GetProperty("dims.width", s64{ 640 })));
		_rect.SetHeight(static_cast<u16>(cfg->GetProperty("dims.height", s64{ 480 })));
		
		//Need to adjust for non-client area of window for CreateWindow.
		RECT&& adj = _GetAdjustedRect(_rect);
		
		//convert the title to a wchar_t string
		std::wstring wtitle{};
		_title = cfg->GetProperty("title", "");
		atow(_title, wtitle);

		_win = CreateWindowExW(WS_EX_OVERLAPPEDWINDOW,	//will either want this or options for fullscreen
			L"InsanityWindowClass",						//Constant
			wtitle.c_str(),								//Good candidate for Config file
			WS_OVERLAPPEDWINDOW,						//as dwExStyle
			adj.left, adj.top,
			adj.right - adj.left, adj.bottom - adj.top,	//Dimensions are another good candidate
			HWND_DESKTOP,								//If in Config file, would need a way to specify another window
			NULL,										//Menu can be assigned later
			hInst,										//Constant
			nullptr);									//Constant (unused)

		SetWindowSubclass(_win, WindowProc, 0, reinterpret_cast<DWORD_PTR>(this));

		ShowWindow(_win, SW_SHOWDEFAULT);
	}
示例#3
0
文件: util.cpp 项目: weimingtom/sls
HBITMAP GXLoadFile(LPCTSTR lpszBitmapName)
{
	WCHAR szBuff[MAX_PATH];
	memset(szBuff, 0, MAX_PATH*sizeof(WCHAR));
	atow(lpszBitmapName, szBuff, MAX_PATH);
	Gdiplus::Bitmap *pImg = new Gdiplus::Bitmap(szBuff);
	if(!pImg)
	{
		printlog("Load %s failed!\n", lpszBitmapName);
		return NULL;
	}
	
	HBITMAP hBMP = NULL;
	Gdiplus::Color cr(255, 0, 255);
	pImg->GetHBITMAP(cr, &hBMP);
	
	HBITMAP hRet = (HBITMAP)CopyImage(hBMP, IMAGE_BITMAP, 0, 0, LR_COPYDELETEORG);
	delete pImg;
	
	return hRet;
}
示例#4
0
	WString ftow(double number)
	{
		return atow(ftoa(number));
	}
示例#5
0
int main(int argc, char* argv[])
#endif
{
	WString baseDirectory;
	{
#if defined VCZH_MSVC
		wchar_t currentDirectory[MAX_PATH]={0};
		GetCurrentDirectory(MAX_PATH, currentDirectory);
		baseDirectory=currentDirectory;
#elif defined VCZHGCC
		char currentDirectory[1024]={0};
		getcwd(currentDirectory, 1024);
		baseDirectory=atow(currentDirectory);
#endif
		if(baseDirectory[baseDirectory.Length()-1]!=PATH_DELIMITER)
		{
			baseDirectory+=PATH_DELIMITER;
		}
	}


	Regex regexPathSplitter(L"[///\\]");
	Ptr<ParsingGeneralParser> parser=CreateBootstrapStrictParser();

	Console::SetTitle(L"Vczh Parser Generator for C++");
	Console::SetColor(false, true, false, true);
	Console::WriteLine(L"parsing>Files : "+itow(argc-1));
	for(int i=1;i<argc;i++)
	{
		Console::WriteLine(L"------------------------------------------------------------");
#if defined VCZH_MSVC
		WString inputPath=argv[i];
#elif defined VCZH_GCC
		WString inputPath=atow(argv[i]);
#endif
		if(inputPath.Length()<2 || inputPath[1]!=L':')
		{
			inputPath=baseDirectory+inputPath;
		}
		Console::WriteLine(L"parsing>Making : "+inputPath);
		if(inputPath.Length()<11 || inputPath.Right(11)!=L".parser.txt")
		{
			Console::SetColor(true, false, false, true);
			Console::WriteLine(L"error> The extenion name of the input file path must be \".parser.txt\".");
			Console::SetColor(false, true, false, true);
		}
		else
		{
			WString name;
			{
				List<Ptr<RegexMatch>> matches;
				regexPathSplitter.Split(inputPath, true, matches);
				name=matches[matches.Count()-1]->Result().Value();
				name=name.Left(name.Length()-11);
			}
			WString outputMetaPath=inputPath.Left(inputPath.Length()-11);
			WString outputHeaderPath=outputMetaPath+L".h";
			WString outputCppPath=outputMetaPath+L".cpp";
			WString logPath=outputMetaPath+L".log";
			Console::WriteLine(L"parsing>Output header path : "+outputHeaderPath);
			Console::WriteLine(L"parsing>Output cpp path : "+outputCppPath);
			Console::WriteLine(L"parsing>Log path : "+logPath);

			CodegenConfig config;
			WString codeGrammar;
			{
				FileStream fileStream(inputPath, FileStream::ReadOnly);
				if(!fileStream.IsAvailable())
				{
					Console::SetColor(true, false, false, true);
					Console::WriteLine(L"error> Cannot open \""+inputPath+L" for read.");
					Console::SetColor(false, true, false, true);
					goto STOP_PARSING;
				}
				BomDecoder decoder;
				DecoderStream decoderStream(fileStream, decoder);
				StreamReader reader(decoderStream);

				if(!config.ReadConfig(reader))
				{
					goto STOP_PARSING;
				}
				codeGrammar=reader.ReadToEnd();
			}

			Ptr<ParsingDefinition> definition;
			Ptr<ParsingTable> table;
			{
				FileStream fileStream(logPath, FileStream::WriteOnly);
				if(!fileStream.IsAvailable())
				{
					Console::SetColor(true, false, false, true);
					Console::WriteLine(L"error> Cannot open \""+logPath+L" for write.");
					Console::SetColor(false, true, false, true);
					goto STOP_PARSING;
				}
				BomEncoder encoder(BomEncoder::Utf16);
				EncoderStream encoderStream(fileStream, encoder);
				StreamWriter writer(encoderStream);
				
				if(codeGrammar==L"<bootstrap-grammar>")
				{
					definition=CreateParserDefinition();
					MemoryStream bootstrapStream;
					{
						StreamWriter bootstrapWriter(bootstrapStream);
						Log(definition, bootstrapWriter);
					}
					bootstrapStream.SeekFromBegin(0);
					StreamReader bootstrapReader(bootstrapStream);
					codeGrammar=bootstrapReader.ReadToEnd();
				}
				else
				{
					definition=CreateDefinition(parser, codeGrammar, writer);
				}
				if(!definition)
				{
					Console::SetColor(true, false, false, true);
					Console::WriteLine(L"error> Error happened. Open \""+logPath+L" for details.");
					Console::SetColor(false, true, false, true);
					goto STOP_PARSING;
				}

				table=CreateTable(definition, writer, config.ambiguity);
				if(!table)
				{
					Console::SetColor(true, false, false, true);
					Console::WriteLine(L"error> Error happened. Open \""+logPath+L" for details.");
					Console::SetColor(false, true, false, true);
					goto STOP_PARSING;
				}
			}
			{
				FileStream fileStream(outputHeaderPath, FileStream::WriteOnly);
				if(!fileStream.IsAvailable())
				{
					Console::SetColor(true, false, false, true);
					Console::WriteLine(L"error> Cannot open \""+outputHeaderPath+L" for write.");
					Console::SetColor(false, true, false, true);
					goto STOP_PARSING;
				}
				BomEncoder encoder(BomEncoder::Mbcs);
				EncoderStream encoderStream(fileStream, encoder);
				StreamWriter writer(encoderStream);
				WriteHeaderFile(name, definition, table, config, writer);
			}
			{
				FileStream fileStream(outputCppPath, FileStream::WriteOnly);
				if(!fileStream.IsAvailable())
				{
					Console::SetColor(true, false, false, true);
					Console::WriteLine(L"error> Cannot open \""+outputCppPath+L" for write.");
					Console::SetColor(false, true, false, true);
					goto STOP_PARSING;
				}
				BomEncoder encoder(BomEncoder::Mbcs);
				EncoderStream encoderStream(fileStream, encoder);
				StreamWriter writer(encoderStream);
				
				config.includes.Clear();
				config.includes.Add(L"\""+name+L".h\"");
				WriteCppFile(name, codeGrammar, definition, table, config, writer);
			}
		}
	STOP_PARSING:;
	}
	Console::WriteLine(L"Finished!");
	return 0;
}