[haiku-bugs] Re: [Haiku] #3637: [preferences/FileTypes] menuField text is clipped(easy)

  • From: "stippi" <trac@xxxxxxxxxxxx>
  • Date: Fri, 11 Dec 2009 08:54:12 -0000

#3637: [preferences/FileTypes] menuField text is clipped(easy)
-----------------------------------+----------------------------------------
 Reporter:  chico                  |       Owner:  axeld         
     Type:  bug                    |      Status:  new           
 Priority:  normal                 |   Milestone:  R1            
Component:  Preferences/FileTypes  |     Version:  R1/Development
 Keywords:                         |   Blockedby:                
 Platform:  All                    |    Blocking:                
-----------------------------------+----------------------------------------

Comment(by stippi):

 If you couldn't find the TruncateString() method being used in drawing
 code, then that's most likely the issue. You have to know that BMenuFields
 internally use a BMenuBar, which is a subclass of BMenu. The rendering of
 the label is done using BMenuItem drawing code. Usually, a menu uses as
 much space as it needs on the screen, so that's probably why the string
 truncation is missing. In BMenuItem, there should be code similar to
 DrawString(Label(), ...);. This needs to change to:

 {{{
 BString truncatedLabel(Label());
 font.TruncateString(&truncatedLabel, ...);
 DrawString(truncatedLabel.String(), ...);
 }}}

 ... with the availabel width passed to font.TruncateString(). If there
 isn't already the font variable around, then you can get it via
 Menu()->GetFont(&font). But to do this in every BMenuItem (if it isn't
 already done) is a small performance problem.

-- 
Ticket URL: <http://dev.haiku-os.org/ticket/3637#comment:7>
Haiku <http://dev.haiku-os.org>
Haiku - the operating system.

Other related posts: