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


C++ StringFormat::SetTrimming方法代码示例

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


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

示例1: CalculateWidth

int CNotification::CalculateWidth(int defaultSize)
{
	CString s;
	GetWindowText(s);
	
	CDIB dib;
	dib.Resize(1, 1);
	if(!dib.Ready())
	{
		return defaultSize;
	}
	Graphics g(dib.dc);
	g.SetCompositingMode(CompositingModeSourceOver);
	g.SetSmoothingMode(SmoothingModeAntiAlias);

	RectF rf(0, 0, 0, 0);

	Font font(L"Arial", defaultSize * 0.6f, FontStyleRegular, UnitPixel);
	StringFormat *stringFormat = new StringFormat();
	stringFormat->SetAlignment(StringAlignmentCenter);
	stringFormat->SetLineAlignment(StringAlignmentCenter);
	stringFormat->SetFormatFlags(StringFormatFlagsLineLimit);
	stringFormat->SetTrimming(StringTrimmingEllipsisCharacter);

	g.MeasureString(s.GetBuffer(), s.GetLength(), &font, rf, stringFormat, &rf);

	delete stringFormat;

	defaultSize += (int)rf.Width - defaultSize / 2;
	return defaultSize;
}
开发者ID:VladimirLichonos,项目名称:XWindows-Dock-2.0,代码行数:31,代码来源:notifications.cpp

示例2: GPDrawShadowTextSimple

void GPDrawShadowTextSimple( Graphics&gc, CString& strTxtIn, CRect& rcIn, Gdiplus::Font& fontIn, ARGB BrushClrIn, ARGB shadowBrushClrIn /*= 0xff000000*/, int nOffXIn /*= 2*/, int nOffYIn /*= 2*/, StringFormat* fmtIn /*= NULL*/ )
{
	Gdiplus::Font& gcfont = fontIn;
	Rect rcText = CRect2Rect(rcIn);
	StringFormat fmt;
	fmt.SetAlignment(StringAlignmentCenter);
	fmt.SetTrimming(StringTrimmingEllipsisWord);
	fmt.SetLineAlignment(StringAlignmentCenter);
	StringFormat& fmtUse = fmtIn == NULL? fmt:*fmtIn;

	GraphicsContainer  gcContainer = gc.BeginContainer();
	gc.SetSmoothingMode(SmoothingModeAntiAlias);
	CComBSTR btrTxtIn(strTxtIn);

	SolidBrush textbrush(ARGB2Color(shadowBrushClrIn));
	RectF rfText = Rect2RectF(rcText);
	if (shadowBrushClrIn != 0)
	{
		rfText.Offset(1.0, 1.0);
		gc.DrawString(btrTxtIn, -1, &gcfont, rfText, &fmtUse, &textbrush);
	}

	textbrush.SetColor(ARGB2Color(BrushClrIn));
	gc.DrawString(btrTxtIn, -1, &gcfont, rfText, &fmtUse, &textbrush);
	gc.EndContainer(gcContainer);
}
开发者ID:tianyx,项目名称:TxUIProject,代码行数:26,代码来源:GDIDrawFunc.cpp

示例3: onPaintText

void UILabel::onPaintText(Graphics& graphics, Rect rect)
{
    StringFormat stringFormat;
    stringFormat.SetTrimming(m_font.m_trimming);
    stringFormat.SetAlignment(m_font.m_horizen);
    stringFormat.SetLineAlignment(m_font.m_vertical);

    Font font(m_font.m_family, m_font.m_size, m_font.m_style, m_font.m_unit);
    SolidBrush brush(getTrueColor(m_font.m_color));
    graphics.DrawString(m_font.m_text, -1, &font, m_font.m_rect, &stringFormat, &brush);
}
开发者ID:smithLiLi,项目名称:dev,代码行数:11,代码来源:UIComomCtrls.cpp

示例4: GPDrawShadowText

void GPDrawShadowText( Graphics& gc, CString& strTxtIn, CRect& rcIn, Gdiplus::Font& fontIn, ARGB BrushClrIn, ARGB PenClrIn , ARGB shadowPenClrIn /*= 0xff000000*/, ARGB shadowBrushClrIn /*= 0xff000000*/, int nOffXIn /*= 2*/, int nOffYIn /*= 2*/, StringFormat* fmtIn /*= NULL*/ )
{
	Gdiplus::Font& gcfont = fontIn;
	FontFamily fmy;
	gcfont.GetFamily(&fmy);
	int nfontStyle  = gcfont.GetStyle();
	REAL dFontSize = gcfont.GetSize();
	Rect rcText = CRect2Rect(rcIn);
	StringFormat fmt;
	fmt.SetAlignment(StringAlignmentCenter);
	fmt.SetTrimming(StringTrimmingEllipsisWord);
	fmt.SetLineAlignment(StringAlignmentCenter);
	StringFormat& fmtUse = fmtIn == NULL? fmt:*fmtIn;

	GraphicsContainer  gcContainer = gc.BeginContainer();
	gc.SetSmoothingMode(SmoothingModeAntiAlias);
	CComBSTR btrTxtIn(strTxtIn);
	GraphicsPath textPath;
	textPath.AddString(btrTxtIn, -1,  &fmy, nfontStyle, dFontSize, rcText, &fmtUse);

	Matrix mx;
	mx.Translate(nOffXIn, nOffYIn);
	textPath.Transform(&mx);

	Pen textPen(ARGB2Color(shadowPenClrIn), 1);
	SolidBrush textbrush(ARGB2Color(shadowBrushClrIn));
	textPen.SetLineJoin(LineJoinRound);
	if (shadowBrushClrIn != 0)
	{
		gc.FillPath(&textbrush, &textPath);
	}
	if (shadowPenClrIn != 0)
	{
		gc.DrawPath(&textPen, &textPath);
	}



	mx.Invert();
	textPath.Transform(&mx);
	textPen.SetColor(ARGB2Color(PenClrIn));
	textbrush.SetColor(ARGB2Color(BrushClrIn));
	if (BrushClrIn != 0)
	{
		gc.FillPath(&textbrush, &textPath);
	}
	if (PenClrIn != 0)
	{
		gc.DrawPath(&textPen, &textPath);
	}
	gc.EndContainer(gcContainer);
}
开发者ID:tianyx,项目名称:TxUIProject,代码行数:52,代码来源:GDIDrawFunc.cpp

示例5: SetStringFormat

void ProcessDateTime::SetStringFormat(StringFormat &format)
{
	UINT formatFlags;

	formatFlags = Gdiplus::StringFormatFlagsNoFitBlackBox
		| Gdiplus::StringFormatFlagsMeasureTrailingSpaces;


	format.SetFormatFlags(formatFlags);
	format.SetTrimming(Gdiplus::StringTrimmingWord);

	format.SetAlignment(Gdiplus::StringAlignmentNear);


}
开发者ID:wwllww,项目名称:LiveStream_MultiIntance,代码行数:15,代码来源:libDateTime.cpp

示例6: Draw

void CSkinList::Draw(CDIB &tmp)
{
	CRect r;
	GetClientRect(&r);

	tmp.Resize(r.Width(), r.Height());
	if(!tmp.Ready())
	{
		return;
	}

	RectF rf(0, 0, (REAL)tmp.Width(), (REAL)tmp.Height());
	RectF rx;

	Graphics g(tmp.dc);
	g.SetCompositingMode(CompositingModeSourceOver);

	if(bckg->Ready())
	{
		tmp.Draw(tmp.Rect(), 0, 0, bckg, DrawFlagsReflectDest);
	}

	if(dib->Ready())
	{
		g.DrawImage(dib->bmp, 0.0f, r.Height() * 0.36f);

		Font font(L"Arial", 9.0f);
		StringFormat *stringFormat = new StringFormat();
		stringFormat->SetAlignment(StringAlignmentCenter);
		stringFormat->SetLineAlignment(StringAlignmentCenter);
		stringFormat->SetTrimming(StringTrimmingEllipsisCharacter);

		CString s;
		s.Format(L"%s\n%s", skin->name.GetBuffer(), skin->description.GetBuffer());
		
		RectF rx(0, 0, (REAL)dib->Width(), r.Height() * 0.36f);

		rx.Y++;
		SolidBrush brush(0xfff0f0f0);
		g.DrawString(s.GetBuffer(), s.GetLength(), &font, rx, stringFormat, &brush);

		rx.Y--;
		brush.SetColor(0xff000000);
		g.DrawString(s.GetBuffer(), s.GetLength(), &font, rx, stringFormat, &brush);

		delete stringFormat;
	}
}
开发者ID:VladimirLichonos,项目名称:XWindows-Dock-2.0,代码行数:48,代码来源:skinlist.cpp

示例7: GetMaxItemWidth

int CLMenu::GetMaxItemWidth()
{
	int w = 0;

	HDC dc = CreateCompatibleDC(0);
	Graphics g(dc);
	RectF r;
	Font font(L"Arial", FONT_SIZE);
	StringFormat *stringFormat = new StringFormat();
	stringFormat->SetAlignment(StringAlignmentNear);
	stringFormat->SetLineAlignment(StringAlignmentCenter);
	stringFormat->SetTrimming(StringTrimmingEllipsisCharacter);
	stringFormat->SetFormatFlags(StringFormatFlagsLineLimit);

	POSITION p = items.GetHeadPosition();
	while(p)
	{
		r.X = 0;
		r.Y = 0;
		r.Width = 0;
		r.Height = 0;

		CLMenuItem *item = items.GetAt(p);
		if(item->visible)
		{
			g.MeasureString(item->text.GetBuffer(), item->text.GetLength(), &font, r, &r);

			if(r.Width > w)
			{
				w = (int)r.Width;
			}
		}
		items.GetNext(p);
	}

	delete stringFormat;
	DeleteObject(dc);

	return w;
}
开发者ID:VladimirLichonos,项目名称:XWindows-Dock-2.0,代码行数:40,代码来源:menu.cpp

示例8: DrawItem


