Make _frame in -gui the window frame always. Add methods for converting to/from screen frames.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@19855 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Alexander Malmberg 2004-08-09 12:59:53 +00:00
parent d52db5f427
commit 8a4361bbae
7 changed files with 124 additions and 19 deletions

View file

@ -1,3 +1,21 @@
2004-08-09 14:38 Alexander Malmberg <alexander@malmberg.org>
* Headers/AppKit/NSWindow.h: _frame is the window frame.
(+screenRectForFrameRect:styleMask:,
+frameRectForScreenRect:styleMask:): New methods.
* Source/GSDisplayServer.m (-window:::, -styleoffsets:::::):
Update documentation.
* Source/GSStandardWindowDecorationView.m
(+screenOffsets::::forStyleMask:): Implement new method.
* Source/GSWindowDecorationView.h (+screenRectForFrameRect:styleMask:,
+frameRectForScreenRect:styleMask:): New methods.
* Source/GSWindowDecorationView.m (+screenOffsets::::forStyleMask:,
+screenRectForFrameRect:styleMask:,
+frameRectForScreenRect:styleMask:): Implement them.
* Source/NSWindow.m (+screenRectForFrameRect:styleMask:,
+frameRectForScreenRect:styleMask:): Implement new methods.
(-_initBackendWindow): Always update _wv's frame.
2004-08-08 Quentin Mathe <qmathe@club-internet.fr> 2004-08-08 Quentin Mathe <qmathe@club-internet.fr>
* Source/NSComboBox.m: * Source/NSComboBox.m:

View file

@ -123,10 +123,12 @@ APPKIT_EXPORT NSSize NSTokenSize;
To get coordinate transforms and stuff right wrt. OpenStep, we really want To get coordinate transforms and stuff right wrt. OpenStep, we really want
the window frame here. However, for hysterical reasons, _frame is actually the window frame here.
the screen frame. (The other rectangles/sizes passed around in NSWindow
methods are likely a mix of screen and window frames.) Only if -gui manages For hysterical reasons, _frame used to be the screen frame. However, the
decorations will this match the semantics properly. 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; NSRect _frame;
@ -216,12 +218,22 @@ APPKIT_EXPORT NSSize NSTokenSize;
/* /*
* Computing frame and content rectangles * Computing frame and content rectangles
*/ */
/* These methods convert between the various frames discussed above. */
+ (NSRect) contentRectForFrameRect: (NSRect)aRect + (NSRect) contentRectForFrameRect: (NSRect)aRect
styleMask: (unsigned int)aStyle; styleMask: (unsigned int)aStyle;
+ (NSRect) frameRectForContentRect: (NSRect)aRect + (NSRect) frameRectForContentRect: (NSRect)aRect
styleMask: (unsigned int)aStyle; 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. */
+ (float) minFrameWidthWithTitle: (NSString *)aTitle + (float) minFrameWidthWithTitle: (NSString *)aTitle
styleMask: (unsigned int)aStyle; styleMask: (unsigned int)aStyle;

View file

