aboutsummaryrefslogtreecommitdiffstats
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
parentef9f2de4c69410664f5c75db6b512138c7df72aa (diff)
downloadsequelpro-786a51fb9539858aa8974d9fd93e9410867ee08d.tar.gz
sequelpro-786a51fb9539858aa8974d9fd93e9410867ee08d.tar.bz2
sequelpro-786a51fb9539858aa8974d9fd93e9410867ee08d.zip
More tidy up. Constants and functions.
-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
-rw-r--r--sequel-pro.xcodeproj/project.pbxproj16
7 files changed, 43 insertions, 33 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;
diff --git a/sequel-pro.xcodeproj/project.pbxproj b/sequel-pro.xcodeproj/project.pbxproj
index 78b3de45..5ff51aa9 100644
--- a/sequel-pro.xcodeproj/project.pbxproj
+++ b/sequel-pro.xcodeproj/project.pbxproj
@@ -1095,6 +1095,17 @@
path = topics;
sourceTree = "<group>";
};
+ 17DF51241163C68600E3F396 /* Outline Views */ = {
+ isa = PBXGroup;
+ children = (
+ 173C44D61044A6AF001F3A30 /* SPOutlineView.h */,
+ 173C44D71044A6B0001F3A30 /* SPOutlineView.m */,
+ BC4DF1961158FB280059FABD /* SPNavigatorOutlineView.h */,
+ BC4DF1971158FB280059FABD /* SPNavigatorOutlineView.m */,
+ );
+ name = "Outline Views";
+ sourceTree = "<group>";
+ };
17E641420EF01E8A001BC333 /* Source */ = {
isa = PBXGroup;
children = (
@@ -1158,16 +1169,13 @@
isa = PBXGroup;
children = (
171312CF109D23CA00FB465F /* Cells */,
+ 17DF51241163C68600E3F396 /* Outline Views */,
BC01BCCD104024BE006BDEE7 /* SPEncodingPopupAccessory.h */,
BC01BCCE104024BE006BDEE7 /* SPEncodingPopupAccessory.m */,
- 173C44D61044A6AF001F3A30 /* SPOutlineView.h */,
- 173C44D71044A6B0001F3A30 /* SPOutlineView.m */,
29A1B7E30FD1293A000B88E8 /* SPPrintAccessory.h */,
29A1B7E40FD1293A000B88E8 /* SPPrintAccessory.m */,
BC8C8530100E0A8000D7A129 /* SPTableView.h */,
BC8C8531100E0A8000D7A129 /* SPTableView.m */,
- BC4DF1961158FB280059FABD /* SPNavigatorOutlineView.h */,
- BC4DF1971158FB280059FABD /* SPNavigatorOutlineView.m */,
);
name = Views;
sourceTree = "<group>";