Rewrote all the toolbar methods. Implemented [zoom:]. Extracted

new method [_terminateBackendWindow] from [dealloc] and use it to
implement one shot windows in the orderOut case of
[orderWindow:relativeTo:]. Removed frame restriction from
[setFrameFromString:]  as this gets done in
[setFrame:display:]. Use [NSScreen visibleFrame] here and in
[stringWithSavedFrame]. Implemented [cascadeTopLeftFromPoint:].
Removed unused and empty methods [performHide:] and [performUnhide:].


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@15848 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
FredKiefer 2003-02-02 00:58:32 +00:00
parent 8ed0811f4f
commit 16126c9b4a

View file

@ -585,10 +585,26 @@ static NSNotificationCenter *nc = nil;
defer: NO]; defer: NO];
} }
- (void) _terminateBackendWindow
{
NSGraphicsContext *context = GSCurrentContext();
/* Check for context also as it might have disappeared before us */
if (context && _gstate)
{
GSUndefineGState(context, _gstate);
_gstate = 0;
}
if (_windowNum)
{
[GSServerForWindow(self) termwindow: _windowNum];
NSMapRemove(windowmaps, (void*)_windowNum);
}
}
- (void) dealloc - (void) dealloc
{ {
NSGraphicsContext *context = GSCurrentContext();
[nc removeObserver: self]; [nc removeObserver: self];
[[NSRunLoop currentRunLoop] [[NSRunLoop currentRunLoop]
cancelPerformSelector: @selector(_handleWindowNeedsDisplay:) cancelPerformSelector: @selector(_handleWindowNeedsDisplay:)
@ -629,6 +645,7 @@ static NSNotificationCenter *nc = nil;
TEST_RELEASE(_initialFirstResponder); TEST_RELEASE(_initialFirstResponder);
TEST_RELEASE(_defaultButtonCell); TEST_RELEASE(_defaultButtonCell);
TEST_RELEASE(_cachedImage); TEST_RELEASE(_cachedImage);
TEST_RELEASE(_toolbar);
RELEASE(_screen); RELEASE(_screen);
/* /*
@ -637,18 +654,8 @@ static NSNotificationCenter *nc = nil;
*/ */
[GSServerForWindow(self) removeDragTypes: nil fromWindow: self]; [GSServerForWindow(self) removeDragTypes: nil fromWindow: self];
/* Check for context also as it might have disappeared before us */ [self _terminateBackendWindow];
if (context && _gstate)
{
GSUndefineGState(context, _gstate);
}
if (_windowNum)
{
[GSServerForWindow(self) termwindow: _windowNum];
NSMapRemove(windowmaps, (void*)_windowNum);
}
if (_delegate != nil) if (_delegate != nil)
{ {
[nc removeObserver: _delegate name: nil object: self]; [nc removeObserver: _delegate name: nil object: self];
@ -682,13 +689,13 @@ static NSNotificationCenter *nc = nil;
screenNumber = [_screen screenNumber]; screenNumber = [_screen screenNumber];
_windowNum = [srv window: frame : _backingType : _styleMask : screenNumber]; _windowNum = [srv window: frame : _backingType : _styleMask : screenNumber];
[srv setwindowlevel: [self level] : _windowNum]; [srv setwindowlevel: [self level] : _windowNum];
NSMapInsert (windowmaps, (void*)_windowNum, self);
// Set window in new _gstate // Set window in new _gstate
DPSgsave(context); DPSgsave(context);
[srv windowdevice: _windowNum]; [srv windowdevice: _windowNum];
_gstate = GSDefineGState(context); _gstate = GSDefineGState(context);
DPSgrestore(context); DPSgrestore(context);
NSMapInsert (windowmaps, (void*)_windowNum, self);
frame = [NSWindow contentRectForFrameRect: frame styleMask: _styleMask]; frame = [NSWindow contentRectForFrameRect: frame styleMask: _styleMask];
if (NSIsEmptyRect([_wv frame])) if (NSIsEmptyRect([_wv frame]))
@ -974,6 +981,7 @@ static NSNotificationCenter *nc = nil;
- (void) setHasShadow: (BOOL)hasShadow - (void) setHasShadow: (BOOL)hasShadow
{ {
// FIXME: Should be send to backend
_f.has_shadow = hasShadow; _f.has_shadow = hasShadow;
} }
@ -984,6 +992,7 @@ static NSNotificationCenter *nc = nil;
- (void) setAlphaValue: (float)windowAlpha - (void) setAlphaValue: (float)windowAlpha
{ {
// FIXME
_alphaValue = windowAlpha; _alphaValue = windowAlpha;
} }
@ -994,6 +1003,7 @@ static NSNotificationCenter *nc = nil;
- (void) setOpaque: (BOOL)isOpaque - (void) setOpaque: (BOOL)isOpaque
{ {
// FIXME
_f.is_opaque = isOpaque; _f.is_opaque = isOpaque;
} }
@ -1414,6 +1424,10 @@ static NSNotificationCenter *nc = nil;
} }
_f.visible = YES; _f.visible = YES;
} }
else if ([self isOneShot])
{
[self _terminateBackendWindow];
}
} }
- (void) resignKeyWindow - (void) resignKeyWindow
@ -1486,8 +1500,12 @@ static NSNotificationCenter *nc = nil;
*/ */
- (NSPoint) cascadeTopLeftFromPoint: (NSPoint)topLeftPoint - (NSPoint) cascadeTopLeftFromPoint: (NSPoint)topLeftPoint
{ {
// FIXME: The implementation of this method is missing // FIXME: As we know nothing about the other window we can only guess
return NSZeroPoint; topLeftPoint.x += 20;
topLeftPoint.y += 20;
[self setFrameTopLeftPoint: topLeftPoint];
return topLeftPoint;
} }
- (BOOL) showsResizeIndicator - (BOOL) showsResizeIndicator
@ -2193,7 +2211,7 @@ resetCursorRectsForView(NSView *theView)
/** /**
Causes the window to deminiaturize. Normally you would not call this Causes the window to deminiaturize. Normally you would not call this
method directly. A window is automatically deminiaturized by the method directly. A window is automatically deminiaturized by the
user via a mouse cloick event. */ user via a mouse click event. */
- (void) deminiaturize: sender - (void) deminiaturize: sender
{ {
if (_counterpart != 0) if (_counterpart != 0)
@ -3590,40 +3608,23 @@ Code shared with [NSPanel -sendEvent:], remember to update both places.
sRect.size.height = value; sRect.size.height = value;
/* /*
* FIXME - the screen rectangle should give the area of the screen in which * The screen rectangle gives the area of the screen in which
* the window could be placed (ie a rectangle excluding the dock), but * the window could be placed (ie a rectangle excluding the dock).
* there is no API for that yet - so we just use the screen at present.
*/ */
nRect = [[self screen] frame]; nRect = [[self screen] visibleFrame];
/* /*
* FIXME - if the stored screen area is not the same as that currently * FIXME - if the stored screen area is not the same as that currently
* available, we should probably adjust the window frame (position) in * available, we should probably adjust the window frame (position) in
* some way to try to amke layout sensible. * some way to try to make layout sensible.
*/ */
if (NSEqualRects(nRect, sRect) == NO) if (NSEqualRects(nRect, sRect) == NO)
{ {
} }
/* /*
* Check and set frame. * Set frame.
*/ */
if (_maximumSize.width > 0 && fRect.size.width > _maximumSize.width)
{
fRect.size.width = _maximumSize.width;
}
if (_maximumSize.height > 0 && fRect.size.height > _maximumSize.height)
{
fRect.size.height = _maximumSize.height;
}
if (fRect.size.width < _minimumSize.width)
{
fRect.size.width = _minimumSize.width;
}
if (fRect.size.height < _minimumSize.height)
{
fRect.size.height = _minimumSize.height;
}
[self setFrame: fRect display: (_f.visible) ? YES : NO]; [self setFrame: fRect display: (_f.visible) ? YES : NO];
} }
@ -3659,11 +3660,10 @@ Code shared with [NSPanel -sendEvent:], remember to update both places.
fRect = _frame; fRect = _frame;
/* /*
* FIXME - the screen rectangle should give the area of the screen in which * The screen rectangle should gives the area of the screen in which
* the window could be placed (ie a rectangle excluding the dock), but * the window could be placed (ie a rectangle excluding the dock).
* there is no API for that yet - so we just use the screen at present.
*/ */
sRect = [[self screen] frame]; sRect = [[self screen] visibleFrame];
return [NSString stringWithFormat: @"%d %d %d %d %d %d % d %d ", return [NSString stringWithFormat: @"%d %d %d %d %d %d % d %d ",
(int)fRect.origin.x, (int)fRect.origin.y, (int)fRect.origin.x, (int)fRect.origin.y,
@ -3713,9 +3713,54 @@ Code shared with [NSPanel -sendEvent:], remember to update both places.
[self zoom: sender]; [self zoom: sender];
} }
#define DIST 3
- (void) zoom: (id)sender - (void) zoom: (id)sender
{ {
NSLog (@"[NSWindow zoom:] not implemented yet"); NSRect maxRect = [[self screen] visibleFrame];
if ([_delegate respondsToSelector: @selector(windowWillUseStandardFrame:defaultFrame:)])
{
maxRect = [_delegate windowWillUseStandardFrame: self defaultFrame: maxRect];
}
else if ([self respondsToSelector: @selector(windowWillUseStandardFrame:defaultFrame:)])
{
maxRect = [self windowWillUseStandardFrame: self defaultFrame: maxRect];
}
maxRect = [self constrainFrameRect: maxRect toScreen: [self screen]];
// Compare the new frame with the current one
if ((abs(NSMaxX(maxRect) - NSMaxX(_frame)) < DIST) &&
(abs(NSMaxY(maxRect) - NSMaxY(_frame)) < DIST) &&
(abs(NSMinX(maxRect) - NSMinX(_frame)) < DIST) &&
(abs(NSMinY(maxRect) - NSMinY(_frame)) < DIST))
{
// Already in zoomed mode, reset user frame, if stored
if (_autosaveName != nil)
{
[self setFrameUsingName: _autosaveName];
}
return;
}
if ([_delegate respondsToSelector: @selector(windowShouldZoom:toFrame:)])
{
if (![_delegate windowShouldZoom: self toFrame: maxRect])
return;
}
else if ([self respondsToSelector: @selector(windowShouldZoom:toFrame:)])
{
if (![self windowShouldZoom: self toFrame: maxRect])
return;
}
if (_autosaveName != nil)
{
[self saveFrameUsingName: _autosaveName];
}
[self setFrame: maxRect display: YES];
} }
@ -3925,8 +3970,7 @@ Code shared with [NSPanel -sendEvent:], remember to update both places.
- (void) setToolbar: (NSToolbar*)toolbar - (void) setToolbar: (NSToolbar*)toolbar
{ {
ASSIGN(_toolbar, toolbar); ASSIGN(_toolbar, toolbar);
[_wv addSubview: (NSView *)[toolbar _toolbarView]]; // FIXME The toolbar needs to know about the window!
[self setViewsNeedDisplay: YES];
} }
- (NSToolbar *) toolbar - (NSToolbar *) toolbar
@ -3936,16 +3980,12 @@ Code shared with [NSPanel -sendEvent:], remember to update both places.
- (void) toggleToolbarShown: (id)sender - (void) toggleToolbarShown: (id)sender
{ {
// TODO [_toolbar setVisible: [_toolbar isVisible]];
NSLog(@"Method %s is not implemented for class %s",
"toggleToolbarShown:", "NSWindow");
} }
- (void) runToolbarCustomizationPalette: (id)sender - (void) runToolbarCustomizationPalette: (id)sender
{ {
// TODO [_toolbar runCustomizationPalette: sender];
NSLog(@"Method %s is not implemented for class %s",
"runToolbarCustomizationPalette:", "NSWindow");
} }
- (NSWindow *) initWithWindowRef: (void *)windowRef - (NSWindow *) initWithWindowRef: (void *)windowRef
@ -3966,11 +4006,8 @@ Code shared with [NSPanel -sendEvent:], remember to update both places.
- (void *) windowHandle - (void *) windowHandle
{ {
// FIXME: Should only be defined on MS Windows // Should only be defined on MS Windows
// TODO return (void *)_windowNum;
NSLog(@"Method %s is not implemented for class %s",
"windowHandle", "NSWindow");
return (void *) 0;
} }
@end @end
@ -4015,16 +4052,6 @@ Code shared with [NSPanel -sendEvent:], remember to update both places.
[self deminiaturize: sender]; [self deminiaturize: sender];
} }
- (void) performHide: sender
{
// FIXME: Implementation is missing
}
- (void) performUnhide: sender
{
// FIXME: Implementation is missing
}
/* /*
* Allow subclasses to init without the backend * Allow subclasses to init without the backend
* class attempting to create an actual window * class attempting to create an actual window
@ -4051,7 +4078,7 @@ Code shared with [NSPanel -sendEvent:], remember to update both places.
_f.is_one_shot = NO; _f.is_one_shot = NO;
_f.is_autodisplay = YES; _f.is_autodisplay = YES;
_f.optimize_drawing = YES; _f.optimize_drawing = NO;
_f.dynamic_depth_limit = YES; _f.dynamic_depth_limit = YES;
_f.cursor_rects_enabled = NO; _f.cursor_rects_enabled = NO;
_f.visible = NO; _f.visible = NO;