#include "gdiptest.h" //******************************************************************* // // OutputFile // // // //******************************************************************* OutputFile* OutputFile :: CreateOutputFile(LPTSTR filename) { // convert to upper case & verify file extension TCHAR tmpStr[MAX_PATH]; _tcscpy(&tmpStr[0], filename); _tcsupr(&tmpStr[0]); LPTSTR ext = &tmpStr[0] + _tcslen(&tmpStr[0]) - 3; INT formatType = -1; FILE* outfile = _tfopen(filename, _T("w")); if (!outfile) { WarningBox(_T("Can't create the output file.")); return NULL; } if (!_tcscmp(ext, _T("CPP")) || !_tcscmp(ext, _T("C")) || !_tcscmp(ext, _T("CXX"))) return new CPPOutputFile(outfile); else if (!_tcscmp(ext, _T("JAVA"))) return new JavaOutputFile(outfile); else if (!_tcscmp(ext, _T("VML"))) return new VMLOutputFile(outfile); else { WarningBox(_T("Unrecognized file type (.cpp, .c, .cxx, .Java, .vml)")); return NULL; } } //******************************************************************* // // CPPOutputFile // // // //******************************************************************* VOID CPPOutputFile :: GraphicsProcedure() { _ftprintf(outfile, _T("VOID DoGraphicsTest(HWND hWnd)\n")); } VOID CPPOutputFile :: GraphicsDeclaration() { _ftprintf(outfile, _T("%*sGraphics g(hWnd);\n"), 4, _T("")); } VOID CPPOutputFile :: PointDeclaration(LPCTSTR pointName, Point* pts, INT count) { if (count < 0) _ftprintf(outfile, _T("%sPoint %s(%e, %e);\n"), tabStr, pointName, pts->X, pts->Y); else { _ftprintf(outfile, _T("%sPoint %s[%d];\n"), tabStr, pointName, count); for (INT pos=0; posX, pointName, pos, pts->Y); } } VOID CPPOutputFile :: ColorDeclaration(LPCTSTR colorName, ARGB* argb, INT count) { if (count < 0) _ftprintf(outfile, _T("%sColor %s(0x%08X);\n"), tabStr, colorName, *argb); else { _ftprintf(outfile, _T("%sColor %s[%d];\n"), tabStr, colorName, count); for (INT pos=0; posX, pts->Y); _ftprintf(outfile, _T("%s%s.%s(%s);\n"), tabStr, object, command, ref ? Ref(_T(varName)) : varName); } else { _ftprintf(outfile, _T("%sPoint %s[%d];\n"), tabStr, varName, count); for (INT pos=0; posX, varName, pos, pts->Y); _ftprintf(outfile, _T("%s%s.%s(%s);\n"), tabStr, object, command, RefArray(varName)); } } VOID CPPOutputFile :: SetColorDeclaration(LPCTSTR object, LPCTSTR command, LPCTSTR varName, ARGB* colors, INT count, BOOL ref) { if (count < 0) { _ftprintf(outfile, _T("%sColor %s(0x%08X);\n"), tabStr, varName, *colors); _ftprintf(outfile, _T("%s%s.%s(%s%s);\n"), tabStr, object, command, ref ? _T("&") : _T(""), varName); } else { _ftprintf(outfile, _T("%sColor %s[%d];\n"), tabStr, varName, count); for (INT pos=0; posIsIdentity()) { _ftprintf(outfile, _T("%s// identity matrix transform\n"), tabStr); return; } matrix->GetElements(&m[0]); _ftprintf(outfile, _T("%sMatrix %s(%e, %e, %e, \n" "%s%*s%e, %e, %e);\n"), tabStr, varName, m[0], m[1], m[2], tabStr, 8 + _tcslen(varName), _T(""), m[3], m[4], m[5]); _ftprintf(outfile, _T("%s%s.%s(&%s);\n"), tabStr, object, command, varName); } VOID CPPOutputFile :: SetBlendDeclaration(LPCTSTR object, LPCTSTR command, LPCTSTR varName, REAL* blend, INT count) { _ftprintf(outfile, _T("%sREAL %s[%d];\n"), tabStr, varName, count); for (INT pos=0; pos