Add dragging of ruler markers.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@14907 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Adam Fedor 2002-11-02 23:17:23 +00:00
parent 00f196e1c0
commit 52b116f1f4
8 changed files with 572 additions and 97 deletions

View file

@ -1,3 +1,31 @@
2002-11-02 Adam Fedor <fedor@gnu.org>
* Source/NSWindowController.m (-setDocument:): Remove window's
setReleasedWhenClosed when doc is not nil.
(-setWindow:): Idem.
(Pointed out by Stefan Urbanek).
2002-11-02 Adam Fedor <fedor@gnu.org>
* Source/NSParagraphStyle.m (-compare:): Correct the comparision of
NSTextTabs.
* Source/NSScrollView.m (-tile:): Add a call to setNeedsDisplay.
* Source/NSRulerMarker.h: Correct a mispelling in a method name
makerLocation to markerLocation.
* Source/NSTextView.m: Idem.
(-rulerView:didAddMarker:) Create a new NSTextTab corresponding
to the marker.
(-rulerView:handleMouseDown:) Ask rulerview to track a new
marker, instead of simply adding a new marker
* Source/NSRulerView.m: Remove some unused macros.
(-_verifyReservedThicknessForMarkers, _rulerRect, _markersRect,
-markerAtPoint:): New private.
(-trackMarker:withMouseEvent:): Implement.
(-mouseDown:) Track marker if click was on marker, or asks
client to handle if click was on ruler area.
* Source/NSRulerMarker.m: -trackMouse:adding:): Implement.
(Patches from Benhur Stein <benhur@inf.ufsm.br>).
2002-11-01 Adam Fedor <fedor@gnu.org>
* Source/NSApplication.m (-finishLaunching): Instantiate an

View file

@ -70,7 +70,7 @@
- (BOOL)isRemovable;
- (void)setMarkerLocation:(float)location;
- (float)makerLocation;
- (float)markerLocation;
- (void)setRepresentedObject:(id <NSCopying>)anObject;
- (id <NSCopying>)representedObject;

View file

@ -55,9 +55,9 @@
if (anObject == nil || ([anObject isKindOfClass: self->isa] == NO))
return NSOrderedAscending;
loc = ((NSTextTab*)anObject)->_location;
if (loc < _location)
if (_location < loc)
return NSOrderedAscending;
else if (loc > _location)
else if (_location > loc)
return NSOrderedDescending;
else
return NSOrderedSame;

View file

@ -30,6 +30,13 @@
#include <AppKit/NSRulerView.h>
#include <AppKit/NSEvent.h>
#include <AppKit/NSImage.h>
#include <AppKit/NSApplication.h>
#include <AppKit/NSWindow.h>
#include <AppKit/NSCursor.h>
@interface NSRulerView (GNUstepInternal)
- (NSRect)_markersRect;
@end
@implementation NSRulerMarker
@ -42,6 +49,7 @@
[NSException raise: NSInvalidArgumentException
format: @"No view or image for ruler marker"];
self = [super init];
_isMovable = YES;
_isRemovable = NO;
_location = location;
@ -55,6 +63,7 @@
- (void) dealloc
{
RELEASE(_image);
TEST_RELEASE(_representedObject);
[super dealloc];
}
@ -86,17 +95,43 @@
- (NSRect)imageRectInRuler
{
//BOOL flipped = [_rulerView isFlipped];
BOOL flipped = [_rulerView isFlipped];
NSSize size = [_image size];
NSPoint pointInRuler;
pointInRuler = [[_rulerView clientView]
convertPoint: NSMakePoint(_location, _location)
toView: _rulerView];
// FIXME
if ([_rulerView orientation] == NSHorizontalRuler)
{
return NSMakeRect(_location - _imageOrigin.x, -_imageOrigin.y,
size.width, size.height);
if (flipped)
{
return NSMakeRect(pointInRuler.x - _imageOrigin.x,
[_rulerView baselineLocation] - (size.height - _imageOrigin.y),
size.width, size.height);
}
else
{
return NSMakeRect(pointInRuler.x - _imageOrigin.x,
[_rulerView baselineLocation] - _imageOrigin.y,
size.width, size.height);
}
}
else
{
if (flipped)
{
return NSMakeRect([_rulerView baselineLocation] - _imageOrigin.x,
pointInRuler.y - (size.height - _imageOrigin.y),
size.width, size.height);
}
else
{
return NSMakeRect([_rulerView baselineLocation] - _imageOrigin.x,
pointInRuler.y - _imageOrigin.y,
size.width, size.height);
}
}
return NSZeroRect;
@ -106,14 +141,15 @@
{
NSSize size = [_image size];
//FIXME
if ([_rulerView orientation] == NSHorizontalRuler)
{
return size.height;
/* what is below imageOrigin is on the ruler area and is not counted */
return size.height - _imageOrigin.y;
}
else
{
return size.width;
/* what is to the right of imageOrigin is on the ruler area */
return _imageOrigin.x;
}
}
@ -142,14 +178,14 @@
_location = location;
}
- (float)makerLocation
- (float)markerLocation
{
return _location;
}
- (void)setRepresentedObject:(id <NSCopying>)anObject
{
_representedObject = anObject;
ASSIGN(_representedObject, anObject);
}
- (id <NSCopying>)representedObject
@ -160,8 +196,15 @@
- (void)drawRect:(NSRect)aRect
{
NSPoint aPoint;
NSRect rect = [self imageRectInRuler];
NSRect rect;
/* do not draw when dragging, all drawing is done in -trackMouse... */
if (_isDragging)
{
return;
}
rect = [self imageRectInRuler];
aPoint = rect.origin;
if ([_rulerView isFlipped])
{
@ -171,10 +214,8 @@
if (NSIsEmptyRect(rect))
return;
[_rulerView lockFocus];
[_image compositeToPoint: aPoint
operation: NSCompositeSourceOver];
[_rulerView unlockFocus];
}
- (BOOL)isDragging
@ -182,32 +223,302 @@
return _isDragging;
}
- (BOOL)trackMouse:(NSEvent *)theEvent adding:(BOOL)flag
- (BOOL)trackMouse:(NSEvent *)theEvent adding:(BOOL)adding
{
NSView *client = [_rulerView clientView];
NSEvent *newEvent;
int eventMask = NSLeftMouseDraggedMask | NSLeftMouseUpMask;
BOOL isFar = NO;
BOOL askedCanRemove = NO;
BOOL canRemove = NO;
BOOL flipped;
NSPoint mousePositionInRuler;
NSPoint mousePositionInClient;
NSPoint mousePositionInWindow;
NSPoint previousMousePositionInWindow;
NSPoint mouseOffset;
NSRect markersRect;
float location;
NSRect drawRect;
NSPoint drawPoint;
BOOL returnValue = NO;
NSWindow *window;
if (flag)
if (adding)
{
if ([client respondsToSelector: @selector(rulerView:shouldAddMarker:)] &&
[client rulerView: _rulerView shouldAddMarker: self] == NO)
if ([client respondsToSelector: @selector(rulerView:shouldAddMarker:)]
&& [client rulerView: _rulerView shouldAddMarker: self] == NO)
return NO;
}
else if (!_isMovable && !_isRemovable)
{
return NO;
}
else if ([client respondsToSelector: @selector(rulerView:shouldMoveMarker:)] &&
[client rulerView: _rulerView shouldMoveMarker: self] == NO)
else if (_isMovable
&& [client respondsToSelector: @selector(rulerView:shouldMoveMarker:)]
&& [client rulerView: _rulerView shouldMoveMarker: self] == NO)
{
return NO;
}
// I'm being dragged!
_isDragging = YES;
// FIXME
RETAIN(self); // make sure we're not dealloc'd if removed from ruler
[NSCursor hide];
[_rulerView lockFocus];
_isDragging = NO;
/* cache some values */
markersRect = [_rulerView _markersRect];
flipped = [_rulerView isFlipped];
window = [_rulerView window];
mousePositionInWindow = [theEvent locationInWindow];
previousMousePositionInWindow = mousePositionInWindow;
mousePositionInRuler = [_rulerView convertPoint: mousePositionInWindow
fromView: nil];
return YES;
/* calculate offset of mouse click relative to marker's location
(to avoid marker bumping when dragging starts) */
if (adding)
{
mouseOffset = NSMakePoint(0, 0);
}
else
{
NSPoint locationInRuler;
locationInRuler = [client convertPoint: NSMakePoint(_location, _location)
toView: _rulerView];
if ([_rulerView orientation] == NSHorizontalRuler)
{
mouseOffset = NSMakePoint(locationInRuler.x - mousePositionInRuler.x, 0);
}
else
{
mouseOffset = NSMakePoint(0, locationInRuler.y - mousePositionInRuler.y);
if (flipped)
{
mouseOffset.y *= -1;
}
}
}
/* cache image without marker and draw marker in position */
if (adding)
{
/* marker is not drawn yet; mouse is in marker's imageOrigin */
drawRect.size = [_image size];
drawPoint.x = mousePositionInRuler.x - _imageOrigin.x;
if (!flipped)
{
drawPoint.y = mousePositionInRuler.y - _imageOrigin.y;
drawRect.origin = drawPoint;
}
else
{
drawPoint.y = mousePositionInRuler.y + _imageOrigin.y;
drawRect.origin.x = drawPoint.x;
drawRect.origin.y = drawPoint.y - drawRect.size.height;
}
}
else
{
drawRect = [self imageRectInRuler];
drawPoint = drawRect.origin;
if (flipped)
{
drawPoint.y += drawRect.size.height;
}
/* make marker disappear (-drawRect: does not draw marker when dragged) */
[_rulerView drawRect: drawRect];
}
[window cacheImageInRect: [_rulerView convertRect: drawRect toView: nil]];
[_image compositeToPoint: drawPoint
operation: NSCompositeSourceOver];
[window flushWindow];
/* loop processing events until mouse up */
while (_isDragging)
{
newEvent = [NSApp nextEventMatchingMask: eventMask
untilDate: [NSDate distantFuture]
inMode: NSEventTrackingRunLoopMode
dequeue: YES];
switch ([newEvent type])
{
case NSLeftMouseDragged:
/* take mouse position from outside of event stream
and ignore event if in same position as previous event,
to reduce the number of events to process */
mousePositionInWindow = [window mouseLocationOutsideOfEventStream];
if (NSEqualPoints(mousePositionInWindow, previousMousePositionInWindow))
{
break;
}
previousMousePositionInWindow = mousePositionInWindow;
/* offset mouse position to marker's location */
mousePositionInWindow.x += mouseOffset.x;
mousePositionInWindow.y += mouseOffset.y;
/* see if mouse is far from ruler area (to remove marker) */
mousePositionInRuler = [_rulerView convertPoint: mousePositionInWindow
fromView: nil];
isFar = !NSMouseInRect(mousePositionInRuler, markersRect, flipped);
/* if it is the first time it's far from the ruler area,
see if it can be removed */
if (isFar && !askedCanRemove)
{
if (adding)
{
canRemove = YES;
}
else if (!_isRemovable)
{
canRemove = NO;
}
else if ([client respondsToSelector: @selector(rulerView:shouldRemoveMarker:)])
{
canRemove = [client rulerView: _rulerView
shouldRemoveMarker: self];
}
else
{
canRemove = YES;
}
askedCanRemove = YES;
}
/* calculate new marker location */
mousePositionInClient = [client convertPoint: mousePositionInWindow
fromView: nil];
if ([_rulerView orientation] == NSHorizontalRuler)
{
location = mousePositionInClient.x;
}
else
{
location = mousePositionInClient.y;
}
/* give client a chance to change location */
if (adding && !isFar)
{
if ([client respondsToSelector: @selector(rulerView:willAddMarker:atLocation:)])
{
location = [client rulerView: _rulerView
willAddMarker: self
atLocation: location];
}
}
else if (_isMovable && !(isFar && canRemove))
{
if ([client respondsToSelector: @selector(rulerView:willMoveMarker:toLocation:)])
{
location = [client rulerView: _rulerView
willMoveMarker: self
toLocation: location];
}
}
_location = location;
/* calculate position to draw marker */
drawRect = [self imageRectInRuler];
drawPoint = drawRect.origin;
if (flipped)
{
drawPoint.y += drawRect.size.height;
}
if (isFar && canRemove)
{
if ([_rulerView orientation] == NSHorizontalRuler)
{
float offset;
offset = mousePositionInRuler.y - [_rulerView baselineLocation];
drawPoint.y += offset;
drawRect.origin.y += offset;
}
else
{
float offset;
offset = mousePositionInRuler.x - [_rulerView baselineLocation];
drawPoint.x += offset;
drawRect.origin.x += offset;
}
}
/* undraw marker and redraw in new position */
[window restoreCachedImage];
[window cacheImageInRect: [_rulerView convertRect: drawRect
toView: nil]];
[_image compositeToPoint: drawPoint
operation: NSCompositeSourceOver];
[window flushWindow];
break;
case NSLeftMouseUp:
if (adding)
{
if (isFar)
{
/* do nothing, it won't be added */
[window restoreCachedImage];
returnValue = NO;
}
else
{
/* marker is added to ruler view; inform client */
[window discardCachedImage];
[_rulerView addMarker:self];
if ([client respondsToSelector: @selector(rulerView:didAddMarker:)])
{
[client rulerView: _rulerView didAddMarker: self];
}
returnValue = YES;
}
}
else
{
if (isFar && _isRemovable && canRemove)
{
/* remove marker from ruler and inform client */
/* this could result in marker being dealloc'd; that's
why there is a retain before the loop */
[window restoreCachedImage];
[_rulerView removeMarker:self];
if ([client respondsToSelector: @selector(rulerView:didRemoveMarker:)])
{
[client rulerView: _rulerView didRemoveMarker: self];
}
returnValue = YES;
}
else if (_isMovable)
{
/* inform client that marker has been moved */
[window discardCachedImage];
if ([client respondsToSelector: @selector(rulerView:didMoveMarker:)])
{
[client rulerView: _rulerView didMoveMarker: self];
}
returnValue = YES;
}
else
{
[window restoreCachedImage];
returnValue = NO;
}
}
_isDragging = NO;
break;
default:
break;
}
}
[_rulerView unlockFocus];
[NSCursor unhide];
[window flushWindow];
RELEASE(self); // was retained when dragging started
return returnValue;
}
// NSCopying protocol

View file

@ -36,7 +36,9 @@
#include <AppKit/NSRulerMarker.h>
#include <AppKit/NSRulerView.h>
#include <AppKit/NSScrollView.h>
#include <AppKit/NSEvent.h>
#include <AppKit/PSOperators.h>
#include <AppKit/NSAttributedString.h>
DEFINE_RINT_IF_MISSING
@ -50,16 +52,19 @@ DEFINE_RINT_IF_MISSING
#define BASE_LINE_LOCATION 0
#define RULER_THICKNESS 16
#define MARKER_THICKNESS 15
#define ASSIGN_FIRST_VALUE(firstVal, tRect) (firstVal = (int)((tRect - _zeroLocation) / labelDistInRuler) * labelDistInRuler)
#define ASSIGN_FIRST_MARKER(firstMarker, tRect) (firstMarker = ceil(((tRect - _zeroLocation) - firstVal) / (_unitToRuler * markDistInUnits)))
#define ASSIGN_DIFERENCE(diference, tRect) (diference = (firstMarker * (markDistInUnits * _unitToRuler)) + firstVal + _zeroLocation - tRect)
#define SET_MARK_COUNT(markCount, tRect, dif) (markCount = floor(1 + (tRect - dif) / (_unitToRuler * markDistInUnits)))
#define DRAW_HASH_MARK(context, size) {if (_orientation == NSHorizontalRuler) DPSrlineto(context, 0, size); else DPSrlineto(context, size, 0);}
#define DRAW_HASH_MARK(context, size) \
do { \
if (_orientation == NSHorizontalRuler)\
{ \
DPSrlineto(context, 0, size); \
} \
else \
{ \
DPSrlineto(context, size, 0); \
} \
} while (0)
@interface GSRulerUnit : NSObject
{
@ -163,7 +168,7 @@ unitToPointsConversionFactor: (float)factor
/*
* Class variables
*/
*/
static NSMutableDictionary *units = nil;
/*
@ -221,7 +226,14 @@ static NSMutableDictionary *units = nil;
[self setRuleThickness: RULER_THICKNESS];
[self setOriginOffset: 0.0];
[self setReservedThicknessForAccessoryView: 0.0];
[self setReservedThicknessForMarkers: 0.0];
if (o == NSHorizontalRuler)
{
[self setReservedThicknessForMarkers: MARKER_THICKNESS];
}
else
{
[self setReservedThicknessForMarkers: 0.0];
}
[self invalidateHashMarks];
}
return self;
@ -310,6 +322,32 @@ static NSMutableDictionary *units = nil;
return _originOffset;
}
- (void) _verifyReservedThicknessForMarkers
{
NSEnumerator *en;
NSRulerMarker *marker;
float maxThickness = _reservedThicknessForMarkers;
if (_markers == nil)
{
return;
}
en = [_markers objectEnumerator];
while ((marker = [en nextObject]) != nil)
{
float markerThickness;
markerThickness = [marker thicknessRequiredInRuler];
if (markerThickness > maxThickness)
{
maxThickness = markerThickness;
}
}
if (maxThickness > _reservedThicknessForMarkers)
{
[self setReservedThicknessForMarkers: maxThickness];
}
}
- (void) setMarkers: (NSArray *)newMarkers
{
if (newMarkers != nil && _clientView == nil)
@ -320,6 +358,7 @@ static NSMutableDictionary *units = nil;
if (newMarkers != nil)
{
ASSIGN(_markers, [NSMutableArray arrayWithArray: newMarkers]);
[self _verifyReservedThicknessForMarkers];
}
else
{
@ -368,17 +407,101 @@ static NSMutableDictionary *units = nil;
- (BOOL) trackMarker: (NSRulerMarker *)aMarker
withMouseEvent: (NSEvent *)theEvent
{
/* FIXME/TODO: not implemented */
return NO;
NSParameterAssert(aMarker != nil);
return [aMarker trackMouse: theEvent adding: YES];
}
- (NSRect) _rulerRect
{
NSRect rect = [self bounds];
if (_orientation == NSHorizontalRuler)
{
rect.size.height = _ruleThickness;
if ([self isFlipped])
{
rect.origin.y = [self baselineLocation];
}
else
{
rect.origin.y = [self baselineLocation] - _ruleThickness;
}
}
else
{
rect.size.width = _ruleThickness;
rect.origin.x = [self baselineLocation];
}
return rect;
}
- (NSRect) _markersRect
{
NSRect rect = [self bounds];
if (_orientation == NSHorizontalRuler)
{
rect.size.height = _reservedThicknessForMarkers;
if ([self isFlipped])
{
rect.origin.y = _reservedThicknessForAccessoryView;
}
else
{
rect.origin.y = _ruleThickness;
}
}
else
{
rect.size.width = _reservedThicknessForMarkers;
rect.origin.x = _reservedThicknessForAccessoryView;
}
return rect;
}
- (NSRulerMarker *) _markerAtPoint: (NSPoint)point
{
NSEnumerator *markerEnum;
NSRulerMarker *marker;
BOOL flipped = [self isFlipped];
/* test markers in reverse order so that markers drawn on top
are tested before those underneath */
markerEnum = [_markers reverseObjectEnumerator];
while ( (marker = [markerEnum nextObject]) != nil)
{
if (NSMouseInRect (point, [marker imageRectInRuler], flipped))
{
return marker;
}
}
return nil;
}
- (void) mouseDown: (NSEvent*)theEvent
{
if (_clientView != nil
&& [_clientView respondsToSelector:
@selector(rulerView:handleMouseDown:)])
NSPoint clickPoint;
BOOL flipped = [self isFlipped];
clickPoint = [self convertPoint: [theEvent locationInWindow]
fromView: nil];
if (NSMouseInRect (clickPoint, [self _rulerRect], flipped))
{
[_clientView rulerView: self handleMouseDown: theEvent];
if (_clientView != nil
&& [_clientView respondsToSelector:
@selector(rulerView:handleMouseDown:)])
{
[_clientView rulerView: self handleMouseDown: theEvent];
}
}
else if (NSMouseInRect (clickPoint, [self _markersRect], flipped))
{
NSRulerMarker *clickedMarker;
clickedMarker = [self _markerAtPoint: clickPoint];
if (clickedMarker != nil)
{
[clickedMarker trackMouse: theEvent adding: NO];
}
}
}
@ -419,25 +542,22 @@ static NSMutableDictionary *units = nil;
{
if (! _cacheIsValid)
{
NSRect rect;
NSRect unitRect;
NSSize unitSize;
float cf;
int convIndex;
/* calculate the position of the zero coordinate in the ruler
* and the size one unit in document view has in the ruler */
/* calculate the size one unit in document view has in the ruler */
cf = [_unit conversionFactor];
rect = NSMakeRect(_originOffset, _originOffset, cf, cf);
unitRect = [self convertRect: rect
unitSize = [self convertSize: NSMakeSize(cf, cf)
fromView: [_scrollView documentView]];
if (_orientation == NSHorizontalRuler)
{
_unitToRuler = NSWidth(unitRect);
_unitToRuler = unitSize.width;
}
else
{
_unitToRuler = NSHeight(unitRect);
_unitToRuler = unitSize.height;
}
/* Calculate distance between marks. */
@ -461,7 +581,7 @@ static NSMutableDictionary *units = nil;
/* calculate number of small marks in each bigger mark */
_marksToMidMark = rint([self _stepForIndex: convIndex + 1]);
_marksToBigMark = _marksToMidMark
* rint([self _stepForIndex: convIndex + 2]);
* rint([self _stepForIndex: convIndex + 2]);
/* Calculate distance between labels.
It must not be less than MIN_LABEL_DISTANCE. */
@ -502,9 +622,13 @@ static NSMutableDictionary *units = nil;
int firstVisibleMark;
int lastVisibleMark;
int mark;
int firstVisibleLabel;
int lastVisibleLabel;
int label;
NSRect baseLineRect;
float baselineLocation = [self baselineLocation];
NSPoint zeroPoint;
BOOL flipped = [self isFlipped];
docView = [_scrollView documentView];
@ -549,7 +673,7 @@ static NSMutableDictionary *units = nil;
NSRectFill(baseLineRect);
/* draw hash marks */
firstVisibleMark = ceil((firstVisibleLocation - _zeroLocation)
firstVisibleMark = floor((firstVisibleLocation - _zeroLocation)
/ _markDistance);
lastVisibleMark = floor((firstVisibleLocation + visibleLength - _zeroLocation)
/ _markDistance);
@ -570,33 +694,7 @@ static NSMutableDictionary *units = nil;
if ((mark % _marksToLabel) == 0)
{
float labelValue;
NSString *label;
DRAW_HASH_MARK(ctxt, LABEL_MARK_SIZE);
/* draw label */
/* FIXME: shouldn't be using NSCell to draw labels? */
labelValue = (markLocation - _zeroLocation) / _unitToRuler;
if ([self isFlipped] == NO && labelValue != 0.0)
{
label = [NSString stringWithFormat: _labelFormat, -labelValue];
}
else
{
label = [NSString stringWithFormat: _labelFormat, labelValue];
}
if (_orientation == NSHorizontalRuler)
{
DPSrmoveto(ctxt, 2, 0);
}
else
{
float labelWidth;
labelWidth = [font widthOfString: label];
DPSrmoveto(ctxt, 3 - labelWidth, 9);
}
DPSshow(ctxt, [label cString]);
}
else if ((mark % _marksToBigMark) == 0)
{
@ -612,6 +710,47 @@ static NSMutableDictionary *units = nil;
}
}
DPSstroke(ctxt);
/* draw labels */
/* FIXME: shouldn't be using NSCell to draw labels? */
firstVisibleLabel = floor((firstVisibleLocation - _zeroLocation)
/ (_marksToLabel * _markDistance));
lastVisibleLabel = floor((firstVisibleLocation + visibleLength - _zeroLocation)
/ (_marksToLabel * _markDistance));
for (label = firstVisibleLabel; label <= lastVisibleLabel; label++)
{
float labelLocation;
float labelValue;
NSString *labelString;
NSPoint labelPosition;
labelLocation = _zeroLocation + label * _marksToLabel * _markDistance;
labelValue = (labelLocation - _zeroLocation) / _unitToRuler;
labelString = [NSString stringWithFormat: _labelFormat, labelValue];
if (_orientation == NSHorizontalRuler)
{
labelPosition.x = labelLocation + 2;
labelPosition.y = baselineLocation + LABEL_MARK_SIZE;
}
else
{
float labelWidth;
labelWidth = [font widthOfString: labelString];
labelPosition.x = baselineLocation + LABEL_MARK_SIZE + 3 - labelWidth;
if (flipped)
{
labelPosition.y = labelLocation + [font xHeight] + 4;
}
else
{
labelPosition.y = labelLocation + 2;
}
}
DPSmoveto(ctxt, labelPosition.x, labelPosition.y);
DPSshow(ctxt, [labelString cString]);
}
}
- (void) drawMarkersInRect: (NSRect)aRect
@ -665,7 +804,6 @@ static NSMutableDictionary *units = nil;
- (void) setReservedThicknessForMarkers: (float)thickness
{
/* NSLog(@"requiredThicknessForMarkers: %f", thickness); */
_reservedThicknessForMarkers = thickness;
[_scrollView tile];
}

View file

@ -914,6 +914,7 @@ static float scrollerWidth;
}
[_contentView setFrame: contentRect];
[self setNeedsDisplay: YES];
}
- (void) drawRect: (NSRect)rect

View file

@ -2255,8 +2255,8 @@ replacing the selection.
- (BOOL) shouldChangeTextInRange: (NSRange)affectedCharRange
replacementString: (NSString*)replacementString
{
if (_tf.is_editable == NO)
return NO;
//if (_tf.is_editable == NO)
// return NO;
/* We need to send the textShouldBeginEditing: /
textDidBeginEditingNotification only once; and we need to send it
@ -3472,7 +3472,7 @@ afterString in order over charRange. */
{
NSTextTab *old_tab = [marker representedObject];
NSTextTab *new_tab = [[NSTextTab alloc] initWithType: [old_tab tabStopType]
location: [marker makerLocation]];
location: [marker markerLocation]];
NSRange range = [self rangeForUserParagraphAttributeChange];
unsigned loc = range.location;
NSParagraphStyle *style;
@ -3598,7 +3598,9 @@ afterString in order over charRange. */
- (void) rulerView: (NSRulerView *)ruler
didAddMarker: (NSRulerMarker *)marker
{
NSTextTab *tab = [marker representedObject];
NSTextTab *old_tab = [marker representedObject];
NSTextTab *new_tab = [[NSTextTab alloc] initWithType: [old_tab tabStopType]
location: [marker markerLocation]];
NSRange range = [self rangeForUserParagraphAttributeChange];
unsigned loc = range.location;
NSParagraphStyle *style;
@ -3627,7 +3629,7 @@ afterString in order over charRange. */
copiedStyle = YES;
}
[value addTabStop: tab];
[value addTabStop: new_tab];
[_textStorage addAttribute: NSParagraphStyleAttributeName
value: value
@ -3648,10 +3650,13 @@ afterString in order over charRange. */
mstyle = [style mutableCopy];
[mstyle addTabStop: tab];
[mstyle addTabStop: new_tab];
// FIXME: Should use setTypingAttributes
[_typingAttributes setObject: mstyle forKey: NSParagraphStyleAttributeName];
RELEASE (mstyle);
[marker setRepresentedObject: new_tab];
RELEASE(new_tab);
}
/**
@ -3672,9 +3677,9 @@ afterString in order over charRange. */
location: location];
[marker setRepresentedObject: tab];
[ruler addMarker: marker];
[ruler trackMarker: marker withMouseEvent: event];
RELEASE(marker);
AUTORELEASE(tab);
RELEASE(tab);
}
/**

View file

@ -147,11 +147,7 @@
ASSIGN (_document, document);
[self synchronizeWindowTitleWithDocumentName];
if (_document != nil)
{
[_window setReleasedWhenClosed: YES];
}
else
if (_document == nil)
{
/* If you want the window to be deallocated when closed, you
need to observe the NSWindowWillCloseNotification (or
@ -276,11 +272,7 @@
- (void) setWindow: (NSWindow *)aWindow
{
ASSIGN (_window, aWindow);
if (_document != nil)
{
[_window setReleasedWhenClosed: YES];
}
else
if (_document == nil)
{
[_window setReleasedWhenClosed: NO];
}