* 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
This commit is contained in:
Gregory John Casamento 2010-01-04 05:24:37 +00:00
parent 47422f87d4
commit 2de8faf99a
3 changed files with 49 additions and 52 deletions

View file

@ -1,3 +1,9 @@
2010-01-04 00:25-EST Gregory John Casamento <greg.casamento@gmail.com>
* 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 <rmottola@users.sf.net> 2010-01-04 Riccardo Mottola <rmottola@users.sf.net>
* Source/GSWindowDecorationView.m: When adding a toolbar take in account * Source/GSWindowDecorationView.m: When adding a toolbar take in account

View file

@ -54,11 +54,11 @@ this, either directly, or indirectly (by using the backend).
{ {
NSWindow *window; /* not retained */ NSWindow *window; /* not retained */
int windowNumber; int windowNumber;
NSRect contentRect; NSRect contentRect;
int inputState; int inputState;
BOOL documentEdited; BOOL documentEdited;
BOOL hasMenu;
BOOL hasToolbar;
} }
+ (id<GSWindowDecorator>) windowDecorator; + (id<GSWindowDecorator>) windowDecorator;
@ -101,7 +101,7 @@ Standard OPENSTEP-ish window decorations.
@interface GSStandardWindowDecorationView : GSWindowDecorationView @interface GSStandardWindowDecorationView : GSWindowDecorationView
{ {
BOOL hasTitleBar, hasResizeBar, hasCloseButton, hasMiniaturizeButton; BOOL hasTitleBar, hasResizeBar, hasCloseButton, hasMiniaturizeButton;
BOOL isTitled; BOOL isTitled; //, hasToolbar, hasMenu;
NSRect titleBarRect; NSRect titleBarRect;
NSRect resizeBarRect; NSRect resizeBarRect;
NSRect closeButtonRect; NSRect closeButtonRect;

View file

@ -108,6 +108,8 @@
self = [super initWithFrame: frame]; self = [super initWithFrame: frame];
if (self != nil) if (self != nil)
{ {
hasToolbar = NO;
hasMenu = NO;
window = w; window = w;
// Content rect will be everything apart from the border // Content rect will be everything apart from the border
// that is including menu, toolbar and the like. // that is including menu, toolbar and the like.
@ -209,12 +211,12 @@
NSRect contentViewFrame; NSRect contentViewFrame;
NSToolbar *tb = [_window toolbar]; NSToolbar *tb = [_window toolbar];
NSRect frame = [window frame]; NSRect frame = [window frame];
frame.origin = NSZeroPoint; frame.origin = NSZeroPoint;
contentViewFrame = [isa contentRectForFrameRect: frame contentViewFrame = [isa contentRectForFrameRect: frame
styleMask: [window styleMask]]; styleMask: [window styleMask]];
if ([_window menu] != nil) if (hasMenu)
{ {
NSMenuView *menuView; NSMenuView *menuView;
float menuBarHeight = [NSMenuView menuBarHeight]; float menuBarHeight = [NSMenuView menuBarHeight];
@ -228,25 +230,28 @@
contentViewFrame.size.height -= menuBarHeight; contentViewFrame.size.height -= menuBarHeight;
} }
if ([tb isVisible]) if(hasToolbar)
{ {
GSToolbarView *tv = [tb _toolbarView]; if ([tb isVisible])
float newToolbarViewHeight; {
GSToolbarView *tv = [tb _toolbarView];
// If the width changed we may need to recalculate the height float newToolbarViewHeight;
if (contentViewFrame.size.width != [tv frame].size.width)
{ // If the width changed we may need to recalculate the height
[tv setFrameSize: NSMakeSize(contentViewFrame.size.width, 100)]; if (contentViewFrame.size.width != [tv frame].size.width)
// Will recalculate the layout {
[tv _reload]; [tv setFrameSize: NSMakeSize(contentViewFrame.size.width, 100)];
} // Will recalculate the layout
newToolbarViewHeight = [tv _heightFromLayout]; [tv _reload];
[tv setFrame: NSMakeRect( }
contentViewFrame.origin.x, newToolbarViewHeight = [tv _heightFromLayout];
NSMaxY(contentViewFrame) - newToolbarViewHeight, [tv setFrame: NSMakeRect(
contentViewFrame.size.width, contentViewFrame.origin.x,
newToolbarViewHeight)]; NSMaxY(contentViewFrame) - newToolbarViewHeight,
contentViewFrame.size.height -= newToolbarViewHeight; contentViewFrame.size.width,
newToolbarViewHeight)];
contentViewFrame.size.height -= newToolbarViewHeight;
}
} }
} }
@ -355,6 +360,7 @@
float newToolbarViewHeight; float newToolbarViewHeight;
float contentYOrigin; float contentYOrigin;
hasToolbar = YES;
[toolbarView setFrameSize: NSMakeSize(contentRect.size.width, 100)]; [toolbarView setFrameSize: NSMakeSize(contentRect.size.width, 100)];
// Will recalculate the layout // Will recalculate the layout
[toolbarView _reload]; [toolbarView _reload];
@ -362,9 +368,11 @@
// take in account of the menubar when calculating the origin // take in account of the menubar when calculating the origin
contentYOrigin = NSMaxY(contentRect); contentYOrigin = NSMaxY(contentRect);
if ([_window menu] != nil) if(hasMenu)
{
contentYOrigin -= [NSMenuView menuBarHeight]; contentYOrigin -= [NSMenuView menuBarHeight];
}
// Plug the toolbar view // Plug the toolbar view
[toolbarView setFrame: NSMakeRect( [toolbarView setFrame: NSMakeRect(
contentRect.origin.x, contentRect.origin.x,
@ -381,8 +389,9 @@
float toolbarViewHeight = [toolbarView frame].size.height; float toolbarViewHeight = [toolbarView frame].size.height;
// Unplug the toolbar view // Unplug the toolbar view
hasToolbar = NO;
[toolbarView removeFromSuperviewWithoutNeedingDisplay]; [toolbarView removeFromSuperviewWithoutNeedingDisplay];
[self changeWindowHeight: -toolbarViewHeight]; [self changeWindowHeight: -toolbarViewHeight];
} }
@ -413,6 +422,7 @@
{ {
float menubarHeight = [NSMenuView menuBarHeight]; float menubarHeight = [NSMenuView menuBarHeight];
hasMenu = YES;
// Plug the menu view // Plug the menu view
[menuView setFrame: NSMakeRect( [menuView setFrame: NSMakeRect(
contentRect.origin.x, contentRect.origin.x,
@ -428,42 +438,23 @@
{ {
NSEnumerator *e = [[self subviews] objectEnumerator]; NSEnumerator *e = [[self subviews] objectEnumerator];
NSView *v; NSView *v;
while ((v = [e nextObject]) != nil) while ((v = [e nextObject]) != nil)
{ {
if ([v isKindOfClass: [NSMenuView class]] == YES) if ([v isKindOfClass: [NSMenuView class]] == YES)
{ {
float menubarHeight = [NSMenuView menuBarHeight];
/* Unplug the menu view and return it so that it can be /* 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]; [RETAIN(v) removeFromSuperviewWithoutNeedingDisplay];
[self changeWindowHeight: -menubarHeight]; [self changeWindowHeight: -([NSMenuView menuBarHeight])];
return AUTORELEASE(v); 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; return nil;
} }