/** * Precompute height for the link */ unsigned int LinkEvent::GetRenderedHeight(unsigned int width, const gd::Platform & platform) const { #if !defined(GD_NO_WX_GUI) if ( eventHeightNeedUpdate ) { wxMemoryDC dc; wxBitmap fakeBmp(1,1); dc.SelectObject(fakeBmp); dc.SetFont( wxFont( 12, wxDEFAULT, wxNORMAL, wxNORMAL ) ); wxRect lien = dc.GetTextExtent(_("Link to ")); renderedHeight = lien.GetHeight()+10; eventHeightNeedUpdate = false; } return renderedHeight; #else return 0; #endif }
unsigned int GroupEvent::GetRenderedHeight(unsigned int width, const gd::Platform & platform) const { #if !defined(GD_NO_WX_GUI) if ( eventHeightNeedUpdate ) { wxMemoryDC dc; wxBitmap fakeBmp(1,1); dc.SelectObject(fakeBmp); wxString groupTitle = name.empty() ? _("Untitled group") : wxString(name); dc.SetFont( wxFont( 12, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL ) ); wxRect text = dc.GetTextExtent(groupTitle); renderedHeight = text.GetHeight()+10; eventHeightNeedUpdate = false; } return renderedHeight; #else return 0; #endif }
/** * Precompute height for the link */ unsigned int LinkEvent::GetRenderedHeight(unsigned int width, const gd::Platform & platform) const { #if !defined(GD_NO_WX_GUI) if ( eventHeightNeedUpdate ) { gd::EventsRenderingHelper * renderingHelper = gd::EventsRenderingHelper::Get(); wxMemoryDC dc; wxBitmap fakeBmp(1,1); dc.SelectObject(fakeBmp); dc.SetFont(renderingHelper->GetNiceFont()); wxRect lien = dc.GetTextExtent(_("Link to ")); renderedHeight = lien.GetHeight()+15; eventHeightNeedUpdate = false; } return renderedHeight; #else return 0; #endif }
unsigned int CommentEvent::GetRenderedHeight(unsigned int width, const gd::Platform &) const { #if !defined(GD_NO_WX_GUI) if ( eventHeightNeedUpdate ) { gd::EventsRenderingHelper * renderingHelper = gd::EventsRenderingHelper::Get(); wxMemoryDC dc; wxBitmap fakeBmp(1,1); dc.SelectObject(fakeBmp); renderingHelper->GetHTMLRenderer().SetDC(&dc); renderingHelper->GetHTMLRenderer().SetStandardFonts(renderingHelper->GetNiceFont().GetPointSize()); gd::String str1 = "<FONT color="+wxColour(textR, textG, textB).GetAsString(wxC2S_HTML_SYNTAX)+">"+renderingHelper->GetHTMLText(com1)+"</FONT>"; gd::String str2 = "<FONT color="+wxColour(textR, textG, textB).GetAsString(wxC2S_HTML_SYNTAX)+">"+renderingHelper->GetHTMLText(com2)+"</FONT>"; //Calculate space constraints const int sideSeparation = 3; //Spacing between text and borders unsigned int textWidth = com2.empty() ? width-sideSeparation*2 : width/2-sideSeparation*2; renderingHelper->GetHTMLRenderer().SetSize(textWidth, 9999); renderingHelper->GetHTMLRenderer().SetHtmlText(str1); unsigned int text1Height = renderingHelper->GetHTMLRenderer().GetTotalHeight(); renderingHelper->GetHTMLRenderer().SetHtmlText(str2); unsigned int text2Height = renderingHelper->GetHTMLRenderer().GetTotalHeight(); unsigned int height = std::max(text1Height, text2Height)+sideSeparation*2; height = std::max(height, (unsigned int)15); renderedHeight = height; } #endif return renderedHeight+2;//2 : 2 small borders }