示例#1
0
void AClipboard::SetText(const AString& sText,bool bUnicode /*=true */ )
{
	if(::OpenClipboard(NULL))
	{
		::EmptyClipboard();
		HGLOBAL clipbuffer;
		char *buffer;
		if( bUnicode )
		{
			clipbuffer = ::GlobalAlloc(GMEM_DDESHARE, (sText.Length()+1)*2);
			buffer = (char *)::GlobalLock(clipbuffer);
			wcscpy((wchar_t*)buffer,sText.Text());
			::GlobalUnlock(clipbuffer);
			::SetClipboardData(CF_UNICODETEXT, clipbuffer);
		}
		else
		{
			AString str2;
			str2 = sText;
			const UACHAR* sz = str2.ConvertTo();
			clipbuffer = ::GlobalAlloc(GMEM_DDESHARE, strlen(sz)+1);
			buffer = (char *)::GlobalLock(clipbuffer);
			strcpy(buffer,sz);
			::GlobalUnlock(clipbuffer);
			::SetClipboardData(CF_TEXT, clipbuffer);
		}
		::CloseClipboard();
	}
}
示例#2
0
void ACanvasSkia::DrawText(int x1,int y1,const AString& sText)
{
	//_clip();
	_SetPaint_Font();

	int nFontSize = GetFont()->GetSize();
	y1 += nFontSize;
	//y1 -= 2;//微调 fix me later
	//AString str;
	//str = sText;
// 	AMemory ms;
// 	ms.SetSize( ::WideCharToMultiByte(CP_UTF8,0,sText.Text(),sText.Length(),NULL,0,NULL,NULL) +1 );
// 	char* buf = (char *)ms.GetData();
// 	::WideCharToMultiByte(CP_UTF8,0,sText.Text(),sText.Length(),buf,ms.GetSize()-1,NULL,NULL);
// 	buf[ms.GetSize()-1] = 0;
	const char* sz = (char *)sText.Text();// buf;//str.ConvertTo();
	int iLen = sText.Length()*sizeof(ACHAR);// sz ? strlen(sz) : 0 );

	m_Paint.setTextSize(SkIntToScalar(nFontSize));
	//m_Paint.setSubpixelText(false);
	//m_Paint.setLinearText(true);
	//m_Paint.setHinting(SkPaint::kFull_Hinting);
	m_pCanvas->drawText(sz,iLen,SkIntToScalar(x1),SkIntToScalar(y1),m_Paint);
	
// 	SkPoint pts[1000];
// 	SkScalar xpos = x1;
// 	//SkASSERT(length <= SK_ARRAY_COUNT(pts));
// 	for (size_t i = 0; i < iLen; i++) {
// 		pts[i].set(xpos, y1), xpos += nFontSize;
// 	}
// 	m_pCanvas->drawPosText(sz, iLen, pts, m_Paint);

	Reset();
}
示例#3
0
void GCanvas::DrawText(const ARect& r,const AString& sText,TTextAlign ta)
{
	Flush();

	UINT uFormat=DT_SINGLELINE;
	switch(ta)
	{
	case taLeftTop: uFormat |= DT_LEFT | DT_TOP; break;
	case taCenterTop:uFormat |= DT_CENTER | DT_TOP;break;
	case taRightTop:uFormat |= DT_RIGHT | DT_TOP; break;
	case taLeftMiddle:uFormat |= DT_LEFT | DT_VCENTER;break;
	case taCenterMiddle : uFormat |= DT_CENTER|DT_VCENTER;break;
	case taRightMiddle: uFormat |= DT_RIGHT | DT_VCENTER;break;
	case taLeftBottom: uFormat |= DT_LEFT | DT_BOTTOM; break;
	case taCenterBottom: uFormat |= DT_CENTER | DT_BOTTOM; break;
	case taRightBottom: uFormat |= DT_RIGHT | DT_BOTTOM;break;
	default:break;
	}
	::DrawText(m_hDC,sText.Text(),sText.Length(),(LPRECT)&r,uFormat);
}
示例#4
0
int ACanvasSkia::MeasurePosition(const AString& sText,int iPos)//根据位置找到所在字符串的下标
{
	_SetPaint_Font();
	int iLen = sText.Length();
	ACHAR* s = (ACHAR*)sText.Text();
	int x=0;
	int i=0;
	for(i=0;i<iLen;i++)
	{
		int y = m_Paint.measureText(s,(i+1)*sizeof(ACHAR));
		if( iPos >= x && iPos <= y ) 
		{
			int delta = (y-x)/2;
			if( iPos < x+delta ) return i;
			else return i+1;
		}
		x = y;
	}
	return i;
}
int AApplication::MsgBox(const AString& sText,const AString& sCaption,UINT nTyppe)
{
	return ::MessageBox(NULL,sText.Text(),sCaption.Text(),0);
}
示例#6
0
void GCanvas::DrawText(int x1,int y1,const AString& sText)
{
	Flush();
	::TextOut(m_hDC,x1,y1,sText.Text(),sText.Length());
}
示例#7
0
void ABitmap::LoadFromFile(const AString& sFileName)
{
	m_Bitmap.Load((LPTSTR)sFileName.Text());
}
示例#8
0
ASize ACanvasSkia::MeasureText(const AString& sText)
{
	_SetPaint_Font();
	int x = m_Paint.measureText(sText.Text(),sText.Length()*sizeof(ACHAR));
	return ASize(x,GetFont()->GetSize());
}
示例#9
0
void AMyImage::LoadFromFile(const AString& sFileName)
{
	m_Image.Load(sFileName.Text());
	ConvertBits();
	ToTransparent();
}