From: <ho...@us...> - 2010-09-28 09:52:34
|
Revision: 6847 http://skim-app.svn.sourceforge.net/skim-app/?rev=6847&view=rev Author: hofman Date: 2010-09-28 09:52:27 +0000 (Tue, 28 Sep 2010) Log Message: ----------- observe table font size changes only in main window controller and not in table classes, as we also need to update the page column widths Modified Paths: -------------- trunk/SKFindTableView.m trunk/SKMainWindowController.m trunk/SKNoteOutlineView.m trunk/SKOutlineView.h trunk/SKOutlineView.m trunk/SKTableView.h trunk/SKTableView.m trunk/SKTocOutlineView.m Modified: trunk/SKFindTableView.m =================================================================== --- trunk/SKFindTableView.m 2010-09-24 14:06:42 UTC (rev 6846) +++ trunk/SKFindTableView.m 2010-09-28 09:52:27 UTC (rev 6847) @@ -42,8 +42,6 @@ @implementation SKFindTableView -+ (BOOL)usesDefaultFontSize { return YES; } - - (void)awakeFromNib { [super awakeFromNib]; [[[self tableColumnWithIdentifier:PAGE_COLUMNID] headerCell] setTitle:NSLocalizedString(@"Page", @"Table header title")]; Modified: trunk/SKMainWindowController.m =================================================================== --- trunk/SKMainWindowController.m 2010-09-24 14:06:42 UTC (rev 6846) +++ trunk/SKMainWindowController.m 2010-09-28 09:52:27 UTC (rev 6847) @@ -343,6 +343,12 @@ [leftSideController.groupedFindTableView setDoubleAction:@selector(goToSelectedFindResults:)]; [leftSideController.groupedFindTableView setTarget:self]; + NSFont *font = [NSFont systemFontOfSize:[[NSUserDefaults standardUserDefaults] floatForKey:SKTableFontSizeKey]]; + [leftSideController.tocOutlineView setFont:font]; + [rightSideController.noteOutlineView setFont:font]; + [leftSideController.findTableView setFont:font]; + [leftSideController.groupedFindTableView setFont:font]; + if (mwcFlags.usesDrawers) { leftSideDrawer = [[NSDrawer alloc] initWithContentSize:[leftSideContentView frame].size preferredEdge:NSMinXEdge]; [leftSideDrawer setParentWindow:[self window]]; @@ -2221,7 +2227,13 @@ } else if ([key isEqualToString:SKTableFontSizeKey]) { NSFont *font = [NSFont systemFontOfSize:[[NSUserDefaults standardUserDefaults] floatForKey:SKTableFontSizeKey]]; [leftSideController.tocOutlineView setFont:font]; + [rightSideController.noteOutlineView setFont:font]; + [leftSideController.findTableView setFont:font]; + [leftSideController.groupedFindTableView setFont:font]; [self updatePageColumnWidthForTableView:leftSideController.tocOutlineView]; + [self updatePageColumnWidthForTableView:rightSideController.noteOutlineView]; + [self updatePageColumnWidthForTableView:leftSideController.findTableView]; + [self updatePageColumnWidthForTableView:leftSideController.groupedFindTableView]; } } else if (context == &SKNPDFAnnotationPropertiesObservationContext) { Modified: trunk/SKNoteOutlineView.m =================================================================== --- trunk/SKNoteOutlineView.m 2010-09-24 14:06:42 UTC (rev 6846) +++ trunk/SKNoteOutlineView.m 2010-09-28 09:52:27 UTC (rev 6847) @@ -49,8 +49,6 @@ @implementation SKNoteOutlineView -+ (BOOL)usesDefaultFontSize { return YES; } - - (void)awakeFromNib { [super awakeFromNib]; Modified: trunk/SKOutlineView.h =================================================================== --- trunk/SKOutlineView.h 2010-09-24 14:06:42 UTC (rev 6846) +++ trunk/SKOutlineView.h 2010-09-28 09:52:27 UTC (rev 6847) @@ -45,8 +45,6 @@ SKTypeSelectHelper *typeSelectHelper; } -+ (BOOL)usesDefaultFontSize; - @property (nonatomic, readonly) NSArray *selectedItems; @property (nonatomic, readonly) BOOL canDelete, canCopy, canPaste; @property (nonatomic, retain) SKTypeSelectHelper *typeSelectHelper; Modified: trunk/SKOutlineView.m =================================================================== --- trunk/SKOutlineView.m 2010-09-24 14:06:42 UTC (rev 6846) +++ trunk/SKOutlineView.m 2010-09-28 09:52:27 UTC (rev 6847) @@ -45,48 +45,18 @@ #define SPACE_CHARACTER 0x20 -static char SKOutlineViewDefaultsObservationContext; - @implementation SKOutlineView @synthesize typeSelectHelper; @dynamic selectedItems, canDelete, canCopy, canPaste; -+ (BOOL)usesDefaultFontSize { return NO; } - - (void)dealloc { - if ([[self class] usesDefaultFontSize]) { - @try { [[NSUserDefaultsController sharedUserDefaultsController] removeObserver:self forKey:SKTableFontSizeKey]; } - @catch (id e) {} - } [typeSelectHelper setDataSource:nil]; SKDESTROY(typeSelectHelper); [super dealloc]; } -- (void)awakeFromNib { - if ([[self class] usesDefaultFontSize]) { - NSNumber *fontSize = [[NSUserDefaults standardUserDefaults] objectForKey:SKTableFontSizeKey]; - if (fontSize) - [self setFont:[NSFont systemFontOfSize:[fontSize doubleValue]]]; - [[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKey:SKTableFontSizeKey context:&SKOutlineViewDefaultsObservationContext]; - } - if ([[SKOutlineView superclass] instancesRespondToSelector:_cmd]) - [super awakeFromNib]; -} - -- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { - if (context == &SKOutlineViewDefaultsObservationContext) { - NSString *key = [keyPath substringFromIndex:7]; - if ([key isEqualToString:SKTableFontSizeKey]) { - [self setFont:[NSFont systemFontOfSize:[[NSUserDefaults standardUserDefaults] floatForKey:SKTableFontSizeKey]]]; - } - } else { - [super observeValueForKeyPath:keyPath ofObject:object change:change context:context]; - } -} - - (NSArray *)selectedItems { NSMutableArray *items = [NSMutableArray array]; NSIndexSet *indexes = [self selectedRowIndexes]; Modified: trunk/SKTableView.h =================================================================== --- trunk/SKTableView.h 2010-09-24 14:06:42 UTC (rev 6846) +++ trunk/SKTableView.h 2010-09-28 09:52:27 UTC (rev 6847) @@ -47,8 +47,6 @@ SKTypeSelectHelper *typeSelectHelper; } -+ (BOOL)usesDefaultFontSize; - @property (nonatomic, readonly) BOOL canDelete, canCopy, canPaste; @property (nonatomic, retain) SKTypeSelectHelper *typeSelectHelper; Modified: trunk/SKTableView.m =================================================================== --- trunk/SKTableView.m 2010-09-24 14:06:42 UTC (rev 6846) +++ trunk/SKTableView.m 2010-09-28 09:52:27 UTC (rev 6847) @@ -46,9 +46,7 @@ #define SPACE_CHARACTER 0x20 -static char SKTableViewDefaultsObservationContext; - @interface SKTableView (SKPrivate) - (void)rebuildTrackingAreas; @end @@ -59,41 +57,13 @@ @synthesize typeSelectHelper; @dynamic canDelete, canCopy, canPaste; -+ (BOOL)usesDefaultFontSize { return NO; } - - (void)dealloc { - if ([[self class] usesDefaultFontSize]) { - @try { [[NSUserDefaultsController sharedUserDefaultsController] removeObserver:self forKey:SKTableFontSizeKey]; } - @catch (id e) {} - } SKDESTROY(trackingAreas); [typeSelectHelper setDataSource:nil]; SKDESTROY(typeSelectHelper); [super dealloc]; } -- (void)awakeFromNib { - if ([[self class] usesDefaultFontSize]) { - NSNumber *fontSize = [[NSUserDefaults standardUserDefaults] objectForKey:SKTableFontSizeKey]; - if (fontSize) - [self setFont:[NSFont systemFontOfSize:[fontSize doubleValue]]]; - [[NSUserDefaultsController sharedUserDefaultsController] addObserver:self forKey:SKTableFontSizeKey context:&SKTableViewDefaultsObservationContext]; - } - if ([[SKTableView superclass] instancesRespondToSelector:_cmd]) - [super awakeFromNib]; -} - -- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { - if (context == &SKTableViewDefaultsObservationContext) { - NSString *key = [keyPath substringFromIndex:7]; - if ([key isEqualToString:SKTableFontSizeKey]) { - [self setFont:[NSFont systemFontOfSize:[[NSUserDefaults standardUserDefaults] floatForKey:SKTableFontSizeKey]]]; - } - } else { - [super observeValueForKeyPath:keyPath ofObject:object change:change context:context]; - } -} - - (void)setTypeSelectHelper:(SKTypeSelectHelper *)newTypeSelectHelper { if (typeSelectHelper != newTypeSelectHelper) { if ([typeSelectHelper dataSource] == self) Modified: trunk/SKTocOutlineView.m =================================================================== --- trunk/SKTocOutlineView.m 2010-09-24 14:06:42 UTC (rev 6846) +++ trunk/SKTocOutlineView.m 2010-09-28 09:52:27 UTC (rev 6847) @@ -44,8 +44,6 @@ @implementation SKTocOutlineView -+ (BOOL)usesDefaultFontSize { return YES; } - - (void)dealloc { SKDESTROY(trackingAreas); [super dealloc]; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |