Skip to content

Commit

Permalink
align table row and column-header cell spacing to editor text inset a…
Browse files Browse the repository at this point in the history
…s per Stakker's suggestion: http://github.com/scrod/nv/issues/50
  • Loading branch information
Zachary Schneirov committed Feb 24, 2010
1 parent 9e62371 commit a264118
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 10 deletions.
2 changes: 1 addition & 1 deletion LinkingEditor.m
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ - (void)awakeFromNib {
@selector(setMakeURLsClickable:sender:),
@selector(setSearchTermHighlightColor:sender:), nil];

[self setTextContainerInset:NSMakeSize(2, 6)];
[self setTextContainerInset:NSMakeSize(3, 8)];
[self setSmartInsertDeleteEnabled:NO];
[self setUsesRuler:NO];
[self setUsesFontPanel:NO];
Expand Down
6 changes: 6 additions & 0 deletions NoteAttributeColumn.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@

@class NotesTableView;

@interface NoteTableHeaderCell : NSTableHeaderCell {

}

@end

@interface NoteAttributeColumn : NSTableColumn {

NSInteger (*sortFunction) (id*, id*);
Expand Down
11 changes: 9 additions & 2 deletions NoteAttributeColumn.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,22 @@
#import "NoteAttributeColumn.h"
#import "NotesTableView.h"

@implementation NoteAttributeColumn

@implementation NoteTableHeaderCell

- (NSRect)drawingRectForBounds:(NSRect)theRect {
return NSInsetRect(theRect, 6.0f, 0.0);
}

@end

@implementation NoteAttributeColumn

- (id)initWithIdentifier:(id)anObject {

if ([super initWithIdentifier:anObject]) {

absoluteMinimumWidth = [anObject sizeWithAttributes:[NoteAttributeColumn standardDictionary]].width + 2;
absoluteMinimumWidth = [anObject sizeWithAttributes:[NoteAttributeColumn standardDictionary]].width + 5;
[self setMinWidth:absoluteMinimumWidth];
}

Expand Down
12 changes: 7 additions & 5 deletions NotesTableView.m
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ - (id)initWithCoder:(NSCoder *)decoder {
for (i=0; i<sizeof(colStrings)/sizeof(NSString*); i++) {
NoteAttributeColumn *column = [[NoteAttributeColumn alloc] initWithIdentifier:colStrings[i]];
[column setEditable:(colMutators[i] != NULL)];
[[column headerCell] setStringValue:[[NSBundle mainBundle] localizedStringForKey:colStrings[i] value:@"" table:nil]];
[column setHeaderCell:[[[NoteTableHeaderCell alloc] initTextCell:[[NSBundle mainBundle] localizedStringForKey:colStrings[i] value:@"" table:nil]] autorelease]];

[[column dataCell] setFont:font];
[column setMutatingSelector:colMutators[i]];
[column setDereferencingFunction:colReferencors[i]];
Expand All @@ -75,15 +76,17 @@ - (id)initWithCoder:(NSCoder *)decoder {
[allColumns addObject:column];
[column release];
}

NSLayoutManager *lm = [[NSLayoutManager alloc] init];
[self setRowHeight:[lm defaultLineHeightForFont:font] + 1.0f];
[self setRowHeight:[lm defaultLineHeightForFont:font] + 2.0f];
[lm release];

//[self setAutosaveName:@"notesTable"];
//[self setAutosaveTableColumns:YES];
[self setAllowsColumnSelection:NO];
//[self setVerticalMotionCanBeginDrag:NO];

[self setIntercellSpacing:NSMakeSize(12, 2)];

BOOL hideHeader = [columnsToDisplay count] == 1 && [columnsToDisplay containsObject:NoteTitleColumnString];
if (hideHeader) {
Expand Down Expand Up @@ -235,9 +238,8 @@ - (void)settingChangedForSelectorString:(NSString*)selectorString {
[[[allColumns objectAtIndex:i] dataCell] setFont:font];

NSLayoutManager *lm = [[NSLayoutManager alloc] init];
[self setRowHeight:[lm defaultLineHeightForFont:font] + 1.0f];
[self setRowHeight:[lm defaultLineHeightForFont:font] + 2.0f];
[lm release];

}
}

Expand Down
6 changes: 4 additions & 2 deletions PrefsWindowController.m
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
#import "NotationPrefs.h"
#import "GlobalPrefs.h"

#define SYSTEM_LIST_FONT_SIZE 12.0f

@implementation PrefsWindowController

- (id)init {
Expand Down Expand Up @@ -184,7 +186,7 @@ - (IBAction)changedTableText:(id)sender {
newFontSize = [NSFont smallSystemFontSize];
break;
case 2:
newFontSize = [NSFont systemFontSize];
newFontSize = /*[NSFont systemFontSize]*/ SYSTEM_LIST_FONT_SIZE;
break;
case 3:
newFontSize = [tableTextSizeField floatValue];
Expand Down Expand Up @@ -358,7 +360,7 @@ - (void)awakeFromNib {
float fontSize = [prefsController tableFontSize];
int fontButtonIndex = 3;
if (fontSize == [NSFont smallSystemFontSize]) fontButtonIndex = 0;
else if (fontSize == [NSFont systemFontSize]) fontButtonIndex = 1;
else if (fontSize == /*[NSFont systemFontSize]*/ SYSTEM_LIST_FONT_SIZE) fontButtonIndex = 1;
[tableTextMenuButton selectItemAtIndex:fontButtonIndex];
[tableTextSizeField setFloatValue:fontSize];
[tableTextSizeField setHidden:(fontButtonIndex != 3)];
Expand Down

0 comments on commit a264118

Please sign in to comment.