Tweak new theme method and fix up indentation errors.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@23909 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
rfm 2006-10-19 06:06:00 +00:00
parent a72332d295
commit ec6668f3b3
4 changed files with 141 additions and 79 deletions

View file

@ -1,3 +1,10 @@
2006-10-19 Richard Frith-Macdonald <rfm@gnu.org>
* Headers/Additions/GNUstepGUI/GSTheme.h:
* Source/GSTheme.m:
Have tile filling method return rect of central tile area.
* Source/NSView.m: Fixup indentation problems.
2006-10-19 01:45-EDT Gregory John Casamento <greg_casamento@yahoo.com>
* Source/NSView.m: Applied patch from Banlu Kemiyatorn. Corrects

View file

@ -430,7 +430,12 @@ APPKIT_EXPORT NSString *GSThemeDidDeactivateNotification;
*/
@interface GSTheme (LowLevelDrawing)
/**
* Method to tile the supplied image to fill the horizontal rectangle.
* Method to tile the supplied image to fill the horizontal rectangle.<br />
* The rect argument is the rectangle to be filled.<br />
* The image argument is the data to fill with.<br />
* The source argument is the rectangle within the image which is used.<br />
* The flipped argument specifies what sort of coordinate system is in
* use in the view where we are drawing.
*/
- (void) fillHorizontalRect: (NSRect)rect
withImage: (NSImage*)image
@ -449,20 +454,29 @@ withRepeatedImage: (NSImage*)image
center: (BOOL)center;
/**
* Method to tile a rectangle given an array of nine tile images.<br />
* Method to tile a rectangle given a group of up to nine tile images.<br />
* The GSDrawTiles object encapsulates the tile images and information
* about what parts of each image are used for tiling.<br />
* This draws the left, right, top and bottom borders by tiling the
* images at TileCL, TileCR, TileTM and TileBM respectively. It then
* draws the four corner images and finally deals with the remaining
* space in the middle according to the specified style.<br />
* The background color specified is used where style is FillStyleNone.
* images at left, right, top and bottom. It then draws the four corner
* images and finally deals with the remaining space in the middle according
* to the specified style.<br />
* The background color specified is used to fill the center where
* style is FillStyleNone.<br />
* The return value is the central rectangle (inside the border images).
*/
- (void) fillRect: (NSRect)rect
withTiles: (GSDrawTiles*)tiles
background: (NSColor*)color
fillStyle: (GSThemeFillStyle)style;
- (NSRect) fillRect: (NSRect)rect
withTiles: (GSDrawTiles*)tiles
background: (NSColor*)color
fillStyle: (GSThemeFillStyle)style;
/**
* Method to tile the supplied image to fill the vertical rectangle.
* Method to tile the supplied image to fill the vertical rectangle.<br />
* The rect argument is the rectangle to be filled.<br />
* The image argument is the data to fill with.<br />
* The source argument is the rectangle within the image which is used.<br />
* The flipped argument specifies what sort of coordinate system is in
* use in the view where we are drawing.
*/
- (void) fillVerticalRect: (NSRect)rect
withImage: (NSImage*)image

View file