//.........这里部分代码省略.........
	else
	{
		rf.X += 4;
		rf.Width -= 14;

		if(item->icon->Ready())
		{
			RectF ri = rf;
			ri.Width = rf.Height * 0.9f;
			ri.Height = ri.Width;
			ri.Y += (rf.Height - ri.Height) / 2;

			rf.X += rf.Height;
			rf.Width -= rf.Height;

			float k = min(ri.Width / item->icon->Width(), ri.Height / item->icon->Height());
			
			g.SetInterpolationMode(InterpolationModeHighQualityBicubic);

			ri.X += (ri.Width - item->icon->Width() * k) / 2;
			ri.Y += (ri.Height - item->icon->Height() * k) / 2;
			ri.Width = item->icon->Width() * k;
			ri.Height = item->icon->Height() * k;

			g.DrawImage(item->icon->bmp, ri);
		}

		RectF rc = rf;
		rc.Width = rf.Height * 0.42f;
		rc.Height = rc.Width;
		rc.Y += (rf.Height - rc.Height) / 2;

		if(item->checkbox)
		{
			if(item->checked)
			{
				Pen pen(0xffffffff);
				SolidBrush brush(0xffffffff);
				if(!item->enabled)
				{
					pen.SetColor(0xffb0b0b0);
					brush.SetColor(0xffb0b0b0);
				}

				GraphicsPath *path = new GraphicsPath();
				path->AddLine(rc.X + rc.Width * 0.4f, rc.Y + rc.Height, rc.X + rc.Width * 0.9f, rc.Y);
				path->AddLine(rc.X + rc.Width * 0.9f, rc.Y, rc.X + rc.Width * 0.4f, rc.Y + rc.Height * 0.8f);
				path->AddLine(rc.X + rc.Width * 0.4f, rc.Y + rc.Height * 0.8f, rc.X, rc.Y + rc.Height * 0.6f);
				path->CloseFigure();

				g.FillPath(&brush, path);
				g.DrawPath(&pen, path);

				delete path;
			}
		}

		if(!item->icon->Ready())
		{
			rf.X += (rc.Height + 2);
			rf.Width -= (rc.Height + 2);
		}

		SolidBrush brush(0xff000000);

		Font font(L"Arial", FONT_SIZE);
		StringFormat *stringFormat = new StringFormat();
		stringFormat->SetAlignment(StringAlignmentNear);
		stringFormat->SetLineAlignment(StringAlignmentCenter);
		stringFormat->SetTrimming(StringTrimmingEllipsisCharacter);
		stringFormat->SetFormatFlags(StringFormatFlagsLineLimit);

		//rf.Y++;
		//g.DrawString(item->text.GetBuffer(), item->text.GetLength(), &font, rf, stringFormat, &brush);

		brush.SetColor(0xffffffff);
		if(!item->enabled)
		{
			brush.SetColor(0xffb0b0b0);
		}

		//rf.Y--;
		g.DrawString(item->text.GetBuffer(), item->text.GetLength(), &font, rf, stringFormat, &brush);

		if(item->menu->ItemCount(TRUE))
		{
			GraphicsPath *path = new GraphicsPath();

			path->AddLine((REAL)(item->dib->Width() - 12), (REAL)(item->dib->Height() * 0.33), (REAL)(item->dib->Width() - 6), (REAL)(item->dib->Height() * 0.5));
			path->AddLine((REAL)(item->dib->Width() - 6), (REAL)(item->dib->Height() * 0.5), (REAL)(item->dib->Width() - 12), (REAL)(item->dib->Height() * 0.67));
			path->CloseFigure();

			g.FillPath(&brush, path);

			delete path;
		}

		delete stringFormat;
	}
}
开发者ID:VladimirLichonos,项目名称:XWindows-Dock-2.0,代码行数:101,代码来源:menu.cpp

示例9: createTexture

TextDisplay::DisplayTexture TextDisplay::createTexture(const char* text)
{
	DisplayTexture displayTex;
	size_t textLen = strlen(text);
	displayTex.text = new char[textLen+1];
	strcpy_s(displayTex.text, textLen+1, text);
	Bitmap* bitmap;
	Gdiplus::Font* font;

	{
		pfc::stringcvt::string_wide_from_utf8 w_text(text);
		StringFormat strFormat;
		strFormat.SetAlignment(StringAlignmentCenter);
		strFormat.SetTrimming(StringTrimmingNone);
		strFormat.SetFormatFlags(StringFormatFlagsNoFitBlackBox |
								 StringFormatFlagsNoWrap |
								 StringFormatFlagsNoClip);
		RectF stringSize(0, 0, 1024, 128);

		{ // calculate Text Size
			Bitmap calcBitmap(5, 5, PixelFormat32bppARGB);
			Graphics graphics(&calcBitmap);

			HDC fontDC = graphics.GetHDC();
			font = new Gdiplus::Font(fontDC, &(cfgTitleFont.get_value()));
			graphics.ReleaseHDC(fontDC);
			if (!font->IsAvailable()){
				delete font;
				font = new Gdiplus::Font(L"Verdana", 8.0f);
			}

			graphics.MeasureString(w_text, -1, font, PointF(), &stringSize);
		}
		// round to multiples of two, so centering is consistent
		stringSize.Width = ceil(stringSize.Width / 2.0f) * 2;
		stringSize.Height = ceil(stringSize.Height);
		displayTex.texWidth  = displayTex.textWidth  = (int)stringSize.Width;
		displayTex.texHeight = displayTex.textHeight = (int)stringSize.Height;
		
		// Make the texture size a power of two
		displayTex.texWidth = 1;
		while (displayTex.texWidth < displayTex.textWidth)
			displayTex.texWidth = displayTex.texWidth << 1;

		displayTex.texHeight = 1;
		while (displayTex.texHeight < displayTex.textHeight)
			displayTex.texHeight = displayTex.texHeight << 1;

		bitmap = new Bitmap(displayTex.texWidth, displayTex.texHeight, PixelFormat32bppARGB);
		Graphics drawer(bitmap);
		drawer.SetTextRenderingHint(TextRenderingHintAntiAliasGridFit);

		Color textColor(255, 255, 255);
		textColor.SetFromCOLORREF(cfgTitleColor);
		SolidBrush textBrush(textColor);
		displayTex.color = cfgTitleColor;

		drawer.DrawString(w_text, -1, font, stringSize, &strFormat, &textBrush);
	}

	{
		bitmap->RotateFlip(RotateNoneFlipY);
		Rect rc(0,0,bitmap->GetWidth(),bitmap->GetHeight());
		BitmapData bitmapData;
		bitmap->LockBits(&rc,ImageLockModeRead,PixelFormat32bppARGB,&bitmapData);

		glGenTextures(1,&displayTex.glTex);
		glBindTexture(GL_TEXTURE_2D, displayTex.glTex);
		glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_NEAREST);
		glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);

		void* data = bitmapData.Scan0;
		glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, displayTex.texWidth, displayTex.texHeight, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE,data);

		bitmap->UnlockBits(&bitmapData);

	}
	delete bitmap;
	delete font;

	return displayTex;
}
开发者ID:qq2377654,项目名称:foo_chronflow,代码行数:82,代码来源:TextDisplay.cpp

