From: <bru...@us...> - 2009-02-28 13:22:14
|
Revision: 3681 http://hugin.svn.sourceforge.net/hugin/?rev=3681&view=rev Author: brunopostle Date: 2009-02-28 12:40:28 +0000 (Sat, 28 Feb 2009) Log Message: ----------- Shorten filename when control-point indication bar overlaps in pull-down menu (Thomas Modes) Modified Paths: -------------- hugin/trunk/src/hugin1/hugin/CPImagesComboBox.cpp Modified: hugin/trunk/src/hugin1/hugin/CPImagesComboBox.cpp =================================================================== --- hugin/trunk/src/hugin1/hugin/CPImagesComboBox.cpp 2009-02-28 12:03:45 UTC (rev 3680) +++ hugin/trunk/src/hugin1/hugin/CPImagesComboBox.cpp 2009-02-28 12:40:28 UTC (rev 3681) @@ -115,7 +115,38 @@ { if ( item == wxNOT_FOUND ) return; - dc.DrawText(GetString(item),rect.x + 3,rect.y + ((rect.height - dc.GetCharHeight())/2)); + + wxCoord w, h; + GetTextExtent(GetString(item), &w, &h); + wxCoord maxWidth=0.73*rect.width-3; + // determine if the string can fit inside the current combo box + if (w <= maxWidth) + { + // it can, draw it + dc.DrawText(GetString(item),rect.x + 3,rect.y + ((rect.height - dc.GetCharHeight())/2)); + } + else // otherwise, truncate and add an ellipsis + { + // determine the base width + wxString ellipsis(wxT("...")); + wxCoord base_w; + GetTextExtent(ellipsis, &base_w, &h); + + // continue until we have enough space or only one character left + wxString drawntext = GetString(item); + while (drawntext.length() > 1) + { + drawntext.RemoveLast(); + GetTextExtent(drawntext,&w,&h); + if (w + base_w <= maxWidth) + break; + } + + // now draw the text + dc.DrawText(drawntext, rect.x + 3, rect.y + ((rect.height - dc.GetCharHeight())/2)); + dc.DrawText(ellipsis, rect.x + 3 + w, rect.y + ((rect.height - dc.GetCharHeight())/2)); + } + //draw rectangle when images are connected by control points if(CPConnection[item]>-1.0) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |