Move spelling dot to OakTextView

We now load the image via NSImage and creates a CGImageRef from that (based on the current graphics context). This ensures we get the @2px version when on a HiDPI display.
This commit is contained in:
Allan Odgaard
2012-09-04 23:16:55 +02:00
parent 649398bf03
commit ace2e2269b
4 changed files with 6 additions and 1 deletions

View File

Before

Width:  |  Height:  |  Size: 109 B

After

Width:  |  Height:  |  Size: 109 B

View File

Before

Width:  |  Height:  |  Size: 163 B

After

Width:  |  Height:  |  Size: 163 B

View File

@@ -38,6 +38,8 @@ PUBLIC @interface OakTextView : OakView <NSTextInput, NSTextFieldDelegate>
BOOL hideCaret;
NSTimer* blinkCaretTimer;
NSImage* spellingDotImage;
// =================
// = Mouse Support =
// =================

View File

@@ -435,6 +435,8 @@ static std::string shell_quote (std::vector<std::string> paths)
showInvisibles = settings.get(kSettingsShowInvisiblesKey, false);
antiAlias = ![[NSUserDefaults standardUserDefaults] boolForKey:kUserDefaultsDisableAntiAliasKey];
spellingDotImage = [[NSImage imageNamed:@"SpellingDot" inSameBundleAsClass:[self class]] retain];
[self registerForDraggedTypes:[[self class] dropTypes]];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(documentWillSave:) name:@"OakDocumentNotificationWillSave" object:nil];
@@ -448,6 +450,7 @@ static std::string shell_quote (std::vector<std::string> paths)
[[NSNotificationCenter defaultCenter] removeObserver:self];
[liveSearchString release];
[self setDocument:document::document_ptr()];
[spellingDotImage release];
[super dealloc];
}
@@ -579,7 +582,7 @@ static std::string shell_quote (std::vector<std::string> paths)
CGContextRef context = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];
if(!antiAlias)
CGContextSetShouldAntialias(context, false);
layout->draw(context, aRect, [self isFlipped], showInvisibles, merge(editor->ranges(), [self markedRanges]), liveSearchRanges);
layout->draw(ng::context_t(context, [spellingDotImage CGImageForProposedRect:NULL context:[NSGraphicsContext currentContext] hints:nil]), aRect, [self isFlipped], showInvisibles, merge(editor->ranges(), [self markedRanges]), liveSearchRanges);
}
// ===============