• 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: Help with NSMatrix (for displaying images from iPhoto)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Help with NSMatrix (for displaying images from iPhoto)


  • Subject: Re: Help with NSMatrix (for displaying images from iPhoto)
  • From: John Pannell <email@hidden>
  • Date: Thu, 29 Jan 2004 21:06:17 -0700

Hi John-

I have an app that uses NSMatrix to house various numbers of NSImages
in NSImageCells (well, a subclass). I've been quite happy with the
results...

Your description of what you did sounds good to me (Drag a custom view
from the palette, assign its custom class to your subclass, etc.).
Without seeing your class implementation, I can't guess on much else;
I've got my implementation below if you want to compare...

Hope this helps!

John

@implementation ThumbnailMatrix
- (id)initWithFrame:(NSRect)frameRect
{
// create the cell prototype and style it
id cell = [[PSMActionImageCell alloc] init];
[cell setImageAlignment:NSImageAlignCenter];
[cell setImageFrameStyle:NSImageFrameGrayBezel];
[cell setImageScaling:NSScaleProportionally];
[cell setEnabled:YES];

// create the actual matrix of buttons
[super initWithFrame:frameRect
mode:NSListModeMatrix
prototype:cell
numberOfRows:0
numberOfColumns:4];

// put a white background behind cells
[self setDrawsBackground:YES];
[self setBackgroundColor:[NSColor whiteColor]];

// configure the size and spacing of buttons
// use the width of the superview (the scroller)

[self setCellSize:NSMakeSize(100,100)];
[self setIntercellSpacing:NSMakeSize(0,0)];

[cell release];

return self;
}

- (void)resizeWithOldSuperviewSize:(NSSize)oldFrameSize
{
// this gets called when the superview is being resized
// I want the matrix to grow and shrink based on the width of the
superview,
// with no regard to the height.

int cellWidth = (int)(oldFrameSize.width / 4.0);
[self setCellSize:NSMakeSize(cellWidth,cellWidth)];
[self sizeToCells];
[self setNeedsDisplay];
}

- (void)viewDidEndLiveResize
{
// called when the resize is over
// want to set width to 1/4 of the parent view
int cellWidth = (int)([[self superview] frame].size.width / 4.0);
[self setCellSize:NSMakeSize(cellWidth,cellWidth)];
[self sizeToCells];
[self setNeedsDisplay];
}

On Jan 29, 2004, at 8:31 PM, John C. Fox wrote:

> Howdy:
>
> New day, new problem. There's been a fair amout of traffic on the list
> about NSTableView and NSMatrix lately, so why not add some more?
>
> Like other folks out there, I'm working on adding support for browsing
> images in a user's iPhoto Library (are you listening Apple, we need
> public API's for doing this, along with accessing media from the other
> iLife apps).
>
> At any rate, I want to create a "contact sheet"-like display of
> images. I've been able to do this using an NSTableView, which was easy
> enough to do. However, as others have recently pointed out, if you
> want to isolate a single cell, you're kind of SOL. The prevailing
> wisdom seems to be to use an NSMatrix, which I've been working on, but
> I'm having trouble.
>
> Since the number of image cells will vary, I need to programmatically
> create the NSMatrix (or in my case, a subclass). I created a method to
> add the necessary rows based on an array of URL's. (using insertRow:
> withCells). So far, so good, but nothing displays, even after calling
> displayIfNeeded.
>
> Bummer.
>
> Did I do something wrong in IB? I dragged a view onto my window, then
> changed its class to my NSMatrix subclass. Should I simply create an
> NSView subclass and add my matrix as a subview?
>
> As always, any help greatly appreciated.
>
> John
> _______________________________________________
> cocoa-dev mailing list | email@hidden
> Help/Unsubscribe/Archives:
> http://www.lists.apple.com/mailman/listinfo/cocoa-dev
> Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Help with NSMatrix (for displaying images from iPhoto) (From: "John C. Fox" <email@hidden>)

  • Prev by Date: Re: Finder-like Color Labels
  • Next by Date: Re: Instance variable.
  • Previous by thread: Help with NSMatrix (for displaying images from iPhoto)
  • Next by thread: plist files
  • Index(es):
    • Date
    • Thread