Correct the implementation of the method gState and moved code a bit to

avoid warning.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@24910 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Fred Kiefer 2007-03-20 23:47:27 +00:00
parent dfe4cd8073
commit a7a164262c
2 changed files with 74 additions and 64 deletions

View file

@ -1,3 +1,8 @@
2007-03-21 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSView.m (-gState): Generate a gstate if one is needed
and none has been set up to now.
2007-03-19 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSPrintOperation.m (NSView -_endSheet, NSView

View file

@ -1681,67 +1681,6 @@ static NSRect convert_rect_using_matrices(NSRect aRect, NSAffineTransform *matri
[self setFrame: newFrame];
}
/**
<p> Tell the view to maintain a private gstate object which
encapsulates all the information about drawing, such as coordinate
transforms, line widths, etc. If you do not invoke this method, a
gstate object is constructed each time the view is lockFocused.
Allocating a private gstate may improve the performance of views
that are focused a lot and have a lot of customized drawing
parameters. </p>
<p> View subclasses should override the
setUpGstate method to set these custom parameters.
</p>
*/
- (void) allocateGState
{
// FIXME: This should create an actual gState
_allocate_gstate = 1;
_renew_gstate = 1;
}
/**
Frees the gstate object, if there is one.
*/
- (void) releaseGState
{
if (_allocate_gstate && _gstate)
GSUndefineGState(GSCurrentContext(), _gstate);
_gstate = 0;
_allocate_gstate = 0;
}
/**
Returns an identifier that represents the view's gstate object,
which is used to encapsulate drawing information about the view.
Most of the time a gstate object is created from scratch when the
view is focused, so if the view is not currently focused or
allocateGState has not been called, then this method will return 0.
FIXME: The above is what the OpenStep and Cocoa specification say, but
gState is 0 unless allocateGState has been called.
*/
- (int) gState
{
return _gstate;
}
/**
Invalidates the view's gstate object so it will be set up again
using setUpGState the next time the view is focused. */
- (void) renewGState
{
_renew_gstate = 1;
/* Note that the next time we lock focus, we'll realloc a gstate (if
_allocate_gstate). This seems to make sense, and also allows us
to call this method each time we invalidate the coordinates */
}
/* Overridden by subclasses to setup custom gstate */
- (void) setUpGState
{
}
- (void) _lockFocusInContext: (NSGraphicsContext *)ctxt inRect: (NSRect)rect
{
NSRect wrect;
@ -1818,20 +1757,19 @@ static NSRect convert_rect_using_matrices(NSRect aRect, NSAffineTransform *matri
if (_renew_gstate)
{
[self setUpGState];
_renew_gstate = NO;
}
_renew_gstate = 0;
DPSgsave(ctxt);
}
else
{
DPSsetgstate(ctxt, window_gstate);
DPSgsave(ctxt);
[matrix concat];
/* Allow subclases to make other modifications */
[self setUpGState];
_renew_gstate = 0;
_renew_gstate = NO;
if (_allocate_gstate)
{
_gstate = GSDefineGState(ctxt);
@ -1915,6 +1853,73 @@ static NSRect convert_rect_using_matrices(NSRect aRect, NSAffineTransform *matri
[ctxt unlockFocusView: self needsFlush: YES ];
}
/**
<p> Tell the view to maintain a private gstate object which
encapsulates all the information about drawing, such as coordinate
transforms, line widths, etc. If you do not invoke this method, a
gstate object is constructed each time the view is lockFocused.
Allocating a private gstate may improve the performance of views
that are focused a lot and have a lot of customized drawing
parameters. </p>
<p> View subclasses should override the
setUpGstate method to set these custom parameters.
</p>
*/
- (void) allocateGState
{
_allocate_gstate = YES;
_renew_gstate = YES;
}
/**
Frees the gstate object, if there is one.
*/
- (void) releaseGState
{
if (_allocate_gstate && _gstate)
GSUndefineGState(GSCurrentContext(), _gstate);
_gstate = 0;
_allocate_gstate = NO;
}
/**
Returns an identifier that represents the view's gstate object,
which is used to encapsulate drawing information about the view.
Most of the time a gstate object is created from scratch when the
view is focused, so if the view is not currently focused or
allocateGState has not been called, then this method will return 0.
FIXME: The above is what the OpenStep and Cocoa specification say, but
gState is 0 unless allocateGState has been called.
*/
- (int) gState
{
if (_allocate_gstate && (!_gstate || _renew_gstate))
{
// Set the gstate by locking and unlocking focus.
[self lockFocus];
[self unlockFocusNeedsFlush: NO];
}
return _gstate;
}
/**
Invalidates the view's gstate object so it will be set up again
using setUpGState the next time the view is focused. */
- (void) renewGState
{
_renew_gstate = YES;
/* Note that the next time we lock focus, we'll realloc a gstate (if
_allocate_gstate). This seems to make sense, and also allows us
to call this method each time we invalidate the coordinates */
}
/* Overridden by subclasses to setup custom gstate */
- (void) setUpGState
{
}
- (void) lockFocusInRect: (NSRect)rect
{
[self _lockFocusInContext: nil inRect: rect];