forked from smokyonion/SCSelectionBorder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSCSelectionBorder.h
96 lines (80 loc) · 2.76 KB
/
SCSelectionBorder.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
//
// SCSelectionBorder.h
// SCToolkit
//
// Created by Vincent Wang on 12/8/11.
// Copyright (c) 2011 Vincent S. Wang. All rights reserved.
//
#import <Foundation/Foundation.h>
extern const CGFloat SCSelectionBorderHandleWidth;
extern const CGFloat SCSelectionBorderHandleHalfWidth;
typedef enum {
kSCSelectionBorderHandleNone = 0,
kSCSelectionBorderUpperLeftHandle = 1,
kSCSelectionBorderUpperMiddleHandle = 2,
kSCSelectionBorderUpperRightHandle = 3,
kSCSelectionBorderMiddleLeftHandle = 4,
kSCSelectionBorderMiddleRightHandle = 5,
kSCSelectionBorderLowerLeftHandle = 6,
kSCSelectionBorderLowerMiddleHandle = 7,
kSCSelectionBorderLowerRightHandle = 8,
} SCSelectionBorderHandle;
enum
{
kSCSelectionXResizeable = 1U << 0,
kSCSelectionYResizeable = 1U << 1,
kSCSelectionWidthResizeable = 1U << 2,
kSCSelectionHeightResizeable= 1U << 3,
};
enum {
kSCDashStyleSolid = 0,
kSCDashStyleDashed = 1,
kSCDashStyleDashedAndDotted = 2,
};
typedef NSInteger SCDashStyle;
@interface SCSelectionBorder : NSObject
{
@private
//NSBezierPath Drawing Guideline - Dash Style Patterns
//http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/CocoaDrawingGuide/Paths/Paths.html
SCDashStyle _dashStyle;
//unsigned int _resizingMask;
NSColor *_borderColor;
NSColor *_fillColor;
BOOL _drawingFill;
CGFloat _borderWidth;
NSSize _aspectRatio;
BOOL _lockAspectRatio;
NSSize _minSize;
NSRect _selectedRect;
BOOL _drawingHandles;
BOOL _drawingGrids;
BOOL _drawingOffView;
unsigned int _gridLineNumber;
}
@property (retain) NSColor *borderColor;
@property (retain) NSColor *fillColor;
@property (assign, getter = isDrawingFill) BOOL drawingFill;
@property (assign) NSSize aspectRatio;
@property (readonly, getter = canLockAspectRatio) BOOL lockAspectRatio;
@property (assign) NSSize minSize;
@property (nonatomic) NSRect selectedRect;
@property (nonatomic) CGFloat borderWidth;
@property (assign) unsigned int gridLineNumber;
@property (assign, getter = isDrawingGrids) BOOL drawingGrids;
@property (assign, getter = canDrawOffView) BOOL drawingOffView;
@property (assign) SCDashStyle dashStyle;
- (void)setColors:(NSColor *)aColor;
// Drawing
- (void)drawContentInView:(NSView *)aView;
// Handle checking
- (NSInteger)handleAtPoint:(NSPoint)point frameRect:(NSRect)bounds;
- (NSPoint)locationOfHandle:(SCSelectionBorderHandle)handle frameRect:(NSRect)bounds;
/** track mouse event and decide whether to moving or resizing selection border itself
@param theEvent a NSEvent
@returns
@exception
*/
- (void)selectAndTrackMouseWithEvent:(NSEvent *)theEvent atPoint:(NSPoint)mouseLocation inView:(NSView *)view;
- (void)setLockAspectRatio:(BOOL)yesOrNo;
@end