Revision: 5424
http://skim-app.svn.sourceforge.net/skim-app/?rev=5424&view=rev
Author: hofman
Date: 2009-06-15 16:59:51 +0000 (Mon, 15 Jun 2009)
Log Message:
-----------
move repeating code to separate method
Modified Paths:
--------------
trunk/SKMainWindowController.m
Modified: trunk/SKMainWindowController.m
===================================================================
--- trunk/SKMainWindowController.m 2009-06-13 23:56:21 UTC (rev 5423)
+++ trunk/SKMainWindowController.m 2009-06-15 16:59:51 UTC (rev 5424)
@@ -153,6 +153,8 @@
@interface SKMainWindowController (SKPrivate)
+- (void)applyLeftSideWidth:(CGFloat)leftSideWidth
rightSideWidth:(CGFloat)rightSideWidth;
+
- (void)setupToolbar;
- (void)updatePageLabel;
@@ -294,7 +296,6 @@
- (void)windowDidLoad{
NSUserDefaults *sud = [NSUserDefaults standardUserDefaults];
BOOL hasWindowSetup = [savedNormalSetup count] > 0;
- NSRect frame;
mwcFlags.settingUpWindow = 1;
@@ -419,41 +420,8 @@
NSNumber *leftWidth = [savedNormalSetup
objectForKey:LEFTSIDEPANEWIDTH_KEY] ?: [sud
objectForKey:SKLeftSidePaneWidthKey];
NSNumber *rightWidth = [savedNormalSetup
objectForKey:RIGHTSIDEPANEWIDTH_KEY] ?: [sud
objectForKey:SKRightSidePaneWidthKey];
- if (leftWidth && rightWidth) {
- CGFloat width = [leftWidth floatValue];
- if (width >= 0.0) {
- frame = [leftSideContentView frame];
- frame.size.width = width;
- if (mwcFlags.usesDrawers == 0) {
- [leftSideContentView setFrame:frame];
- } else if (width > 0.0) {
- [leftSideDrawer setContentSize:frame.size];
- [leftSideDrawer openOnEdge:NSMinXEdge];
- } else {
- [leftSideDrawer close];
- }
- }
- width = [rightWidth floatValue];
- if (width >= 0.0) {
- frame = [rightSideContentView frame];
- frame.size.width = width;
- if (mwcFlags.usesDrawers == 0) {
- frame.origin.x = NSMaxX([splitView bounds]) - width;
- [rightSideContentView setFrame:frame];
- } else if (width > 0.0) {
- [rightSideDrawer setContentSize:frame.size];
- [rightSideDrawer openOnEdge:NSMaxXEdge];
- } else {
- [rightSideDrawer close];
- }
- }
- if (mwcFlags.usesDrawers == 0) {
- frame = [pdfSplitView frame];
- frame.size.width = NSWidth([splitView frame]) -
NSWidth([leftSideContentView frame]) - NSWidth([rightSideContentView frame]) -
2 * [splitView dividerThickness];
- frame.origin.x = NSMaxX([leftSideContentView frame]) + [splitView
dividerThickness];
- [pdfSplitView setFrame:frame];
- }
- }
+ if (leftWidth && rightWidth)
+ [self applyLeftSideWidth:[leftWidth floatValue]
rightSideWidth:[rightWidth floatValue]];
// this needs to be done before loading the PDFDocument
[self resetThumbnailSizeIfNeeded];
@@ -538,6 +506,41 @@
mwcFlags.settingUpWindow = 0;
}
+- (void)applyLeftSideWidth:(CGFloat)leftSideWidth
rightSideWidth:(CGFloat)rightSideWidth {
+ NSRect frame;
+ if (leftSideWidth >= 0.0) {
+ frame = [leftSideContentView frame];
+ frame.size.width = leftSideWidth;
+ if (mwcFlags.usesDrawers == 0) {
+ [leftSideContentView setFrame:frame];
+ } else if (leftSideWidth > 0.0) {
+ [leftSideDrawer setContentSize:frame.size];
+ [leftSideDrawer openOnEdge:NSMinXEdge];
+ } else {
+ [leftSideDrawer close];
+ }
+ }
+ if (rightSideWidth >= 0.0) {
+ frame = [rightSideContentView frame];
+ frame.size.width = rightSideWidth;
+ if (mwcFlags.usesDrawers == 0) {
+ frame.origin.x = NSMaxX([splitView bounds]) - rightSideWidth;
+ [rightSideContentView setFrame:frame];
+ } else if (rightSideWidth > 0.0) {
+ [rightSideDrawer setContentSize:frame.size];
+ [rightSideDrawer openOnEdge:NSMaxXEdge];
+ } else {
+ [rightSideDrawer close];
+ }
+ }
+ if (mwcFlags.usesDrawers == 0) {
+ frame = [pdfSplitView frame];
+ frame.size.width = NSWidth([splitView frame]) -
NSWidth([leftSideContentView frame]) - NSWidth([rightSideContentView frame]) -
2 * [splitView dividerThickness];
+ frame.origin.x = NSMaxX([leftSideContentView frame]) + [splitView
dividerThickness];
+ [pdfSplitView setFrame:frame];
+ }
+}
+
- (void)applySetup:(NSDictionary *)setup{
if ([self isWindowLoaded] == NO) {
[savedNormalSetup setDictionary:setup];
@@ -549,42 +552,8 @@
NSNumber *leftWidth = [setup objectForKey:LEFTSIDEPANEWIDTH_KEY];
NSNumber *rightWidth = [setup objectForKey:RIGHTSIDEPANEWIDTH_KEY];
- if (leftWidth && rightWidth) {
- CGFloat width = [leftWidth floatValue];
- NSRect frame;
- if (width >= 0.0) {
- frame = [leftSideContentView frame];
- frame.size.width = width;
- if (mwcFlags.usesDrawers == 0) {
- [leftSideContentView setFrame:frame];
- } else if (width > 0.0) {
- [leftSideDrawer setContentSize:frame.size];
- [leftSideDrawer openOnEdge:NSMinXEdge];
- } else {
- [leftSideDrawer close];
- }
- }
- width = [rightWidth floatValue];
- if (width >= 0.0) {
- frame = [rightSideContentView frame];
- frame.size.width = width;
- if (mwcFlags.usesDrawers == 0) {
- frame.origin.x = NSMaxX([splitView bounds]) - width;
- [rightSideContentView setFrame:frame];
- } else if (width > 0.0) {
- [rightSideDrawer setContentSize:frame.size];
- [rightSideDrawer openOnEdge:NSMaxXEdge];
- } else {
- [rightSideDrawer close];
- }
- }
- if (mwcFlags.usesDrawers == 0) {
- frame = [pdfSplitView frame];
- frame.size.width = NSWidth([splitView frame]) -
NSWidth([leftSideContentView frame]) - NSWidth([rightSideContentView frame]) -
2 * [splitView dividerThickness];
- frame.origin.x = NSMaxX([leftSideContentView frame]) +
[splitView dividerThickness];
- [pdfSplitView setFrame:frame];
- }
- }
+ if (leftWidth && rightWidth)
+ [self applyLeftSideWidth:[leftWidth floatValue]
rightSideWidth:[rightWidth floatValue]];
NSUInteger pageIndex = [[setup objectForKey:PAGEINDEX_KEY]
unsignedIntValue];
if (pageIndex != NSNotFound)
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Crystal Reports - New Free Runtime and 30 Day Trial
Check out the new simplified licensing option that enables unlimited
royalty-free distribution of the report engine for externally facing
server and web deployment.
http://p.sf.net/sfu/businessobjects
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit