Re: mlRE: NSScrollView problems when scaling an NSTextView
Re: mlRE: NSScrollView problems when scaling an NSTextView
- Subject: Re: mlRE: NSScrollView problems when scaling an NSTextView
- From: Todd Ransom <email@hidden>
- Date: Mon, 7 Nov 2005 15:38:15 -0700
Keith,
You can have two textviews use the same undo manager. It works ok for
me with two textviews that share the same text storage. Just make
them share the same delegate and implement this method:
- (NSUndoManager *)undoManagerForTextView:(NSTextView *)aTextView {
return [[self document] undoManager];
}
hope that helps,
Todd Ransom
Return Self Software
http://returnself.com
On Nov 7, 2005, at 3:04 PM, Keith Blount wrote:
Many thanks for your reply. I use a similar method you
suggest for various other swapping of text storages
within the text view. However, the reason I use the
same text view and swap it between scroll views is
that I want undo to be constant across leaping in and
out of full screen mode. If I use a separate text
view, undo will be lost...
Many thanks,
Keith
--- ORIGINAL MESSAGE: ---
Date: Mon, 7 Nov 2005 11:13:30 -0800 (PST)
From: Keith Blount <<email_removed>>
Subject: RE: NSScrollView problems when scaling an
NSTextView
I am having some strange issues when scaling an
NSTextView that have been bugging me for days - any
help of advice would be much appreciated.
I am scaling my text view using scaleUnitSquareToSize.
Note that I do not want the scaling behaviour of
TextEdit (which resizes the bounds), as I don't want
the need for a horizontal scroller. I just want the
whole text to get bigger but fit within the visible
width.
My scaling code looks like this (note that
scalePercent is a float passed in):
float currentScaleOffset = 1.0/([textView
bounds].size.width/[textView frame].size.width);
float scaleFactor =
(scalePercent/100.0)/currentScaleOffset;
NSSize scaleSize =
NSMakeSize(scaleFactor,scaleFactor);
[textView scaleUnitSquareToSize:scaleSize];
// We need to notifiy the clip view that the
// text view's frame has changed
[[NSNotificationCenter defaultCenter]
postNotificationName:NSViewFrameDidChangeNotification
object:textView];
[textView setNeedsDisplayInRect:[textView
visibleRect]];
This works great. The problem arises when I flip to
a
full screen mode. I do this by moving the whole text
view to different window - removing it from its
current
scroll view and placing it in a different scroll
view
(I swap scroll views because I use a centering clip
view and custom scroller; however, I have tried
swapping to a normal scroll view in case this was
the
problem, but it made no difference). I then call the
above code again, as full screen mode can have a
different scale percent. At this point, there can be
loads of extra space beneath the text in the text
view, or there may be no scroller when there should
be
one (because there is text to scroll). It seems that
the clip view or scroll view just isn't recognising
the correct size (height) of the text view.
Does anybody have any idea what I might be missing
here?
Instead of moving the text view from one scroll view
to another, you
could have a completely separate text view on your
full screen window
and only move the NSTextStorage from one text view to
another. Or have
both text views share the same text storage.
Look at figure 4 on this page:
http://developer.apple.com/documentation/Cocoa/Conceptual/
TextArchitecture/index.html#//apple_ref/doc/uid/10000086i
To replace a text storage use:
[[textView layoutManager]
replaceTextStorage:textStorage];
Hope this helps,
Peter
__________________________________
Yahoo! Mail - PC Magazine Editors' Choice 2005
http://mail.yahoo.com
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden