From 1b117841945a9ed4241f317255f852e5366c20ea Mon Sep 17 00:00:00 2001 From: Fred Kiefer Date: Mon, 20 Oct 2008 13:28:28 +0000 Subject: [PATCH] Delegate the content rect computation to the actual window decoration view. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@26942 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 8 +++++++ Source/GSWindowDecorationView.h | 18 +++++++++++++--- Source/GSWindowDecorationView.m | 38 +++++++++++++++++---------------- Source/NSWindow.m | 16 +++++++------- 4 files changed, 51 insertions(+), 29 deletions(-) diff --git a/ChangeLog b/ChangeLog index 6f675d01d..23662286a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2008-10-20 Fred Kiefer + + * Source/GSWindowDecorationView.h, + * Source/GSWindowDecorationView.m + (-contentRectForFrameRect:styleMask:, + -frameRectForContentRect:styleMask): New instance methods. + * Source/NSWindow.m: Use these new methods. + 2008-10-19 Riccardo Mottola > * Source/GSServicesManager.m: dont unreigster non existent named port diff --git a/Source/GSWindowDecorationView.h b/Source/GSWindowDecorationView.h index a6b06ca63..95d4b0a95 100644 --- a/Source/GSWindowDecorationView.h +++ b/Source/GSWindowDecorationView.h @@ -32,16 +32,16 @@ @class NSWindow; +// These are implemented as class methods on GSWindowDecorationView @protocol GSWindowDecorator - (id) newWindowDecorationViewWithFrame: (NSRect)frame window: (NSWindow *)window; - - (NSRect) contentRectForFrameRect: (NSRect)aRect - styleMask: (unsigned int)aStyle; + styleMask: (unsigned int)aStyle; - (NSRect) frameRectForContentRect: (NSRect)aRect styleMask: (unsigned int)aStyle; - (float) minFrameWidthWithTitle: (NSString *)aTitle - styleMask: (unsigned int)aStyle; + styleMask: (unsigned int)aStyle; @end @@ -64,6 +64,11 @@ this, either directly, or indirectly (by using the backend). - (id) initWithFrame: (NSRect)frame window: (NSWindow *)w; +- (NSRect) contentRectForFrameRect: (NSRect)aRect + styleMask: (unsigned int)aStyle; +- (NSRect) frameRectForContentRect: (NSRect)aRect + styleMask: (unsigned int)aStyle; + - (void) setBackgroundColor: (NSColor *)color; - (void) setContentView: (NSView *)contentView; - (void) setDocumentEdited: (BOOL)flag; @@ -79,6 +84,13 @@ windowNumber will be 0. @end +/* Manage window decorations by using the backend functions. This only works + * on backends that can handle window decorations. + */ +@interface GSBackendWindowDecorationView : GSWindowDecorationView +@end + + /* Standard OPENSTEP-ish window decorations. */ diff --git a/Source/GSWindowDecorationView.m b/Source/GSWindowDecorationView.m index 89125babe..a3aefc1b0 100644 --- a/Source/GSWindowDecorationView.m +++ b/Source/GSWindowDecorationView.m @@ -33,20 +33,6 @@ #include "GNUstepGUI/GSDisplayServer.h" #include "GNUstepGUI/GSTheme.h" - -struct NSWindow_struct -{ - @defs(NSWindow) -}; - - -/* Manage window decorations by using the backend functions. This only works - * on backends that can handle window decorations. - */ -@interface GSBackendWindowDecorationView : GSWindowDecorationView -@end - - @implementation GSWindowDecorationView + (id) windowDecorator @@ -118,13 +104,29 @@ struct NSWindow_struct self = [super initWithFrame: frame]; if (self != nil) { - contentRect = [isa contentRectForFrameRect: frame - styleMask: [w styleMask]]; window = w; + contentRect = [self contentRectForFrameRect: frame + styleMask: [w styleMask]]; } return self; } +- (NSRect) contentRectForFrameRect: (NSRect)aRect + styleMask: (unsigned int)aStyle +{ + // TODO: Handle toolbar and others + return [isa contentRectForFrameRect: aRect + styleMask: aStyle]; +} + +- (NSRect) frameRectForContentRect: (NSRect)aRect + styleMask: (unsigned int)aStyle +{ + // TODO: Handle toolbar and others + return [isa frameRectForContentRect: aRect + styleMask: aStyle]; +} + #if 0 - (void) removeSubview: (NSView*)aView { @@ -179,8 +181,8 @@ struct NSWindow_struct _autoresizes_subviews = NO; [super setFrame: frameRect]; - contentRect = [isa contentRectForFrameRect: frameRect - styleMask: [window styleMask]]; + contentRect = [self contentRectForFrameRect: frameRect + styleMask: [window styleMask]]; // Safety Check. [cv setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable]; diff --git a/Source/NSWindow.m b/Source/NSWindow.m index 66d891d09..6a7118287 100644 --- a/Source/NSWindow.m +++ b/Source/NSWindow.m @@ -980,8 +980,6 @@ many times. @"can be created."); NSDebugLLog(@"NSWindow", @"NSWindow start of init\n"); - if (!windowDecorator) - windowDecorator = [GSWindowDecorationView windowDecorator]; // FIXME: This hack is here to work around a gorm decoding problem. if (_windowNum) @@ -1014,6 +1012,9 @@ many times. /* Create the window view */ cframe.origin = NSZeroPoint; cframe.size = _frame.size; + if (!windowDecorator) + windowDecorator = [GSWindowDecorationView windowDecorator]; + _wv = [windowDecorator newWindowDecorationViewWithFrame: cframe window: self]; [_wv _viewWillMoveToWindow: self]; @@ -1091,12 +1092,12 @@ many times. - (NSRect) contentRectForFrameRect: (NSRect)frameRect { - return [isa contentRectForFrameRect: frameRect styleMask: _styleMask]; + return [_wv contentRectForFrameRect: frameRect styleMask: _styleMask]; } - (NSRect) frameRectForContentRect: (NSRect)contentRect { - return [isa frameRectForContentRect: contentRect styleMask: _styleMask]; + return [_wv frameRectForContentRect: contentRect styleMask: _styleMask]; } /* @@ -1116,8 +1117,7 @@ many times. { aView = AUTORELEASE([[NSView alloc] initWithFrame: - [NSWindow contentRectForFrameRect: _frame - styleMask: _styleMask]]); + [self contentRectForFrameRect: _frame]]); } if (_contentView != nil) { @@ -1819,7 +1819,7 @@ many times. } [self setFrameTopLeftPoint: topLeftPoint]; - cRect = [isa contentRectForFrameRect: _frame styleMask: _styleMask]; + cRect = [self contentRectForFrameRect: _frame]; topLeftPoint.x = NSMinX(cRect); topLeftPoint.y = NSMaxY(cRect); @@ -2030,7 +2030,7 @@ many times. NSRect r = _frame; r.size = aSize; - r = [NSWindow frameRectForContentRect: r styleMask: _styleMask]; + r = [self frameRectForContentRect: r]; r.origin = _frame.origin; [self setFrame: r display: YES]; }