Re: Highlighting NSImageCells in an NSMatrix
Re: Highlighting NSImageCells in an NSMatrix
- Subject: Re: Highlighting NSImageCells in an NSMatrix
- From: John Pannell <email@hidden>
- Date: Sun, 1 Feb 2004 08:34:24 -0700
Hi Michael-
I have an app that uses an NSMatrix subclass to display images. Here is
the "setup" portion of the implementation...
@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;
}
The cells in the matrix are nothing special - I subclassed NSImageCell
(PSMActionImageCell above) to handle some target/action stuff. When
setup like this, the image cells highlight with a light grey color (not
the control color) due to the NSImageFrameGrayBezel setting. You could
use another option there for different highlighting.
You might also make sure your matrix has been setup with the
NSListModeMatrix option.
Hope this helps!
John
On Feb 1, 2004, at 7:28 AM, Michael Becker wrote:
>
> Here's the method you need to implement:
>
>
>
> - (void)setHighlighted:(BOOL)flag
>
>
>
>
Hm, for testing purposes I tried to invoke NSRectFill([[ self
>
controlView] bounds]); but nothing happened. I actually think my
>
problem goes a little deeper. Maybe this is complete nonsense, but it
>
"feels" like this is happening:
>
>
The ImageView completely draws itself over the Cell, so that the
>
highlighting (performed on the cell) is overdrawn. Maybe I get this
>
feeling because in IB is created a matrix of NSImageViews, having 1
>
row and 4 cols, and the ImageViews completely fill a cell.
>
In awakeFromNib is set the prototype-cell to NSImageCell.
>
Programmatically, I add and delete cells.
>
>
Maybe you could provide me with some more info on what to do :)
>
>
As I mentioned:
>
>
NSRectFill (see above) didn't do anything, and
>
>
[[ self controlView] setKeyboardFocusRingNeedsDisplayInRect:[[ self
>
controlView] bounds]];
>
>
didn't do anything, either.
>
>
- Michael
>
_______________________________________________
>
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.