mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-01 19:01:54 +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
2f732e6801
commit
6fb717124e
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>
|
2000-06-06 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
* Source/NSTextAttachment.m
|
* Source/NSTextAttachment.m
|
||||||
|
|
|
@ -88,6 +88,9 @@ typedef enum _NSTitlePosition {
|
||||||
- (void)setFrameFromContentFrame:(NSRect)contentFrame;
|
- (void)setFrameFromContentFrame:(NSRect)contentFrame;
|
||||||
- (void)sizeToFit;
|
- (void)sizeToFit;
|
||||||
|
|
||||||
|
#ifndef NO_GNUSTEP
|
||||||
|
-(NSSize) minimumSize;
|
||||||
|
#endif
|
||||||
@end
|
@end
|
||||||
|
|
||||||
#endif // _GNUstep_H_NSBox
|
#endif // _GNUstep_H_NSBox
|
||||||
|
|
|
@ -237,6 +237,40 @@
|
||||||
[_content_view setFrame: [self calcSizesAllowingNegative: NO]];
|
[_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
|
- (void) sizeToFit
|
||||||
{
|
{
|
||||||
NSRect f;
|
NSRect f;
|
||||||
|
@ -255,15 +289,7 @@
|
||||||
// Loop through subviews and calculate rect to encompass all
|
// Loop through subviews and calculate rect to encompass all
|
||||||
while ((o = [e nextObject]))
|
while ((o = [e nextObject]))
|
||||||
{
|
{
|
||||||
f = [o frame];
|
r = NSUnionRect(r, [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;
|
|
||||||
}
|
}
|
||||||
[_content_view setBoundsOrigin: r.origin];
|
[_content_view setBoundsOrigin: r.origin];
|
||||||
r.size = [self convertSize: r.size fromView: _content_view];
|
r.size = [self convertSize: r.size fromView: _content_view];
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue