From 043cc9df062d7167934401fd0b41b0ff6c22defc Mon Sep 17 00:00:00 2001 From: stuconnolly Date: Sun, 15 Nov 2009 00:43:03 +0000 Subject: Make the relations table view observe the use monospaced font preference. --- Source/SPTableRelations.m | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/Source/SPTableRelations.m b/Source/SPTableRelations.m index d16838be..d0ebb11b 100644 --- a/Source/SPTableRelations.m +++ b/Source/SPTableRelations.m @@ -61,6 +61,17 @@ // Set the table relation view's vertical gridlines if required [relationsTableView setGridStyleMask:([[NSUserDefaults standardUserDefaults] boolForKey:SPDisplayTableViewVerticalGridlines]) ? NSTableViewSolidVerticalGridLineMask : NSTableViewGridNone]; + // Set the strutcture and index view's font + BOOL useMonospacedFont = [[NSUserDefaults standardUserDefaults] boolForKey:SPUseMonospacedFonts]; + + for (NSTableColumn *column in [relationsTableView tableColumns]) + { + [[column dataCell] setFont:(useMonospacedFont) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]] : [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]; + [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(tableSelectionChanged:) name:SPTableChangedNotification @@ -377,9 +388,22 @@ */ - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { + // Display table veiew vertical gridlines preference changed if ([keyPath isEqualToString:SPDisplayTableViewVerticalGridlines]) { [relationsTableView 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 [relationsTableView tableColumns]) + { + [[column dataCell] setFont:(useMonospacedFont) ? [NSFont fontWithName:SPDefaultMonospacedFontName size:[NSFont smallSystemFontSize]] : [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]]; + } + + [relationsTableView reloadData]; + } } /** @@ -397,6 +421,8 @@ return YES; } +#pragma mark - + /* * Dealloc. */ -- cgit v1.2.3