示例#1
0
	//--------------------------------------------------------------------------------------------------------------
	//设置最大字符数量
	void TextSurface::SetMaxChars( int nMaxChars )
	{
		free( mpText );

		//分配内存
		size_t nStrLen = sizeof(wchar_t) * ( nMaxChars + 1 );
		size_t nDrawLen = sizeof(FontFace::GlyphDraw) * nMaxChars;

		BYTE* pMem = (BYTE*)malloc( nStrLen + nDrawLen + sizeof(OverlayVertex)*6*nMaxChars );

		//分配新字符串缓存
		mMaxChars = nMaxChars;
		mNumChars = 0;

		mpText = (wchar_t*)pMem;
		memset( mpText, 0, nStrLen + nDrawLen );

		//分配字形数据缓存
		mpGlyphDraw = (FontFace::GlyphDraw*)( pMem + nStrLen );

		//分配顶点数据缓存
		mpVertexData = (OverlayVertex*)( pMem + nStrLen + nDrawLen );
		mpVertexPtr = mpVertexData;

		//更新文字数据
		_UpdateText();
	}
示例#2
0
void
StringEditor::AttachedToWindow()
{
	fEditor.StartWatching(this);

	_UpdateText();
}
示例#3
0
void
NumberEditor::AttachedToWindow()
{
	fTextControl->SetTarget(this);
	fEditor.StartWatching(this);

	_UpdateText();
}
示例#4
0
	//--------------------------------------------------------------------------------------------------------------
	TextSurface::TextSurface( ZOrderType eZType, OverlaySurface* pZRefOverlay, FontFace* pFont, LPCWSTR szText,
		int nX, int nY, int nLineWidth, int nMaxChars, DWORD dwColor, TextureFilterType eFilterType )
		:OverlaySurface	( eZType, pZRefOverlay, eFilterType )
		 ,mpFont			(pFont)
		, mpText			(NULL)
		, mNumChars			(0)
		, mX				(nX)
		, mY				(nY)
		, mLineWidth		(nLineWidth)
		, mTextColor		(dwColor)
	{
		if( nX + mpFont->mnMaxWidth > nLineWidth )
			Except( Exception::ERR_INVALIDPARAMS, "指定平面文字行宽度过小。" );

		//计算字符串长度
		int nNumChars = 0;
		wchar_t* pChar = (wchar_t*)szText;
		while( *pChar != 0 )
		{
			++pChar;
			++nNumChars;
		}

		//如果未指定最大字符数量则使用当前字符串字符数量
		if( nMaxChars == 0 )
			mMaxChars = nNumChars;
		else if( nMaxChars < nNumChars )
			Except( Exception::ERR_INVALIDPARAMS, "指定的最大字符数量小于当前文字字符数量。" );
		else
			mMaxChars = nMaxChars;

		mNumChars = nNumChars;

		//分配内存
		size_t nStrLen = sizeof(wchar_t) * ( mMaxChars + 1 );
		size_t nDrawLen = sizeof(FontFace::GlyphDraw) * mMaxChars;

		BYTE* pMem = (BYTE*)malloc( nStrLen + nDrawLen + sizeof(OverlayVertex)*6*mMaxChars );

		//复制字符串
		mpText = (wchar_t*)pMem;
		memcpy( mpText, szText, sizeof(wchar_t) * ( mNumChars + 1 ) );

		//分配字形数据缓存
		mpGlyphDraw = (FontFace::GlyphDraw*)( pMem + nStrLen );
		memset( mpGlyphDraw, 0, nDrawLen );

		//分配顶点数据缓存
		mpVertexData = (OverlayVertex*)( pMem + nStrLen + nDrawLen );
		mpVertexPtr = mpVertexData;
		mNumVertex = 0;

		//更新文字数据
		_UpdateText();
	}
示例#5
0
void
NumberEditor::MessageReceived(BMessage *message)
{
	switch (message->what) {
		case kMsgValueChanged:
			CommitChanges();
			break;
		case kMsgDataEditorUpdate:
			_UpdateText();
			break;

		default:
			BView::MessageReceived(message);
	}
}
示例#6
0
void
MimeTypeEditor::MessageReceived(BMessage *message)
{
	switch (message->what) {
		case kMsgValueChanged:
			fEditor.Replace(0, (const uint8 *)fTextControl->Text(),
				strlen(fTextControl->Text()) + 1);
			break;

		case kMsgDataEditorUpdate:
			_UpdateText();
			break;

		default:
			BView::MessageReceived(message);
	}
}
示例#7
0
void
TextViewTest::MessageReceived(BMessage* message)
{
	switch (message->what) {
		case MSG_UPDATE_INSETS:
			_UpdateInsets();
			break;
		case MSG_UPDATE_TEXT:
			_UpdateText();
			break;
		case MSG_UPDATE_FONT:
			_UpdateFont();
			break;
		default:
			Test::MessageReceived(message);
			break;
	}
}
示例#8
0
	//--------------------------------------------------------------------------------------------------------------
	//设置文字内容
	void TextSurface::SetText( LPCWSTR szText )
	{
		//计算字符串长度
		int mNumChars = 0;
		wchar_t* pChar = (wchar_t*)szText;
		while( *pChar != 0 )
		{
			++pChar;
			++mNumChars;
		}

		if( mMaxChars < mNumChars )
			Except( Exception::ERR_INVALIDPARAMS, "指定的文字字符数量超过了最大字符数量。" );

		//复制字符串
		memcpy( mpText, szText, sizeof(wchar_t) * ( mNumChars + 1 ) );

		//重置字形数据缓存
		memset( mpGlyphDraw, 0, sizeof(FontFace::GlyphDraw) * mMaxChars );

		//更新文字数据
		_UpdateText();
	}