-(void)switchView:(id)sender { if (isSimpleView) { int mask = (NSNormalWindowLevel); isSimpleView = NO; [mainWindow setShowsToolbarButton:YES]; [[mainWindow toolbar]setSizeMode:NSToolbarSizeModeRegular]; NSRect newFrame = [mainWindow frameRectForContentRect:[tmpStandardView frame]]; newFrame.size.height = prevHeight; newFrame.size.width = prevWidth; int widthDiff = [tmpStandardView frame].size.width - [mainWindow frame].size.width; int heightDiff = [tmpStandardView frame].size.height - [mainWindow frame].size.height; newFrame.origin.x = [mainWindow frame].origin.x - (widthDiff / 2); newFrame.origin.y = [mainWindow frame].origin.y - (heightDiff / 2); [mainWindow setFrame:newFrame display:YES animate:YES]; //tmpStandardView == [[mainWindow contentView]retain]; [mainWindow setContentView:tmpStandardView]; [mainWindow setShowsResizeIndicator:YES]; [mainWindow setLevel:mask]; tmpStandardView = nil; } else { int mask = (NSModalPanelWindowLevel); isSimpleView = YES; [mainWindow setShowsToolbarButton:NO]; [[mainWindow toolbar]setSizeMode:NSToolbarSizeModeSmall]; prevHeight = [mainWindow frame].size.height; prevWidth = [mainWindow frame].size.width; NSRect newFrame = [mainWindow frameRectForContentRect:[simpleView frame]]; newFrame.size.height = 300; newFrame.size.width = 500; int widthDiff = [simpleView frame].size.width - [mainWindow frame].size.width; int heightDiff = [simpleView frame].size.height - [mainWindow frame].size.height; newFrame.origin.x = [mainWindow frame].origin.x - (widthDiff / 2); newFrame.origin.y = [mainWindow frame].origin.y - (heightDiff / 2); //newFrame.origin.y = ([mainWindow frame].size.height / 2); //newFrame.origin.x = ([mainWindow frameRectForContentRect:[mainWindow frame]].size.width / 2); [mainWindow setLevel:mask]; [mainWindow setFrame:newFrame display:YES animate:YES]; tmpStandardView = [[mainWindow contentView]retain]; [mainWindow setContentView:simpleView]; [mainWindow setShowsResizeIndicator:NO]; } }