Revision: 5374
http://skim-app.svn.sourceforge.net/skim-app/?rev=5374&view=rev
Author: hofman
Date: 2009-05-11 11:08:09 +0000 (Mon, 11 May 2009)
Log Message:
-----------
Draw scroller background in a custom view enclosing the placard view. Use
normal popup buttons as placard views.
Modified Paths:
--------------
trunk/NSScrollView_SKExtensions.m
trunk/SKSecondaryPDFView.m
trunk/SKSnapshotPDFView.m
trunk/Skim.xcodeproj/project.pbxproj
Removed Paths:
-------------
trunk/BDSKHeaderPopUpButton.h
trunk/BDSKHeaderPopUpButton.m
trunk/BDSKHeaderPopUpButtonCell.h
trunk/BDSKHeaderPopUpButtonCell.m
Deleted: trunk/BDSKHeaderPopUpButton.h
===================================================================
--- trunk/BDSKHeaderPopUpButton.h 2009-05-10 12:10:37 UTC (rev 5373)
+++ trunk/BDSKHeaderPopUpButton.h 2009-05-11 11:08:09 UTC (rev 5374)
@@ -1,45 +0,0 @@
-//
-// BDSKHeaderPopUpButton.h
-// Bibdesk
-//
-// Created by Christiaan Hofman on 10/23/05.
-/*
- This software is Copyright (c) 2005-2009-2008
- Christiaan Hofman. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
- - Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- - Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in
- the documentation and/or other materials provided with the
- distribution.
-
- - Neither the name of Christiaan Hofman nor the names of any
- contributors may be used to endorse or promote products derived
- from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import <Cocoa/Cocoa.h>
-#import "BDSKHeaderPopUpButtonCell.h"
-
-
-...@interface BDSKHeaderPopUpButton : NSPopUpButton {
-}
-...@end
Deleted: trunk/BDSKHeaderPopUpButton.m
===================================================================
--- trunk/BDSKHeaderPopUpButton.m 2009-05-10 12:10:37 UTC (rev 5373)
+++ trunk/BDSKHeaderPopUpButton.m 2009-05-11 11:08:09 UTC (rev 5374)
@@ -1,48 +0,0 @@
-//
-// BDSKHeaderPopUpButton.m
-// Bibdesk
-//
-// Created by Christiaan Hofman on 10/23/05.
-/*
- This software is Copyright (c) 2005-2009-2008
- Christiaan Hofman. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
- - Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- - Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in
- the documentation and/or other materials provided with the
- distribution.
-
- - Neither the name of Christiaan Hofman nor the names of any
- contributors may be used to endorse or promote products derived
- from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "BDSKHeaderPopUpButton.h"
-
-
-...@implementation BDSKHeaderPopUpButton
-
-+ (Class)cellClass{
- return [BDSKHeaderPopUpButtonCell class];
-}
-
-...@end
Deleted: trunk/BDSKHeaderPopUpButtonCell.h
===================================================================
--- trunk/BDSKHeaderPopUpButtonCell.h 2009-05-10 12:10:37 UTC (rev 5373)
+++ trunk/BDSKHeaderPopUpButtonCell.h 2009-05-11 11:08:09 UTC (rev 5374)
@@ -1,43 +0,0 @@
-//
-// BDSKHeaderPopUpButtonCell.h
-// Bibdesk
-//
-// Created by Christiaan Hofman on 10/23/05.
-/*
- This software is Copyright (c) 2005-2009-2008
- Christiaan Hofman. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
- - Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- - Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in
- the documentation and/or other materials provided with the
- distribution.
-
- - Neither the name of Christiaan Hofman nor the names of any
- contributors may be used to endorse or promote products derived
- from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import <Cocoa/Cocoa.h>
-
-
-...@interface BDSKHeaderPopUpButtonCell : NSPopUpButtonCell
-...@end
Deleted: trunk/BDSKHeaderPopUpButtonCell.m
===================================================================
--- trunk/BDSKHeaderPopUpButtonCell.m 2009-05-10 12:10:37 UTC (rev 5373)
+++ trunk/BDSKHeaderPopUpButtonCell.m 2009-05-11 11:08:09 UTC (rev 5374)
@@ -1,68 +0,0 @@
-//
-// BDSKHeaderPopUpButtonCell.m
-// Bibdesk
-//
-// Created by Christiaan Hofman on 10/23/05.
-/*
- This software is Copyright (c) 2005-2009-2008
- Christiaan Hofman. All rights reserved.
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions
- are met:
-
- - Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-
- - Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in
- the documentation and/or other materials provided with the
- distribution.
-
- - Neither the name of Christiaan Hofman nor the names of any
- contributors may be used to endorse or promote products derived
- from this software without specific prior written permission.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#import "BDSKHeaderPopUpButtonCell.h"
-#import "NSImage_SKExtensions.h"
-
-...@implementation BDSKHeaderPopUpButtonCell
-
-- (id)initTextCell:(NSString *)stringValue pullsDown:(BOOL)pullDown {
- if ([super initTextCell:@"" pullsDown:NO]) {
- [self setBordered:NO];
- [self setEnabled:YES];
- [self setUsesItemFromMenu:YES];
- [self setRefusesFirstResponder:YES];
- }
- return self;
-}
-
-- (NSSize)cellSize {
- NSSize size = [super cellSize];
- size.width -= 22.0 + 2 * [self controlSize];
- return size;
-}
-
-- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView {
- NSRect bgRect, divRect, srcRect = NSMakeRect(0.0, 0.0, 1.0, 15.0);
- NSDivideRect(cellFrame, &divRect, &bgRect, 1.0, NSMaxXEdge);
- [[NSImage imageNamed:@"Scroller_Background"] drawFlipped:[controlView
isFlipped] inRect:bgRect fromRect:srcRect operation:NSCompositeSourceOver
fraction:1.0];
- [[NSImage imageNamed:@"Scroller_Divider"] drawFlipped:[controlView
isFlipped] inRect:divRect fromRect:srcRect operation:NSCompositeSourceOver
fraction:1.0];
- [super drawWithFrame:cellFrame inView:controlView];
-}
-
-...@end
Modified: trunk/NSScrollView_SKExtensions.m
===================================================================
--- trunk/NSScrollView_SKExtensions.m 2009-05-10 12:10:37 UTC (rev 5373)
+++ trunk/NSScrollView_SKExtensions.m 2009-05-11 11:08:09 UTC (rev 5374)
@@ -41,6 +41,11 @@
#import "BDSKEdgeView.h"
+...@interface BDSKPlacardView : NSView
+- (void)tile;
+...@end
+
+
@implementation NSScrollView (SKExtensions)
static void (*original_setHasHorizontalScroller)(id, SEL, BOOL) = NULL;
@@ -48,11 +53,11 @@
static void (*original_dealloc)(id, SEL) = NULL;
static void (*original_tile)(id, SEL) = NULL;
-static CFMutableDictionaryRef scrollViewPlacards = NULL;
+static CFMutableDictionaryRef scrollViewPlacardViews = NULL;
- (void)replacement_dealloc;
{
- CFDictionaryRemoveValue(scrollViewPlacards, self);
+ CFDictionaryRemoveValue(scrollViewPlacardViews, self);
original_dealloc(self, _cmd);
}
@@ -71,70 +76,97 @@
- (void)replacement_tile {
original_tile(self, _cmd);
- NSArray *placards = [self placards];
-
- if ([placards count]) {
- NSEnumerator *viewEnum = [placards objectEnumerator];
- NSView *view;
- NSScroller *horizScroller = [self horizontalScroller];
- NSRect viewFrame, horizScrollerFrame = [horizScroller frame];
- CGFloat height = NSHeight(horizScrollerFrame), totalWidth = 0.0;
- BDSKEdgeView *edgeView = (BDSKEdgeView *)[[[placards lastObject]
superview] superview];
-
- if ([edgeView isDescendantOf:self] == NO) {
- edgeView = [[[BDSKEdgeView alloc] init] autorelease];
- [edgeView setEdgeColor:[NSColor colorWithCalibratedWhite:0.75
alpha:1.0]];
- [edgeView setEdges:BDSKMinXEdgeMask];
- [self addSubview:edgeView];
- }
-
- while (view = [viewEnum nextObject]) {
- viewFrame = NSMakeRect(totalWidth, 0.0, NSWidth([view frame]),
height);
- totalWidth += NSWidth(viewFrame);
- [view setFrame:viewFrame];
- if ([view isDescendantOf:edgeView] == NO)
- [edgeView addSubview:view];
- }
-
- NSDivideRect(horizScrollerFrame, &viewFrame, &horizScrollerFrame,
totalWidth + 1.0, NSMaxXEdge);
- [horizScroller setFrame:horizScrollerFrame];
- [edgeView setFrame:viewFrame];
+ BDSKPlacardView *placardView = (BDSKPlacardView
*)CFDictionaryGetValue(scrollViewPlacardViews, self);
+ if (placardView) {
+ NSScroller *scroller = [self horizontalScroller];
+ NSRect placardFrame, scrollerFrame = [scroller frame];
+ [placardView tile];
+ NSDivideRect(scrollerFrame, &placardFrame, &scrollerFrame,
NSWidth([placardView frame]), NSMaxXEdge);
+ [scroller setFrame:scrollerFrame];
+ [placardView setFrame:placardFrame];
+ if ([placardView isDescendantOf:self] == NO)
+ [self addSubview:placardView];
}
}
-+ (void)load{
++ (void)load {
original_setHasHorizontalScroller = (void (*)(id, SEL,
BOOL))SKReplaceInstanceMethodImplementationFromSelector(self,
@selector(setHasHorizontalScroller:),
@selector(replacement_setHasHorizontalScroller:));
original_setAutohidesScrollers = (void (*)(id, SEL,
BOOL))SKReplaceInstanceMethodImplementationFromSelector(self,
@selector(setAutohidesScrollers:),
@selector(replacement_setAutohidesScrollers:));
original_dealloc = (void (*)(id,
SEL))SKReplaceInstanceMethodImplementationFromSelector(self,
@selector(dealloc), @selector(replacement_dealloc));
original_tile = (void (*)(id,
SEL))SKReplaceInstanceMethodImplementationFromSelector(self, @selector(tile),
@selector(replacement_tile));
// dictionary doesn't retain keys, so no retain cycles; pointer equality
used to compare views
- scrollViewPlacards = CFDictionaryCreateMutable(CFAllocatorGetDefault(), 0,
NULL, &kCFTypeDictionaryValueCallBacks);
+ scrollViewPlacardViews =
CFDictionaryCreateMutable(CFAllocatorGetDefault(), 0, NULL,
&kCFTypeDictionaryValueCallBacks);
}
- (NSArray *)placards {
- return (NSArray *)CFDictionaryGetValue(scrollViewPlacards, self);
+ return [(NSView *)CFDictionaryGetValue(scrollViewPlacardViews, self)
subviews];
}
- (void)setPlacards:(NSArray *)newPlacards {
- NSMutableArray *placards = (NSMutableArray
*)CFDictionaryGetValue(scrollViewPlacards, self);
- if (placards == nil && [newPlacards count]) {
- placards = [NSMutableArray array];
- CFDictionarySetValue(scrollViewPlacards, self, placards);
+ BDSKPlacardView *placardView = [(BDSKPlacardView
*)CFDictionaryGetValue(scrollViewPlacardViews, self) retain];
+ if (placardView == nil && [newPlacards count]) {
+ placardView = [[BDSKPlacardView alloc] init];
+ CFDictionarySetValue(scrollViewPlacardViews, self, placardView);
}
- [[[[placards lastObject] superview] superview] removeFromSuperview];
- [placards setArray:newPlacards];
+ [placardView removeFromSuperview];
- if ([placards count] != 0) {
+ NSArray *subviews = [[placardView subviews] retain];
+ NSEnumerator *viewEnum = [newPlacards objectEnumerator];
+ NSView *view;
+ [subviews makeObjectsPerformSelector:@selector(removeFromSuperview)];
+ while (view = [viewEnum nextObject])
+ [placardView addSubview:view];
+ [subviews release];
+
+ if ([newPlacards count] != 0) {
original_setHasHorizontalScroller(self,
@selector(setHasHorizontalScroller:), YES);
original_setAutohidesScrollers(self,
@selector(setAutohidesScrollers:), NO);
- } else if (placards) {
- CFDictionaryRemoveValue(scrollViewPlacards, self);
- placards = nil;
+ } else if (placardView) {
+ CFDictionaryRemoveValue(scrollViewPlacardViews, self);
}
+ [placardView release];
[self tile];
}
@end
+
+
+...@implementation BDSKPlacardView
+
+- (void)drawRect:(NSRect)aRect {
+ [self subviews];
+ NSImage *bgImage = [NSImage imageNamed:@"Scroller_Background"];
+ NSImage *divImage = [NSImage imageNamed:@"Scroller_Divider"];
+ NSRect srcRect = {NSZeroPoint, [bgImage size]};
+ NSRect bounds = [self bounds];
+ NSRect divRect = bounds;
+ divRect.size.width = 1.0;
+ [bgImage drawInRect:bounds fromRect:srcRect
operation:NSCompositeSourceOver fraction:1.0];
+ [divImage drawInRect:divRect fromRect:srcRect
operation:NSCompositeSourceOver fraction:1.0];
+ NSEnumerator *viewEnum = [[self subviews] objectEnumerator];
+ NSView *view;
+ while (view = [viewEnum nextObject]) {
+ divRect.origin.x = NSMaxX([view frame]);
+ [divImage drawInRect:divRect fromRect:srcRect
operation:NSCompositeSourceOver fraction:1.0];
+ }
+}
+
+- (void)tile {
+ NSSize size = NSMakeSize(1.0, [NSScroller scrollerWidth]);
+ NSEnumerator *viewEnum = [[self subviews] objectEnumerator];
+ NSView *view;
+ while (view = [viewEnum nextObject]) {
+ NSRect rect = [view frame];
+ rect.origin.x = size.width;
+ rect.origin.y = 0.0;
+ rect.size.height = size.height;
+ [view setFrame:rect];
+ size.width += NSWidth(rect) + 1.0;
+ }
+ [self setFrameSize:size];
+}
+
+...@end
Modified: trunk/SKSecondaryPDFView.m
===================================================================
--- trunk/SKSecondaryPDFView.m 2009-05-10 12:10:37 UTC (rev 5373)
+++ trunk/SKSecondaryPDFView.m 2009-05-11 11:08:09 UTC (rev 5374)
@@ -37,7 +37,6 @@
*/
#import "SKSecondaryPDFView.h"
-#import "BDSKHeaderPopUpButton.h"
#import "NSScrollView_SKExtensions.h"
#import "PDFAnnotation_SKExtensions.h"
#import "PDFPage_SKExtensions.h"
@@ -163,6 +162,16 @@
#pragma mark Popup buttons
+static void sizePopUpToItemAtIndex(NSPopUpButton *popUpButton, NSUInteger
anIndex) {
+ NSUInteger i = [popUpButton indexOfSelectedItem];
+ [popUpButton selectItemAtIndex:anIndex];
+ [popUpButton sizeToFit];
+ NSSize frameSize = [popUpButton frame].size;
+ frameSize.width -= 22.0 + 2 * [[popUpButton cell] controlSize];
+ [popUpButton setFrameSize:frameSize];
+ [popUpButton selectItemAtIndex:i];
+}
+
- (void)reloadPagePopUpButton {
PDFDocument *pdfDoc = [self document];
NSUInteger i, count = [pagePopUpButton numberOfItems];
@@ -186,10 +195,7 @@
[pagePopUpButton addItemWithTitle:label];
}
- i = [pagePopUpButton indexOfSelectedItem];
- [pagePopUpButton selectItemAtIndex:maxIndex];
- [pagePopUpButton sizeToFit];
- [pagePopUpButton selectItemAtIndex:i];
+ sizePopUpToItemAtIndex(pagePopUpButton, maxIndex);
[pagePopUpButton selectItemAtIndex:[pdfDoc indexForPage:[self
currentPage]]];
}
@@ -207,9 +213,13 @@
if (scalePopUpButton == nil) {
// create it
- scalePopUpButton = [[BDSKHeaderPopUpButton allocWithZone:[self zone]]
initWithFrame:NSMakeRect(0.0, 0.0, 1.0, 1.0) pullsDown:NO];
+ scalePopUpButton = [[NSPopUpButton allocWithZone:[self zone]]
initWithFrame:NSMakeRect(0.0, 0.0, 1.0, 1.0) pullsDown:NO];
[[scalePopUpButton cell] setControlSize:controlSize];
+ [scalePopUpButton setBordered:NO];
+ [scalePopUpButton setEnabled:YES];
+ [scalePopUpButton setRefusesFirstResponder:YES];
+ [[scalePopUpButton cell] setUsesItemFromMenu:YES];
// set a suitable font, the control size is 0, 1 or 2
[scalePopUpButton setFont:[NSFont toolTipsFontOfSize:
SKPopUpMenuFontSize - controlSize]];
@@ -241,10 +251,7 @@
[self setScaleFactor:[self scaleFactor] adjustPopup:YES];
// Make sure the popup is big enough to fit the largest cell
- cnt = [scalePopUpButton indexOfSelectedItem];
- [scalePopUpButton selectItemAtIndex:maxIndex];
- [scalePopUpButton sizeToFit];
- [scalePopUpButton selectItemAtIndex:cnt];
+ sizePopUpToItemAtIndex(scalePopUpButton, maxIndex);
// don't let it become first responder
[scalePopUpButton setRefusesFirstResponder:YES];
@@ -258,9 +265,13 @@
if (pagePopUpButton == nil) {
// create it
- pagePopUpButton = [[BDSKHeaderPopUpButton allocWithZone:[self zone]]
initWithFrame:NSMakeRect(0.0, 0.0, 1.0, 1.0) pullsDown:NO];
+ pagePopUpButton = [[NSPopUpButton allocWithZone:[self zone]]
initWithFrame:NSMakeRect(0.0, 0.0, 1.0, 1.0) pullsDown:NO];
[[pagePopUpButton cell] setControlSize:controlSize];
+ [pagePopUpButton setBordered:NO];
+ [pagePopUpButton setEnabled:YES];
+ [pagePopUpButton setRefusesFirstResponder:YES];
+ [[pagePopUpButton cell] setUsesItemFromMenu:YES];
// set a suitable font, the control size is 0, 1 or 2
[pagePopUpButton setFont:[NSFont toolTipsFontOfSize:
SKPopUpMenuFontSize - controlSize]];
Modified: trunk/SKSnapshotPDFView.m
===================================================================
--- trunk/SKSnapshotPDFView.m 2009-05-10 12:10:37 UTC (rev 5373)
+++ trunk/SKSnapshotPDFView.m 2009-05-11 11:08:09 UTC (rev 5374)
@@ -37,7 +37,6 @@
*/
#import "SKSnapshotPDFView.h"
-#import "BDSKHeaderPopUpButton.h"
#import "NSScrollView_SKExtensions.h"
#import "NSResponder_SKExtensions.h"
#import "NSEvent_SKExtensions.h"
@@ -104,6 +103,16 @@
[super dealloc];
}
+static void sizePopUpToItemAtIndex(NSPopUpButton *popUpButton, NSUInteger
anIndex) {
+ NSUInteger i = [popUpButton indexOfSelectedItem];
+ [popUpButton selectItemAtIndex:anIndex];
+ [popUpButton sizeToFit];
+ NSSize frameSize = [popUpButton frame].size;
+ frameSize.width -= 22.0 + 2 * [[popUpButton cell] controlSize];
+ [popUpButton setFrameSize:frameSize];
+ [popUpButton selectItemAtIndex:i];
+}
+
- (void)makeScalePopUpButton {
if (scalePopUpButton == nil) {
@@ -112,10 +121,14 @@
[scrollView setHasHorizontalScroller:YES];
// create it
- scalePopUpButton = [[BDSKHeaderPopUpButton allocWithZone:[self zone]]
initWithFrame:NSMakeRect(0.0, 0.0, 1.0, 1.0) pullsDown:NO];
+ scalePopUpButton = [[NSPopUpButton allocWithZone:[self zone]]
initWithFrame:NSMakeRect(0.0, 0.0, 1.0, 1.0) pullsDown:NO];
NSControlSize controlSize = [[scrollView horizontalScroller]
controlSize];
[[scalePopUpButton cell] setControlSize:controlSize];
+ [scalePopUpButton setBordered:NO];
+ [scalePopUpButton setEnabled:YES];
+ [scalePopUpButton setRefusesFirstResponder:YES];
+ [[scalePopUpButton cell] setUsesItemFromMenu:YES];
// set a suitable font, the control size is 0, 1 or 2
[scalePopUpButton setFont:[NSFont toolTipsFontOfSize:
BDSKScaleMenuFontSize - controlSize]];
@@ -154,10 +167,7 @@
[scalePopUpButton setRefusesFirstResponder:YES];
// Make sure the popup is big enough to fit the largest cell
- cnt = [scalePopUpButton indexOfSelectedItem];
- [scalePopUpButton selectItemAtIndex:maxIndex];
- [scalePopUpButton sizeToFit];
- [scalePopUpButton selectItemAtIndex:cnt];
+ sizePopUpToItemAtIndex(scalePopUpButton, maxIndex);
// put it in the scrollview
[scrollView setPlacards:[NSArray arrayWithObject:scalePopUpButton]];
Modified: trunk/Skim.xcodeproj/project.pbxproj
===================================================================
--- trunk/Skim.xcodeproj/project.pbxproj 2009-05-10 12:10:37 UTC (rev
5373)
+++ trunk/Skim.xcodeproj/project.pbxproj 2009-05-11 11:08:09 UTC (rev
5374)
@@ -252,9 +252,7 @@
CEF84C630C78A89A00A3AD51 /* SmallPreferences.tiff in Resources
*/ = {isa = PBXBuildFile; fileRef = CEF84C620C78A89900A3AD51 /*
SmallPreferences.tiff */; };
CEFD68740C01D4080027B933 /* SkimImporter.mdimporter in Copy
Files: Spotlight */ = {isa = PBXBuildFile; fileRef = CEFD68690C01D3BB0027B933
/* SkimImporter.mdimporter */; };
CEFDF8BE0B3848C40091C61A /* SKNavigationWindow.m in Sources */
= {isa = PBXBuildFile; fileRef = CEFDF8BD0B3848C40091C61A /*
SKNavigationWindow.m */; };
- F92DB5AC0B36FE1F002A26E9 /* BDSKHeaderPopUpButtonCell.m in
Sources */ = {isa = PBXBuildFile; fileRef = F92DB5A90B36FE1F002A26E9 /*
BDSKHeaderPopUpButtonCell.m */; };
F92DB5AD0B36FE1F002A26E9 /* SKSnapshotPDFView.m in Sources */ =
{isa = PBXBuildFile; fileRef = F92DB5AB0B36FE1F002A26E9 /* SKSnapshotPDFView.m
*/; };
- F92DB5B30B36FE5E002A26E9 /* BDSKHeaderPopUpButton.m in Sources
*/ = {isa = PBXBuildFile; fileRef = F92DB5B20B36FE5E002A26E9 /*
BDSKHeaderPopUpButton.m */; };
F968C5A30C036E9D000BD1B2 /* NSBitmapImageRep_SKExtensions.m in
Sources */ = {isa = PBXBuildFile; fileRef = F968C5A10C036E9D000BD1B2 /*
NSBitmapImageRep_SKExtensions.m */; };
F97751630B37461000DF673B /* SKConversionProgressController.m in
Sources */ = {isa = PBXBuildFile; fileRef = F97751620B37461000DF673B /*
SKConversionProgressController.m */; };
F98E24BF0B702D9400914AF0 /* Carbon.framework in Frameworks */ =
{isa = PBXBuildFile; fileRef = F98E24BE0B702D9400914AF0 /* Carbon.framework */;
};
@@ -971,12 +969,8 @@
CEFD68610C01D3BB0027B933 /* SkimImporter.xcodeproj */ = {isa =
PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name =
SkimImporter.xcodeproj; path = SkimImporter/SkimImporter.xcodeproj; sourceTree
= "<group>"; };
CEFDF8BC0B3848C40091C61A /* SKNavigationWindow.h */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path =
SKNavigationWindow.h; sourceTree = "<group>"; };
CEFDF8BD0B3848C40091C61A /* SKNavigationWindow.m */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path
= SKNavigationWindow.m; sourceTree = "<group>"; };
- F92DB5A80B36FE1F002A26E9 /* BDSKHeaderPopUpButtonCell.h */ =
{isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h;
path = BDSKHeaderPopUpButtonCell.h; sourceTree = "<group>"; };
- F92DB5A90B36FE1F002A26E9 /* BDSKHeaderPopUpButtonCell.m */ =
{isa = PBXFileReference; fileEncoding = 4; lastKnownFileType =
sourcecode.c.objc; path = BDSKHeaderPopUpButtonCell.m; sourceTree = "<group>";
};
F92DB5AA0B36FE1F002A26E9 /* SKSnapshotPDFView.h */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path =
SKSnapshotPDFView.h; sourceTree = "<group>"; };
F92DB5AB0B36FE1F002A26E9 /* SKSnapshotPDFView.m */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path
= SKSnapshotPDFView.m; sourceTree = "<group>"; };
- F92DB5B10B36FE5E002A26E9 /* BDSKHeaderPopUpButton.h */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path =
BDSKHeaderPopUpButton.h; sourceTree = "<group>"; };
- F92DB5B20B36FE5E002A26E9 /* BDSKHeaderPopUpButton.m */ = {isa =
PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path
= BDSKHeaderPopUpButton.m; sourceTree = "<group>"; };
F968C5A00C036E9D000BD1B2 /* NSBitmapImageRep_SKExtensions.h */
= {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType =
sourcecode.c.h; path = NSBitmapImageRep_SKExtensions.h; sourceTree = "<group>";
};
F968C5A10C036E9D000BD1B2 /* NSBitmapImageRep_SKExtensions.m */
= {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType =
sourcecode.c.objc; path = NSBitmapImageRep_SKExtensions.m; sourceTree =
"<group>"; };
F97751610B37461000DF673B /* SKConversionProgressController.h */
= {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType =
sourcecode.c.h; path = SKConversionProgressController.h; sourceTree =
"<group>"; };
@@ -1386,10 +1380,6 @@
CE3A41570B790C56006B64D3 /* BDSKDragImageView.m
*/,
CE2DED6A0B86334900D0DA12 /*
BDSKFindFieldEditor.h */,
CE2DED6B0B86334900D0DA12 /*
BDSKFindFieldEditor.m */,
- F92DB5B10B36FE5E002A26E9 /*
BDSKHeaderPopUpButton.h */,
- F92DB5B20B36FE5E002A26E9 /*
BDSKHeaderPopUpButton.m */,
- F92DB5A80B36FE1F002A26E9 /*
BDSKHeaderPopUpButtonCell.h */,
- F92DB5A90B36FE1F002A26E9 /*
BDSKHeaderPopUpButtonCell.m */,
);
name = Views;
sourceTree = "<group>";
@@ -2074,9 +2064,7 @@
4530DCF70B27CACE007C59F4 /* SKPDFView.m in
Sources */,
CE546FC40B32D5DB00F8AFB6 /*
SKNoteWindowController.m in Sources */,
CE54898F0B35D50E00F8AFB6 /*
SKInfoWindowController.m in Sources */,
- F92DB5AC0B36FE1F002A26E9 /*
BDSKHeaderPopUpButtonCell.m in Sources */,
F92DB5AD0B36FE1F002A26E9 /* SKSnapshotPDFView.m
in Sources */,
- F92DB5B30B36FE5E002A26E9 /*
BDSKHeaderPopUpButton.m in Sources */,
F97751630B37461000DF673B /*
SKConversionProgressController.m in Sources */,
CEFDF8BE0B3848C40091C61A /*
SKNavigationWindow.m in Sources */,
45A3BD080B4F0770002B297F /* SKStringConstants.m
in Sources */,
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
The NEW KODAK i700 Series Scanners deliver under ANY circumstances! Your
production scanning environment may not be a perfect world - but thanks to
Kodak, there's a perfect scanner to get the job done! With the NEW KODAK i700
Series Scanner you'll get full speed at 300 dpi even with all image
processing features enabled. http://p.sf.net/sfu/kodak-com
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit