RE: NSScrollView problems when scaling an NSTextView
RE: NSScrollView problems when scaling an NSTextView
- Subject: RE: NSScrollView problems when scaling an NSTextView
- From: Keith Blount <email@hidden>
- Date: Mon, 7 Nov 2005 11:13:30 -0800 (PST)
Very sorry to reply to my own post, but this is
driving me crazy now - I have been trying to fix it
for nearly a week now with no luck. If anyone knows
why the scrollers might get messed up when switching a
(scaled) text view between scroll views, I would be
very grateful.
Many thanks,
Keith
--- Original post: ---
Hello,
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?
Many thanks in advance,
Keith
--- email@hidden wrote:
> Send Cocoa-dev mailing list submissions to
> email@hidden
>
> To subscribe or unsubscribe via the World Wide Web,
> visit
> http://lists.apple.com/mailman/listinfo/cocoa-dev
> or, via email, send a message with subject or body
> 'help' to
> email@hidden
>
> You can reach the person managing the list at
> email@hidden
>
> When replying, please edit your Subject line so it
> is more specific
> than "Re: Contents of Cocoa-dev digest..."
>
>
> Today's Topics:
>
> 1. Easy backtrace (Gideon King)
> 2. Demande de renseignements sur NSDatePicker
> (gael thibaud)
> 3. RE: NSTextView scrolling issue. (Anthony Duer)
> 4. Problems parsing plist files (Peter Schols)
> 5. Re: Easy backtrace (j o a r)
> 6. Re: An OutlineView with Finder Editing
> Behavior
> (Guillaume Gandreau)
> 7. Re: Trouble with MakeFSSpec (Ricky Sharp)
> 8. Re: Start an application with a panel (Andrea
> Salomoni)
> 9. Fwd: DO and Sleep (Julien Guimont)
> 10. Re: Easy backtrace (Gideon King)
> 11. Re: Problems parsing plist files (I. Savant)
> 12. Re: Reviews of "Advanced Mac OS X Programming"
> (Mark Dalrymple)
> 13. Re: programmatic nib (Alex Reynolds)
> 14. Re: Cross platform Cocoa/ObjC? (Scott
> Thompson)
> 15. Re: programmatic nib (Rory Prior)
> 16. Re: programmatic nib (I. Savant)
>
>
>
----------------------------------------------------------------------
>
> Message: 1
> Date: Mon, 7 Nov 2005 22:14:07 +1000
> From: Gideon King <email@hidden>
> Subject: Easy backtrace
> To: CocoaDev Dev <email@hidden>
> Message-ID:
> <email@hidden>
> Content-Type: text/plain; charset=US-ASCII;
> delsp=yes; format=flowed
>
> Hi, I don't know whether others of you may find this
> trivial, but I
> just came across something I thought might be useful
> for other people...
>
> I had an issue to debug where I needed to know what
> the stack trace
> was on a series of calls to retain and release on an
> object.
> Unfortunately because of the nature of the program,
> switching window
> focus by having GDB stop at a breakbpoint and
> looking in XCode
> altered the behavior of the code, as did throwing an
> exception,
> catching it and printing the stack trace from there.
>
> So I added the following two methods to my class so
> I could print out
> when retain and release were called:
>
> - (void)retain {
> NSLog(@"+++Retaining graphicview %d", [self
> retainCount]);
> [super retain];
> }
>
> - (void)release {
> NSLog(@"---Releasing graphicview %d", [self
> retainCount]);
> [super release];
> }
>
> I then put breakpoints after the NSLogs, and
> double-clicked the
> breakpoints to see the breakpoint settings, and
> clicked on the plus
> button for each one, and added the debugger command:
>
> bt
> c
>
> to each one. Now when I run it, I get the backtrace
> of each call
> without interrupting the flow or switching windows.
>
> Obviously there are variations of this where you
> don't need to
> explicitly override methods etc, but you get the
> idea.
>
> As I say, pretty basic, but I hadn't thought of it
> before, and
> thought others may find it useful too.
>
>
>
> Gideon King
> email@hidden
>
>
>
> ------------------------------
>
> Message: 2
> Date: Mon, 7 Nov 2005 13:14:52 +0100
> From: gael thibaud <email@hidden>
> Subject: Demande de renseignements sur NSDatePicker
> To: Cocoa Mailing <email@hidden>
> Message-ID:
> <email@hidden>
> Content-Type: text/plain; charset=US-ASCII;
> delsp=yes; format=flowed
>
> I have met a problem during my use of NSDatePicker
> (Cocoa-Objective C)
>
> On the window of MyDatePicker Inspector
> (attributes), TimeZone and
> Era are not selectable.
>
> In fact, it is not possible for me with NSDatePicker
> interface to use
> several TimeZone (with a popUp for instance).
>
> Is it really impossible to use NSTimeZone with
> DatePicker interface ?
>
>
>
>
> ------------------------------
>
> Message: 3
> Date: Mon, 7 Nov 2005 04:17:37 -0800
> From: Anthony Duer <email@hidden>
> Subject: RE: NSTextView scrolling issue.
> To: email@hidden
> Message-ID:
> <email@hidden>
> Content-Type: text/plain; charset=US-ASCII;
> delsp=yes; format=flowed
>
> Hi List,
>
> I did a little more digging around with my problem
> via NSLog'ing and
> I'm definitely noticing something weird with a
> subclassed NSTextView
> and it's enclosing NSScroller. My slightly updated
> method:
>
> -(void)appendStringToView:
> (NSMutableAttributedString *)text
> {
> BOOL shouldScroll = ([scroller floatValue] ==
> 1.00) ? YES : NO;
> NSLog(@"%f", [scroller floatValue]);
> [myStore beginEditing];
> [myStore appendAttributedString: text];
> [myStore endEditing];
> NSLog(@"%f", [scroller floatValue]);
> if(shouldScroll)
> {
> [self scrollRangeToVisible: NSMakeRange([myStore
> length], 0)];
> [scroller setFloatValue: 1.00];
> NSLog(@"%f", [scroller floatValue]);
> }
> NSLog(@"%f", [scroller floatValue]);
> }
>
> Here's a NSLog I received...
> 2005-11-07 04:10:43.284 Program[1348] 1.000000
> 2005-11-07 04:10:43.292 Program[1348] 1.000000
> 2005-11-07 04:10:43.295 Program[1348] 1.000000
> 2005-11-07 04:10:43.296 Program[1348] 1.000000
> ------------
> 2005-11-07 04:10:43.304 Program[1348] 0.992714
> 2005-11-07 04:10:43.306 Program[1348] 0.992714
> 2005-11-07 04:10:43.306 Program[1348] 0.992714
>
> Somehow, between function calls, my scroller is
> moving up very
> slightly for no reason at all. Nothing occurring at
> the
=== message truncated ===
__________________________________
Yahoo! FareChase: Search multiple travel sites in one click.
http://farechase.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