示例#1
0
// Append a measurement, never with preceding comma. stid contains a %s which is replaced
// with the nVal (initially mp) converted to the appropriate display units.
void AppendMeasurement(StrApp & strDesc, int nVal, MsrSysType nMsrSys, int stid)
{
	if (nVal == knNinch)
		return;
	StrAppBuf strb;
	AfUtil::MakeMsrStr(nVal , nMsrSys, &strb);
	StrApp strFmt(stid);
	strDesc.FormatAppend(strFmt.Chars(), strb.Chars());
}
示例#2
0
// Append information about one border, if it is defined
void AppendBorderInfo(StrApp & strDesc, int mp, int stid, bool & fFirst)
{
	if (mp == knNinch)
		return;
	StrAppBuf strb;
	AfUtil::MakeMsrStr (mp , knpt, &strb);
	StrApp strFmt(stid);
	StrApp strT;
	strT.Format(strFmt.Chars(), strb.Chars());
	AppendDescPart(strDesc, strT, fFirst);
}
示例#3
0
    ArgHolder parse(
            int argc,
            const char *argv[],
            const dict::Dict<string, FuncType> &optToChker,
            char optChar='-',
            bool genHelpChker=true
            ) {
        ArgHolder holder{dict::Dict<string, vector<string>>(), vector<string>()};

        vector<string> curArgs;
        string curOpt;
        string error;
        unsigned nargs;
        int i = 1;

        while (i < argc) {
            if (argv[i][0] != optChar) {
                // positional argument
                holder.posArgs.push_back(argv[i]);
                i++;
                continue;
            }

            if (genHelpChker and (strcmp(argv[i], "-h") == 0 or strcmp(argv[i], "--help") == 0)) {
                holder.optToArgs.insert(pair<string, vector<string>>("-h", vector<string>()));
                i++;
                continue;
            }

            // option (begins with `optChar`)
            curArgs.clear();
            curOpt = argv[i];

            i++;
            while (i < argc and argv[i][0] != optChar) {
                curArgs.push_back(argv[i]);
                i++;
            }

            try {
                nargs = optToChker.at(curOpt)(curArgs);
            } catch (out_of_range &err) {
                throw invalid_argument(strFmt("unknown option %s", curOpt.c_str()));
            }
            
            holder.posArgs.insert(holder.posArgs.end(), curArgs.begin() + nargs, curArgs.end());
            curArgs.resize(nargs);

            holder.optToArgs.insert(pair<string, vector<string>>(curOpt, curArgs));
        }

        return holder;
    }
示例#4
0
// 绘制羽化文字
void DrawEclosionText(HDC hDC, LPCTSTR lpszText, LPCTSTR lpszFontName, int nFontSize)
{
	int nWidth = 56, nHeight = 16;

	Gdiplus::Bitmap bmp(nWidth, nHeight, 0, PixelFormat32bppARGB, NULL);
	Gdiplus::Graphics graphics(&bmp);
	Gdiplus::GraphicsPath path(Gdiplus::FillModeAlternate);
	Gdiplus::FontFamily fontFamily(lpszFontName, NULL);
	Gdiplus::StringFormat strFmt(0, 0);

	Gdiplus::RectF rc(0.0f, 0.0f, nWidth, nHeight);
	path.AddString(lpszText, -1, &fontFamily, Gdiplus::FontStyleBold, nFontSize, rc, &strFmt);

	Gdiplus::Matrix matrix(1.0f/* / 5.0f*/, 0.0f, 0.0f, 1.0f/* / 5.0f*/, -1.0f/* / 5.0f*/, -1.0f/* / 5.0f*/);
	
	graphics.SetSmoothingMode(Gdiplus::SmoothingModeAntiAlias);
	graphics.SetTransform(&matrix);

	Gdiplus::Color color((Gdiplus::ARGB)0x55CCE0EE);
	Gdiplus::Pen pen(color, 3);

	graphics.DrawPath(&pen, &path);

	Gdiplus::Color color2((Gdiplus::ARGB)0x55CCE0EE);
	Gdiplus::SolidBrush brush(color2);

	graphics.FillPath(&brush, &path);

 	Gdiplus::Bitmap bmp2(300, 40, 0, PixelFormat32bppARGB, NULL);
 	Gdiplus::Graphics graphics2(&bmp2);
 
 	graphics2.SetSmoothingMode(Gdiplus::SmoothingModeAntiAlias);
 	graphics2.SetInterpolationMode(Gdiplus::InterpolationModeHighQualityBicubic);
 	graphics2.DrawImage(&bmp, 0, 0, nWidth, nHeight);
 
 	Gdiplus::Color color3((Gdiplus::ARGB)0xFF000000);
 	Gdiplus::SolidBrush brush2(color3);
 
 	graphics2.FillPath(&brush2, &path);

	CLSID clsid;
	::CLSIDFromString(_T("{557CF406-1A04-11D3-9A73-0000F81EF32E}"), &clsid);
	bmp2.Save(_T("c:\\CoolText.png"), &clsid, NULL);

	Gdiplus::Graphics graphics3(hDC);

	graphics3.DrawImage(&bmp2, 8, 4);
}