FROM : Steve Weller
DATE : Sat Mar 01 03:10:01 2008
On Feb 29, 2008, at 4:46 PM, Quincey Morris wrote:
>
> On Feb 29, 2008, at 16:00, Steve Weller wrote:
>
>> - (void) setFrameSize:(NSSize)newSize
>> {
>> NSSize cSize;
>> cSize = [self canvasSize]; // Provides a size
>>
>> // Use the larger dimensions of the two rects
>> if(newSize.width > cSize.width)
>> cSize.width = newSize.width;
>> if(newSize.height > cSize.height)
>> cSize.height = newSize.height;
>>
>> [super setFrameSize:cSize];
>> }
>>
>> And this works as long as the window is only made smaller. If the
>> window is made larger then the scrollers do not disappear.
>>
>> Is my approach the right one for what I am trying to achieve?
>
> Probably not. There are various ways the view frame can change, and
> they don't all funnel through the setFrameSize method.
>
> If you register to receive NSViewFrameDidChangeNotification's for
> your view (remembering to call setPostsFrameChangedNotifications:
> YES), it might work to do something like this in the notification
> method:
>
> [[NSNotificationCenter defaultCenter] removeObserver: self];
> NSRect frame = [self frame];
> // calculate new frame
> [self setFrame: frame];
> [[NSNotificationCenter defaultCenter] addObserver: self ...
>
I implemented this with no change no behavior.
The higher level problem I am trying to solve is this:
My custom view spans the window's content view. I want to draw a white
rectangle (think of a document) centered in that area and fill the
remainder gray. In my drawRect method I first draw gray into the
rectangle passed. Then I calculate where the white rectangle should be
and draw it.
I need the scrollers to act on the bounds of the white rectangle so
that they are present when any part of it is not visible.
Should I be putting my custom view inside another view and doing the
centering and background color with IB instead?
What is the best way of implementing this?
DATE : Sat Mar 01 03:10:01 2008
On Feb 29, 2008, at 4:46 PM, Quincey Morris wrote:
>
> On Feb 29, 2008, at 16:00, Steve Weller wrote:
>
>> - (void) setFrameSize:(NSSize)newSize
>> {
>> NSSize cSize;
>> cSize = [self canvasSize]; // Provides a size
>>
>> // Use the larger dimensions of the two rects
>> if(newSize.width > cSize.width)
>> cSize.width = newSize.width;
>> if(newSize.height > cSize.height)
>> cSize.height = newSize.height;
>>
>> [super setFrameSize:cSize];
>> }
>>
>> And this works as long as the window is only made smaller. If the
>> window is made larger then the scrollers do not disappear.
>>
>> Is my approach the right one for what I am trying to achieve?
>
> Probably not. There are various ways the view frame can change, and
> they don't all funnel through the setFrameSize method.
>
> If you register to receive NSViewFrameDidChangeNotification's for
> your view (remembering to call setPostsFrameChangedNotifications:
> YES), it might work to do something like this in the notification
> method:
>
> [[NSNotificationCenter defaultCenter] removeObserver: self];
> NSRect frame = [self frame];
> // calculate new frame
> [self setFrame: frame];
> [[NSNotificationCenter defaultCenter] addObserver: self ...
>
I implemented this with no change no behavior.
The higher level problem I am trying to solve is this:
My custom view spans the window's content view. I want to draw a white
rectangle (think of a document) centered in that area and fill the
remainder gray. In my drawRect method I first draw gray into the
rectangle passed. Then I calculate where the white rectangle should be
and draw it.
I need the scrollers to act on the bounds of the white rectangle so
that they are present when any part of it is not visible.
Should I be putting my custom view inside another view and doing the
centering and background color with IB instead?
What is the best way of implementing this?
| Related mails | Author | Date |
|---|---|---|
| Steve Weller | Mar 1, 01:00 | |
| Quincey Morris | Mar 1, 01:46 | |
| Steve Weller | Mar 1, 03:10 | |
| Quincey Morris | Mar 1, 03:40 | |
| Quincey Morris | Mar 1, 04:31 | |
| Steve Weller | Mar 1, 06:31 | |
| Quincey Morris | Mar 1, 07:33 | |
| Steve Weller | Mar 1, 17:57 | |
| Kyle Sluder | Mar 1, 18:37 |






Cocoa mail archive

