Add methods -_becomeRulerClient and -_resignRulerClient to set self as the

ruler client and to resign from that. These get called when self becomes 
first responder or resigns from first responder.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@33287 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Fred Kiefer 2011-06-12 22:43:08 +00:00
parent 4dbb7eaa8a
commit 783d3d3ae8
2 changed files with 53 additions and 3 deletions

View file

@ -1,3 +1,10 @@
2011-06-13 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSTextView.m: Add methods -_becomeRulerClient and
-_resignRulerClient to set self as the ruler client and to resign
from that. These get called when self becomes first responder or
resigns from first responder.
2011-06-11 Fred Kiefer <FredKiefer@gmx.de>
* Headers/AppKit/NSPrintInfo.h,

View file

@ -159,6 +159,11 @@ Interface for a bunch of internal methods that need to be cleaned up.
- (void) _textDidChange: (NSNotification*)notif;
- (void) _textCheckingTimerFired: (NSTimer *)t;
/*
* helper method for ruler view
*/
- (void) _becomeRulerClient;
- (void) _resignRulerClient;
@end
@ -310,7 +315,6 @@ Interface for a bunch of internal methods that need to be cleaned up.
- (void) _undoTextChange: (NSTextViewUndoObject *)anObject;
@end
/**** Misc. helpers and stuff ****/
static const int currentVersion = 3;
@ -1445,6 +1449,7 @@ to make sure syncing is handled properly in all cases.
- (void) setRulerVisible: (BOOL)flag
{
NSScrollView *sv;
NSRulerView *rv;
NSTEXTVIEW_SYNC;
@ -1457,6 +1462,18 @@ to make sure syncing is handled properly in all cases.
[sv setHasHorizontalRuler: YES];
}
[sv setRulersVisible: _tf.is_ruler_visible];
if (self == [_window firstResponder] &&
(rv = [sv horizontalRulerView]) != nil)
{
if (flag)
{
[rv setClientView: self];
}
else
{
[rv setClientView: nil];
}
}
}
}
@ -1630,6 +1647,7 @@ to make sure syncing is handled properly in all cases.
/* Add any clean-up stuff here */
[self _resignRulerClient];
if ([self shouldDrawInsertionPoint])
{
@ -1668,6 +1686,7 @@ started (in another text view attached to the same layout manager). */
/* Note: Notifications (NSTextBeginEditingNotification etc) are sent
the first time the user tries to edit us. */
[self _becomeRulerClient];
/* Draw selection, update insertion point */
if ([self shouldDrawInsertionPoint])
@ -4457,8 +4476,6 @@ shouldRemoveMarker: (NSRulerMarker *)marker
makers = [_layoutManager rulerMarkersForTextView: self
paragraphStyle: paraStyle
ruler: rv];
// TODO This is not the correct place to call this.
[rv setClientView: self];
[rv setMarkers: makers];
}
}
@ -6183,6 +6200,32 @@ or add guards
}
}
- (void) _becomeRulerClient
{
NSScrollView *sv;
NSRulerView *rv;
if (_tf.uses_ruler && _tf.is_ruler_visible &&
(sv = [self enclosingScrollView]) != nil &&
(rv = [sv horizontalRulerView]) != nil)
{
[rv setClientView: self];
}
}
- (void) _resignRulerClient
{
NSScrollView *sv;
NSRulerView *rv;
if (_tf.uses_ruler && _tf.is_ruler_visible &&
(sv = [self enclosingScrollView]) != nil &&
(rv = [sv horizontalRulerView]) != nil)
{
[rv setClientView: nil];
}
}
@end
@implementation NSTextViewUndoObject