discuss-gnustep
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSPopUpButton cellSize


From: Andreas Höschler
Subject: NSPopUpButton cellSize
Date: Tue, 25 Sep 2007 14:03:59 +0200

Hi all,

in NSPopUpButtonCell we have

- (NSSize) cellSize
{
  NSSize s;
  NSSize imageSize;
  NSSize titleSize;
  int i, count;
  NSString *title;

  count = [_menu numberOfItems];

  if (count == 0)
    return NSZeroSize;

  imageSize = [_pbc_image[_pbcFlags.pullsDown] size];
  s = NSMakeSize(0, imageSize.height);

  for (i = 0; i < count; i++)
    {
      title = [[_menu itemAtIndex: i] title];
      titleSize = [self _sizeText: title];

      if (titleSize.width > s.width)
        s.width = titleSize.width;
      if (titleSize.height > s.height)
        s.height = titleSize.height;
    }

  s.width += imageSize.width;
  s.width += 5; /* Left border to text (border included) */
  s.width += 3; /* Text to Image */
  s.width += 4; /* Right border to image (border included) */

  /* (vertical) border: */
  s.height += 2 * (_sizeForBorderType (NSBezelBorder).height);

  /* Spacing between border and inside: */
  s.height += 2 * 1;
  s.width  += 2 * 3;

  return s;
}

If the PoPUpButton has no items yet, this method returns NSZeroSize. That's definitely wrong! I do

  NSSize titleSize = NSMakeSize(10,28);
//  if (count == 0)  return NSZeroSize;

now which is of course a hack of its own but at least works for markup based interfaces. If anybody has a better idea ...

Regards,

   Andreas





reply via email to

[Prev in Thread] Current Thread [Next in Thread]