aboutsummaryrefslogtreecommitdiffstats
path: root/Source/CustomQuery.m
diff options
context:
space:
mode:
authorBibiko <bibiko@eva.mpg.de>2010-01-30 22:29:34 +0000
committerBibiko <bibiko@eva.mpg.de>2010-01-30 22:29:34 +0000
commit890247960876e8dd987dd44ec98da4300b6a0fd3 (patch)
treefe077fbf95d6599c88dc2c2f34494665452a32ef /Source/CustomQuery.m
parenta776a6437e40837cc2e20a9231e3eb8ef1a73ddf (diff)
downloadsequelpro-890247960876e8dd987dd44ec98da4300b6a0fd3.tar.gz
sequelpro-890247960876e8dd987dd44ec98da4300b6a0fd3.tar.bz2
sequelpro-890247960876e8dd987dd44ec98da4300b6a0fd3.zip
• CMTextView's colours are set via observer, live changed in editable textviews
• added Preference setting "Table font" in "Table" pane to set the table font/size for all result tables (Content, Custom Query) • added to SPTableView the method setFont: • fixed the initialisation of vars in CMTextView (fixes the displaying of create syntax)
Diffstat (limited to 'Source/CustomQuery.m')
-rw-r--r--Source/CustomQuery.m44
1 files changed, 15 insertions, 29 deletions
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];
+
+
}
/**