* 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>
* 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 */
int windowNumber;
NSRect contentRect;
int inputState;
BOOL documentEdited;
BOOL hasMenu;
BOOL hasToolbar;
}
+ (id<GSWindowDecorator>) 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;

View file

@ -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.
@ -214,7 +216,7 @@
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 ([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;
// 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,8 +368,10 @@
// 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(
@ -381,6 +389,7 @@
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,
@ -433,37 +443,18 @@
{
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;
}