Interface Builder "layout" versus "frame"

  • I've noticed that Interface Builder shows not only a "frame" value
    for object sizes, but also a "layout" value.

    I am trying to create a few controls programatically and it seems
    like I'd get results a lot closer to what I'm expecting if I could
    create them with a "layout" rectangle instead of a "frame" rectangle.
    For instance, if I make an NSTabView, it's significantly inset
    compared to the NSRect I've set. But if I go into IB and create a tab
    control and set up its "layout" rectangle to match what I want, the
    positioning is perfect.

    So programatically, how do I work with "layout" rectangles instead of
    "frames"?

    I know that technically I could just hard-code the margin sizes of
    controls but I am hoping to avoid this… it doesn't seem future-proof.
  • On Nov 8, 2007, at 13:26, John Stiles wrote:

    > I've noticed that Interface Builder shows not only a "frame" value
    > for object sizes, but also a "layout" value.
    >
    > I am trying to create a few controls programatically and it seems
    > like I'd get results a lot closer to what I'm expecting if I could
    > create them with a "layout" rectangle instead of a "frame"
    > rectangle. For instance, if I make an NSTabView, it's significantly
    > inset compared to the NSRect I've set. But if I go into IB and
    > create a tab control and set up its "layout" rectangle to match what
    > I want, the positioning is perfect.
    >
    > So programatically, how do I work with "layout" rectangles instead
    > of "frames"?

    http://developer.apple.com/documentation/DeveloperTools/Reference/NSViewIBA
    dditions_Reference/Reference/Reference.html

      perhaps?

    > I know that technically I could just hard-code the margin sizes of
    > controls but I am hoping to avoid this… it doesn't seem future-proof.

    This was the only route prior to 10.5, sadly.

    Joe Ranieri
    Lead Magician, Alacatia Labs, Inc.
    http://alacatia.com
  • That's a shame; I don't want to require 10.5 just yet.
    So basically I should just look at what IB uses for layout values and
    hard-code? Or maybe would it be possible to leverage HITheme or some
    other Carbon API?

    On Nov 8, 2007, at 10:34 AM, Joe Ranieri wrote:

    >
    > On Nov 8, 2007, at 13:26, John Stiles wrote:
    >
    >> I've noticed that Interface Builder shows not only a "frame" value
    >> for object sizes, but also a "layout" value.
    >>
    >> I am trying to create a few controls programatically and it seems
    >> like I'd get results a lot closer to what I'm expecting if I could
    >> create them with a "layout" rectangle instead of a "frame"
    >> rectangle. For instance, if I make an NSTabView, it's
    >> significantly inset compared to the NSRect I've set. But if I go
    >> into IB and create a tab control and set up its "layout" rectangle
    >> to match what I want, the positioning is perfect.
    >>
    >> So programatically, how do I work with "layout" rectangles instead
    >> of "frames"?
    >
    > http://developer.apple.com/documentation/DeveloperTools/Reference/
    > NSViewIBAdditions_Reference/Reference/Reference.html perhaps?
    >
    >
    >> I know that technically I could just hard-code the margin sizes of
    >> controls but I am hoping to avoid this… it doesn't seem future-proof.
    >
    >
    > This was the only route prior to 10.5, sadly.
    >
    > Joe Ranieri
    > Lead Magician, Alacatia Labs, Inc.
    > http://alacatia.com
  • On Nov 8, 2007, at 13:44, John Stiles wrote:

    > That's a shame; I don't want to require 10.5 just yet.
    > So basically I should just look at what IB uses for layout values
    > and hard-code? Or maybe would it be possible to leverage HITheme or
    > some other Carbon API?

    To the best of my knowledge there is simply *no* API to do this prior
    to 10.5. There was a thing on the mailing list quite a while back, but
    I couldn't dig it up.

    Joe Ranieri
    Lead Magician, Alacatia Labs, Inc.
    http://alacatia.com
  • I checked out some Carbon APIs but it looks like Carbon tab views
    don't have the same beefy margins as NSTabViews, so even if I could
    find an appropriate constant, the values would not match up.

    Bummer. I guess it's hard-coding for me :(

    On Nov 8, 2007, at 10:44 AM, John Stiles wrote:

    > That's a shame; I don't want to require 10.5 just yet.
    > So basically I should just look at what IB uses for layout values
    > and hard-code? Or maybe would it be possible to leverage HITheme or
    > some other Carbon API?
    >
    >
    > On Nov 8, 2007, at 10:34 AM, Joe Ranieri wrote:
    >
    >>
    >> On Nov 8, 2007, at 13:26, John Stiles wrote:
    >>
    >>> I've noticed that Interface Builder shows not only a "frame"
    >>> value for object sizes, but also a "layout" value.
    >>>
    >>> I am trying to create a few controls programatically and it seems
    >>> like I'd get results a lot closer to what I'm expecting if I
    >>> could create them with a "layout" rectangle instead of a "frame"
    >>> rectangle. For instance, if I make an NSTabView, it's
    >>> significantly inset compared to the NSRect I've set. But if I go
    >>> into IB and create a tab control and set up its "layout"
    >>> rectangle to match what I want, the positioning is perfect.
    >>>
    >>> So programatically, how do I work with "layout" rectangles
    >>> instead of "frames"?
    >>
    >> http://developer.apple.com/documentation/DeveloperTools/Reference/
    >> NSViewIBAdditions_Reference/Reference/Reference.html perhaps?
    >>
    >>
    >>> I know that technically I could just hard-code the margin sizes
    >>> of controls but I am hoping to avoid this… it doesn't seem future-
    >>> proof.
    >>
    >>
    >> This was the only route prior to 10.5, sadly.
    >>
    >> Joe Ranieri
    >> Lead Magician, Alacatia Labs, Inc.
    >> http://alacatia.com

  • On Nov 8, 2007, at 13:44, John Stiles wrote:

    > That's a shame; I don't want to require 10.5 just yet.
    > So basically I should just look at what IB uses for layout values
    > and hard-code? Or maybe would it be possible to leverage HITheme or
    > some other Carbon API?

    Spoke too soon - found the old mailing list topic <http://www.cocoabuilder.com/archive/message/cocoa/2002/9/5/8673>.

    Joe Ranieri
    Lead Magician, Alacatia Labs, Inc.
    http://alacatia.com
  • On Nov 8, 2007, at 1:34 PM, Joe Ranieri wrote:

    >> So programatically, how do I work with "layout" rectangles instead
    >> of "frames"?
    >
    > http://developer.apple.com/documentation/DeveloperTools/Reference/
    > NSViewIBAdditions_Reference/Reference/Reference.html perhaps?

    It says:

    Because these methods are relevant only in the context of Interface
    Builder, it is recommended that you implement these methods in a
    category on your class and include the category code only in your
    Interface Builder plug-in.

    Jim
  • On Nov 8, 2007, at 11:29 AM, Jim Correia wrote:

    > On Nov 8, 2007, at 1:34 PM, Joe Ranieri wrote:
    >
    >>> So programatically, how do I work with "layout" rectangles
    >>> instead of "frames"?
    >>
    >> http://developer.apple.com/documentation/DeveloperTools/Reference/
    >> NSViewIBAdditions_Reference/Reference/Reference.html perhaps?
    >
    > It says:
    >
    > Because these methods are relevant only in the context of Interface
    > Builder, it is recommended that you implement these methods in a
    > category on your class and include the category code only in your
    > Interface Builder plug-in.

    Bah!
    Since when is a layout rectangle only useful within the context of IB?
  • Hi John,

    Sorry; this is a long standing request, but this information isn't
    available.  IB isn't retrieving the info from the frameworks, it has
    its own internal rules.

    -Ken
    Cocoa Frameworks

    On Nov 8, 2007 10:26 AM, John Stiles <JStiles...> wrote:
    > I've noticed that Interface Builder shows not only a "frame" value
    > for object sizes, but also a "layout" value.
    >
    > I am trying to create a few controls programatically and it seems
    > like I'd get results a lot closer to what I'm expecting if I could
    > create them with a "layout" rectangle instead of a "frame" rectangle.
    > For instance, if I make an NSTabView, it's significantly inset
    > compared to the NSRect I've set. But if I go into IB and create a tab
    > control and set up its "layout" rectangle to match what I want, the
    > positioning is perfect.
    >
    > So programatically, how do I work with "layout" rectangles instead of
    > "frames"?
    >
    > I know that technically I could just hard-code the margin sizes of
    > controls but I am hoping to avoid this… it doesn't seem future-proof.
    >
  • So far I've been going into IB, making a control, measuring each
    margin by hand, and hard-coding it. Then I've added a category to
    each view I care about which can return the margin info. That way
    it's pretty easy to account for it when calculating sizes and positions.

    It's been a little slow going, but it does work.

    I hate doing stuff which I know to be fragile, but I guess if they
    changed it, then everyone's nibs would be broken too. So I can't
    imagine this breaking without tons of existing layouts also being
    broken.

    On Nov 8, 2007, at 1:41 PM, Ken Ferry wrote:

    > Hi John,
    >
    > Sorry; this is a long standing request, but this information isn't
    > available.  IB isn't retrieving the info from the frameworks, it has
    > its own internal rules.
    >
    > -Ken
    > Cocoa Frameworks
    >
    > On Nov 8, 2007 10:26 AM, John Stiles <JStiles...> wrote:
    >> I've noticed that Interface Builder shows not only a "frame" value
    >> for object sizes, but also a "layout" value.
    >>
    >> I am trying to create a few controls programatically and it seems
    >> like I'd get results a lot closer to what I'm expecting if I could
    >> create them with a "layout" rectangle instead of a "frame" rectangle.
    >> For instance, if I make an NSTabView, it's significantly inset
    >> compared to the NSRect I've set. But if I go into IB and create a tab
    >> control and set up its "layout" rectangle to match what I want, the
    >> positioning is perfect.
    >>
    >> So programatically, how do I work with "layout" rectangles instead of
    >> "frames"?
    >>
    >> I know that technically I could just hard-code the margin sizes of
    >> controls but I am hoping to avoid this… it doesn't seem future-proof.
    >>
previous month november 2007 next month
MTWTFSS
      1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30    
Go to today