• 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
NSMatrix with Custom NSCells
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSMatrix with Custom NSCells


  • Subject: NSMatrix with Custom NSCells
  • From: Stephan Burlot <email@hidden>
  • Date: Wed, 2 Jul 2003 15:25:21 +0200
  • Resent-date: Wed, 9 Jul 2003 15:32:35 +0200
  • Resent-from: Stephan Burlot <email@hidden>
  • Resent-message-id: <email@hidden>
  • Resent-to: email@hidden

Hi,

I have a class, derived from NSMatrix, which contains custom cells (with images).
When displaying, the images is drawn only if the cell is fully visible (ie when resizing the window).

When scrolling, only the lower part of the image is shown, but when resizing, all fully visible images are shown, without problems.

In my custom cell, drawWithFrame is called and fills the cell with green before drawing the pic, and this is always done, even if the cell is not fully visible.
It's just the image that is missing.

Any idea?

Here's some code:
My class, derived from NSMatrix, is initialized:

- (id) initWithFrame:(NSRect)frameRect
{
IconCell *cell = [[IconCell alloc] initImageCell:[NSImage imageNamed:@"sample"]];

NSLog(@"initWithFrame");

[super initWithFrame:frameRect
mode:NSListModeMatrix
prototype:cell
numberOfRows:350
numberOfColumns:7];
[cell release];
[self setCellSize:NSMakeSize(140, 140)];
[self setValidateSize:TRUE];
[self sizeToCells];

return self;
}

My custom cell drawing code:
- (void) drawWithFrame: (NSRect)theFrame inView: (NSView *)theView
{
NSLog(@"drawWithFrame");

// make background green
[[NSColor greenColor] set];
[NSBezierPath fillRect:theFrame];
// draw the pic
[self drawInteriorWithFrame:theFrame inView:theView];

return;
}

- (void) drawInteriorWithFrame: (NSRect)theFrame inView: (NSView *)theView
{
NSPoint p;
NSSize s;
NSImage *theImage;

// Composite the pic in the rect.
theImage = [NSImage imageNamed: icon];
if ( ! theImage ) {
NSString *path = [[NSBundle mainBundle] pathForImageResource: icon];
theImage = [[NSImage alloc] initWithContentsOfFile: path];
[theImage setName: icon];
}

[theView lockFocus];
[theImage compositeToPoint: theFrame.origin operation: NSCompositeCopy];
[theView unlockFocus];

return;
}

Thanks,

Stephan Burlot, Coriolis Technologies
Custom Application Development
Email: email@hidden
http://www.coriolis.ch/
_______________________________________________
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.

  • Prev by Date: Re: gcc 3.3, Precompiled Headers and Project Builder
  • Next by Date: class dispatch table has duplicate names right?
  • Previous by thread: Re: Duplicating Apple search field UI
  • Next by thread: class dispatch table has duplicate names right?
  • Index(es):
    • Date
    • Thread