mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 15:11:37 +00:00
Method to calc minimum size
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@10096 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
7c3852cea6
commit
f77edb1d03
3 changed files with 43 additions and 9 deletions
|
@ -1,3 +1,8 @@
|
|||
2001-06-06 Adam Fedor <fedor@gnu.org>
|
||||
|
||||
* Source/NSBox.m ([NSBox -minimumSize]): New method.
|
||||
* Headers/gnustep/gui/NSBox.h: Declare it.
|
||||
|
||||
2000-06-06 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/NSTextAttachment.m
|
||||
|
|
|
@ -88,6 +88,9 @@ typedef enum _NSTitlePosition {
|
|||
- (void)setFrameFromContentFrame:(NSRect)contentFrame;
|
||||
- (void)sizeToFit;
|
||||
|
||||
#ifndef NO_GNUSTEP
|
||||
-(NSSize) minimumSize;
|
||||
#endif
|
||||
@end
|
||||
|
||||
#endif // _GNUstep_H_NSBox
|
||||
|
|
|
@ -237,6 +237,40 @@
|
|||
[_content_view setFrame: [self calcSizesAllowingNegative: NO]];
|
||||
}
|
||||
|
||||
-(NSSize) minimumSize
|
||||
{
|
||||
NSRect r;
|
||||
NSSize borderSize = _sizeForBorderType (_border_type);
|
||||
|
||||
if ([_content_view respondsToSelector: @selector(minimumSize)])
|
||||
{
|
||||
r.size = [_content_view minimumSize];
|
||||
}
|
||||
else
|
||||
{
|
||||
NSArray *subviewArray = [_content_view subviews];
|
||||
if ([subviewArray count])
|
||||
{
|
||||
id o, e = [subviewArray objectEnumerator];
|
||||
r = [[e nextObject] frame];
|
||||
// Loop through subviews and calculate rect to encompass all
|
||||
while ((o = [e nextObject]))
|
||||
{
|
||||
r = NSUnionRect(r, [o frame]);
|
||||
}
|
||||
}
|
||||
else // _content_view has no subviews
|
||||
{
|
||||
r = NSZeroRect;
|
||||
}
|
||||
}
|
||||
|
||||
r.size = [self convertSize: r.size fromView: _content_view];
|
||||
r.size.width += (2 * _offsets.width) + (2 * borderSize.width);
|
||||
r.size.height += (2 * _offsets.height) + (2 * borderSize.height);
|
||||
return r.size;
|
||||
}
|
||||
|
||||
- (void) sizeToFit
|
||||
{
|
||||
NSRect f;
|
||||
|
@ -255,15 +289,7 @@
|
|||
// Loop through subviews and calculate rect to encompass all
|
||||
while ((o = [e nextObject]))
|
||||
{
|
||||
f = [o frame];
|
||||
if (f.origin.x < r.origin.x)
|
||||
r.origin.x = f.origin.x;
|
||||
if (f.origin.y < f.origin.y)
|
||||
r.origin.y = f.origin.y;
|
||||
if ((f.origin.x + f.size.width) > (r.origin.x + r.size.width))
|
||||
r.size.width = (f.origin.x + f.size.width) - r.origin.x;
|
||||
if ((f.origin.y + f.size.height) > (r.origin.y + r.size.height))
|
||||
r.size.height = (f.origin.y + f.size.height) - r.origin.y;
|
||||
r = NSUnionRect(r, [o frame]);
|
||||
}
|
||||
[_content_view setBoundsOrigin: r.origin];
|
||||
r.size = [self convertSize: r.size fromView: _content_view];
|
||||
|
|
Loading…
Reference in a new issue