diff --git a/ChangeLog b/ChangeLog index 0fa420e7d..5339c70db 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2006-09-06 Richard Frith-Macdonald + + * Headers/AppKit/NSWindow.h: Add some documentation about what + frame management methods should do. Remove some bogus additional + methods for messing with frames. + * Source/NSWindow.m: ([cascadeTopLeftFromPoint:]) implement to match + MacOS-X specification. Remove unused additional frame methods. + * Source/GSWindowDecorationView.h: + * Source/GSWindowDecorationView.m: + * Source/GSStandardWindowDecorationView.m: + Remove unused/unnecessary methods and simplify. + NB. These fixups require corresponding fixups in the backend. + 2006-09-05 Richard Frith-Macdonald * Source/NSBitmapImageRep+JPEG.m: Fix declaration position causing diff --git a/Headers/AppKit/NSWindow.h b/Headers/AppKit/NSWindow.h index c2323e1c8..a1be2ad03 100644 --- a/Headers/AppKit/NSWindow.h +++ b/Headers/AppKit/NSWindow.h @@ -106,29 +106,21 @@ APPKIT_EXPORT NSSize NSTokenSize; /* A window really has three interesting frames: - The screen frame. This is the frame of the _entire_ window on the screen, + The window frame. This is the frame of the _entire_ window on the screen, including all decorations and borders (regardless of where they come from). - (On X, we can only guess what the screen frame is.) - The window frame. This is the frame of the backend window for this window, + The backend frame. This is the frame of the backend window for this window, and is thus the base of the coordinate system for the window. IOW, it's - the frame of the area we can draw into. + the frame of the area the gui library internals can draw into. - The contect rect. This is the frame of the content view. + The contect rect. This is the frame of the content view ... ie the frame + that an application using the GUI/AppKit API can draw into. - Wrt. size, ScreenFrame >= WindowFrame >= ContentRect. When -gui doesn't - manage the window decorations, WindowFrame == ContentRect. When -gui does - manage the window decorations, WindowFrame will include the decorations, - and ScreenFrame == WindowFrame. + Wrt. size, Frame >= BackendFrame >= ContentRect. When -gui doesn't + manage the window decorations, BackendFrame == ContentRect. When -gui does + manage the window decorations, BackendFrame will include the decorations, + and Frame == BackendFrame. - - To get coordinate transforms and stuff right wrt. OpenStep, we really want - the window frame here. - - For hysterical reasons, _frame used to be the screen frame. However, the - resulting inconsistencies caused a bunch of problems. Thus, _frame is the - window frame. The other rectangles/sizes passed around in NSWindow - methods are supposed to all be window frames. */ NSRect _frame; @@ -219,21 +211,27 @@ APPKIT_EXPORT NSSize NSTokenSize; * Computing frame and content rectangles */ -/* These methods convert between the various frames discussed above. */ +/** + * Returns the rectangle which would be used for the content view of + * a window whose on-screen size and position is specified by aRect + * and which is decorated with the border and title etc given by aStyle. + */ + (NSRect) contentRectForFrameRect: (NSRect)aRect styleMask: (unsigned int)aStyle; +/** + * Returns the rectangle which would be used for the on-screen frame of + * a window if that window had a content view occupying the rectangle aRect + * and was decorated with the border and title etc given by aStyle. + */ + (NSRect) frameRectForContentRect: (NSRect)aRect styleMask: (unsigned int)aStyle; -+ (NSRect) screenRectForFrameRect: (NSRect)aRect - styleMask: (unsigned int)aStyle; - -+ (NSRect) frameRectForScreenRect: (NSRect)aRect - styleMask: (unsigned int)aStyle; - -/* Returns the smallest window width that will fit the given title and -style. */ +/** + * Returns the smallest frame width that will fit the given title + * and style. This is the on-screen width of the window including + * decorations. + */ + (float) minFrameWidthWithTitle: (NSString *)aTitle styleMask: (unsigned int)aStyle; @@ -252,22 +250,66 @@ style. */ defer: (BOOL)flag screen: (NSScreen*)aScreen; -/* - * Converting coordinates +/** + * Converts aPoint from the base coordinate system of the receiver + * to a point in the screen coordinate system. */ - (NSPoint) convertBaseToScreen: (NSPoint)aPoint; + +/** + * Converts aPoint from the screen coordinate system to a point in + * the base coordinate system of the receiver. + */ - (NSPoint) convertScreenToBase: (NSPoint)aPoint; -/* - * Moving and resizing the window +/** + * Returns the frame of the receiver ... the rectangular area that the window + * (including any border, title, and other decorations) occupies on screen. */ - (NSRect) frame; + +/** + *

Sets the frame for the receiver to frameRect and if flag is YES causes + * the window contents to be refreshed. The value of frameRect is the + * desired on-screen size and position of the window including all + * border/decoration. + *

+ *

The size of the frame is constrained to the minimum and maximum + * sizes set for the receiver (if any).
+ * Its position is constrained to be on screen if it is a titled window. + *

+ */ - (void) setFrame: (NSRect)frameRect display: (BOOL)flag; + +/** + * Sets the origin (bottom left corner) of the receiver's frame to be the + * specified point (in screen coordinates). + */ - (void) setFrameOrigin: (NSPoint)aPoint; + +/** + * Sets the top left corner of the receiver's frame to be the + * specified point (in screen coordinates). + */ - (void) setFrameTopLeftPoint: (NSPoint)aPoint; + +/** + * Sets the size of the receiver's content view to aSize, implicitly + * adjusting the size of the receiver's frame to match. + */ - (void) setContentSize: (NSSize)aSize; + +/** + * Positions the receiver at topLeftPoint (or if topLeftPoint is NSZeroPoint, + * leaves the receiver unmoved except for any necessary constraint to fit + * on screen).
+ * Returns the position of the top left corner of the receivers content + * view (after repositioning), so that another window cascaded at the + * returned point will not obscure the title bar of the receiver. + */ - (NSPoint) cascadeTopLeftFromPoint: (NSPoint)topLeftPoint; + - (void) center; - (int) resizeFlags; #ifndef STRICT_OPENSTEP @@ -309,7 +351,7 @@ style. */ - (NSString*) stringWithSavedFrame; #ifndef STRICT_OPENSTEP - (BOOL) setFrameUsingName: (NSString *)name - force: (BOOL)force; + force: (BOOL)force; #endif /* @@ -556,7 +598,7 @@ style. */ - (void) print: (id)sender; - (NSData*) dataWithEPSInsideRect: (NSRect)rect; #ifndef STRICT_OPENSTEP -- (NSData *)dataWithPDFInsideRect:(NSRect)aRect; +- (NSData*) dataWithPDFInsideRect:(NSRect)aRect; #endif /* diff --git a/Source/GSStandardWindowDecorationView.m b/Source/GSStandardWindowDecorationView.m index 6d7205a6b..8800d9ea7 100644 --- a/Source/GSStandardWindowDecorationView.m +++ b/Source/GSStandardWindowDecorationView.m @@ -44,18 +44,22 @@ #define TITLE_HEIGHT 23.0 #define RESIZE_HEIGHT 9.0 -+(void) offsets: (float *)l : (float *)r : (float *)t : (float *)b - forStyleMask: (unsigned int)style ++ (void) offsets: (float *)l : (float *)r : (float *)t : (float *)b + forStyleMask: (unsigned int)style { if (style - & (NSTitledWindowMask | NSClosableWindowMask - | NSMiniaturizableWindowMask | NSResizableWindowMask)) - *l = *r = *t = *b = 1.0; + & (NSTitledWindowMask | NSClosableWindowMask + | NSMiniaturizableWindowMask | NSResizableWindowMask)) + { + *l = *r = *t = *b = 1.0; + } else - *l = *r = *t = *b = 0.0; + { + *l = *r = *t = *b = 0.0; + } if (style - & (NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask)) + & (NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask)) { *t = TITLE_HEIGHT; } @@ -65,24 +69,19 @@ } } -+(void) screenOffsets: (float *)l : (float *)r : (float *)t : (float *)b - forStyleMask: (unsigned int)style -{ - *l = *r = *r = *b = 0.0; -} - + (float) minFrameWidthWithTitle: (NSString *)aTitle styleMask: (unsigned int)aStyle { float l, r, t, b, width; - [self offsets: &l : &r : &t : &b - forStyleMask: aStyle]; + + [self offsets: &l : &r : &t : &b forStyleMask: aStyle]; width = l + r; if (aStyle & NSTitledWindowMask) - width += [aTitle sizeWithAttributes: nil].width; - + { + width += [aTitle sizeWithAttributes: nil].width; + } return width; } @@ -90,14 +89,17 @@ static NSDictionary *titleTextAttributes[3]; static NSColor *titleColor[3]; --(void) updateRects +- (void) updateRects { if (hasTitleBar) - titleBarRect = NSMakeRect(0.0, _frame.size.height - TITLE_HEIGHT, - _frame.size.width, TITLE_HEIGHT); + { + titleBarRect = NSMakeRect(0.0, _frame.size.height - TITLE_HEIGHT, + _frame.size.width, TITLE_HEIGHT); + } if (hasResizeBar) - resizeBarRect = NSMakeRect(0.0, 0.0, _frame.size.width, RESIZE_HEIGHT); - + { + resizeBarRect = NSMakeRect(0.0, 0.0, _frame.size.width, RESIZE_HEIGHT); + } if (hasCloseButton) { closeButtonRect = NSMakeRect( @@ -107,18 +109,18 @@ static NSColor *titleColor[3]; if (hasMiniaturizeButton) { - miniaturizeButtonRect = NSMakeRect(4, _frame.size.height - 15 - 4, - 15, 15); + miniaturizeButtonRect = NSMakeRect( + 4, _frame.size.height - 15 - 4, 15, 15); [miniaturizeButton setFrame: miniaturizeButtonRect]; } } -- initWithFrame: (NSRect)frame - window: (NSWindow *)w +- (id) initWithFrame: (NSRect)frame + window: (NSWindow *)w { if (!titleTextAttributes[0]) { - NSMutableParagraphStyle *p; + NSMutableParagraphStyle *p; p = [[NSParagraphStyle defaultParagraphStyle] mutableCopy]; [p setLineBreakMode: NSLineBreakByClipping]; @@ -129,12 +131,14 @@ static NSColor *titleColor[3]; [NSColor windowFrameTextColor], NSForegroundColorAttributeName, p, NSParagraphStyleAttributeName, nil]; + titleTextAttributes[1] = [[NSMutableDictionary alloc] initWithObjectsAndKeys: [NSFont titleBarFontOfSize: 0], NSFontAttributeName, [NSColor blackColor], NSForegroundColorAttributeName, /* TODO: need a named color for this */ p, NSParagraphStyleAttributeName, nil]; + titleTextAttributes[2] = [[NSMutableDictionary alloc] initWithObjectsAndKeys: [NSFont titleBarFontOfSize: 0], NSFontAttributeName, @@ -148,18 +152,18 @@ static NSColor *titleColor[3]; titleColor[2] = RETAIN([NSColor darkGrayColor]); } - self = [super initWithFrame: frame - window: w]; + self = [super initWithFrame: frame window: w]; if (!self) return nil; if ([w styleMask] - & (NSTitledWindowMask | NSClosableWindowMask - | NSMiniaturizableWindowMask)) + & (NSTitledWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask)) { hasTitleBar = YES; } if ([w styleMask] & NSTitledWindowMask) - isTitled = YES; + { + isTitled = YES; + } if ([w styleMask] & NSClosableWindowMask) { hasCloseButton = YES; @@ -200,17 +204,18 @@ static NSColor *titleColor[3]; RELEASE(miniaturizeButton); } if ([w styleMask] & NSResizableWindowMask) - hasResizeBar = YES; - + { + hasResizeBar = YES; + } [self updateRects]; return self; } --(void) drawTitleBar +- (void) drawTitleBar { -static const NSRectEdge edges[4] = {NSMinXEdge, NSMaxYEdge, + static const NSRectEdge edges[4] = {NSMinXEdge, NSMaxYEdge, NSMaxXEdge, NSMinYEdge}; float grays[3][4] = {{NSLightGray, NSLightGray, NSDarkGray, NSDarkGray}, @@ -271,7 +276,7 @@ static const NSRectEdge edges[4] = {NSMinXEdge, NSMaxYEdge, } } --(void) drawResizeBar +- (void) drawResizeBar { [[NSColor lightGrayColor] set]; PSrectfill(1.0, 1.0, resizeBarRect.size.width - 2.0, RESIZE_HEIGHT - 3.0); @@ -313,7 +318,7 @@ static const NSRectEdge edges[4] = {NSMinXEdge, NSMaxYEdge, PSstroke(); } --(void) drawRect: (NSRect)rect +- (void) drawRect: (NSRect)rect { if (hasTitleBar && NSIntersectsRect(rect, titleBarRect)) { @@ -359,14 +364,14 @@ static const NSRectEdge edges[4] = {NSMinXEdge, NSMaxYEdge, } --(void) setTitle: (NSString *)newTitle +- (void) setTitle: (NSString *)newTitle { if (isTitled) [self setNeedsDisplayInRect: titleBarRect]; [super setTitle: newTitle]; } --(void) setInputState: (int)state +- (void) setInputState: (int)state { NSAssert(state >= 0 && state <= 2, @"Invalid state!"); [super setInputState: state]; @@ -374,7 +379,7 @@ static const NSRectEdge edges[4] = {NSMinXEdge, NSMaxYEdge, [self setNeedsDisplayInRect: titleBarRect]; } --(void) setDocumentEdited: (BOOL)flag +- (void) setDocumentEdited: (BOOL)flag { if (flag) { @@ -392,14 +397,14 @@ static const NSRectEdge edges[4] = {NSMinXEdge, NSMaxYEdge, } --(NSPoint) mouseLocationOnScreenOutsideOfEventStream +- (NSPoint) mouseLocationOnScreenOutsideOfEventStream { int screen = [[window screen] screenNumber]; return [GSServerForWindow(window) mouseLocationOnScreen: screen window: NULL]; } --(void) moveWindowStartingWithEvent: (NSEvent *)event +- (void) moveWindowStartingWithEvent: (NSEvent *)event { unsigned int mask = NSLeftMouseDraggedMask | NSLeftMouseUpMask; NSEvent *currentEvent = event; @@ -436,8 +441,9 @@ static const NSRectEdge edges[4] = {NSMinXEdge, NSMaxYEdge, } -static NSRect calc_new_frame(NSRect frame, NSPoint point, NSPoint firstPoint, - int mode, NSSize minSize, NSSize maxSize) +static NSRect +calc_new_frame(NSRect frame, NSPoint point, NSPoint firstPoint, + int mode, NSSize minSize, NSSize maxSize) { NSRect newFrame = frame; newFrame.origin.y = point.y - firstPoint.y; @@ -473,7 +479,7 @@ static NSRect calc_new_frame(NSRect frame, NSPoint point, NSPoint firstPoint, return newFrame; } --(void) resizeWindowStartingWithEvent: (NSEvent *)event +- (void) resizeWindowStartingWithEvent: (NSEvent *)event { unsigned int mask = NSLeftMouseDraggedMask | NSLeftMouseUpMask; NSEvent *currentEvent = event; @@ -517,7 +523,8 @@ static NSRect calc_new_frame(NSRect frame, NSPoint point, NSPoint firstPoint, } point = [self mouseLocationOnScreenOutsideOfEventStream]; - newFrame = calc_new_frame(frame, point, firstPoint, mode, minSize, maxSize); + newFrame + = calc_new_frame(frame, point, firstPoint, mode, minSize, maxSize); if (currentEvent && [currentEvent type] == NSLeftMouseUp) break; @@ -532,12 +539,12 @@ static NSRect calc_new_frame(NSRect frame, NSPoint point, NSPoint firstPoint, [window setFrame: newFrame display: YES]; } --(BOOL) acceptsFirstMouse: (NSEvent*)theEvent +- (BOOL) acceptsFirstMouse: (NSEvent*)theEvent { return YES; } --(void) mouseDown: (NSEvent *)event +- (void) mouseDown: (NSEvent *)event { NSPoint p = [self convertPoint: [event locationInWindow] fromView: nil]; diff --git a/Source/GSWindowDecorationView.h b/Source/GSWindowDecorationView.h index a27c51e8f..d0ff45955 100644 --- a/Source/GSWindowDecorationView.h +++ b/Source/GSWindowDecorationView.h @@ -39,10 +39,6 @@ styleMask: (unsigned int)aStyle; - (NSRect) frameRectForContentRect: (NSRect)aRect styleMask: (unsigned int)aStyle; -- (NSRect) screenRectForFrameRect: (NSRect)aRect - styleMask: (unsigned int)aStyle; -- (NSRect) frameRectForScreenRect: (NSRect)aRect - styleMask: (unsigned int)aStyle; - (float) minFrameWidthWithTitle: (NSString *)aTitle styleMask: (unsigned int)aStyle; @end @@ -63,23 +59,22 @@ this, either directly, or indirectly (by using the backend). int inputState; BOOL documentEdited; } -+(id) windowDecorator; ++ (id) windowDecorator; -- initWithFrame: (NSRect)frame - window: (NSWindow *)w; +- (id) initWithFrame: (NSRect)frame window: (NSWindow *)w; --(void) setContentView: (NSView *)contentView; +- (void) setBackgroundColor: (NSColor *)color; +- (void) setContentView: (NSView *)contentView; +- (void) setDocumentEdited: (BOOL)flag; +- (void) setInputState: (int)state; +- (void) setTitle: (NSString *)title; /* Called when the backend window is created or destroyed. When it's destroyed, windowNumber will be 0. */ --(void) setWindowNumber: (int)windowNumber; +- (void) setWindowNumber: (int)windowNumber; --(void) setTitle: (NSString *)title; --(void) setInputState: (int)state; --(void) setDocumentEdited: (BOOL)flag; --(void) setBackgroundColor: (NSColor *)color; @end diff --git a/Source/GSWindowDecorationView.m b/Source/GSWindowDecorationView.m index 55d12f37b..eedd970f7 100644 --- a/Source/GSWindowDecorationView.m +++ b/Source/GSWindowDecorationView.m @@ -38,20 +38,16 @@ struct NSWindow_struct }; -/* -Manage window decorations by using the backend functions. This only works -on backends that can handle window decorations. -*/ +/* Manage window decorations by using the backend functions. This only works + * on backends that can handle window decorations. + */ @interface GSBackendWindowDecorationView : GSWindowDecorationView @end -/* -GSWindowDecorationView implementation. -*/ @implementation GSWindowDecorationView -+(id) windowDecorator ++ (id) windowDecorator { if ([GSCurrentServer() handlesWindowDecorations]) return [GSBackendWindowDecorationView self]; @@ -60,22 +56,16 @@ GSWindowDecorationView implementation. } -+(id) newWindowDecorationViewWithFrame: (NSRect)frame - window: (NSWindow *)aWindow ++ (id) newWindowDecorationViewWithFrame: (NSRect)frame + window: (NSWindow *)aWindow { return [[self alloc] initWithFrame: frame window: aWindow]; } -+(void) offsets: (float *)l : (float *)r : (float *)t : (float *)b - forStyleMask: (unsigned int)style -{ - [self subclassResponsibility: _cmd]; -} - -+(void) screenOffsets: (float *)l : (float *)r : (float *)t : (float *)b - forStyleMask: (unsigned int)style ++ (void) offsets: (float *)l : (float *)r : (float *)t : (float *)b + forStyleMask: (unsigned int)style { [self subclassResponsibility: _cmd]; } @@ -85,8 +75,7 @@ GSWindowDecorationView implementation. { float t, b, l, r; - [self offsets: &l : &r : &t : &b - forStyleMask: aStyle]; + [self offsets: &l : &r : &t : &b forStyleMask: aStyle]; aRect.size.width -= l + r; aRect.size.height -= t + b; aRect.origin.x += l; @@ -99,8 +88,7 @@ GSWindowDecorationView implementation. { float t, b, l, r; - [self offsets: &l : &r : &t : &b - forStyleMask: aStyle]; + [self offsets: &l : &r : &t : &b forStyleMask: aStyle]; aRect.size.width += l + r; aRect.size.height += t + b; aRect.origin.x -= l; @@ -108,34 +96,6 @@ GSWindowDecorationView implementation. return aRect; } -+ (NSRect) screenRectForFrameRect: (NSRect)aRect - styleMask: (unsigned int)aStyle -{ - float t, b, l, r; - - [self screenOffsets: &l : &r : &t : &b - forStyleMask: aStyle]; - aRect.size.width += l + r; - aRect.size.height += t + b; - aRect.origin.x -= l; - aRect.origin.y -= b; - return aRect; -} - -+ (NSRect) frameRectForScreenRect: (NSRect)aRect - styleMask: (unsigned int)aStyle -{ - float t, b, l, r; - - [self screenOffsets: &l : &r : &t : &b - forStyleMask: aStyle]; - aRect.size.width -= l + r; - aRect.size.height -= t + b; - aRect.origin.x += l; - aRect.origin.y += b; - return aRect; -} - + (float) minFrameWidthWithTitle: (NSString *)aTitle styleMask: (unsigned int)aStyle { @@ -144,73 +104,46 @@ GSWindowDecorationView implementation. } -/* -Internal helpers. - -Returns the internal window frame rect for a given (screen) frame. -*/ -+(NSRect) windowFrameRectForFrameRect: (NSRect)aRect ++ (NSRect) decorationRectForFrameRect: (NSRect)aRect styleMask: (unsigned int)aStyle { aRect.origin = NSZeroPoint; return aRect; } -/* -Returns the content rect for a given window frame. -*/ -+(NSRect) contentRectForWindowFrameRect: (NSRect)aRect ++ (NSRect) contentRectForDecorationRect: (NSRect)aRect styleMask: (unsigned int)aStyle { return [self contentRectForFrameRect: aRect styleMask: aStyle]; } -- initWithFrame: (NSRect)frame +- (id) initWithFrame: (NSRect)frame { NSAssert(NO, @"Tried to create GSWindowDecorationView without a window!"); return nil; } -- initWithFrame: (NSRect)frame - window: (NSWindow *)w +- (id) initWithFrame: (NSRect)frame + window: (NSWindow *)w { - frame = [isa windowFrameRectForFrameRect: frame - styleMask: [w styleMask]]; + unsigned int styleMask = [w styleMask]; + frame = [isa decorationRectForFrameRect: frame + styleMask: styleMask]; self = [super initWithFrame: frame]; - if (!self) - return nil; - - window = w; - contentRect = frame; - contentRect = - [isa contentRectForWindowFrameRect: contentRect - styleMask: [window styleMask]]; - + if (self != nil) + { + contentRect = [isa contentRectForDecorationRect: frame + styleMask: styleMask]; + window = w; + } return self; } -/* - * Special setFrame: implementation - a minimal autoresize mechanism - */ -- (void) setFrame: (NSRect)frameRect +- (void) setBackgroundColor: (NSColor *)color { - NSSize oldSize = _frame.size; - NSView *cv = [_window contentView]; - - frameRect = [isa windowFrameRectForFrameRect: frameRect - styleMask: [window styleMask]]; - - _autoresizes_subviews = NO; - [super setFrame: frameRect]; - - contentRect = [isa contentRectForWindowFrameRect: frameRect - styleMask: [window styleMask]]; - - // Safety Check. - [cv setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable]; - [cv resizeWithOldSuperviewSize: oldSize]; + [self setNeedsDisplayInRect: contentRect]; } - (void) setContentView: (NSView *)contentView @@ -228,7 +161,49 @@ Returns the content rect for a given window frame. contentRect.origin.y)]; } --(void) setWindowNumber: (int)theWindowNumber +- (void) setDocumentEdited: (BOOL)flag +{ + documentEdited = flag; + if (windowNumber) + [GSServerForWindow(window) docedited: documentEdited : windowNumber]; +} + +/* + * Special setFrame: implementation - a minimal autoresize mechanism + */ +- (void) setFrame: (NSRect)frameRect +{ + NSSize oldSize = _frame.size; + NSView *cv = [_window contentView]; + + frameRect = [isa decorationRectForFrameRect: frameRect + styleMask: [window styleMask]]; + + _autoresizes_subviews = NO; + [super setFrame: frameRect]; + + contentRect = [isa contentRectForDecorationRect: frameRect + styleMask: [window styleMask]]; + + // Safety Check. + [cv setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable]; + [cv resizeWithOldSuperviewSize: oldSize]; +} + +- (void) setInputState: (int)state +{ + inputState = state; + if (windowNumber) + [GSServerForWindow(window) setinputstate: inputState : windowNumber]; +} + +- (void) setTitle: (NSString *)title +{ + if (windowNumber) + [GSServerForWindow(window) titlewindow: title : windowNumber]; +} + +- (void) setWindowNumber: (int)theWindowNumber { windowNumber = theWindowNumber; if (!windowNumber) @@ -239,29 +214,6 @@ Returns the content rect for a given window frame. [GSServerForWindow(window) docedited: documentEdited : windowNumber]; } --(void) setTitle: (NSString *)title -{ - if (windowNumber) - [GSServerForWindow(window) titlewindow: title : windowNumber]; -} --(void) setInputState: (int)state -{ - inputState = state; - if (windowNumber) - [GSServerForWindow(window) setinputstate: inputState : windowNumber]; -} --(void) setDocumentEdited: (BOOL)flag -{ - documentEdited = flag; - if (windowNumber) - [GSServerForWindow(window) docedited: documentEdited : windowNumber]; -} - --(void) setBackgroundColor: (NSColor *)color -{ - [self setNeedsDisplayInRect: contentRect]; -} - - (BOOL) isOpaque { @@ -279,14 +231,13 @@ Returns the content rect for a given window frame. } } - - -- initWithCoder: (NSCoder*)aCoder +- (id) initWithCoder: (NSCoder*)aCoder { NSAssert(NO, @"The top-level window view should never be encoded."); return nil; } --(void) encodeWithCoder: (NSCoder*)aCoder + +- (void) encodeWithCoder: (NSCoder*)aCoder { NSAssert(NO, @"The top-level window view should never be encoded."); } @@ -297,14 +248,8 @@ Returns the content rect for a given window frame. @implementation GSBackendWindowDecorationView -+(void) offsets: (float *)l : (float *)r : (float *)t : (float *)b - forStyleMask: (unsigned int)style -{ - *l = *r = *t = *b = 0.0; -} - -+(void) screenOffsets: (float *)l : (float *)r : (float *)t : (float *)b - forStyleMask: (unsigned int)style ++ (void) offsets: (float *)l : (float *)r : (float *)t : (float *)b + forStyleMask: (unsigned int)style { [GSCurrentServer() styleoffsets: l : r : t : b : style]; } @@ -316,21 +261,19 @@ Returns the content rect for a given window frame. return 0.0; } -+(NSRect) windowFrameRectForFrameRect: (NSRect)aRect ++ (NSRect) decorationRectForFrameRect: (NSRect)aRect styleMask: (unsigned int)aStyle { float l, r, t, b; + [self offsets: &l : &r : &t : &b forStyleMask: aStyle]; aRect.size.width -= l + r; aRect.size.height -= t + b; return aRect; } -/* -Returns the content rect for a given window frame. -*/ -+(NSRect) contentRectForWindowFrameRect: (NSRect)aRect - styleMask: (unsigned int)aStyle ++ (NSRect) contentRectForDecorationRect: (NSRect)aRect + styleMask: (unsigned int)aStyle { return aRect; } diff --git a/Source/NSScreen.m b/Source/NSScreen.m index 4497642b6..0791b494f 100644 --- a/Source/NSScreen.m +++ b/Source/NSScreen.m @@ -307,7 +307,12 @@ static NSMutableArray *screenArray = nil; switch (NSInterfaceStyleForKey(@"NSMenuInterfaceStyle", nil)) { case NSMacintoshInterfaceStyle: - if ([NSApp mainMenu] != nil) + if ([NSApp mainMenu] == nil) + { + // No menu yet ... assume a standard height + visFrame.size.height -= 23.0; + } + else { float menuHeight = [[[NSApp mainMenu] window] frame].size.height; diff --git a/Source/NSWindow.m b/Source/NSWindow.m index 52f1ab332..57ef1c25e 100644 --- a/Source/NSWindow.m +++ b/Source/NSWindow.m @@ -616,26 +616,6 @@ static NSNotificationCenter *nc = nil; styleMask: aStyle]; } -+ (NSRect) screenRectForFrameRect: (NSRect)aRect - styleMask: (unsigned int)aStyle -{ - if (!windowDecorator) - windowDecorator = [GSWindowDecorationView windowDecorator]; - - return [windowDecorator screenRectForFrameRect: aRect - styleMask: aStyle]; -} - -+ (NSRect) frameRectForScreenRect: (NSRect)aRect - styleMask: (unsigned int)aStyle -{ - if (!windowDecorator) - windowDecorator = [GSWindowDecorationView windowDecorator]; - - return [windowDecorator frameRectForScreenRect: aRect - styleMask: aStyle]; -} - + (float) minFrameWidthWithTitle: (NSString *)aTitle styleMask: (unsigned int)aStyle { @@ -1706,16 +1686,20 @@ many times. } } -/* - * Moving and resizing the window - */ - (NSPoint) cascadeTopLeftFromPoint: (NSPoint)topLeftPoint { - // FIXME: As we know nothing about the other window we can only guess - topLeftPoint.x += 20; - topLeftPoint.y += 20; + NSRect cRect; + if (NSEqualPoints(topLeftPoint, NSZeroPoint) == YES) + { + topLeftPoint.x = _frame.origin.x; + topLeftPoint.y = _frame.origin.y + _frame.size.height; + } [self setFrameTopLeftPoint: topLeftPoint]; + cRect = [isa contentRectForFrameRect: _frame styleMask: _styleMask]; + topLeftPoint.x = cRect.origin.x; + topLeftPoint.y = cRect.origin.y + cRect.size.height; + return topLeftPoint; } @@ -4061,7 +4045,7 @@ resetCursorRectsForView(NSView *theView) [_wv convertRect: rect fromView: nil]]; } -- (NSData *)dataWithPDFInsideRect:(NSRect)aRect +- (NSData *) dataWithPDFInsideRect:(NSRect)aRect { return [_wv dataWithPDFInsideRect: [_wv convertRect: aRect fromView: nil]];