Revision: 3606
http://skim-app.svn.sourceforge.net/skim-app/?rev=3606&view=rev
Author: hofman
Date: 2008-04-03 09:57:57 -0700 (Thu, 03 Apr 2008)
Log Message:
-----------
Global variable for note size. Use unsigned long for 4-char code.
Modified Paths:
--------------
trunk/PDFAnnotation_SKExtensions.m
trunk/SKPDFAnnotationNote.h
trunk/SKPDFAnnotationNote.m
trunk/SKPDFView.m
Modified: trunk/PDFAnnotation_SKExtensions.m
===================================================================
--- trunk/PDFAnnotation_SKExtensions.m 2008-04-03 15:27:57 UTC (rev 3605)
+++ trunk/PDFAnnotation_SKExtensions.m 2008-04-03 16:57:57 UTC (rev 3606)
@@ -90,13 +90,12 @@
NSString *SKPDFAnnotationScriptingNoteTypeKey = @"scriptingNoteType";
NSString *SKPDFAnnotationScriptingBorderStyleKey = @"scriptingBorderStyle";
+enum {
+ SKPDFAnnotationScriptingNoteClassCode = 'Note'
+};
+
@implementation PDFAnnotation (SKExtensions)
-- (id)initWithBounds:(NSRect)bounds dictionary:(NSDictionary *)dict{
- [[self initWithBounds:NSZeroRect] release];
- return nil;
-}
-
- (id)initWithProperties:(NSDictionary *)dict{
Class stringClass = [NSString class];
@@ -327,13 +326,14 @@
NSScriptCommand *currentCommand = [NSScriptCommand currentCommand];
if ([currentCommand isKindOfClass:[NSCreateCommand class]]) {
unsigned long classCode = [[(NSCreateCommand *)currentCommand
createClassDescription] appleEventCode];
- float defaultWidth = [[NSUserDefaults standardUserDefaults]
floatForKey:SKDefaultNoteWidthKey];
- float defaultHeight = [[NSUserDefaults standardUserDefaults]
floatForKey:SKDefaultNoteHeightKey];
+ NSRect bounds = NSMakeRect(100.0, 100.0, 0.0, 0.0);
+ bounds.size.width = [[NSUserDefaults standardUserDefaults]
floatForKey:SKDefaultNoteWidthKey];
+ bounds.size.height = [[NSUserDefaults standardUserDefaults]
floatForKey:SKDefaultNoteHeightKey];
- if (classCode == 'Note') {
+ if (classCode == SKPDFAnnotationScriptingNoteClassCode) {
NSDictionary *properties = [(NSCreateCommand *)currentCommand
resolvedKeyDictionary];
- int type = [[properties
objectForKey:SKPDFAnnotationScriptingNoteTypeKey] intValue];
+ unsigned long type = [[properties
objectForKey:SKPDFAnnotationScriptingNoteTypeKey] unsignedLongValue];
if (type == 0) {
[currentCommand
setScriptErrorNumber:NSRequiredArgumentsMissingScriptError];
@@ -360,15 +360,16 @@
}
}
} else if (type == SKScriptingTextNote) {
- self = [[SKPDFAnnotationFreeText alloc]
initWithBounds:NSMakeRect(100.0, 100.0, defaultWidth, defaultHeight)];
+ self = [[SKPDFAnnotationFreeText alloc] initWithBounds:bounds];
} else if (type == SKScriptingAnchoredNote) {
- self = [[SKPDFAnnotationNote alloc]
initWithBounds:NSMakeRect(100.0, 100.0, 16.0, 16.0)];
+ bounds.size = SKPDFAnnotationNoteSize;
+ self = [[SKPDFAnnotationNote alloc] initWithBounds:bounds];
} else if (type == SKScriptingCircleNote) {
- self = [[SKPDFAnnotationCircle alloc]
initWithBounds:NSMakeRect(100.0, 100.0, defaultWidth, defaultHeight)];
+ self = [[SKPDFAnnotationCircle alloc] initWithBounds:bounds];
} else if (type == SKScriptingSquareNote) {
- self = [[SKPDFAnnotationSquare alloc]
initWithBounds:NSMakeRect(100.0, 100.0, defaultWidth, defaultHeight)];
+ self = [[SKPDFAnnotationSquare alloc] initWithBounds:bounds];
} else if (type == SKScriptingLineNote) {
- self = [[SKPDFAnnotationLine alloc]
initWithBounds:NSMakeRect(100.0, 100.0, defaultWidth, defaultHeight)];
+ self = [[SKPDFAnnotationLine alloc] initWithBounds:bounds];
}
}
}
Modified: trunk/SKPDFAnnotationNote.h
===================================================================
--- trunk/SKPDFAnnotationNote.h 2008-04-03 15:27:57 UTC (rev 3605)
+++ trunk/SKPDFAnnotationNote.h 2008-04-03 16:57:57 UTC (rev 3606)
@@ -62,7 +62,9 @@
extern NSString *SKPDFAnnotationScriptingIconTypeKey;
extern NSString *SKPDFAnnotationRichTextKey;
+extern NSSize SKPDFAnnotationNoteSize;
+
@interface PDFAnnotationText (SKLeopardDeprecated)
// these are deprecated on 10.5, but we don't want to use the popup for 10.4
compatibility; we check for existence before using this anyway
- (BOOL)windowIsOpen;
Modified: trunk/SKPDFAnnotationNote.m
===================================================================
--- trunk/SKPDFAnnotationNote.m 2008-04-03 15:27:57 UTC (rev 3605)
+++ trunk/SKPDFAnnotationNote.m 2008-04-03 16:57:57 UTC (rev 3606)
@@ -79,6 +79,7 @@
NSString *SKPDFAnnotationScriptingIconTypeKey = @"scriptingIconType";
NSString *SKPDFAnnotationRichTextKey = @"richText";
+NSSize SKPDFAnnotationNoteSize = {16.0, 16.0};
@implementation SKPDFAnnotationNote
@@ -318,7 +319,7 @@
- (id)copyNoteAnnotation {
NSRect bounds = [self bounds];
- bounds.size = SKMakeSquareSize(16.0);
+ bounds.size = SKPDFAnnotationNoteSize;
SKPDFAnnotationNote *annotation = [[SKPDFAnnotationNote alloc]
initWithBounds:bounds];
[annotation setString:[self string]];
[annotation setColor:[self color]];
Modified: trunk/SKPDFView.m
===================================================================
--- trunk/SKPDFView.m 2008-04-03 15:27:57 UTC (rev 3605)
+++ trunk/SKPDFView.m 2008-04-03 16:57:57 UTC (rev 3606)
@@ -92,8 +92,6 @@
static unsigned int moveReadingBarModifiers = NSAlternateKeyMask;
static unsigned int resizeReadingBarModifiers = NSAlternateKeyMask |
NSShiftKeyMask;
-#define ANCHORED_NOTE_SIZE SKMakeSquareSize(16.0)
-
static inline int SKIndexOfRectAtYInOrderedRects(float y, NSArray
*rectValues, BOOL lower);
static CGMutablePathRef SKCGCreatePathWithRoundRectInRect(CGRect rect, float
radius);
@@ -827,7 +825,7 @@
float defaultWidth = [[NSUserDefaults standardUserDefaults]
floatForKey:SKDefaultNoteWidthKey];
float defaultHeight = [[NSUserDefaults standardUserDefaults]
floatForKey:SKDefaultNoteHeightKey];
- NSSize defaultSize = isAlternate ? ANCHORED_NOTE_SIZE : ([page
rotation] % 180 == 0) ? NSMakeSize(defaultWidth, defaultHeight) :
NSMakeSize(defaultHeight, defaultWidth);
+ NSSize defaultSize = isAlternate ? SKPDFAnnotationNoteSize : ([page
rotation] % 180 == 0) ? NSMakeSize(defaultWidth, defaultHeight) :
NSMakeSize(defaultHeight, defaultWidth);
NSRect bounds = SKRectFromCenterAndSize(center, defaultSize);
bounds = SKConstrainRect(bounds, [page boundsForBox:[self
displayBox]]);
@@ -1705,7 +1703,7 @@
if (annotationType == SKCircleNote || annotationType == SKSquareNote)
bounds = NSInsetRect(bounds, -5.0, -5.0);
else if (annotationType == SKAnchoredNote)
- bounds.size = ANCHORED_NOTE_SIZE;
+ bounds.size = SKPDFAnnotationNoteSize;
} else if (annotationType == SKHighlightNote || annotationType ==
SKUnderlineNote || annotationType == SKStrikeOutNote) {
NSBeep();
return;
@@ -1726,7 +1724,7 @@
float defaultWidth = [[NSUserDefaults standardUserDefaults]
floatForKey:SKDefaultNoteWidthKey];
float defaultHeight = [[NSUserDefaults standardUserDefaults]
floatForKey:SKDefaultNoteHeightKey];
- NSSize defaultSize = (annotationType == SKAnchoredNote) ?
ANCHORED_NOTE_SIZE : ([page rotation] % 180 == 0) ? NSMakeSize(defaultWidth,
defaultHeight) : NSMakeSize(defaultHeight, defaultWidth);
+ NSSize defaultSize = (annotationType == SKAnchoredNote) ?
SKPDFAnnotationNoteSize : ([page rotation] % 180 == 0) ?
NSMakeSize(defaultWidth, defaultHeight) : NSMakeSize(defaultHeight,
defaultWidth);
// Convert to "page space".
center = SKIntegralPoint([self convertPoint: center toPage:
page]);
@@ -2745,7 +2743,7 @@
NSPointInRect(pagePoint, [page boundsForBox:[self
displayBox]])) {
// add a new annotation immediately, unless this is just a click
if (annotationMode == SKAnchoredNote || NSLeftMouseDragged ==
[[NSApp nextEventMatchingMask:(NSLeftMouseUpMask | NSLeftMouseDraggedMask)
untilDate:[NSDate distantFuture] inMode:NSDefaultRunLoopMode dequeue:NO] type])
{
- NSSize size = annotationMode == SKAnchoredNote ?
ANCHORED_NOTE_SIZE : NSZeroSize;
+ NSSize size = annotationMode == SKAnchoredNote ?
SKPDFAnnotationNoteSize : NSZeroSize;
NSRect bounds = SKRectFromCenterAndSize(pagePoint, size);
[self addAnnotationWithType:annotationMode contents:nil
page:page bounds:bounds];
newActiveAnnotation = activeAnnotation;
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
-------------------------------------------------------------------------
Check out the new SourceForge.net Marketplace.
It's the best place to buy or sell services for
just about anything Open Source.
http://ad.doubleclick.net/clk;164216239;13503038;w?http://sf.net/marketplace
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit