>
>
>>
>
> You need to place a view here and do the custom drawing in the view. To
> place the view, you need to subclass NSScrollView and override the -tile
> method to place the view in that corner. The scrollview subclass will also
> typically own the custom view.
>
> Here's an example from the archives that will do what you want:
>
> http://www.cocoabuilder.com/archive/message/cocoa/2001/6/29/21070
>
> --Graham
>
>
>
Hi, Graham,

I think I finally got what you said. I referred your linked sample, and
implemented my source as follows.(I enclose my source for anyone who has
same problem with many thanks to this list.) I also needed to add some code
to drawRect to draw my custom view correctly.

If you find any problem from my source, please let me know.



#import "BSScrollView.h"



@implementation BSScrollView



// Prepare a view to be a background of scrollers. This view will cover all
area of scrollView.

- (void) _setScrollerBackgroundView:(NSView *) view{

[view retain];

[_scrollerBackgroundView release];

_scrollerBackgroundView = view;

[self addSubview:_scrollerBackgroundView];

}

- (NSView *) scrollerBackgroundView {

return _scrollerBackgroundView;

}


- (void)tile {

[super tile];

if (![self scrollerBackgroundView])

{

// Place a view that cover all area of scroll view.

NSRect tempRect = NSMakeRect(0.0, 0.0, [self bounds].size.width, [self
bounds].size.height);

NSView *tempView = [NSView allocWithZone:[self zone]];

[tempView initWithFrame:tempRect];

[self _setScrollerBackgroundView:tempView];

}

}


- (void)drawRect:(NSRect)rect {

[super drawRect:rect];

// draw background color for scroll view. This color fills areas under knob
slots and right bottom area of scroll view.

[[NSColor blackColor]set];

NSRectFill([_scrollerBackgroundView frame]);

}


- (void) dealloc {

[_scrollerBackgroundView release];

[super dealloc];

}

@end
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to