mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-26 02:01:04 +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];
|
||||||
|
@ -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,13 +29,14 @@
|
||||||
|
|
||||||
#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;
|
||||||
|
@ -52,6 +53,7 @@ static NSColor *txtCol;
|
||||||
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
|
||||||
|
@ -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];
|
||||||
|
@ -197,12 +243,56 @@ static NSColor *txtCol;
|
||||||
{
|
{
|
||||||
[[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;
|
||||||
|
|
Loading…
Reference in a new issue