/***************************************************** ** ** SheetWidget --- doPaint ** ******************************************************/ void SheetWidget::doPaint( const wxRect &rect, const bool eraseBackground ) { #ifdef SCROLLABLE_PAGE_WIDGET_SHOW_STOP_WATCH const wxLongLong starttime = wxGetLocalTimeMillis(); #endif // may have changed writer->setSheetConfig( getSheetConfig() ); assert( painter ); painter->writercfg = sheet->writercfg; painter->colorcfg = colorcfg; //printf( "RECT x %d y %d w %d h %d\n", rect.x, rect.y, rect.width, rect.height ); MRect therect( rect ); //printf( "SheetWidget::doPaint xviewport %d yviewport %d erase = %d DIRTY %d\n", xviewport, yviewport, eraseBackground, dirty ); // dirty ist okay. kommt bei echten Updates und Resize. nicht bei Scroll, mouse over usw. if ( dirty ) { init(); calculateContentSize(); initViewPort(); dirty = false; } painter->setBrush( config->colors->bgColor ); painter->setTransparentPen(); painter->drawRectangle( rect ); painter->setTransparentPen(); writer->drawSheet( painter, therect, eraseBackground ); #ifdef SCROLLABLE_PAGE_WIDGET_SHOW_STOP_WATCH const wxLongLong totaltime = wxGetLocalTimeMillis() - starttime; wxLogMessage( wxString::Format( wxT( "SheetWidget::doPaint in %ld millisec eraseBackground %d" ), totaltime.ToLong(), eraseBackground )); #endif }
/***************************************************** ** ** Painter --- drawMString ** ******************************************************/ void Painter::drawMString( const MRect &r, MString &f, const int& align ) { #ifdef SHOW_STOP_WATCH static wxLongLong totaltime = 0; const wxLongLong starttime = wxGetLocalTimeMillis(); #endif static int count = 0; SheetFormatter sfmt; wxString s; if ( f.formattedLines.size() == 0 ) { if ( ! f.isEmpty() && f.size.real() == 0 ) { s = sfmt.fragment2PlainText( f ); //printf( "Painter::drawMString - old size %f %f\n", f.size.real(), f.size.imag()); f.size = getTextExtent( f ); printf( "Painter::drawMString - size not set #%d contents was %s, size now %f %f\n", count++, str2char( s ), f.size.real(), f.size.imag()); } drawSingleMStringLine( r, f, align ); //return; } else { double y0 = r.y; if ( align & Align::Top ) { // nothing } else if ( align & Align::Bottom ) { y0 = y0 + r.height - f.size.imag(); } else // default: align & align::VCenter { y0 += .5 * ( r.height - f.size.imag()); } MRect rect( r.x, y0, r.width, r.height ); int line = 0; for( list<MString>::iterator iter = f.formattedLines.begin(); iter != f.formattedLines.end(); iter++ ) { line++; rect.height = iter->size.imag(); //printf( " --->>> Line %d width %f h %f\n", line, iter->size.real(), iter->size.imag() ); drawSingleMStringLine( rect, *iter, align ); rect.y += rect.height; } } #ifdef SHOW_STOP_WATCH const wxLongLong duration = wxGetLocalTimeMillis() - starttime; totaltime += duration; wxLogMessage( wxString::Format( wxT( "Painter::drawTextFormatted in %ld msec, total %ld" ), duration.ToLong(), totaltime.ToLong() )); #endif }