mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-26 15:41:08 +00:00
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:
parent
a72332d295
commit
ec6668f3b3
4 changed files with 141 additions and 79 deletions
|
@ -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>
|
2006-10-19 01:45-EDT Gregory John Casamento <greg_casamento@yahoo.com>
|
||||||
|
|
||||||
* Source/NSView.m: Applied patch from Banlu Kemiyatorn. Corrects
|
* Source/NSView.m: Applied patch from Banlu Kemiyatorn. Corrects
|
||||||
|
|
|
@ -430,7 +430,12 @@ APPKIT_EXPORT NSString *GSThemeDidDeactivateNotification;
|
||||||
*/
|
*/
|
||||||
@interface GSTheme (LowLevelDrawing)
|
@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
|
- (void) fillHorizontalRect: (NSRect)rect
|
||||||
withImage: (NSImage*)image
|
withImage: (NSImage*)image
|
||||||
|
@ -449,20 +454,29 @@ withRepeatedImage: (NSImage*)image
|
||||||
center: (BOOL)center;
|
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
|
* This draws the left, right, top and bottom borders by tiling the
|
||||||
* images at TileCL, TileCR, TileTM and TileBM respectively. It then
|
* images at left, right, top and bottom. It then draws the four corner
|
||||||
* draws the four corner images and finally deals with the remaining
|
* images and finally deals with the remaining space in the middle according
|
||||||
* space in the middle according to the specified style.<br />
|
* to the specified style.<br />
|
||||||
* The background color specified is used where style is FillStyleNone.
|
* 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
|
- (NSRect) fillRect: (NSRect)rect
|
||||||
withTiles: (GSDrawTiles*)tiles
|
withTiles: (GSDrawTiles*)tiles
|
||||||
background: (NSColor*)color
|
background: (NSColor*)color
|
||||||
fillStyle: (GSThemeFillStyle)style;
|
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
|
- (void) fillVerticalRect: (NSRect)rect
|
||||||
withImage: (NSImage*)image
|
withImage: (NSImage*)image
|
||||||
|
|
|
@ -1050,7 +1050,7 @@ withRepeatedImage: (NSImage*)image
|
||||||
DPSgrestore (ctxt);
|
DPSgrestore (ctxt);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) fillRect: (NSRect)rect
|
- (NSRwect) fillRect: (NSRect)rect
|
||||||
withTiles: (GSDrawTiles*)tiles
|
withTiles: (GSDrawTiles*)tiles
|
||||||
background: (NSColor*)color
|
background: (NSColor*)color
|
||||||
fillStyle: (GSThemeFillStyle)style
|
fillStyle: (GSThemeFillStyle)style
|
||||||
|
@ -1085,6 +1085,7 @@ withRepeatedImage: (NSImage*)image
|
||||||
float space = 3.0;
|
float space = 3.0;
|
||||||
float scale;
|
float scale;
|
||||||
|
|
||||||
|
inFill = NSZeroRect;
|
||||||
if (tiles->images[TileTM] == nil)
|
if (tiles->images[TileTM] == nil)
|
||||||
{
|
{
|
||||||
grid.size.width = (tiles->rects[TileTL].size.width
|
grid.size.width = (tiles->rects[TileTL].size.width
|
||||||
|
@ -1289,16 +1290,22 @@ withRepeatedImage: (NSImage*)image
|
||||||
fromRect: tiles->rects[TileBR]
|
fromRect: tiles->rects[TileBR]
|
||||||
operation: NSCompositeSourceOver];
|
operation: NSCompositeSourceOver];
|
||||||
|
|
||||||
inFill = NSMakeRect (rect.origin.x +cls.width,
|
inFill = NSMakeRect (rect.origin.x + cls.width,
|
||||||
rect.origin.y + bms.height,
|
rect.origin.y + bms.height,
|
||||||
rect.size.width - cls.width - crs.width,
|
rect.size.width - cls.width - crs.width,
|
||||||
rect.size.height - bms.height - tms.height);
|
rect.size.height - bms.height - tms.height);
|
||||||
if (style == GSThemeFillStyleCenter)
|
if (style == GSThemeFillStyleCenter)
|
||||||
{
|
{
|
||||||
[self fillRect: inFill
|
NSRect r = tiles->rects[TileCM];
|
||||||
withRepeatedImage: tiles->images[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]
|
fromRect: tiles->rects[TileCM]
|
||||||
center: NO];
|
operation: NSCompositeSourceOver];
|
||||||
}
|
}
|
||||||
else if (style == GSThemeFillStyleRepeat)
|
else if (style == GSThemeFillStyleRepeat)
|
||||||
{
|
{
|
||||||
|
@ -1309,11 +1316,27 @@ withRepeatedImage: (NSImage*)image
|
||||||
}
|
}
|
||||||
else if (style == GSThemeFillStyleScale)
|
else if (style == GSThemeFillStyleScale)
|
||||||
{
|
{
|
||||||
[tiles->images[TileCM] setScalesWhenResized: YES];
|
NSImage *im = [tiles->images[TileCM] copy];
|
||||||
[tiles->images[TileCM] setSize: inFill.size];
|
NSRect r = tiles->rects[TileCM];
|
||||||
[tiles->images[TileCM] compositeToPoint: inFill.origin
|
NSSize s = [tiles->images[TileCM] size];
|
||||||
fromRect: tiles->rects[TileCM]
|
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];
|
operation: NSCompositeSourceOver];
|
||||||
|
RELEASE(im);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1387,10 +1410,15 @@ withRepeatedImage: (NSImage*)image
|
||||||
|
|
||||||
if (style == GSThemeFillStyleCenter)
|
if (style == GSThemeFillStyleCenter)
|
||||||
{
|
{
|
||||||
[self fillRect: inFill
|
NSRect r = tiles->rects[TileCM];
|
||||||
withRepeatedImage: tiles->images[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]
|
fromRect: tiles->rects[TileCM]
|
||||||
center: NO];
|
operation: NSCompositeSourceOver];
|
||||||
}
|
}
|
||||||
else if (style == GSThemeFillStyleRepeat)
|
else if (style == GSThemeFillStyleRepeat)
|
||||||
{
|
{
|
||||||
|
@ -1402,15 +1430,29 @@ withRepeatedImage: (NSImage*)image
|
||||||
else if (style == GSThemeFillStyleScale)
|
else if (style == GSThemeFillStyleScale)
|
||||||
{
|
{
|
||||||
NSImage *im = [tiles->images[TileCM] copy];
|
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 setScalesWhenResized: YES];
|
||||||
[im setSize: inFill.size];
|
[im setSize: s];
|
||||||
[im compositeToPoint: inFill.origin
|
[im compositeToPoint: p
|
||||||
fromRect: tiles->rects[TileCM]
|
fromRect: r
|
||||||
operation: NSCompositeSourceOver];
|
operation: NSCompositeSourceOver];
|
||||||
RELEASE(im);
|
RELEASE(im);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return inFill;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) fillVerticalRect: (NSRect)rect
|
- (void) fillVerticalRect: (NSRect)rect
|
||||||
|
|
|
@ -312,11 +312,9 @@ GSSetDragTypes(NSView* obj, NSArray *types)
|
||||||
/* prepend translation */
|
/* prepend translation */
|
||||||
tMatrix = _matrixToWindow;
|
tMatrix = _matrixToWindow;
|
||||||
tMatrix->matrix.tX = NSMinX(_frame) * tMatrix->matrix.m11 +
|
tMatrix->matrix.tX = NSMinX(_frame) * tMatrix->matrix.m11 +
|
||||||
NSMinY(_frame) * tMatrix->matrix.m21 +
|
NSMinY(_frame) * tMatrix->matrix.m21 + tMatrix->matrix.tX;
|
||||||
tMatrix->matrix.tX;
|
|
||||||
tMatrix->matrix.tY = NSMinX(_frame) * tMatrix->matrix.m12 +
|
tMatrix->matrix.tY = NSMinX(_frame) * tMatrix->matrix.m12 +
|
||||||
NSMinY(_frame) * tMatrix->matrix.m22 +
|
NSMinY(_frame) * tMatrix->matrix.m22 + tMatrix->matrix.tY;
|
||||||
tMatrix->matrix.tY;
|
|
||||||
|
|
||||||
/* prepend rotation */
|
/* prepend rotation */
|
||||||
if (_frameMatrix != nil)
|
if (_frameMatrix != nil)
|
||||||
|
@ -2090,11 +2088,12 @@ static NSRect convert_rect_using_matrices(NSRect aRect, NSAffineTransform *matri
|
||||||
if (subview->_frameMatrix) // assume rotation
|
if (subview->_frameMatrix) // assume rotation
|
||||||
{
|
{
|
||||||
NSRect r;
|
NSRect r;
|
||||||
|
|
||||||
r.origin = NSZeroPoint;
|
r.origin = NSZeroPoint;
|
||||||
r.size = subviewFrame.size;
|
r.size = subviewFrame.size;
|
||||||
[subview->_frameMatrix boundingRectFor: r
|
[subview->_frameMatrix boundingRectFor: r result: &r];
|
||||||
result: &r];
|
subviewFrame = NSOffsetRect(r, NSMinX(subviewFrame),
|
||||||
subviewFrame = NSOffsetRect(r, NSMinX(subviewFrame), NSMinY(subviewFrame));
|
NSMinY(subviewFrame));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -2223,11 +2222,12 @@ static NSRect convert_rect_using_matrices(NSRect aRect, NSAffineTransform *matri
|
||||||
if (subview->_frameMatrix != nil)
|
if (subview->_frameMatrix != nil)
|
||||||
{
|
{
|
||||||
NSRect r;
|
NSRect r;
|
||||||
|
|
||||||
r.origin = NSZeroPoint;
|
r.origin = NSZeroPoint;
|
||||||
r.size = subviewFrame.size;
|
r.size = subviewFrame.size;
|
||||||
[subview->_frameMatrix boundingRectFor: r
|
[subview->_frameMatrix boundingRectFor: r result: &r];
|
||||||
result: &r];
|
subviewFrame = NSOffsetRect(r, NSMinX(subviewFrame),
|
||||||
subviewFrame = NSOffsetRect(r, NSMinX(subviewFrame), NSMinY(subviewFrame));
|
NSMinY(subviewFrame));
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -2854,8 +2854,7 @@ static NSView* findByTag(NSView *view, int aTag, unsigned *level)
|
||||||
unsigned count;
|
unsigned count;
|
||||||
NSView *v = nil, *w;
|
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,
|
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.
|
ie. if we're the top-level view in a window.
|
||||||
|
|
Loading…
Reference in a new issue