mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-24 18:31:20 +00:00
Merge in text-system-branch.
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@15720 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
d137be7d9f
commit
765f78b9e5
4 changed files with 0 additions and 552 deletions
|
@ -1,141 +0,0 @@
|
|||
/*
|
||||
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
|
||||
{
|
||||
NSTypesetterGlyphInfo *_glyphInfo;
|
||||
unsigned _capacityGlyphInfo;
|
||||
unsigned _sizeGlyphInfo;
|
||||
NSLayoutManager *_currentLayoutManager;
|
||||
NSTextStorage *_currentTextStorage;
|
||||
NSTextContainer *_currentContainer;
|
||||
NSParagraphStyle *_currentParagraphStyle;
|
||||
unsigned _firstIndexOfCurrentLineFragment;
|
||||
|
||||
unsigned _currentGlyphIndex;
|
||||
}
|
||||
|
||||
//
|
||||
// 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 */
|
|
@ -1,47 +0,0 @@
|
|||
/*
|
||||
GSSimpleLayoutManager.h
|
||||
|
||||
First GNUstep layout manager, extracted from NSText
|
||||
|
||||
Copyright (C) 2000 Free Software Foundation, Inc.
|
||||
|
||||
Author: Fred Kiefer <FredKiefer@gmx.de>
|
||||
Date: September 2000
|
||||
Extracted from NSText, reorganised to specification
|
||||
|
||||
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 __GSSimpleLayoutManager_h_GNUSTEP_GUI_INCLUDE
|
||||
#define __GSSimpleLayoutManager_h_GNUSTEP_GUI_INCLUDE
|
||||
|
||||
#include <Foundation/NSGeometry.h>
|
||||
#include <Foundation/NSArray.h>
|
||||
|
||||
#include <AppKit/NSTextView.h>
|
||||
#include <AppKit/NSLayoutManager.h>
|
||||
|
||||
@interface GSSimpleLayoutManager: NSLayoutManager
|
||||
{
|
||||
// contains private _GNULineLayoutInfo objects
|
||||
NSMutableArray *_lineLayoutInfo;
|
||||
NSRect _rects[4];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
#endif /*__NSCharacterSet_h_GNUSTEP_BASE_INCLUDE*/
|
|
@ -1,278 +0,0 @@
|
|||
/*
|
||||
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 _glyphInfo;
|
||||
}
|
||||
|
||||
- (unsigned) capacityOfTypesetterGlyphInfo
|
||||
{
|
||||
return _capacityGlyphInfo;
|
||||
}
|
||||
|
||||
- (NSTextContainer *) currentContainer
|
||||
{
|
||||
return _currentContainer;
|
||||
}
|
||||
|
||||
- (NSLayoutManager *) currentLayoutManager
|
||||
{
|
||||
return _currentLayoutManager;
|
||||
}
|
||||
|
||||
- (NSParagraphStyle *) currentParagraphStyle
|
||||
{
|
||||
return _currentParagraphStyle;
|
||||
}
|
||||
|
||||
- (NSTextStorage *) currentTextStorage
|
||||
{
|
||||
return _currentTextStorage;
|
||||
}
|
||||
|
||||
- (unsigned) firstIndexOfCurrentLineFragment
|
||||
{
|
||||
return _firstIndexOfCurrentLineFragment;
|
||||
}
|
||||
|
||||
- (unsigned) sizeOfTypesetterGlyphInfo
|
||||
{
|
||||
return _sizeGlyphInfo;
|
||||
}
|
||||
|
||||
//
|
||||
// Glyph layout
|
||||
//
|
||||
|
||||
- (void) breakLineAtIndex: (unsigned)location
|
||||
{
|
||||
// Find an index to break the line, if inside a word try to hyphenate and
|
||||
// add a hyphen, if not possibe wrap.
|
||||
// Do justification acording to the paragraph style.
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
/*
|
||||
I think that this is the main interface of the typesetter to the outside
|
||||
world. So this must be protected by a lock!!
|
||||
|
||||
|
||||
*/
|
||||
- (void) layoutGlyphsInLayoutManager: (NSLayoutManager *)layoutManager
|
||||
startingAtGlyphIndex: (unsigned)glyphIndex
|
||||
maxNumberOfLineFragments: (unsigned)maxNumLines
|
||||
nextGlyphIndex: (unsigned *)nextGlyph
|
||||
{
|
||||
unsigned charIndex;
|
||||
unsigned numLines = 0;
|
||||
NSLayoutStatus status;
|
||||
|
||||
[_gs_horiz_typesetter_lock lock];
|
||||
// Set up all the internal state variables
|
||||
// Don't assign here
|
||||
_currentLayoutManager = layoutManager;
|
||||
_currentTextStorage = [layoutManager textStorage];
|
||||
// This probably is wrong as it does layouting itself
|
||||
_currentContainer = [layoutManager textContainerForGlyphAtIndex: glyphIndex
|
||||
effectiveRange: NULL];
|
||||
charIndex = [layoutManager characterIndexForGlyphAtIndex: glyphIndex];
|
||||
_currentParagraphStyle = [_currentTextStorage
|
||||
attribute: NSParagraphStyleAttributeName
|
||||
atIndex: charIndex
|
||||
effectiveRange: NULL];
|
||||
_firstIndexOfCurrentLineFragment = glyphIndex;
|
||||
|
||||
|
||||
do {
|
||||
float baseline = 0;
|
||||
NSRect lineFragmentRect;
|
||||
NSRect usedRect;
|
||||
|
||||
// Get the current lineFragmentRect from the layout manager / container
|
||||
usedRect = lineFragmentRect;
|
||||
|
||||
// Build up a line
|
||||
status = [self layoutGlyphsInHorizontalLineFragment: &usedRect
|
||||
baseline: &baseline];
|
||||
if (status == NSLayoutOutOfGlyphs)
|
||||
{
|
||||
[self growGlyphCaches: [self sizeOfTypesetterGlyphInfo] + 100
|
||||
fillGlyphInfo: YES];
|
||||
continue;
|
||||
}
|
||||
|
||||
[self willSetLineFragmentRect: lineFragmentRect
|
||||
forGlyphRange: NSMakeRange(_firstIndexOfCurrentLineFragment,
|
||||
_currentGlyphIndex - _firstIndexOfCurrentLineFragment)
|
||||
usedRect: usedRect];
|
||||
[self breakLineAtIndex: _currentGlyphIndex];
|
||||
|
||||
_firstIndexOfCurrentLineFragment = _currentGlyphIndex + 1;
|
||||
numLines++;
|
||||
} while((numLines <= maxNumLines) && (status));
|
||||
|
||||
if (nextGlyph != NULL)
|
||||
*nextGlyph = _firstIndexOfCurrentLineFragment;
|
||||
|
||||
[_gs_horiz_typesetter_lock unlock];
|
||||
}
|
||||
|
||||
/*
|
||||
This is probably the second method to be called from the outside
|
||||
*/
|
||||
- (float) baselineOffsetInLayoutManager: (NSLayoutManager *)layoutManager
|
||||
glyphIndex: (unsigned)glyphIndex
|
||||
{
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
- (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
|
||||
|
|
@ -1,86 +0,0 @@
|
|||
/*
|
||||
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…
Reference in a new issue