mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-12-04 20:05:03 +00:00
Fixed: nib2cib with CPTextView works. Editable, Selectable, RichText, StringValue, BackgroundColor, InsertionPointColor works
This commit is contained in:
1 parent
1f369b47d7
commit
3581ac5ebd
13 files changed
+527
-472
No files matched your search
+409
-371
@@ -50,372 +50,6 @@ function _RectEqualToRectHorizontally(lhsRect, rhsRect)
|
||||
|
||||
_oncontextmenuhandler = function () { return false; };
|
||||
|
||||
@implementation CPArray (SortedSearching)
|
||||
|
||||
- (unsigned)_indexOfObject:(id)anObject sortedByFunction:(Function)aFunction context:(id)aContext
|
||||
{
|
||||
var length= [self count];
|
||||
|
||||
if (!aFunction)
|
||||
return CPNotFound;
|
||||
|
||||
if (length === 0)
|
||||
return -1;
|
||||
|
||||
var mid,
|
||||
c,
|
||||
first = 0,
|
||||
last = length - 1;
|
||||
|
||||
while (first <= last)
|
||||
{
|
||||
mid = FLOOR((first + last) / 2);
|
||||
c = aFunction(anObject, self[mid], aContext);
|
||||
|
||||
if (c > 0)
|
||||
{
|
||||
first = mid + 1;
|
||||
}
|
||||
else if (c < 0)
|
||||
{
|
||||
last = mid - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
while (mid < length - 1 && aFunction(anObject, self[mid + 1], aContext) == CPOrderedSame)
|
||||
mid++;
|
||||
|
||||
return mid;
|
||||
}
|
||||
}
|
||||
|
||||
var result = -first - 1;
|
||||
|
||||
return result >= 0 ? result : CPNotFound;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
var _sortRange = function(location, anObject)
|
||||
{
|
||||
if (CPLocationInRange(location, anObject._range))
|
||||
return CPOrderedSame;
|
||||
else if (CPMaxRange(anObject._range) <= location)
|
||||
return CPOrderedDescending;
|
||||
else
|
||||
return CPOrderedAscending;
|
||||
}
|
||||
|
||||
var _objectWithLocationInRange = function(aList, aLocation)
|
||||
{
|
||||
var index = [aList _indexOfObject: aLocation sortedByFunction:_sortRange context:nil];
|
||||
|
||||
if (index != CPNotFound)
|
||||
return aList[index];
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
var _objectsInRange = function(aList, aRange)
|
||||
{
|
||||
var list = [],
|
||||
c = aList.length,
|
||||
location = aRange.location;
|
||||
|
||||
for (var i = 0; i < c; i++)
|
||||
{
|
||||
if (CPLocationInRange(location, aList[i]._range))
|
||||
{
|
||||
list.push(aList[i]);
|
||||
|
||||
if (CPMaxRange(aList[i]._range) <= CPMaxRange(aRange))
|
||||
location = CPMaxRange(aList[i]._range);
|
||||
else
|
||||
break;
|
||||
}
|
||||
else if (CPLocationInRange(CPMaxRange(aRange), aList[i]._range))
|
||||
{
|
||||
list.push(aList[i]);
|
||||
break;
|
||||
}
|
||||
else if (CPRangeInRange(aRange, aList[i]._range))
|
||||
{
|
||||
list.push(aList[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
@implementation _CPLineFragment : CPObject
|
||||
{
|
||||
CPArray _glyphsFrames @accessors(getter=glyphFrames);
|
||||
|
||||
BOOL _isInvalid;
|
||||
CGRect _fragmentRect;
|
||||
CGRect _usedRect;
|
||||
CGPoint _location;
|
||||
CPRange _range;
|
||||
CPTextContainer _textContainer;
|
||||
CPMutableArray _runs;
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Init methods
|
||||
|
||||
- (id)createDOMElementWithText:(CPString)aString andFont:(CPFont)aFont andColor:(CPColor)aColor
|
||||
{
|
||||
#if PLATFORM(DOM)
|
||||
var style,
|
||||
span = document.createElement("span");
|
||||
|
||||
span.oncontextmenu = span.onmousedown = span.onselectstart = _oncontextmenuhandler;
|
||||
// span.contentEditable = true; // this unfortunately does not work to make native pasting work on safari
|
||||
|
||||
style = span.style;
|
||||
style.position = "absolute";
|
||||
style.visibility = "visible";
|
||||
style.padding = "0px";
|
||||
style.margin = "0px";
|
||||
style.whiteSpace = "pre";
|
||||
style.backgroundColor = "transparent";
|
||||
style.font = [aFont cssString];
|
||||
|
||||
if (aColor)
|
||||
style.color = [aColor cssString];
|
||||
|
||||
if (CPFeatureIsCompatible(CPJavaScriptInnerTextFeature))
|
||||
span.innerText = aString;
|
||||
else if (CPFeatureIsCompatible(CPJavaScriptTextContentFeature))
|
||||
span.textContent = aString;
|
||||
|
||||
//<!> FIXME aString.replace(/&/g,'&')
|
||||
return span;
|
||||
#else
|
||||
return nil;
|
||||
#endif
|
||||
}
|
||||
|
||||
- (id)initWithRange:(CPRange)aRange textContainer:(CPTextContainer)aContainer textStorage:(CPTextStorage)textStorage
|
||||
{
|
||||
if (self = [super init])
|
||||
{
|
||||
var effectiveRange = CPMakeRange(0,0),
|
||||
location;
|
||||
|
||||
_fragmentRect = CGRectMakeZero();
|
||||
_usedRect = CGRectMakeZero();
|
||||
_location = CGPointMakeZero();
|
||||
_range = CPMakeRangeCopy(aRange);
|
||||
_textContainer = aContainer;
|
||||
_isInvalid = NO;
|
||||
_runs = [[CPMutableArray alloc] init];
|
||||
|
||||
for (location = aRange.location; location < CPMaxRange(aRange); location = CPMaxRange(effectiveRange))
|
||||
{
|
||||
var attributes = [textStorage attributesAtIndex:location effectiveRange:effectiveRange];
|
||||
|
||||
effectiveRange = attributes ? CPIntersectionRange(aRange, effectiveRange) : aRange;
|
||||
|
||||
var string = [textStorage._string substringWithRange:effectiveRange],
|
||||
font = [textStorage font] || [CPFont systemFontOfSize:12.0];
|
||||
|
||||
if ([attributes containsKey:CPFontAttributeName])
|
||||
font = [attributes objectForKey:CPFontAttributeName];
|
||||
|
||||
var color = [attributes objectForKey:CPForegroundColorAttributeName],
|
||||
elem = [self createDOMElementWithText:string andFont:font andColor:color],
|
||||
run = {_range:CPMakeRangeCopy(effectiveRange), elem:elem, string:string};
|
||||
|
||||
_runs.push(run);
|
||||
}
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)setAdvancements:(CPArray)someAdvancements
|
||||
{
|
||||
var count = someAdvancements.length,
|
||||
origin = CGPointMake(_fragmentRect.origin.x + _location.x, _fragmentRect.origin.y);
|
||||
|
||||
_glyphsFrames = new Array(count);
|
||||
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
_glyphsFrames[i] = CGRectMake(origin.x, origin.y, someAdvancements[i], _usedRect.size.height);
|
||||
origin.x += someAdvancements[i];
|
||||
}
|
||||
}
|
||||
|
||||
- (CPString)description
|
||||
{
|
||||
return [super description] +
|
||||
"\n\t_fragmentRect="+CPStringFromRect(_fragmentRect) +
|
||||
"\n\t_usedRect="+CPStringFromRect(_usedRect) +
|
||||
"\n\t_location="+CPStringFromPoint(_location) +
|
||||
"\n\t_range="+CPStringFromRange(_range);
|
||||
}
|
||||
|
||||
- (void)drawUnderlineForGlyphRange:(CPRange)glyphRange
|
||||
underlineType:(int)underlineVal
|
||||
baselineOffset:(float)baselineOffset
|
||||
containerOrigin:(CGPoint)containerOrigin
|
||||
{
|
||||
// <!> FIXME
|
||||
}
|
||||
|
||||
- (void)invalidate
|
||||
{
|
||||
_isInvalid = YES;
|
||||
}
|
||||
|
||||
- (void)_deinvalidate
|
||||
{
|
||||
_isInvalid = NO;
|
||||
}
|
||||
|
||||
- (void)_removeFromDOM
|
||||
{
|
||||
var l = _runs.length;
|
||||
|
||||
for (var i = 0; i < l; i++)
|
||||
{
|
||||
if (_runs[i].elem && _runs[i].DOMactive)
|
||||
_textContainer._textView._DOMElement.removeChild(_runs[i].elem);
|
||||
|
||||
_runs[i].elem = nil;
|
||||
_runs[i].DOMactive = NO;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)drawInContext:(CGContext)context atPoint:(CGPoint)aPoint forRange:(CPRange)aRange
|
||||
{
|
||||
var runs = _objectsInRange(_runs, aRange),
|
||||
c = runs.length,
|
||||
orig = CGPointMake(_fragmentRect.origin.x, _fragmentRect.origin.y);
|
||||
|
||||
orig.y += aPoint.y;
|
||||
|
||||
for (var i = 0; i < c; i++)
|
||||
{
|
||||
var run = runs[i];
|
||||
|
||||
if (run.DOMactive && !run.DOMpatched || !run.elem)
|
||||
continue;
|
||||
|
||||
if(!_glyphsFrames)
|
||||
continue;
|
||||
|
||||
orig.x = _glyphsFrames[run._range.location - _runs[0]._range.location].origin.x + aPoint.x;
|
||||
|
||||
run.elem.style.left = (orig.x) + "px";
|
||||
run.elem.style.top = (orig.y) + "px";
|
||||
|
||||
if (!run.DOMactive)
|
||||
_textContainer._textView._DOMElement.appendChild(run.elem);
|
||||
|
||||
run.DOMactive = YES;
|
||||
run.DOMpatched = NO;
|
||||
|
||||
if (run.underline)
|
||||
{
|
||||
// <!> FIXME
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)backgroundColorForGlyphAtIndex:(unsigned)index
|
||||
{
|
||||
var run = _objectWithLocationInRange(_runs, index);
|
||||
|
||||
if (run)
|
||||
return run.backgroundColor;
|
||||
|
||||
return [CPColor clearColor];
|
||||
}
|
||||
|
||||
- (BOOL)isVisuallyIdenticalToFragment:(_CPLineFragment)newLineFragment
|
||||
{
|
||||
var newFragmentRuns= newLineFragment._runs,
|
||||
oldFragmentRuns= _runs;
|
||||
|
||||
if (!oldFragmentRuns || !newFragmentRuns || oldFragmentRuns.length !== newFragmentRuns.length)
|
||||
return NO;
|
||||
|
||||
var l = oldFragmentRuns.length;
|
||||
|
||||
for (var i = 0; i < l; i++)
|
||||
{
|
||||
// FIXME <!> newFragmentRuns[i].elem.style.left !== oldFragmentRuns[i].elem.style.left && compare CSS-strings
|
||||
if (newFragmentRuns[i].string !== oldFragmentRuns[i].string ||
|
||||
!_RectEqualToRectHorizontally(newLineFragment._fragmentRect, _fragmentRect))
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)_relocateVerticallyByY:(double)verticalOffset rangeOffset:(unsigned)rangeOffset
|
||||
{
|
||||
var l = _runs.length;
|
||||
|
||||
_range.location += rangeOffset;
|
||||
|
||||
for (var i = 0; i < l; i++)
|
||||
{
|
||||
_runs[i]._range.location += rangeOffset;
|
||||
|
||||
if (verticalOffset)
|
||||
{
|
||||
_runs[i].elem.top = (_runs[i].elem.top + verticalOffset) + 'px';
|
||||
_runs[i].DOMpatched = YES;
|
||||
}
|
||||
}
|
||||
|
||||
if (!verticalOffset)
|
||||
return NO;
|
||||
|
||||
_fragmentRect.origin.y += verticalOffset;
|
||||
_usedRect.origin.y += verticalOffset;
|
||||
|
||||
var l = _glyphsFrames.length;
|
||||
|
||||
for (var i = 0; i < l ; i++)
|
||||
{
|
||||
_glyphsFrames[i].origin.y += verticalOffset;
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation _CPTemporaryAttributes : CPObject
|
||||
{
|
||||
CPDictionary _attributes;
|
||||
CPRange _range;
|
||||
}
|
||||
|
||||
- (id)initWithRange:(CPRange)aRange attributes:(CPDictionary)attributes
|
||||
{
|
||||
if (self = [super init])
|
||||
{
|
||||
_attributes = attributes;
|
||||
_range = CPMakeRangeCopy(aRange);
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (CPString)description
|
||||
{
|
||||
return [super description] +
|
||||
"\n\t_range="+CPStringFromRange(_range) +
|
||||
"\n\t_attributes="+[_attributes description];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
/*!
|
||||
@ingroup appkit
|
||||
@@ -446,16 +80,24 @@ var _objectsInRange = function(aList, aRange)
|
||||
{
|
||||
if (self = [super init])
|
||||
{
|
||||
_textContainers = [[CPMutableArray alloc] init];
|
||||
_lineFragments = [[CPMutableArray alloc] init];
|
||||
_typesetter = [CPTypesetter sharedSystemTypesetter];
|
||||
_isValidatingLayoutAndGlyphs = NO;
|
||||
_lineFragmentFactory = [_CPLineFragment class];
|
||||
[self _init];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)_init
|
||||
{
|
||||
_isValidatingLayoutAndGlyphs = NO;
|
||||
_lineFragmentFactory = [_CPLineFragment class];
|
||||
_lineFragments = [[CPMutableArray alloc] init];
|
||||
_textContainers = [[CPMutableArray alloc] init];
|
||||
_textStorage = [[CPTextStorage alloc] init];
|
||||
_typesetter = [CPTypesetter sharedSystemTypesetter];
|
||||
|
||||
[_textStorage addLayoutManager:self];
|
||||
}
|
||||
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Text containes method
|
||||
@@ -1244,4 +886,400 @@ var _objectsInRange = function(aList, aRange)
|
||||
|
||||
return rectArray;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
var CPLayoutManagerTextStorageKey = @"CPLayoutManagerTextStorageKey";
|
||||
|
||||
@implementation CPLayoutManager (CPCoding)
|
||||
|
||||
- (id)initWithCoder:(CPCoder)aCoder
|
||||
{
|
||||
self = [super init];
|
||||
|
||||
if (self)
|
||||
{
|
||||
[self _init];
|
||||
|
||||
_textStorage = [aCoder decodeObjectForKey:CPLayoutManagerTextStorageKey];
|
||||
[_textStorage addLayoutManager:self];
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)encodeWithCoder:(CPCoder)aCoder
|
||||
{
|
||||
[aCoder encodeObject:_textStorage forKey:CPLayoutManagerTextStorageKey];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation CPArray (SortedSearching)
|
||||
|
||||
- (unsigned)_indexOfObject:(id)anObject sortedByFunction:(Function)aFunction context:(id)aContext
|
||||
{
|
||||
var length= [self count];
|
||||
|
||||
if (!aFunction)
|
||||
return CPNotFound;
|
||||
|
||||
if (length === 0)
|
||||
return -1;
|
||||
|
||||
var mid,
|
||||
c,
|
||||
first = 0,
|
||||
last = length - 1;
|
||||
|
||||
while (first <= last)
|
||||
{
|
||||
mid = FLOOR((first + last) / 2);
|
||||
c = aFunction(anObject, self[mid], aContext);
|
||||
|
||||
if (c > 0)
|
||||
{
|
||||
first = mid + 1;
|
||||
}
|
||||
else if (c < 0)
|
||||
{
|
||||
last = mid - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
while (mid < length - 1 && aFunction(anObject, self[mid + 1], aContext) == CPOrderedSame)
|
||||
mid++;
|
||||
|
||||
return mid;
|
||||
}
|
||||
}
|
||||
|
||||
var result = -first - 1;
|
||||
|
||||
return result >= 0 ? result : CPNotFound;
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
var _sortRange = function(location, anObject)
|
||||
{
|
||||
if (CPLocationInRange(location, anObject._range))
|
||||
return CPOrderedSame;
|
||||
else if (CPMaxRange(anObject._range) <= location)
|
||||
return CPOrderedDescending;
|
||||
else
|
||||
return CPOrderedAscending;
|
||||
}
|
||||
|
||||
var _objectWithLocationInRange = function(aList, aLocation)
|
||||
{
|
||||
var index = [aList _indexOfObject: aLocation sortedByFunction:_sortRange context:nil];
|
||||
|
||||
if (index != CPNotFound)
|
||||
return aList[index];
|
||||
|
||||
return nil;
|
||||
}
|
||||
|
||||
var _objectsInRange = function(aList, aRange)
|
||||
{
|
||||
var list = [],
|
||||
c = aList.length,
|
||||
location = aRange.location;
|
||||
|
||||
for (var i = 0; i < c; i++)
|
||||
{
|
||||
if (CPLocationInRange(location, aList[i]._range))
|
||||
{
|
||||
list.push(aList[i]);
|
||||
|
||||
if (CPMaxRange(aList[i]._range) <= CPMaxRange(aRange))
|
||||
location = CPMaxRange(aList[i]._range);
|
||||
else
|
||||
break;
|
||||
}
|
||||
else if (CPLocationInRange(CPMaxRange(aRange), aList[i]._range))
|
||||
{
|
||||
list.push(aList[i]);
|
||||
break;
|
||||
}
|
||||
else if (CPRangeInRange(aRange, aList[i]._range))
|
||||
{
|
||||
list.push(aList[i]);
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
@implementation _CPLineFragment : CPObject
|
||||
{
|
||||
CPArray _glyphsFrames @accessors(getter=glyphFrames);
|
||||
|
||||
BOOL _isInvalid;
|
||||
CGRect _fragmentRect;
|
||||
CGRect _usedRect;
|
||||
CGPoint _location;
|
||||
CPRange _range;
|
||||
CPTextContainer _textContainer;
|
||||
CPMutableArray _runs;
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
#pragma mark Init methods
|
||||
|
||||
- (id)createDOMElementWithText:(CPString)aString andFont:(CPFont)aFont andColor:(CPColor)aColor
|
||||
{
|
||||
#if PLATFORM(DOM)
|
||||
var style,
|
||||
span = document.createElement("span");
|
||||
|
||||
span.oncontextmenu = span.onmousedown = span.onselectstart = _oncontextmenuhandler;
|
||||
// span.contentEditable = true; // this unfortunately does not work to make native pasting work on safari
|
||||
|
||||
style = span.style;
|
||||
style.position = "absolute";
|
||||
style.visibility = "visible";
|
||||
style.padding = "0px";
|
||||
style.margin = "0px";
|
||||
style.whiteSpace = "pre";
|
||||
style.backgroundColor = "transparent";
|
||||
style.font = [aFont cssString];
|
||||
|
||||
if (aColor)
|
||||
style.color = [aColor cssString];
|
||||
|
||||
if (CPFeatureIsCompatible(CPJavaScriptInnerTextFeature))
|
||||
span.innerText = aString;
|
||||
else if (CPFeatureIsCompatible(CPJavaScriptTextContentFeature))
|
||||
span.textContent = aString;
|
||||
|
||||
//<!> FIXME aString.replace(/&/g,'&')
|
||||
return span;
|
||||
#else
|
||||
return nil;
|
||||
#endif
|
||||
}
|
||||
|
||||
- (id)initWithRange:(CPRange)aRange textContainer:(CPTextContainer)aContainer textStorage:(CPTextStorage)textStorage
|
||||
{
|
||||
if (self = [super init])
|
||||
{
|
||||
var effectiveRange = CPMakeRange(0,0),
|
||||
location;
|
||||
|
||||
_fragmentRect = CGRectMakeZero();
|
||||
_usedRect = CGRectMakeZero();
|
||||
_location = CGPointMakeZero();
|
||||
_range = CPMakeRangeCopy(aRange);
|
||||
_textContainer = aContainer;
|
||||
_isInvalid = NO;
|
||||
_runs = [[CPMutableArray alloc] init];
|
||||
|
||||
for (location = aRange.location; location < CPMaxRange(aRange); location = CPMaxRange(effectiveRange))
|
||||
{
|
||||
var attributes = [textStorage attributesAtIndex:location effectiveRange:effectiveRange];
|
||||
|
||||
effectiveRange = attributes ? CPIntersectionRange(aRange, effectiveRange) : aRange;
|
||||
|
||||
var string = [textStorage._string substringWithRange:effectiveRange],
|
||||
font = [textStorage font] || [CPFont systemFontOfSize:12.0];
|
||||
|
||||
if ([attributes containsKey:CPFontAttributeName])
|
||||
font = [attributes objectForKey:CPFontAttributeName];
|
||||
|
||||
var color = [attributes objectForKey:CPForegroundColorAttributeName],
|
||||
elem = [self createDOMElementWithText:string andFont:font andColor:color],
|
||||
run = {_range:CPMakeRangeCopy(effectiveRange), elem:elem, string:string};
|
||||
|
||||
_runs.push(run);
|
||||
}
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)setAdvancements:(CPArray)someAdvancements
|
||||
{
|
||||
var count = someAdvancements.length,
|
||||
origin = CGPointMake(_fragmentRect.origin.x + _location.x, _fragmentRect.origin.y);
|
||||
|
||||
_glyphsFrames = new Array(count);
|
||||
|
||||
for (var i = 0; i < count; i++)
|
||||
{
|
||||
_glyphsFrames[i] = CGRectMake(origin.x, origin.y, someAdvancements[i], _usedRect.size.height);
|
||||
origin.x += someAdvancements[i];
|
||||
}
|
||||
}
|
||||
|
||||
- (CPString)description
|
||||
{
|
||||
return [super description] +
|
||||
"\n\t_fragmentRect="+CPStringFromRect(_fragmentRect) +
|
||||
"\n\t_usedRect="+CPStringFromRect(_usedRect) +
|
||||
"\n\t_location="+CPStringFromPoint(_location) +
|
||||
"\n\t_range="+CPStringFromRange(_range);
|
||||
}
|
||||
|
||||
- (void)drawUnderlineForGlyphRange:(CPRange)glyphRange
|
||||
underlineType:(int)underlineVal
|
||||
baselineOffset:(float)baselineOffset
|
||||
containerOrigin:(CGPoint)containerOrigin
|
||||
{
|
||||
// <!> FIXME
|
||||
}
|
||||
|
||||
- (void)invalidate
|
||||
{
|
||||
_isInvalid = YES;
|
||||
}
|
||||
|
||||
- (void)_deinvalidate
|
||||
{
|
||||
_isInvalid = NO;
|
||||
}
|
||||
|
||||
- (void)_removeFromDOM
|
||||
{
|
||||
var l = _runs.length;
|
||||
|
||||
for (var i = 0; i < l; i++)
|
||||
{
|
||||
if (_runs[i].elem && _runs[i].DOMactive)
|
||||
_textContainer._textView._DOMElement.removeChild(_runs[i].elem);
|
||||
|
||||
_runs[i].elem = nil;
|
||||
_runs[i].DOMactive = NO;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)drawInContext:(CGContext)context atPoint:(CGPoint)aPoint forRange:(CPRange)aRange
|
||||
{
|
||||
var runs = _objectsInRange(_runs, aRange),
|
||||
c = runs.length,
|
||||
orig = CGPointMake(_fragmentRect.origin.x, _fragmentRect.origin.y);
|
||||
|
||||
orig.y += aPoint.y;
|
||||
|
||||
for (var i = 0; i < c; i++)
|
||||
{
|
||||
var run = runs[i];
|
||||
|
||||
if (run.DOMactive && !run.DOMpatched || !run.elem)
|
||||
continue;
|
||||
|
||||
if(!_glyphsFrames)
|
||||
continue;
|
||||
|
||||
orig.x = _glyphsFrames[run._range.location - _runs[0]._range.location].origin.x + aPoint.x;
|
||||
|
||||
run.elem.style.left = (orig.x) + "px";
|
||||
run.elem.style.top = (orig.y) + "px";
|
||||
|
||||
if (!run.DOMactive)
|
||||
_textContainer._textView._DOMElement.appendChild(run.elem);
|
||||
|
||||
run.DOMactive = YES;
|
||||
run.DOMpatched = NO;
|
||||
|
||||
if (run.underline)
|
||||
{
|
||||
// <!> FIXME
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (void)backgroundColorForGlyphAtIndex:(unsigned)index
|
||||
{
|
||||
var run = _objectWithLocationInRange(_runs, index);
|
||||
|
||||
if (run)
|
||||
return run.backgroundColor;
|
||||
|
||||
return [CPColor clearColor];
|
||||
}
|
||||
|
||||
- (BOOL)isVisuallyIdenticalToFragment:(_CPLineFragment)newLineFragment
|
||||
{
|
||||
var newFragmentRuns= newLineFragment._runs,
|
||||
oldFragmentRuns= _runs;
|
||||
|
||||
if (!oldFragmentRuns || !newFragmentRuns || oldFragmentRuns.length !== newFragmentRuns.length)
|
||||
return NO;
|
||||
|
||||
var l = oldFragmentRuns.length;
|
||||
|
||||
for (var i = 0; i < l; i++)
|
||||
{
|
||||
// FIXME <!> newFragmentRuns[i].elem.style.left !== oldFragmentRuns[i].elem.style.left && compare CSS-strings
|
||||
if (newFragmentRuns[i].string !== oldFragmentRuns[i].string ||
|
||||
!_RectEqualToRectHorizontally(newLineFragment._fragmentRect, _fragmentRect))
|
||||
{
|
||||
return NO;
|
||||
}
|
||||
}
|
||||
|
||||
return YES;
|
||||
}
|
||||
|
||||
- (void)_relocateVerticallyByY:(double)verticalOffset rangeOffset:(unsigned)rangeOffset
|
||||
{
|
||||
var l = _runs.length;
|
||||
|
||||
_range.location += rangeOffset;
|
||||
|
||||
for (var i = 0; i < l; i++)
|
||||
{
|
||||
_runs[i]._range.location += rangeOffset;
|
||||
|
||||
if (verticalOffset)
|
||||
{
|
||||
_runs[i].elem.top = (_runs[i].elem.top + verticalOffset) + 'px';
|
||||
_runs[i].DOMpatched = YES;
|
||||
}
|
||||
}
|
||||
|
||||
if (!verticalOffset)
|
||||
return NO;
|
||||
|
||||
_fragmentRect.origin.y += verticalOffset;
|
||||
_usedRect.origin.y += verticalOffset;
|
||||
|
||||
var l = _glyphsFrames.length;
|
||||
|
||||
for (var i = 0; i < l ; i++)
|
||||
{
|
||||
_glyphsFrames[i].origin.y += verticalOffset;
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
@implementation _CPTemporaryAttributes : CPObject
|
||||
{
|
||||
CPDictionary _attributes;
|
||||
CPRange _range;
|
||||
}
|
||||
|
||||
- (id)initWithRange:(CPRange)aRange attributes:(CPDictionary)attributes
|
||||
{
|
||||
if (self = [super init])
|
||||
{
|
||||
_attributes = attributes;
|
||||
_range = CPMakeRangeCopy(aRange);
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (CPString)description
|
||||
{
|
||||
return [super description] +
|
||||
"\n\t_range="+CPStringFromRange(_range) +
|
||||
"\n\t_attributes="+[_attributes description];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -24,6 +24,7 @@
|
||||
@import "CPLayoutManager.j"
|
||||
|
||||
@class CPTextView
|
||||
@class CPLayoutManager
|
||||
|
||||
/*
|
||||
@global
|
||||
@@ -110,6 +111,9 @@ CPLineMovesUp = 4;
|
||||
- (void)_init
|
||||
{
|
||||
_lineFragmentPadding = 0.0;
|
||||
|
||||
_layoutManager = [[CPLayoutManager alloc] init];
|
||||
[_layoutManager addTextContainer:self];
|
||||
}
|
||||
|
||||
#pragma mark -
|
||||
@@ -220,7 +224,8 @@ CPLineMovesUp = 4;
|
||||
@end
|
||||
|
||||
|
||||
var CPTextContainerSizeKey = @"CPTextContainerSizeKey";
|
||||
var CPTextContainerSizeKey = @"CPTextContainerSizeKey",
|
||||
CPTextContainerLayoutManagerKey = @"CPTextContainerLayoutManagerKey";
|
||||
|
||||
@implementation CPTextContainer (CPCoding)
|
||||
|
||||
@@ -231,7 +236,11 @@ var CPTextContainerSizeKey = @"CPTextContainerSizeKey";
|
||||
if (self)
|
||||
{
|
||||
[self _init];
|
||||
|
||||
_size = [aCoder decodeSizeForKey:CPTextContainerSizeKey];
|
||||
|
||||
_layoutManager = [aCoder decodeObjectForKey:CPTextContainerLayoutManagerKey];
|
||||
[_layoutManager addTextContainer:self];
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -240,6 +249,7 @@ var CPTextContainerSizeKey = @"CPTextContainerSizeKey";
|
||||
- (void)encodeWithCoder:(CPCoder)aCoder
|
||||
{
|
||||
[aCoder encodeSize:_size forKey:CPTextContainerSizeKey];
|
||||
[aCoder encodeObject:_layoutManager forKey:CPTextContainerLayoutManagerKey];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -254,4 +254,26 @@ CPTextStorageDidProcessEditingNotification = @"CPTextStorageDidProcessEditingNot
|
||||
return [super attributedSubstringFromRange:aRange];
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
@implementation CPTextStorage (CPCoding)
|
||||
|
||||
- (id)initWithCoder:(CPCoder)aCoder
|
||||
{
|
||||
self = [super initWithCoder:aCoder];
|
||||
|
||||
if (self)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
- (void)encodeWithCoder:(CPCoder)aCoder
|
||||
{
|
||||
[super encodeWithCoder:aCoder];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -87,10 +87,10 @@ var kDelegateRespondsTo_textShouldBeginEditing
|
||||
{
|
||||
BOOL _allowsUndo @accessors(property=allowsUndo);
|
||||
BOOL _isEditable @accessors(getter=isEditable, setter=setEditable:);
|
||||
BOOL _isHorizontallyResizable @accessors(getter=isHorizontallyResizable, setter=setHorinzontallyResizable);
|
||||
BOOL _isRichText @accessors(getter=isRichText, setter=setRichText);
|
||||
BOOL _isHorizontallyResizable @accessors(getter=isHorizontallyResizable, setter=setHorinzontallyResizable:);
|
||||
BOOL _isRichText @accessors(getter=isRichText, setter=setRichText:);
|
||||
BOOL _isSelectable @accessors(getter=isSelectable, setter=setSelectable:);
|
||||
BOOL _isVerticallyResizable @accessors(getter=isVerticallyResizable, setter=setVerticallyResizable);
|
||||
BOOL _isVerticallyResizable @accessors(getter=isVerticallyResizable, setter=setVerticallyResizable:);
|
||||
BOOL _usesFontPanel @accessors(property=usesFontPanel);
|
||||
CGPoint _textContainerOrigin @accessors(getter=textContainerOrigin);
|
||||
CGSize _minSize @accessors(property=minSize);
|
||||
@@ -159,12 +159,7 @@ var kDelegateRespondsTo_textShouldBeginEditing
|
||||
|
||||
- (id)initWithFrame:(CGRect)aFrame
|
||||
{
|
||||
var layoutManager = [[CPLayoutManager alloc] init],
|
||||
textStorage = [[CPTextStorage alloc] init],
|
||||
container = [[CPTextContainer alloc] initWithContainerSize:CGSizeMake(aFrame.size.width, 1e7)];
|
||||
|
||||
[textStorage addLayoutManager:layoutManager];
|
||||
[layoutManager addTextContainer:container];
|
||||
var container = [[CPTextContainer alloc] initWithContainerSize:CGSizeMake(aFrame.size.width, 1e7)];
|
||||
|
||||
return [self initWithFrame:aFrame textContainer:container];
|
||||
}
|
||||
@@ -423,14 +418,6 @@ var kDelegateRespondsTo_textShouldBeginEditing
|
||||
_isSelectable = flag;
|
||||
}
|
||||
|
||||
- (void)setSelectable:(BOOL)flag
|
||||
{
|
||||
_isSelectable = flag;
|
||||
|
||||
if (flag)
|
||||
_isEditable = flag;
|
||||
}
|
||||
|
||||
- (void)invalidateTextContainerOrigin
|
||||
{
|
||||
_textContainerOrigin.x = _bounds.origin.x;
|
||||
@@ -1872,7 +1859,13 @@ var kDelegateRespondsTo_textShouldBeginEditing
|
||||
|
||||
var CPTextViewContainerKey = @"CPTextViewContainerKey",
|
||||
CPTextViewLayoutManagerKey = @"CPTextViewLayoutManagerKey";
|
||||
CPTextViewTextStorageKey = @"CPTextViewTextStorageKey";
|
||||
CPTextViewTextStorageKey = @"CPTextViewTextStorageKey",
|
||||
CPTextViewIsEditableKey = @"CPTextViewIsEditableKey",
|
||||
CPTextViewIsSelectableKey = @"CPTextViewIsSelectableKey",
|
||||
CPTextViewIsRichTextKey = @"CPTextViewIsRichTextKey",
|
||||
CPTextViewBackgroundColorKey = @"CPTextViewBackgroundColorKey",
|
||||
CPTextViewInsertionPointColorKey = @"CPTextViewInsertionPointColorKey",
|
||||
CPTextViewSelectedTextAttributesKey = @"CPTextViewSelectedTextAttributesKey";
|
||||
|
||||
@implementation CPTextView (CPCoding)
|
||||
|
||||
@@ -1884,14 +1877,22 @@ var CPTextViewContainerKey = @"CPTextViewContainerKey",
|
||||
{
|
||||
[self _init];
|
||||
|
||||
var layoutManager = [[CPLayoutManager alloc] init],
|
||||
textStorage = [[CPTextStorage alloc] init],
|
||||
container = [aCoder decodeObjectForKey:CPTextViewContainerKey];
|
||||
|
||||
[textStorage addLayoutManager:layoutManager];
|
||||
[layoutManager addTextContainer:container];
|
||||
|
||||
var container = [aCoder decodeObjectForKey:CPTextViewContainerKey];
|
||||
[container setTextView:self];
|
||||
|
||||
[self setSelectable:[aCoder decodeBoolForKey:CPTextViewIsSelectableKey]];
|
||||
[self setEditable:[aCoder decodeBoolForKey:CPTextViewIsEditableKey]];
|
||||
[self setRichText:[aCoder decodeBoolForKey:CPTextViewIsRichTextKey]];
|
||||
[self setBackgroundColor:[aCoder decodeObjectForKey:CPTextViewBackgroundColorKey]];
|
||||
[self setInsertionPointColor:[aCoder decodeObjectForKey:CPTextViewInsertionPointColorKey]];
|
||||
[self setString:[_textStorage string]];
|
||||
|
||||
var selectedTextAttributes = [aCoder decodeObjectForKey:CPTextViewSelectedTextAttributesKey],
|
||||
enumerator = [selectedTextAttributes keyEnumerator],
|
||||
key;
|
||||
|
||||
while (key = [enumerator nextObject])
|
||||
[_selectedTextAttributes setObject:[selectedTextAttributes valueForKey:key] forKey:key];
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -1901,6 +1902,12 @@ var CPTextViewContainerKey = @"CPTextViewContainerKey",
|
||||
{
|
||||
[super encodeWithCoder:aCoder];
|
||||
[aCoder encodeObject:_textContainer forKey:CPTextViewContainerKey];
|
||||
[aCoder encodeBool:_isEditable forKey:CPTextViewIsEditableKey];
|
||||
[aCoder encodeBool:_isSelectable forKey:CPTextViewIsSelectableKey];
|
||||
[aCoder encodeBool:_isRichText forKey:CPTextViewIsRichTextKey];
|
||||
[aCoder encodeObject:_insertionPointColor forKey:CPTextViewInsertionPointColorKey];
|
||||
[aCoder encodeObject:_backgroundColor forKey:CPTextViewBackgroundColorKey];
|
||||
[aCoder encodeObject:_selectedTextAttributes forKey:CPTextViewSelectedTextAttributesKey];
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -1 +1 @@
|
||||
280NPLIST;1.0;D;K;4;$topD;K;18;CPCibObjectDataKeyD;K;6;CP$UIDd;1;2E;E;K;8;$objectsA;S;5;$nullD;K;10;$classnameS;16;_CPCibObjectDataK;8;$classesA;S;16;_CPCibObjectDataS;8;CPObjectE;E;D;K;6;$classD;K;6;CP$UIDd;1;1E;K;28;_CPCibObjectDataNamesKeysKeyD;K;6;CP$UIDd;1;0E;K;30;_CPCibObjectDataNamesValuesKeyD;K;6;CP$UIDd;1;0E;K;30;_CPCibObjectDataClassesKeysKeyD;K;6;CP$UIDd;1;0E;K;32;_CPCibObjectDataClassesValuesKeyD;K;6;CP$UIDd;1;0E;K;30;_CPCibObjectDataConnectionsKeyD;K;6;CP$UIDd;1;4E;K;28;_CPCibObjectDataFrameworkKeyD;K;6;CP$UIDd;1;0E;K;26;_CPCibObjectDataNextOidKeyD;K;6;CP$UIDd;1;5E;K;30;_CPCibObjectDataObjectsKeysKeyD;K;6;CP$UIDd;1;6E;K;32;_CPCibObjectDataObjectsValuesKeyD;K;6;CP$UIDd;1;7E;K;26;_CPCibObjectDataOidKeysKeyD;K;6;CP$UIDd;1;8E;K;28;_CPCibObjectDataOidValuesKeyD;K;6;CP$UIDd;1;9E;K;28;_CPCibObjectDataFileOwnerKeyD;K;6;CP$UIDd;2;11E;K;33;_CPCibObjectDataVisibleWindowsKeyD;K;6;CP$UIDd;2;13E;E;D;K;10;$classnameS;7;CPArrayK;8;$classesA;S;7;CPArrayS;8;CPObjectE;E;D;K;6;$classD;K;6;CP$UIDd;1;3E;K;10;CP.objectsA;D;K;6;CP$UIDd;2;15E;D;K;6;CP$UIDd;2;16E;E;E;D;K;6;$classD;K;6;CP$UIDd;1;3E;K;10;CP.objectsA;E;E;D;K;6;$classD;K;6;CP$UIDd;1;3E;K;10;CP.objectsA;D;K;6;CP$UIDd;2;17E;D;K;6;CP$UIDd;2;19E;D;K;6;CP$UIDd;2;21E;D;K;6;CP$UIDd;2;23E;D;K;6;CP$UIDd;2;25E;D;K;6;CP$UIDd;2;27E;D;K;6;CP$UIDd;2;29E;D;K;6;CP$UIDd;2;30E;D;K;6;CP$UIDd;2;31E;E;E;D;K;6;$classD;K;6;CP$UIDd;1;3E;K;10;CP.objectsA;D;K;6;CP$UIDd;2;11E;D;K;6;CP$UIDd;2;11E;D;K;6;CP$UIDd;2;19E;D;K;6;CP$UIDd;2;21E;D;K;6;CP$UIDd;2;23E;D;K;6;CP$UIDd;2;25E;D;K;6;CP$UIDd;2;23E;D;K;6;CP$UIDd;2;23E;D;K;6;CP$UIDd;2;11E;E;E;D;K;6;$classD;K;6;CP$UIDd;1;3E;K;10;CP.objectsA;E;E;D;K;6;$classD;K;6;CP$UIDd;1;3E;K;10;CP.objectsA;E;E;D;K;10;$classnameS;18;_CPCibCustomObjectK;8;$classesA;S;18;_CPCibCustomObjectS;8;CPObjectE;E;D;K;6;$classD;K;6;CP$UIDd;2;10E;K;27;_CPCibCustomObjectClassNameD;K;6;CP$UIDd;2;32E;E;D;K;10;$classnameS;5;CPSetK;8;$classesA;S;5;CPSetS;8;CPObjectE;E;D;K;6;$classD;K;6;CP$UIDd;2;12E;K;15;CPSetObjectsKeyD;K;6;CP$UIDd;2;33E;E;D;K;10;$classnameS;20;CPCibOutletConnectorK;8;$classesA;S;20;CPCibOutletConnectorS;14;CPCibConnectorS;8;CPObjectE;E;D;K;6;$classD;K;6;CP$UIDd;2;14E;K;24;_CPCibConnectorSourceKeyD;K;6;CP$UIDd;2;11E;K;29;_CPCibConnectorDestinationKeyD;K;6;CP$UIDd;2;31E;K;23;_CPCibConnectorLabelKeyD;K;6;CP$UIDd;2;34E;E;D;K;6;$classD;K;6;CP$UIDd;2;14E;K;24;_CPCibConnectorSourceKeyD;K;6;CP$UIDd;2;31E;K;29;_CPCibConnectorDestinationKeyD;K;6;CP$UIDd;2;19E;K;23;_CPCibConnectorLabelKeyD;K;6;CP$UIDd;2;35E;E;D;K;6;$classD;K;6;CP$UIDd;2;10E;K;27;_CPCibCustomObjectClassNameD;K;6;CP$UIDd;2;32E;E;D;K;10;$classnameS;20;_CPCibWindowTemplateK;8;$classesA;S;20;_CPCibWindowTemplateS;8;CPObjectE;E;D;K;6;$classD;K;6;CP$UIDd;2;18E;K;30;_CPCibWindowTemplateMaxSizeKeyD;K;6;CP$UIDd;2;36E;K;32;_CPCibWindowTemplateViewClassKeyD;K;6;CP$UIDd;1;0E;K;34;_CPCibWindowTemplateWindowClassKeyD;K;6;CP$UIDd;2;37E;K;30;_CPCibWindowTemplateWTFlagsKeyD;K;6;CP$UIDd;2;38E;K;33;_CPCibWindowTemplateWindowRectKeyD;K;6;CP$UIDd;2;39E;K;33;_CPCibWindowTemplateScreenRectKeyD;K;6;CP$UIDd;2;40E;K;30;_CPCibWindowTempatStyleMaskKeyD;K;6;CP$UIDd;2;41E;K;34;_CPCibWindowTemplateWindowTitleKeyD;K;6;CP$UIDd;2;42E;K;33;_CPCibWindowTemplateWindowViewKeyD;K;6;CP$UIDd;2;21E;E;D;K;10;$classnameS;6;CPViewK;8;$classesA;S;6;CPViewS;11;CPResponderS;8;CPObjectE;E;D;K;6;$classD;K;6;CP$UIDd;2;20E;K;18;CPResponderMenuKeyD;K;6;CP$UIDd;1;0E;K;12;CPViewTagKeyD;K;6;CP$UIDd;2;43E;K;14;CPViewFrameKeyD;K;6;CP$UIDd;2;44E;K;15;CPViewBoundsKeyD;K;6;CP$UIDd;2;44E;K;17;CPViewSubviewsKeyD;K;6;CP$UIDd;2;45E;K;19;CPViewThemeClassKeyD;K;6;CP$UIDd;1;0E;K;19;CPViewThemeStateKeyD;K;6;CP$UIDd;2;46E;K;14;CPViewScaleKeyD;K;6;CP$UIDd;2;47E;K;18;CPViewSizeScaleKeyD;K;6;CP$UIDd;2;47E;K;17;CPViewIsScaledKeyD;K;6;CP$UIDd;2;48E;E;D;K;10;$classnameS;12;CPScrollViewK;8;$classesA;S;12;CPScrollViewS;6;CPViewS;11;CPResponderS;8;CPObjectE;E;D;K;6;$classD;K;6;CP$UIDd;2;22E;K;27;CPResponderNextResponderKeyD;K;6;CP$UIDd;2;21E;K;18;CPResponderMenuKeyD;K;6;CP$UIDd;1;0E;K;12;CPViewTagKeyD;K;6;CP$UIDd;2;43E;K;14;CPViewFrameKeyD;K;6;CP$UIDd;2;49E;K;15;CPViewBoundsKeyD;K;6;CP$UIDd;2;50E;K;17;CPViewSubviewsKeyD;K;6;CP$UIDd;2;51E;K;18;CPViewSuperviewKeyD;K;6;CP$UIDd;2;21E;K;22;CPViewAutoresizingMaskD;K;6;CP$UIDd;2;52E;K;19;CPViewThemeClassKeyD;K;6;CP$UIDd;2;53E;K;19;CPViewThemeStateKeyD;K;6;CP$UIDd;2;46E;K;14;CPViewScaleKeyD;K;6;CP$UIDd;2;47E;K;18;CPViewSizeScaleKeyD;K;6;CP$UIDd;2;47E;K;17;CPViewIsScaledKeyD;K;6;CP$UIDd;2;48E;K;23;CPScrollViewContentViewD;K;6;CP$UIDd;2;25E;K;29;CPScrollViewHeaderClipViewKeyD;K;6;CP$UIDd;1;0E;K;21;CPScrollViewVScrollerD;K;6;CP$UIDd;2;30E;K;21;CPScrollViewHScrollerD;K;6;CP$UIDd;2;29E;K;23;CPScrollViewVLineScrollD;K;6;CP$UIDd;2;54E;K;23;CPScrollViewVPageScrollD;K;6;CP$UIDd;2;54E;K;23;CPScrollViewHLineScrollD;K;6;CP$UIDd;2;54E;K;23;CPScrollViewHPageScrollD;K;6;CP$UIDd;2;54E;K;24;CPScrollViewHasVScrollerD;K;6;CP$UIDd;2;55E;K;24;CPScrollViewHasHScrollerD;K;6;CP$UIDd;2;48E;K;29;CPScrollViewAutohidesScrollerD;K;6;CP$UIDd;2;48E;K;25;CPScrollVieLine truncated
|
||||
280NPLIST;1.0;D;K;4;$topD;K;18;CPCibObjectDataKeyD;K;6;CP$UIDd;1;2E;E;K;8;$objectsA;S;5;$nullD;K;10;$classnameS;16;_CPCibObjectDataK;8;$classesA;S;16;_CPCibObjectDataS;8;CPObjectE;E;D;K;6;$classD;K;6;CP$UIDd;1;1E;K;28;_CPCibObjectDataNamesKeysKeyD;K;6;CP$UIDd;1;0E;K;30;_CPCibObjectDataNamesValuesKeyD;K;6;CP$UIDd;1;0E;K;30;_CPCibObjectDataClassesKeysKeyD;K;6;CP$UIDd;1;0E;K;32;_CPCibObjectDataClassesValuesKeyD;K;6;CP$UIDd;1;0E;K;30;_CPCibObjectDataConnectionsKeyD;K;6;CP$UIDd;1;4E;K;28;_CPCibObjectDataFrameworkKeyD;K;6;CP$UIDd;1;0E;K;26;_CPCibObjectDataNextOidKeyD;K;6;CP$UIDd;1;5E;K;30;_CPCibObjectDataObjectsKeysKeyD;K;6;CP$UIDd;1;6E;K;32;_CPCibObjectDataObjectsValuesKeyD;K;6;CP$UIDd;1;7E;K;26;_CPCibObjectDataOidKeysKeyD;K;6;CP$UIDd;1;8E;K;28;_CPCibObjectDataOidValuesKeyD;K;6;CP$UIDd;1;9E;K;28;_CPCibObjectDataFileOwnerKeyD;K;6;CP$UIDd;2;11E;K;33;_CPCibObjectDataVisibleWindowsKeyD;K;6;CP$UIDd;2;13E;E;D;K;10;$classnameS;7;CPArrayK;8;$classesA;S;7;CPArrayS;8;CPObjectE;E;D;K;6;$classD;K;6;CP$UIDd;1;3E;K;10;CP.objectsA;D;K;6;CP$UIDd;2;15E;D;K;6;CP$UIDd;2;16E;E;E;D;K;6;$classD;K;6;CP$UIDd;1;3E;K;10;CP.objectsA;E;E;D;K;6;$classD;K;6;CP$UIDd;1;3E;K;10;CP.objectsA;D;K;6;CP$UIDd;2;17E;D;K;6;CP$UIDd;2;19E;D;K;6;CP$UIDd;2;21E;D;K;6;CP$UIDd;2;23E;D;K;6;CP$UIDd;2;25E;D;K;6;CP$UIDd;2;27E;D;K;6;CP$UIDd;2;29E;D;K;6;CP$UIDd;2;30E;D;K;6;CP$UIDd;2;31E;E;E;D;K;6;$classD;K;6;CP$UIDd;1;3E;K;10;CP.objectsA;D;K;6;CP$UIDd;2;11E;D;K;6;CP$UIDd;2;11E;D;K;6;CP$UIDd;2;19E;D;K;6;CP$UIDd;2;21E;D;K;6;CP$UIDd;2;23E;D;K;6;CP$UIDd;2;25E;D;K;6;CP$UIDd;2;23E;D;K;6;CP$UIDd;2;23E;D;K;6;CP$UIDd;2;11E;E;E;D;K;6;$classD;K;6;CP$UIDd;1;3E;K;10;CP.objectsA;E;E;D;K;6;$classD;K;6;CP$UIDd;1;3E;K;10;CP.objectsA;E;E;D;K;10;$classnameS;18;_CPCibCustomObjectK;8;$classesA;S;18;_CPCibCustomObjectS;8;CPObjectE;E;D;K;6;$classD;K;6;CP$UIDd;2;10E;K;27;_CPCibCustomObjectClassNameD;K;6;CP$UIDd;2;32E;E;D;K;10;$classnameS;5;CPSetK;8;$classesA;S;5;CPSetS;8;CPObjectE;E;D;K;6;$classD;K;6;CP$UIDd;2;12E;K;15;CPSetObjectsKeyD;K;6;CP$UIDd;2;33E;E;D;K;10;$classnameS;20;CPCibOutletConnectorK;8;$classesA;S;20;CPCibOutletConnectorS;14;CPCibConnectorS;8;CPObjectE;E;D;K;6;$classD;K;6;CP$UIDd;2;14E;K;24;_CPCibConnectorSourceKeyD;K;6;CP$UIDd;2;11E;K;29;_CPCibConnectorDestinationKeyD;K;6;CP$UIDd;2;31E;K;23;_CPCibConnectorLabelKeyD;K;6;CP$UIDd;2;34E;E;D;K;6;$classD;K;6;CP$UIDd;2;14E;K;24;_CPCibConnectorSourceKeyD;K;6;CP$UIDd;2;31E;K;29;_CPCibConnectorDestinationKeyD;K;6;CP$UIDd;2;19E;K;23;_CPCibConnectorLabelKeyD;K;6;CP$UIDd;2;35E;E;D;K;6;$classD;K;6;CP$UIDd;2;10E;K;27;_CPCibCustomObjectClassNameD;K;6;CP$UIDd;2;32E;E;D;K;10;$classnameS;20;_CPCibWindowTemplateK;8;$classesA;S;20;_CPCibWindowTemplateS;8;CPObjectE;E;D;K;6;$classD;K;6;CP$UIDd;2;18E;K;30;_CPCibWindowTemplateMaxSizeKeyD;K;6;CP$UIDd;2;36E;K;32;_CPCibWindowTemplateViewClassKeyD;K;6;CP$UIDd;1;0E;K;34;_CPCibWindowTemplateWindowClassKeyD;K;6;CP$UIDd;2;37E;K;30;_CPCibWindowTemplateWTFlagsKeyD;K;6;CP$UIDd;2;38E;K;33;_CPCibWindowTemplateWindowRectKeyD;K;6;CP$UIDd;2;39E;K;33;_CPCibWindowTemplateScreenRectKeyD;K;6;CP$UIDd;2;40E;K;30;_CPCibWindowTempatStyleMaskKeyD;K;6;CP$UIDd;2;41E;K;34;_CPCibWindowTemplateWindowTitleKeyD;K;6;CP$UIDd;2;42E;K;33;_CPCibWindowTemplateWindowViewKeyD;K;6;CP$UIDd;2;21E;E;D;K;10;$classnameS;6;CPViewK;8;$classesA;S;6;CPViewS;11;CPResponderS;8;CPObjectE;E;D;K;6;$classD;K;6;CP$UIDd;2;20E;K;18;CPResponderMenuKeyD;K;6;CP$UIDd;1;0E;K;12;CPViewTagKeyD;K;6;CP$UIDd;2;43E;K;14;CPViewFrameKeyD;K;6;CP$UIDd;2;44E;K;15;CPViewBoundsKeyD;K;6;CP$UIDd;2;44E;K;17;CPViewSubviewsKeyD;K;6;CP$UIDd;2;45E;K;19;CPViewThemeClassKeyD;K;6;CP$UIDd;1;0E;K;19;CPViewThemeStateKeyD;K;6;CP$UIDd;2;46E;K;14;CPViewScaleKeyD;K;6;CP$UIDd;2;47E;K;18;CPViewSizeScaleKeyD;K;6;CP$UIDd;2;47E;K;17;CPViewIsScaledKeyD;K;6;CP$UIDd;2;48E;E;D;K;10;$classnameS;12;CPScrollViewK;8;$classesA;S;12;CPScrollViewS;6;CPViewS;11;CPResponderS;8;CPObjectE;E;D;K;6;$classD;K;6;CP$UIDd;2;22E;K;27;CPResponderNextResponderKeyD;K;6;CP$UIDd;2;21E;K;18;CPResponderMenuKeyD;K;6;CP$UIDd;1;0E;K;12;CPViewTagKeyD;K;6;CP$UIDd;2;43E;K;14;CPViewFrameKeyD;K;6;CP$UIDd;2;49E;K;15;CPViewBoundsKeyD;K;6;CP$UIDd;2;50E;K;17;CPViewSubviewsKeyD;K;6;CP$UIDd;2;51E;K;18;CPViewSuperviewKeyD;K;6;CP$UIDd;2;21E;K;22;CPViewAutoresizingMaskD;K;6;CP$UIDd;2;52E;K;19;CPViewThemeClassKeyD;K;6;CP$UIDd;2;53E;K;19;CPViewThemeStateKeyD;K;6;CP$UIDd;2;46E;K;14;CPViewScaleKeyD;K;6;CP$UIDd;2;47E;K;18;CPViewSizeScaleKeyD;K;6;CP$UIDd;2;47E;K;17;CPViewIsScaledKeyD;K;6;CP$UIDd;2;48E;K;23;CPScrollViewContentViewD;K;6;CP$UIDd;2;25E;K;29;CPScrollViewHeaderClipViewKeyD;K;6;CP$UIDd;1;0E;K;21;CPScrollViewVScrollerD;K;6;CP$UIDd;2;30E;K;21;CPScrollViewHScrollerD;K;6;CP$UIDd;2;29E;K;23;CPScrollViewVLineScrollD;K;6;CP$UIDd;2;54E;K;23;CPScrollViewVPageScrollD;K;6;CP$UIDd;2;54E;K;23;CPScrollViewHLineScrollD;K;6;CP$UIDd;2;54E;K;23;CPScrollViewHPageScrollD;K;6;CP$UIDd;2;54E;K;24;CPScrollViewHasVScrollerD;K;6;CP$UIDd;2;55E;K;24;CPScrollViewHasHScrollerD;K;6;CP$UIDd;2;48E;K;29;CPScrollViewAutohidesScrollerD;K;6;CP$UIDd;2;48E;K;25;CPScrollVieLine truncated
|
||||
@@ -29,11 +29,19 @@
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<textView identifier="vfokrt" importsGraphics="NO" findStyle="panel" continuousSpellChecking="YES" allowsUndo="YES" usesRuler="YES" usesFontPanel="YES" verticallyResizable="YES" allowsNonContiguousLayout="YES" quoteSubstitution="YES" dashSubstitution="YES" spellingCorrection="YES" smartInsertDelete="YES" id="lio-7d-ZF1">
|
||||
<rect key="frame" x="0.0" y="0.0" width="238" height="133"/>
|
||||
<rect key="frame" x="0.0" y="0.0" width="238" height="318"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<size key="minSize" width="446" height="318"/>
|
||||
<size key="maxSize" width="463" height="10000000"/>
|
||||
<attributedString key="textStorage">
|
||||
<fragment content="Je suis un CPTextView">
|
||||
<attributes>
|
||||
<font key="NSFont" metaFont="controlContent" size="11"/>
|
||||
<paragraphStyle key="NSParagraphStyle" alignment="natural" lineBreakMode="wordWrapping" baseWritingDirection="natural"/>
|
||||
</attributes>
|
||||
</fragment>
|
||||
</attributedString>
|
||||
<color key="insertionPointColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<size key="minSize" width="446" height="318"/>
|
||||
<size key="maxSize" width="463" height="10000000"/>
|
||||
@@ -52,6 +60,7 @@
|
||||
</scrollView>
|
||||
</subviews>
|
||||
</view>
|
||||
<point key="canvasLocation" x="288" y="319"/>
|
||||
</window>
|
||||
<customObject id="450" customClass="AppController">
|
||||
<connections>
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="6254" systemVersion="14D72i" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
|
||||
<dependencies>
|
||||
<deployment version="1050" identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="6254"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="NSApplication">
|
||||
<connections>
|
||||
<outlet property="delegate" destination="450" id="451"/>
|
||||
</connections>
|
||||
</customObject>
|
||||
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
|
||||
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
|
||||
<window title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" animationBehavior="default" id="371">
|
||||
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES"/>
|
||||
<windowPositionMask key="initialPositionMask" leftStrut="YES" bottomStrut="YES"/>
|
||||
<rect key="contentRect" x="335" y="390" width="480" height="360"/>
|
||||
<rect key="screenRect" x="0.0" y="0.0" width="1440" height="878"/>
|
||||
<view key="contentView" id="372">
|
||||
<rect key="frame" x="0.0" y="0.0" width="480" height="360"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<scrollView horizontalLineScroll="10" horizontalPageScroll="10" verticalLineScroll="10" verticalPageScroll="10" hasHorizontalScroller="NO" usesPredominantAxisScrolling="NO" id="jll-qG-fPP">
|
||||
<rect key="frame" x="20" y="57" width="353" height="283"/>
|
||||
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
|
||||
<clipView key="contentView" id="iXp-AZ-pxs">
|
||||
<rect key="frame" x="1" y="1" width="238" height="133"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<subviews>
|
||||
<textView identifier="vfokrt" importsGraphics="NO" findStyle="panel" continuousSpellChecking="YES" allowsUndo="YES" usesRuler="YES" usesFontPanel="YES" verticallyResizable="YES" allowsNonContiguousLayout="YES" quoteSubstitution="YES" dashSubstitution="YES" spellingCorrection="YES" smartInsertDelete="YES" id="lio-7d-ZF1">
|
||||
<rect key="frame" x="0.0" y="0.0" width="238" height="133"/>
|
||||
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
|
||||
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<size key="minSize" width="351" height="281"/>
|
||||
<size key="maxSize" width="463" height="10000000"/>
|
||||
<color key="insertionPointColor" white="0.0" alpha="1" colorSpace="calibratedWhite"/>
|
||||
<size key="minSize" width="351" height="281"/>
|
||||
<size key="maxSize" width="463" height="10000000"/>
|
||||
</textView>
|
||||
</subviews>
|
||||
<color key="backgroundColor" red="1" green="0.64941237564325471" blue="0.36235191105575371" alpha="1" colorSpace="calibratedRGB"/>
|
||||
</clipView>
|
||||
<scroller key="horizontalScroller" hidden="YES" verticalHuggingPriority="750" doubleValue="1" horizontal="YES" id="tou-bI-pKK">
|
||||
<rect key="frame" x="-100" y="-100" width="87" height="18"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</scroller>
|
||||
<scroller key="verticalScroller" verticalHuggingPriority="750" doubleValue="1" horizontal="NO" id="HzS-T1-0kM">
|
||||
<rect key="frame" x="223" y="1" width="16" height="133"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</scroller>
|
||||
</scrollView>
|
||||
</subviews>
|
||||
</view>
|
||||
</window>
|
||||
<customObject id="450" customClass="AppController">
|
||||
<connections>
|
||||
<outlet property="theWindow" destination="371" id="459"/>
|
||||
</connections>
|
||||
</customObject>
|
||||
</objects>
|
||||
</document>
|
||||
@@ -40,5 +40,7 @@
|
||||
|
||||
@implementation NSMutableAttributedString : NSAttributedString
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@end
|
||||
@@ -30,6 +30,9 @@
|
||||
{
|
||||
self = [super init];
|
||||
|
||||
_textStorage = [aCoder decodeObjectForKey:@"NSTextStorage"];
|
||||
[_textStorage addLayoutManager:self];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
@@ -46,7 +49,7 @@
|
||||
|
||||
if (self)
|
||||
{
|
||||
var textStorage = [aCoder decodeObjectForKey:@"NSTextStorage"];
|
||||
|
||||
}
|
||||
|
||||
return self;
|
||||
|
||||
@@ -30,6 +30,11 @@
|
||||
{
|
||||
self = [super init];
|
||||
|
||||
_size = CGSizeMake([aCoder decodeIntForKey:@"NSWidth"], 1e7);
|
||||
|
||||
_layoutManager = [aCoder decodeObjectForKey:@"NSLayoutManager"];
|
||||
[_layoutManager addTextContainer:self];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
@@ -45,9 +50,7 @@
|
||||
|
||||
if (self)
|
||||
{
|
||||
_size = CGSizeMake([aCoder decodeIntForKey:@"NSWidth"], 1e7);
|
||||
|
||||
var layoutManager = [aCoder decodeObjectForKey:@"NSLayoutManager"];
|
||||
}
|
||||
|
||||
return self;
|
||||
|
||||
@@ -28,7 +28,8 @@
|
||||
|
||||
- (id)NS_initWithCoder:(CPCoder)aCoder
|
||||
{
|
||||
self = [super init];
|
||||
//self = [super initWithString:[aCoder decodeObjectForKey:@"NSString"] attributes:[aCoder decodeObjectForKey:@"NSAttributes"]];
|
||||
self = [super initWithString:[aCoder decodeObjectForKey:@"NSString"] attributes:nil];
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
@@ -28,11 +28,19 @@
|
||||
|
||||
@implementation CPTextView (NSCoding)
|
||||
|
||||
- (id)NS_initWithCoder:(CPCoder)aCoder
|
||||
- (id)NS_initWithCoder:(CPCoder)aCoder textViewSharedData:(CPTextViewSharedData)aTextViewSharedData
|
||||
{
|
||||
if (self = [super NS_initWithCoder:aCoder])
|
||||
{
|
||||
_textContainer = [aCoder decodeObjectForKey:@"NSTextContainer"];
|
||||
|
||||
[self setEditable:[aTextViewSharedData isEditable]];
|
||||
[self setSelectable:[aTextViewSharedData isSelectable]];
|
||||
[self setRichText:[aTextViewSharedData isRichText]];
|
||||
|
||||
[self setBackgroundColor:[aTextViewSharedData backgroundColor]];
|
||||
[self setInsertionPointColor:[aTextViewSharedData insertionColor]];
|
||||
[self setSelectedTextAttributes:[aTextViewSharedData selectedTextAttributes]];
|
||||
}
|
||||
|
||||
return self;
|
||||
@@ -42,16 +50,14 @@
|
||||
|
||||
@implementation NSTextView : CPTextView
|
||||
{
|
||||
CPTextViewSharedData _textViewSharedData;
|
||||
|
||||
}
|
||||
|
||||
- (id)initWithCoder:(CPCoder)aCoder
|
||||
{
|
||||
self = [self NS_initWithCoder:aCoder];
|
||||
|
||||
if (self)
|
||||
if (self = [self NS_initWithCoder:aCoder textViewSharedData:[aCoder decodeObjectForKey:@"NSSharedData"]])
|
||||
{
|
||||
_textViewSharedData = [aCoder decodeObjectForKey:@"NSSharedData"];
|
||||
|
||||
}
|
||||
|
||||
return self;
|
||||
|
||||
@@ -21,19 +21,27 @@
|
||||
*/
|
||||
|
||||
@import <Foundation/Foundation.j>
|
||||
@import <AppKit/CPColor.j>
|
||||
|
||||
@class Nib2Cib
|
||||
|
||||
@implementation CPTextViewSharedData : CPObject
|
||||
{
|
||||
BOOL _editable @accessors(getter=isEditable);
|
||||
BOOL _richText @accessors(getter=isRichText);
|
||||
BOOL _selectable @accessors(getter=isSelectable);
|
||||
CPColor _backgroundColor @accessors(getter=backgroundColor);
|
||||
CPColor _insertionColor @accessors(getter=insertionColor);
|
||||
CPDictionary _selectedTextAttributes @accessors(getter=selectedTextAttributes);
|
||||
}
|
||||
|
||||
- (id)init
|
||||
{
|
||||
if(self = [super init])
|
||||
if (self = [super init])
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
return self;
|
||||
}
|
||||
|
||||
@@ -47,6 +55,14 @@
|
||||
if (self = [super init])
|
||||
{
|
||||
var flags = [aCoder decodeIntForKey:@"NSFlags"];
|
||||
|
||||
_selectable = flags & 0x00000001 ? YES : NO;
|
||||
_editable = flags & 0x00000002 ? YES : NO;
|
||||
_richText = flags & 0x00000004 ? YES : NO;
|
||||
|
||||
_backgroundColor = [aCoder decodeObjectForKey:@"NSBackgroundColor"];
|
||||
_insertionColor = [aCoder decodeObjectForKey:@"NSInsertionColor"];
|
||||
_selectedTextAttributes = [aCoder decodeObjectForKey:@"NSSelectedAttributes"];
|
||||
}
|
||||
|
||||
return self;
|
||||
|
||||
Reference in new issue
Block a user