mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 15:11:37 +00:00
Improved combobox layout.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@21248 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
694ae7c56a
commit
b63d9513ca
2 changed files with 31 additions and 3 deletions
|
@ -1,3 +1,10 @@
|
|||
2005-05-22 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/NSComboBox.m (-cellSize) Added simple implementation of
|
||||
this method to get sizeToFit working.
|
||||
(GSComboWindow -layoutWithComboBoxCell:) Don't subtract the width
|
||||
of the scroller from the popup item size, increase the popup width instead.
|
||||
|
||||
2005-05-20 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/NSWindow.m (-center, -constrainFrameRect:toScreen:) Use
|
||||
|
|
|
@ -222,6 +222,7 @@ static GSComboWindow *gsWindow = nil;
|
|||
NSSize size;
|
||||
float itemHeight;
|
||||
float textCellWidth;
|
||||
float popUpWidth;
|
||||
NSSize intercellSpacing;
|
||||
int num = [comboBoxCell numberOfItems];
|
||||
int max = [comboBoxCell numberOfVisibleItems];
|
||||
|
@ -248,12 +249,13 @@ static GSComboWindow *gsWindow = nil;
|
|||
textCellWidth = [comboBoxCell _textCellFrame].size.width;
|
||||
if ([comboBoxCell hasVerticalScroller])
|
||||
{
|
||||
size.width = textCellWidth - [NSScroller scrollerWidth] - bsize.width;
|
||||
popUpWidth = textCellWidth + [NSScroller scrollerWidth];
|
||||
}
|
||||
else
|
||||
{
|
||||
size.width = textCellWidth - bsize.width;
|
||||
popUpWidth = textCellWidth;
|
||||
}
|
||||
size.width = textCellWidth - bsize.width;
|
||||
|
||||
if (size.width < 0)
|
||||
{
|
||||
|
@ -300,7 +302,7 @@ static GSComboWindow *gsWindow = nil;
|
|||
if (num > max)
|
||||
num = max;
|
||||
|
||||
[self setFrame: NSMakeRect(0, 0, textCellWidth,
|
||||
[self setFrame: NSMakeRect(0, 0, popUpWidth,
|
||||
2 * bsize.height + (itemHeight + intercellSpacing.height) * (num - 1)
|
||||
+ itemHeight) display: NO];
|
||||
}
|
||||
|
@ -1488,6 +1490,25 @@ static inline NSRect buttonCellFrameFromRect(NSRect cellRect)
|
|||
untilMouseUp: [[_cell class] prefersTrackingUntilMouseUp]] */
|
||||
}
|
||||
|
||||
- (NSSize) cellSize
|
||||
{
|
||||
NSSize textSize;
|
||||
NSSize buttonSize;
|
||||
NSSize mySize;
|
||||
|
||||
/* Simple version takes the size from text field. A more useful one could
|
||||
loop over the strings of the combo box and calculate the maximal width of
|
||||
all strings. */
|
||||
textSize = [super cellSize];
|
||||
// Or should we use the hard coded values from above here?
|
||||
buttonSize = [_buttonCell cellSize];
|
||||
|
||||
mySize.height = MAX(textSize.height, buttonSize.height);
|
||||
mySize.width = textSize.width + BorderSize + buttonSize.width;
|
||||
|
||||
return mySize;
|
||||
}
|
||||
|
||||
- (void) drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
|
||||
{
|
||||
NSRect rect = cellFrame;
|
||||
|
|
Loading…
Reference in a new issue