Пример #1
0
/*****************************************************
**
**   BasicWidget   ---   drawSimpleText
**
******************************************************/
void BasicWidget::drawSimpleText( const wxRect &r, const wxString &s )
{
	drawTextFormatted( r, s, Align::Center );
}
Пример #2
0
/*****************************************************
**
**   Painter   ---   drawSingleMStringLine
**
******************************************************/
void Painter::drawSingleMStringLine( const MRect &r, MString &f, const int& align )
{
	assert( f.formattedLines.size() == 0 );
	wxString s;
	MPoint p;
	Lang lang( writercfg );
	wxFont oldFont = getCurrentFont();
	const int drawalign = Align::Left + Align::VCenter;
	SheetFormatter formatter( writercfg );

	if ( ! f.isEmpty() && ( f.size.real() == 0 ||  f.size.imag() == 0 ))
	{
		printf( "WARN: size not set\n" );
		f.size = getTextExtent( f );
	}

	//printf( "PAINT -- --- - - - - x %f y %f w %f h %f SIZE x %f y %f\n", r.x, r.y, r.width, r.height, size.real(), size.imag() );
	//printf( " ----- %s\n", str2char( formatter.fragment2PlainText( f )));

	double x0 = r.x;
	double y0 = r.y;

	if ( align & Align::HCenter )
	{
		x0 += .5 * ( r.width - f.size.real());
	}
	else if ( align & Align::Right )
	{
		x0 = x0 + r.width - f.size.real();
	}

	// offset for subscriptum and superscriptum
	const double yoffset = .5 * f.size.imag();

	double yy = y0; // + .5 * ( r.height - size.imag());
	for( list<MToken>::const_iterator iter = f.tokens.begin(); iter != f.tokens.end(); iter++ )
	{
		switch ( iter->fontFormat )
		{
			case TTFF_SUBSCRPTUM:
				yy = y0 + yoffset;
			break;
			case TTFF_SUPERSCRPTUM:
				yy = y0 - yoffset;
			break;
			case TTFF_NORMAL:
			default:
				yy = y0;
			break;
		}

		setFont( oldFont );

		wxChar symbol = 0;
		SymbolProvider sp( writercfg );
		switch ( iter->entity )
		{
			case TTSE_PLANET:
				if ( writercfg->planetSymbols ) symbol = sp.getPlanetCode( (ObjectId)iter->entityId );
				if ( ! symbol || symbol == SYMBOL_CODE_ERROR )
					s = formatter.getObjectNamePlain( (ObjectId)iter->entityId, iter->textFormat, iter->vedic );
			break;
			case TTSE_SIGN:
				if ( writercfg->signSymbols ) symbol = sp.getSignCode( (Rasi)iter->entityId );
				if ( ! symbol ) s = lang.getSignName( (Rasi)iter->entityId, iter->textFormat ); //, writercfg->vedicSignNames );
			break;
			case TTSE_ASPECT:
				symbol = SymbolProvider().getAspectCode( (ASPECT_TYPE)iter->entityId );
				if ( ! symbol ) s = AspectExpert::getAspectShortDescription( (int)iter->entityId );
			break;
			case TTSE_DIRECTION:
				symbol = sp.getRetroCode( (MOVING_DIRECTION)iter->entityId );
				if ( ! symbol ) s = wxT( "R" );
			break;
			default:
				symbol = 0;
				s = iter->text;
			break;
		}
		if ( symbol && symbol != SYMBOL_CODE_ERROR )
		{
			const int pointSize = oldFont.GetPointSize();
			setFont( *FontProvider::get()->getFontBySize( FONT_GRAPHIC_SYMBOLS, pointSize ));
			drawTextFormatted( MRect( x0, yy, r.width, r.height ), symbol, drawalign );
			p = getTextExtent( symbol );
		}
		else
		{
			drawTextFormatted( MRect( x0, yy, r.width, r.height ), s, drawalign );
			p = getTextExtent( s );
		}

		x0 += p.real();
	}
}