BathyScapheのTitleRulerAppearanceを手軽に変更するツール
Revision | dff82a897c1a42d7066a164ce1132e9c7e435a57 (tree) |
---|---|
Time | 2009-06-01 23:21:00 |
Author | masakih <masakih@user...> |
Commiter | masakih |
BSTitleRulerViewをプロジェクトおよびリポジトリから外した。
SDKを10.4に変更。
git-svn-id: svn+ssh://macmini/usr/local/svnrepos/BSTRAEditor/BSTRAEditor@5 f892931e-c658-45bd-90f1-b3d0def27f12
@@ -66,8 +66,6 @@ | ||
66 | 66 | F434415E0D86B8C900F9416E /* Makefile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.make; path = Makefile; sourceTree = "<group>"; }; |
67 | 67 | F43441610D86B96500F9416E /* Japanese */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.make; name = Japanese; path = Japanese.lproj/Makefile; sourceTree = "<group>"; }; |
68 | 68 | F43441710D86C85900F9416E /* Japanese */ = {isa = PBXFileReference; lastKnownFileType = text; name = Japanese; path = Japanese.lproj/Localizable.strings.sed; sourceTree = "<group>"; }; |
69 | - F479A5EC0D860C4C00A414C2 /* BSTitleRulerView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BSTitleRulerView.h; sourceTree = "<group>"; }; | |
70 | - F479A5ED0D860C4C00A414C2 /* BSTitleRulerView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BSTitleRulerView.m; sourceTree = "<group>"; }; | |
71 | 69 | F479A5EF0D860C6C00A414C2 /* NSBezierPath_AMShading.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NSBezierPath_AMShading.m; sourceTree = "<group>"; }; |
72 | 70 | F479A5F00D860C6C00A414C2 /* NSBezierPath_AMShading.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSBezierPath_AMShading.h; sourceTree = "<group>"; }; |
73 | 71 | F479A5FB0D860D7C00A414C2 /* BSTitleRulerAppearance.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BSTitleRulerAppearance.h; sourceTree = "<group>"; }; |
@@ -192,8 +190,6 @@ | ||
192 | 190 | F479A5FC0D860D7C00A414C2 /* BSTitleRulerAppearance.m */, |
193 | 191 | F479A5F00D860C6C00A414C2 /* NSBezierPath_AMShading.h */, |
194 | 192 | F479A5EF0D860C6C00A414C2 /* NSBezierPath_AMShading.m */, |
195 | - F479A5EC0D860C4C00A414C2 /* BSTitleRulerView.h */, | |
196 | - F479A5ED0D860C4C00A414C2 /* BSTitleRulerView.m */, | |
197 | 193 | ); |
198 | 194 | name = "External Classes"; |
199 | 195 | sourceTree = "<group>"; |
@@ -414,7 +410,7 @@ | ||
414 | 410 | GCC_WARN_UNUSED_VARIABLE = YES; |
415 | 411 | PREBINDING = NO; |
416 | 412 | SDKROOT = "$(DEVELOPER_SDK_DIR)/MacOSX10.4u.sdk"; |
417 | - "SDKROOT[arch=ppc]" = /Developer/SDKs/MacOSX10.3.9.sdk; | |
413 | + "SDKROOT[arch=ppc]" = "$(DEVELOPER_SDK_DIR)/MacOSX10.4u.sdk"; | |
418 | 414 | }; |
419 | 415 | name = Debug; |
420 | 416 | }; |
@@ -429,7 +425,7 @@ | ||
429 | 425 | GCC_WARN_UNUSED_VARIABLE = YES; |
430 | 426 | PREBINDING = NO; |
431 | 427 | SDKROOT = "$(DEVELOPER_SDK_DIR)/MacOSX10.4u.sdk"; |
432 | - "SDKROOT[arch=ppc]" = /Developer/SDKs/MacOSX10.3.9.sdk; | |
428 | + "SDKROOT[arch=ppc]" = "$(DEVELOPER_SDK_DIR)/MacOSX10.4u.sdk"; | |
433 | 429 | }; |
434 | 430 | name = Release; |
435 | 431 | }; |
@@ -1,50 +0,0 @@ | ||
1 | -// | |
2 | -// BSTitleRulerView.h | |
3 | -// SGAppKit (BathyScaphe) | |
4 | -// | |
5 | -// Created by Tsutomu Sawada on 05/09/22. | |
6 | -// Copyright 2005-2007 BathyScaphe Project. All rights reserved. | |
7 | -// encoding="UTF-8" | |
8 | -// | |
9 | - | |
10 | -#import <Cocoa/Cocoa.h> | |
11 | - | |
12 | -@class BSTitleRulerAppearance; | |
13 | - | |
14 | -typedef enum _BSTitleRulerModeType { | |
15 | - BSTitleRulerShowTitleOnlyMode = 0, // スレッドタイトルバーのみ | |
16 | - BSTitleRulerShowInfoOnlyMode = 1, // 「dat 落ちと判定されました。」のみ | |
17 | - BSTitleRulerShowTitleAndInfoMode = 2, // スレッドタイトルバー、その下に「dat 落ちと判定されました。」 | |
18 | -} BSTitleRulerModeType; | |
19 | - | |
20 | -@interface BSTitleRulerView : NSRulerView { | |
21 | - @private | |
22 | - BSTitleRulerAppearance *m_appearance; | |
23 | - | |
24 | - NSString *m_titleStr; | |
25 | - NSString *m_infoStr; | |
26 | - NSString *m_pathStr; | |
27 | - | |
28 | - BSTitleRulerModeType _currentMode; | |
29 | -} | |
30 | - | |
31 | -// Designated initializer. Available in Twincam Angel/SGAppKit 1.7.1 and later. | |
32 | -- (id)initWithScrollView:(NSScrollView *)aScrollView appearance:(BSTitleRulerAppearance *)appearance; | |
33 | - | |
34 | -- (BSTitleRulerAppearance *)appearance; | |
35 | -- (void)setAppearance:(BSTitleRulerAppearance *)appearance; | |
36 | - | |
37 | -- (NSString *)titleStr; | |
38 | -- (void)setTitleStr:(NSString *)aString; | |
39 | -- (void)setTitleStrWithoutNeedingDisplay:(NSString *)aString; | |
40 | - | |
41 | -- (NSString *)infoStr; | |
42 | -- (void)setInfoStr:(NSString *)aString; | |
43 | -- (void)setInfoStrWithoutNeedingDisplay:(NSString *)aString; | |
44 | - | |
45 | -- (NSString *)pathStr; | |
46 | -- (void)setPathStr:(NSString *)aString; | |
47 | - | |
48 | -- (BSTitleRulerModeType)currentMode; | |
49 | -- (void)setCurrentMode:(BSTitleRulerModeType)newType; | |
50 | -@end |
@@ -1,350 +0,0 @@ | ||
1 | -// | |
2 | -// BSTitleRulerView.m | |
3 | -// SGAppKit (BathyScaphe) | |
4 | -// | |
5 | -// Created by Tsutomu Sawada on 05/09/22. | |
6 | -// Copyright 2005-2007 BathyScaphe Project. All rights reserved. | |
7 | -// encoding="UTF-8" | |
8 | -// | |
9 | - | |
10 | -#import "BSTitleRulerView.h" | |
11 | -#import <SGAppKit/NSWorkspace-SGExtensions.h> | |
12 | -#import <SGAppKit/BSTitleRulerAppearance.h> | |
13 | -#import <SGAppKit/NSBezierPath_AMShading.h> | |
14 | - | |
15 | -#define THICKNESS_FOR_TITLE 22.0 | |
16 | -#define THICKNESS_FOR_INFO 36.0 | |
17 | -#define TITLE_FONT_SIZE 12.0 | |
18 | -#define INFO_FONT_SIZE 13.0 | |
19 | - | |
20 | -@implementation BSTitleRulerView | |
21 | - | |
22 | -#pragma mark Accessors | |
23 | -- (BSTitleRulerAppearance *)appearance | |
24 | -{ | |
25 | - return m_appearance; | |
26 | -} | |
27 | - | |
28 | -- (void)setAppearance:(BSTitleRulerAppearance *)appearance | |
29 | -{ | |
30 | - [appearance retain]; | |
31 | - [m_appearance release]; | |
32 | - m_appearance = appearance; | |
33 | -} | |
34 | - | |
35 | -- (NSString *)titleStr | |
36 | -{ | |
37 | - return m_titleStr; | |
38 | -} | |
39 | - | |
40 | -- (void)setTitleStr:(NSString *)aString | |
41 | -{ | |
42 | - [self setTitleStrWithoutNeedingDisplay:aString]; | |
43 | - [self setNeedsDisplay:YES]; | |
44 | -} | |
45 | - | |
46 | -- (void)setTitleStrWithoutNeedingDisplay:(NSString *)aString | |
47 | -{ | |
48 | - [aString retain]; | |
49 | - [m_titleStr release]; | |
50 | - m_titleStr = aString; | |
51 | -} | |
52 | - | |
53 | -- (NSString *)infoStr | |
54 | -{ | |
55 | - return m_infoStr; | |
56 | -} | |
57 | - | |
58 | -- (void)setInfoStr:(NSString *)aString | |
59 | -{ | |
60 | - [self setInfoStrWithoutNeedingDisplay:aString]; | |
61 | - [self setNeedsDisplay:YES]; | |
62 | -} | |
63 | - | |
64 | -- (void)setInfoStrWithoutNeedingDisplay:(NSString *)aString | |
65 | -{ | |
66 | - [aString retain]; | |
67 | - [m_infoStr release]; | |
68 | - m_infoStr = aString; | |
69 | -} | |
70 | - | |
71 | -- (NSString *)pathStr | |
72 | -{ | |
73 | - return m_pathStr; | |
74 | -} | |
75 | - | |
76 | -- (void)setPathStr:(NSString *)aString | |
77 | -{ | |
78 | - [aString retain]; | |
79 | - [m_pathStr release]; | |
80 | - m_pathStr = aString; | |
81 | -} | |
82 | - | |
83 | -- (BSTitleRulerModeType)currentMode | |
84 | -{ | |
85 | - return _currentMode; | |
86 | -} | |
87 | - | |
88 | -- (void)setCurrentMode:(BSTitleRulerModeType)newType | |
89 | -{ | |
90 | - float newThickness; | |
91 | - _currentMode = newType; | |
92 | - | |
93 | - switch(newType) { | |
94 | - case BSTitleRulerShowTitleOnlyMode: | |
95 | - newThickness = THICKNESS_FOR_TITLE; | |
96 | - break; | |
97 | - case BSTitleRulerShowInfoOnlyMode: | |
98 | - newThickness = THICKNESS_FOR_INFO; | |
99 | - break; | |
100 | - case BSTitleRulerShowTitleAndInfoMode: | |
101 | - newThickness = (THICKNESS_FOR_TITLE + THICKNESS_FOR_INFO); | |
102 | - break; | |
103 | - default: | |
104 | - newThickness = THICKNESS_FOR_TITLE; | |
105 | - break; | |
106 | - } | |
107 | - | |
108 | - [self setRuleThickness:newThickness]; | |
109 | -} | |
110 | - | |
111 | -#pragma mark Private Utilities | |
112 | -- (NSDictionary *)attrTemplateForTitle | |
113 | -{ | |
114 | - static NSDictionary *tmp = nil; | |
115 | - if (!tmp) { | |
116 | - NSColor *color_; | |
117 | - | |
118 | - color_ = [[self appearance] textColor]; | |
119 | - | |
120 | - tmp = [[NSDictionary alloc] initWithObjectsAndKeys: | |
121 | - [NSFont boldSystemFontOfSize:TITLE_FONT_SIZE], NSFontAttributeName, | |
122 | - color_, NSForegroundColorAttributeName, | |
123 | - nil]; | |
124 | - } | |
125 | - return tmp; | |
126 | -} | |
127 | - | |
128 | -- (NSDictionary *)attrTemplateForInfo | |
129 | -{ | |
130 | - static NSDictionary *tmp2 = nil; | |
131 | - if (!tmp2) { | |
132 | - NSColor *color_; | |
133 | - | |
134 | - color_ = [[self appearance] infoColor]; | |
135 | - | |
136 | - tmp2 = [[NSDictionary alloc] initWithObjectsAndKeys: | |
137 | - [NSFont systemFontOfSize:INFO_FONT_SIZE], NSFontAttributeName, | |
138 | - color_, NSForegroundColorAttributeName, | |
139 | - nil]; | |
140 | - } | |
141 | - return tmp2; | |
142 | -} | |
143 | - | |
144 | -- (NSAttributedString *)titleForDrawing | |
145 | -{ | |
146 | - return [[[NSAttributedString alloc] initWithString:[self titleStr] attributes:[self attrTemplateForTitle]] autorelease]; | |
147 | -} | |
148 | - | |
149 | -- (NSAttributedString *)infoForDrawing | |
150 | -{ | |
151 | - return [[[NSAttributedString alloc] initWithString:[self infoStr] attributes:[self attrTemplateForInfo]] autorelease]; | |
152 | -} | |
153 | - | |
154 | -- (NSArray *)activeColors | |
155 | -{ | |
156 | - BSTitleRulerAppearance *appearance = [self appearance]; | |
157 | - return ([NSColor currentControlTint] == NSGraphiteControlTint) ? [appearance activeGraphiteColors] : [appearance activeBlueColors]; | |
158 | -} | |
159 | - | |
160 | -#pragma mark Setup & Cleanup | |
161 | -- (id)initWithScrollView:(NSScrollView *)aScrollView appearance:(BSTitleRulerAppearance *)appearance | |
162 | -{ | |
163 | - if (self = [super initWithScrollView:aScrollView orientation:NSHorizontalRuler]) { | |
164 | - NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; | |
165 | - // Original NSRulerView Properties | |
166 | - [self setMarkers:nil]; | |
167 | - [self setReservedThicknessForMarkers:0.0]; | |
168 | - | |
169 | - // Notifications | |
170 | - [nc addObserver:self | |
171 | - selector:@selector(mainWinOrSystemColorsDidChange:) | |
172 | - name:NSSystemColorsDidChangeNotification | |
173 | - object:nil]; | |
174 | - | |
175 | - [nc addObserver:self | |
176 | - selector:@selector(mainWinOrSystemColorsDidChange:) | |
177 | - name:NSWindowDidBecomeMainNotification | |
178 | - object:[self window]]; | |
179 | - | |
180 | - [nc addObserver:self | |
181 | - selector:@selector(mainWinOrSystemColorsDidChange:) | |
182 | - name:NSWindowDidResignMainNotification | |
183 | - object:[self window]]; | |
184 | - | |
185 | - // BSTitleRulerView Properties | |
186 | - [self setCurrentMode:BSTitleRulerShowTitleOnlyMode]; | |
187 | - [self setAppearance:appearance]; | |
188 | - } | |
189 | - return self; | |
190 | -} | |
191 | - | |
192 | -- (void)dealloc | |
193 | -{ | |
194 | - NSNotificationCenter *nc = [NSNotificationCenter defaultCenter]; | |
195 | - | |
196 | - [nc removeObserver:self | |
197 | - name:NSSystemColorsDidChangeNotification | |
198 | - object:nil]; | |
199 | - | |
200 | - [nc removeObserver:self | |
201 | - name:NSWindowDidBecomeMainNotification | |
202 | - object:[self window]]; | |
203 | - | |
204 | - [nc removeObserver:self | |
205 | - name:NSWindowDidResignMainNotification | |
206 | - object:[self window]]; | |
207 | - | |
208 | - [m_titleStr release]; | |
209 | - [m_infoStr release]; | |
210 | - [m_pathStr release]; | |
211 | - [m_appearance release]; | |
212 | - | |
213 | - [super dealloc]; | |
214 | -} | |
215 | - | |
216 | -#pragma mark Drawing | |
217 | -- (void)drawTitleBarInRect:(NSRect)aRect | |
218 | -{ | |
219 | - NSArray *colors_; | |
220 | - NSColor *gradientStartColor, *gradientEndColor; | |
221 | - | |
222 | - BSTitleRulerAppearance *appearance = [self appearance]; | |
223 | - | |
224 | - colors_ = [[self window] isMainWindow] ? [self activeColors] : [appearance inactiveColors]; | |
225 | - | |
226 | - gradientStartColor = [colors_ objectAtIndex:0]; | |
227 | - gradientEndColor = [colors_ objectAtIndex:1]; | |
228 | - | |
229 | - [[NSBezierPath bezierPathWithRect:aRect] linearGradientFillWithStartColor:gradientStartColor endColor:gradientEndColor]; | |
230 | - | |
231 | - if ([appearance drawsCarvedText]) { | |
232 | - // このへん、暫定的 | |
233 | - NSMutableAttributedString *foo = [[self titleForDrawing] mutableCopy]; | |
234 | - NSRange range = NSMakeRange(0,[foo length]); | |
235 | - [foo removeAttribute:NSForegroundColorAttributeName range:range]; | |
236 | - [foo addAttributes:[NSDictionary dictionaryWithObject:[NSColor grayColor] forKey:NSForegroundColorAttributeName] range:range]; | |
237 | - [foo drawInRect:NSInsetRect(aRect, 5.0, 3.0)]; | |
238 | - [foo release]; | |
239 | - } | |
240 | - | |
241 | - [[self titleForDrawing] drawInRect:NSInsetRect(aRect, 5.0, 2.0)]; | |
242 | -} | |
243 | - | |
244 | -- (BOOL)isOpaque | |
245 | -{ | |
246 | - return YES; | |
247 | -} | |
248 | - | |
249 | -- (void)drawInfoBarInRect:(NSRect)aRect | |
250 | -{ | |
251 | - NSRect iconRect; | |
252 | - NSImage *icon_ = [[NSWorkspace sharedWorkspace] systemIconForType:kAlertNoteIcon]; | |
253 | - [icon_ setSize:NSMakeSize(32, 32)]; | |
254 | - [icon_ setFlipped:[self isFlipped]]; | |
255 | - | |
256 | - [[[self appearance] infoBackgroundColor] set]; | |
257 | - NSRectFill(aRect); | |
258 | - | |
259 | - iconRect = NSMakeRect(NSMinX(aRect)+5.0, NSMinY(aRect)+2.0, 32, 32); | |
260 | - | |
261 | - [icon_ drawInRect:iconRect fromRect:NSMakeRect(0,0,32,32) operation:NSCompositeSourceOver fraction:1.0]; | |
262 | - | |
263 | - aRect = NSInsetRect(aRect, 5.0, 7.0); | |
264 | - aRect.origin.x += 36.0; | |
265 | - [[self infoForDrawing] drawInRect:NSInsetRect(aRect, 5.0, 2.0)]; | |
266 | -} | |
267 | - | |
268 | -- (void)drawRect:(NSRect)aRect | |
269 | -{ | |
270 | - switch ([self currentMode]) { | |
271 | - case BSTitleRulerShowTitleOnlyMode: | |
272 | - [self drawTitleBarInRect:aRect]; | |
273 | - break; | |
274 | - case BSTitleRulerShowInfoOnlyMode: | |
275 | - [self drawInfoBarInRect:aRect]; | |
276 | - break; | |
277 | - case BSTitleRulerShowTitleAndInfoMode: | |
278 | - { | |
279 | - NSRect titleRect, infoRect; | |
280 | - NSDivideRect(aRect, &infoRect, &titleRect, THICKNESS_FOR_INFO, NSMaxYEdge); | |
281 | - [self drawTitleBarInRect:titleRect]; | |
282 | - [self drawInfoBarInRect:infoRect]; | |
283 | - } | |
284 | - break; | |
285 | - } | |
286 | -} | |
287 | - | |
288 | -#pragma mark Path Popup Menu Support | |
289 | -- (IBAction)revealPathComponent:(id)sender | |
290 | -{ | |
291 | - NSString *path = [sender representedObject]; | |
292 | - if (path) [[NSWorkspace sharedWorkspace] selectFile:path inFileViewerRootedAtPath:[path stringByDeletingLastPathComponent]]; | |
293 | -} | |
294 | - | |
295 | -static NSMenu *createPathMenu(NSString *fullPath) | |
296 | -{ | |
297 | - NSFileManager *fm = [NSFileManager defaultManager]; | |
298 | - NSWorkspace *ws = [NSWorkspace sharedWorkspace]; | |
299 | - NSMenu *menu = [[NSMenu alloc] initWithTitle:@"Path"]; | |
300 | - NSMenuItem *menuItem; | |
301 | - NSImage *img; | |
302 | - NSSize size16 = NSMakeSize(16,16); | |
303 | - SEL mySel = @selector(revealPathComponent:); | |
304 | - | |
305 | - menuItem = [[NSMenuItem alloc] initWithTitle:[fm displayNameAtPath:fullPath] action:mySel keyEquivalent:@""]; | |
306 | - img = [ws iconForFile:fullPath]; | |
307 | - [img setSize:size16]; | |
308 | - [menuItem setImage:img]; | |
309 | - [menu addItem:menuItem]; | |
310 | - [menuItem release]; | |
311 | - | |
312 | - NSString *bar = fullPath; | |
313 | - NSString *foo; | |
314 | - | |
315 | - while (![bar isEqualToString:@"/"]) { | |
316 | - foo = [bar stringByDeletingLastPathComponent]; | |
317 | - menuItem = [[NSMenuItem alloc] initWithTitle:[fm displayNameAtPath:foo] action:mySel keyEquivalent:@""]; | |
318 | - img = [ws iconForFile:foo]; | |
319 | - [img setSize:size16]; | |
320 | - [menuItem setRepresentedObject:bar]; | |
321 | - [menuItem setImage:img]; | |
322 | - [menu addItem:menuItem]; | |
323 | - [menuItem release]; | |
324 | - bar = foo; | |
325 | - } | |
326 | - return [menu autorelease]; | |
327 | -} | |
328 | - | |
329 | -- (void)mouseDown:(NSEvent *)theEvent | |
330 | -{ | |
331 | - unsigned int flag = [theEvent modifierFlags]; | |
332 | - if ([self pathStr] && (flag & NSCommandKeyMask)) { | |
333 | - [NSMenu popUpContextMenu:createPathMenu([self pathStr]) withEvent:theEvent forView:self]; | |
334 | - } | |
335 | -} | |
336 | - | |
337 | -- (NSMenu *)menuForEvent:(NSEvent *)theEvent | |
338 | -{ | |
339 | - if ([self pathStr]) { | |
340 | - return createPathMenu([self pathStr]); | |
341 | - } | |
342 | - return [super menuForEvent:theEvent]; | |
343 | -} | |
344 | - | |
345 | -#pragma mark Notifications | |
346 | -- (void)mainWinOrSystemColorsDidChange:(NSNotification *)theNotification | |
347 | -{ | |
348 | - [self setNeedsDisplay:YES]; | |
349 | -} | |
350 | -@end |