Set backgrounds of images before drawing them.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@4184 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 1999-05-02 18:27:38 +00:00
parent ae7f99c597
commit 6847940a3e
3 changed files with 29 additions and 15 deletions

View file

@ -261,15 +261,15 @@ static NSImage *highlight_image;
// //
- (void) drawInteriorWithFrame: (NSRect)cellFrame inView: (NSView *)controlView - (void) drawInteriorWithFrame: (NSRect)cellFrame inView: (NSView *)controlView
{ {
NSRect title_rect = cellFrame; NSRect title_rect = cellFrame;
NSRect image_rect = cellFrame; NSRect image_rect = cellFrame;
NSImage *image = nil; NSImage *image = nil;
NSColor *backColor;
control_view = controlView; // remember last view cell was drawn in control_view = controlView; // remember last view cell was drawn in
if (cell_highlighted || cell_state) // temporary hack FAR FIX ME? if (cell_highlighted || cell_state) // temporary hack FAR FIX ME?
{ {
NSColor *backColor = [NSColor selectedControlColor]; backColor = [NSColor selectedControlColor];
[backColor set]; [backColor set];
if (!_isLeaf) if (!_isLeaf)
{ {
@ -284,8 +284,7 @@ static NSImage *highlight_image;
} }
else else
{ {
NSColor *backColor = [[controlView window] backgroundColor]; backColor = [[controlView window] backgroundColor];
[backColor set]; [backColor set];
if (!_isLeaf) if (!_isLeaf)
{ {
@ -304,7 +303,10 @@ static NSImage *highlight_image;
[_browserText drawWithFrame: title_rect inView: controlView]; [_browserText drawWithFrame: title_rect inView: controlView];
if (image) if (image)
[self _drawImage: image inFrame: image_rect]; {
[image setBackgroundColor: backColor];
[self _drawImage: image inFrame: image_rect];
}
} }
// //

View file

@ -414,7 +414,7 @@
NSString *titleToDisplay; NSString *titleToDisplay;
NSSize imageSize = {0, 0}; NSSize imageSize = {0, 0};
NSRect rect; NSRect rect;
float backgroundGray = NSLightGray; NSColor *backgroundColor = [NSColor controlBackgroundColor];
cellFrame = NSInsetRect(cellFrame, xDist, yDist); cellFrame = NSInsetRect(cellFrame, xDist, yDist);
@ -423,18 +423,18 @@
{ {
if ( [self showsStateBy] if ( [self showsStateBy]
& (NSChangeGrayCellMask | NSChangeBackgroundCellMask) ) & (NSChangeGrayCellMask | NSChangeBackgroundCellMask) )
backgroundGray = NSWhite; backgroundColor = [NSColor selectedControlColor];
} }
if ([self isHighlighted]) if ([self isHighlighted])
{ {
if ( [self highlightsBy] if ( [self highlightsBy]
& (NSChangeGrayCellMask | NSChangeBackgroundCellMask) ) & (NSChangeGrayCellMask | NSChangeBackgroundCellMask) )
backgroundGray = NSWhite; backgroundColor = [NSColor selectedControlColor];
} }
// set cell's background color // set cell's background color
[[NSColor colorWithCalibratedWhite: backgroundGray alpha: 1.0] set]; [backgroundColor set];
NSRectFill(cellFrame); NSRectFill(cellFrame);
// Determine the image and the title that will be // Determine the image and the title that will be
@ -465,7 +465,10 @@
} }
if (imageToDisplay) if (imageToDisplay)
imageSize = [imageToDisplay size]; {
imageSize = [imageToDisplay size];
[imageToDisplay setBackgroundColor: backgroundColor];
}
rect = NSMakeRect (cellFrame.origin.x, cellFrame.origin.y, rect = NSMakeRect (cellFrame.origin.x, cellFrame.origin.y,
imageSize.width, imageSize.height); imageSize.width, imageSize.height);

View file

@ -646,9 +646,18 @@ static inline NSPoint centerSizeInRect(NSSize innerSize, NSRect outerRect)
// Clear the cell frame // Clear the cell frame
if ([self isOpaque]) if ([self isOpaque])
{ {
[[NSColor lightGrayColor] set]; NSColor *bg;
if (cell_highlighted)
bg = [NSColor selectedControlColor];
else
bg = [NSColor controlBackgroundColor];
[bg set];
[[self image] setBackgroundColor: bg];
NSRectFill(cellFrame); NSRectFill(cellFrame);
} }
else
[[self image] setBackgroundColor: [NSColor clearColor]];
switch ([self type]) switch ([self type])
{ {