mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-25 01:01:10 +00:00
Implemented code to support autosizing of the popupbutton
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@6225 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
91baf8d04c
commit
4b558226f0
1 changed files with 44 additions and 0 deletions
|
@ -570,4 +570,48 @@ static NSImage *_pbc_image[2];
|
|||
|
||||
[view unlockFocus];
|
||||
}
|
||||
|
||||
- (NSSize) cellSize
|
||||
{
|
||||
NSSize s;
|
||||
NSSize imageSize;
|
||||
int i, count;
|
||||
NSString *title;
|
||||
float candidateWidth;
|
||||
|
||||
count = [_menu numberOfItems];
|
||||
|
||||
if (count == 0)
|
||||
return NSZeroSize;
|
||||
|
||||
imageSize = [_pbc_image[_pbcFlags.pullsDown] size];
|
||||
s = NSZeroSize;
|
||||
|
||||
s.height = [_cell_font boundingRectForFont].size.height;
|
||||
if (imageSize.height > s.height)
|
||||
s.height = imageSize.height;
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
title = [[_menu itemAtIndex: i] title];
|
||||
candidateWidth = [_cell_font widthOfString: title];
|
||||
|
||||
if (candidateWidth > s.width)
|
||||
s.width = candidateWidth;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
@end
|
||||
|
|
Loading…
Reference in a new issue