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:
fredkiefer 2007-09-09 15:30:06 +00:00
parent 1d293756e0
commit ced527d0e5
5 changed files with 274 additions and 128 deletions

View file

@ -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/NSResponder.h: Correct conditional compilation.

View file

@ -29,8 +29,11 @@
#ifndef _GNUstep_H_NSTextField
#define _GNUstep_H_NSTextField
#import <GNUstepBase/GSVersionMacros.h>
#include <AppKit/NSControl.h>
// For NSTextFieldBezelStyle
#include <AppKit/NSTextFieldCell.h>
@class NSNotification;
@class NSColor;
@ -114,6 +117,11 @@
- (void)setTitleWithMnemonic:(NSString *)aString;
#endif
#if OS_API_VERSION(MAC_OS_X_VERSION_10_2, GS_API_LATEST)
- (void)setBezelStyle:(NSTextFieldBezelStyle)style;
- (NSTextFieldBezelStyle)bezelStyle;
#endif
@end
#endif // _GNUstep_H_NSTextField

View file

@ -29,21 +29,39 @@
#ifndef _GNUstep_H_NSTextFieldCell
#define _GNUstep_H_NSTextFieldCell
#import <GNUstepBase/GSVersionMacros.h>
#include <AppKit/NSActionCell.h>
@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>
{
// Attributes
NSColor *_background_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
#define _textfieldcell_draws_background _cell.subclass_bool_one
// The following is different from _draws_background
// if we are using a semi-transparent color.
#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;
- (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
#endif // _GNUstep_H_NSTextFieldCell

View file

@ -83,11 +83,12 @@ static Class textFieldCellClass;
//
- (id) initWithFrame: (NSRect)frameRect
{
[super initWithFrame: frameRect];
[_cell setState: 1];
self = [super initWithFrame: frameRect];
if (self == nil)
return self;
[_cell setBezeled: YES];
[_cell setSelectable: YES];
[_cell setEnabled: YES];
[_cell setEditable: YES];
[_cell setDrawsBackground: YES];
_text_object = nil;
@ -99,8 +100,7 @@ static Class textFieldCellClass;
{
if (_delegate != nil)
{
[nc removeObserver: _delegate name: nil object: self];
_delegate = nil;
[self setDelegate: nil];
}
[super dealloc];
@ -687,6 +687,16 @@ static Class textFieldCellClass;
[_cell setTitleWithMnemonic: aString];
}
- (void)setBezelStyle:(NSTextFieldBezelStyle)style
{
[_cell setBezelStyle: style];
}
- (NSTextFieldBezelStyle)bezelStyle
{
return [_cell bezelStyle];
}
//
// NSCoding protocol
//

View file

@ -29,13 +29,14 @@
#include "config.h"
#include <Foundation/NSNotification.h>
#include "AppKit/NSAttributedString.h"
#include "AppKit/NSColor.h"
#include "AppKit/NSControl.h"
#include "AppKit/NSEvent.h"
#include "AppKit/NSFont.h"
#include "AppKit/NSGraphics.h"
#include "AppKit/NSTextFieldCell.h"
#include "AppKit/NSText.h"
#include "AppKit/NSEvent.h"
static NSColor *bgCol;
static NSColor *txtCol;
@ -52,6 +53,7 @@ static NSColor *txtCol;
ASSIGN(bgCol, [NSColor textBackgroundColor]);
ASSIGN(txtCol, [NSColor textColor]);
}
- (BOOL) _isOpaque
{
if (_textfieldcell_draws_background == NO
@ -81,20 +83,16 @@ static NSColor *txtCol;
//
// Initialization
//
- (id) init
{
[self initTextCell: @""];
return self;
}
- (id) initTextCell: (NSString *)aString
{
[super initTextCell: aString];
self = [super initTextCell: aString];
if (self == nil)
return self;
ASSIGN(_text_color, txtCol);
ASSIGN(_background_color, bgCol);
_textfieldcell_draws_background = NO;
_textfieldcell_is_opaque = NO;
// _textfieldcell_draws_background = NO;
// _textfieldcell_is_opaque = NO;
_action_mask = NSKeyUpMask | NSKeyDownMask;
return self;
}
@ -103,6 +101,7 @@ static NSColor *txtCol;
{
RELEASE(_background_color);
RELEASE(_text_color);
RELEASE(_placeholder);
[super dealloc];
}
@ -112,6 +111,7 @@ static NSColor *txtCol;
RETAIN(_background_color);
RETAIN(_text_color);
c->_placeholder = [_placeholder copyWithZone: zone];
return c;
}
@ -176,6 +176,52 @@ static NSColor *txtCol;
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
{
textObject = [super setUpFieldEditorAttributes: textObject];
@ -203,6 +249,50 @@ static NSColor *txtCol;
[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
{
return _textfieldcell_is_opaque;