aboutsummaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorstuconnolly <stuart02@gmail.com>2010-03-31 18:24:37 +0000
committerstuconnolly <stuart02@gmail.com>2010-03-31 18:24:37 +0000
commit786a51fb9539858aa8974d9fd93e9410867ee08d (patch)
tree5c27f959e01e3b4310009d93f29d5f9fcdb32eea /Source
parentef9f2de4c69410664f5c75db6b512138c7df72aa (diff)
downloadsequelpro-786a51fb9539858aa8974d9fd93e9410867ee08d.tar.gz
sequelpro-786a51fb9539858aa8974d9fd93e9410867ee08d.tar.bz2
sequelpro-786a51fb9539858aa8974d9fd93e9410867ee08d.zip
More tidy up. Constants and functions.
Diffstat (limited to 'Source')
-rw-r--r--Source/CMTextView.h15
-rw-r--r--Source/CMTextView.m1
-rw-r--r--Source/SPConstants.h8
-rw-r--r--Source/SPStringAdditions.h16
-rw-r--r--Source/SPTextAndLinkCell.h7
-rw-r--r--Source/SPTextAndLinkCell.m13
6 files changed, 31 insertions, 29 deletions
diff --git a/Source/CMTextView.h b/Source/CMTextView.h
index 4e96ad39..224349e3 100644
--- a/Source/CMTextView.h
+++ b/Source/CMTextView.h
@@ -31,21 +31,6 @@
#define SP_TEXT_SIZE_TRIGGER_FOR_PARTLY_PARSING 10000
-static inline void NSMutableAttributedStringAddAttributeValueRange (NSMutableAttributedString* self, NSString* aStr, id aValue, NSRange aRange) {
- typedef void (*SPMutableAttributedStringAddAttributeValueRangeMethodPtr)(NSMutableAttributedString*, SEL, NSString*, id, NSRange);
- static SPMutableAttributedStringAddAttributeValueRangeMethodPtr SPMutableAttributedStringAddAttributeValueRange;
- if (!SPMutableAttributedStringAddAttributeValueRange) SPMutableAttributedStringAddAttributeValueRange = (SPMutableAttributedStringAddAttributeValueRangeMethodPtr)[self methodForSelector:@selector(addAttribute:value:range:)];
- SPMutableAttributedStringAddAttributeValueRange(self, @selector(addAttribute:value:range:), aStr, aValue, aRange);
- return;
-}
-static inline id NSMutableAttributedStringAttributeAtIndex (NSMutableAttributedString* self, NSString* aStr, NSUInteger index, NSRangePointer range) {
- typedef id (*SPMutableAttributedStringAttributeAtIndexMethodPtr)(NSMutableAttributedString*, SEL, NSString*, NSUInteger, NSRangePointer);
- static SPMutableAttributedStringAttributeAtIndexMethodPtr SPMutableAttributedStringAttributeAtIndex;
- if (!SPMutableAttributedStringAttributeAtIndex) SPMutableAttributedStringAttributeAtIndex = (SPMutableAttributedStringAttributeAtIndexMethodPtr)[self methodForSelector:@selector(attribute:atIndex:effectiveRange:)];
- id r = SPMutableAttributedStringAttributeAtIndex(self, @selector(attribute:atIndex:effectiveRange:), aStr, index, range);
- return r;
-}
-
@interface CMTextView : NSTextView
{
BOOL autoindentEnabled;
diff --git a/Source/CMTextView.m b/Source/CMTextView.m
index 004eea93..fae2554a 100644
--- a/Source/CMTextView.m
+++ b/Source/CMTextView.m
@@ -85,7 +85,6 @@ static inline CGFloat SPRectRight(NSRect rectangle) { return rectangle.origin.x+
static inline CGFloat SPPointDistance(NSPoint a, NSPoint b) { return sqrt( (a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y-b.y) ); }
static inline NSPoint SPPointOnLine(NSPoint a, NSPoint b, CGFloat t) { return NSMakePoint(a.x*(1.-t) + b.x*t, a.y*(1.-t) + b.y*t); }
-
@implementation CMTextView
@synthesize queryHiliteColor;
diff --git a/Source/SPConstants.h b/Source/SPConstants.h
index 319f107e..b7241136 100644
--- a/Source/SPConstants.h
+++ b/Source/SPConstants.h
@@ -101,6 +101,14 @@ typedef enum
SPFavoritesSortTypeItem = 2
} SPFavoritesSortItem;
+// Text and link cell draw states
+typedef enum
+{
+ SPLinkDrawStateNormal = 0,
+ SPLinkDrawStateHighlight = 1,
+ SPLinkDrawStateBackgroundHighlight = 2
+} SPTextAndLinkCellDrawState;
+
// Long running notification time for Growl messages
extern const CGFloat SPLongRunningNotificationTime;
diff --git a/Source/SPStringAdditions.h b/Source/SPStringAdditions.h
index b67baa54..3f7c9066 100644
--- a/Source/SPStringAdditions.h
+++ b/Source/SPStringAdditions.h
@@ -38,6 +38,22 @@ static inline const char* NSStringUTF8String(NSString* self) {
return to_return;
}
+static inline void NSMutableAttributedStringAddAttributeValueRange (NSMutableAttributedString* self, NSString* aStr, id aValue, NSRange aRange) {
+ typedef void (*SPMutableAttributedStringAddAttributeValueRangeMethodPtr)(NSMutableAttributedString*, SEL, NSString*, id, NSRange);
+ static SPMutableAttributedStringAddAttributeValueRangeMethodPtr SPMutableAttributedStringAddAttributeValueRange;
+ if (!SPMutableAttributedStringAddAttributeValueRange) SPMutableAttributedStringAddAttributeValueRange = (SPMutableAttributedStringAddAttributeValueRangeMethodPtr)[self methodForSelector:@selector(addAttribute:value:range:)];
+ SPMutableAttributedStringAddAttributeValueRange(self, @selector(addAttribute:value:range:), aStr, aValue, aRange);
+ return;
+}
+
+static inline id NSMutableAttributedStringAttributeAtIndex (NSMutableAttributedString* self, NSString* aStr, NSUInteger index, NSRangePointer range) {
+ typedef id (*SPMutableAttributedStringAttributeAtIndexMethodPtr)(NSMutableAttributedString*, SEL, NSString*, NSUInteger, NSRangePointer);
+ static SPMutableAttributedStringAttributeAtIndexMethodPtr SPMutableAttributedStringAttributeAtIndex;
+ if (!SPMutableAttributedStringAttributeAtIndex) SPMutableAttributedStringAttributeAtIndex = (SPMutableAttributedStringAttributeAtIndexMethodPtr)[self methodForSelector:@selector(attribute:atIndex:effectiveRange:)];
+ id r = SPMutableAttributedStringAttributeAtIndex(self, @selector(attribute:atIndex:effectiveRange:), aStr, index, range);
+ return r;
+}
+
@interface NSString (SPStringAdditions)
+ (NSString *)stringForByteSize:(long long)byteSize;
diff --git a/Source/SPTextAndLinkCell.h b/Source/SPTextAndLinkCell.h
index d9f2ea1e..ab2deef9 100644
--- a/Source/SPTextAndLinkCell.h
+++ b/Source/SPTextAndLinkCell.h
@@ -24,13 +24,6 @@
#import <Cocoa/Cocoa.h>
-enum sptextandlinkcell_drawstates
-{
- SP_LINKDRAWSTATE_NORMAL = 0,
- SP_LINKDRAWSTATE_HIGHLIGHT = 1,
- SP_LINKDRAWSTATE_BACKGROUNDHIGHLIGHT = 2
-};
-
@interface SPTextAndLinkCell : NSTextFieldCell
{
BOOL hasLink;
diff --git a/Source/SPTextAndLinkCell.m b/Source/SPTextAndLinkCell.m
index 29d93a62..194f0e61 100644
--- a/Source/SPTextAndLinkCell.m
+++ b/Source/SPTextAndLinkCell.m
@@ -24,6 +24,7 @@
// More info at <http://code.google.com/p/sequel-pro/>
#import "SPTextAndLinkCell.h"
+#import "SPConstants.h"
@implementation SPTextAndLinkCell
@@ -48,7 +49,7 @@ static inline NSRect SPTextLinkRectFromCellRect(NSRect inRect)
hasLink = NO;
linkButton = nil;
linkTarget = nil;
- drawState = SP_LINKDRAWSTATE_NORMAL;
+ drawState = SPLinkDrawStateNormal;
lastLinkColumn = NSNotFound;
lastLinkRow = NSNotFound;
@@ -140,22 +141,22 @@ static inline NSRect SPTextLinkRectFromCellRect(NSRect inRect)
NSInteger newDrawState = ([self isHighlighted])?
((([(NSTableView *)[self controlView] editedColumn] != -1
|| [[[self controlView] window] firstResponder] == [self controlView])
- && [[[self controlView] window] isKeyWindow])?SP_LINKDRAWSTATE_HIGHLIGHT:SP_LINKDRAWSTATE_BACKGROUNDHIGHLIGHT):
- SP_LINKDRAWSTATE_NORMAL;
+ && [[[self controlView] window] isKeyWindow])?SPLinkDrawStateHighlight:SPLinkDrawStateBackgroundHighlight):
+ SPLinkDrawStateNormal;
// Update the link arrow style if the state has changed
if (drawState != newDrawState) {
drawState = newDrawState;
switch (drawState) {
- case SP_LINKDRAWSTATE_NORMAL:
+ case SPLinkDrawStateNormal:
[linkButton setImage:[NSImage imageNamed:@"link-arrow"]];
[linkButton setAlternateImage:[NSImage imageNamed:@"link-arrow-clicked"]];
break;
- case SP_LINKDRAWSTATE_HIGHLIGHT:
+ case SPLinkDrawStateHighlight:
[linkButton setImage:[NSImage imageNamed:@"link-arrow-highlighted"]];
[linkButton setAlternateImage:[NSImage imageNamed:@"link-arrow-highlighted-clicked"]];
break;
- case SP_LINKDRAWSTATE_BACKGROUNDHIGHLIGHT:
+ case SPLinkDrawStateBackgroundHighlight:
[linkButton setImage:[NSImage imageNamed:@"link-arrow-clicked"]];
[linkButton setAlternateImage:[NSImage imageNamed:@"link-arrow"]];
break;