mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-10-10 02:40:59 +00:00
Fixed: background color attribute was ignored by CPTextView (#2899)
This commit is contained in:
1 parent
38dd776049
commit
77fe16faec
2 files changed
+26
-19
No files matched your search
@@ -1085,10 +1085,10 @@ var _objectsInRange = function(aList, aRange)
|
||||
|
||||
- (id)createDOMElementWithText:(CPString)aString andFont:(CPFont)aFont andColor:(CPColor)aColor
|
||||
{
|
||||
return [self createDOMElementWithText:aString andFont:aFont andColor:aColor andUnderline:nil];
|
||||
return [self createDOMElementWithText:aString andFont:aFont andColor:aColor andBackgroundColor:nil andUnderline:nil ];
|
||||
}
|
||||
|
||||
- (id)createDOMElementWithText:(CPString)aString andFont:(CPFont)aFont andColor:(CPColor)aColor andUnderline:(CPUnderlineStyle)aUnderline
|
||||
- (id)createDOMElementWithText:(CPString)aString andFont:(CPFont)aFont andColor:(CPColor)fgColor andBackgroundColor:(CPColor)bgColor andUnderline:(CPUnderlineStyle)aUnderline
|
||||
{
|
||||
#if PLATFORM(DOM)
|
||||
var style,
|
||||
@@ -1129,8 +1129,11 @@ var _objectsInRange = function(aList, aRange)
|
||||
}
|
||||
}
|
||||
|
||||
if (aColor)
|
||||
style.color = [aColor cssString];
|
||||
if (fgColor)
|
||||
style.color = [fgColor cssString];
|
||||
|
||||
if (bgColor)
|
||||
style.backgroundColor = [bgColor cssString];
|
||||
|
||||
if (CPFeatureIsCompatible(CPJavaScriptInnerTextFeature))
|
||||
span.innerText = aString;
|
||||
@@ -1185,8 +1188,9 @@ var _objectsInRange = function(aList, aRange)
|
||||
else
|
||||
{
|
||||
var color = [attributes objectForKey:CPForegroundColorAttributeName],
|
||||
bgcolor = [attributes objectForKey:CPBackgroundColorAttributeName],
|
||||
font = [attributes objectForKey:CPFontAttributeName] || [textStorage font] || [CPFont systemFontOfSize:12.0],
|
||||
run = {_range:CPMakeRangeCopy(effectiveRange), color:color, font:font, elem:nil, string:string};
|
||||
run = {_range:CPMakeRangeCopy(effectiveRange), color:color, font:font, elem:nil, string:string, bgcolor:bgcolor};
|
||||
|
||||
_runs.push(run);
|
||||
}
|
||||
@@ -1284,7 +1288,7 @@ var _objectsInRange = function(aList, aRange)
|
||||
var run = runs[i];
|
||||
|
||||
if (!run.elem && CPRectIntersectsRect([_textContainer._textView exposedRect], _fragmentRect))
|
||||
run.elem = [self createDOMElementWithText:run.string andFont:run.font andColor:run.color andUnderline:run.underline];
|
||||
run.elem = [self createDOMElementWithText:run.string andFont:run.font andColor:run.color andBackgroundColor:run.bgcolor andUnderline:run.underline];
|
||||
|
||||
if (run.DOMactive && !run.DOMpatched)
|
||||
continue;
|
||||
|
||||
@@ -67,19 +67,17 @@
|
||||
_textView2._isRichText = NO;
|
||||
[_textView setBackgroundColor:[CPColor whiteColor]];
|
||||
[_textView2 setBackgroundColor:[CPColor whiteColor]];
|
||||
|
||||
|
||||
var scrollView = [[CPScrollView alloc] initWithFrame:CGRectMake(20, 70, 520, 510)];
|
||||
var scrollView2 = [[CPScrollView alloc] initWithFrame:CGRectMake(560, 70, 520, 510)];
|
||||
// [scrollView setAutohidesScrollers:YES];
|
||||
|
||||
[scrollView setDocumentView:_textView];
|
||||
[scrollView2 setDocumentView:_textView2];
|
||||
//
|
||||
|
||||
[contentView addSubview: scrollView];
|
||||
[contentView addSubview: scrollView2];
|
||||
//
|
||||
// [_textView setDelegate:self];
|
||||
//
|
||||
// build our menu
|
||||
|
||||
// build our menu
|
||||
var mainMenu = [CPApp mainMenu];
|
||||
|
||||
while ([mainMenu numberOfItems] > 0)
|
||||
@@ -114,17 +112,22 @@
|
||||
var tempButton = [[CPButton alloc] initWithFrame:CGRectMake(0, 0, 64, 28)]
|
||||
[_textView insertText:[CPTextStorage attributedStringWithAttachment:tempButton]];
|
||||
|
||||
// var centeredParagraph=[CPParagraphStyle new];
|
||||
// [centeredParagraph setAlignment: CPCenterTextAlignment];
|
||||
// [_textView insertText:[[CPAttributedString alloc] initWithString:@"Fusce\n"
|
||||
// attributes:[CPDictionary dictionaryWithObjects:[centeredParagraph, [CPFont boldFontWithName:"Arial" size:18], [CPColor redColor]]
|
||||
// forKeys:[CPParagraphStyleAttributeName, CPFontAttributeName, CPForegroundColorAttributeName]]]];
|
||||
var centeredParagraph=[CPParagraphStyle new];
|
||||
[centeredParagraph setAlignment: CPCenterTextAlignment];
|
||||
[_textView insertText:"\n"];
|
||||
[_textView insertText:[[CPAttributedString alloc] initWithString:@"Fusce\n"
|
||||
attributes:[CPDictionary dictionaryWithObjects:[centeredParagraph, [CPFont boldFontWithName:"Arial" size:18], [CPColor redColor], [CPColor yellowColor]]
|
||||
forKeys:[CPParagraphStyleAttributeName, CPFontAttributeName, CPForegroundColorAttributeName, CPBackgroundColorAttributeName]]]];
|
||||
|
||||
[_textView insertText:"\n"];
|
||||
[_textView insertText:[[CPAttributedString alloc] initWithString:@"Yellow\n"
|
||||
attributes:[CPDictionary dictionaryWithObjects:[[CPFont boldFontWithName:"Arial" size:25], [CPColor yellowColor]]
|
||||
forKeys:[CPFontAttributeName, CPBackgroundColorAttributeName]]]];
|
||||
[theWindow orderFront:self];
|
||||
[CPMenu setMenuBarVisible:YES];
|
||||
}
|
||||
|
||||
- (void) makeRTF:sender
|
||||
- (void) makeRTF:(id)sender
|
||||
{
|
||||
[_textView2 setString: [_CPRTFProducer produceRTF:[_textView textStorage] documentAttributes: @{}] ];
|
||||
var tc = [_CPRTFParser new];
|
||||
|
||||
Reference in new issue
Block a user