How to Make a Very Thin Window?

  • Folks;

    I've spend some time trying to make a very narrow window and have run
    into a number of obstacles.
    Perhaps someone here can shake up my misconceptions or point out a
    useful sample...

    I want to make a window which can resize down to a narrow strip
    window (say 25 pixels wide).

    The first issue is that I cannot do this and have a normal title bar.
    An IB created window appears to have a minimum width of 74 pixels.
    (This allows the 3 normal controls to appear and not be hidden by a
    resize event)
    Am I confused on this point?  Is there a way to do this in IB?
    (Tiger not Leopard BTW).

    So I subclass NSWindow and do the
    - (id)initWithContentRect:(NSRect)contentRect  styleMask:(unsigned
    int)styleMask backing:(NSBackingStoreType)backingType defer:(BOOL)flag {
    setting styleMask = NSBorderlessWindowMask

    If I load the new class into IB designate the window's custom class
    and then set the window controller's -window to this instance, I
    still get the limitation on width.
    NOTE: A resize widget will not show up even if -
    setShowsResizeIndicator:YES.
    So I has to implement my own resizing and even then the resize WILL
    NOT resize less than the same amount as when using standard IB window.
    So I conclude that the instantiation process thru IB prevents what I
    want.
    Am I confused on this point?  Is there a way to accomplish resizing
    custom window classes in IB?

    So now I feel I must implement the window controller and the window
    completely programmatically without any use of IB.
    But then how do utilize the views which have all of the UI widgets
    that I need on this window?

    So much work and time for something that seems so not complicated:  a
    window with a 'MINI' title bar...

    Having the 3 controls at top left is desirable - users are familiar
    with windows that have them and users expect windows to have them.
    I want their functionality to work (Close, Minimze,...) I just want a
    skinny version.

    Anyone have any useful counsel?
    Steve
  • Hi

    try either a utility panel in IB
    or use ib to create the normal window and then set the minSize and
    size of the window in code at runtime?!

    Regards,
    Dominik

    Am Dec 4, 2007 um 9:56 PM schrieb Steve Cronin:

    > Folks;
    >
    > I've spend some time trying to make a very narrow window and have
    > run into a number of obstacles.
    > Perhaps someone here can shake up my misconceptions or point out a
    > useful sample...
    >
    > I want to make a window which can resize down to a narrow strip
    > window (say 25 pixels wide).
    >
    > The first issue is that I cannot do this and have a normal title bar.
    > An IB created window appears to have a minimum width of 74 pixels.
    > (This allows the 3 normal controls to appear and not be hidden by a
    > resize event)
    > Am I confused on this point?  Is there a way to do this in IB?
    > (Tiger not Leopard BTW).
    >
    > So I subclass NSWindow and do the
    > - (id)initWithContentRect:(NSRect)contentRect  styleMask:(unsigned
    > int)styleMask backing:(NSBackingStoreType)backingType defer:
    > (BOOL)flag {
    > setting styleMask = NSBorderlessWindowMask
    >
    > If I load the new class into IB designate the window's custom class
    > and then set the window controller's -window to this instance, I
    > still get the limitation on width.
    > NOTE: A resize widget will not show up even if -
    > setShowsResizeIndicator:YES.
    > So I has to implement my own resizing and even then the resize WILL
    > NOT resize less than the same amount as when using standard IB window.
    > So I conclude that the instantiation process thru IB prevents what I
    > want.
    > Am I confused on this point?  Is there a way to accomplish resizing
    > custom window classes in IB?
    >
    > So now I feel I must implement the window controller and the window
    > completely programmatically without any use of IB.
    > But then how do utilize the views which have all of the UI widgets
    > that I need on this window?
    >
    > So much work and time for something that seems so not complicated:
    > a window with a 'MINI' title bar...
    >
    > Having the 3 controls at top left is desirable - users are familiar
    > with windows that have them and users expect windows to have them.
    > I want their functionality to work (Close, Minimze,...) I just want
    > a skinny version.
    >
    > Anyone have any useful counsel?
    > Steve
  • Dominik;

    I have already tried both.

    It appears to me that the manual setting of -setMinSize is overrided
    by the IB instantiation

    Panels have all the same behavior as NSWindows.

    Thanks for trying,
    Steve

    On Dec 4, 2007, at 3:18 PM, Dominik Pich wrote:

    > Hi
    >
    > try either a utility panel in IB
    > or use ib to create the normal window and then set the minSize and
    > size of the window in code at runtime?!
    >
    > Regards,
    > Dominik
    >
    > Am Dec 4, 2007 um 9:56 PM schrieb Steve Cronin:
    >
    >> Folks;
    >>
    >> I've spend some time trying to make a very narrow window and have
    >> run into a number of obstacles.
    >> Perhaps someone here can shake up my misconceptions or point out a
    >> useful sample...
    >>
    >> I want to make a window which can resize down to a narrow strip
    >> window (say 25 pixels wide).
    >>
    >> The first issue is that I cannot do this and have a normal title bar.
    >> An IB created window appears to have a minimum width of 74 pixels.
    >> (This allows the 3 normal controls to appear and not be hidden by
    >> a resize event)
    >> Am I confused on this point?  Is there a way to do this in IB?
    >> (Tiger not Leopard BTW).
    >>
    >> So I subclass NSWindow and do the
    >> - (id)initWithContentRect:(NSRect)contentRect  styleMask:(unsigned
    >> int)styleMask backing:(NSBackingStoreType)backingType defer:(BOOL)
    >> flag {
    >> setting styleMask = NSBorderlessWindowMask
    >>
    >> If I load the new class into IB designate the window's custom
    >> class and then set the window controller's -window to this
    >> instance, I still get the limitation on width.
    >> NOTE: A resize widget will not show up even if -
    >> setShowsResizeIndicator:YES.
    >> So I has to implement my own resizing and even then the resize
    >> WILL NOT resize less than the same amount as when using standard
    >> IB window.
    >> So I conclude that the instantiation process thru IB prevents what
    >> I want.
    >> Am I confused on this point?  Is there a way to accomplish
    >> resizing custom window classes in IB?
    >>
    >> So now I feel I must implement the window controller and the
    >> window completely programmatically without any use of IB.
    >> But then how do utilize the views which have all of the UI widgets
    >> that I need on this window?
    >>
    >> So much work and time for something that seems so not
    >> complicated:  a window with a 'MINI' title bar...
    >>
    >> Having the 3 controls at top left is desirable - users are
    >> familiar with windows that have them and users expect windows to
    >> have them.
    >> I want their functionality to work (Close, Minimze,...) I just
    >> want a skinny version.
    >>
    >> Anyone have any useful counsel?
    >> Steve
    >
  • On Tuesday, December 04, 2007, at 04:27PM, "Steve Cronin" <steve_cronin...> wrote:
    >> I want to make a window which can resize down to a narrow strip
    >> window (say 25 pixels wide).
    >
    > It appears to me that the manual setting of -setMinSize is overrided
    > by the IB instantiation

    Perhaps you could explain why you need such a small window.  Maybe there is something else that would work better for this case.  Maybe a drawer?
  • Well another idea.

    try using your own class of NSWindow and do a setMinWidth and setSize
    in its awakeFromNib... that way you can be quite sure it is not
    overriden - atleast not by IB :)

    Regards,
    Dominik
  • Christopher;

    It is a palette of functionality that can logically be resized up and
    down.

    Some users may prefer a fatter view of the palette - others may
    prefer a thinner
    (especially on a laptop where screen real estate is most precious)

    The palette floats alone so a drawer would not appear viable.

    In addition, even if there was a 'parent window' the core issue remains:
    How would you thin down the parent to attach a thin drawer....

    Steve

    On Dec 4, 2007, at 3:35 PM, Christopher Hickman wrote:

    > On Tuesday, December 04, 2007, at 04:27PM, "Steve Cronin"
    > <steve_cronin...> wrote:
    >>> I want to make a window which can resize down to a narrow strip
    >>> window (say 25 pixels wide).
    >>
    >> It appears to me that the manual setting of -setMinSize is overrided
    >> by the IB instantiation
    >
    > Perhaps you could explain why you need such a small window.  Maybe
    > there is something else that would work better for this case.
    > Maybe a drawer?
  • Dominik;

    That's what I tried to explain.

    I do sublclass the window and do set the minSize

    So long as I use IB to instantiate the window the values of minSize
    appear to be overwritten.

    If I then try and not use IB at all I'm back to being confused by how
    I would then utilize all of the palette's UI widgets which ARE in IB!!

    So if I try and summarize:  Right now, it seems to me, that in order
    to do this I must implement the entire window/controller in code with
    no IB participation.  YIKES!

    Steve

    On Dec 4, 2007, at 3:44 PM, Dominik Pich wrote:

    > Well another idea.
    >
    > try using your own class of NSWindow and do a setMinWidth and
    > setSize in its awakeFromNib... that way you can be quite sure it is
    > not overriden - atleast not by IB :)
    >
    > Regards,
    > Dominik
  • On Dec 4, 2007, at 4:51 PM, Steve Cronin wrote:

    > Dominik;
    >
    > That's what I tried to explain.
    >
    > I do sublclass the window and do set the minSize
    >
    > So long as I use IB to instantiate the window the values of minSize
    > appear to be overwritten.
    >
    > If I then try and not use IB at all I'm back to being confused by
    > how I would then utilize all of the palette's UI widgets which ARE
    > in IB!!
    >
    > So if I try and summarize:  Right now, it seems to me, that in
    > order to do this I must implement the entire window/controller in
    > code with no IB participation.  YIKES!

    Swap the content view of a window created in IB into your code-
    instantiated small panel. Then for anything that refers to the IB-
    window, make them point to your code-instantiated window.
  • Christoper;

    A panel won't work because I specifically want the palette to remain
    on-screen in an application switch.

    The link you included seems to be for Leopard, iB3, not Tiger.
    Leopard is cool and I'm looking forward to it, but for now I just
    can't ignore all those potential Tiger customers ...

    Steve

    On Dec 4, 2007, at 3:59 PM, Christopher Hickman wrote:

    > On Tuesday, December 04, 2007, at 04:46PM, "Steve Cronin"
    > <steve_cronin...> wrote:
    >> Christopher;
    >>
    >> It is a palette of functionality that can logically be resized up and
    >> down.
    >>
    >> The palette floats alone so a drawer would not appear viable.
    >
    > So why not use a utility window with just a close button.
    >
    > Like the first example here: http://developer.apple.com/
    > documentation/UserExperience/Conceptual/OSXHIGuidelines/XHIGWindows/
    > chapter_17_section_5.html
  • Folks;

    For the record I thought I would submit what I did to get this to work.

    There was a menu item, in MainMenu, which would invoke both the
    windowController's -initWithNib and -showWindow.
    The nib referenced here was a second nib - NOT - 'MainMenu'.
    The windowController was set as this second nib's fileOwner and the
    windowController's -window was an outlet hooked up in IB in this 2nd
    nib.
    The window was fully created in IB in the 2nd nib.

    The way I solved the problem was to first create the window
    programmatically and then utilize the windowController's -
    initWithWindow method.
    I have to implement all the dragging and resizing code for the window
    because the NSBorderlessWindow mask does not create any UI widgets.
    (NOTE the NSWindow class' method -setShowResizeIndicator is
    apparently just ignored)

    In order to do this the window has to be created before the
    windowController's -initWithWindow.
    So neither the window itself, nor the windowController, are involved
    in the 2 nib mentioned above.

    Now that I am creating both window and windowController in the menu
    action in MainMenu I have to migrate all the UI widgets into a view
    in MainMenu.
    In fact, it appears, the 2nd Nib is no longer useful as such. So I
    must migrate all of its objects to MainMenu.  (Arrgh!)
    This new view is set as the contentView for the programatiically
    created window.

    If someone sees a flaw or a better way to do this - chime in!
    Hopefully this will be useful to someone else.
    Steve

    //create the window
    [self setMyWindow:[MyWindow alloc] initWithContentRect:someWindowRect
    styleMask:NSBorderlessWindowMask backing:NSBackingStoreBuffered
    defer:NO]];
    [[self myWindow] setFrame:someWindowRect display:YES];
    [[self myWindow] setLevel:NSNormalWindowLevel];
    [[self myWindow] setOpaque:YES];
    [[self myWindow] setHasShadow:YES];
    [[self myWindow] setMinSize:NSMakeSize(MIN_WIN_WIDTH,
    MIN_WIN_HEIGHT)];        //static floats
    [[self myWindow] setMinSize:NSMakeSize(MAX_WIN_WIDTH,
    MAX_WIN_HEIGHT)];;    //static floats
    [[self myWindow] setContentView:myWindowView];                   //(an NSView
    IBOutlet in appController)

    //create the windowController
    [self setMyWindowController:[[MyWindowController alloc]
    initWithWindow:[self myWindow]]];

    //hook them up
    [[self myWindow] setDelegate:[self myWindowController]];

    //rock-n-roll
    [[self myWindowController] showWindow:self];
  • On Dec 5, 2007 6:46 AM, Steve Cronin <steve_cronin...> wrote:
    > Folks;
    >
    > For the record I thought I would submit what I did to get this to work.
    >
    > There was a menu item, in MainMenu, which would invoke both the
    > windowController's -initWithNib and -showWindow.
    > The nib referenced here was a second nib - NOT - 'MainMenu'.
    > The windowController was set as this second nib's fileOwner and the
    > windowController's -window was an outlet hooked up in IB in this 2nd
    > nib.
    > The window was fully created in IB in the 2nd nib.
    >
    > The way I solved the problem was to first create the window
    > programmatically and then utilize the windowController's -
    > initWithWindow method.
    > I have to implement all the dragging and resizing code for the window
    > because the NSBorderlessWindow mask does not create any UI widgets.
    > (NOTE the NSWindow class' method -setShowResizeIndicator is
    > apparently just ignored)

    Border-less windows are special and the framework provides limited
    support for them.

    > In order to do this the window has to be created before the
    > windowController's -initWithWindow.
    > So neither the window itself, nor the windowController, are involved
    > in the 2 nib mentioned above.

    Since you are subclassing NSWindowController you could do just about
    anything you want (you don't even need to use a window controller
    depending on your needs). The order restrictions you are implying
    above are not set in stone in other words.

    > Now that I am creating both window and windowController in the menu
    > action in MainMenu I have to migrate all the UI widgets into a view
    > in MainMenu.
    > In fact, it appears, the 2nd Nib is no longer useful as such. So I
    > must migrate all of its objects to MainMenu.  (Arrgh!)
    > This new view is set as the contentView for the programatiically
    > created window.

    That second nib is still useful since you can choose to load it only
    when you need the view items it contains. In fact you can have the
    file owner wired up with those objects and simply move swap the
    content view into your custom window. You could even have that nibs
    owner do the construction of you border-less window when the nib is
    loaded.

    -Shawn
  • Shawn;

    Hey thanks for the comments!

    Couple of questions:
    What do you mean that the order is not important?
    How would I do a -initWithWindow if the window doesn't exist?
    Do you mean to create it with some placeholder window and then later
    do a -setWindow?

    What do you mean "...can have the file owner wired up with those
    objects..?
    Who is the fileOwner? What objects are you referring to?
    By "wired up" do you mean set as outlets or something different?

    What do you mean "...You could even have that nib owner do the
    construction of you border-less window when the nib is loaded.."
    When is the nib loaded?  by who?
    Something like??
    [[NSBundle mainBundle] loadNibNamed:@"MyNib" owner:myWindowController];
    What method would do the window creation?

    Best Regards,
    Steve

    On Dec 5, 2007, at 10:29 AM, Shawn Erickson wrote:

    > On Dec 5, 2007 6:46 AM, Steve Cronin <steve_cronin...> wrote:
    >> Folks;
    >>
    >> For the record I thought I would submit what I did to get this to
    >> work.
    >>
    >> There was a menu item, in MainMenu, which would invoke both the
    >> windowController's -initWithNib and -showWindow.
    >> The nib referenced here was a second nib - NOT - 'MainMenu'.
    >> The windowController was set as this second nib's fileOwner and the
    >> windowController's -window was an outlet hooked up in IB in this 2nd
    >> nib.
    >> The window was fully created in IB in the 2nd nib.
    >>
    >> The way I solved the problem was to first create the window
    >> programmatically and then utilize the windowController's -
    >> initWithWindow method.
    >> I have to implement all the dragging and resizing code for the window
    >> because the NSBorderlessWindow mask does not create any UI widgets.
    >> (NOTE the NSWindow class' method -setShowResizeIndicator is
    >> apparently just ignored)
    >
    > Border-less windows are special and the framework provides limited
    > support for them.
    >
    >> In order to do this the window has to be created before the
    >> windowController's -initWithWindow.
    >> So neither the window itself, nor the windowController, are involved
    >> in the 2 nib mentioned above.
    >
    > Since you are subclassing NSWindowController you could do just about
    > anything you want (you don't even need to use a window controller
    > depending on your needs). The order restrictions you are implying
    > above are not set in stone in other words.
    >
    >> Now that I am creating both window and windowController in the menu
    >> action in MainMenu I have to migrate all the UI widgets into a view
    >> in MainMenu.
    >> In fact, it appears, the 2nd Nib is no longer useful as such. So I
    >> must migrate all of its objects to MainMenu.  (Arrgh!)
    >> This new view is set as the contentView for the programatiically
    >> created window.
    >
    > That second nib is still useful since you can choose to load it only
    > when you need the view items it contains. In fact you can have the
    > file owner wired up with those objects and simply move swap the
    > content view into your custom window. You could even have that nibs
    > owner do the construction of you border-less window when the nib is
    > loaded.
    >
    > -Shawn
  • On Dec 4, 2007, at 6:13 PM, Steve Cronin wrote:

    > The link you included seems to be for Leopard, iB3, not Tiger.

    You can target Tiger (or even earlier operating systems) and still use
    Interface Builder 3 on Leopard. You don't need to be running Tiger or
    using Tiger developer tools to write software that runs on Tiger.

      -- Chris
previous month december 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
31            
Go to today