resizing troubles
resizing troubles
- Subject: resizing troubles
- From: Benjámin Salánki <email@hidden>
- Date: Mon, 12 Jan 2004 22:21:17 +0100
Hi again,
Here's my trouble: I Have an NSView subclass that contains two
NSTextView subclasses in an NSScrollView subclass. I need to have
subclasses for future stuff I need to add, so I thought I'd just try
working with them. I want the two NSTextViews to grow with the
NSScrollView which in turn should grow with the NSView subclass if that
is resized. Could you please check out my included sample and check
what i might be doing wrong?
thx.
#import "SFNumberedTextView.h"
@implementation SFNumberedTextView
- (id)initWithFrame:(NSRect)frame
{
self = [super initWithFrame:frame];
if (self)
{
// Initialization code here.
_counterView = [[SFCounterTextView alloc] initWithFrame:NSMakeRect(0,
0, 25, frame.size.height)];
_textView = [[SFSyntaxTextView alloc] initWithFrame:NSMakeRect(25, 0,
frame.size.width-25, frame.size.height)];
_scrollView = [[SFNumberedScrollView alloc] initWithFrame:frame];
[_scrollView addSubview:_counterView];
[_scrollView addSubview:_textView];
[self addSubview:_scrollView];
}
return self;
}
- (void)drawRect:(NSRect)rect {
// Drawing code here.
}
- (BOOL)postsFrameChangedNotifications
{
return YES;
}
- (BOOL)autoresizesSubviews
{
return YES;
}
- (unsigned int)autoresizingMask
{
return (NSViewWidthSizable|NSViewHeightSizable);
}
- (SFCounterTextView *)counterView
{
return [[_counterView retain] autorelease];
}
- (void)setCounterView:(SFCounterTextView *)newCounterView
{
if (_counterView != newCounterView)
{
[_counterView release];
_counterView = [newCounterView copy];
}
}
- (SFSyntaxTextView *)textView
{
return [[_textView retain] autorelease];
}
- (void)setTextView:(SFSyntaxTextView *)newTextView
{
if (_textView != newTextView)
{
[_textView release];
_textView = [newTextView copy];
}
}
- (SFNumberedScrollView *)scrollView
{
return [[_scrollView retain] autorelease];
}
- (void)setScrollView:(SFNumberedScrollView *)newScrollView
{
if (_scrollView != newScrollView)
{
[_scrollView release];
_scrollView = [newScrollView copy];
}
}
@end
@implementation SFCounterTextView
- (BOOL)isSelectable
{
return NO;
}
- (BOOL)isEditable
{
return NO;
}
- (BOOL)isRichText
{
return YES;
}
- (BOOL)importsGraphics
{
return NO;
}
- (BOOL)isRulerVisible
{
return NO;
}
- (NSColor *)backgroundColor
{
return [[[NSColor controlHighlightColor] retain] autorelease];
}
- (BOOL)drawsBackground
{
return YES;
}
- (BOOL)allowsUndo
{
return NO;
}
- (unsigned int)autoresizingMask
{
return (NSViewMaxXMargin|NSViewWidthSizable|NSViewHeightSizable);
}
- (BOOL)autoresizesSubviews
{
return YES;
}
@end
@implementation SFSyntaxTextView
- (BOOL)isSelectable
{
return YES;
}
- (BOOL)isEditable
{
return YES;
}
- (BOOL)isRichText
{
return YES;
}
- (BOOL)importsGraphics
{
return NO;
}
- (BOOL)isRulerVisible
{
return NO;
}
- (NSColor *)backgroundColor
{
return [[[NSColor whiteColor] retain] autorelease];
}
- (BOOL)drawsBackground
{
return YES;
}
- (BOOL)allowsUndo
{
return YES;
}
- (unsigned int)autoresizingMask
{
return (NSViewWidthSizable|NSViewHeightSizable);
}
- (BOOL)autoresizesSubviews
{
return YES;
}
@end
@implementation SFNumberedScrollView
- (NSBorderType)borderType
{
return NSNoBorder;
}
- (BOOL)drawsBackground
{
return NO;
}
- (BOOL)hasVerticalScroller
{
return YES;
}
- (BOOL)hasHorizontalScroller
{
return NO;
}
- (BOOL)autohidesScrollers
{
return YES;
}
- (BOOL)autoresizesSubviews
{
return YES;
}
- (unsigned int)autoresizingMask
{
return (NSViewWidthSizable|NSViewHeightSizable);
}
- (BOOL)postsFrameChangedNotifications
{
return YES;
}
@end
stupidFish23
http://www.stupidfish23.com
_______________________________________________
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.