Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSMatrix setOrigin issue?



On Thu, 27 Jul 2006 13:17:55 -0400, Richard Salvatierra <email@hidden>
said:
>How can I center the NSMatrix (vertically) within the width of an
>NSScrollView?

The words "vertically" and "width" do not go together well. You probably
mean "horizontally".

>I have an NSMatrix (subclass) in a NSScrollView.  I am doing a
>scaling routine to the cells adjusting size and spacing.  I want to
>center the matrix within the scrollview.  I can't seem to change the
>origin of the matrix using [self setFrameOrigin: newOrigin].  If I
>change the origin of the it's superview, it appears to be placed
>correctly, but the background of the scrollView does not fill
>correctly.  It fills starting with the origin point.

Here's a crude start. Put the NSMatrix in a custom NSView, and set the
springs and struts to keep the matrix centered. Now put the NSView in an
NSScrollView. Finally, use the NSView's code to keep it the height of the
matrix and the width of the scroll view:

- (void) resizeYourself {
    NSSize s = [[self enclosingScrollView] contentSize];
    NSSize s2 = [[[self subviews] lastObject] frame].size;
    [self setFrame: NSMakeRect(0, 0, s.width, s2.height)];
}

m.


-- 
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
<http://www.amazon.com/gp/product/0596102119>



 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.