mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 15:11:37 +00:00
Moved _sizeForBorderType() into GSTheme header and added more methods
for theme abstraction. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@26836 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
aa4ce2c493
commit
f114baad28
8 changed files with 338 additions and 263 deletions
16
ChangeLog
16
ChangeLog
|
@ -1,3 +1,19 @@
|
|||
2008-09-08 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Headers/AppKit/NSCell.h: Move _sizeForBorderType to GSTheme.h
|
||||
* Headers/Additions/GNUstepGUI/GSTheme.h (-sizeForBorderType:,
|
||||
-drawBorderType:frame:view:, -sizeForImageFrameStyle:,
|
||||
-drawBorderForImageFrameStyle:frame:view:),
|
||||
* Source/GSTheme.m: New methods.
|
||||
* Source/NSCell.m (-cellSize, -drawingRectForBounds:,
|
||||
-_drawBorderAndBackgroundWithFrame:inView:),
|
||||
* Source/NSImageCell.m (-cellSize, -drawingRectForBounds:,
|
||||
-_drawBorderAndBackgroundWithFrame:inView:): Use new GSTheme methods.
|
||||
* Source/NSPopUpButtonCell.m: Include GSTheme.h
|
||||
* Source/NSButtonCell.m: Moved gradient drawing method to GSTheme
|
||||
and call it from _drawBorderAndBackgroundWithFrame:inView:.
|
||||
* Source/GSTheme.m (-drawGradientBorder:inRect:withClip:): New method.
|
||||
|
||||
2008-09-07 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Source/NSBitmapImageRep+ICNS.m: Corrected last change.
|
||||
|
|
|
@ -138,6 +138,8 @@
|
|||
#include "AppKit/NSCell.h"
|
||||
// For gradient types
|
||||
#include "AppKit/NSButtonCell.h"
|
||||
// For image frame style
|
||||
#include "AppKit/NSImageCell.h"
|
||||
|
||||
#if OS_API_VERSION(GS_API_NONE,GS_API_NONE)
|
||||
@class NSArray;
|
||||
|
@ -405,6 +407,30 @@ APPKIT_EXPORT NSString *GSThemeDidDeactivateNotification;
|
|||
*/
|
||||
- (void) drawWindowBackground: (NSRect)frame view: (NSView*)view;
|
||||
|
||||
/**
|
||||
* Draw a border of the specified border type.
|
||||
*/
|
||||
- (void) drawBorderType: (NSBorderType)aType
|
||||
frame: (NSRect)frame
|
||||
view: (NSView*)view;
|
||||
|
||||
/**
|
||||
* Determine the size for the specified border type .
|
||||
*/
|
||||
- (NSSize) sizeForBorderType: (NSBorderType)aType;
|
||||
|
||||
/**
|
||||
* Draw a border of the specified frame style.
|
||||
*/
|
||||
- (void) drawBorderForImageFrameStyle: (NSImageFrameStyle)frameStyle
|
||||
frame: (NSRect)frame
|
||||
view: (NSView*)view;
|
||||
|
||||
/**
|
||||
* Determine the size for the specified frame style.
|
||||
*/
|
||||
- (NSSize) sizeForImageFrameStyle: (NSImageFrameStyle)frameStyle;
|
||||
|
||||
@end
|
||||
|
||||
/**
|
||||
|
@ -502,5 +528,14 @@ withRepeatedImage: (NSImage*)image
|
|||
flipped: (BOOL)flipped;
|
||||
@end
|
||||
|
||||
//
|
||||
// Function which should be somewhere else
|
||||
//
|
||||
static inline NSSize
|
||||
_sizeForBorderType (NSBorderType aType)
|
||||
{
|
||||
return [[GSTheme theme] sizeForBorderType: aType];
|
||||
}
|
||||
|
||||
#endif /* OS_API_VERSION */
|
||||
#endif /* _GNUstep_H_GSTheme */
|
||||
|
|
|
@ -493,11 +493,5 @@ enum {
|
|||
inView: (NSView*)controlView;
|
||||
@end
|
||||
|
||||
//
|
||||
// Function which should be somewhere else
|
||||
//
|
||||
inline NSSize
|
||||
_sizeForBorderType (NSBorderType aType);
|
||||
|
||||
#endif // _GNUstep_H_NSCell
|
||||
|
||||
|
|
201
Source/GSTheme.m
201
Source/GSTheme.m
|
@ -860,6 +860,86 @@ static NSNull *null = nil;
|
|||
NSRectFill (frame);
|
||||
}
|
||||
|
||||
- (void) drawBorderType: (NSBorderType)aType
|
||||
frame: (NSRect)frame
|
||||
view: (NSView*)view
|
||||
{
|
||||
switch (aType)
|
||||
{
|
||||
case NSLineBorder:
|
||||
[[NSColor controlDarkShadowColor] set];
|
||||
NSFrameRect(frame);
|
||||
break;
|
||||
case NSGrooveBorder:
|
||||
[self drawGroove: frame withClip: NSZeroRect];
|
||||
break;
|
||||
case NSBezelBorder:
|
||||
[self drawWhiteBezel: frame withClip: NSZeroRect];
|
||||
break;
|
||||
case NSNoBorder:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
- (NSSize) sizeForBorderType: (NSBorderType)aType
|
||||
{
|
||||
// Returns the size of a border
|
||||
switch (aType)
|
||||
{
|
||||
case NSLineBorder:
|
||||
return NSMakeSize(1, 1);
|
||||
case NSGrooveBorder:
|
||||
case NSBezelBorder:
|
||||
return NSMakeSize(2, 2);
|
||||
case NSNoBorder:
|
||||
default:
|
||||
return NSZeroSize;
|
||||
}
|
||||
}
|
||||
|
||||
- (void) drawBorderForImageFrameStyle: (NSImageFrameStyle)frameStyle
|
||||
frame: (NSRect)frame
|
||||
view: (NSView*)view
|
||||
{
|
||||
switch (frameStyle)
|
||||
{
|
||||
case NSImageFrameNone:
|
||||
// do nothing
|
||||
break;
|
||||
case NSImageFramePhoto:
|
||||
[self drawFramePhoto: frame withClip: NSZeroRect];
|
||||
break;
|
||||
case NSImageFrameGrayBezel:
|
||||
[self drawGrayBezel: frame withClip: NSZeroRect];
|
||||
break;
|
||||
case NSImageFrameGroove:
|
||||
[self drawGroove: frame withClip: NSZeroRect];
|
||||
break;
|
||||
case NSImageFrameButton:
|
||||
[self drawButton: frame withClip: NSZeroRect];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
- (NSSize) sizeForImageFrameStyle: (NSImageFrameStyle)frameStyle
|
||||
{
|
||||
// Get border size
|
||||
switch (frameStyle)
|
||||
{
|
||||
case NSImageFrameNone:
|
||||
default:
|
||||
return NSZeroSize;
|
||||
case NSImageFramePhoto:
|
||||
// FIXME
|
||||
return NSMakeSize(2, 2);
|
||||
case NSImageFrameGrayBezel:
|
||||
case NSImageFrameGroove:
|
||||
case NSImageFrameButton:
|
||||
return NSMakeSize(2, 2);
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
@ -968,9 +1048,10 @@ static NSNull *null = nil;
|
|||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
- (NSRect) drawGradientBorder: (NSGradientType)gradientType
|
||||
inRect: (NSRect)border
|
||||
withClip: (NSRect)clip
|
||||
inRect: (NSRect)border
|
||||
withClip: (NSRect)clip
|
||||
{
|
||||
NSRectEdge up_sides[] = {NSMaxXEdge, NSMinYEdge,
|
||||
NSMinXEdge, NSMaxYEdge};
|
||||
|
@ -1017,6 +1098,122 @@ static NSNull *null = nil;
|
|||
return rect;
|
||||
}
|
||||
|
||||
#else
|
||||
// FIXME: I think this method is wrong.
|
||||
- (NSRect) drawGradientBorder: (NSGradientType)gradientType
|
||||
inRect: (NSRect)cellFrame
|
||||
withClip: (NSRect)clip
|
||||
{
|
||||
float start_white = 0.0;
|
||||
float end_white = 0.0;
|
||||
float white = 0.0;
|
||||
float white_step = 0.0;
|
||||
float h, s, v, a;
|
||||
NSPoint p1, p2;
|
||||
NSColor *gray = nil;
|
||||
NSColor *darkGray = nil;
|
||||
NSColor *lightGray = nil;
|
||||
|
||||
lightGray = [NSColor colorWithDeviceRed: NSLightGray
|
||||
green: NSLightGray
|
||||
blue: NSLightGray
|
||||
alpha:1.0];
|
||||
gray = [NSColor colorWithDeviceRed: NSGray
|
||||
green: NSGray
|
||||
blue: NSGray
|
||||
alpha:1.0];
|
||||
darkGray = [NSColor colorWithDeviceRed: NSDarkGray
|
||||
green: NSDarkGray
|
||||
blue: NSDarkGray
|
||||
alpha:1.0];
|
||||
|
||||
switch (gradientType)
|
||||
{
|
||||
case NSGradientNone:
|
||||
return NSZeroRect;
|
||||
break;
|
||||
|
||||
case NSGradientConcaveWeak:
|
||||
[gray getHue: &h saturation: &s brightness: &v alpha: &a];
|
||||
start_white = [lightGray brightnessComponent];
|
||||
end_white = [gray brightnessComponent];
|
||||
break;
|
||||
|
||||
case NSGradientConvexWeak:
|
||||
[darkGray getHue: &h saturation: &s brightness: &v alpha: &a];
|
||||
start_white = [gray brightnessComponent];
|
||||
end_white = [lightGray brightnessComponent];
|
||||
break;
|
||||
|
||||
case NSGradientConcaveStrong:
|
||||
[lightGray getHue: &h saturation: &s brightness: &v alpha: &a];
|
||||
start_white = [lightGray brightnessComponent];
|
||||
end_white = [darkGray brightnessComponent];
|
||||
break;
|
||||
|
||||
case NSGradientConvexStrong:
|
||||
[darkGray getHue: &h saturation: &s brightness: &v alpha: &a];
|
||||
start_white = [darkGray brightnessComponent];
|
||||
end_white = [lightGray brightnessComponent];
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
white = start_white;
|
||||
white_step = fabs(start_white - end_white)
|
||||
/ (cellFrame.size.width + cellFrame.size.height);
|
||||
|
||||
// Start from top left
|
||||
p1 = NSMakePoint(cellFrame.origin.x,
|
||||
cellFrame.size.height + cellFrame.origin.y);
|
||||
p2 = NSMakePoint(cellFrame.origin.x,
|
||||
cellFrame.size.height + cellFrame.origin.y);
|
||||
|
||||
// Move by Y
|
||||
while (p1.y > cellFrame.origin.y)
|
||||
{
|
||||
[[NSColor
|
||||
colorWithDeviceHue: h saturation: s brightness: white alpha: 1.0] set];
|
||||
[NSBezierPath strokeLineFromPoint: p1 toPoint: p2];
|
||||
|
||||
if (start_white > end_white)
|
||||
white -= white_step;
|
||||
else
|
||||
white += white_step;
|
||||
|
||||
p1.y -= 1.0;
|
||||
if (p2.x < (cellFrame.size.width + cellFrame.origin.x))
|
||||
p2.x += 1.0;
|
||||
else
|
||||
p2.y -= 1.0;
|
||||
}
|
||||
|
||||
// Move by X
|
||||
while (p1.x < (cellFrame.size.width + cellFrame.origin.x))
|
||||
{
|
||||
[[NSColor
|
||||
colorWithDeviceHue: h saturation: s brightness: white alpha: 1.0] set];
|
||||
[NSBezierPath strokeLineFromPoint: p1 toPoint: p2];
|
||||
|
||||
if (start_white > end_white)
|
||||
white -= white_step;
|
||||
else
|
||||
white += white_step;
|
||||
|
||||
p1.x += 1.0;
|
||||
if (p2.x >= (cellFrame.size.width + cellFrame.origin.x))
|
||||
p2.y -= 1.0;
|
||||
else
|
||||
p2.x += 1.0;
|
||||
}
|
||||
|
||||
return NSZeroRect;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
- (NSRect) drawGrayBezel: (NSRect)border withClip: (NSRect)clip
|
||||
{
|
||||
NSRectEdge up_sides[] = {NSMaxXEdge, NSMinYEdge, NSMinXEdge, NSMaxYEdge,
|
||||
|
|
|
@ -929,6 +929,14 @@ typedef struct _GSButtonCellFlags
|
|||
- (void) _drawBorderAndBackgroundWithFrame: (NSRect)cellFrame
|
||||
inView: (NSView*)controlView
|
||||
{
|
||||
// Draw gradient
|
||||
if (!_cell.is_highlighted)
|
||||
{
|
||||
[[GSTheme theme] drawGradientBorder: _gradient_type
|
||||
inRect: cellFrame
|
||||
withClip: NSZeroRect];
|
||||
}
|
||||
|
||||
// The inside check could also be done via a track rect, but then this would
|
||||
// only work with specially prepared controls. Therefore we dont use
|
||||
// _mouse_inside here.
|
||||
|
@ -941,105 +949,6 @@ typedef struct _GSButtonCellFlags
|
|||
}
|
||||
}
|
||||
|
||||
- (void) drawGradientWithFrame: (NSRect)cellFrame inView: (NSView *)controlView
|
||||
{
|
||||
float start_white = 0.0;
|
||||
float end_white = 0.0;
|
||||
float white = 0.0;
|
||||
float white_step = 0.0;
|
||||
float h, s, v, a;
|
||||
NSColor *lightGray = nil;
|
||||
NSColor *gray = nil;
|
||||
NSColor *darkGray = nil;
|
||||
NSPoint p1, p2;
|
||||
|
||||
lightGray = [NSColor colorWithDeviceRed:0.83 green:0.83 blue:0.83 alpha:1.0];
|
||||
gray = [NSColor colorWithDeviceRed:0.50 green:0.50 blue:0.50 alpha:1.0];
|
||||
darkGray = [NSColor colorWithDeviceRed:0.32 green:0.32 blue:0.32 alpha:1.0];
|
||||
|
||||
switch (_gradient_type)
|
||||
{
|
||||
case NSGradientNone:
|
||||
return;
|
||||
break;
|
||||
|
||||
case NSGradientConcaveWeak:
|
||||
[gray getHue: &h saturation: &s brightness: &v alpha: &a];
|
||||
start_white = [lightGray brightnessComponent];
|
||||
end_white = [gray brightnessComponent];
|
||||
break;
|
||||
|
||||
case NSGradientConvexWeak:
|
||||
[darkGray getHue: &h saturation: &s brightness: &v alpha: &a];
|
||||
start_white = [gray brightnessComponent];
|
||||
end_white = [lightGray brightnessComponent];
|
||||
break;
|
||||
|
||||
case NSGradientConcaveStrong:
|
||||
[lightGray getHue: &h saturation: &s brightness: &v alpha: &a];
|
||||
start_white = [lightGray brightnessComponent];
|
||||
end_white = [darkGray brightnessComponent];
|
||||
break;
|
||||
|
||||
case NSGradientConvexStrong:
|
||||
[darkGray getHue: &h saturation: &s brightness: &v alpha: &a];
|
||||
start_white = [darkGray brightnessComponent];
|
||||
end_white = [lightGray brightnessComponent];
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
white = start_white;
|
||||
white_step = fabs(start_white - end_white)
|
||||
/ (cellFrame.size.width + cellFrame.size.height);
|
||||
|
||||
// Start from top left
|
||||
p1 = NSMakePoint(cellFrame.origin.x,
|
||||
cellFrame.size.height + cellFrame.origin.y);
|
||||
p2 = NSMakePoint(cellFrame.origin.x,
|
||||
cellFrame.size.height + cellFrame.origin.y);
|
||||
|
||||
// Move by Y
|
||||
while (p1.y > cellFrame.origin.y)
|
||||
{
|
||||
[[NSColor
|
||||
colorWithDeviceHue: h saturation: s brightness: white alpha: 1.0] set];
|
||||
[NSBezierPath strokeLineFromPoint: p1 toPoint: p2];
|
||||
|
||||
if (start_white > end_white)
|
||||
white -= white_step;
|
||||
else
|
||||
white += white_step;
|
||||
|
||||
p1.y -= 1.0;
|
||||
if (p2.x < (cellFrame.size.width + cellFrame.origin.x))
|
||||
p2.x += 1.0;
|
||||
else
|
||||
p2.y -= 1.0;
|
||||
}
|
||||
|
||||
// Move by X
|
||||
while (p1.x < (cellFrame.size.width + cellFrame.origin.x))
|
||||
{
|
||||
[[NSColor
|
||||
colorWithDeviceHue: h saturation: s brightness: white alpha: 1.0] set];
|
||||
[NSBezierPath strokeLineFromPoint: p1 toPoint: p2];
|
||||
|
||||
if (start_white > end_white)
|
||||
white -= white_step;
|
||||
else
|
||||
white += white_step;
|
||||
|
||||
p1.x += 1.0;
|
||||
if (p2.x >= (cellFrame.size.width + cellFrame.origin.x))
|
||||
p2.y -= 1.0;
|
||||
else
|
||||
p2.x += 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
- (void) drawInteriorWithFrame: (NSRect)cellFrame inView: (NSView*)controlView
|
||||
{
|
||||
unsigned mask;
|
||||
|
@ -1275,13 +1184,6 @@ typedef struct _GSButtonCellFlags
|
|||
break;
|
||||
}
|
||||
|
||||
// Draw gradient
|
||||
if (!_cell.is_highlighted && _gradient_type != NSGradientNone)
|
||||
{
|
||||
// FIXME: I think this method is wrong.
|
||||
[self drawGradientWithFrame: cellFrame inView: controlView];
|
||||
}
|
||||
|
||||
// Draw image
|
||||
if (imageToDisplay != nil)
|
||||
{
|
||||
|
|
|
@ -71,7 +71,6 @@ static Class imageClass;
|
|||
|
||||
static NSColor *txtCol;
|
||||
static NSColor *dtxtCol;
|
||||
static NSColor *shadowCol;
|
||||
|
||||
@interface NSCell (PrivateColor)
|
||||
+ (void) _systemColorsChanged: (NSNotification*)n;
|
||||
|
@ -83,7 +82,6 @@ static NSColor *shadowCol;
|
|||
{
|
||||
ASSIGN (txtCol, [colorClass controlTextColor]);
|
||||
ASSIGN (dtxtCol, [colorClass disabledControlTextColor]);
|
||||
ASSIGN (shadowCol, [colorClass controlDarkShadowColor]);
|
||||
}
|
||||
@end
|
||||
|
||||
|
@ -1763,14 +1761,17 @@ static NSColor *shadowCol;
|
|||
- (NSSize) cellSize
|
||||
{
|
||||
NSSize borderSize, s;
|
||||
|
||||
NSBorderType aType;
|
||||
|
||||
// Get border size
|
||||
if (_cell.is_bordered)
|
||||
borderSize = _sizeForBorderType (NSLineBorder);
|
||||
aType = NSLineBorder;
|
||||
else if (_cell.is_bezeled)
|
||||
borderSize = _sizeForBorderType (NSBezelBorder);
|
||||
aType = NSBezelBorder;
|
||||
else
|
||||
borderSize = NSZeroSize;
|
||||
aType = NSNoBorder;
|
||||
|
||||
borderSize = [[GSTheme theme] sizeForBorderType: aType];
|
||||
|
||||
// Add spacing between border and inside
|
||||
if (_cell.is_bordered || _cell.is_bezeled)
|
||||
|
@ -1841,15 +1842,17 @@ static NSColor *shadowCol;
|
|||
- (NSRect) drawingRectForBounds: (NSRect)theRect
|
||||
{
|
||||
NSSize borderSize;
|
||||
NSBorderType aType;
|
||||
|
||||
// Get border size
|
||||
if (_cell.is_bordered)
|
||||
borderSize = _sizeForBorderType (NSLineBorder);
|
||||
aType = NSLineBorder;
|
||||
else if (_cell.is_bezeled)
|
||||
borderSize = _sizeForBorderType (NSBezelBorder);
|
||||
aType = NSBezelBorder;
|
||||
else
|
||||
borderSize = NSZeroSize;
|
||||
|
||||
aType = NSNoBorder;
|
||||
|
||||
borderSize = [[GSTheme theme] sizeForBorderType: aType];
|
||||
return NSInsetRect(theRect, borderSize.width, borderSize.height);
|
||||
}
|
||||
|
||||
|
@ -2814,15 +2817,17 @@ static NSColor *shadowCol;
|
|||
- (void) _drawBorderAndBackgroundWithFrame: (NSRect)cellFrame
|
||||
inView: (NSView*)controlView
|
||||
{
|
||||
NSBorderType aType;
|
||||
|
||||
// Get border size
|
||||
if (_cell.is_bordered)
|
||||
{
|
||||
[shadowCol set];
|
||||
NSFrameRect(cellFrame);
|
||||
}
|
||||
aType = NSLineBorder;
|
||||
else if (_cell.is_bezeled)
|
||||
{
|
||||
[[GSTheme theme] drawWhiteBezel: cellFrame withClip: NSZeroRect];
|
||||
}
|
||||
aType = NSBezelBorder;
|
||||
else
|
||||
aType = NSNoBorder;
|
||||
|
||||
[[GSTheme theme] drawBorderType: aType frame: cellFrame view: controlView];
|
||||
}
|
||||
|
||||
// Private helper method
|
||||
|
@ -2855,23 +2860,3 @@ static NSColor *shadowCol;
|
|||
}
|
||||
|
||||
@end
|
||||
|
||||
/*
|
||||
* Global function which should go somewhere else
|
||||
*/
|
||||
inline NSSize
|
||||
_sizeForBorderType (NSBorderType aType)
|
||||
{
|
||||
// Returns the size of a border
|
||||
switch (aType)
|
||||
{
|
||||
case NSLineBorder:
|
||||
return NSMakeSize(1, 1);
|
||||
case NSGrooveBorder:
|
||||
case NSBezelBorder:
|
||||
return NSMakeSize(2, 2);
|
||||
case NSNoBorder:
|
||||
default:
|
||||
return NSZeroSize;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -52,9 +52,7 @@
|
|||
//
|
||||
- (id) init
|
||||
{
|
||||
[self initImageCell: nil];
|
||||
|
||||
return self;
|
||||
return [self initImageCell: nil];
|
||||
}
|
||||
|
||||
- (void) setImage:(NSImage *)anImage
|
||||
|
@ -120,35 +118,13 @@
|
|||
//
|
||||
// Displaying
|
||||
//
|
||||
- (void) drawWithFrame: (NSRect)cellFrame inView: (NSView *)controlView
|
||||
- (void) _drawBorderAndBackgroundWithFrame: (NSRect)cellFrame
|
||||
inView: (NSView *)controlView
|
||||
{
|
||||
NSDebugLLog(@"NSImageCell", @"NSImageCell -drawWithFrame");
|
||||
|
||||
// do nothing if cell's frame rect is zero
|
||||
if (NSIsEmptyRect (cellFrame))
|
||||
return;
|
||||
|
||||
// draw the border if needed
|
||||
switch (_frameStyle)
|
||||
{
|
||||
case NSImageFrameNone:
|
||||
// do nothing
|
||||
break;
|
||||
case NSImageFramePhoto:
|
||||
[[GSTheme theme] drawFramePhoto: cellFrame withClip: NSZeroRect];
|
||||
break;
|
||||
case NSImageFrameGrayBezel:
|
||||
[[GSTheme theme] drawGrayBezel: cellFrame withClip: NSZeroRect];
|
||||
break;
|
||||
case NSImageFrameGroove:
|
||||
[[GSTheme theme] drawGroove: cellFrame withClip: NSZeroRect];
|
||||
break;
|
||||
case NSImageFrameButton:
|
||||
[[GSTheme theme] drawButton: cellFrame withClip: NSZeroRect];
|
||||
break;
|
||||
}
|
||||
|
||||
[self drawInteriorWithFrame: cellFrame inView: controlView];
|
||||
NSDebugLLog(@"NSImageCell", @"NSImageCell -_drawBorderAndBackgroundWithFrame");
|
||||
[[GSTheme theme] drawBorderForImageFrameStyle: _frameStyle
|
||||
frame: cellFrame
|
||||
view: controlView];
|
||||
}
|
||||
|
||||
static inline float
|
||||
|
@ -219,7 +195,7 @@ scaleProportionally(NSSize imageSize, NSRect canvasRect)
|
|||
{
|
||||
NSPoint position;
|
||||
BOOL is_flipped = [controlView isFlipped];
|
||||
NSSize imageSize, realImageSize;
|
||||
NSSize imageSize, realImageSize;
|
||||
|
||||
NSDebugLLog(@"NSImageCell", @"NSImageCell drawInteriorWithFrame called");
|
||||
|
||||
|
@ -234,65 +210,65 @@ scaleProportionally(NSSize imageSize, NSRect canvasRect)
|
|||
switch (_imageScaling)
|
||||
{
|
||||
case NSScaleProportionally:
|
||||
{
|
||||
NSDebugLLog(@"NSImageCell", @"NSScaleProportionally");
|
||||
imageSize = scaleProportionally (realImageSize, cellFrame);
|
||||
break;
|
||||
}
|
||||
{
|
||||
NSDebugLLog(@"NSImageCell", @"NSScaleProportionally");
|
||||
imageSize = scaleProportionally (realImageSize, cellFrame);
|
||||
break;
|
||||
}
|
||||
case NSScaleToFit:
|
||||
{
|
||||
NSDebugLLog(@"NSImageCell", @"NSScaleToFit");
|
||||
imageSize = cellFrame.size;
|
||||
break;
|
||||
}
|
||||
{
|
||||
NSDebugLLog(@"NSImageCell", @"NSScaleToFit");
|
||||
imageSize = cellFrame.size;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
case NSScaleNone:
|
||||
{
|
||||
NSDebugLLog(@"NSImageCell", @"NSScaleNone");
|
||||
imageSize = realImageSize;
|
||||
break;
|
||||
}
|
||||
{
|
||||
NSDebugLLog(@"NSImageCell", @"NSScaleNone");
|
||||
imageSize = realImageSize;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
switch (_imageAlignment)
|
||||
{
|
||||
default:
|
||||
case NSImageAlignLeft:
|
||||
position.x = xLeftInRect(imageSize, cellFrame);
|
||||
position.y = yCenterInRect(imageSize, cellFrame, is_flipped);
|
||||
break;
|
||||
position.x = xLeftInRect(imageSize, cellFrame);
|
||||
position.y = yCenterInRect(imageSize, cellFrame, is_flipped);
|
||||
break;
|
||||
case NSImageAlignRight:
|
||||
position.x = xRightInRect(imageSize, cellFrame);
|
||||
position.y = yCenterInRect(imageSize, cellFrame, is_flipped);
|
||||
break;
|
||||
position.x = xRightInRect(imageSize, cellFrame);
|
||||
position.y = yCenterInRect(imageSize, cellFrame, is_flipped);
|
||||
break;
|
||||
case NSImageAlignCenter:
|
||||
position.x = xCenterInRect(imageSize, cellFrame);
|
||||
position.y = yCenterInRect(imageSize, cellFrame, is_flipped);
|
||||
break;
|
||||
position.x = xCenterInRect(imageSize, cellFrame);
|
||||
position.y = yCenterInRect(imageSize, cellFrame, is_flipped);
|
||||
break;
|
||||
case NSImageAlignTop:
|
||||
position.x = xCenterInRect(imageSize, cellFrame);
|
||||
position.y = yTopInRect(imageSize, cellFrame, is_flipped);
|
||||
break;
|
||||
position.x = xCenterInRect(imageSize, cellFrame);
|
||||
position.y = yTopInRect(imageSize, cellFrame, is_flipped);
|
||||
break;
|
||||
case NSImageAlignBottom:
|
||||
position.x = xCenterInRect(imageSize, cellFrame);
|
||||
position.y = yBottomInRect(imageSize, cellFrame, is_flipped);
|
||||
break;
|
||||
position.x = xCenterInRect(imageSize, cellFrame);
|
||||
position.y = yBottomInRect(imageSize, cellFrame, is_flipped);
|
||||
break;
|
||||
case NSImageAlignTopLeft:
|
||||
position.x = xLeftInRect(imageSize, cellFrame);
|
||||
position.y = yTopInRect(imageSize, cellFrame, is_flipped);
|
||||
break;
|
||||
position.x = xLeftInRect(imageSize, cellFrame);
|
||||
position.y = yTopInRect(imageSize, cellFrame, is_flipped);
|
||||
break;
|
||||
case NSImageAlignTopRight:
|
||||
position.x = xRightInRect(imageSize, cellFrame);
|
||||
position.y = yTopInRect(imageSize, cellFrame, is_flipped);
|
||||
break;
|
||||
position.x = xRightInRect(imageSize, cellFrame);
|
||||
position.y = yTopInRect(imageSize, cellFrame, is_flipped);
|
||||
break;
|
||||
case NSImageAlignBottomLeft:
|
||||
position.x = xLeftInRect(imageSize, cellFrame);
|
||||
position.y = yBottomInRect(imageSize, cellFrame, is_flipped);
|
||||
break;
|
||||
position.x = xLeftInRect(imageSize, cellFrame);
|
||||
position.y = yBottomInRect(imageSize, cellFrame, is_flipped);
|
||||
break;
|
||||
case NSImageAlignBottomRight:
|
||||
position.x = xRightInRect(imageSize, cellFrame);
|
||||
position.y = yBottomInRect(imageSize, cellFrame, is_flipped);
|
||||
break;
|
||||
position.x = xRightInRect(imageSize, cellFrame);
|
||||
position.y = yBottomInRect(imageSize, cellFrame, is_flipped);
|
||||
break;
|
||||
}
|
||||
|
||||
// account for flipped views
|
||||
|
@ -304,11 +280,11 @@ scaleProportionally(NSSize imageSize, NSRect canvasRect)
|
|||
|
||||
// draw!
|
||||
[_cell_image drawInRect: NSMakeRect(position.x, position.y,
|
||||
imageSize.width, imageSize.height)
|
||||
fromRect: NSMakeRect(0, 0, realImageSize.width,
|
||||
realImageSize.height)
|
||||
operation: NSCompositeSourceOver
|
||||
fraction: 1.0];
|
||||
imageSize.width, imageSize.height)
|
||||
fromRect: NSMakeRect(0, 0, realImageSize.width,
|
||||
realImageSize.height)
|
||||
operation: NSCompositeSourceOver
|
||||
fraction: 1.0];
|
||||
}
|
||||
|
||||
- (NSSize) cellSize
|
||||
|
@ -316,22 +292,7 @@ scaleProportionally(NSSize imageSize, NSRect canvasRect)
|
|||
NSSize borderSize, s;
|
||||
|
||||
// Get border size
|
||||
switch (_frameStyle)
|
||||
{
|
||||
case NSImageFrameNone:
|
||||
default:
|
||||
borderSize = NSZeroSize;
|
||||
break;
|
||||
case NSImageFramePhoto:
|
||||
// FIXME
|
||||
borderSize = _sizeForBorderType (NSNoBorder);
|
||||
break;
|
||||
case NSImageFrameGrayBezel:
|
||||
case NSImageFrameGroove:
|
||||
case NSImageFrameButton:
|
||||
borderSize = _sizeForBorderType (NSBezelBorder);
|
||||
break;
|
||||
}
|
||||
borderSize = [[GSTheme theme] sizeForImageFrameStyle: _frameStyle];
|
||||
|
||||
// Get Content Size
|
||||
s = _original_image_size;
|
||||
|
@ -348,23 +309,7 @@ scaleProportionally(NSSize imageSize, NSRect canvasRect)
|
|||
NSSize borderSize;
|
||||
|
||||
// Get border size
|
||||
switch (_frameStyle)
|
||||
{
|
||||
case NSImageFrameNone:
|
||||
default:
|
||||
borderSize = NSZeroSize;
|
||||
break;
|
||||
case NSImageFramePhoto:
|
||||
// what does this one look like? TODO (in sync with the rest of the code)
|
||||
borderSize = _sizeForBorderType (NSNoBorder);
|
||||
break;
|
||||
case NSImageFrameGrayBezel:
|
||||
case NSImageFrameGroove:
|
||||
case NSImageFrameButton:
|
||||
borderSize = _sizeForBorderType (NSBezelBorder);
|
||||
break;
|
||||
}
|
||||
|
||||
borderSize = [[GSTheme theme] sizeForImageFrameStyle: _frameStyle];
|
||||
return NSInsetRect (theRect, borderSize.width, borderSize.height);
|
||||
}
|
||||
|
||||
|
|
|
@ -36,6 +36,7 @@
|
|||
#include "AppKit/NSPopUpButton.h"
|
||||
#include "AppKit/NSPopUpButtonCell.h"
|
||||
#include "AppKit/NSWindow.h"
|
||||
#include "GNUstepGUI/GSTheme.h"
|
||||
|
||||
/* The image to use in a specific popupbutton depends on type and
|
||||
* preferred edge; that is, _pbc_image[0] if it is a
|
||||
|
|
Loading…
Reference in a new issue