• 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: Highlighting NSImageCells in an NSMatrix
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Highlighting NSImageCells in an NSMatrix


  • Subject: Re: Highlighting NSImageCells in an NSMatrix
  • From: Alastair Houghton <email@hidden>
  • Date: Tue, 3 Feb 2004 12:20:05 +0000

On 3 Feb 2004, at 11:41, Michael Becker wrote:

>> I have an app that uses an NSMatrix subclass to display images. Here
>> is the "setup" portion of the implementation...
>>
>
> This actually works, but I cannot use the bezeled borders. My images
> have to be "just the image on plain white" and when selected, the
> white cell background around the image should turn blue (or whatever).
>
> I think I will have to subclass NSImageCell, override drawWithFrame:
> or drawInteriorWithFrame:, and probably even override some
> highlighting method to draw the blue background...
>
> Lotta work for just highlighting a cell...

You're overstating the level of difficulty. Subclassing NSImageCell to
do what you want is *easy*:

@interface MBImageCell : NSImageCell
{
}

@end

@implementation MBImageCell

-(void)drawInteriorWithFrame:(NSRect)frame inView:(NSView *)controlView
{
if ([self isHighlighted]) {
[[NSColor selectedControlColor] set];
NSRectFill (frame);
}

[super drawInteriorWithFrame:frame inView:controlView];
}

@end

Obviously this was typed quickly in Mail and hasn't been tested, but I
think you get the idea. It is possible that NSImageCell's
-drawInteriorWithFrame:inView: doesn't do quite what you want, in which
case you might want to replace it with a call to one of NSImage's
methods, but otherwise I think it should work.

(BTW, you can turn the borders off using the -setBordered: and/or
-setBezeled: methods if you want to do so.)

Kind regards,

Alastair.

[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
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.

  • Follow-Ups:
    • Re: Highlighting NSImageCells in an NSMatrix
      • From: Michael Becker <email@hidden>
References: 
 >Re: Highlighting NSImageCells in an NSMatrix (From: Michael Becker <email@hidden>)
 >Re: Highlighting NSImageCells in an NSMatrix (From: John Pannell <email@hidden>)
 >Re: Highlighting NSImageCells in an NSMatrix (From: Michael Becker <email@hidden>)

  • Prev by Date: Re: Highlighting NSImageCells in an NSMatrix
  • Next by Date: Re: Help, ugly compositing...
  • Previous by thread: Re: Highlighting NSImageCells in an NSMatrix
  • Next by thread: Re: Highlighting NSImageCells in an NSMatrix
  • Index(es):
    • Date
    • Thread