mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-25 19:21:16 +00:00
Add new MacOSX 10.3 methods and constants.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@25470 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
1d293756e0
commit
ced527d0e5
5 changed files with 274 additions and 128 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,4 +1,12 @@
|
||||||
2007-09-08 Fred Kiefer <FredKiefer@gmx.de>
|
2007-09-09 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
|
* Headers/AppKit/NSTextField.h:
|
||||||
|
* Headers/AppKit/NSTextFieldCell.h:
|
||||||
|
* Source/NSTextField.m,
|
||||||
|
* Source/NSTextFieldCell.m: Add new MacOSX 10.3 methods and
|
||||||
|
constants.
|
||||||
|
|
||||||
|
2007-09-09 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
* Headers/AppKit/NSBitmapImageRep.h,
|
* Headers/AppKit/NSBitmapImageRep.h,
|
||||||
* Headers/AppKit/NSResponder.h: Correct conditional compilation.
|
* Headers/AppKit/NSResponder.h: Correct conditional compilation.
|
||||||
|
|
|
@ -29,8 +29,11 @@
|
||||||
|
|
||||||
#ifndef _GNUstep_H_NSTextField
|
#ifndef _GNUstep_H_NSTextField
|
||||||
#define _GNUstep_H_NSTextField
|
#define _GNUstep_H_NSTextField
|
||||||
|
#import <GNUstepBase/GSVersionMacros.h>
|
||||||
|
|
||||||
#include <AppKit/NSControl.h>
|
#include <AppKit/NSControl.h>
|
||||||
|
// For NSTextFieldBezelStyle
|
||||||
|
#include <AppKit/NSTextFieldCell.h>
|
||||||
|
|
||||||
@class NSNotification;
|
@class NSNotification;
|
||||||
@class NSColor;
|
@class NSColor;
|
||||||
|
@ -114,6 +117,11 @@
|
||||||
- (void)setTitleWithMnemonic:(NSString *)aString;
|
- (void)setTitleWithMnemonic:(NSString *)aString;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if OS_API_VERSION(MAC_OS_X_VERSION_10_2, GS_API_LATEST)
|
||||||
|
- (void)setBezelStyle:(NSTextFieldBezelStyle)style;
|
||||||
|
- (NSTextFieldBezelStyle)bezelStyle;
|
||||||
|
#endif
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
#endif // _GNUstep_H_NSTextField
|
#endif // _GNUstep_H_NSTextField
|
||||||
|
|
|
@ -29,21 +29,39 @@
|
||||||
|
|
||||||
#ifndef _GNUstep_H_NSTextFieldCell
|
#ifndef _GNUstep_H_NSTextFieldCell
|
||||||
#define _GNUstep_H_NSTextFieldCell
|
#define _GNUstep_H_NSTextFieldCell
|
||||||
|
#import <GNUstepBase/GSVersionMacros.h>
|
||||||
|
|
||||||
#include <AppKit/NSActionCell.h>
|
#include <AppKit/NSActionCell.h>
|
||||||
|
|
||||||
@class NSColor;
|
@class NSColor;
|
||||||
|
|
||||||
|
#if OS_API_VERSION(MAC_OS_X_VERSION_10_2, GS_API_LATEST)
|
||||||
|
typedef enum _NSTextFieldBezelStyle
|
||||||
|
{
|
||||||
|
NSTextFieldSquareBezel = 0,
|
||||||
|
NSTextFieldRoundedBezel
|
||||||
|
} NSTextFieldBezelStyle;
|
||||||
|
#endif
|
||||||
|
|
||||||
@interface NSTextFieldCell : NSActionCell <NSCoding>
|
@interface NSTextFieldCell : NSActionCell <NSCoding>
|
||||||
{
|
{
|
||||||
// Attributes
|
// Attributes
|
||||||
NSColor *_background_color;
|
NSColor *_background_color;
|
||||||
NSColor *_text_color;
|
NSColor *_text_color;
|
||||||
|
|
||||||
|
#if OS_API_VERSION(MAC_OS_X_VERSION_10_2, GS_API_LATEST)
|
||||||
|
NSTextFieldBezelStyle _bezelStyle;
|
||||||
|
#else
|
||||||
|
unsigned int _bezelStyle;
|
||||||
|
#endif
|
||||||
|
|
||||||
// Think of the following ones as of two BOOL ivars
|
// Think of the following ones as of two BOOL ivars
|
||||||
#define _textfieldcell_draws_background _cell.subclass_bool_one
|
#define _textfieldcell_draws_background _cell.subclass_bool_one
|
||||||
// The following is different from _draws_background
|
// The following is different from _draws_background
|
||||||
// if we are using a semi-transparent color.
|
// if we are using a semi-transparent color.
|
||||||
#define _textfieldcell_is_opaque _cell.subclass_bool_two
|
#define _textfieldcell_is_opaque _cell.subclass_bool_two
|
||||||
|
#define _textfieldcell_placeholder_is_attributed_string _cell.subclass_bool_three
|
||||||
|
id _placeholder;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -58,6 +76,18 @@
|
||||||
- (void)setBackgroundColor:(NSColor *)aColor;
|
- (void)setBackgroundColor:(NSColor *)aColor;
|
||||||
- (NSColor *)backgroundColor;
|
- (NSColor *)backgroundColor;
|
||||||
|
|
||||||
|
#if OS_API_VERSION(MAC_OS_X_VERSION_10_2, GS_API_LATEST)
|
||||||
|
- (void)setBezelStyle:(NSTextFieldBezelStyle)style;
|
||||||
|
- (NSTextFieldBezelStyle)bezelStyle;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if OS_API_VERSION(MAC_OS_X_VERSION_10_3, GS_API_LATEST)
|
||||||
|
- (void)setPlaceholderString:(NSString *)string;
|
||||||
|
- (NSString *)placeholderString;
|
||||||
|
- (void)setPlaceholderAttributedString:(NSAttributedString *)string;
|
||||||
|
- (NSAttributedString *)placeholderAttributedString;
|
||||||
|
#endif
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
#endif // _GNUstep_H_NSTextFieldCell
|
#endif // _GNUstep_H_NSTextFieldCell
|
||||||
|
|
|
@ -83,11 +83,12 @@ static Class textFieldCellClass;
|
||||||
//
|
//
|
||||||
- (id) initWithFrame: (NSRect)frameRect
|
- (id) initWithFrame: (NSRect)frameRect
|
||||||
{
|
{
|
||||||
[super initWithFrame: frameRect];
|
self = [super initWithFrame: frameRect];
|
||||||
[_cell setState: 1];
|
if (self == nil)
|
||||||
|
return self;
|
||||||
|
|
||||||
[_cell setBezeled: YES];
|
[_cell setBezeled: YES];
|
||||||
[_cell setSelectable: YES];
|
[_cell setSelectable: YES];
|
||||||
[_cell setEnabled: YES];
|
|
||||||
[_cell setEditable: YES];
|
[_cell setEditable: YES];
|
||||||
[_cell setDrawsBackground: YES];
|
[_cell setDrawsBackground: YES];
|
||||||
_text_object = nil;
|
_text_object = nil;
|
||||||
|
@ -99,8 +100,7 @@ static Class textFieldCellClass;
|
||||||
{
|
{
|
||||||
if (_delegate != nil)
|
if (_delegate != nil)
|
||||||
{
|
{
|
||||||
[nc removeObserver: _delegate name: nil object: self];
|
[self setDelegate: nil];
|
||||||
_delegate = nil;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
|
@ -157,28 +157,28 @@ static Class textFieldCellClass;
|
||||||
if ([self isSelectable] && (_super_view != nil))
|
if ([self isSelectable] && (_super_view != nil))
|
||||||
{
|
{
|
||||||
if (_text_object)
|
if (_text_object)
|
||||||
[_text_object selectAll: self];
|
[_text_object selectAll: self];
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NSText *text = [_window fieldEditor: YES forObject: self];
|
NSText *text = [_window fieldEditor: YES forObject: self];
|
||||||
int length;
|
int length;
|
||||||
|
|
||||||
if ([text superview] != nil)
|
if ([text superview] != nil)
|
||||||
if ([text resignFirstResponder] == NO)
|
if ([text resignFirstResponder] == NO)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// [NSCursor hide];
|
// [NSCursor hide];
|
||||||
/* [self stringValue] generates a call to validateEditing
|
/* [self stringValue] generates a call to validateEditing
|
||||||
so we need to call it before setting up the _text_object */
|
so we need to call it before setting up the _text_object */
|
||||||
length = [[self stringValue] length];
|
length = [[self stringValue] length];
|
||||||
_text_object = [_cell setUpFieldEditorAttributes: text];
|
_text_object = [_cell setUpFieldEditorAttributes: text];
|
||||||
[_cell selectWithFrame: _bounds
|
[_cell selectWithFrame: _bounds
|
||||||
inView: self
|
inView: self
|
||||||
editor: _text_object
|
editor: _text_object
|
||||||
delegate: self
|
delegate: self
|
||||||
start: 0
|
start: 0
|
||||||
length: length];
|
length: length];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -526,35 +526,35 @@ static Class textFieldCellClass;
|
||||||
|
|
||||||
partialString = [_text_object string];
|
partialString = [_text_object string];
|
||||||
wasAccepted = [formatter isPartialStringValid: partialString
|
wasAccepted = [formatter isPartialStringValid: partialString
|
||||||
newEditingString: &newString
|
newEditingString: &newString
|
||||||
errorDescription: &error];
|
errorDescription: &error];
|
||||||
|
|
||||||
if (wasAccepted == NO)
|
if (wasAccepted == NO)
|
||||||
{
|
{
|
||||||
SEL sel = @selector(control:didFailToValidatePartialString:errorDescription:);
|
SEL sel = @selector(control:didFailToValidatePartialString:errorDescription:);
|
||||||
|
|
||||||
if ([_delegate respondsToSelector: sel])
|
if ([_delegate respondsToSelector: sel])
|
||||||
{
|
{
|
||||||
[_delegate control: self
|
[_delegate control: self
|
||||||
didFailToValidatePartialString: partialString
|
didFailToValidatePartialString: partialString
|
||||||
errorDescription: error];
|
errorDescription: error];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newString != nil)
|
if (newString != nil)
|
||||||
{
|
{
|
||||||
NSLog (@"Unimplemented: should set string to %@", newString);
|
NSLog (@"Unimplemented: should set string to %@", newString);
|
||||||
// FIXME ! This would reset editing !
|
// FIXME ! This would reset editing !
|
||||||
//[_text_object setString: newString];
|
//[_text_object setString: newString];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (wasAccepted == NO)
|
if (wasAccepted == NO)
|
||||||
{
|
{
|
||||||
// FIXME: Need to delete last typed character (?!)
|
// FIXME: Need to delete last typed character (?!)
|
||||||
NSLog (@"Unimplemented: should delete last typed character");
|
NSLog (@"Unimplemented: should delete last typed character");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -568,27 +568,27 @@ static Class textFieldCellClass;
|
||||||
if (textMovement)
|
if (textMovement)
|
||||||
{
|
{
|
||||||
switch ([(NSNumber *)textMovement intValue])
|
switch ([(NSNumber *)textMovement intValue])
|
||||||
{
|
{
|
||||||
case NSReturnTextMovement:
|
case NSReturnTextMovement:
|
||||||
if ([self sendAction: [self action] to: [self target]] == NO)
|
if ([self sendAction: [self action] to: [self target]] == NO)
|
||||||
{
|
{
|
||||||
if ([self performKeyEquivalent: [_window currentEvent]] == NO)
|
if ([self performKeyEquivalent: [_window currentEvent]] == NO)
|
||||||
[self selectText: self];
|
[self selectText: self];
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case NSTabTextMovement:
|
case NSTabTextMovement:
|
||||||
[_window selectKeyViewFollowingView: self];
|
[_window selectKeyViewFollowingView: self];
|
||||||
|
|
||||||
if ([_window firstResponder] == _window)
|
if ([_window firstResponder] == _window)
|
||||||
[self selectText: self];
|
[self selectText: self];
|
||||||
break;
|
break;
|
||||||
case NSBacktabTextMovement:
|
case NSBacktabTextMovement:
|
||||||
[_window selectKeyViewPrecedingView: self];
|
[_window selectKeyViewPrecedingView: self];
|
||||||
|
|
||||||
if ([_window firstResponder] == _window)
|
if ([_window firstResponder] == _window)
|
||||||
[self selectText: self];
|
[self selectText: self];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -598,9 +598,9 @@ static Class textFieldCellClass;
|
||||||
return NO;
|
return NO;
|
||||||
|
|
||||||
if (_delegate && [_delegate respondsToSelector:
|
if (_delegate && [_delegate respondsToSelector:
|
||||||
@selector(control:textShouldBeginEditing:)])
|
@selector(control:textShouldBeginEditing:)])
|
||||||
return [_delegate control: self
|
return [_delegate control: self
|
||||||
textShouldBeginEditing: textObject];
|
textShouldBeginEditing: textObject];
|
||||||
else
|
else
|
||||||
return YES;
|
return YES;
|
||||||
}
|
}
|
||||||
|
@ -614,13 +614,13 @@ static Class textFieldCellClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ([_delegate respondsToSelector:
|
if ([_delegate respondsToSelector:
|
||||||
@selector(control:textShouldEndEditing:)])
|
@selector(control:textShouldEndEditing:)])
|
||||||
{
|
{
|
||||||
if ([_delegate control: self textShouldEndEditing: textObject] == NO)
|
if ([_delegate control: self textShouldEndEditing: textObject] == NO)
|
||||||
{
|
{
|
||||||
NSBeep ();
|
NSBeep ();
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ([_delegate respondsToSelector: @selector(control:isValidObject:)] == YES)
|
if ([_delegate respondsToSelector: @selector(control:isValidObject:)] == YES)
|
||||||
|
@ -631,14 +631,14 @@ static Class textFieldCellClass;
|
||||||
formatter = [_cell formatter];
|
formatter = [_cell formatter];
|
||||||
|
|
||||||
if ([formatter getObjectValue: &newObjectValue
|
if ([formatter getObjectValue: &newObjectValue
|
||||||
forString: [_text_object text]
|
forString: [_text_object text]
|
||||||
errorDescription: NULL] == YES)
|
errorDescription: NULL] == YES)
|
||||||
{
|
{
|
||||||
if ([_delegate control: self isValidObject: newObjectValue] == NO)
|
if ([_delegate control: self isValidObject: newObjectValue] == NO)
|
||||||
{
|
{
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// In all other cases
|
// In all other cases
|
||||||
|
@ -651,8 +651,8 @@ static Class textFieldCellClass;
|
||||||
[_delegate respondsToSelector: @selector(control:textView:doCommandBySelector:)])
|
[_delegate respondsToSelector: @selector(control:textView:doCommandBySelector:)])
|
||||||
{
|
{
|
||||||
return [_delegate control: self
|
return [_delegate control: self
|
||||||
textView: textView
|
textView: textView
|
||||||
doCommandBySelector: command];
|
doCommandBySelector: command];
|
||||||
}
|
}
|
||||||
|
|
||||||
return NO;
|
return NO;
|
||||||
|
@ -687,6 +687,16 @@ static Class textFieldCellClass;
|
||||||
[_cell setTitleWithMnemonic: aString];
|
[_cell setTitleWithMnemonic: aString];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void)setBezelStyle:(NSTextFieldBezelStyle)style
|
||||||
|
{
|
||||||
|
[_cell setBezelStyle: style];
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSTextFieldBezelStyle)bezelStyle
|
||||||
|
{
|
||||||
|
return [_cell bezelStyle];
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// NSCoding protocol
|
// NSCoding protocol
|
||||||
//
|
//
|
||||||
|
|
|
@ -29,16 +29,17 @@
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include <Foundation/NSNotification.h>
|
#include <Foundation/NSNotification.h>
|
||||||
|
#include "AppKit/NSAttributedString.h"
|
||||||
#include "AppKit/NSColor.h"
|
#include "AppKit/NSColor.h"
|
||||||
#include "AppKit/NSControl.h"
|
#include "AppKit/NSControl.h"
|
||||||
|
#include "AppKit/NSEvent.h"
|
||||||
#include "AppKit/NSFont.h"
|
#include "AppKit/NSFont.h"
|
||||||
#include "AppKit/NSGraphics.h"
|
#include "AppKit/NSGraphics.h"
|
||||||
#include "AppKit/NSTextFieldCell.h"
|
#include "AppKit/NSTextFieldCell.h"
|
||||||
#include "AppKit/NSText.h"
|
#include "AppKit/NSText.h"
|
||||||
#include "AppKit/NSEvent.h"
|
|
||||||
|
|
||||||
static NSColor *bgCol;
|
static NSColor *bgCol;
|
||||||
static NSColor *txtCol;
|
static NSColor *txtCol;
|
||||||
|
|
||||||
@interface NSTextFieldCell (PrivateColor)
|
@interface NSTextFieldCell (PrivateColor)
|
||||||
+ (void) _systemColorsChanged: (NSNotification*)n;
|
+ (void) _systemColorsChanged: (NSNotification*)n;
|
||||||
|
@ -46,12 +47,13 @@ static NSColor *txtCol;
|
||||||
- (BOOL) _isOpaque;
|
- (BOOL) _isOpaque;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation NSTextFieldCell (PrivateColor)
|
@implementation NSTextFieldCell (PrivateColor)
|
||||||
+ (void) _systemColorsChanged: (NSNotification*)n
|
+ (void) _systemColorsChanged: (NSNotification*)n
|
||||||
{
|
{
|
||||||
ASSIGN(bgCol, [NSColor textBackgroundColor]);
|
ASSIGN(bgCol, [NSColor textBackgroundColor]);
|
||||||
ASSIGN(txtCol, [NSColor textColor]);
|
ASSIGN(txtCol, [NSColor textColor]);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (BOOL) _isOpaque
|
- (BOOL) _isOpaque
|
||||||
{
|
{
|
||||||
if (_textfieldcell_draws_background == NO
|
if (_textfieldcell_draws_background == NO
|
||||||
|
@ -70,10 +72,10 @@ static NSColor *txtCol;
|
||||||
{
|
{
|
||||||
[self setVersion: 2];
|
[self setVersion: 2];
|
||||||
[[NSNotificationCenter defaultCenter]
|
[[NSNotificationCenter defaultCenter]
|
||||||
addObserver: self
|
addObserver: self
|
||||||
selector: @selector(_systemColorsChanged:)
|
selector: @selector(_systemColorsChanged:)
|
||||||
name: NSSystemColorsDidChangeNotification
|
name: NSSystemColorsDidChangeNotification
|
||||||
object: nil];
|
object: nil];
|
||||||
[self _systemColorsChanged: nil];
|
[self _systemColorsChanged: nil];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -81,20 +83,16 @@ static NSColor *txtCol;
|
||||||
//
|
//
|
||||||
// Initialization
|
// Initialization
|
||||||
//
|
//
|
||||||
- (id) init
|
|
||||||
{
|
|
||||||
[self initTextCell: @""];
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
|
|
||||||
- (id) initTextCell: (NSString *)aString
|
- (id) initTextCell: (NSString *)aString
|
||||||
{
|
{
|
||||||
[super initTextCell: aString];
|
self = [super initTextCell: aString];
|
||||||
|
if (self == nil)
|
||||||
|
return self;
|
||||||
|
|
||||||
ASSIGN(_text_color, txtCol);
|
ASSIGN(_text_color, txtCol);
|
||||||
ASSIGN(_background_color, bgCol);
|
ASSIGN(_background_color, bgCol);
|
||||||
_textfieldcell_draws_background = NO;
|
// _textfieldcell_draws_background = NO;
|
||||||
_textfieldcell_is_opaque = NO;
|
// _textfieldcell_is_opaque = NO;
|
||||||
_action_mask = NSKeyUpMask | NSKeyDownMask;
|
_action_mask = NSKeyUpMask | NSKeyDownMask;
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
@ -103,6 +101,7 @@ static NSColor *txtCol;
|
||||||
{
|
{
|
||||||
RELEASE(_background_color);
|
RELEASE(_background_color);
|
||||||
RELEASE(_text_color);
|
RELEASE(_text_color);
|
||||||
|
RELEASE(_placeholder);
|
||||||
[super dealloc];
|
[super dealloc];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,8 +109,9 @@ static NSColor *txtCol;
|
||||||
{
|
{
|
||||||
NSTextFieldCell *c = [super copyWithZone: zone];
|
NSTextFieldCell *c = [super copyWithZone: zone];
|
||||||
|
|
||||||
RETAIN (_background_color);
|
RETAIN(_background_color);
|
||||||
RETAIN (_text_color);
|
RETAIN(_text_color);
|
||||||
|
c->_placeholder = [_placeholder copyWithZone: zone];
|
||||||
|
|
||||||
return c;
|
return c;
|
||||||
}
|
}
|
||||||
|
@ -176,6 +176,52 @@ static NSColor *txtCol;
|
||||||
return _text_color;
|
return _text_color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (void) setBezelStyle: (NSTextFieldBezelStyle)style
|
||||||
|
{
|
||||||
|
_bezelStyle = style;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSTextFieldBezelStyle) bezelStyle
|
||||||
|
{
|
||||||
|
return _bezelStyle;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSAttributedString*) placeholderAttributedString
|
||||||
|
{
|
||||||
|
if (_textfieldcell_placeholder_is_attributed_string == YES)
|
||||||
|
{
|
||||||
|
return (NSAttributedString*)_placeholder;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (NSString*) placeholderString
|
||||||
|
{
|
||||||
|
if (_textfieldcell_placeholder_is_attributed_string == YES)
|
||||||
|
{
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return (NSString*)_placeholder;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) setPlaceholderAttributedString: (NSAttributedString*)string
|
||||||
|
{
|
||||||
|
ASSIGN(_placeholder, string);
|
||||||
|
_textfieldcell_placeholder_is_attributed_string = YES;
|
||||||
|
}
|
||||||
|
|
||||||
|
- (void) setPlaceholderString: (NSString*)string
|
||||||
|
{
|
||||||
|
ASSIGN(_placeholder, string);
|
||||||
|
_textfieldcell_placeholder_is_attributed_string = NO;
|
||||||
|
}
|
||||||
|
|
||||||
- (NSText *) setUpFieldEditorAttributes: (NSText *)textObject
|
- (NSText *) setUpFieldEditorAttributes: (NSText *)textObject
|
||||||
{
|
{
|
||||||
textObject = [super setUpFieldEditorAttributes: textObject];
|
textObject = [super setUpFieldEditorAttributes: textObject];
|
||||||
|
@ -190,19 +236,63 @@ static NSColor *txtCol;
|
||||||
if (_textfieldcell_draws_background)
|
if (_textfieldcell_draws_background)
|
||||||
{
|
{
|
||||||
if ([self isEnabled])
|
if ([self isEnabled])
|
||||||
{
|
{
|
||||||
[_background_color set];
|
[_background_color set];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
[[NSColor controlBackgroundColor] set];
|
[[NSColor controlBackgroundColor] set];
|
||||||
}
|
}
|
||||||
NSRectFill ([self drawingRectForBounds: cellFrame]);
|
NSRectFill([self drawingRectForBounds: cellFrame]);
|
||||||
}
|
}
|
||||||
|
|
||||||
[super drawInteriorWithFrame: cellFrame inView: controlView];
|
[super drawInteriorWithFrame: cellFrame inView: controlView];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Attributed string that will be displayed.
|
||||||
|
*/
|
||||||
|
- (NSAttributedString*)_drawAttributedString
|
||||||
|
{
|
||||||
|
NSAttributedString *attrStr;
|
||||||
|
|
||||||
|
attrStr = [super _drawAttributedString];
|
||||||
|
if (attrStr == nil)
|
||||||
|
{
|
||||||
|
attrStr = [self placeholderAttributedString];
|
||||||
|
if (attrStr == nil)
|
||||||
|
{
|
||||||
|
NSString *string;
|
||||||
|
NSDictionary *attributes;
|
||||||
|
NSMutableDictionary *newAttribs;
|
||||||
|
|
||||||
|
string = [self placeholderString];
|
||||||
|
if (string == nil)
|
||||||
|
{
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
|
attributes = [self _nonAutoreleasedTypingAttributes];
|
||||||
|
newAttribs = [NSMutableDictionary
|
||||||
|
dictionaryWithDictionary: attributes];
|
||||||
|
[newAttribs setObject: [NSColor disabledControlTextColor]
|
||||||
|
forKey: NSForegroundColorAttributeName];
|
||||||
|
|
||||||
|
return AUTORELEASE([[NSAttributedString alloc]
|
||||||
|
initWithString: string
|
||||||
|
attributes: newAttribs]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return attrStr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return attrStr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
- (BOOL) isOpaque
|
- (BOOL) isOpaque
|
||||||
{
|
{
|
||||||
return _textfieldcell_is_opaque;
|
return _textfieldcell_is_opaque;
|
||||||
|
@ -244,9 +334,9 @@ static NSColor *txtCol;
|
||||||
[self setTextColor: textColor];
|
[self setTextColor: textColor];
|
||||||
if ([aDecoder containsValueForKey: @"NSDrawsBackground"])
|
if ([aDecoder containsValueForKey: @"NSDrawsBackground"])
|
||||||
{
|
{
|
||||||
[self setDrawsBackground: [aDecoder decodeBoolForKey:
|
[self setDrawsBackground: [aDecoder decodeBoolForKey:
|
||||||
@"NSDrawsBackground"]];
|
@"NSDrawsBackground"]];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -254,19 +344,19 @@ static NSColor *txtCol;
|
||||||
|
|
||||||
if ([aDecoder versionForClassName:@"NSTextFieldCell"] < 2)
|
if ([aDecoder versionForClassName:@"NSTextFieldCell"] < 2)
|
||||||
{
|
{
|
||||||
/* Replace the old default _action_mask with the new default one
|
/* Replace the old default _action_mask with the new default one
|
||||||
if it's set. There isn't really a way to modify this value
|
if it's set. There isn't really a way to modify this value
|
||||||
on an NSTextFieldCell encoded in a .gorm file. The old default value
|
on an NSTextFieldCell encoded in a .gorm file. The old default value
|
||||||
causes problems with newer NSTableViews which uses this to discern
|
causes problems with newer NSTableViews which uses this to discern
|
||||||
whether it should trackMouse:inRect:ofView:untilMouseUp: or not.
|
whether it should trackMouse:inRect:ofView:untilMouseUp: or not.
|
||||||
This also disables the action from being sent on an uneditable and
|
This also disables the action from being sent on an uneditable and
|
||||||
unselectable text fields.
|
unselectable text fields.
|
||||||
*/
|
*/
|
||||||
if (_action_mask == NSLeftMouseUpMask)
|
if (_action_mask == NSLeftMouseUpMask)
|
||||||
{
|
{
|
||||||
_action_mask = NSKeyUpMask | NSKeyDownMask;
|
_action_mask = NSKeyUpMask | NSKeyDownMask;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[aDecoder decodeValueOfObjCType: @encode(id) at: &_background_color];
|
[aDecoder decodeValueOfObjCType: @encode(id) at: &_background_color];
|
||||||
[aDecoder decodeValueOfObjCType: @encode(id) at: &_text_color];
|
[aDecoder decodeValueOfObjCType: @encode(id) at: &_text_color];
|
||||||
|
|
Loading…
Reference in a new issue