Well, this question has already been asked in the "working with bitmaps" article but remained unanswered so far.
So, I wanted to take the following approach: when the window is resized (for example the user makes the window larger then the view should be placed in the center of the window) there should be an NSWindowDidResize notification flying around. My goal is to register the ImageView for this notification in order to catch it and make some adjustments on the placement of the ImageView.
I have no problems, registering and unregistering the ImageView with the default notificationCenter, but it looks like there is no NSWindowDidResize notification, well at least my method to handle the event is not invoked, which I checked with the help of NSLog.
The only idea I have, is that it is not sufficient to register the ImageView with the notificationCenter? Might it be, that the windows aren't automatically sending these notifications?
Any help is appreciated
greetings Henri
Showing messages 1 through 3 of 3.
Centering the view.
2002-08-12 05:02:38
infallible
[View]
I am looking for a solution for that problem also.
1. Fixing lower-left corner problem is easy, just overwrite one method:
- (BOOL)isFlipped
{
return YES;
}
now about centering the view :/....
I have 1 idea:
1. make a new subclass from NSView called MyPositioningView or something.
2. add a MyImageView subview to MyPositioningView
3. then check if the clipview is larger than the image * scaleFactor. If it is set MyPositioningView's frame as big as clipView's frame, but if not then make it as big as your image * scaleFactor.
4. change MyImageView's frame origin.
I am gonna try it this week[when i got time], but maybe somebody knows a better way...
Oh easiest way would be just make a subclass of NSScrollView and overwrite the (void)tile method, but its not a good solution[ euw ugly!] :( ].
btw. sorry about my poor english. And good luck with your book Mike :).
1. Make a subclass of NSScrollView
2. overwrite drawRect, its not needed, but i wanted to make gray background for the image :]. If you won't overwrite it then it will be white
hmm 15 pixels is scroller's width ofcourse, you can make the code sigtly better ofcourse. Like: float scrollerWidth = NSHeight([[self horizontalScroller] frame]);
// assuming that both scrollers are always visible! Modify if needed :]
newContentRect = NSMakeRect(0,0,newContentRect.size.width - scrollerWidth, newContentRect.size.height - scrollerWidth);
// use if([self hasHorizontalScroller])/if([self hasVerticalScroller]) also if you need to check if the scrollView has to draw the scrollers
1. Fixing lower-left corner problem is easy, just overwrite one method:
- (BOOL)isFlipped
{
return YES;
}
now about centering the view :/....
I have 1 idea:
1. make a new subclass from NSView called MyPositioningView or something.
2. add a MyImageView subview to MyPositioningView
3. then check if the clipview is larger than the image * scaleFactor. If it is set MyPositioningView's frame as big as clipView's frame, but if not then make it as big as your image * scaleFactor.
4. change MyImageView's frame origin.
I am gonna try it this week[when i got time], but maybe somebody knows a better way...
Oh easiest way would be just make a subclass of NSScrollView and overwrite the (void)tile method, but its not a good solution[ euw ugly!] :( ].
btw. sorry about my poor english. And good luck with your book Mike :).