//----------------------------------------------------------------------------- // Purpose: Size the text window so all the text fits inside it. //----------------------------------------------------------------------------- void Tooltip::SizeTextWindow() { if ( !s_TooltipWindow.Get() ) return; if (_displayOnOneLine) { // We want the tool tip to be one line s_TooltipWindow->SetMultiline(false); s_TooltipWindow->SetToFullWidth(); } else { // We want the tool tip to be one line s_TooltipWindow->SetMultiline(false); s_TooltipWindow->SetToFullWidth(); int wide, tall; s_TooltipWindow->GetSize( wide, tall ); double newWide = sqrt( (2.0/1) * wide * tall ); double newTall = (1/2) * newWide; s_TooltipWindow->SetMultiline(true); s_TooltipWindow->SetSize((int)newWide, (int)newTall ); s_TooltipWindow->SetToFullHeight(); s_TooltipWindow->GetSize( wide, tall ); if (( wide < 100 ) && ( s_TooltipWindow->GetNumLines() == 2) ) { s_TooltipWindow->SetMultiline(false); s_TooltipWindow->SetToFullWidth(); } else { while ( (float)wide/(float)tall < 2 ) { s_TooltipWindow->SetSize( wide + 1, tall ); s_TooltipWindow->SetToFullHeight(); s_TooltipWindow->GetSize( wide, tall ); } } s_TooltipWindow->GetSize( wide, tall ); // ivgui()->DPrintf("End Ratio: %f\n", (float)wide/(float)tall); } }