Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 118 lines (97 sloc) 4.592 kB
544c9ac @tjw Initial import of LinkBack 1.0 alpha from <http://linkbackproject.org…
tjw authored
1 // SKTToolPaletteController.m
2 // Sketch Example
3 //
4
5 #import "SKTToolPaletteController.h"
6 #import "SKTGraphic.h"
7 #import "SKTRectangle.h"
8 #import "SKTCircle.h"
9 #import "SKTLine.h"
10 #import "SKTTextArea.h"
11
12 enum {
13 SKTArrowToolRow = 0,
14 SKTRectToolRow,
15 SKTCircleToolRow,
16 SKTLineToolRow,
17 SKTTextToolRow,
18 };
19
20 NSString *SKTSelectedToolDidChangeNotification = @"SKTSelectedToolDidChange";
21
22 @implementation SKTToolPaletteController
23
24 + (id)sharedToolPaletteController {
25 static SKTToolPaletteController *sharedToolPaletteController = nil;
26
27 if (!sharedToolPaletteController) {
28 sharedToolPaletteController = [[SKTToolPaletteController allocWithZone:NULL] init];
29 }
30
31 return sharedToolPaletteController;
32 }
33
34 - (id)init {
35 self = [self initWithWindowNibName:@"ToolPalette"];
36 if (self) {
37 [self setWindowFrameAutosaveName:@"ToolPalette"];
38 }
39 return self;
40 }
41
42 - (void)windowDidLoad {
43 NSArray *cells = [toolButtons cells];
44 unsigned i, c = [cells count];
45
46 [super windowDidLoad];
47
48 for (i=0; i<c; i++) {
49 [[cells objectAtIndex:i] setRefusesFirstResponder:YES];
50 }
51 [(NSPanel *)[self window] setFloatingPanel:YES];
52 [(NSPanel *)[self window] setBecomesKeyOnlyIfNeeded:YES];
53
54 [toolButtons setIntercellSpacing:NSMakeSize(0.0, 0.0)];
55 [toolButtons sizeToFit];
56 [[self window] setContentSize:[toolButtons frame].size];
57 [toolButtons setFrameOrigin:NSMakePoint(0.0, 0.0)];
58 }
59
60 - (IBAction)selectToolAction:(id)sender {
61 [[NSNotificationCenter defaultCenter] postNotificationName:SKTSelectedToolDidChangeNotification object:self];
62 }
63
64 - (Class)currentGraphicClass {
65 int row = [toolButtons selectedRow];
66 Class theClass = nil;
67 if (row == SKTRectToolRow) {
68 theClass = [SKTRectangle class];
69 } else if (row == SKTCircleToolRow) {
70 theClass = [SKTCircle class];
71 } else if (row == SKTLineToolRow) {
72 theClass = [SKTLine class];
73 } else if (row == SKTTextToolRow) {
74 theClass = [SKTTextArea class];
75 }
76 return theClass;
77 }
78
79 - (void)selectArrowTool {
80 [toolButtons selectCellAtRow:SKTArrowToolRow column:0];
81 [[NSNotificationCenter defaultCenter] postNotificationName:SKTSelectedToolDidChangeNotification object:self];
82 }
83
84 @end
85
86 /*
87 IMPORTANT: This Apple software is supplied to you by Apple Computer, Inc. ("Apple") in
88 consideration of your agreement to the following terms, and your use, installation,
89 modification or redistribution of this Apple software constitutes acceptance of these
90 terms. If you do not agree with these terms, please do not use, install, modify or
91 redistribute this Apple software.
92
93 In consideration of your agreement to abide by the following terms, and subject to these
94 terms, Apple grants you a personal, non-exclusive license, under Apple's copyrights in
95 this original Apple software (the "Apple Software"), to use, reproduce, modify and
96 redistribute the Apple Software, with or without modifications, in source and/or binary
97 forms; provided that if you redistribute the Apple Software in its entirety and without
98 modifications, you must retain this notice and the following text and disclaimers in all
99 such redistributions of the Apple Software. Neither the name, trademarks, service marks
100 or logos of Apple Computer, Inc. may be used to endorse or promote products derived from
101 the Apple Software without specific prior written permission from Apple. Except as expressly
102 stated in this notice, no other rights or licenses, express or implied, are granted by Apple
103 herein, including but not limited to any patent rights that may be infringed by your
104 derivative works or by other works in which the Apple Software may be incorporated.
105
106 The Apple Software is provided by Apple on an "AS IS" basis. APPLE MAKES NO WARRANTIES,
107 EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION THE IMPLIED WARRANTIES OF NON-INFRINGEMENT,
108 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, REGARDING THE APPLE SOFTWARE OR ITS
109 USE AND OPERATION ALONE OR IN COMBINATION WITH YOUR PRODUCTS.
110
111 IN NO EVENT SHALL APPLE BE LIABLE FOR ANY SPECIAL, INDIRECT, INCIDENTAL OR CONSEQUENTIAL
112 DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
113 OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) ARISING IN ANY WAY OUT OF THE USE,
114 REPRODUCTION, MODIFICATION AND/OR DISTRIBUTION OF THE APPLE SOFTWARE, HOWEVER CAUSED AND
115 WHETHER UNDER THEORY OF CONTRACT, TORT (INCLUDING NEGLIGENCE), STRICT LIABILITY OR
116 OTHERWISE, EVEN IF APPLE HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
117 */
Something went wrong with that request. Please try again.