From 890247960876e8dd987dd44ec98da4300b6a0fd3 Mon Sep 17 00:00:00 2001 From: Bibiko Date: Sat, 30 Jan 2010 22:29:34 +0000 Subject: =?UTF-8?q?=E2=80=A2=20CMTextView's=20colours=20are=20set=20via=20?= =?UTF-8?q?observer,=20live=20changed=20in=20editable=20textviews=20?= =?UTF-8?q?=E2=80=A2=20added=20Preference=20setting=20"Table=20font"=20in?= =?UTF-8?q?=20"Table"=20pane=20to=20set=20the=20table=20font/size=20for=20?= =?UTF-8?q?all=20result=20tables=20(Content,=20Custom=20Query)=20=E2=80=A2?= =?UTF-8?q?=C2=A0added=20to=20SPTableView=20the=20method=20setFont:=20?= =?UTF-8?q?=E2=80=A2=20fixed=20the=20initialisation=20of=20vars=20in=20CMT?= =?UTF-8?q?extView=20(fixes=20the=20displaying=20of=20create=20syntax)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Interfaces/English.lproj/Preferences.xib | 351 ++++++++++++++++++++++++++++--- Resources/PreferenceDefaults.plist | 2 + Source/CMTextView.m | 88 +++++--- Source/CustomQuery.m | 44 ++-- Source/SPConstants.h | 1 + Source/SPConstants.m | 1 + Source/SPPreferenceController.h | 4 + Source/SPPreferenceController.m | 38 +++- Source/SPTableView.m | 11 + Source/TableContent.m | 20 +- Source/TableDocument.m | 8 +- 11 files changed, 448 insertions(+), 120 deletions(-) diff --git a/Interfaces/English.lproj/Preferences.xib b/Interfaces/English.lproj/Preferences.xib index c4f0892d..b9f04f4f 100644 --- a/Interfaces/English.lproj/Preferences.xib +++ b/Interfaces/English.lproj/Preferences.xib @@ -46,7 +46,7 @@ Preferences NSWindow - {1.79769e+308, 1.79769e+308} + {3.40282e+38, 3.40282e+38} {500, 0} @@ -55,10 +55,10 @@ {{0, 0}, {1920, 1178}} {500, 22} - {1.79769e+308, 1.79769e+308} + {3.40282e+38, 3.40282e+38} - + 268 YES @@ -67,6 +67,7 @@ 268 {{151, 121}, {254, 26}} + YES -2076049856 @@ -404,6 +405,7 @@ 268 {{152, 214}, {209, 18}} + YES 67239424 @@ -431,6 +433,7 @@ 268 {{40, 242}, {108, 17}} + YES 68288064 @@ -444,7 +447,7 @@ controlColor 3 - MC42NjY2NjY2NjY3AA + MC42NjY2NjY2ODY1AA @@ -463,6 +466,7 @@ 268 {{151, 236}, {254, 26}} + YES -2076049856 @@ -495,6 +499,7 @@ 268 {{33, 85}, {116, 17}} + YES 68288064 @@ -511,6 +516,7 @@ 268 {{33, 127}, {116, 17}} + YES 68288064 @@ -527,6 +533,7 @@ 268 {{152, 84}, {166, 18}} + YES 67239424 @@ -549,6 +556,7 @@ 268 {{152, 62}, {181, 18}} + YES 67239424 @@ -571,6 +579,7 @@ 12 {{154, 156}, {326, 5}} + {0, 0} 67239424 @@ -601,6 +610,7 @@ 12 {{154, 108}, {326, 5}} + {0, 0} 67239424 @@ -623,6 +633,7 @@ 12 {{154, 53}, {326, 5}} + {0, 0} 67239424 @@ -645,6 +656,7 @@ 268 {{42, 23}, {106, 17}} + YES 68288064 @@ -661,6 +673,7 @@ 268 {{153, 20}, {38, 22}} + YES -1804468671 @@ -737,6 +750,7 @@ 268 {{197, 23}, {162, 17}} + YES 68288064 @@ -753,6 +767,7 @@ 268 {{151, 169}, {254, 26}} + YES -2076049856 @@ -866,6 +881,7 @@ 268 {{61, 175}, {88, 17}} + YES 68288064 @@ -882,6 +898,7 @@ 12 {{154, 204}, {326, 5}} + {0, 0} 67239424 @@ -901,6 +918,8 @@ {500, 280} + + NSView @@ -908,10 +927,51 @@ 268 YES + + + 289 + {{395, 12}, {90, 32}} + + YES + + 67239424 + 134217728 + Select… + + + -2038284033 + 129 + + + 200 + 25 + + + + + 289 + {{163, 20}, {221, 19}} + + YES + + -2076049856 + 4327424 + + + LucidaGrande + 11 + 3100 + + + YES + + + + 268 - {{160, 16}, {322, 26}} + {{162, 56}, {320, 26}} YES @@ -977,10 +1037,26 @@ 2 + + + 292 + {{16, 22}, {140, 17}} + + YES + + 68288064 + 71304192 + Table font: + + + + + + 268 - {{17, 22}, {140, 17}} + {{17, 62}, {140, 17}} YES @@ -996,7 +1072,7 @@ 12 - {{163, 46}, {316, 5}} + {{163, 86}, {316, 5}} {0, 0} @@ -1018,7 +1094,7 @@ 268 - {{161, 198}, {123, 18}} + {{161, 238}, {123, 18}} YES @@ -1040,7 +1116,7 @@ 268 - {{32, 237}, {125, 17}} + {{32, 277}, {125, 17}} YES @@ -1056,7 +1132,7 @@ 268 - {{383, 104}, {38, 17}} + {{383, 144}, {38, 17}} YES @@ -1072,7 +1148,7 @@ 268 - {{161, 238}, {106, 18}} + {{161, 278}, {106, 18}} YES @@ -1094,7 +1170,7 @@ 268 - {{161, 103}, {115, 18}} + {{161, 143}, {115, 18}} YES @@ -1116,7 +1192,7 @@ 268 - {{161, 218}, {105, 18}} + {{161, 258}, {105, 18}} YES @@ -1138,7 +1214,7 @@ 268 - {{362, 98}, {19, 27}} + {{362, 138}, {19, 27}} YES @@ -1156,7 +1232,7 @@ 268 - {{282, 101}, {75, 22}} + {{282, 141}, {75, 22}} YES @@ -1226,7 +1302,7 @@ 268 - {{17, 59}, {140, 17}} + {{17, 99}, {140, 17}} YES @@ -1242,7 +1318,7 @@ 268 - {{163, 57}, {75, 22}} + {{163, 97}, {75, 22}} YES @@ -1260,7 +1336,7 @@ 268 - {{161, 158}, {297, 18}} + {{161, 198}, {297, 18}} YES @@ -1279,10 +1355,32 @@ 25 + + + 12 + {{163, 45}, {316, 5}} + + {0, 0} + + 67239424 + 0 + Box + + + + 3 + MCAwLjgwMDAwMDAxMTkAA + + + 3 + 2 + 0 + NO + 12 - {{163, 184}, {316, 5}} + {{163, 224}, {316, 5}} {0, 0} @@ -1304,7 +1402,7 @@ 12 - {{163, 129}, {316, 5}} + {{163, 169}, {316, 5}} {0, 0} @@ -1326,7 +1424,7 @@ 12 - {{163, 90}, {316, 5}} + {{163, 130}, {316, 5}} {0, 0} @@ -1348,7 +1446,7 @@ 268 - {{161, 138}, {206, 18}} + {{161, 178}, {206, 18}} YES @@ -1368,7 +1466,7 @@ - {499, 276} + {499, 316} NSView @@ -1491,11 +1589,7 @@ 75628096 2048 Favorites - - LucidaGrande - 11 - 3100 - + 3 MC4zMzMzMzI5ODU2AA @@ -3711,10 +3805,6 @@ AQAAAAA NSView - - YES - TableRowCountQueryLevel - YES @@ -5793,6 +5883,22 @@ AQAAAAA 1484 + + + globalResultTableFontName + + + + 1493 + + + + showGlobalResultTableFontPanel: + + + + 1494 + @@ -6349,7 +6455,11 @@ AQAAAAA + + + + Tables @@ -8226,6 +8336,53 @@ AQAAAAA + + 1485 + + + YES + + + + + + 1486 + + + + + 1487 + + + YES + + + + + + 1488 + + + YES + + + + + + 1489 + + + + + 1490 + + + + + 1492 + + + @@ -8428,6 +8585,13 @@ AQAAAAA 1473.IBPluginDependency 1474.IBPluginDependency 1475.IBPluginDependency + 1485.IBPluginDependency + 1486.IBPluginDependency + 1487.IBPluginDependency + 1488.IBPluginDependency + 1489.IBPluginDependency + 1490.IBPluginDependency + 1492.IBPluginDependency 17.IBEditorWindowLastContentRect 17.IBPluginDependency 17.IBUserGuides @@ -8892,6 +9056,13 @@ AQAAAAA com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin {{571, 222}, {500, 280}} com.apple.InterfaceBuilder.CocoaPlugin @@ -9072,7 +9243,7 @@ AQAAAAA com.apple.InterfaceBuilder.CocoaPlugin - {{318, 137}, {499, 276}} + {{751, 254}, {499, 316}} com.apple.InterfaceBuilder.CocoaPlugin YES @@ -9214,7 +9385,7 @@ AQAAAAA com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin - {{254, 361}, {500, 395}} + {{545, 361}, {500, 395}} com.apple.InterfaceBuilder.CocoaPlugin YES @@ -9275,7 +9446,7 @@ AQAAAAA - 1484 + 1494 @@ -9479,6 +9650,116 @@ AQAAAAA ../../Frameworks/Sparkle.framework/Versions/A/Headers/SUUpdater.h + + SPPreferenceController + NSWindowController + + YES + + YES + addFavorite: + changeFont: + displayAutoUpdatePreferences: + displayEditorPreferences: + displayFavoritePreferences: + displayGeneralPreferences: + displayNetworkPreferences: + displayNotificationPreferences: + displayTablePreferences: + duplicateFavorite: + favoriteTypeDidChange: + removeFavorite: + saveFavorite: + setDefaultColors: + showCustomQueryFontPanel: + showGlobalResultTableFontPanel: + updateDefaultFavorite: + + + YES + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + id + + + + YES + + YES + autoUpdateView + defaultFavoritePopup + editorFontName + editorView + favoriteHostTextField + favoriteHostTextFieldSSH + favoriteNameTextField + favoriteUserTextField + favoriteUserTextFieldSSH + favoriteUserTextFieldSocket + favoritesController + favoritesTabView + favoritesTableView + favoritesView + generalView + globalResultTableFontName + networkView + notificationsView + preferencesWindow + socketPasswordField + sshPasswordField + sshSQLPasswordField + standardPasswordField + tableCell + tablesView + + + YES + NSView + NSPopUpButton + NSTextField + NSView + NSTextField + NSTextField + NSTextField + NSTextField + NSTextField + NSTextField + NSArrayController + NSTabView + NSTableView + NSView + NSView + NSTextField + NSView + NSView + NSWindow + NSSecureTextField + NSSecureTextField + NSSecureTextField + NSSecureTextField + id + NSView + + + + IBDocumentRelativeSource + ../../Source/SPPreferenceController.h + + SUUpdater NSObject diff --git a/Resources/PreferenceDefaults.plist b/Resources/PreferenceDefaults.plist index 233569d2..76eda386 100644 --- a/Resources/PreferenceDefaults.plist +++ b/Resources/PreferenceDefaults.plist @@ -10,6 +10,8 @@ 1 UseMonospacedFonts + GlobalResultTableFont + BAtzdHJlYW10eXBlZIHoA4QBQISEhAZOU0ZvbnQehIQITlNPYmplY3QAhYQBaSSEBVszNmNdBgAAABoAAAD//kwAdQBjAGkAZABhAEcAcgBhAG4AZABlAAAAhAFmC4QBYwCYAZgAmACG CustomQueryMaxHistoryItems 20 ReloadAfterAddingRow diff --git a/Source/CMTextView.m b/Source/CMTextView.m index e025296c..5afd08cb 100644 --- a/Source/CMTextView.m +++ b/Source/CMTextView.m @@ -169,6 +169,19 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) prefs = [[NSUserDefaults standardUserDefaults] retain]; + [self setQueryHiliteColor:[NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:SPCustomQueryEditorHighlightQueryColor]]]; + [self setQueryEditorBackgroundColor:[NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:SPCustomQueryEditorBackgroundColor]]]; + [self setCommentColor:[NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:SPCustomQueryEditorCommentColor]]]; + [self setQuoteColor:[NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:SPCustomQueryEditorQuoteColor]]]; + [self setKeywordColor:[NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:SPCustomQueryEditorSQLKeywordColor]]]; + [self setBacktickColor:[NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:SPCustomQueryEditorBacktickColor]]]; + [self setNumericColor:[NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:SPCustomQueryEditorNumericColor]]]; + [self setVariableColor:[NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:SPCustomQueryEditorVariableColor]]]; + [self setOtherTextColor:[NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:SPCustomQueryEditorTextColor]]]; + [self setTextColor:[self otherTextColor]]; + [self setInsertionPointColor:[self otherTextColor]]; + [self setShouldHiliteQuery:[prefs boolForKey:SPCustomQueryHighlightCurrentQuery]]; + // Register observers for the when editor background colors preference changes [prefs addObserver:self forKeyPath:SPCustomQueryEditorBackgroundColor options:NSKeyValueObservingOptionNew context:NULL]; [prefs addObserver:self forKeyPath:SPCustomQueryEditorHighlightQueryColor options:NSKeyValueObservingOptionNew context:NULL]; @@ -205,32 +218,32 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) [self setNeedsDisplay:YES]; } else if ([keyPath isEqualToString:SPCustomQueryEditorCommentColor]) { [self setCommentColor:[NSUnarchiver unarchiveObjectWithData:[change objectForKey:NSKeyValueChangeNewKey]]]; - if([[self string] length]<100000) + if([[self string] length]<100000 && [self isEditable]) [self performSelector:@selector(doSyntaxHighlighting) withObject:nil afterDelay:0.1]; } else if ([keyPath isEqualToString:SPCustomQueryEditorQuoteColor]) { [self setQuoteColor:[NSUnarchiver unarchiveObjectWithData:[change objectForKey:NSKeyValueChangeNewKey]]]; - if([[self string] length]<100000) + if([[self string] length]<100000 && [self isEditable]) [self performSelector:@selector(doSyntaxHighlighting) withObject:nil afterDelay:0.1]; } else if ([keyPath isEqualToString:SPCustomQueryEditorSQLKeywordColor]) { [self setKeywordColor:[NSUnarchiver unarchiveObjectWithData:[change objectForKey:NSKeyValueChangeNewKey]]]; - if([[self string] length]<100000) + if([[self string] length]<100000 && [self isEditable]) [self performSelector:@selector(doSyntaxHighlighting) withObject:nil afterDelay:0.1]; } else if ([keyPath isEqualToString:SPCustomQueryEditorBacktickColor]) { [self setBacktickColor:[NSUnarchiver unarchiveObjectWithData:[change objectForKey:NSKeyValueChangeNewKey]]]; - if([[self string] length]<100000) + if([[self string] length]<100000 && [self isEditable]) [self performSelector:@selector(doSyntaxHighlighting) withObject:nil afterDelay:0.1]; } else if ([keyPath isEqualToString:SPCustomQueryEditorNumericColor]) { [self setNumericColor:[NSUnarchiver unarchiveObjectWithData:[change objectForKey:NSKeyValueChangeNewKey]]]; - if([[self string] length]<100000) + if([[self string] length]<100000 && [self isEditable]) [self performSelector:@selector(doSyntaxHighlighting) withObject:nil afterDelay:0.1]; } else if ([keyPath isEqualToString:SPCustomQueryEditorVariableColor]) { [self setVariableColor:[NSUnarchiver unarchiveObjectWithData:[change objectForKey:NSKeyValueChangeNewKey]]]; - if([[self string] length]<100000) + if([[self string] length]<100000 && [self isEditable]) [self performSelector:@selector(doSyntaxHighlighting) withObject:nil afterDelay:0.1]; } else if ([keyPath isEqualToString:SPCustomQueryEditorTextColor]) { [self setOtherTextColor:[NSUnarchiver unarchiveObjectWithData:[change objectForKey:NSKeyValueChangeNewKey]]]; [self setTextColor:[self otherTextColor]]; - if([[self string] length]<100000) + if([[self string] length]<100000 && [self isEditable]) [self performSelector:@selector(doSyntaxHighlighting) withObject:nil afterDelay:0.1]; } } @@ -2981,37 +2994,42 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) [[self queryEditorBackgroundColor] setFill]; NSRectFill(rect); - // Highlightes the current query if set in the Pref and no snippet session - // and if nothing is selected in the text view - if ([self shouldHiliteQuery] && snippetControlCounter<=-1 && ![self selectedRange].length) { - NSUInteger rectCount; - [[self textStorage] ensureAttributesAreFixedInRange:[self queryRange]]; - NSRectArray queryRects = [[self layoutManager] rectArrayForCharacterRange: [self queryRange] - withinSelectedCharacterRange: [self queryRange] - inTextContainer: [self textContainer] - rectCount: &rectCount ]; - [[self queryHiliteColor] setFill]; - NSRectFillList(queryRects, rectCount); - } + if([[self delegate] isKindOfClass:[CustomQuery class]]) { + + // Highlightes the current query if set in the Pref and no snippet session + // and if nothing is selected in the text view + if ([self shouldHiliteQuery] && snippetControlCounter<=-1 && ![self selectedRange].length) { + NSUInteger rectCount; + [[self textStorage] ensureAttributesAreFixedInRange:[self queryRange]]; + NSRectArray queryRects = [[self layoutManager] rectArrayForCharacterRange: [self queryRange] + withinSelectedCharacterRange: [self queryRange] + inTextContainer: [self textContainer] + rectCount: &rectCount ]; + [[self queryHiliteColor] setFill]; + NSRectFillList(queryRects, rectCount); + } - // Highlight snippets coming from the Query Favorite text macro - if(snippetControlCounter > -1) { - for(NSUInteger i=0; i -1) { - // choose the colors for the snippet parts - if(i == currentSnippetIndex) { - [[NSColor colorWithCalibratedRed:1.0 green:0.6 blue:0.0 alpha:0.4] setFill]; - [[NSColor colorWithCalibratedRed:1.0 green:0.6 blue:0.0 alpha:0.8] setStroke]; - } else { - [[NSColor colorWithCalibratedRed:1.0 green:0.8 blue:0.2 alpha:0.2] setFill]; - [[NSColor colorWithCalibratedRed:1.0 green:0.8 blue:0.2 alpha:0.5] setStroke]; + // Highlight snippets coming from the Query Favorite text macro + if(snippetControlCounter > -1) { + for(NSUInteger i=0; i -1) { + // choose the colors for the snippet parts + if(i == currentSnippetIndex) { + [[NSColor colorWithCalibratedRed:1.0 green:0.6 blue:0.0 alpha:0.4] setFill]; + [[NSColor colorWithCalibratedRed:1.0 green:0.6 blue:0.0 alpha:0.8] setStroke]; + } else { + [[NSColor colorWithCalibratedRed:1.0 green:0.8 blue:0.2 alpha:0.2] setFill]; + [[NSColor colorWithCalibratedRed:1.0 green:0.8 blue:0.2 alpha:0.5] setStroke]; + } + NSBezierPath *snippetPath = [self roundedBezierPathAroundRange: NSMakeRange(snippetControlArray[i][0],snippetControlArray[i][1]) ]; + [snippetPath fill]; + [snippetPath stroke]; } - NSBezierPath *snippetPath = [self roundedBezierPathAroundRange: NSMakeRange(snippetControlArray[i][0],snippetControlArray[i][1]) ]; - [snippetPath fill]; - [snippetPath stroke]; } } + } + [super drawRect:rect]; } @@ -3275,11 +3293,11 @@ NSInteger alphabeticSort(id string1, id string2, void *reverse) } /* - * Show only setable modes in the font panel + * Set font panel's valid modes */ - (NSUInteger)validModesForFontPanel:(NSFontPanel *)fontPanel { - return (NSFontPanelFaceModeMask | NSFontPanelSizeModeMask); + return (NSFontPanelSizeModeMask|NSFontPanelCollectionModeMask); } #pragma mark - diff --git a/Source/CustomQuery.m b/Source/CustomQuery.m index 1bc06e48..fd8af332 100644 --- a/Source/CustomQuery.m +++ b/Source/CustomQuery.m @@ -399,7 +399,7 @@ */ - (NSUInteger)validModesForFontPanel:(NSFontPanel *)fontPanel { - return (NSFontPanelAllModesMask ^ NSFontPanelAllEffectsModeMask); + return (NSFontPanelSizeModeMask|NSFontPanelCollectionModeMask); } #pragma mark - @@ -482,6 +482,8 @@ NSUInteger queryCount = [queries count]; NSMutableArray *tempQueries = [NSMutableArray arrayWithCapacity:queryCount]; + NSFont *tableFont = [NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:SPGlobalResultTableFont]]; + [customQueryView setRowHeight:2.0f+NSSizeToCGSize([[NSString stringWithString:@"{ǞṶḹÜ∑zgyf"] sizeWithAttributes:[NSDictionary dictionaryWithObject:tableFont forKey:NSFontAttributeName]]).height]; // Enable task cancellation if (queryCount > 1) @@ -533,7 +535,8 @@ SPTextAndLinkCell *dataCell = [[[SPTextAndLinkCell alloc] initTextCell:@""] autorelease]; [dataCell setEditable:YES]; [dataCell setFormatter:[[SPDataCellFormatter new] autorelease]]; - [dataCell setFont:([prefs boolForKey:SPUseMonospacedFonts]) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; + [dataCell setFont:tableFont]; + [dataCell setLineBreakMode:NSLineBreakByTruncatingTail]; [theCol setDataCell:dataCell]; [[theCol headerCell] setStringValue:NSArrayObjectAtIndex(theColumns, j)]; @@ -855,7 +858,7 @@ // Init copyTable with necessary information for copying selected rows as SQL INSERT [customQueryView setTableInstance:self withTableData:resultData withColumns:cqColumnDefinition withTableName:resultTableName withConnection:mySQLConnection]; - + //query finished [[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryHasBeenPerformed" object:tableDocumentInstance]; @@ -1276,22 +1279,6 @@ // Set up the interface [textView setAllowsDocumentBackgroundColorChange:YES]; - [textView setTextColor:[NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:SPCustomQueryEditorTextColor]]]; - [textView setInsertionPointColor:[NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:SPCustomQueryEditorCaretColor]]]; - - [textView setQueryHiliteColor:[NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:SPCustomQueryEditorHighlightQueryColor]]]; - [textView setQueryEditorBackgroundColor:[NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:SPCustomQueryEditorBackgroundColor]]]; - - [textView setCommentColor:[NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:SPCustomQueryEditorCommentColor]]]; - [textView setQuoteColor:[NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:SPCustomQueryEditorQuoteColor]]]; - [textView setKeywordColor:[NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:SPCustomQueryEditorSQLKeywordColor]]]; - [textView setBacktickColor:[NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:SPCustomQueryEditorBacktickColor]]]; - [textView setNumericColor:[NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:SPCustomQueryEditorNumericColor]]]; - [textView setVariableColor:[NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:SPCustomQueryEditorVariableColor]]]; - [textView setOtherTextColor:[NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:SPCustomQueryEditorTextColor]]]; - [textView setTextColor:[textView otherTextColor]]; - - [textView setShouldHiliteQuery:[prefs boolForKey:SPCustomQueryHighlightCurrentQuery]]; [customQueryView setVerticalMotionCanBeginDrag:NO]; [textView setContinuousSpellCheckingEnabled:NO]; @@ -2822,16 +2809,11 @@ if ([keyPath isEqualToString:SPDisplayTableViewVerticalGridlines]) { [customQueryView setGridStyleMask:([[change objectForKey:NSKeyValueChangeNewKey] boolValue]) ? NSTableViewSolidVerticalGridLineMask : NSTableViewGridNone]; } - // Use monospaced fonts preference changed - else if ([keyPath isEqualToString:SPUseMonospacedFonts]) { - - BOOL useMonospacedFont = [[change objectForKey:NSKeyValueChangeNewKey] boolValue]; - - for (NSTableColumn *column in [customQueryView tableColumns]) - { - [[column dataCell] setFont:(useMonospacedFont) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; - } - + // Result Table Font preference changed + else if ([keyPath isEqualToString:SPGlobalResultTableFont]) { + NSFont *tableFont = [NSUnarchiver unarchiveObjectWithData:[change objectForKey:NSKeyValueChangeNewKey]]; + [customQueryView setRowHeight:2.0f+NSSizeToCGSize([[NSString stringWithString:@"{ǞṶḹÜ∑zgyf"] sizeWithAttributes:[NSDictionary dictionaryWithObject:tableFont forKey:NSFontAttributeName]]).height]; + [customQueryView setFont:tableFont]; [customQueryView reloadData]; } } @@ -3101,6 +3083,10 @@ selector:@selector(endDocumentTaskForTab:) name:SPDocumentTaskEndNotification object:tableDocumentInstance]; + + [prefs addObserver:self forKeyPath:SPGlobalResultTableFont options:NSKeyValueObservingOptionNew context:NULL]; + + } /** diff --git a/Source/SPConstants.h b/Source/SPConstants.h index a4f844d4..0c237e17 100644 --- a/Source/SPConstants.h +++ b/Source/SPConstants.h @@ -96,6 +96,7 @@ extern NSString *SPNewFieldsAllowNulls; extern NSString *SPLimitResults; extern NSString *SPLimitResultsValue; extern NSString *SPNullValue; +extern NSString *SPGlobalResultTableFont; // Favorites Prefpane extern NSString *SPFavorites; diff --git a/Source/SPConstants.m b/Source/SPConstants.m index f5f6e5bf..90fd0e2b 100644 --- a/Source/SPConstants.m +++ b/Source/SPConstants.m @@ -64,6 +64,7 @@ NSString *SPNewFieldsAllowNulls = @"NewFieldsAllowNulls"; NSString *SPLimitResults = @"LimitResults"; NSString *SPLimitResultsValue = @"LimitResultsValue"; NSString *SPNullValue = @"NullValue"; +NSString *SPGlobalResultTableFont = @"GlobalResultTableFont"; // Favorites Prefpane NSString *SPFavorites = @"favorites"; diff --git a/Source/SPPreferenceController.h b/Source/SPPreferenceController.h index b8cf7be3..62babfed 100644 --- a/Source/SPPreferenceController.h +++ b/Source/SPPreferenceController.h @@ -62,6 +62,9 @@ NSDictionary *currentFavorite; IBOutlet NSTextField *editorFontName; + IBOutlet NSTextField *globalResultTableFontName; + + NSInteger fontChangeTarget; NSToolbar *toolbar; @@ -89,6 +92,7 @@ - (IBAction)saveFavorite:(id)sender; - (IBAction)updateDefaultFavorite:(id)sender; - (IBAction)showCustomQueryFontPanel:(id)sender; +- (IBAction)showGlobalResultTableFontPanel:(id)sender; - (IBAction)setDefaultColors:(id)sender; // Toolbar item IBAction methods diff --git a/Source/SPPreferenceController.m b/Source/SPPreferenceController.m index 6377153a..d7d6bdbe 100644 --- a/Source/SPPreferenceController.m +++ b/Source/SPPreferenceController.m @@ -57,6 +57,7 @@ keychain = nil; favoriteNameFieldWasTouched = YES; favoriteType = 0; + fontChangeTarget = 0; } return self; @@ -457,6 +458,8 @@ [[self window] setShowsResizeIndicator:NO]; [toolbar setSelectedItemIdentifier:SPPreferenceToolbarTables]; + NSFont *nf = [NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:SPGlobalResultTableFont]]; + [globalResultTableFontName setStringValue:[NSString stringWithFormat:@"%@, %.1f pt", [nf displayName], [nf pointSize]]]; [self _resizeWindowForContentView:tablesView]; } @@ -1050,13 +1053,24 @@ [favoritesTableView scrollRowToVisible:theIndex]; } +// ------------------------------------------------------------------------------- +// global table font selection +// ------------------------------------------------------------------------------- +// show the font panel +- (IBAction)showGlobalResultTableFontPanel:(id)sender +{ + fontChangeTarget = 1; + [[NSFontPanel sharedFontPanel] setPanelFont:[NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:SPGlobalResultTableFont]] isMultiple:NO]; + [[NSFontPanel sharedFontPanel] makeKeyAndOrderFront:self]; +} + // ------------------------------------------------------------------------------- // query editor font selection -// // ------------------------------------------------------------------------------- // show the font panel - (IBAction)showCustomQueryFontPanel:(id)sender { + fontChangeTarget = 2; [[NSFontPanel sharedFontPanel] setPanelFont:[NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:SPCustomQueryEditorFont]] isMultiple:NO]; [[NSFontPanel sharedFontPanel] makeKeyAndOrderFront:self]; } @@ -1076,17 +1090,29 @@ [prefs setObject:[NSArchiver archivedDataWithRootObject:[NSColor whiteColor]] forKey:SPCustomQueryEditorBackgroundColor]; } -// set font panel's valid modes + +// Set font panel's valid modes - (NSUInteger)validModesForFontPanel:(NSFontPanel *)fontPanel { - return (NSFontPanelAllModesMask ^ NSFontPanelAllEffectsModeMask); + return (NSFontPanelSizeModeMask|NSFontPanelCollectionModeMask); } + // Action receiver for a font change in the font panel - (void)changeFont:(id)sender { - NSFont *nf = [[NSFontPanel sharedFontPanel] panelConvertFont:[NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:SPCustomQueryEditorFont]]]; - [prefs setObject:[NSArchiver archivedDataWithRootObject:nf] forKey:SPCustomQueryEditorFont]; - [editorFontName setStringValue:[NSString stringWithFormat:@"%@, %.1f pt", [nf displayName], [nf pointSize]]]; + NSFont *nf; + switch(fontChangeTarget) { + case 1: + nf = [[NSFontPanel sharedFontPanel] panelConvertFont:[NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:SPGlobalResultTableFont]]]; + [prefs setObject:[NSArchiver archivedDataWithRootObject:nf] forKey:SPGlobalResultTableFont]; + [globalResultTableFontName setStringValue:[NSString stringWithFormat:@"%@, %.1f pt", [nf displayName], [nf pointSize]]]; + break; + case 2: + nf = [[NSFontPanel sharedFontPanel] panelConvertFont:[NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:SPCustomQueryEditorFont]]]; + [prefs setObject:[NSArchiver archivedDataWithRootObject:nf] forKey:SPCustomQueryEditorFont]; + [editorFontName setStringValue:[NSString stringWithFormat:@"%@, %.1f pt", [nf displayName], [nf pointSize]]]; + break; + } } // ------------------------------------------------------------------------------- diff --git a/Source/SPTableView.m b/Source/SPTableView.m index 753996fb..0a1592ca 100644 --- a/Source/SPTableView.m +++ b/Source/SPTableView.m @@ -97,4 +97,15 @@ } +- (void)setFont:(NSFont *)font; +{ + NSArray *tableColumns; + NSUInteger columnIndex; + + tableColumns = [self tableColumns]; + columnIndex = [tableColumns count]; + while (columnIndex--) + [[(NSTableColumn *)[tableColumns objectAtIndex:columnIndex] dataCell] setFont:font]; +} + @end diff --git a/Source/TableContent.m b/Source/TableContent.m index 64996349..0a397707 100644 --- a/Source/TableContent.m +++ b/Source/TableContent.m @@ -224,7 +224,6 @@ // Init copyTable with necessary information for copying selected rows as SQL INSERT [tableContentView setTableInstance:self withTableData:tableValues withColumns:dataColumns withTableName:selectedTable withConnection:mySQLConnection]; - // Post the notification that the query is finished [[NSNotificationCenter defaultCenter] postNotificationName:@"SMySQLQueryHasBeenPerformed" object:tableDocumentInstance]; @@ -374,6 +373,8 @@ } NSString *nullValue = [prefs objectForKey:SPNullValue]; + NSFont *tableFont = [NSUnarchiver unarchiveObjectWithData:[prefs dataForKey:SPGlobalResultTableFont]]; + [tableContentView setRowHeight:2.0f+NSSizeToCGSize([[NSString stringWithString:@"{ǞṶḹÜ∑zgyf"] sizeWithAttributes:[NSDictionary dictionaryWithObject:tableFont forKey:NSFontAttributeName]]).height]; // Add the new columns to the table for ( i = 0 ; i < [dataColumns count] ; i++ ) { @@ -419,7 +420,7 @@ } // Set the data cell font according to the preferences - [dataCell setFont:([prefs boolForKey:SPUseMonospacedFonts]) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; + [dataCell setFont:tableFont]; // Assign the data cell [theCol setDataCell:dataCell]; @@ -3118,16 +3119,11 @@ if ([keyPath isEqualToString:SPDisplayTableViewVerticalGridlines]) { [tableContentView setGridStyleMask:([[change objectForKey:NSKeyValueChangeNewKey] boolValue]) ? NSTableViewSolidVerticalGridLineMask : NSTableViewGridNone]; } - // Use monospaced fonts preference changed - else if ([keyPath isEqualToString:SPUseMonospacedFonts]) { - - BOOL useMonospacedFont = [[change objectForKey:NSKeyValueChangeNewKey] boolValue]; - - for (NSTableColumn *column in [tableContentView tableColumns]) - { - [[column dataCell] setFont:(useMonospacedFont) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; - } - + // Table font preference changed + else if ([keyPath isEqualToString:SPGlobalResultTableFont]) { + NSFont *tableFont = [NSUnarchiver unarchiveObjectWithData:[change objectForKey:NSKeyValueChangeNewKey]]; + [tableContentView setRowHeight:2.0f+NSSizeToCGSize([[NSString stringWithString:@"{ǞṶḹÜ∑zgyf"] sizeWithAttributes:[NSDictionary dictionaryWithObject:tableFont forKey:NSFontAttributeName]]).height]; + [tableContentView setFont:tableFont]; [tableContentView reloadData]; } } diff --git a/Source/TableDocument.m b/Source/TableDocument.m index fecea349..368d9f94 100644 --- a/Source/TableDocument.m +++ b/Source/TableDocument.m @@ -179,10 +179,12 @@ // Register observers for the when the UseMonospacedFonts preference changes [prefs addObserver:tableSourceInstance forKeyPath:SPUseMonospacedFonts options:NSKeyValueObservingOptionNew context:NULL]; - [prefs addObserver:tableContentInstance forKeyPath:SPUseMonospacedFonts options:NSKeyValueObservingOptionNew context:NULL]; - [prefs addObserver:customQueryInstance forKeyPath:SPUseMonospacedFonts options:NSKeyValueObservingOptionNew context:NULL]; + // [prefs addObserver:tableContentInstance forKeyPath:SPUseMonospacedFonts options:NSKeyValueObservingOptionNew context:NULL]; + // [prefs addObserver:customQueryInstance forKeyPath:SPUseMonospacedFonts options:NSKeyValueObservingOptionNew context:NULL]; [prefs addObserver:[SPQueryController sharedQueryController] forKeyPath:SPUseMonospacedFonts options:NSKeyValueObservingOptionNew context:NULL]; - + + [prefs addObserver:tableContentInstance forKeyPath:SPGlobalResultTableFont options:NSKeyValueObservingOptionNew context:NULL]; + // Register observers for when the logging preference changes [prefs addObserver:[SPQueryController sharedQueryController] forKeyPath:SPConsoleEnableLogging options:NSKeyValueObservingOptionNew context:NULL]; -- cgit v1.2.3