mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-06-01 16:21:56 +00:00
implement a couple of methods
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@4752 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
220586bc55
commit
891b3f5f38
1 changed files with 99 additions and 17 deletions
|
@ -11,10 +11,88 @@
|
|||
|
||||
- (NSDictionary*) fontAttributesInRange: (NSRange)range
|
||||
{
|
||||
NSDictionary *all;
|
||||
static SEL sel = @selector(objectForKey:);
|
||||
IMP objForKey;
|
||||
id objects[8];
|
||||
id keys[8];
|
||||
int count = 0;
|
||||
|
||||
if (range.location < 0 || NSMaxRange(range) > [self length])
|
||||
{
|
||||
[NSException raise: NSRangeException
|
||||
format: @"RangeError in method -fontAttributesInRange:"];
|
||||
}
|
||||
all = [self attributesAtIndex: range.location
|
||||
effectiveRange: &range];
|
||||
|
||||
objForKey = [all methodForSelector: sel];
|
||||
|
||||
keys[count] = NSFontAttributeName;
|
||||
objects[count] = (*objForKey)(all, sel, keys[count]);
|
||||
if (objects[count] != nil)
|
||||
count++;
|
||||
|
||||
keys[count] = NSForegroundColorAttributeName;
|
||||
objects[count] = (*objForKey)(all, sel, keys[count]);
|
||||
if (objects[count] != nil)
|
||||
count++;
|
||||
|
||||
keys[count] = NSBackgroundColorAttributeName;
|
||||
objects[count] = (*objForKey)(all, sel, keys[count]);
|
||||
if (objects[count] != nil)
|
||||
count++;
|
||||
|
||||
keys[count] = NSUnderlineStyleAttributeName;
|
||||
objects[count] = (*objForKey)(all, sel, keys[count]);
|
||||
if (objects[count] != nil)
|
||||
count++;
|
||||
|
||||
keys[count] = NSSuperscriptAttributeName;
|
||||
objects[count] = (*objForKey)(all, sel, keys[count]);
|
||||
if (objects[count] != nil)
|
||||
count++;
|
||||
|
||||
keys[count] = NSBaselineOffsetAttributeName;
|
||||
objects[count] = (*objForKey)(all, sel, keys[count]);
|
||||
if (objects[count] != nil)
|
||||
count++;
|
||||
|
||||
keys[count] = NSKernAttributeName;
|
||||
objects[count] = (*objForKey)(all, sel, keys[count]);
|
||||
if (objects[count] != nil)
|
||||
count++;
|
||||
|
||||
keys[count] = NSLigatureAttributeName;
|
||||
objects[count] = (*objForKey)(all, sel, keys[count]);
|
||||
if (objects[count] != nil)
|
||||
count++;
|
||||
|
||||
return [NSDictionary dictionaryWithObjects: objects
|
||||
forKeys: keys
|
||||
count: count];
|
||||
}
|
||||
|
||||
- (NSDictionary*) rulerAttributesInRange: (NSRange)range
|
||||
{
|
||||
id style;
|
||||
|
||||
if (range.location < 0 || NSMaxRange(range) > [self length])
|
||||
{
|
||||
[NSException raise: NSRangeException
|
||||
format: @"RangeError in method -rulerAttributesInRange:"];
|
||||
}
|
||||
|
||||
style = [self attribute: NSParagraphStyleAttributeName
|
||||
atIndex: range.location
|
||||
effectiveRange: &range];
|
||||
|
||||
if (style)
|
||||
{
|
||||
return [NSDictionary dictionaryWithObject: style
|
||||
forKey: NSParagraphStyleAttributeName];
|
||||
}
|
||||
return [NSDictionary dictionary];
|
||||
}
|
||||
|
||||
- (unsigned) lineBreakBeforeIndex: (unsigned)location
|
||||
|
@ -120,14 +198,16 @@ documentAttributes: (NSDictionary**)dict
|
|||
int sValue;
|
||||
|
||||
value = [self attribute: NSSuperscriptAttributeName
|
||||
atIndex:range.location effectiveRange:&range];
|
||||
atIndex: range.location
|
||||
effectiveRange: &range];
|
||||
|
||||
sValue = [value intValue];
|
||||
|
||||
sValue++;
|
||||
|
||||
[self addAttribute:NSSuperscriptAttributeName value:[[NSNumber alloc]
|
||||
initWithInt:sValue] range:range];
|
||||
[self addAttribute: NSSuperscriptAttributeName
|
||||
value: [[NSNumber alloc] initWithInt: sValue]
|
||||
range: range];
|
||||
}
|
||||
|
||||
- (void) subscriptRange: (NSRange)range
|
||||
|
@ -136,14 +216,16 @@ documentAttributes: (NSDictionary**)dict
|
|||
int sValue;
|
||||
|
||||
value = [self attribute: NSSuperscriptAttributeName
|
||||
atIndex:range.location effectiveRange:&range];
|
||||
atIndex: range.location
|
||||
effectiveRange: &range];
|
||||
|
||||
sValue = [value intValue];
|
||||
|
||||
sValue--;
|
||||
|
||||
[self addAttribute:NSSuperscriptAttributeName value:[[NSNumber alloc]
|
||||
initWithInt:sValue] range:range];
|
||||
[self addAttribute: NSSuperscriptAttributeName
|
||||
value: [[NSNumber alloc] initWithInt: sValue]
|
||||
range: range];
|
||||
}
|
||||
|
||||
- (void)unscriptRange:(NSRange)range
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue