parameters: (dc, text, max_size)
return_statement: return ret
docstring: Chops the input `text` if its size does not fit in `max_size`, by cutting the
      text and adding ellipsis at the end.
  
      :param `dc`: a :class:`DC` device context;
      :param string `text`: the text to chop;
      :param integer `max_size`: the maximum size in which the text should fit.
docstring_summary: Chops the input `text` if its size does not fit in `max_size`, by cutting the
      text and adding ellipsis at the end.
docstring_tokens: Chops the input text if its size does not fit in max_size by cutting the text and adding ellipsis at the end .
function: def ChopText(dc, text, max_size):
      """
      Chops the input `text` if its size does not fit in `max_size`, by cutting the
      text and adding ellipsis at the end.
  
      :param `dc`: a :class:`DC` device context;
      :param string `text`: the text to chop;
      :param integer `max_size`: the maximum size in which the text should fit.
      """
      
      # first check if the text fits with no problems
      x, y, dummy = dc.GetMultiLineTextExtent(text)
      
      if x <= max_size:
          return text
  
      textLen = len(text)
      last_good_length = 0
      
      for i in xrange(textLen, -1, -1):
          s = text[0:i]
          s += "..."
  
          x, y = dc.GetTextExtent(s)
          last_good_length = i
          
          if x < max_size:
              break
  
      ret = text[0:last_good_length] + "..."    
      return ret
function_tokens: def ChopText ( dc , text , max_size ) : # first check if the text fits with no problems x , y , dummy = dc . GetMultiLineTextExtent ( text ) if x <= max_size : return text textLen = len ( text ) last_good_length = 0 for i in xrange ( textLen , - 1 , - 1 ) : s = text [ 0 : i ] s += "..." x , y = dc . GetTextExtent ( s ) last_good_length = i if x < max_size : break ret = text [ 0 : last_good_length ] + "..." return ret