Revision: 5905
http://skim-app.svn.sourceforge.net/skim-app/?rev=5905&view=rev
Author: hofman
Date: 2009-10-18 14:08:11 +0000 (Sun, 18 Oct 2009)
Log Message:
-----------
add class for the bookmark root and return menu icon as icon
Modified Paths:
--------------
trunk/SKBookmark.h
trunk/SKBookmark.m
trunk/SKBookmarkController.m
trunk/SKTextFieldSheetController.m
Modified: trunk/SKBookmark.h
===================================================================
--- trunk/SKBookmark.h 2009-10-18 13:46:27 UTC (rev 5904)
+++ trunk/SKBookmark.h 2009-10-18 14:08:11 UTC (rev 5905)
@@ -61,6 +61,7 @@
- (id)initWithSetup:(NSDictionary *)aSetupDict label:(NSString *)aLabel;
- (id)initFolderWithChildren:(NSArray *)aChildren label:(NSString *)aLabel;
- (id)initFolderWithLabel:(NSString *)aLabel;
+- (id)initRootWithChildren:(NSArray *)aChildren;
- (id)initSessionWithChildren:(NSArray *)aChildren label:(NSString *)aLabel;
- (id)initSeparator;
- (id)initWithProperties:(NSDictionary *)dictionary;
Modified: trunk/SKBookmark.m
===================================================================
--- trunk/SKBookmark.m 2009-10-18 13:46:27 UTC (rev 5904)
+++ trunk/SKBookmark.m 2009-10-18 14:08:11 UTC (rev 5905)
@@ -74,6 +74,9 @@
}
@end
+...@interface SKRootBookmark : SKFolderBookmark
+...@end
+
@interface SKSessionBookmark : SKFolderBookmark
@end
@@ -145,6 +148,11 @@
return nil;
}
+- (id)initRootWithChildren:(NSArray *)aChildren {
+ [self doesNotRecognizeSelector:_cmd];
+ return nil;
+}
+
- (id)initSessionWithChildren:(NSArray *)aChildren label:(NSString *)aLabel {
[self doesNotRecognizeSelector:_cmd];
return nil;
@@ -241,6 +249,10 @@
return [self initFolderWithChildren:nil label:aLabel];
}
+- (id)initRootWithChildren:(NSArray *)aChildren {
+ return [[SKRootBookmark alloc] initFolderWithChildren:aChildren label:nil];
+}
+
- (id)initSessionWithChildren:(NSArray *)aChildren label:(NSString *)aLabel {
return [[SKSessionBookmark alloc] initFolderWithChildren:aChildren
label:aLabel];
}
@@ -464,6 +476,60 @@
#pragma mark -
+...@implementation SKRootBookmark
+
+- (NSImage *)icon {
+ static NSImage *menuIcon = nil;
+ if (menuIcon == nil) {
+ menuIcon = [[NSImage alloc] initWithSize:NSMakeSize(16.0, 16.0)];
+ NSShadow *s = [[[NSShadow alloc] init] autorelease];
+ [s setShadowColor:[NSColor colorWithCalibratedWhite:0.0
alpha:0.33333]];
+ [s setShadowBlurRadius:2.0];
+ [s setShadowOffset:NSMakeSize(0.0, -1.0)];
+ [menuIcon lockFocus];
+ [[NSColor colorWithCalibratedWhite:0.0 alpha:0.2] set];
+ [NSBezierPath fillRect:NSMakeRect(1.0, 1.0, 14.0, 13.0)];
+ [NSGraphicsContext saveGraphicsState];
+ NSBezierPath *path = [NSBezierPath bezierPath];
+ [path moveToPoint:NSMakePoint(2.0, 2.0)];
+ [path lineToPoint:NSMakePoint(2.0, 15.0)];
+ [path lineToPoint:NSMakePoint(7.0, 15.0)];
+ [path lineToPoint:NSMakePoint(7.0, 13.0)];
+ [path lineToPoint:NSMakePoint(14.0, 13.0)];
+ [path lineToPoint:NSMakePoint(14.0, 2.0)];
+ [path closePath];
+ [[NSColor whiteColor] set];
+ [s set];
+ [path fill];
+ [NSGraphicsContext restoreGraphicsState];
+ [[NSColor colorWithCalibratedRed:0.162 green:0.304 blue:0.755
alpha:1.0] set];
+ NSRectFill(NSMakeRect(2.0, 13.0, 5.0, 2.0));
+ [[NSColor colorWithCalibratedRed:0.894 green:0.396 blue:0.202
alpha:1.0] set];
+ NSRectFill(NSMakeRect(3.0, 4.0, 1.0, 1.0));
+ NSRectFill(NSMakeRect(3.0, 7.0, 1.0, 1.0));
+ NSRectFill(NSMakeRect(3.0, 10.0, 1.0, 1.0));
+ [[NSColor colorWithCalibratedWhite:0.6 alpha:1.0] set];
+ NSRectFill(NSMakeRect(5.0, 4.0, 1.0, 1.0));
+ NSRectFill(NSMakeRect(5.0, 7.0, 1.0, 1.0));
+ NSRectFill(NSMakeRect(5.0, 10.0, 1.0, 1.0));
+ NSUInteger i, j;
+ for (i = 0; i < 7; i++) {
+ for (j = 0; j < 3; j++) {
+ [[NSColor colorWithCalibratedWhite:0.45 + 0.1 * rand() /
RAND_MAX alpha:1.0] set];
+ NSRectFill(NSMakeRect(6.0 + i, 4.0 + 3.0 * j, 1.0, 1.0));
+ }
+ }
+ NSGradient *gradient = [[[NSGradient alloc]
initWithStartingColor:[NSColor colorWithCalibratedWhite:0.0 alpha:0.1]
endingColor:[NSColor colorWithCalibratedWhite:0.0 alpha:0.0]] autorelease];
+ [gradient drawInRect:NSMakeRect(2.0, 2.0, 12.0,11.0) angle:90.0];
+ [menuIcon unlockFocus];
+ }
+ return menuIcon;
+}
+
+...@end
+
+#pragma mark -
+
@implementation SKSessionBookmark
- (NSDictionary *)properties {
Modified: trunk/SKBookmarkController.m
===================================================================
--- trunk/SKBookmarkController.m 2009-10-18 13:46:27 UTC (rev 5904)
+++ trunk/SKBookmarkController.m 2009-10-18 14:08:11 UTC (rev 5905)
@@ -137,7 +137,7 @@
}
- bookmarkRoot = [[SKBookmark alloc] initFolderWithChildren:bookmarks
label:nil];
+ bookmarkRoot = [[SKBookmark alloc] initRootWithChildren:bookmarks];
[self startObservingBookmarks:[NSArray arrayWithObject:bookmarkRoot]];
[[NSNotificationCenter defaultCenter] addObserver:self
Modified: trunk/SKTextFieldSheetController.m
===================================================================
--- trunk/SKTextFieldSheetController.m 2009-10-18 13:46:27 UTC (rev 5904)
+++ trunk/SKTextFieldSheetController.m 2009-10-18 14:08:11 UTC (rev 5905)
@@ -86,54 +86,6 @@
@implementation SKBookmarkSheetController
-+ (NSImage *)menuIcon {
- static NSImage *menuIcon = nil;
- if (menuIcon == nil) {
- menuIcon = [[NSImage alloc] initWithSize:NSMakeSize(16.0, 16.0)];
- NSShadow *s = [[[NSShadow alloc] init] autorelease];
- [s setShadowColor:[NSColor colorWithCalibratedWhite:0.0
alpha:0.33333]];
- [s setShadowBlurRadius:2.0];
- [s setShadowOffset:NSMakeSize(0.0, -1.0)];
- [menuIcon lockFocus];
- [[NSColor colorWithCalibratedWhite:0.0 alpha:0.2] set];
- [NSBezierPath fillRect:NSMakeRect(1.0, 1.0, 14.0, 13.0)];
- [NSGraphicsContext saveGraphicsState];
- NSBezierPath *path = [NSBezierPath bezierPath];
- [path moveToPoint:NSMakePoint(2.0, 2.0)];
- [path lineToPoint:NSMakePoint(2.0, 15.0)];
- [path lineToPoint:NSMakePoint(7.0, 15.0)];
- [path lineToPoint:NSMakePoint(7.0, 13.0)];
- [path lineToPoint:NSMakePoint(14.0, 13.0)];
- [path lineToPoint:NSMakePoint(14.0, 2.0)];
- [path closePath];
- [[NSColor whiteColor] set];
- [s set];
- [path fill];
- [NSGraphicsContext restoreGraphicsState];
- [[NSColor colorWithCalibratedRed:0.162 green:0.304 blue:0.755
alpha:1.0] set];
- NSRectFill(NSMakeRect(2.0, 13.0, 5.0, 2.0));
- [[NSColor colorWithCalibratedRed:0.894 green:0.396 blue:0.202
alpha:1.0] set];
- NSRectFill(NSMakeRect(3.0, 4.0, 1.0, 1.0));
- NSRectFill(NSMakeRect(3.0, 7.0, 1.0, 1.0));
- NSRectFill(NSMakeRect(3.0, 10.0, 1.0, 1.0));
- [[NSColor colorWithCalibratedWhite:0.6 alpha:1.0] set];
- NSRectFill(NSMakeRect(5.0, 4.0, 1.0, 1.0));
- NSRectFill(NSMakeRect(5.0, 7.0, 1.0, 1.0));
- NSRectFill(NSMakeRect(5.0, 10.0, 1.0, 1.0));
- NSUInteger i, j;
- for (i = 0; i < 7; i++) {
- for (j = 0; j < 3; j++) {
- [[NSColor colorWithCalibratedWhite:0.45 + 0.1 * rand() /
RAND_MAX alpha:1.0] set];
- NSRectFill(NSMakeRect(6.0 + i, 4.0 + 3.0 * j, 1.0, 1.0));
- }
- }
- NSGradient *gradient = [[[NSGradient alloc]
initWithStartingColor:[NSColor colorWithCalibratedWhite:0.0 alpha:0.1]
endingColor:[NSColor colorWithCalibratedWhite:0.0 alpha:0.0]] autorelease];
- [gradient drawInRect:NSMakeRect(2.0, 2.0, 12.0,11.0) angle:90.0];
- [menuIcon unlockFocus];
- }
- return menuIcon;
-}
-
- (NSString *)windowNibName { return @"BookmarkSheet"; }
- (void)addMenuItemsForBookmarks:(NSArray *)bookmarks level:(NSInteger)level
toMenu:(NSMenu *)menu {
@@ -156,7 +108,7 @@
SKBookmark *root = [bookmarkController bookmarkRoot];
[folderPopUp removeAllItems];
NSMenuItem *item = [[folderPopUp menu]
addItemWithTitle:NSLocalizedString(@"Bookmarks Menu", @"Menu item title")
action:NULL keyEquivalent:@""];
- [item setImage:[[self class] menuIcon]];
+ [item setImage:[root icon]];
[item setRepresentedObject:root];
[self addMenuItemsForBookmarks:[root children] level:1 toMenu:[folderPopUp
menu]];
[folderPopUp selectItemAtIndex:0];
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit