• 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: Programatically resizing a window
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Programatically resizing a window


  • Subject: Re: Programatically resizing a window
  • From: Henry McGilton <email@hidden>
  • Date: Wed, 15 Dec 2004 19:24:55 -0800


On Dec 15, 2004, at 11:41 AM, Michael Heinz wrote:


On Wednesday, December 15, 2004, at 01:09PM, j o a r <email@hidden> wrote:



What you could do is to store the "default window size" in
NSUserDefaults every time one of your document windows changes size,
and then make sure to size new windows accordingly before they are
brought on screen.


Joar,

I've actually asked questions about that several times on this list and I never got a reply- I'm already using "auto save name" feature of the nib, and it the user defaults load correctly when the first document is loaded at application start up. The problem is that all later windows just get the original settings from the nib. If that worked "as expected" I wouldn't be trying to do it by hand.

You say that "there doesn't seem to be any get/set size functionality
at all". I assume that you mean that you don't mean in NSWindow (as it
obviously has that functionality), but rather that you can't find it in
the convenience classes of a document based application?

That was the first problem - while I found the method for taking a NSWindow pointer and getting the matching document, there doesn't seem to be a way to go from an NSDocument to the corresponding NSWindow. Fortunately, I was able to extract that information from a custom view that's already in the application.

I have had the same conceptual trouble with this last point: how to get from a document to its associated window. The problem with this statement of requirements is that a given document may have multiple associated windows, in which case you are back where you started. That is to say, in the multiple windows per document case, you can not talk about 'the' window associated with the document, but you must decide on 'a' window associated with the document.

However, one can make several simplifying assumptions.  Assuming
that there is one and only one associated window in your document
nib, there then will be one and only one window controller
associated with that window.

After your document has initialised, your document object will
receive a  windowNibName  message.  In the single-window case, you
simply invoke  [super windowNibName], and return the name of your
document.  Following that sequence, your document will receive a
windowControllerDidLoadNib  message.  At that point, you can ask
the window controller (passed as an argument to the message)
for its window.

Two other paths are available to get to the window.  One is
to get the list of window controllers in your document by
a  [self  windowControllers]  message, extract the first
window controller, and ask it for its window.

The other route is to simply use a  [self windowForSheet]
message, which does essentially the same thing as described
in the previous paragraph.

Of course, given that your document class is a sub-class
of NSDocument, why not simply add a new   IBOutlet  instance
variable that points to the associated document window?

    Best Wishes,
		........  Henry


===============================+============================ Henry McGilton, Boulevardier | Trilithon Software Objective-C/Java Composer | Seroia Research -------------------------------+---------------------------- mailto:email@hidden | http://www.trilithon.com | ===============================+============================

_______________________________________________
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


  • Follow-Ups:
    • Re: Programatically resizing a window
      • From: Tim Lucas <email@hidden>
References: 
 >Programatically resizing a window (From: Michael Heinz <email@hidden>)
 >Re: Programatically resizing a window (From: j o a r <email@hidden>)
 >Re: Programatically resizing a window (From: Michael Heinz <email@hidden>)

  • Prev by Date: Re: NSSocketPort bug?
  • Next by Date: Re: cross development on Jaguar
  • Previous by thread: Re: Programatically resizing a window
  • Next by thread: Re: Programatically resizing a window
  • Index(es):
    • Date
    • Thread