rendered paste bodybool PangoFontLayout::LayoutText( ImplLayoutArgs& rArgs )
{
//DFB_TODO
int j = 0;
ByteString aFontName( "NULL" );
m_nMinCharPos = rArgs.mnMinCharPos;
m_nEndCharPos = rArgs.mnEndCharPos;
m_nLen = rArgs.mnEndCharPos - rArgs.mnMinCharPos;
ByteString aInString( &rArgs.mpStr[rArgs.mnMinCharPos], m_nLen);
aInString.Convert( RTL_TEXTENCODING_UNICODE, RTL_TEXTENCODING_UTF8 );
[.......]
m_nWidth = pango_font_metrics_get_approximate_char_width( pfm ) * m_nLen / PANGO_SCALE;
m_nchwidth = pango_font_metrics_get_approximate_char_width( pfm ) / PANGO_SCALE;
pango_layout_set_text( layout, aInString.GetBuffer(), m_nLen );
return true;
}
void PangoFontLayout::AdjustLayout( ImplLayoutArgs& rArgs )
{
LayoutText( rArgs );
}
int PangoFontLayout::GetTextBreak( long nMaxWidth, long nCharExtra, int nFactor ) const
{
long nWidth = 0;
int i;
for( i = m_nMinCharPos + 1 ; i < m_nEndCharPos; ++i )
{
nWidth = ( i - m_nMinCharPos ) * m_nchwidth * nFactor;
if( nWidth >= nMaxWidth )
{
return i;
}
}
return i;
}
long PangoFontLayout::FillDXArray( sal_Int32* pDXArray ) const
{
if(pDXArray)
{
for(int i=0;i<m_nLen;++i)
pDXArray[i]=(m_nWidth*i)/m_nLen;
}
return m_nWidth;
}
void PangoFontLayout::DrawText( SalGraphics& rSalGraphics ) const
{
fprintf( stderr, "%x DrawText mnMinCharPos %d mnEndCharPos %d X %d+%d Y %d+%d, \n",
this, m_nMinCharPos, m_nEndCharPos,
maDrawBase.X(), maDrawOffset .X(), maDrawBase.Y(), maDrawOffset .Y() );
int i, j;
i = m_nEndCharPos - m_nMinCharPos;
if ( i != 0)
j = m_nMinCharPos / i;
else
j = 1;
GdkGC* gc;
GdkColor black = { 0, 65535, 65535, 65535, };
GdkColor white = { 0, 0, 0, 0, };
GtkSalGraphics *g = (GtkSalGraphics *)(&rSalGraphics);
GdkDrawable* gd = g->GetDrawable();
gc = gdk_gc_new ( gd );
gdk_gc_set_foreground (gc, &black);
gdk_gc_set_background (gc, &white);
gdk_draw_layout ( gd, gc, GetDrawPosition().X () , GetDrawPosition().Y () - 10 + (j * 20), layout);
// gdk_draw_layout ( gd, gc, maDrawBase.X () , maDrawBase.Y () - 10, layout);
// gdk_draw_layout ( gd, gc, maDrawOffset.X () , maDrawOffset .Y () - 10, layout);
}