示例10: DrawString

/*
** Draws the string or calculates it's size
**
*/
bool CMeterString::DrawString(Graphics& graphics, RectF* rect)
{
	if (m_Font == NULL) return false;

	LPCWSTR string = m_String.c_str();
	int stringLen = (int)m_String.length();

	StringFormat stringFormat;

	if (m_AntiAlias)
	{
		graphics.SetTextRenderingHint(TextRenderingHintAntiAlias);
	}
	else
	{
		graphics.SetTextRenderingHint(TextRenderingHintSingleBitPerPixelGridFit);
	}

	switch (m_Align)
	{
	case ALIGN_CENTERCENTER:
		stringFormat.SetAlignment(StringAlignmentCenter);
		stringFormat.SetLineAlignment(StringAlignmentCenter);
		break;

	case ALIGN_RIGHTCENTER:
		stringFormat.SetAlignment(StringAlignmentFar);
		stringFormat.SetLineAlignment(StringAlignmentCenter);
		break;

	case ALIGN_LEFTCENTER:
		stringFormat.SetAlignment(StringAlignmentNear);
		stringFormat.SetLineAlignment(StringAlignmentCenter);
		break;

	case ALIGN_CENTERBOTTOM:
		stringFormat.SetAlignment(StringAlignmentCenter);
		stringFormat.SetLineAlignment(StringAlignmentFar);
		break;

	case ALIGN_RIGHTBOTTOM:
		stringFormat.SetAlignment(StringAlignmentFar);
		stringFormat.SetLineAlignment(StringAlignmentFar);
		break;

	case ALIGN_LEFTBOTTOM:
		stringFormat.SetAlignment(StringAlignmentNear);
		stringFormat.SetLineAlignment(StringAlignmentFar);
		break;

	case ALIGN_CENTER:	// Same as CenterTop
		stringFormat.SetAlignment(StringAlignmentCenter);
		stringFormat.SetLineAlignment(StringAlignmentNear);
		break;

	case ALIGN_RIGHT:	// Same as RightTop
		stringFormat.SetAlignment(StringAlignmentFar);
		stringFormat.SetLineAlignment(StringAlignmentNear);
		break;

	case ALIGN_LEFT:	// Same as LeftTop
		stringFormat.SetAlignment(StringAlignmentNear);
		stringFormat.SetLineAlignment(StringAlignmentNear);
		break;
	}

	if (m_ClipString)
	{
		stringFormat.SetTrimming(StringTrimmingEllipsisCharacter);
	}
	else
	{
		stringFormat.SetTrimming(StringTrimmingNone);
		stringFormat.SetFormatFlags(StringFormatFlagsNoClip | StringFormatFlagsNoWrap);
	}

	CharacterRange range(0, stringLen);
	stringFormat.SetMeasurableCharacterRanges(1, &range);

	REAL x = (REAL)GetX();
	REAL y = (REAL)GetY();

	if (rect)
	{
		PointF pos(x, y);
		graphics.MeasureString(string, stringLen, m_Font, pos, &stringFormat, rect);
	}
	else
	{
		RectF rcDest(x, y, (REAL)m_W, (REAL)m_H);
		m_Rect = rcDest;

		if (m_Angle != 0.0f)
		{
			graphics.TranslateTransform((Gdiplus::REAL)CMeter::GetX(), y);
			graphics.RotateTransform(CONVERT_TO_DEGREES(m_Angle));
//.........这里部分代码省略.........
开发者ID:VladimirKhomenko,项目名称:SunMeter,代码行数:101,代码来源:MeterString.cpp

示例11: Draw

void CDrawWarn::Draw(CDC* pDC)
{
	ASSERT_VALID(this);
	CRect rect = m_position;
	rect.NormalizeRect();

	if(rect.Width() < 10 || rect.Height()<10)
		return;

	Rect GdiRect (rect.TopLeft().x,rect.TopLeft().y,rect.Size().cx,rect.Size().cy); 

	Color crBackColor,crTitleColor,crLineColor,crTextColor ;
	crBackColor.SetFromCOLORREF(m_ctlBackColor);
	crTitleColor.SetFromCOLORREF(m_ctlTitleColor );
	crLineColor.SetFromCOLORREF(m_ctlLineColor);
	crTextColor.SetFromCOLORREF(m_ctlTextColor);

	Graphics graphics (pDC->m_hDC);
	graphics.SetSmoothingMode (SmoothingModeHighSpeed);
	Graphics Textgraphics (pDC->m_hDC);
	SolidBrush  solidBrush(crBackColor);
	SolidBrush  TitleBrush(crTitleColor);
	SolidBrush  TextBrush(crTextColor);
	Pen pen(crLineColor,1);
	
	graphics.FillRectangle(&solidBrush,GdiRect);

        		BSTR bstr = m_fontName.AllocSysString();
///	BSTR bstr = _com_util::ConvertStringToBSTR(m_fontName);
	FontFamily  fontFamily(bstr);
   	SysFreeString(bstr);
	Font font(&fontFamily, m_fontSize, m_fontStyle, UnitPoint);

	for(int j =1; j<= m_nColCount; j++)
	{
		m_nCellWidth = 0;
		for(int i=1; i<= m_nRowCount; i++)
		{
			CRect rc = rect;
			if(m_bIsAutoSize)
			{
				m_nCellWidth = rect.Width()/m_nRowCount;
				m_nCellHeight = rect.Height()/m_nColCount;
				rc.TopLeft().x += (i-1)*m_nCellWidth;
				rc.TopLeft().y += (j-1)*m_nCellHeight;
				m_CellRect = CRect(rc.TopLeft(),CSize(m_nCellWidth,m_nCellHeight));
				m_CellRect.NormalizeRect();
			}
			else
			{
				rc.TopLeft().x += m_nCellWidth;
				m_nCellWidth += rect.Width()*m_nPercent[i-1]/100;
				m_nCellHeight = rect.Height()/m_nColCount;
				rc.TopLeft().y += (j-1)*m_nCellHeight;	
				m_CellRect = CRect(rc.TopLeft(),CSize(rect.Width()*m_nPercent[i-1]/100,m_nCellHeight));
				m_CellRect.NormalizeRect();
			}

			Rect CellRect(m_CellRect.TopLeft().x,m_CellRect.TopLeft().y,m_CellRect.Size().cx,m_CellRect.Size().cy);

			graphics.DrawRectangle(&pen,CellRect);
			
			if(j == m_nColCount)	//画标题
			{
				StringFormat stringFormat;
				stringFormat.SetAlignment(StringAlignmentCenter);
				stringFormat.SetLineAlignment(StringAlignmentCenter);
				stringFormat.SetFormatFlags(StringFormatFlagsDirectionRightToLeft);
				stringFormat.SetTrimming(m_trimmingSyle);

				CString m_strButton;
				if(i == 1)
					m_strButton = "点号";
				if(i == 2)
					m_strButton = "数据";
				if(i == 3)
					m_strButton = "说明";
				if(i == 4)
					m_strButton = "报警原因";
				if(i == 5)
					m_strButton = "时间";

				m_strButton.TrimRight();
        		bstr = m_strButton.AllocSysString();
///				bstr = _com_util::ConvertStringToBSTR(m_strButton);
				RectF theRect (m_CellRect.TopLeft().x,m_CellRect.TopLeft().y,m_CellRect.Size().cx,m_CellRect.Size().cy);
				Matrix matrix(1,0,0,-1,0,0);
				Textgraphics.SetTransform(&matrix);
				
				theRect.Y *=-1;
				theRect.Height*=-1;
				Normallize (theRect);	
				Textgraphics.FillRectangle(&TitleBrush,theRect);
				Textgraphics.DrawString(bstr,-1,&font, theRect,&stringFormat, &TextBrush);
            	SysFreeString(bstr);
			}
			else 
			{					//画文字  m_CStrWarn      pStrWarn
				StringFormat stringFormat;
				stringFormat.SetAlignment(StringAlignmentNear);
//.........这里部分代码省略.........
开发者ID:xiaoyugm,项目名称:chtproject,代码行数:101,代码来源:DrawWarn.cpp

示例12: DrawItem

void CTabsControl::DrawItem(CTabControl *item, Gdiplus::Graphics &g)
{
	CRect rect = ItemRect(item);

	g.ResetTransform();
	g.TranslateTransform((REAL)rect.left, (REAL)rect.top);

	RectF rf(0.0f, 0.0f, (REAL)rect.Width(), (REAL)rect.Height());
	RectF rx;

	if(item->selected)
	{
		#define shadowb 10

		CDIB tmp;
		tmp.Resize(rect.Width() + shadowb * 2, rect.Height() + shadowb * 2);
		if(tmp.Ready())
		{
			Graphics gt(tmp.bmp);
			RectF rx(0, 0, (REAL)tmp.Width(), (REAL)tmp.Height());
			
			GraphicsPath *path = new GraphicsPath();
			path->AddLine(rx.X + shadowb, rx.Y + rx.Height - shadowb, rx.X + rx.Width - 2 - shadowb, rx.Y + rx.Height - shadowb);
			path->AddLine(rx.X + rx.Width - 2 - shadowb, rx.Y + rx.Height - shadowb, rx.X + rx.Width - 2, rx.Y);
			path->AddLine(rx.X + rx.Width - 2, rx.Y, rx.X + rx.Width, rx.Y + rx.Height);
			path->AddLine(rx.X + rx.Width, rx.Y + rx.Height, rx.X, rx.Y + rx.Height);
			path->AddLine(rx.X, rx.Y, rx.X + shadowb, rx.Y + rx.Height - shadowb);
			path->CloseFigure();

			SolidBrush brush(0xff000000);
			gt.FillPath(&brush, path);

			tmp.Blur(tmp.Rect(), CRect(0, 0, 0, 0), shadowb);

			g.DrawImage(tmp.bmp, rf, shadowb, shadowb, rf.Width, rf.Height, UnitPixel);

			delete path;
		}
	}

	Font font(L"Arial", item->selected ? 8.0f : 8.0f);
	StringFormat *stringFormat = new StringFormat();
	stringFormat->SetAlignment(StringAlignmentCenter);
	stringFormat->SetLineAlignment(StringAlignmentCenter);
	stringFormat->SetTrimming(StringTrimmingEllipsisCharacter);
	stringFormat->SetFormatFlags(StringFormatFlagsLineLimit);

	if(item->icon->Ready())
	{
		g.SetInterpolationMode(InterpolationModeBicubic);
		rx = rf;
		rx.Y += 6;
		rx.Height -= (20 + rx.Y);
		rx.Width = rx.Height;
		rx.X += (rf.Width - rx.Width) / 2;

		if(item->selected)
		{
			rx.Y++;

			#define shadow 5
			CDIB tmp;
			tmp.Resize(item->icon->Width(), item->icon->Height());
			if(tmp.Ready())
			{
				tmp.Draw(CRect(shadow, shadow, 
					item->icon->Width() - shadow, 
					item->icon->Height() - shadow), 
					item->icon->Rect(), item->icon);
				DIB_ARGB *p = tmp.scan0;
				int size = tmp.Width() * tmp.Height();
				for(int i = 0; i < size; i++, p++)
				{
					p->r = 0;
					p->g = 0;
					p->b = 0;
				}
				tmp.Blur(tmp.Rect(), CRect(0, 0, 0, 0), shadow);
				g.DrawImage(tmp.bmp, RectF(rx.X, rx.Y + shadow, rx.Width, rx.Height));
			}
			tmp.Assign(item->icon);
			/*if(tmp.Ready())
			{
				DIB_ARGB *p = tmp.scan0;
				int size = tmp.Width() * tmp.Height();
				for(int i = 0; i < size; i++, p++)
				{
					p->r = 0x6f;
					p->g = 0xa6;
					p->b = 0xde;
				} 
			}*/
			g.DrawImage(tmp.bmp, rx);
		}
		else
		{
			g.DrawImage(item->icon->bmp, rx);
		}
	}

//.........这里部分代码省略.........
开发者ID:VladimirLichonos,项目名称:XWindows-Dock-2.0,代码行数:101,代码来源:tabscontrol.cpp

示例13: DrawControl

void CDuiListCtrl::DrawControl(CDC &dc, CRect rcUpdate)
{
	// 列表画图方法:
	// 1.列表的虚拟高度为每一行高度*行数
	// 2.列表显示的top坐标由scroll控件记录
	// 3.重画时候,根据top坐标位置计算出显示的第一行的序号,根据显示高度计算出显示的最后一行的序号
	// 4.根据计算出的显示的行,画相应的内容到内存dc中
	// 5.计算出显示的top坐标进行内存dc的拷贝
	int nWidth = m_rc.Width() - m_nScrollWidth;	// 减去滚动条的宽度
	int nHeightAll = (int)m_vecRowInfo.size()*m_nRowHeight; // 总的虚拟高度 //m_rc.Height();
	CScrollV* pScrollV = (CScrollV*)m_pControScrollV;
	int nCurPos = pScrollV->GetScrollCurrentPos();	// 当前top位置
	int nMaxRange = pScrollV->GetScrollMaxRange();

	m_nVirtualTop = (nMaxRange > 0) ? nCurPos*(nHeightAll-m_rc.Height())/nMaxRange : 0;	// 当前滚动条位置对应的虚拟的top位置
	if(m_nVirtualTop < 0)
	{
		m_nVirtualTop = 0;
		pScrollV->SetScrollCurrentPos(0);
	}
	m_nFirstViewRow = m_nVirtualTop / m_nRowHeight;					// 显示的第一行序号
	m_nLastViewRow = (m_nVirtualTop + m_rc.Height()) / m_nRowHeight;	// 显示的最后一行序号
	if(m_nLastViewRow >= (int)m_vecRowInfo.size())
	{
		m_nLastViewRow = (int)m_vecRowInfo.size() - 1;
	}
	if(m_nLastViewRow < 0)
	{
		m_nLastViewRow = 0;
	}
	int nHeightView = (m_nLastViewRow - m_nFirstViewRow +1) * m_nRowHeight;	// 显示涉及到的虚拟高度
	int nYViewPos = m_nVirtualTop - (m_nFirstViewRow * m_nRowHeight);		// 内存dc显示到屏幕时候的top位置
	if(nYViewPos < 0)
	{
		nYViewPos = 0;
	}

	if(!m_bUpdate)
	{
		UpdateMemDC(dc, nWidth, nHeightView);

		Graphics graphics(m_memDC);
		
		m_memDC.BitBlt(0, 0, nWidth, nHeightView, &dc, m_rc.left ,m_rc.top, WHITENESS);	// 画白色背景
		DrawVerticalTransition(m_memDC, dc, CRect(0, nYViewPos, nWidth, m_rc.Height()+nYViewPos),	// 背景透明度
				m_rc, m_nBkTransparent, m_nBkTransparent);
		
		BSTR bsFontTitle = m_strFontTitle.AllocSysString();
		FontFamily fontFamilyTitle(bsFontTitle);
		Font fontTitle(&fontFamilyTitle, (REAL)m_nFontTitleWidth, m_fontTitleStyle, UnitPixel);
		::SysFreeString(bsFontTitle);

		BSTR bsFont = m_strFont.AllocSysString();
		FontFamily fontFamily(bsFont);
		Font font(&fontFamily, (REAL)m_nFontWidth, m_fontStyle, UnitPixel);
		::SysFreeString(bsFont);

		SolidBrush solidBrush(m_clrText);			// 正常文字画刷
		SolidBrush solidBrushH(m_clrTextHover);		// 热点文字画刷
		SolidBrush solidBrushD(m_clrTextDown);		// 当前行画刷
		SolidBrush solidBrushT(m_clrTitle);			// 标题文字画刷
		SolidBrush solidBrushS(m_clrSeperator);		// 分割线画刷

		graphics.SetTextRenderingHint( TextRenderingHintClearTypeGridFit );

		// 普通文字的对齐方式
		StringFormat strFormat;
		strFormat.SetAlignment(StringAlignmentNear);	// 左对齐
		if(m_uVAlignment == VAlign_Top)
		{
			strFormat.SetLineAlignment(StringAlignmentNear);	// 上对其
		}else
		if(m_uVAlignment == VAlign_Middle)
		{
			strFormat.SetLineAlignment(StringAlignmentCenter);	// 中间对齐
		}else
		if(m_uVAlignment == VAlign_Bottom)
		{
			strFormat.SetLineAlignment(StringAlignmentFar);	// 下对齐
		}
		strFormat.SetTrimming(StringTrimmingEllipsisWord);	// 以单词为单位去尾,略去部分使用省略号
		//strFormat.SetFormatFlags( StringFormatFlagsNoClip | StringFormatFlagsMeasureTrailingSpaces);
		if(!m_bTextWrap)
		{
			strFormat.SetFormatFlags(StringFormatFlagsNoWrap | StringFormatFlagsMeasureTrailingSpaces);	// 不换行
		}

		// 时间字段采用右对齐
		StringFormat strFormatRight;
		strFormatRight.SetAlignment(StringAlignmentFar);	// 右对齐
		if(m_uVAlignment == VAlign_Top)
		{
			strFormatRight.SetLineAlignment(StringAlignmentNear);	// 上对其
		}else
		if(m_uVAlignment == VAlign_Middle)
		{
			strFormatRight.SetLineAlignment(StringAlignmentCenter);	// 中间对齐
		}else
		if(m_uVAlignment == VAlign_Bottom)
		{
//.........这里部分代码省略.........
开发者ID:anchowee,项目名称:DuiVision,代码行数:101,代码来源:DuiListCtrl.cpp

示例14: LayerDraw

void CNotification::LayerDraw(CDIB *dib)
{
	if(!dib)
	{
		dib = CNotification::dib;
	}
	CRect rect;
	GetWindowRect(&rect);
	dib->Resize(rect.Width(), rect.Height());
	if(!dib->Ready())
	{
		return;
	}

	RectF rf(0.0f, 0.0f, (REAL)dib->Width(), (REAL)dib->Height());
	rf.Width -= SHADOW_SIZE;
	rf.Height -= SHADOW_SIZE;

	Graphics g(dib->dc);
	g.SetCompositingMode(CompositingModeSourceOver);
	g.SetSmoothingMode(SmoothingModeAntiAlias);

	GraphicsPath *path = new GraphicsPath();

	float radius = rf.Height;

	path->AddArc(rf.X + rf.Width - radius, rf.Y + rf.Height - radius, radius - 1, radius - 1, 0, 90);
	path->AddArc(rf.X, rf.Y + rf.Height - radius, radius - 1, radius - 1, 90, 90);
	path->AddArc(rf.X, rf.Y, radius - 1, radius - 1, 180, 90);
	path->AddArc(rf.X + rf.Width - radius, rf.Y, radius - 1, radius - 1, 270, 90);
	path->CloseFigure();

	g.TranslateTransform(SHADOW_SIZE, SHADOW_SIZE);
	g.ScaleTransform((rf.Width - SHADOW_SIZE) / rf.Width, (rf.Height - SHADOW_SIZE) / rf.Height);

	SolidBrush brush2(0xf0000000);
	g.FillPath(&brush2, path);

	g.ResetTransform();

	dib->Blur(dib->Rect(), CRect(0, 0, 0, 0), SHADOW_SIZE);

	brush2.SetColor(0xffffffff);
	g.FillPath(&brush2, path);

	rf.X += rf.Height * 0.1f;
	rf.Y += rf.Height * 0.1f;
	rf.Width -= rf.Height * 0.2f;
	rf.Height -= rf.Height * 0.2f;

	radius = rf.Height;

	path->Reset();
	path->AddArc(rf.X + rf.Width - radius, rf.Y + rf.Height - radius, radius - 1, radius - 1, 0, 90);
	path->AddArc(rf.X, rf.Y + rf.Height - radius, radius - 1, radius - 1, 90, 90);
	path->AddArc(rf.X, rf.Y, radius - 1, radius - 1, 180, 90);
	path->AddArc(rf.X + rf.Width - radius, rf.Y, radius - 1, radius - 1, 270, 90);
	path->CloseFigure();

	LinearGradientBrush brush(rf, 0xff6fa6de, 0xff1e6cbb, LinearGradientModeVertical);
	g.FillPath(&brush, path);

	delete path;

	Font font(L"Arial", rect.Height() * 0.6f, FontStyleRegular, UnitPixel);
	StringFormat *stringFormat = new StringFormat();
	stringFormat->SetAlignment(StringAlignmentCenter);
	stringFormat->SetLineAlignment(StringAlignmentCenter);
	stringFormat->SetFormatFlags(StringFormatFlagsLineLimit);
	stringFormat->SetTrimming(StringTrimmingEllipsisCharacter);

	CString s;
	GetWindowText(s);

	g.DrawString(s.GetBuffer(), s.GetLength(), &font, rf, stringFormat, &brush2);

	delete stringFormat;
}
开发者ID:VladimirLichonos,项目名称:XWindows-Dock-2.0,代码行数:78,代码来源:notifications.cpp

示例15: DrawShipDesignMenue


//.........这里部分代码省略.........
		Color btnColor;
		CFontLoader::GetGDIFontColor(pMajor, 1, btnColor);
		SolidBrush btnBrush(btnColor);

		fontFormat.SetAlignment(StringAlignmentCenter);
		fontFormat.SetLineAlignment(StringAlignmentCenter);

		// Nach Beamwaffen suchen
		if (m_pShownShip->GetBeamWeapons()->GetSize() > m_iBeamWeaponNumber)
		{
			// gibt es schon von dieser Beamwaffe hier auf dem Schiff einen höheren Typ?
			USHORT maxTyp =	pMajor->GetWeaponObserver()->GetMaxBeamType(m_pShownShip->GetBeamWeapons()->GetAt(m_iBeamWeaponNumber).GetBeamName());
			if (maxTyp > m_pShownShip->GetBeamWeapons()->GetAt(m_iBeamWeaponNumber).GetBeamType())
			{
				// Dann können wir den Typ unserer Beamwaffe(n) verbessern
				if (graphic)
					g->DrawImage(graphic, 930, 120, 120, 30);
				g->DrawString(CComBSTR(CLoc::GetString("BTN_STRONGER")), -1, &Gdiplus::Font(CComBSTR(fontName), fontSize), RectF(930,120,120,30), &fontFormat, &btnBrush);
				m_bFoundBetterBeam = TRUE;
			}
			// Wenn wir einen größeren Typ als Typ 1 haben, dann können wir diesen verringern
			if (m_pShownShip->GetBeamWeapons()->GetAt(m_iBeamWeaponNumber).GetBeamType() > 1)
			{
				// Dann können wir den Typ unserer Beamwaffe(n) verkleinern
				if (graphic)
					g->DrawImage(graphic, 800, 120, 120, 30);
				g->DrawString(CComBSTR(CLoc::GetString("BTN_WEAKER")), -1, &Gdiplus::Font(CComBSTR(fontName), fontSize), RectF(800,120,120,30), &fontFormat, &btnBrush);
				m_bFoundWorseBeam = TRUE;
			}

			// Typ und Name der Beamwaffe zeichnen
			fontBrush.SetColor(normalColor);
			s.Format("%s %d %s",CLoc::GetString("TYPE"),m_pShownShip->GetBeamWeapons()->GetAt(m_iBeamWeaponNumber).GetBeamType(),m_pShownShip->GetBeamWeapons()->GetAt(m_iBeamWeaponNumber).GetBeamName());
			fontFormat.SetTrimming(StringTrimmingEllipsisCharacter);
			g->DrawString(CComBSTR(s), -1, &Gdiplus::Font(CComBSTR(fontName), fontSize), RectF(845,80,160,25), &fontFormat, &fontBrush);
			fontFormat.SetTrimming(StringTrimmingNone);
		}

		// Nach anderer Torpedowaffe suchen
		if (m_pShownShip->GetTorpedoWeapons()->GetSize() > m_iTorpedoWeaponNumber)
		{
			// den aktuellen Torpedotyp holen
			BYTE currentTorpType = m_pShownShip->GetTorpedoWeapons()->GetAt(m_iTorpedoWeaponNumber).GetTorpedoType();
			// Torpedoname zeichnen
			fontBrush.SetColor(normalColor);
			s.Format("%s (%d°)",m_pShownShip->GetTorpedoWeapons()->GetAt(m_iTorpedoWeaponNumber).GetTupeName(), m_pShownShip->GetTorpedoWeapons()->GetAt(m_iTorpedoWeaponNumber).GetFirearc()->GetAngle());
			g->DrawString(CComBSTR(s), -1, &Gdiplus::Font(CComBSTR(fontName), fontSize), RectF(775,170,300,25), &fontFormat, &fontBrush);

			s.Format("%s (%d)", CTorpedoInfo::GetName(currentTorpType), CTorpedoInfo::GetPower(currentTorpType));
			g->DrawString(CComBSTR(s), -1, &Gdiplus::Font(CComBSTR(fontName), fontSize), RectF(775,195,300,25), &fontFormat, &fontBrush);

			if (graphic)
				g->DrawImage(graphic, 800, 230, 120, 30);
			g->DrawString(CComBSTR(CLoc::GetString("BTN_LAUNCHER")), -1, &Gdiplus::Font(CComBSTR(fontName), fontSize), RectF(800,230,120,30), &fontFormat, &btnBrush);
			if (graphic)
				g->DrawImage(graphic, 930, 230, 120, 30);
			g->DrawString(CComBSTR(CLoc::GetString("BTN_TORPEDO")), -1, &Gdiplus::Font(CComBSTR(fontName), fontSize), RectF(930,230,120,30), &fontFormat, &btnBrush);
		}

		// hier Möglichkeit anderes Hüllenmaterial anzubringen eingebaut
		CString material;
		switch (m_pShownShip->GetHull()->GetHullMaterial())
		{
			case TITAN:		material = CLoc::GetString("TITAN");; break;
			case DURANIUM:	material = CLoc::GetString("DURANIUM");; break;
			case IRIDIUM:	material = CLoc::GetString("IRIDIUM");; break;
开发者ID:bote-reginald,项目名称:BotE-Rainer,代码行数:67,代码来源:ShipDesignMenuView.cpp


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