From cb3f168082f921bdfd65eecec7d21eaf4e8bd79e Mon Sep 17 00:00:00 2001 From: Bibiko Date: Tue, 17 Aug 2010 19:39:14 +0000 Subject: =?UTF-8?q?=E2=80=A2=20Editor=20color=20setting=20in=20Pref=20pane?= =?UTF-8?q?=20displays=20the=20color=20names=20using=20the=20Editor's=20fo?= =?UTF-8?q?nt=20-=20added=20some=20logic=20for=20closing=20the=20NSColorPa?= =?UTF-8?q?nel=20-=20some=20GUI=20tweaks?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Source/SPPreferenceController.m | 20 +++++++++++++++++--- Source/SPTextView.m | 6 ++++++ 2 files changed, 23 insertions(+), 3 deletions(-) (limited to 'Source') diff --git a/Source/SPPreferenceController.m b/Source/SPPreferenceController.m index 4f249723..ad8d6bb8 100644 --- a/Source/SPPreferenceController.m +++ b/Source/SPPreferenceController.m @@ -106,9 +106,12 @@ } - NSTableColumn* column; - SPColorWellCell* colorCell; - + NSTableColumn *column; + SPColorWellCell *colorCell; + NSTextFieldCell *textCell; + column = [[colorSettingTableView tableColumns] objectAtIndex: 0]; + textCell = [[[NSTextFieldCell alloc] init] autorelease]; + [textCell setFont:[NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:SPCustomQueryEditorFont]]]; column = [[colorSettingTableView tableColumns] objectAtIndex: 1]; colorCell = [[[SPColorWellCell alloc] init] autorelease]; [colorCell setEditable: YES]; @@ -857,6 +860,8 @@ if(tableView == colorSettingTableView && [[tableColumn identifier] isEqualToString:@"name"]) { if ([cell isKindOfClass:[NSTextFieldCell class]]) { [cell setDrawsBackground:YES]; + NSFont *nf = [NSFont fontWithName:[[[NSFontPanel sharedFontPanel] panelConvertFont:[NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:SPCustomQueryEditorFont]]] fontName] size:13.0f]; + [cell setFont:nf]; switch(index) { case 1: [cell setTextColor:[NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:SPCustomQueryEditorTextColor]]]; @@ -1202,6 +1207,9 @@ // ------------------------------------------------------------------------------- - (void)windowWillClose:(NSNotification *)notification { + + [[NSColorPanel sharedColorPanel] close]; + // Mark the currently selected field in the window as having finished editing, to trigger saves. if ([preferencesWindow firstResponder]) [preferencesWindow endEditingFor:[preferencesWindow firstResponder]]; @@ -1214,6 +1222,9 @@ // ------------------------------------------------------------------------------- - (NSSize)windowWillResize:(NSWindow *)sender toSize:(NSSize)frameSize { + + [[NSColorPanel sharedColorPanel] close]; + if ([sender showsResizeIndicator]) return frameSize; else @@ -1364,6 +1375,7 @@ // reset syntax highlighting colors - (IBAction)setDefaultColors:(id)sender { + [[NSColorPanel sharedColorPanel] close]; [prefs setObject:[NSArchiver archivedDataWithRootObject:[NSColor colorWithDeviceRed:0.000 green:0.455 blue:0.000 alpha:1.000]] forKey:SPCustomQueryEditorCommentColor]; [prefs setObject:[NSArchiver archivedDataWithRootObject:[NSColor colorWithDeviceRed:0.769 green:0.102 blue:0.086 alpha:1.000]] forKey:SPCustomQueryEditorQuoteColor]; [prefs setObject:[NSArchiver archivedDataWithRootObject:[NSColor colorWithDeviceRed:0.200 green:0.250 blue:1.000 alpha:1.000]] forKey:SPCustomQueryEditorSQLKeywordColor]; @@ -1393,6 +1405,7 @@ - (void)colorChanged:(id)sender { + if(![[NSColorPanel sharedColorPanel] isVisible]) return; [prefs setObject:[NSArchiver archivedDataWithRootObject:[sender color]] forKey:[editorColors objectAtIndex:colorRow]]; [colorSettingTableView reloadData]; @@ -1423,6 +1436,7 @@ [editorFontName setStringValue:[NSString stringWithFormat:@"%@, %.1f pt", [nf displayName], [nf pointSize]]]; break; } + [colorSettingTableView reloadData]; } /** diff --git a/Source/SPTextView.m b/Source/SPTextView.m index a4ed1adc..a045a4ad 100644 --- a/Source/SPTextView.m +++ b/Source/SPTextView.m @@ -3317,6 +3317,12 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) NSLog(@"%@ ‘%@’.", NSLocalizedString(@"Couldn't read the file content of", @"Couldn't read the file content of"), aPath); } +// Do nothing if NSColorPanel was opened from the NSTextView +- (void)changeColor:(id)sender +{ + return; +} + - (void)changeFont:(id)sender { if (prefs && [self font] != nil) { -- cgit v1.2.3