* added NSStringDrawing.m and NSStringDrawing.h which implement the

frontend portion of the NSString additions Category from 4.1.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@2915 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Felipe A. Rodriguez 1998-08-08 16:09:35 +00:00
parent 035b3fa393
commit 3769b37842
5 changed files with 129 additions and 2 deletions

View file

@ -1,4 +1,9 @@
<<<<<<< ChangeLog
Sat Aug 8 1998 Felipe A. Rodriguez <far@ix.netcom.com>
* added NSStringDrawing.m and NSStringDrawing.h which implement the
frontend portion of the NSString additions Category from 4.1.
Tues Aug 4 1998 Felipe A. Rodriguez <far@ix.netcom.com>
* NSSplitView in initWithFrame changed default back color to light gray.

View file

@ -0,0 +1,75 @@
/*
NSStringDrawing.h
Category which adds measure capabilities to NSString.
Copyright (C) 1997 Free Software Foundation, Inc.
Author: Felipe A. Rodriguez <far@ix.netcom.com>
Date: Aug 1998
This file is part of the GNUstep GUI Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#ifndef _GNUstep_H_NSStringDrawing
#define _GNUstep_H_NSStringDrawing
#include <Foundation/NSString.h>
#include <Foundation/NSGeometry.h>
#include <gnustep/base/preface.h>
// global NSString attribute names used in ascessing
// the respective property in a text attributes
// dictionary. if the key is not in the dictionary the
// default value is assumed
NSString *NSFontAttributeName; // NSFont, defaults to Helvetica 12
NSString *NSParagraphStyleAttributeName; // NSParagraphStyle, default to
// defaultParagraphStyle
NSString *NSForegroundColorAttributeName; // NSColor, default is blackColor
NSString *NSUnderlineStyleAttributeName; // int, default 0 = no underline
NSString *NSSuperscriptAttributeName; // int, default 0
NSString *NSBackgroundColorAttributeName; // NSColor,default nil =no back col
NSString *NSAttachmentAttributeName; // NSTextAttachment, default nil
NSString *NSLigatureAttributeName; // int, default 1
// 1 = default ligatures,
// 0 = no ligatures,
// 2 = all ligatures
NSString *NSBaselineOffsetAttributeName; // float, default 0 in points;
// offset from baseline,
NSString *NSKernAttributeName; // float, amount to modify default
// kerning, if 0 kerning is off
enum
{ // Currently supported values for
NSSingleUnderlineStyle = 1 // NSUnderlineStyleAttributeName
};
@interface NSString(NSStringDrawing)
- (NSSize)sizeWithAttributes:(NSDictionary *)attrs;
@end
#ifdef OS_4_2
@interface NSAttributedString(NSStringDrawing)
- (NSSize)size;
@end
#endif /* OS_4_2 */
#endif /* _GNUstep_H_NSStringDrawing */

View file

@ -95,6 +95,7 @@ NSSliderCell.m \
NSSpellChecker.m \
NSSpellServer.m \
NSSplitView.m \
NSStringDrawing.m \
NSText.m \
NSTextField.m \
NSTextFieldCell.m \
@ -179,6 +180,7 @@ AppKit/NSSpellChecker.h \
AppKit/NSSpellProtocol.h \
AppKit/NSSpellServer.h \
AppKit/NSSplitView.h \
AppKit/NSStringDrawing.h \
AppKit/NSText.h \
AppKit/NSTextField.h \
AppKit/NSTextFieldCell.h \

View file

@ -42,10 +42,10 @@
ADDITIONAL_CPPFLAGS = -DGNUSTEP_INSTALL_LIBDIR=\"$(GNUSTEP_LIBRARIES_ROOT)\"
# Additional flags to pass to the Objective-C compiler
ADDITIONAL_OBJCFLAGS = -Wall
ADDITIONAL_OBJCFLAGS = -g -Wall
# Additional flags to pass to the C compiler
ADDITIONAL_CFLAGS =
ADDITIONAL_CFLAGS = -g
# Additional include directories the compiler should search
ADDITIONAL_INCLUDE_DIRS = -I../Headers

45
Source/NSStringDrawing.m Normal file
View file

@ -0,0 +1,45 @@
/*
NSStringDrawing.m
Category which adds measure capabilities to NSString.
Copyright (C) 1997 Free Software Foundation, Inc.
Author: Felipe A. Rodriguez <far@ix.netcom.com>
Date: Aug 1998
This file is part of the GNUstep GUI Library.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public
License along with this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include <AppKit/NSStringDrawing.h>
#include <AppKit/AppKit.h>
@implementation NSString(NSStringDrawing)
- (NSSize)sizeWithAttributes:(NSDictionary *)attrs
{
NSFont *font;
// if font is not
if(!(font = [attrs objectForKey:NSFontAttributeName])) // specified, use
font = [NSFont userFontOfSize:12]; // the default
return NSMakeSize([font widthOfString:self], [font pointSize]);
}
@end