• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Tight NSBox around view
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Tight NSBox around view


  • Subject: Re: Tight NSBox around view
  • From: Daniel Jalkut <email@hidden>
  • Date: Sun, 10 Sep 2006 12:56:52 -0400

Hans - keep in mind that by default NSBox expects to draw a border and a title. It sounds like the white space you're seeing corresponds to these areas of "reserved real-estate."

In your subclass's init method, try:

[self setBorderType:NSNoBorder];
[self setTitlePosition:NSNoTitle];

Daniel

On Sep 10, 2006, at 10:57 AM, Hans van der Meer wrote:

I would like to draw an NSBox tight around its contained subview; the subview being a NSView descendant.

In order to draw a rectangle with given color and linewidth around the content of the box I subclassed NSBox and did an override of drawRect:
- (void) drawRect:(NSRect)frame {
float framesize = 1.0f;
NSFrameRectWithWidth(frame, framesize);
// Note: no call to super.
}


In awakeFromNib I do for the NSBox variable surround:
	[surround sizeToFit];

Both surround and its contents are custom views installed through IBuilder.

When I do this, the frame in the box does not fit tight around its contents. There is a considerable margin between the frame and the view contained. At the top the margin is larger than at the bottom and the sides. Changing the frame width and height of the surrounding box had not the effect sought. It therefore looks to me if there is some mechanism determining the margins between box and contents. Because I was unable to find the solution, I am asking if someone can point me in the right direction.

Thanks in advance.

Hans van der Meer



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
sweater.com


This email sent to email@hidden

_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Tight NSBox around view (From: Hans van der Meer <email@hidden>)

  • Prev by Date: Re: about the objecttableinfo
  • Next by Date: Releasing window controllers - at wits end
  • Previous by thread: Re: Tight NSBox around view
  • Next by thread: about the objecttableinfo
  • Index(es):
    • Date
    • Thread