mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-02 13:20:59 +00:00
Added MacOSX 10.4 methods to NSControl and reworked the whole cell
editing mechanism. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@24380 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
9a71af08ad
commit
aa68ca06dc
8 changed files with 294 additions and 240 deletions
23
ChangeLog
23
ChangeLog
|
@ -1,3 +1,26 @@
|
||||||
|
2007-01-18 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
|
* Source/NSCell.m (-setFloatingPointFormat:left:right): Basic
|
||||||
|
implementation.
|
||||||
|
* Source/NSCell.m (-setUpFieldEditorAttributes:,
|
||||||
|
_setupTextWithFrame:inView:editor:delegate:range:, endEditing:,
|
||||||
|
editWithFrame:...event:, selectWithFrame:...length:): Changed to
|
||||||
|
handle more text attributes and non-scrolling text.
|
||||||
|
* Source/NSCell.m (-setScrollable:): If switched on, switch wraps off.
|
||||||
|
* Headers/AppKit/NSCell.h: Corrected version number for some methods.
|
||||||
|
|
||||||
|
* Headers/AppKit/NSControl.h: Add MacOS 10.4 methods.
|
||||||
|
* Source/NSControl.m: Implement new MacOS 10.4 methods.
|
||||||
|
* Source/NSControl.m (-mouseDown): Once more removed action mask
|
||||||
|
fiddling. This time there is protection that the control itself
|
||||||
|
does not go away.
|
||||||
|
* Source/NSControl.m (-textDidBeginEditing:, -textDidChange:,
|
||||||
|
-textDidEndEditing:): Extracted code to be shared between subclasses.
|
||||||
|
* Source/NSTextField.m,
|
||||||
|
* Source/NSTableView.m,
|
||||||
|
* Source/NSMatrix.m (-textDidBeginEditing:, -textDidChange:,
|
||||||
|
-textDidEndEditing:): Call shared super code.
|
||||||
|
|
||||||
2007-01-17 Fred Kiefer <FredKiefer@gmx.de>
|
2007-01-17 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
* Headers/AppKit/NSResponder.h: Add MacOS 10.4 methods.
|
* Headers/AppKit/NSResponder.h: Add MacOS 10.4 methods.
|
||||||
|
|
|
@ -272,11 +272,9 @@ enum {
|
||||||
- (void)setTitle:(NSString *)aString;
|
- (void)setTitle:(NSString *)aString;
|
||||||
- (NSString *)title;
|
- (NSString *)title;
|
||||||
#endif
|
#endif
|
||||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_3, GS_API_LATEST)
|
#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
|
||||||
- (NSWritingDirection)baseWritingDirection;
|
- (NSWritingDirection)baseWritingDirection;
|
||||||
- (void)setBaseWritingDirection:(NSWritingDirection)direction;
|
- (void)setBaseWritingDirection:(NSWritingDirection)direction;
|
||||||
#endif
|
|
||||||
#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
|
|
||||||
- (NSLineBreakMode)lineBreakMode;
|
- (NSLineBreakMode)lineBreakMode;
|
||||||
- (void)setLineBreakMode:(NSLineBreakMode)mode;
|
- (void)setLineBreakMode:(NSLineBreakMode)mode;
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -31,7 +31,9 @@
|
||||||
#define _GNUstep_H_NSControl
|
#define _GNUstep_H_NSControl
|
||||||
#import <GNUstepBase/GSVersionMacros.h>
|
#import <GNUstepBase/GSVersionMacros.h>
|
||||||
|
|
||||||
#include <AppKit/NSText.h>
|
// for NSWritingDirection
|
||||||
|
#include <AppKit/NSParagraphStyle.h>
|
||||||
|
#include <AppKit/NSView.h>
|
||||||
|
|
||||||
@class NSString;
|
@class NSString;
|
||||||
@class NSNotification;
|
@class NSNotification;
|
||||||
|
@ -113,6 +115,10 @@
|
||||||
- (void)setFormatter:(NSFormatter*)newFormatter;
|
- (void)setFormatter:(NSFormatter*)newFormatter;
|
||||||
- (id)formatter;
|
- (id)formatter;
|
||||||
#endif
|
#endif
|
||||||
|
#if OS_API_VERSION(MAC_OS_X_VERSION_10_4, GS_API_LATEST)
|
||||||
|
- (NSWritingDirection)baseWritingDirection;
|
||||||
|
- (void)setBaseWritingDirection:(NSWritingDirection)direction;
|
||||||
|
#endif
|
||||||
|
|
||||||
//
|
//
|
||||||
// Managing the Field Editor
|
// Managing the Field Editor
|
||||||
|
|
274
Source/NSCell.m
274
Source/NSCell.m
|
@ -37,6 +37,7 @@
|
||||||
#include <Foundation/NSException.h>
|
#include <Foundation/NSException.h>
|
||||||
#include <Foundation/NSValue.h>
|
#include <Foundation/NSValue.h>
|
||||||
#include <Foundation/NSNotification.h>
|
#include <Foundation/NSNotification.h>
|
||||||
|
#include <Foundation/NSNumberFormatter.h>
|
||||||
#include <Foundation/NSDebug.h>
|
#include <Foundation/NSDebug.h>
|
||||||
#include <Foundation/NSFormatter.h>
|
#include <Foundation/NSFormatter.h>
|
||||||
#include <Foundation/NSRunLoop.h>
|
#include <Foundation/NSRunLoop.h>
|
||||||
|
@ -904,6 +905,10 @@ static NSColor *shadowCol;
|
||||||
- (void) setScrollable: (BOOL)flag
|
- (void) setScrollable: (BOOL)flag
|
||||||
{
|
{
|
||||||
_cell.is_scrollable = flag;
|
_cell.is_scrollable = flag;
|
||||||
|
if (flag)
|
||||||
|
{
|
||||||
|
[self setWraps: NO];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setWraps: (BOOL)flag
|
- (void) setWraps: (BOOL)flag
|
||||||
|
@ -1008,32 +1013,6 @@ static NSColor *shadowCol;
|
||||||
return _cell.imports_graphics;
|
return _cell.imports_graphics;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSText*) setUpFieldEditorAttributes: (NSText*)textObject
|
|
||||||
{
|
|
||||||
[textObject setString: @""];
|
|
||||||
[textObject setTextColor: [self textColor]];
|
|
||||||
if (_cell.contents_is_attributed_string == NO)
|
|
||||||
{
|
|
||||||
/* TODO: Manage scrollable attribute */
|
|
||||||
[textObject setFont: _font];
|
|
||||||
[textObject setAlignment: _cell.text_align];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* FIXME/TODO. What do we do if we are an attributed string.
|
|
||||||
Think about what happens when the user ends editing.
|
|
||||||
Allows editing text attributes... Formatter... TODO. */
|
|
||||||
}
|
|
||||||
[textObject setEditable: _cell.is_editable];
|
|
||||||
[textObject setSelectable: _cell.is_selectable || _cell.is_editable];
|
|
||||||
[textObject setRichText: _cell.is_rich_text];
|
|
||||||
[textObject setImportsGraphics: _cell.imports_graphics];
|
|
||||||
[textObject setSelectedRange: NSMakeRange(0, 0)];
|
|
||||||
[textObject scrollRangeToVisible: NSMakeRange(0, 0)];
|
|
||||||
|
|
||||||
return textObject;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (NSString*) title
|
- (NSString*) title
|
||||||
{
|
{
|
||||||
return [self stringValue];
|
return [self stringValue];
|
||||||
|
@ -1199,12 +1178,41 @@ static NSColor *shadowCol;
|
||||||
left: (unsigned int)leftDigits
|
left: (unsigned int)leftDigits
|
||||||
right: (unsigned int)rightDigits
|
right: (unsigned int)rightDigits
|
||||||
{
|
{
|
||||||
// TODO: Pass this on to the formatter to handle
|
NSNumberFormatter *formatter = [[NSNumberFormatter alloc] init];
|
||||||
|
NSMutableString *format = [[NSMutableString alloc] init];
|
||||||
|
|
||||||
|
if (autoRange)
|
||||||
|
{
|
||||||
|
unsigned fieldWidth = leftDigits + rightDigits + 1;
|
||||||
|
|
||||||
|
// FIXME: this does not fully match the documentation.
|
||||||
|
while (fieldWidth--)
|
||||||
|
{
|
||||||
|
[format appendString: @"#"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
while (leftDigits--)
|
||||||
|
{
|
||||||
|
[format appendString: @"#"];
|
||||||
|
}
|
||||||
|
[format appendString: @"."];
|
||||||
|
while (rightDigits--)
|
||||||
|
{
|
||||||
|
[format appendString: @"0"];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[formatter setFormat: format];
|
||||||
|
RELEASE(format);
|
||||||
|
[self setFormatter: formatter];
|
||||||
|
RELEASE(formatter);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setFormatter: (NSFormatter*)newFormatter
|
- (void) setFormatter: (NSFormatter*)newFormatter
|
||||||
{
|
{
|
||||||
ASSIGN (_formatter, newFormatter);
|
ASSIGN(_formatter, newFormatter);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id) formatter
|
- (id) formatter
|
||||||
|
@ -1378,6 +1386,7 @@ static NSColor *shadowCol;
|
||||||
if (controlView != nil)
|
if (controlView != nil)
|
||||||
{
|
{
|
||||||
NSWindow *cvWin = [controlView window];
|
NSWindow *cvWin = [controlView window];
|
||||||
|
NSDate *limit = [NSDate dateWithTimeIntervalSinceNow: 0.1];
|
||||||
|
|
||||||
[controlView lockFocus];
|
[controlView lockFocus];
|
||||||
|
|
||||||
|
@ -1386,12 +1395,10 @@ static NSColor *shadowCol;
|
||||||
[cvWin flushWindow];
|
[cvWin flushWindow];
|
||||||
|
|
||||||
// Wait approx 1/10 seconds
|
// Wait approx 1/10 seconds
|
||||||
[[NSRunLoop currentRunLoop]
|
[[NSRunLoop currentRunLoop] runUntilDate: limit];
|
||||||
runUntilDate: [NSDate dateWithTimeIntervalSinceNow: 0.1]];
|
|
||||||
|
|
||||||
[self highlight: NO withFrame: cellFrame inView: controlView];
|
[self highlight: NO withFrame: cellFrame inView: controlView];
|
||||||
[cvWin flushWindow];
|
[cvWin flushWindow];
|
||||||
|
|
||||||
[controlView unlockFocus];
|
[controlView unlockFocus];
|
||||||
|
|
||||||
if (action)
|
if (action)
|
||||||
|
@ -2072,29 +2079,126 @@ static NSColor *shadowCol;
|
||||||
return [NSColor selectedControlColor];
|
return [NSColor selectedControlColor];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (NSText*) setUpFieldEditorAttributes: (NSText*)textObject
|
||||||
|
{
|
||||||
|
// Reset the string to have a well defined state. The real string gets set later on.
|
||||||
|
[textObject setString: @""];
|
||||||
|
|
||||||
|
[textObject setTextColor: [self textColor]];
|
||||||
|
if ([self isBezeled])
|
||||||
|
{
|
||||||
|
[textObject setBackgroundColor: [NSColor textBackgroundColor]];
|
||||||
|
[textObject setDrawsBackground: YES];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
[textObject setDrawsBackground: NO];
|
||||||
|
}
|
||||||
|
[textObject setFont: [self font]];
|
||||||
|
[textObject setAlignment: [self alignment]];
|
||||||
|
// FIXME: Add base writing direction
|
||||||
|
|
||||||
|
[textObject setEditable: [self isEditable]];
|
||||||
|
[textObject setSelectable: [self isSelectable]];
|
||||||
|
[textObject setRichText: [self allowsEditingTextAttributes]];
|
||||||
|
[textObject setImportsGraphics: [self importsGraphics]];
|
||||||
|
[(NSTextView*)textObject setAllowsUndo: [self allowsUndo]];
|
||||||
|
|
||||||
|
return textObject;
|
||||||
|
}
|
||||||
|
|
||||||
- (void) _setupTextWithFrame: (NSRect)aRect
|
- (void) _setupTextWithFrame: (NSRect)aRect
|
||||||
inView: (NSView*)controlView
|
inView: (NSView*)controlView
|
||||||
editor: (NSText*)textObject
|
editor: (NSText*)textObject
|
||||||
|
delegate: (id)anObject
|
||||||
|
range: (NSRange)selection
|
||||||
{
|
{
|
||||||
NSRect titleRect = [self titleRectForBounds: aRect];
|
NSRect titleRect = [self titleRectForBounds: aRect];
|
||||||
/* See comments in NSStringDrawing.m about the choice of maximum size. */
|
NSRect maxRect;
|
||||||
NSSize maxSize = NSMakeSize(1e6, titleRect.size.height);
|
|
||||||
NSClipView *cv = [[NSClipView alloc]
|
|
||||||
initWithFrame: titleRect];
|
|
||||||
NSTextContainer *ct = [(NSTextView*)textObject textContainer];
|
|
||||||
|
|
||||||
[controlView addSubview: cv];
|
// A clip view should is only created for scrollable text
|
||||||
RELEASE(cv);
|
if ([self isScrollable])
|
||||||
[cv setAutoresizesSubviews: NO];
|
{
|
||||||
[cv setDocumentView: textObject];
|
/* See comments in NSStringDrawing.m about the choice of maximum size. */
|
||||||
[textObject setFrame: NSMakeRect(0, 0, maxSize.width, maxSize.height)];
|
NSSize maxSize = NSMakeSize(1e6, titleRect.size.height);
|
||||||
|
NSClipView *cv = [[NSClipView alloc] initWithFrame: titleRect];
|
||||||
|
NSTextContainer *ct = [(NSTextView*)textObject textContainer];
|
||||||
|
|
||||||
|
maxRect = NSMakeRect(0, 0, maxSize.width, maxSize.height);
|
||||||
|
[controlView addSubview: cv];
|
||||||
|
RELEASE(cv);
|
||||||
|
[cv setAutoresizesSubviews: NO];
|
||||||
|
[cv setDocumentView: textObject];
|
||||||
|
[ct setContainerSize: maxSize];
|
||||||
|
[ct setHeightTracksTextView: NO];
|
||||||
|
[ct setWidthTracksTextView: NO];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
maxRect = titleRect;
|
||||||
|
[controlView addSubview: textObject];
|
||||||
|
}
|
||||||
|
|
||||||
|
[textObject setFrame: maxRect];
|
||||||
[textObject setHorizontallyResizable: NO];
|
[textObject setHorizontallyResizable: NO];
|
||||||
[textObject setVerticallyResizable: NO];
|
[textObject setVerticallyResizable: NO];
|
||||||
[textObject setMaxSize: maxSize];
|
[textObject setMaxSize: maxRect.size];
|
||||||
[textObject setMinSize: titleRect.size];
|
[textObject setMinSize: titleRect.size];
|
||||||
[ct setContainerSize: maxSize];
|
|
||||||
[ct setHeightTracksTextView: NO];
|
if (_formatter != nil)
|
||||||
[ct setWidthTracksTextView: NO];
|
{
|
||||||
|
NSString *contents;
|
||||||
|
|
||||||
|
contents = [_formatter editingStringForObjectValue: _object_value];
|
||||||
|
if (contents == nil)
|
||||||
|
{
|
||||||
|
contents = _contents;
|
||||||
|
}
|
||||||
|
[textObject setText: contents];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (_cell.contents_is_attributed_string == NO)
|
||||||
|
{
|
||||||
|
[textObject setText: _contents];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// The curent text has size 0, so this replaces the whole text.
|
||||||
|
[textObject replaceCharactersInRange: NSMakeRange(0, 0)
|
||||||
|
withAttributedString: (NSAttributedString *)_contents];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[textObject sizeToFit];
|
||||||
|
[textObject setSelectedRange: selection];
|
||||||
|
[textObject scrollRangeToVisible: selection];
|
||||||
|
|
||||||
|
[textObject setDelegate: anObject];
|
||||||
|
[[controlView window] makeFirstResponder: textObject];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**<p>Ends any text editing. This method sets the text object's delegate
|
||||||
|
to nil, and remove the NSClipView and the text object used for editing</p>
|
||||||
|
<p>See Also: -editWithFrame:inView:editor:delegate:event:</p>
|
||||||
|
*/
|
||||||
|
- (void) endEditing: (NSText*)textObject
|
||||||
|
{
|
||||||
|
[textObject setString: @""];
|
||||||
|
[textObject setDelegate: nil];
|
||||||
|
|
||||||
|
if ([self isScrollable])
|
||||||
|
{
|
||||||
|
NSClipView *clipView;
|
||||||
|
|
||||||
|
clipView = (NSClipView*)[textObject superview];
|
||||||
|
[textObject removeFromSuperview];
|
||||||
|
[clipView removeFromSuperview];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
[textObject removeFromSuperview];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -2115,35 +2219,9 @@ static NSColor *shadowCol;
|
||||||
|
|
||||||
[self _setupTextWithFrame: aRect
|
[self _setupTextWithFrame: aRect
|
||||||
inView: controlView
|
inView: controlView
|
||||||
editor: textObject];
|
editor: textObject
|
||||||
|
delegate: anObject
|
||||||
if (_formatter != nil)
|
range: NSMakeRange(0, 0)];
|
||||||
{
|
|
||||||
NSString *contents;
|
|
||||||
|
|
||||||
contents = [_formatter editingStringForObjectValue: _object_value];
|
|
||||||
if (contents == nil)
|
|
||||||
{
|
|
||||||
contents = _contents;
|
|
||||||
}
|
|
||||||
[textObject setText: contents];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (_cell.contents_is_attributed_string == NO)
|
|
||||||
{
|
|
||||||
[textObject setText: _contents];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* FIXME/TODO make sure this is correct. */
|
|
||||||
[textObject setText: [(NSAttributedString *)_contents string]];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
[textObject sizeToFit];
|
|
||||||
|
|
||||||
[textObject setDelegate: anObject];
|
|
||||||
[[controlView window] makeFirstResponder: textObject];
|
|
||||||
|
|
||||||
if ([theEvent type] == NSLeftMouseDown)
|
if ([theEvent type] == NSLeftMouseDown)
|
||||||
{
|
{
|
||||||
|
@ -2151,20 +2229,6 @@ static NSColor *shadowCol;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**<p>Ends any text editing. This method sets the text object's delegate
|
|
||||||
to nil, and remove the NSClipView and the text object used for editing</p>
|
|
||||||
<p>See Also: -editWithFrame:inView:editor:delegate:event:</p>
|
|
||||||
*/
|
|
||||||
- (void) endEditing: (NSText*)textObject
|
|
||||||
{
|
|
||||||
NSClipView *clipView;
|
|
||||||
|
|
||||||
[textObject setDelegate: nil];
|
|
||||||
clipView = (NSClipView*)[textObject superview];
|
|
||||||
[textObject removeFromSuperview];
|
|
||||||
[clipView removeFromSuperview];
|
|
||||||
}
|
|
||||||
|
|
||||||
/** <p> This method does nothing if the <var>controlView</var> is nil,
|
/** <p> This method does nothing if the <var>controlView</var> is nil,
|
||||||
if text object does not exist or if the cell's type is not <ref type="type"
|
if text object does not exist or if the cell's type is not <ref type="type"
|
||||||
id="NSCellType">NSTextCellType</ref> </p>
|
id="NSCellType">NSTextCellType</ref> </p>
|
||||||
|
@ -2181,37 +2245,9 @@ static NSColor *shadowCol;
|
||||||
|
|
||||||
[self _setupTextWithFrame: aRect
|
[self _setupTextWithFrame: aRect
|
||||||
inView: controlView
|
inView: controlView
|
||||||
editor: textObject];
|
editor: textObject
|
||||||
|
delegate: anObject
|
||||||
if (_formatter != nil)
|
range: NSMakeRange(selStart, selLength)];
|
||||||
{
|
|
||||||
NSString *contents;
|
|
||||||
|
|
||||||
contents = [_formatter editingStringForObjectValue: _object_value];
|
|
||||||
if (contents == nil)
|
|
||||||
{
|
|
||||||
contents = _contents;
|
|
||||||
}
|
|
||||||
[textObject setText: contents];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (_cell.contents_is_attributed_string == NO)
|
|
||||||
{
|
|
||||||
[textObject setText: _contents];
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* FIXME/TODO make sure this is correct. */
|
|
||||||
[textObject setText: [(NSAttributedString *)_contents string]];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[textObject sizeToFit];
|
|
||||||
[textObject setSelectedRange: NSMakeRange (selStart, selLength)];
|
|
||||||
[textObject scrollRangeToVisible: NSMakeRange(selStart, selLength)];
|
|
||||||
[textObject setDelegate: anObject];
|
|
||||||
[[controlView window] makeFirstResponder: textObject];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL) sendsActionOnEndEditing
|
- (BOOL) sendsActionOnEndEditing
|
||||||
|
|
|
@ -31,6 +31,7 @@
|
||||||
|
|
||||||
#include <Foundation/NSDebug.h>
|
#include <Foundation/NSDebug.h>
|
||||||
#include <Foundation/NSException.h>
|
#include <Foundation/NSException.h>
|
||||||
|
#include <Foundation/NSNotification.h>
|
||||||
#include "AppKit/NSActionCell.h"
|
#include "AppKit/NSActionCell.h"
|
||||||
#include "AppKit/NSApplication.h"
|
#include "AppKit/NSApplication.h"
|
||||||
#include "AppKit/NSCell.h"
|
#include "AppKit/NSCell.h"
|
||||||
|
@ -47,6 +48,7 @@
|
||||||
static Class usedCellClass;
|
static Class usedCellClass;
|
||||||
static Class cellClass;
|
static Class cellClass;
|
||||||
static Class actionCellClass;
|
static Class actionCellClass;
|
||||||
|
static NSNotificationCenter *nc;
|
||||||
|
|
||||||
/**<p>TODO Description</p>
|
/**<p>TODO Description</p>
|
||||||
*/
|
*/
|
||||||
|
@ -64,6 +66,8 @@ static Class actionCellClass;
|
||||||
cellClass = [NSCell class];
|
cellClass = [NSCell class];
|
||||||
usedCellClass = cellClass;
|
usedCellClass = cellClass;
|
||||||
actionCellClass = [NSActionCell class];
|
actionCellClass = [NSActionCell class];
|
||||||
|
// Cache the notifiaction centre for editing notifications
|
||||||
|
nc = [NSNotificationCenter defaultCenter];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -440,6 +444,21 @@ static Class actionCellClass;
|
||||||
return [_cell formatter];
|
return [_cell formatter];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (NSWritingDirection) baseWritingDirection
|
||||||
|
{
|
||||||
|
return [_cell baseWritingDirection];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) setBaseWritingDirection: (NSWritingDirection)direction
|
||||||
|
{
|
||||||
|
if (_cell)
|
||||||
|
{
|
||||||
|
[_cell setBaseWritingDirection: direction];
|
||||||
|
if (![_cell isKindOfClass: actionCellClass])
|
||||||
|
[self setNeedsDisplay: YES];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**<p>Sends an [NSCell-endEditing:] message to the current object used to
|
/**<p>Sends an [NSCell-endEditing:] message to the current object used to
|
||||||
edit the NSControl. Returns NO if the the currentEditor does not exists,
|
edit the NSControl. Returns NO if the the currentEditor does not exists,
|
||||||
YES otherwise.</p>
|
YES otherwise.</p>
|
||||||
|
@ -508,6 +527,70 @@ static Class actionCellClass;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Text delegate methods
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**<p>Invokes when the text cell starts to be editing.This methods posts
|
||||||
|
a NSControlTextDidBeginEditingNotification with a dictionary containing
|
||||||
|
the NSFieldEditor as user info </p><p>See Also:
|
||||||
|
[NSNotificationCenter-postNotificationName:object:userInfo:]</p>
|
||||||
|
*/
|
||||||
|
- (void) textDidBeginEditing: (NSNotification *)aNotification
|
||||||
|
{
|
||||||
|
NSMutableDictionary *dict;
|
||||||
|
|
||||||
|
dict = [[NSMutableDictionary alloc] initWithDictionary:
|
||||||
|
[aNotification userInfo]];
|
||||||
|
[dict setObject: [aNotification object] forKey: @"NSFieldEditor"];
|
||||||
|
|
||||||
|
[nc postNotificationName: NSControlTextDidBeginEditingNotification
|
||||||
|
object: self
|
||||||
|
userInfo: dict];
|
||||||
|
RELEASE(dict);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**<p>Invokes when the text cell is changed. This methods posts a
|
||||||
|
NSControlTextDidChangeNotification with a dictionary containing the
|
||||||
|
NSFieldEditor as user info </p><p>See Also:
|
||||||
|
[NSNotificationCenter-postNotificationName:object:userInfo:]</p>
|
||||||
|
*/
|
||||||
|
- (void) textDidChange: (NSNotification *)aNotification
|
||||||
|
{
|
||||||
|
NSMutableDictionary *dict;
|
||||||
|
|
||||||
|
dict = [[NSMutableDictionary alloc] initWithDictionary:
|
||||||
|
[aNotification userInfo]];
|
||||||
|
[dict setObject: [aNotification object] forKey: @"NSFieldEditor"];
|
||||||
|
|
||||||
|
[nc postNotificationName: NSControlTextDidChangeNotification
|
||||||
|
object: self
|
||||||
|
userInfo: dict];
|
||||||
|
RELEASE(dict);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**<p>Invokes when the text cell is changed.
|
||||||
|
This methods posts a NSControlTextDidEndEditingNotification
|
||||||
|
a dictionary containing the NSFieldEditor as user info </p><p>See Also:
|
||||||
|
[NSNotificationCenter-postNotificationName:object:userInfo:]</p>
|
||||||
|
*/
|
||||||
|
- (void) textDidEndEditing: (NSNotification *)aNotification
|
||||||
|
{
|
||||||
|
NSMutableDictionary *dict;
|
||||||
|
|
||||||
|
[self validateEditing];
|
||||||
|
[self abortEditing];
|
||||||
|
|
||||||
|
dict = [[NSMutableDictionary alloc] initWithDictionary:
|
||||||
|
[aNotification userInfo]];
|
||||||
|
[dict setObject: [aNotification object] forKey: @"NSFieldEditor"];
|
||||||
|
|
||||||
|
[nc postNotificationName: NSControlTextDidEndEditingNotification
|
||||||
|
object: self
|
||||||
|
userInfo: dict];
|
||||||
|
RELEASE(dict);
|
||||||
|
}
|
||||||
|
|
||||||
/**<p>Recalculates the internal size by sending [NSCell-calcDrawInfo:]
|
/**<p>Recalculates the internal size by sending [NSCell-calcDrawInfo:]
|
||||||
to the cell.</p>
|
to the cell.</p>
|
||||||
*/
|
*/
|
||||||
|
@ -675,7 +758,7 @@ static Class actionCellClass;
|
||||||
return AUTORELEASE([NSAttributedString new]);
|
return AUTORELEASE([NSAttributedString new]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// As this mehtod is not defined for NSActionCell, we have
|
// As this method is not defined for NSActionCell, we have
|
||||||
// to do the validation here.
|
// to do the validation here.
|
||||||
[self validateEditing];
|
[self validateEditing];
|
||||||
|
|
||||||
|
@ -732,8 +815,6 @@ static Class actionCellClass;
|
||||||
unsigned int event_mask = NSLeftMouseDownMask | NSLeftMouseUpMask
|
unsigned int event_mask = NSLeftMouseDownMask | NSLeftMouseUpMask
|
||||||
| NSMouseMovedMask | NSLeftMouseDraggedMask | NSOtherMouseDraggedMask
|
| NSMouseMovedMask | NSLeftMouseDraggedMask | NSOtherMouseDraggedMask
|
||||||
| NSRightMouseDraggedMask;
|
| NSRightMouseDraggedMask;
|
||||||
BOOL mouseUp = NO;
|
|
||||||
int oldActionMask = 0;
|
|
||||||
NSEvent *e = nil;
|
NSEvent *e = nil;
|
||||||
|
|
||||||
// If not enabled ignore mouse clicks
|
// If not enabled ignore mouse clicks
|
||||||
|
@ -747,8 +828,8 @@ static Class actionCellClass;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// stop cell from sending action while tracking the mouse...
|
// Make sure self does not go away during the processing of the event
|
||||||
oldActionMask = [_cell sendActionOn: ([_cell isContinuous]?NSPeriodicMask:0)];
|
RETAIN(self);
|
||||||
|
|
||||||
// loop until mouse goes up
|
// loop until mouse goes up
|
||||||
e = theEvent;
|
e = theEvent;
|
||||||
|
@ -774,7 +855,6 @@ static Class actionCellClass;
|
||||||
|
|
||||||
if (done)
|
if (done)
|
||||||
{
|
{
|
||||||
mouseUp = YES;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -785,19 +865,12 @@ static Class actionCellClass;
|
||||||
dequeue: YES];
|
dequeue: YES];
|
||||||
if ([e type] == NSLeftMouseUp)
|
if ([e type] == NSLeftMouseUp)
|
||||||
{
|
{
|
||||||
mouseUp = YES;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// allow the cell to send actions again...
|
// undo initial retain
|
||||||
[_cell sendActionOn: oldActionMask];
|
RELEASE(self);
|
||||||
|
|
||||||
// Mouse went up inside the control but not inside the cell
|
|
||||||
if (mouseUp)
|
|
||||||
{
|
|
||||||
[self sendAction: [self action] to: [self target]];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL) shouldBeTreatedAsInkEvent: (NSEvent *)theEvent
|
- (BOOL) shouldBeTreatedAsInkEvent: (NSEvent *)theEvent
|
||||||
|
|
|
@ -1686,16 +1686,7 @@ static SEL getSel;
|
||||||
*/
|
*/
|
||||||
- (void) textDidBeginEditing: (NSNotification *)aNotification
|
- (void) textDidBeginEditing: (NSNotification *)aNotification
|
||||||
{
|
{
|
||||||
NSMutableDictionary *dict;
|
[super textDidBeginEditing: aNotification];
|
||||||
|
|
||||||
dict = [[NSMutableDictionary alloc] initWithDictionary:
|
|
||||||
[aNotification userInfo]];
|
|
||||||
AUTORELEASE (dict);
|
|
||||||
[dict setObject: [aNotification object] forKey: @"NSFieldEditor"];
|
|
||||||
|
|
||||||
[nc postNotificationName: NSControlTextDidBeginEditingNotification
|
|
||||||
object: self
|
|
||||||
userInfo: dict];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**<p>Invokes when the text cell is changed. This methods posts a
|
/**<p>Invokes when the text cell is changed. This methods posts a
|
||||||
|
@ -1705,7 +1696,6 @@ static SEL getSel;
|
||||||
*/
|
*/
|
||||||
- (void) textDidChange: (NSNotification *)aNotification
|
- (void) textDidChange: (NSNotification *)aNotification
|
||||||
{
|
{
|
||||||
NSMutableDictionary *dict;
|
|
||||||
NSFormatter *formatter;
|
NSFormatter *formatter;
|
||||||
|
|
||||||
// MacOS-X asks us to inform the cell if possible.
|
// MacOS-X asks us to inform the cell if possible.
|
||||||
|
@ -1713,16 +1703,9 @@ static SEL getSel;
|
||||||
@selector(textDidChange:)])
|
@selector(textDidChange:)])
|
||||||
[_selectedCell textDidChange: aNotification];
|
[_selectedCell textDidChange: aNotification];
|
||||||
|
|
||||||
dict = [[NSMutableDictionary alloc] initWithDictionary:
|
[super textDidChange: aNotification];
|
||||||
[aNotification userInfo]];
|
|
||||||
AUTORELEASE (dict);
|
|
||||||
[dict setObject: [aNotification object] forKey: @"NSFieldEditor"];
|
|
||||||
|
|
||||||
[nc postNotificationName: NSControlTextDidChangeNotification
|
formatter = [_selectedCell formatter];
|
||||||
object: self
|
|
||||||
userInfo: dict];
|
|
||||||
|
|
||||||
formatter = [_cell formatter];
|
|
||||||
if (formatter != nil)
|
if (formatter != nil)
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
|
@ -1742,9 +1725,14 @@ static SEL getSel;
|
||||||
|
|
||||||
if (wasAccepted == NO)
|
if (wasAccepted == NO)
|
||||||
{
|
{
|
||||||
[_delegate control:self
|
SEL sel = @selector(control:didFailToValidatePartialString:errorDescription:);
|
||||||
didFailToValidatePartialString: partialString
|
|
||||||
errorDescription: error];
|
if ([_delegate respondsToSelector: sel])
|
||||||
|
{
|
||||||
|
[_delegate control: self
|
||||||
|
didFailToValidatePartialString: partialString
|
||||||
|
errorDescription: error];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newString != nil)
|
if (newString != nil)
|
||||||
|
@ -1772,22 +1760,9 @@ static SEL getSel;
|
||||||
*/
|
*/
|
||||||
- (void) textDidEndEditing: (NSNotification *)aNotification
|
- (void) textDidEndEditing: (NSNotification *)aNotification
|
||||||
{
|
{
|
||||||
NSMutableDictionary *dict;
|
|
||||||
id textMovement;
|
id textMovement;
|
||||||
|
|
||||||
[self validateEditing];
|
[super textDidEndEditing: aNotification];
|
||||||
|
|
||||||
[_selectedCell endEditing: [aNotification object]];
|
|
||||||
_textObject = nil;
|
|
||||||
|
|
||||||
dict = [[NSMutableDictionary alloc] initWithDictionary:
|
|
||||||
[aNotification userInfo]];
|
|
||||||
AUTORELEASE (dict);
|
|
||||||
[dict setObject: [aNotification object] forKey: @"NSFieldEditor"];
|
|
||||||
|
|
||||||
[nc postNotificationName: NSControlTextDidEndEditingNotification
|
|
||||||
object: self
|
|
||||||
userInfo: dict];
|
|
||||||
|
|
||||||
textMovement = [[aNotification userInfo] objectForKey: @"NSTextMovement"];
|
textMovement = [[aNotification userInfo] objectForKey: @"NSTextMovement"];
|
||||||
if (textMovement)
|
if (textMovement)
|
||||||
|
@ -1888,7 +1863,7 @@ static SEL getSel;
|
||||||
NSFormatter *formatter;
|
NSFormatter *formatter;
|
||||||
id newObjectValue;
|
id newObjectValue;
|
||||||
|
|
||||||
formatter = [_cell formatter];
|
formatter = [_selectedCell formatter];
|
||||||
|
|
||||||
if ([formatter getObjectValue: &newObjectValue
|
if ([formatter getObjectValue: &newObjectValue
|
||||||
forString: [_textObject text]
|
forString: [_textObject text]
|
||||||
|
|
|
@ -5200,59 +5200,29 @@ static BOOL selectContiguousRegion(NSTableView *self,
|
||||||
|
|
||||||
- (void) textDidBeginEditing: (NSNotification *)aNotification
|
- (void) textDidBeginEditing: (NSNotification *)aNotification
|
||||||
{
|
{
|
||||||
NSMutableDictionary *d;
|
[super textDidBeginEditing: aNotification];
|
||||||
|
|
||||||
d = [NSMutableDictionary dictionaryWithDictionary:
|
|
||||||
[aNotification userInfo]];
|
|
||||||
[d setObject: [aNotification object] forKey: @"NSFieldEditor"];
|
|
||||||
[nc postNotificationName: NSControlTextDidBeginEditingNotification
|
|
||||||
object: self
|
|
||||||
userInfo: d];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) textDidChange: (NSNotification *)aNotification
|
- (void) textDidChange: (NSNotification *)aNotification
|
||||||
{
|
{
|
||||||
NSMutableDictionary *d;
|
|
||||||
|
|
||||||
// MacOS-X asks us to inform the cell if possible.
|
// MacOS-X asks us to inform the cell if possible.
|
||||||
if ((_editedCell != nil) && [_editedCell respondsToSelector:
|
if ((_editedCell != nil) && [_editedCell respondsToSelector:
|
||||||
@selector(textDidChange:)])
|
@selector(textDidChange:)])
|
||||||
[_editedCell textDidChange: aNotification];
|
[_editedCell textDidChange: aNotification];
|
||||||
|
|
||||||
d = [NSMutableDictionary dictionaryWithDictionary:
|
[super textDidChange: aNotification];
|
||||||
[aNotification userInfo]];
|
|
||||||
[d setObject: [aNotification object] forKey: @"NSFieldEditor"];
|
|
||||||
[nc postNotificationName: NSControlTextDidChangeNotification
|
|
||||||
object: self
|
|
||||||
userInfo: d];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) textDidEndEditing: (NSNotification *)aNotification
|
- (void) textDidEndEditing: (NSNotification *)aNotification
|
||||||
{
|
{
|
||||||
NSMutableDictionary *d;
|
|
||||||
id textMovement;
|
id textMovement;
|
||||||
int row, column;
|
int row, column;
|
||||||
|
|
||||||
[self validateEditing];
|
|
||||||
|
|
||||||
[_editedCell endEditing: [aNotification object]];
|
|
||||||
[self setNeedsDisplayInRect:
|
|
||||||
[self frameOfCellAtColumn: _editedColumn row: _editedRow]];
|
|
||||||
_textObject = nil;
|
|
||||||
DESTROY (_editedCell);
|
|
||||||
/* Save values */
|
/* Save values */
|
||||||
row = _editedRow;
|
row = _editedRow;
|
||||||
column = _editedColumn;
|
column = _editedColumn;
|
||||||
/* Only then Reset them */
|
|
||||||
_editedColumn = -1;
|
|
||||||
_editedRow = -1;
|
|
||||||
|
|
||||||
d = [NSMutableDictionary dictionaryWithDictionary:
|
[super textDidEndEditing: aNotification];
|
||||||
[aNotification userInfo]];
|
|
||||||
[d setObject: [aNotification object] forKey: @"NSFieldEditor"];
|
|
||||||
[nc postNotificationName: NSControlTextDidEndEditingNotification
|
|
||||||
object: self
|
|
||||||
userInfo: d];
|
|
||||||
|
|
||||||
textMovement = [[aNotification userInfo] objectForKey: @"NSTextMovement"];
|
textMovement = [[aNotification userInfo] objectForKey: @"NSTextMovement"];
|
||||||
if (textMovement)
|
if (textMovement)
|
||||||
|
|
|
@ -488,32 +488,17 @@ static Class textFieldCellClass;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**<p>Posts a NSControlTextDidBeginEditingNotification notification with object
|
|
||||||
self and a NSDictionary containing the NSFieldEditor for key
|
|
||||||
as user Info</p>
|
|
||||||
*/
|
|
||||||
- (void) textDidBeginEditing: (NSNotification *)aNotification
|
- (void) textDidBeginEditing: (NSNotification *)aNotification
|
||||||
{
|
{
|
||||||
NSDictionary *notifDict;
|
[super textDidBeginEditing: aNotification];
|
||||||
|
|
||||||
notifDict = [NSDictionary dictionaryWithObject:[aNotification object]
|
|
||||||
forKey: @"NSFieldEditor"];
|
|
||||||
|
|
||||||
[nc postNotificationName: NSControlTextDidBeginEditingNotification
|
|
||||||
object: self
|
|
||||||
userInfo: notifDict];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) textDidChange: (NSNotification *)aNotification
|
- (void) textDidChange: (NSNotification *)aNotification
|
||||||
{
|
{
|
||||||
NSDictionary *d;
|
|
||||||
NSFormatter *formatter;
|
NSFormatter *formatter;
|
||||||
|
|
||||||
d = [NSDictionary dictionaryWithObject: [aNotification object]
|
[super textDidChange: aNotification];
|
||||||
forKey: @"NSFieldEditor"];
|
|
||||||
[nc postNotificationName: NSControlTextDidChangeNotification
|
|
||||||
object: self
|
|
||||||
userInfo: d];
|
|
||||||
|
|
||||||
formatter = [_cell formatter];
|
formatter = [_cell formatter];
|
||||||
if (formatter != nil)
|
if (formatter != nil)
|
||||||
|
@ -559,26 +544,14 @@ static Class textFieldCellClass;
|
||||||
NSLog (@"Unimplemented: should delete last typed character");
|
NSLog (@"Unimplemented: should delete last typed character");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) textDidEndEditing: (NSNotification *)aNotification
|
- (void) textDidEndEditing: (NSNotification *)aNotification
|
||||||
{
|
{
|
||||||
NSDictionary *d;
|
|
||||||
id textMovement;
|
id textMovement;
|
||||||
|
|
||||||
[self validateEditing];
|
[super textDidEndEditing: aNotification];
|
||||||
|
|
||||||
[_cell endEditing: [aNotification object]];
|
|
||||||
|
|
||||||
_text_object = nil;
|
|
||||||
|
|
||||||
d = [NSDictionary dictionaryWithObject: [aNotification object]
|
|
||||||
forKey: @"NSFieldEditor"];
|
|
||||||
[nc postNotificationName: NSControlTextDidEndEditingNotification
|
|
||||||
object: self
|
|
||||||
userInfo: d];
|
|
||||||
|
|
||||||
textMovement = [[aNotification userInfo] objectForKey: @"NSTextMovement"];
|
textMovement = [[aNotification userInfo] objectForKey: @"NSTextMovement"];
|
||||||
if (textMovement)
|
if (textMovement)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue