mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 21:40:48 +00:00
Addition of typesetter classes.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@6665 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
da977d8fff
commit
79d8220583
4 changed files with 431 additions and 0 deletions
|
@ -1,3 +1,9 @@
|
||||||
|
2000-06-11 Jonathan Gapen <jagapen@home.com>
|
||||||
|
|
||||||
|
* 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 <FredKiefer@gmx.de>
|
2000-06-11 Fred Kiefer <FredKiefer@gmx.de>
|
||||||
|
|
||||||
* Headers/gnustep/gui/NSFont.h:
|
* Headers/gnustep/gui/NSFont.h:
|
||||||
|
|
131
Headers/gnustep/gui/NSTypesetter.h
Normal file
131
Headers/gnustep/gui/NSTypesetter.h
Normal file
|
@ -0,0 +1,131 @@
|
||||||
|
/*
|
||||||
|
NSTypesetter.h
|
||||||
|
|
||||||
|
The text layout class(es)
|
||||||
|
|
||||||
|
Copyright (C) 1999 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
Author: Jonathan Gapen <jagapen@home.com>
|
||||||
|
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 <AppKit/NSFont.h>
|
||||||
|
#include <AppKit/NSLayoutManager.h>
|
||||||
|
#include <Foundation/NSGeometry.h>
|
||||||
|
#include <Foundation/NSRange.h>
|
||||||
|
|
||||||
|
@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 */
|
208
Source/NSSimpleHorizontalTypesetter.m
Normal file
208
Source/NSSimpleHorizontalTypesetter.m
Normal file
|
@ -0,0 +1,208 @@
|
||||||
|
/*
|
||||||
|
NSSimpleHorizontalTypesetter.m
|
||||||
|
|
||||||
|
The text layout class for horizontal scripts
|
||||||
|
|
||||||
|
Copyright (C) 2000 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
Author: Jonathan Gapen <jagapen@home.com>
|
||||||
|
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 <AppKit/NSLayoutManager.h>
|
||||||
|
#include <AppKit/NSTypesetter.h>
|
||||||
|
#include <Foundation/NSLock.h>
|
||||||
|
|
||||||
|
|
||||||
|
@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
|
86
Source/NSTypesetter.m
Normal file
86
Source/NSTypesetter.m
Normal file
|
@ -0,0 +1,86 @@
|
||||||
|
/*
|
||||||
|
NSTypesetter.m
|
||||||
|
|
||||||
|
The text layout class
|
||||||
|
|
||||||
|
Copyright (C) 2000 Free Software Foundation, Inc.
|
||||||
|
|
||||||
|
Author: Jonathan Gapen <jagapen@home.com>
|
||||||
|
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 <AppKit/NSLayoutManager.h>
|
||||||
|
#include <AppKit/NSTypesetter.h>
|
||||||
|
#include <Foundation/NSLock.h>
|
||||||
|
|
||||||
|
|
||||||
|
@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
|
Loading…
Add table
Add a link
Reference in a new issue