From f25c62d78bbd5d6fbe7a6fac09294317ccd3eeaf Mon Sep 17 00:00:00 2001 From: Stuart Connolly Date: Mon, 26 May 2014 23:01:08 +0100 Subject: Add a hidden preference to control the size of the UI's monospaced font. --- Source/SPConstants.h | 1 + Source/SPConstants.m | 1 + Source/SPDataImport.m | 10 ++++------ Source/SPFieldEditorController.m | 6 ++++-- Source/SPFieldMapperController.m | 4 +++- Source/SPIndexesController.m | 12 ++++++++---- Source/SPProcessListController.m | 10 ++++++---- Source/SPQueryController.m | 3 ++- Source/SPQueryControllerInitializer.m | 5 +++-- Source/SPServerVariablesController.h | 3 ++- Source/SPServerVariablesController.m | 14 ++++++++------ Source/SPTableRelations.m | 8 +++++--- Source/SPTableStructure.m | 22 +++++++++++++--------- Source/SPTableStructureDelegate.m | 5 ++++- Source/SPTableStructureLoading.m | 6 ++++-- Source/SPTableTriggers.h | 1 + Source/SPTableTriggers.m | 22 ++++++++++++++-------- 17 files changed, 83 insertions(+), 50 deletions(-) (limited to 'Source') diff --git a/Source/SPConstants.h b/Source/SPConstants.h index f0f194b4..1778a1d5 100644 --- a/Source/SPConstants.h +++ b/Source/SPConstants.h @@ -371,6 +371,7 @@ extern NSString *SPAlwaysShowWindowTabBar; extern NSString *SPResetAutoIncrementAfterDeletionOfAllRows; extern NSString *SPFavoriteColorList; extern NSString *SPDisplayBinaryDataAsHex; +extern NSString *SPMonospacedFontSize; // Hidden Prefs extern NSString *SPPrintWarningRowLimit; diff --git a/Source/SPConstants.m b/Source/SPConstants.m index ceae92c6..a1bcce8d 100644 --- a/Source/SPConstants.m +++ b/Source/SPConstants.m @@ -177,6 +177,7 @@ NSString *SPAlwaysShowWindowTabBar = @"WindowAlwaysShowTabBar"; NSString *SPResetAutoIncrementAfterDeletionOfAllRows = @"ResetAutoIncrementAfterDeletionOfAllRows"; NSString *SPFavoriteColorList = @"FavoriteColorList"; NSString *SPDisplayBinaryDataAsHex = @"DisplayBinaryDataAsHex"; +NSString *SPMonospacedFontSize = @"MonospacedFontSize"; // Hidden Prefs NSString *SPPrintWarningRowLimit = @"PrintWarningRowLimit"; diff --git a/Source/SPDataImport.m b/Source/SPDataImport.m index 3ab6ee48..26c56348 100644 --- a/Source/SPDataImport.m +++ b/Source/SPDataImport.m @@ -1634,12 +1634,10 @@ [switchButton setButtonType:NSSwitchButton]; [switchButton setControlSize:NSSmallControlSize]; [switchButton release]; - - if ([prefs boolForKey:SPUseMonospacedFonts]) { - [errorsView setFont:[NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]]]; - } else { - [errorsView setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; - } + + CGFloat monospacedFontSize = [[NSUserDefaults standardUserDefaults] floatForKey:SPMonospacedFontSize] > 0 ? [prefs floatForKey:SPMonospacedFontSize] : [NSFont smallSystemFontSize]; + + [errorsView setFont:[prefs boolForKey:SPUseMonospacedFonts] ? [NSFont fontWithName:SPDefaultMonospacedFontName size:monospacedFontSize] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; } /** diff --git a/Source/SPFieldEditorController.m b/Source/SPFieldEditorController.m index 6e1e1fd5..9c2de5fc 100644 --- a/Source/SPFieldEditorController.m +++ b/Source/SPFieldEditorController.m @@ -232,6 +232,8 @@ if ([fieldEncoding length]) [label appendString:fieldEncoding]; + CGFloat monospacedFontSize = [prefs floatForKey:SPMonospacedFontSize] > 0 ? [prefs floatForKey:SPMonospacedFontSize] : [NSFont smallSystemFontSize]; + if ([fieldType length] && [[fieldType uppercaseString] isEqualToString:@"BIT"]) { sheetEditData = [(NSString*)data retain]; @@ -284,7 +286,7 @@ #endif [editTextView setFont: #ifndef SP_CODA - ([prefs boolForKey:SPUseMonospacedFonts]) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]] : + [prefs boolForKey:SPUseMonospacedFonts] ? [NSFont fontWithName:SPDefaultMonospacedFontName size:monospacedFontSize] : #endif [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; #ifndef SP_CODA @@ -302,7 +304,7 @@ #endif ]; - [hexTextView setFont:[NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]]]; + [hexTextView setFont:[NSFont fontWithName:SPDefaultMonospacedFontName size:monospacedFontSize]]; [editSheetFieldName setStringValue:[NSString stringWithFormat:@"%@: %@", NSLocalizedString(@"Field", @"Field"), label]]; diff --git a/Source/SPFieldMapperController.m b/Source/SPFieldMapperController.m index ea44162f..397c017f 100644 --- a/Source/SPFieldMapperController.m +++ b/Source/SPFieldMapperController.m @@ -1639,7 +1639,9 @@ static NSUInteger SPSourceColumnTypeInteger = 1; - (void)tableView:(NSTableView *)aTableView willDisplayCell:(id)aCell forTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex { #ifndef SP_CODA - [aCell setFont:([prefs boolForKey:SPUseMonospacedFonts]) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; + CGFloat monospacedFontSize = [prefs floatForKey:SPMonospacedFontSize] > 0 ? [prefs floatForKey:SPMonospacedFontSize] : [NSFont smallSystemFontSize]; + + [aCell setFont:[prefs boolForKey:SPUseMonospacedFonts] ? [NSFont fontWithName:SPDefaultMonospacedFontName size:monospacedFontSize] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; #endif } diff --git a/Source/SPIndexesController.m b/Source/SPIndexesController.m index 49a19d1f..7236a977 100644 --- a/Source/SPIndexesController.m +++ b/Source/SPIndexesController.m @@ -132,17 +132,19 @@ static const NSString *SPNewIndexKeyBlockSize = @"IndexKeyBlockSize"; BOOL useMonospacedFont = NO; #endif + CGFloat monospacedFontSize = [prefs floatForKey:SPMonospacedFontSize] > 0 ? [prefs floatForKey:SPMonospacedFontSize] : [NSFont smallSystemFontSize]; + // Set the double-click action in blank areas of the table to create new rows [indexesTableView setEmptyDoubleClickAction:@selector(addIndex:)]; for (NSTableColumn *indexColumn in [indexesTableView tableColumns]) { - [[indexColumn dataCell] setFont:(useMonospacedFont) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; + [[indexColumn dataCell] setFont:useMonospacedFont ? [NSFont fontWithName:SPDefaultMonospacedFontName size:monospacedFontSize] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; } for (NSTableColumn *fieldColumn in [indexedColumnsTableView tableColumns]) { - [[fieldColumn dataCell] setFont:(useMonospacedFont) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; + [[fieldColumn dataCell] setFont:useMonospacedFont ? [NSFont fontWithName:SPDefaultMonospacedFontName size:monospacedFontSize] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; } #ifndef SP_CODA /* patch */ @@ -707,18 +709,20 @@ static const NSString *SPNewIndexKeyBlockSize = @"IndexKeyBlockSize"; else if ([keyPath isEqualToString:SPUseMonospacedFonts]) { BOOL useMonospacedFont = [[change objectForKey:NSKeyValueChangeNewKey] boolValue]; + CGFloat monospacedFontSize = [prefs floatForKey:SPMonospacedFontSize] > 0 ? [prefs floatForKey:SPMonospacedFontSize] : [NSFont smallSystemFontSize]; for (NSTableColumn *indexColumn in [indexesTableView tableColumns]) { - [[indexColumn dataCell] setFont:(useMonospacedFont) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; + [[indexColumn dataCell] setFont:useMonospacedFont ? [NSFont fontWithName:SPDefaultMonospacedFontName size:monospacedFontSize] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; } for (NSTableColumn *indexColumn in [indexedColumnsTableView tableColumns]) { - [[indexColumn dataCell] setFont:(useMonospacedFont) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; + [[indexColumn dataCell] setFont:useMonospacedFont ? [NSFont fontWithName:SPDefaultMonospacedFontName size:monospacedFontSize] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; } [indexesTableView reloadData]; + [self _reloadIndexedColumnsTableData]; } } diff --git a/Source/SPProcessListController.m b/Source/SPProcessListController.m index ef6e91ab..956b0d9b 100644 --- a/Source/SPProcessListController.m +++ b/Source/SPProcessListController.m @@ -97,10 +97,11 @@ static NSString *SPTableViewIDColumnIdentifier = @"Id"; // Set the strutcture and index view's font BOOL useMonospacedFont = [prefs boolForKey:SPUseMonospacedFonts]; - + CGFloat monospacedFontSize = [prefs floatForKey:SPMonospacedFontSize] > 0 ? [prefs floatForKey:SPMonospacedFontSize] : [NSFont smallSystemFontSize]; + for (NSTableColumn *column in [processListTableView tableColumns]) { - [[column dataCell] setFont:(useMonospacedFont) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; + [[column dataCell] setFont:useMonospacedFont ? [NSFont fontWithName:SPDefaultMonospacedFontName size:monospacedFontSize] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; // Add a formatter for linebreak display [[column dataCell] setFormatter:[[SPDataCellFormatter new] autorelease]]; @@ -460,10 +461,11 @@ static NSString *SPTableViewIDColumnIdentifier = @"Id"; else if ([keyPath isEqualToString:SPUseMonospacedFonts]) { BOOL useMonospacedFont = [[change objectForKey:NSKeyValueChangeNewKey] boolValue]; - + CGFloat monospacedFontSize = [prefs floatForKey:SPMonospacedFontSize] > 0 ? [prefs floatForKey:SPMonospacedFontSize] : [NSFont smallSystemFontSize]; + for (NSTableColumn *column in [processListTableView tableColumns]) { - [[column dataCell] setFont:(useMonospacedFont) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; + [[column dataCell] setFont:useMonospacedFont ? [NSFont fontWithName:SPDefaultMonospacedFontName size:monospacedFontSize] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; } [processListTableView reloadData]; diff --git a/Source/SPQueryController.m b/Source/SPQueryController.m index caa74c53..feaa1624 100644 --- a/Source/SPQueryController.m +++ b/Source/SPQueryController.m @@ -353,10 +353,11 @@ static SPQueryController *sharedQueryController = nil; else if ([keyPath isEqualToString:SPUseMonospacedFonts]) { BOOL useMonospacedFont = [[change objectForKey:NSKeyValueChangeNewKey] boolValue]; + CGFloat monospacedFontSize = [prefs floatForKey:SPMonospacedFontSize] > 0 ? [prefs floatForKey:SPMonospacedFontSize] : [NSFont smallSystemFontSize]; for (NSTableColumn *column in [consoleTableView tableColumns]) { - [[column dataCell] setFont:(useMonospacedFont) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; + [[column dataCell] setFont:(useMonospacedFont) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:monospacedFontSize] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; } [consoleTableView reloadData]; diff --git a/Source/SPQueryControllerInitializer.m b/Source/SPQueryControllerInitializer.m index 9f0d1f11..93854863 100644 --- a/Source/SPQueryControllerInitializer.m +++ b/Source/SPQueryControllerInitializer.m @@ -78,10 +78,11 @@ static NSString *SPCompletionTokensSnippetsKey = @"function_argument_snippets"; // Set the strutcture and index view's font BOOL useMonospacedFont = [prefs boolForKey:SPUseMonospacedFonts]; - + CGFloat monospacedFontSize = [prefs floatForKey:SPMonospacedFontSize] > 0 ? [prefs floatForKey:SPMonospacedFontSize] : [NSFont smallSystemFontSize]; + for (NSTableColumn *column in [consoleTableView tableColumns]) { - [[column dataCell] setFont:(useMonospacedFont) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; + [[column dataCell] setFont:(useMonospacedFont) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:monospacedFontSize] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; } #endif } diff --git a/Source/SPServerVariablesController.h b/Source/SPServerVariablesController.h index 160f1dc8..4d15fb2b 100644 --- a/Source/SPServerVariablesController.h +++ b/Source/SPServerVariablesController.h @@ -33,7 +33,8 @@ @interface SPServerVariablesController : NSWindowController { SPMySQLConnection *connection; - + + NSUserDefaults *prefs; NSMutableArray *variables, *variablesFiltered; IBOutlet NSTableView *variablesTableView; diff --git a/Source/SPServerVariablesController.m b/Source/SPServerVariablesController.m index 7e66ff0c..a2e1e059 100644 --- a/Source/SPServerVariablesController.m +++ b/Source/SPServerVariablesController.m @@ -60,17 +60,18 @@ - (void)awakeFromNib { - NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults]; + prefs = [NSUserDefaults standardUserDefaults]; // Set the process table view's vertical gridlines if required [variablesTableView setGridStyleMask:([prefs boolForKey:SPDisplayTableViewVerticalGridlines]) ? NSTableViewSolidVerticalGridLineMask : NSTableViewGridNone]; // Set the strutcture and index view's font BOOL useMonospacedFont = [prefs boolForKey:SPUseMonospacedFonts]; - + CGFloat monospacedFontSize = [prefs floatForKey:SPMonospacedFontSize] > 0 ? [prefs floatForKey:SPMonospacedFontSize] : [NSFont smallSystemFontSize]; + for (NSTableColumn *column in [variablesTableView tableColumns]) { - [[column dataCell] setFont:(useMonospacedFont) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; + [[column dataCell] setFont:useMonospacedFont ? [NSFont fontWithName:SPDefaultMonospacedFontName size:monospacedFontSize] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; } // Register as an observer for the when the UseMonospacedFonts preference changes @@ -216,10 +217,11 @@ else if ([keyPath isEqualToString:SPUseMonospacedFonts]) { BOOL useMonospacedFont = [[change objectForKey:NSKeyValueChangeNewKey] boolValue]; - + CGFloat monospacedFontSize = [prefs floatForKey:SPMonospacedFontSize] > 0 ? [prefs floatForKey:SPMonospacedFontSize] : [NSFont smallSystemFontSize]; + for (NSTableColumn *column in [variablesTableView tableColumns]) { - [[column dataCell] setFont:(useMonospacedFont) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; + [[column dataCell] setFont:(useMonospacedFont) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:monospacedFontSize] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; } [variablesTableView reloadData]; @@ -377,7 +379,7 @@ - (void)dealloc { - [[NSUserDefaults standardUserDefaults] removeObserver:self forKeyPath:SPUseMonospacedFonts]; + [prefs removeObserver:self forKeyPath:SPUseMonospacedFonts]; [variables release], variables = nil; diff --git a/Source/SPTableRelations.m b/Source/SPTableRelations.m index 7df13d27..f2188a3b 100644 --- a/Source/SPTableRelations.m +++ b/Source/SPTableRelations.m @@ -88,10 +88,11 @@ static NSString *SPRelationOnDeleteKey = @"on_delete"; // Set the strutcture and index view's font BOOL useMonospacedFont = [[NSUserDefaults standardUserDefaults] boolForKey:SPUseMonospacedFonts]; - + CGFloat monospacedFontSize = [prefs floatForKey:SPMonospacedFontSize] > 0 ? [prefs floatForKey:SPMonospacedFontSize] : [NSFont smallSystemFontSize]; + for (NSTableColumn *column in [relationsTableView tableColumns]) { - [[column dataCell] setFont:(useMonospacedFont) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; + [[column dataCell] setFont:(useMonospacedFont) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:monospacedFontSize] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; } // Register as an observer for the when the UseMonospacedFonts preference changes @@ -536,10 +537,11 @@ static NSString *SPRelationOnDeleteKey = @"on_delete"; else if ([keyPath isEqualToString:SPUseMonospacedFonts]) { BOOL useMonospacedFont = [[change objectForKey:NSKeyValueChangeNewKey] boolValue]; + CGFloat monospacedFontSize = [prefs floatForKey:SPMonospacedFontSize] > 0 ? [prefs floatForKey:SPMonospacedFontSize] : [NSFont smallSystemFontSize]; for (NSTableColumn *column in [relationsTableView tableColumns]) { - [[column dataCell] setFont:(useMonospacedFont) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; + [[column dataCell] setFont:(useMonospacedFont) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:monospacedFontSize] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; } [relationsTableView reloadData]; diff --git a/Source/SPTableStructure.m b/Source/SPTableStructure.m index 807ff1ae..05bf1186 100644 --- a/Source/SPTableStructure.m +++ b/Source/SPTableStructure.m @@ -100,17 +100,20 @@ static NSString *SPRemoveFieldAndForeignKey = @"SPRemoveFieldAndForeignKey"; { #ifndef SP_CODA /* ui manipulation */ // Set the structure and index view's vertical gridlines if required - [tableSourceView setGridStyleMask:([prefs boolForKey:SPDisplayTableViewVerticalGridlines]) ? NSTableViewSolidVerticalGridLineMask : NSTableViewGridNone]; - [indexesTableView setGridStyleMask:([prefs boolForKey:SPDisplayTableViewVerticalGridlines]) ? NSTableViewSolidVerticalGridLineMask : NSTableViewGridNone]; + [tableSourceView setGridStyleMask:[prefs boolForKey:SPDisplayTableViewVerticalGridlines] ? NSTableViewSolidVerticalGridLineMask : NSTableViewGridNone]; + [indexesTableView setGridStyleMask:[prefs boolForKey:SPDisplayTableViewVerticalGridlines] ? NSTableViewSolidVerticalGridLineMask : NSTableViewGridNone]; #endif // Set the double-click action in blank areas of the table to create new rows [tableSourceView setEmptyDoubleClickAction:@selector(addField:)]; #ifndef SP_CODA /* set font from prefs */ + BOOL useMonospacedFont = [prefs boolForKey:SPUseMonospacedFonts]; + NSInteger monospacedFontSize = [prefs integerForKey:SPMonospacedFontSize] > 0 ? [prefs integerForKey:SPMonospacedFontSize] : [NSFont smallSystemFontSize]; + // Set the strutcture and index view's font - [tableSourceView setFont:([prefs boolForKey:SPUseMonospacedFonts]) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; - [indexesTableView setFont:([prefs boolForKey:SPUseMonospacedFonts]) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; + [tableSourceView setFont:useMonospacedFont ? [NSFont fontWithName:SPDefaultMonospacedFontName size:monospacedFontSize] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; + [indexesTableView setFont:useMonospacedFont ? [NSFont fontWithName:SPDefaultMonospacedFontName size:monospacedFontSize] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; #endif extraFieldSuggestions = [[NSArray arrayWithObjects: @@ -1159,7 +1162,7 @@ static NSString *SPRemoveFieldAndForeignKey = @"SPRemoveFieldAndForeignKey"; else { [self cancelRowEditing]; } - + [tableSourceView reloadData]; } @@ -1178,11 +1181,12 @@ static NSString *SPRemoveFieldAndForeignKey = @"SPRemoveFieldAndForeignKey"; } // Use monospaced fonts preference changed else if ([keyPath isEqualToString:SPUseMonospacedFonts]) { - + BOOL useMonospacedFont = [[change objectForKey:NSKeyValueChangeNewKey] boolValue]; - - [tableSourceView setFont:(useMonospacedFont) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; - [indexesTableView setFont:(useMonospacedFont) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; + CGFloat monospacedFontSize = [prefs floatForKey:SPMonospacedFontSize] > 0 ? [prefs floatForKey:SPMonospacedFontSize] : [NSFont smallSystemFontSize]; + + [tableSourceView setFont:useMonospacedFont ? [NSFont fontWithName:SPDefaultMonospacedFontName size:monospacedFontSize] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; + [indexesTableView setFont:useMonospacedFont ? [NSFont fontWithName:SPDefaultMonospacedFontName size:monospacedFontSize] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; [tableSourceView reloadData]; [indexesTableView reloadData]; diff --git a/Source/SPTableStructureDelegate.m b/Source/SPTableStructureDelegate.m index 6adbc0df..aebb0f18 100644 --- a/Source/SPTableStructureDelegate.m +++ b/Source/SPTableStructureDelegate.m @@ -87,6 +87,9 @@ } [[tableColumn dataCell] addItemWithTitle:@""]; + + BOOL useMonospacedFont = [prefs boolForKey:SPUseMonospacedFonts]; + CGFloat monospacedFontSize = [prefs floatForKey:SPMonospacedFontSize] > 0 ? [prefs floatForKey:SPMonospacedFontSize] : [NSFont smallSystemFontSize]; // Populate collation popup button for (NSDictionary *collation in collations) @@ -100,7 +103,7 @@ NSMenuItem *collationMenuItem = [(NSPopUpButtonCell *)[tableColumn dataCell] itemAtIndex:([[tableColumn dataCell] numberOfItems] - 1)]; NSMutableDictionary *menuAttributes = [NSMutableDictionary dictionaryWithObject:[NSColor lightGrayColor] forKey:NSForegroundColorAttributeName]; - [menuAttributes setObject:[prefs boolForKey:SPUseMonospacedFonts] ? [NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]] forKey:NSFontAttributeName]; + [menuAttributes setObject:useMonospacedFont ? [NSFont fontWithName:SPDefaultMonospacedFontName size:monospacedFontSize] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]] forKey:NSFontAttributeName]; NSAttributedString *itemString = [[[NSAttributedString alloc] initWithString:collationName attributes:menuAttributes] autorelease]; diff --git a/Source/SPTableStructureLoading.m b/Source/SPTableStructureLoading.m index 07656155..9e9edd5c 100644 --- a/Source/SPTableStructureLoading.m +++ b/Source/SPTableStructureLoading.m @@ -142,8 +142,10 @@ [menuStyle setLineBreakMode:NSLineBreakByTruncatingTail]; NSMutableDictionary *menuAttributes = [NSMutableDictionary dictionaryWithObject:[NSColor lightGrayColor] forKey:NSForegroundColorAttributeName]; - - [menuAttributes setObject:[prefs boolForKey:SPUseMonospacedFonts] ? [NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]] forKey:NSFontAttributeName]; + + CGFloat monospacedFontSize = [prefs floatForKey:SPMonospacedFontSize] > 0 ? [prefs floatForKey:SPMonospacedFontSize] : [NSFont smallSystemFontSize]; + + [menuAttributes setObject:[prefs boolForKey:SPUseMonospacedFonts] ? [NSFont fontWithName:SPDefaultMonospacedFontName size:monospacedFontSize] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]] forKey:NSFontAttributeName]; NSAttributedString *itemString = [[[NSAttributedString alloc] initWithString:defaultEncodingDescription attributes:menuAttributes] autorelease]; diff --git a/Source/SPTableTriggers.h b/Source/SPTableTriggers.h index 3de60063..bf2f78d5 100644 --- a/Source/SPTableTriggers.h +++ b/Source/SPTableTriggers.h @@ -57,6 +57,7 @@ SPMySQLConnection *connection; NSMutableArray *triggerData; + NSUserDefaults *prefs; BOOL isEdit; diff --git a/Source/SPTableTriggers.m b/Source/SPTableTriggers.m index 931d0218..1ab39825 100644 --- a/Source/SPTableTriggers.m +++ b/Source/SPTableTriggers.m @@ -80,24 +80,28 @@ static const NSString *SPTriggerSQLMode = @"TriggerSQLMode"; */ - (void)awakeFromNib { + prefs = [NSUserDefaults standardUserDefaults]; + // Set the table triggers view's vertical gridlines if required - [triggersTableView setGridStyleMask:([[NSUserDefaults standardUserDefaults] boolForKey:SPDisplayTableViewVerticalGridlines]) ? NSTableViewSolidVerticalGridLineMask : NSTableViewGridNone]; + [triggersTableView setGridStyleMask:[prefs boolForKey:SPDisplayTableViewVerticalGridlines] ? NSTableViewSolidVerticalGridLineMask : NSTableViewGridNone]; // Set the double-click action in blank areas of the table to create new rows [triggersTableView setEmptyDoubleClickAction:@selector(addTrigger:)]; // Set the strutcture and index view's font - BOOL useMonospacedFont = [[NSUserDefaults standardUserDefaults] boolForKey:SPUseMonospacedFonts]; + BOOL useMonospacedFont = [prefs boolForKey:SPUseMonospacedFonts]; + + CGFloat monospacedFontSize = [prefs floatForKey:SPMonospacedFontSize] > 0 ? [prefs floatForKey:SPMonospacedFontSize] : [NSFont smallSystemFontSize]; [addTriggerPanel setInitialFirstResponder:triggerNameTextField]; for (NSTableColumn *column in [triggersTableView tableColumns]) { - [[column dataCell] setFont:(useMonospacedFont) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; + [[column dataCell] setFont:useMonospacedFont ? [NSFont fontWithName:SPDefaultMonospacedFontName size:monospacedFontSize] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; } // Register as an observer for the when the UseMonospacedFonts preference changes - [[NSUserDefaults standardUserDefaults] addObserver:self forKeyPath:SPUseMonospacedFonts options:NSKeyValueObservingOptionNew context:NULL]; + [prefs addObserver:self forKeyPath:SPUseMonospacedFonts options:NSKeyValueObservingOptionNew context:NULL]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(triggerStatementTextDidChange:) @@ -331,8 +335,9 @@ static const NSString *SPTriggerSQLMode = @"TriggerSQLMode"; { id value = [[triggerData objectAtIndex:rowIndex] objectForKey:[tableColumn identifier]]; - if ([value isNSNull]) - return [[NSUserDefaults standardUserDefaults] objectForKey:SPNullValue]; + if ([value isNSNull]) { + return [prefs objectForKey:SPNullValue]; + } return value; } @@ -425,10 +430,11 @@ static const NSString *SPTriggerSQLMode = @"TriggerSQLMode"; else if ([keyPath isEqualToString:SPUseMonospacedFonts]) { BOOL useMonospacedFont = [[change objectForKey:NSKeyValueChangeNewKey] boolValue]; + CGFloat monospacedFontSize = [prefs floatForKey:SPMonospacedFontSize] > 0 ? [prefs floatForKey:SPMonospacedFontSize] : [NSFont smallSystemFontSize]; for (NSTableColumn *column in [triggersTableView tableColumns]) { - [[column dataCell] setFont:(useMonospacedFont) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; + [[column dataCell] setFont:useMonospacedFont ? [NSFont fontWithName:SPDefaultMonospacedFontName size:monospacedFontSize] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; } [triggersTableView reloadData]; @@ -630,7 +636,7 @@ static const NSString *SPTriggerSQLMode = @"TriggerSQLMode"; [editedTrigger release], editedTrigger = nil; [[NSNotificationCenter defaultCenter] removeObserver:self]; - [[NSUserDefaults standardUserDefaults] removeObserver:self forKeyPath:SPUseMonospacedFonts]; + [prefs removeObserver:self forKeyPath:SPUseMonospacedFonts]; [super dealloc]; } -- cgit v1.2.3