From 2de8faf99a72188f15218d357cf9e36b4b2a883e Mon Sep 17 00:00:00 2001 From: Gregory John Casamento Date: Mon, 4 Jan 2010 05:24:37 +0000 Subject: [PATCH] * Source/GSWindowDecorationView.[hm]: Addition of ivars to track if a toolbar or menu is present in the window decorations. Modified code to set these to YES/NO. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@29203 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 6 +++ Source/GSWindowDecorationView.h | 6 +-- Source/GSWindowDecorationView.m | 89 +++++++++++++++------------------ 3 files changed, 49 insertions(+), 52 deletions(-) diff --git a/ChangeLog b/ChangeLog index b7b38c551..9dc2d1fe6 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2010-01-04 00:25-EST Gregory John Casamento + + * Source/GSWindowDecorationView.[hm]: Addition of ivars to track + if a toolbar or menu is present in the window decorations. Modified + code to set these to YES/NO. + 2010-01-04 Riccardo Mottola * Source/GSWindowDecorationView.m: When adding a toolbar take in account diff --git a/Source/GSWindowDecorationView.h b/Source/GSWindowDecorationView.h index bcdfab4d2..8127d1c5e 100644 --- a/Source/GSWindowDecorationView.h +++ b/Source/GSWindowDecorationView.h @@ -54,11 +54,11 @@ this, either directly, or indirectly (by using the backend). { NSWindow *window; /* not retained */ int windowNumber; - NSRect contentRect; - int inputState; BOOL documentEdited; + BOOL hasMenu; + BOOL hasToolbar; } + (id) windowDecorator; @@ -101,7 +101,7 @@ Standard OPENSTEP-ish window decorations. @interface GSStandardWindowDecorationView : GSWindowDecorationView { BOOL hasTitleBar, hasResizeBar, hasCloseButton, hasMiniaturizeButton; - BOOL isTitled; + BOOL isTitled; //, hasToolbar, hasMenu; NSRect titleBarRect; NSRect resizeBarRect; NSRect closeButtonRect; diff --git a/Source/GSWindowDecorationView.m b/Source/GSWindowDecorationView.m index 40f7f6b97..fb275d0e9 100644 --- a/Source/GSWindowDecorationView.m +++ b/Source/GSWindowDecorationView.m @@ -108,6 +108,8 @@ self = [super initWithFrame: frame]; if (self != nil) { + hasToolbar = NO; + hasMenu = NO; window = w; // Content rect will be everything apart from the border // that is including menu, toolbar and the like. @@ -209,12 +211,12 @@ NSRect contentViewFrame; NSToolbar *tb = [_window toolbar]; NSRect frame = [window frame]; - + frame.origin = NSZeroPoint; contentViewFrame = [isa contentRectForFrameRect: frame styleMask: [window styleMask]]; - if ([_window menu] != nil) + if (hasMenu) { NSMenuView *menuView; float menuBarHeight = [NSMenuView menuBarHeight]; @@ -228,25 +230,28 @@ contentViewFrame.size.height -= menuBarHeight; } - if ([tb isVisible]) + if(hasToolbar) { - GSToolbarView *tv = [tb _toolbarView]; - float newToolbarViewHeight; - - // If the width changed we may need to recalculate the height - if (contentViewFrame.size.width != [tv frame].size.width) - { - [tv setFrameSize: NSMakeSize(contentViewFrame.size.width, 100)]; - // Will recalculate the layout - [tv _reload]; - } - newToolbarViewHeight = [tv _heightFromLayout]; - [tv setFrame: NSMakeRect( - contentViewFrame.origin.x, - NSMaxY(contentViewFrame) - newToolbarViewHeight, - contentViewFrame.size.width, - newToolbarViewHeight)]; - contentViewFrame.size.height -= newToolbarViewHeight; + if ([tb isVisible]) + { + GSToolbarView *tv = [tb _toolbarView]; + float newToolbarViewHeight; + + // If the width changed we may need to recalculate the height + if (contentViewFrame.size.width != [tv frame].size.width) + { + [tv setFrameSize: NSMakeSize(contentViewFrame.size.width, 100)]; + // Will recalculate the layout + [tv _reload]; + } + newToolbarViewHeight = [tv _heightFromLayout]; + [tv setFrame: NSMakeRect( + contentViewFrame.origin.x, + NSMaxY(contentViewFrame) - newToolbarViewHeight, + contentViewFrame.size.width, + newToolbarViewHeight)]; + contentViewFrame.size.height -= newToolbarViewHeight; + } } } @@ -355,6 +360,7 @@ float newToolbarViewHeight; float contentYOrigin; + hasToolbar = YES; [toolbarView setFrameSize: NSMakeSize(contentRect.size.width, 100)]; // Will recalculate the layout [toolbarView _reload]; @@ -362,9 +368,11 @@ // take in account of the menubar when calculating the origin contentYOrigin = NSMaxY(contentRect); - if ([_window menu] != nil) + if(hasMenu) + { contentYOrigin -= [NSMenuView menuBarHeight]; - + } + // Plug the toolbar view [toolbarView setFrame: NSMakeRect( contentRect.origin.x, @@ -381,8 +389,9 @@ float toolbarViewHeight = [toolbarView frame].size.height; // Unplug the toolbar view + hasToolbar = NO; [toolbarView removeFromSuperviewWithoutNeedingDisplay]; - + [self changeWindowHeight: -toolbarViewHeight]; } @@ -413,6 +422,7 @@ { float menubarHeight = [NSMenuView menuBarHeight]; + hasMenu = YES; // Plug the menu view [menuView setFrame: NSMakeRect( contentRect.origin.x, @@ -428,42 +438,23 @@ { NSEnumerator *e = [[self subviews] objectEnumerator]; NSView *v; - + while ((v = [e nextObject]) != nil) { if ([v isKindOfClass: [NSMenuView class]] == YES) { - float menubarHeight = [NSMenuView menuBarHeight]; - /* Unplug the menu view and return it so that it can be - * restored to its original menu if necessary. + * restored to its original menu if necessary. */ + + hasMenu = NO; [RETAIN(v) removeFromSuperviewWithoutNeedingDisplay]; - - [self changeWindowHeight: -menubarHeight]; + + [self changeWindowHeight: -([NSMenuView menuBarHeight])]; return AUTORELEASE(v); } - else if ([v isKindOfClass: [GSToolbarView class]] == YES) - { - GSToolbarView *tv = (GSToolbarView *)v; - NSRect toolViewRect; - - if ([[_window toolbar] isVisible]) - { - /* recalculate the origin of the toolbar view */ - toolViewRect = [tv frame]; - toolViewRect = NSMakeRect( - toolViewRect.origin.x, - toolViewRect.origin.y + [NSMenuView menuBarHeight], - toolViewRect.size.width, - toolViewRect.size.height); - - /* move the toolbar view up of the menubar height */ - [tv setFrame: toolViewRect]; - [tv setNeedsDisplay:YES]; - } - } } + return nil; }