diff --git a/ChangeLog b/ChangeLog index 1c8e20888..16662d3e6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2000-06-11 Jonathan Gapen + + * Headers/gnustep/gui/NSTypesetter.h: New file. + * Source/NSTypesetter.m: Skeleton implementation from Apple docs. + * Source/NSSimpleHorizontalTypesetter.m: As above. + 2000-06-11 Fred Kiefer * Headers/gnustep/gui/NSFont.h: diff --git a/Headers/gnustep/gui/NSTypesetter.h b/Headers/gnustep/gui/NSTypesetter.h new file mode 100644 index 000000000..0d183ff34 --- /dev/null +++ b/Headers/gnustep/gui/NSTypesetter.h @@ -0,0 +1,131 @@ +/* + NSTypesetter.h + + The text layout class(es) + + Copyright (C) 1999 Free Software Foundation, Inc. + + Author: Jonathan Gapen + Date: May 2000 + + 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_NSTypesetter +#define GNUstep_H_NSTypesetter + +#include +#include +#include +#include + +@class NSParagraphStyle, NSTextContainer, NSTextStorage; + +// FIXME - when the use of this type becomes clear +typedef void NSTypesetterGlyphInfo; + +typedef enum +{ + NSLayoutNotDone = 1, + NSLayoutDone, + NSLayoutCantFit, + NSLayoutOutOfGlyphs +} NSLayoutStatus; + + +@interface NSTypesetter : NSObject +{ +} + ++ (NSSize) printingAdjustmentsInLayoutManager: (NSLayoutManager *)layoutManager + forNominallySpacedGlyphRange: (NSRange)glyphRange + packedGlyphs: (const unsigned char *)glyphs + count: (unsigned)packedGlyphCount; + ++ (id) sharedSystemTypesetter; + +- (float) baselineOffsetInLayoutManager: (NSLayoutManager *)layoutManager + glyphIndex: (unsigned)glyphIndex; + +- (void) layoutGlyphsInLayoutManager: (NSLayoutManager *)layoutManager + startingAtGlyphIndex: (unsigned)glyphIndex + maxNumberOfLineFragments: (unsigned)maxFragments + nextGlyphIndex: (unsigned *)nextGlyph; + +@end + +// +// Basic horizontal (l-to-r or r-to-l) typesetter +// + +@interface NSSimpleHorizontalTypesetter : NSTypesetter +{ +} + +// +// Get the shared horizontal typesetter +// ++ (id) sharedInstance; + +// +// Get information about a typesetter +// +- (NSTypesetterGlyphInfo *) baseOfTypesetterGlyphInfo; +- (unsigned) capacityOfTypesetterGlyphInfo; +- (NSTextContainer *) currentContainer; +- (NSLayoutManager *) currentLayoutManager; +- (NSParagraphStyle *) currentParagraphStyle; +- (NSTextStorage *) currentTextStorage; +- (unsigned) firstIndexOfCurrentLineFragment; +- (unsigned) sizeOfTypesetterGlyphInfo; + +// +// Glyph layout +// +- (void) breakLineAtIndex: (unsigned)location; +- (void) fullJustifyLineAtGlyphIndex: (unsigned)glyphIndex; +- (unsigned) glyphIndexToBreakLineByHyphenatingWordAtIndex: (unsigned)charIndex; +- (unsigned) glyphIndexToBreakLineByWrappingAtIndex: (unsigned)charIndex; +- (void) insertGlyph: (NSGlyph)glyph + atGlyphIndex: (unsigned) glyphIndex + characterIndex: (unsigned) charIndex; +- (NSLayoutStatus) layoutControlGlyphForLineFragment: (NSRect)lineFrag; +- (NSLayoutStatus) layoutGlyphsInHorizontalLineFragment: (NSRect *)fragRect + baseline: (float *)baseline; +- (void) layoutGlyphsInLayoutManager: (NSLayoutManager *)layoutManager + startingAtGlyphIndex: (unsigned)startGlyphIndex + maxNumberOfLineFragments: (unsigned)maxNumLines + nextGlyphIndex: (unsigned *)nextGlyph; +- (void) layoutTab; +- (void) typesetterLaidOneGlyph: (NSTypesetterGlyphInfo *)glyphInfo; +- (void) updateCurGlyphOffset; +- (void) willSetLineFragmentRect: (NSRect *)aRect + forGlyphRange: (NSRange)aRange + usedRect: (NSRect *)usedRect; + +// +// Caching +// +- (void) clearAttributesCache; +- (void) clearGlyphCache; +- (void) fillAttributesCache; +- (unsigned) growGlyphCaches: (unsigned)desiredCapacity + fillGlyphInfo: (BOOL)flag; +@end + +#endif /* GNUstep_H_NSTypesetter */ diff --git a/Source/NSSimpleHorizontalTypesetter.m b/Source/NSSimpleHorizontalTypesetter.m new file mode 100644 index 000000000..5282bf249 --- /dev/null +++ b/Source/NSSimpleHorizontalTypesetter.m @@ -0,0 +1,208 @@ +/* + NSSimpleHorizontalTypesetter.m + + The text layout class for horizontal scripts + + Copyright (C) 2000 Free Software Foundation, Inc. + + Author: Jonathan Gapen + Date: May 2000 + + 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 +#include +#include + + +@implementation NSSimpleHorizontalTypesetter + +static NSSimpleHorizontalTypesetter *_gs_horiz_typesetter = nil; +static NSLock *_gs_horiz_typesetter_lock; + ++ (void) initialize +{ + if (self == [NSSimpleHorizontalTypesetter class]) + { + [self setVersion: 1]; + _gs_horiz_typesetter_lock = [NSLock new]; + } +} + ++ (id) sharedInstance +{ + if (_gs_horiz_typesetter == nil) + { + [_gs_horiz_typesetter_lock lock]; + + if (_gs_horiz_typesetter == nil) + _gs_horiz_typesetter = RETAIN([NSSimpleHorizontalTypesetter new]); + + [_gs_horiz_typesetter_lock unlock]; + } + + return _gs_horiz_typesetter; +} + +// +// Get information about the typesetter +// + +- (NSTypesetterGlyphInfo *) baseOfTypesetterGlyphInfo +{ + return nil; +} + +- (unsigned) capacityOfTypesetterGlyphInfo +{ + return 0; +} + +- (NSTextContainer *) currentContainer +{ + return nil; +} + +- (NSLayoutManager *) currentLayoutManager +{ + return nil; +} + +- (NSParagraphStyle *) currentParagraphStyle +{ + return nil; +} + +- (NSTextStorage *) currentTextStorage +{ + return nil; +} + +- (unsigned) firstIndexOfCurrentLineFragment +{ + return 0; +} + +- (unsigned) sizeOfTypesetterGlyphInfo +{ + return 0; +} + +// +// Glyph layout +// + +- (void) breakLineAtIndex: (unsigned)location +{ + return; +} + +- (void) fullJustifyLineAtGlyphIndex: (unsigned)glyphIndex +{ + return; +} + +- (unsigned) glyphIndexToBreakLineByHyphenatingWordAtIndex: (unsigned)charIndex +{ + return 0; +} + +- (unsigned) glyphIndexToBreakLineByWrappingAtIndex: (unsigned)charIndex +{ + return 0; +} + +- (void) insertGlyph: (NSGlyph)glyph + atGlyphIndex: (unsigned)glyphIndex + characterIndex: (unsigned)charIndex +{ + return; +} + +- (NSLayoutStatus) layoutControlGlyphForLineFragment: (NSRect)fragRect +{ + return NSLayoutOutOfGlyphs; +} + +- (NSLayoutStatus) layoutGlyphsInHorizontalLineFragment: (NSRect *)fragRect + baseline: (float *)baseline +{ + *fragRect = NSZeroRect; + *baseline = 0.0; + + return NSLayoutOutOfGlyphs; +} + +- (void) layoutGlyphsInLayoutManager: (NSLayoutManager *)layoutManager + startingAtGlyphIndex: (unsigned)glyphIndex + maxNumberOfLineFragments: (unsigned)maxNumLines + nextGlyphIndex: (unsigned *)nextGlyph +{ + if (nextGlyph != NULL) + *nextGlyph = glyphIndex; +} + +- (void) layoutTab +{ + return; +} + +- (void) typesetterLaidOneGlyph: (NSTypesetterGlyphInfo *)glyphInfo +{ + return; +} + +- (void) updateCurGlyphOffset +{ + return; +} + +- (void) willSetLineFragmentRect: (NSRect *)aRect + forGlyphRange: (NSRange)aRange + usedRect: (NSRect *)usedRect +{ + return; +} + +// +// Caching +// + +- (void) clearAttributesCache +{ + return; +} + +- (void) clearGlyphCache +{ + return; +} + +- (void) fillAttributesCache +{ + return; +} + +- (unsigned) growGlyphCaches: (unsigned)newCapacity + fillGlyphInfo: (BOOL)flag +{ + return 0; +} + +@end diff --git a/Source/NSTypesetter.m b/Source/NSTypesetter.m new file mode 100644 index 000000000..4175bb033 --- /dev/null +++ b/Source/NSTypesetter.m @@ -0,0 +1,86 @@ +/* + NSTypesetter.m + + The text layout class + + Copyright (C) 2000 Free Software Foundation, Inc. + + Author: Jonathan Gapen + Date: May 2000 + + 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 +#include +#include + + +@implementation NSTypesetter + +static NSTypesetter *_gs_system_typesetter = nil; +static NSLock *_gs_typesetter_lock; + ++ (void) initialize +{ + if (self == [NSTypesetter class]) + { + [self setVersion: 1]; + _gs_typesetter_lock = [NSLock new]; + } +} + ++ (id) sharedSystemTypesetter +{ + if (_gs_system_typesetter == nil) + { + [_gs_typesetter_lock lock]; + + if (_gs_system_typesetter == nil) + _gs_system_typesetter = [NSSimpleHorizontalTypesetter sharedInstance]; + + [_gs_typesetter_lock unlock]; + } + + return _gs_system_typesetter; +} + ++ (NSSize) printingAdjustmentsInLayoutManager: (NSLayoutManager *)layoutManager + forNominallySpacedGlyphRange: (NSRange)glyphRange + packedGlyphs: (const unsigned char *)glyphs + count: (unsigned)packedGlyphCount +{ + return NSMakeSize(0, 0); +} + +- (float) baselineOffsetInLayoutManager: (NSLayoutManager *)layoutManager + glyphIndex: (unsigned)glyphIndex +{ + return 0.0; +} + +- (void) layoutGlyphsInLayoutManager: (NSLayoutManager *)layoutManager + startingAtGlyphIndex: (unsigned)glyphIndex + maxNumberOfLineFragments: (unsigned)maxFragments + nextGlyphIndex: (unsigned *)nextGlyph +{ + if (nextGlyph != NULL) + *nextGlyph = glyphIndex; +} + +@end