@ -1050,10 +1050,10 @@ withRepeatedImage: (NSImage*)image
DPSgrestore (ctxt);
}
- (void) fillRect: (NSRect)rect
withTiles: (GSDrawTiles*)tiles
background: (NSColor*)color
fillStyle: (GSThemeFillStyle)style
- (NSRwect) fillRect: (NSRect)rect
withTiles: (GSDrawTiles*)tiles
background: (NSColor*)color
fillStyle: (GSThemeFillStyle)style
{
NSGraphicsContext *ctxt = GSCurrentContext();
NSSize tls = tiles->rects[TileTL].size;
@ -1085,6 +1085,7 @@ withRepeatedImage: (NSImage*)image
float space = 3.0;
float scale;
inFill = NSZeroRect;
if (tiles->images[TileTM] == nil)
{
grid.size.width = (tiles->rects[TileTL].size.width
@ -1289,16 +1290,22 @@ withRepeatedImage: (NSImage*)image
fromRect: tiles->rects[TileBR]
operation: NSCompositeSourceOver];
inFill = NSMakeRect (rect.origin.x +cls.width,
inFill = NSMakeRect (rect.origin.x + cls.width,
rect.origin.y + bms.height,
rect.size.width - cls.width - crs.width,
rect.size.height - bms.height - tms.height);
if (style == GSThemeFillStyleCenter)
{
[self fillRect: inFill
withRepeatedImage: tiles->images[TileCM]
fromRect: tiles->rects[TileCM]
center: NO];
NSRect r = tiles->rects[TileCM];
r.origin.x
= inFill.origin.x + (inFill.size.width - r.size.width) / 2;
r.origin.y
= inFill.origin.y + (inFill.size.height - r.size.height) / 2;
r.origin.y += r.size.height; // Allow for flip of image rectangle
[tiles->images[TileCM] compositeToPoint: r.origin
fromRect: tiles->rects[TileCM]
operation: NSCompositeSourceOver];
}
else if (style == GSThemeFillStyleRepeat)
{
@ -1309,11 +1316,27 @@ withRepeatedImage: (NSImage*)image
}
else if (style == GSThemeFillStyleScale)
{
[tiles->images[TileCM] setScalesWhenResized: YES];
[tiles->images[TileCM] setSize: inFill.size];
[tiles->images[TileCM] compositeToPoint: inFill.origin
fromRect: tiles->rects[TileCM]
operation: NSCompositeSourceOver];
NSImage *im = [tiles->images[TileCM] copy];
NSRect r = tiles->rects[TileCM];
NSSize s = [tiles->images[TileCM] size];
NSPoint p = inFill.origin;
float sx = inFill.size.width / r.size.width;
float sy = inFill.size.height / r.size.height;
r.size.width = inFill.size.width;
r.size.height = inFill.size.height;
r.origin.x *= sx;
r.origin.y *= sy;
s.width *= sx;
s.height *= sy;
p.y += inFill.size.height; // In flipped view
[im setScalesWhenResized: YES];
[im setSize: s];
[im compositeToPoint: p
fromRect: r
operation: NSCompositeSourceOver];
RELEASE(im);
}
}
else
@ -1387,10 +1410,15 @@ withRepeatedImage: (NSImage*)image
if (style == GSThemeFillStyleCenter)
{
[self fillRect: inFill
withRepeatedImage: tiles->images[TileCM]
fromRect: tiles->rects[TileCM]
center: NO];
NSRect r = tiles->rects[TileCM];
r.origin.x
= inFill.origin.x + (inFill.size.width - r.size.width) / 2;
r.origin.y
= inFill.origin.y + (inFill.size.height - r.size.height) / 2;
[tiles->images[TileCM] compositeToPoint: r.origin
fromRect: tiles->rects[TileCM]
operation: NSCompositeSourceOver];
}
else if (style == GSThemeFillStyleRepeat)
{
@ -1402,15 +1430,29 @@ withRepeatedImage: (NSImage*)image
else if (style == GSThemeFillStyleScale)
{
NSImage *im = [tiles->images[TileCM] copy];
NSRect r = tiles->rects[TileCM];
NSSize s = [tiles->images[TileCM] size];
NSPoint p = inFill.origin;
float sx = inFill.size.width / r.size.width;
float sy = inFill.size.height / r.size.height;
r.size.width = inFill.size.width;
r.size.height = inFill.size.height;
r.origin.x *= sx;
r.origin.y *= sy;
s.width *= sx;
s.height *= sy;
[im setScalesWhenResized: YES];
[im setSize: inFill.size];
[im compositeToPoint: inFill.origin
fromRect: tiles->rects[TileCM]
[im setSize: s];
[im compositeToPoint: p
fromRect: r
operation: NSCompositeSourceOver];
RELEASE(im);
}
}
return inFill;
}
- (void) fillVerticalRect: (NSRect)rect

View file

@ -302,8 +302,8 @@ GSSetDragTypes(NSView* obj, NSArray *types)
}
else
{
NSRect superviewsVisibleRect;
BOOL wasFlipped = _super_view->_rFlags.flipped_view;
NSRect superviewsVisibleRect;
BOOL wasFlipped = _super_view->_rFlags.flipped_view;
NSAffineTransform *pMatrix = [_super_view _matrixToWindow];
NSAffineTransform *tMatrix = nil;
@ -312,17 +312,15 @@ GSSetDragTypes(NSView* obj, NSArray *types)
/* prepend translation */
tMatrix = _matrixToWindow;
tMatrix->matrix.tX = NSMinX(_frame) * tMatrix->matrix.m11 +
NSMinY(_frame) * tMatrix->matrix.m21 +
tMatrix->matrix.tX;
NSMinY(_frame) * tMatrix->matrix.m21 + tMatrix->matrix.tX;
tMatrix->matrix.tY = NSMinX(_frame) * tMatrix->matrix.m12 +
NSMinY(_frame) * tMatrix->matrix.m22 +
tMatrix->matrix.tY;
NSMinY(_frame) * tMatrix->matrix.m22 + tMatrix->matrix.tY;
/* prepend rotation */
if (_frameMatrix != nil)
{
(*preImp)(_matrixToWindow, preSel, _frameMatrix);
}
{
(*preImp)(_matrixToWindow, preSel, _frameMatrix);
}
if (_rFlags.flipped_view != wasFlipped)
{
@ -1144,9 +1142,9 @@ GSSetDragTypes(NSView* obj, NSArray *types)
{
/* no frame matrix, create one since it is needed for rotation */
if (_frameMatrix == nil)
{
_frameMatrix = [NSAffineTransform new]; // Map fromsuperview to frame
}
{
_frameMatrix = [NSAffineTransform new]; // Map fromsuperview to frame
}
if (_coordinates_valid)
{
@ -2089,12 +2087,13 @@ static NSRect convert_rect_using_matrices(NSRect aRect, NSAffineTransform *matri
if (subview->_frameMatrix) // assume rotation
{
NSRect r;
r.origin = NSZeroPoint;
r.size = subviewFrame.size;
[subview->_frameMatrix boundingRectFor: r
result: &r];
subviewFrame = NSOffsetRect(r, NSMinX(subviewFrame), NSMinY(subviewFrame));
NSRect r;
r.origin = NSZeroPoint;
r.size = subviewFrame.size;
[subview->_frameMatrix boundingRectFor: r result: &r];
subviewFrame = NSOffsetRect(r, NSMinX(subviewFrame),
NSMinY(subviewFrame));
}
/*
@ -2221,14 +2220,15 @@ static NSRect convert_rect_using_matrices(NSRect aRect, NSAffineTransform *matri
BOOL intersectCalculated = NO;
if (subview->_frameMatrix != nil)
{
NSRect r;
r.origin = NSZeroPoint;
r.size = subviewFrame.size;
[subview->_frameMatrix boundingRectFor: r
result: &r];
subviewFrame = NSOffsetRect(r, NSMinX(subviewFrame), NSMinY(subviewFrame));
}
{
NSRect r;
r.origin = NSZeroPoint;
r.size = subviewFrame.size;
[subview->_frameMatrix boundingRectFor: r result: &r];
subviewFrame = NSOffsetRect(r, NSMinX(subviewFrame),
NSMinY(subviewFrame));
}
/*
* Having drawn ourself into the rect, we must make sure that
@ -2245,7 +2245,7 @@ static NSRect convert_rect_using_matrices(NSRect aRect, NSAffineTransform *matri
*/
subview->_rFlags.needs_display = YES;
subview->_invalidRect = NSUnionRect(subview->_invalidRect,
isect);
isect);
}
if (subview->_rFlags.needs_display == YES)
@ -2854,29 +2854,28 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
unsigned count;
NSView *v = nil, *w;
/*
If not within our frame then it can't be a hit.
/* If not within our frame then it can't be a hit.
As a special case, always assume that it's a hit if our _super_view is nil,
ie. if we're the top-level view in a window.
*/
if (_is_rotated_or_scaled_from_base)
{
p = [self convertPoint: aPoint fromView: _super_view];
if (!NSPointInRect (p, _bounds))
{
return nil;
}
}
else if (_super_view && ![_super_view mouse: aPoint inRect: _frame])
{
{
p = [self convertPoint: aPoint fromView: _super_view];
if (!NSPointInRect (p, _bounds))
{
return nil;
}
}
}
else if (_super_view && ![_super_view mouse: aPoint inRect: _frame])
{
return nil;
}
else
{
p = [self convertPoint: aPoint fromView: _super_view];
}
{
p = [self convertPoint: aPoint fromView: _super_view];
}
if (_rFlags.has_subviews)
{
@ -4275,12 +4274,12 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
- (float) frameRotation
{
if (_frameMatrix != nil)
{
return [_frameMatrix rotationAngle];
}
if (_frameMatrix != nil)
{
return [_frameMatrix rotationAngle];
}
return 0.0;
return 0.0;
}
- (BOOL) postsFrameChangedNotifications