@ -499,11 +499,13 @@ GSCurrentServer(void)
/** Creates a window whose location and size is described by frame and /** Creates a window whose location and size is described by frame and
whose backing store is described by type. This window is not whose backing store is described by type. This window is not
mapped to the screen by this call. Note that frame includes the title mapped to the screen by this call.
bar and all other window decorations. In many cases the window
manager controls these aspects of the window. The actual drawable Note that frame is the frame of the drawable window and does not include
area of the window may vary depending on the window manager involved. any external window decorations. If handlesWindowDecorations returns YES,
Use -styleoffsets::::: to determine the extent of the window decorations. a window manager (or something equivalent) might add decorations outside
the drawable window. Use -styleoffsets::::: to determine the extent of
those decorations.
*/ */
- (int) window: (NSRect)frame : (NSBackingStoreType)type : (unsigned int)style - (int) window: (NSRect)frame : (NSBackingStoreType)type : (unsigned int)style
{ {
@ -654,9 +656,12 @@ GSCurrentServer(void)
[self subclassResponsibility: _cmd]; [self subclassResponsibility: _cmd];
} }
/** Returns the dimensions of the window that are inside the window /** Returns the dimensions of window decorations added outside the drawable
frame but are controlled by the window manager. For instance, t window frame by a window manager or equivalent. For instance, t
gives the height of the title bar for the window */ gives the height of the title bar for the window. The values returned
may be approximations. If handlesWindowDecorations returns NO, there
are no decorations outside the drawable window frame and this method
shouldn't be called. */
- (void) styleoffsets: (float*) l : (float*) r : (float*) t : (float*) b - (void) styleoffsets: (float*) l : (float*) r : (float*) t : (float*) b
: (unsigned int) style : (unsigned int) style
{ {

View file

@ -64,6 +64,12 @@
} }
} }
+(void) screenOffsets: (float *)l : (float *)r : (float *)t : (float *)b
forStyleMask: (unsigned int)style
{
*l = *r = *r = *b = 0.0;
}
+ (float) minFrameWidthWithTitle: (NSString *)aTitle + (float) minFrameWidthWithTitle: (NSString *)aTitle
styleMask: (unsigned int)aStyle styleMask: (unsigned int)aStyle
{ {

View file

@ -39,6 +39,10 @@
styleMask: (unsigned int)aStyle; styleMask: (unsigned int)aStyle;
- (NSRect) frameRectForContentRect: (NSRect)aRect - (NSRect) frameRectForContentRect: (NSRect)aRect
styleMask: (unsigned int)aStyle; styleMask: (unsigned int)aStyle;
- (NSRect) screenRectForFrameRect: (NSRect)aRect
styleMask: (unsigned int)aStyle;
- (NSRect) frameRectForScreenRect: (NSRect)aRect
styleMask: (unsigned int)aStyle;
- (float) minFrameWidthWithTitle: (NSString *)aTitle - (float) minFrameWidthWithTitle: (NSString *)aTitle
styleMask: (unsigned int)aStyle; styleMask: (unsigned int)aStyle;
@end @end

View file

@ -74,6 +74,12 @@ GSWindowDecorationView implementation.
[self subclassResponsibility: _cmd]; [self subclassResponsibility: _cmd];
} }
+(void) screenOffsets: (float *)l : (float *)r : (float *)t : (float *)b
forStyleMask: (unsigned int)style
{
[self subclassResponsibility: _cmd];
}
+ (NSRect) contentRectForFrameRect: (NSRect)aRect + (NSRect) contentRectForFrameRect: (NSRect)aRect
styleMask: (unsigned int)aStyle styleMask: (unsigned int)aStyle
{ {
@ -102,6 +108,34 @@ GSWindowDecorationView implementation.
return aRect; 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 + (float) minFrameWidthWithTitle: (NSString *)aTitle
styleMask: (unsigned int)aStyle styleMask: (unsigned int)aStyle
{ {
@ -265,9 +299,16 @@ Returns the content rect for a given window frame.
+(void) offsets: (float *)l : (float *)r : (float *)t : (float *)b +(void) offsets: (float *)l : (float *)r : (float *)t : (float *)b
forStyleMask: (unsigned int)style forStyleMask: (unsigned int)style
{
*l = *r = *t = *b = 0.0;
}
+(void) screenOffsets: (float *)l : (float *)r : (float *)t : (float *)b
forStyleMask: (unsigned int)style
{ {
[GSCurrentServer() styleoffsets: l : r : t : b : style]; [GSCurrentServer() styleoffsets: l : r : t : b : style];
} }
+ (float) minFrameWidthWithTitle: (NSString *)aTitle + (float) minFrameWidthWithTitle: (NSString *)aTitle
styleMask: (unsigned int)aStyle styleMask: (unsigned int)aStyle
{ {

View file

@ -609,6 +609,26 @@ static NSNotificationCenter *nc = nil;
styleMask: aStyle]; 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 + (float) minFrameWidthWithTitle: (NSString *)aTitle
styleMask: (unsigned int)aStyle styleMask: (unsigned int)aStyle
{ {
@ -773,13 +793,12 @@ many times.
_gstate = GSDefineGState(context); _gstate = GSDefineGState(context);
DPSgrestore(context); DPSgrestore(context);
if (NSIsEmptyRect([_wv frame])) {
{ NSRect frame = _frame;
NSRect frame = _frame; frame.origin = NSZeroPoint;
frame.origin = NSZeroPoint; [_wv setFrame: frame];
[_wv setFrame: frame]; [_wv setNeedsDisplay: YES];
} }
[_wv setNeedsDisplay: YES];
/* Ok, now add the drag types back */ /* Ok, now add the drag types back */
if (dragTypes) if (dragTypes)