mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-25 07:50:53 +00:00
* 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:
parent
47422f87d4
commit
2de8faf99a
3 changed files with 49 additions and 52 deletions
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue