- int ellipsisWidth;
- dc.GetTextExtent( wxT("..."), &ellipsisWidth, NULL);
- do {
- label.Truncate( label.length() - 1 );
- dc.GetTextExtent( label, &tw, &th);
- } while (tw + ellipsisWidth > targetWidth && label.length() );
- label.append( wxT("...") );
- tw += ellipsisWidth;
+ label = wxControl::Ellipsize(label,
+ dc,
+ wxELLIPSIZE_END,
+ availWidth,
+ wxELLIPSIZE_FLAGS_NONE);
+ tw = dc.GetTextExtent(label).x;