mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-20 22:06:42 +00:00
* Source/GSFontInfo.m (-defaultLineHeightForFont): Adjust line
height calculation. * Source/NSButtonCell.m (-drawInteriorWithFrame:inView:): Always initialize imageRect and titleRect. Adjust the calculations to match the new line height. (-cellSize): Always initialize imageRect and titleRect. * Headers/AppKit/NSCell.h (-_drawImage:inFrame:isFlipped:): Remove. * Source/NSCell.m (-_drawImage:inFrame:isFlipped:): Remove. Move code back ... (-drawInteriorWithFrame:inView:): ... here. * Source/NSToolbarItem.m (+initialize): Remove. (+cellClass): Add. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@20100 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
e2e0084fdb
commit
811ae4cf9f
6 changed files with 69 additions and 50 deletions
15
ChangeLog
15
ChangeLog
|
@ -1,3 +1,18 @@
|
||||||
|
2004-09-21 18:53 Alexander Malmberg <alexander@malmberg.org>
|
||||||
|
|
||||||
|
* Source/GSFontInfo.m (-defaultLineHeightForFont): Adjust line
|
||||||
|
height calculation.
|
||||||
|
* Source/NSButtonCell.m (-drawInteriorWithFrame:inView:): Always
|
||||||
|
initialize imageRect and titleRect. Adjust the calculations to match
|
||||||
|
the new line height.
|
||||||
|
(-cellSize): Always initialize imageRect and titleRect.
|
||||||
|
* Headers/AppKit/NSCell.h (-_drawImage:inFrame:isFlipped:): Remove.
|
||||||
|
* Source/NSCell.m (-_drawImage:inFrame:isFlipped:): Remove. Move code
|
||||||
|
back ...
|
||||||
|
(-drawInteriorWithFrame:inView:): ... here.
|
||||||
|
* Source/NSToolbarItem.m (+initialize): Remove.
|
||||||
|
(+cellClass): Add.
|
||||||
|
|
||||||
2004-09-18 15:15 Alexander Malmberg <alexander@malmberg.org>
|
2004-09-18 15:15 Alexander Malmberg <alexander@malmberg.org>
|
||||||
|
|
||||||
* Source/GSServicesManager.m (_serviceFromAnyLocalizedTitle): Rename
|
* Source/GSServicesManager.m (_serviceFromAnyLocalizedTitle): Rename
|
||||||
|
|
|
@ -454,8 +454,6 @@ typedef enum _NSControlSize {
|
||||||
- (void) _drawText: (NSString*)aString inFrame: (NSRect)cellFrame;
|
- (void) _drawText: (NSString*)aString inFrame: (NSRect)cellFrame;
|
||||||
- (void) _drawAttributedText: (NSAttributedString*)aString
|
- (void) _drawAttributedText: (NSAttributedString*)aString
|
||||||
inFrame: (NSRect)aRect;
|
inFrame: (NSRect)aRect;
|
||||||
- (void) _drawImage: (NSImage *)anImage inFrame: (NSRect)aRect
|
|
||||||
isFlipped: (BOOL)flipped;
|
|
||||||
- (BOOL) _sendsActionOn:(int)eventTypeMask;
|
- (BOOL) _sendsActionOn:(int)eventTypeMask;
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
|
@ -425,15 +425,17 @@ static GSFontEnumerator *sharedEnumerator = nil;
|
||||||
- (float) defaultLineHeightForFont
|
- (float) defaultLineHeightForFont
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
Generally, roman text is centered in the line disregarding the descender,
|
In the absence of a more accurate line height from the font itself, we
|
||||||
and the descender height is added above and below. Thus, the line height
|
use ascender_height+descender_height (note that descender is negative
|
||||||
should be ascender_height+2*descender_height. (Note that descender is
|
below the baseline). This matches what other systems do, and it matches
|
||||||
negative below the baseline.)
|
the font-provided line height in most cases. (Note that the ascender
|
||||||
|
height usually includes a bit of space above the top of the actual
|
||||||
|
glyphs, so we get some inter-line spacing anyway.)
|
||||||
|
|
||||||
This calculation should match the baseline calculation in
|
This calculation should match the baseline calculation in
|
||||||
GSHorizontalTypesetter, or text will look odd.
|
GSHorizontalTypesetter, or text will look odd.
|
||||||
*/
|
*/
|
||||||
return [self ascender] - 2 * [self descender];
|
return [self ascender] - [self descender];
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSSize) advancementForGlyph: (NSGlyph)aGlyph
|
- (NSSize) advancementForGlyph: (NSGlyph)aGlyph
|
||||||
|
|
|
@ -353,12 +353,12 @@
|
||||||
/*
|
/*
|
||||||
* Setting the Images
|
* Setting the Images
|
||||||
*/
|
*/
|
||||||
- (NSImage*) alternateImage
|
- (NSImage*) alternateImage
|
||||||
{
|
{
|
||||||
return _altImage;
|
return _altImage;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSCellImagePosition) imagePosition
|
- (NSCellImagePosition) imagePosition
|
||||||
{
|
{
|
||||||
return _cell.image_position;
|
return _cell.image_position;
|
||||||
}
|
}
|
||||||
|
@ -434,7 +434,7 @@
|
||||||
return _buttoncell_is_transparent;
|
return _buttoncell_is_transparent;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) setTransparent: (BOOL)flag
|
- (void) setTransparent: (BOOL)flag
|
||||||
{
|
{
|
||||||
_buttoncell_is_transparent = flag;
|
_buttoncell_is_transparent = flag;
|
||||||
}
|
}
|
||||||
|
@ -907,9 +907,11 @@
|
||||||
*/
|
*/
|
||||||
switch (ipos)
|
switch (ipos)
|
||||||
{
|
{
|
||||||
|
default:
|
||||||
case NSNoImage:
|
case NSNoImage:
|
||||||
imageToDisplay = nil;
|
imageToDisplay = nil;
|
||||||
titleRect = cellFrame;
|
titleRect = cellFrame;
|
||||||
|
imageRect = NSZeroRect;
|
||||||
if (titleSize.width + 6 <= titleRect.size.width)
|
if (titleSize.width + 6 <= titleRect.size.width)
|
||||||
{
|
{
|
||||||
titleRect.origin.x += 3;
|
titleRect.origin.x += 3;
|
||||||
|
@ -920,6 +922,7 @@
|
||||||
case NSImageOnly:
|
case NSImageOnly:
|
||||||
titleToDisplay = nil;
|
titleToDisplay = nil;
|
||||||
imageRect = cellFrame;
|
imageRect = cellFrame;
|
||||||
|
titleRect = NSZeroRect;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NSImageLeft:
|
case NSImageLeft:
|
||||||
|
@ -949,7 +952,8 @@
|
||||||
imageRect.origin.x -= 3;
|
imageRect.origin.x -= 3;
|
||||||
}
|
}
|
||||||
titleRect.origin = cellFrame.origin;
|
titleRect.origin = cellFrame.origin;
|
||||||
titleRect.size.width = imageRect.origin.x - titleRect.origin.x - GSCellTextImageXDist;
|
titleRect.size.width = imageRect.origin.x - titleRect.origin.x
|
||||||
|
- GSCellTextImageXDist;
|
||||||
titleRect.size.height = cellFrame.size.height;
|
titleRect.size.height = cellFrame.size.height;
|
||||||
if (titleSize.width + 3 <= titleRect.size.width)
|
if (titleSize.width + 3 <= titleRect.size.width)
|
||||||
{
|
{
|
||||||
|
@ -964,19 +968,22 @@
|
||||||
* above the text.
|
* above the text.
|
||||||
* The drawing code below will then center the image in imageRect.
|
* The drawing code below will then center the image in imageRect.
|
||||||
*/
|
*/
|
||||||
titleRect.origin.x = cellFrame.origin.x;
|
titleRect.origin = cellFrame.origin;
|
||||||
titleRect.origin.y = cellFrame.origin.y + GSCellTextImageYDist;
|
|
||||||
titleRect.size.width = cellFrame.size.width;
|
titleRect.size.width = cellFrame.size.width;
|
||||||
titleRect.size.height = titleSize.height;
|
titleRect.size.height = titleSize.height;
|
||||||
|
if (_cell.is_bordered || _cell.is_bezeled)
|
||||||
|
{
|
||||||
|
titleRect.origin.y += 3;
|
||||||
|
}
|
||||||
|
|
||||||
imageRect.origin.x = cellFrame.origin.x;
|
imageRect.origin.x = cellFrame.origin.x;
|
||||||
imageRect.origin.y = NSMaxY(titleRect);
|
imageRect.origin.y = NSMaxY(titleRect) + GSCellTextImageYDist;
|
||||||
imageRect.size.width = cellFrame.size.width;
|
imageRect.size.width = cellFrame.size.width;
|
||||||
imageRect.size.height = NSMaxY(cellFrame) - imageRect.origin.y;
|
imageRect.size.height = NSMaxY(cellFrame) - imageRect.origin.y;
|
||||||
|
|
||||||
if (_cell.is_bordered || _cell.is_bezeled)
|
if (_cell.is_bordered || _cell.is_bezeled)
|
||||||
{
|
{
|
||||||
imageRect.origin.y -= 1;
|
imageRect.size.height -= 3;
|
||||||
}
|
}
|
||||||
if (titleSize.width + 6 <= titleRect.size.width)
|
if (titleSize.width + 6 <= titleRect.size.width)
|
||||||
{
|
{
|
||||||
|
@ -995,6 +1002,10 @@
|
||||||
titleRect.origin.y = NSMaxY(cellFrame) - titleSize.height;
|
titleRect.origin.y = NSMaxY(cellFrame) - titleSize.height;
|
||||||
titleRect.size.width = cellFrame.size.width;
|
titleRect.size.width = cellFrame.size.width;
|
||||||
titleRect.size.height = titleSize.height;
|
titleRect.size.height = titleSize.height;
|
||||||
|
if (_cell.is_bordered || _cell.is_bezeled)
|
||||||
|
{
|
||||||
|
titleRect.origin.y -= 3;
|
||||||
|
}
|
||||||
|
|
||||||
imageRect.origin.x = cellFrame.origin.x;
|
imageRect.origin.x = cellFrame.origin.x;
|
||||||
imageRect.origin.y = cellFrame.origin.y;
|
imageRect.origin.y = cellFrame.origin.y;
|
||||||
|
@ -1003,7 +1014,8 @@
|
||||||
|
|
||||||
if (_cell.is_bordered || _cell.is_bezeled)
|
if (_cell.is_bordered || _cell.is_bezeled)
|
||||||
{
|
{
|
||||||
imageRect.origin.y += 1;
|
imageRect.origin.y += 3;
|
||||||
|
imageRect.size.height -= 3;
|
||||||
}
|
}
|
||||||
if (titleSize.width + 6 <= titleRect.size.width)
|
if (titleSize.width + 6 <= titleRect.size.width)
|
||||||
{
|
{
|
||||||
|
@ -1028,7 +1040,7 @@
|
||||||
{
|
{
|
||||||
[self drawGradientWithFrame: cellFrame inView: controlView];
|
[self drawGradientWithFrame: cellFrame inView: controlView];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw image
|
// Draw image
|
||||||
if (imageToDisplay != nil)
|
if (imageToDisplay != nil)
|
||||||
{
|
{
|
||||||
|
@ -1105,6 +1117,7 @@
|
||||||
|
|
||||||
switch (_cell.image_position)
|
switch (_cell.image_position)
|
||||||
{
|
{
|
||||||
|
default:
|
||||||
case NSNoImage:
|
case NSNoImage:
|
||||||
s = titleSize;
|
s = titleSize;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -889,7 +889,7 @@ static NSColor *shadowCol;
|
||||||
return textObject;
|
return textObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (NSString*) title
|
- (NSString*) title
|
||||||
{
|
{
|
||||||
return [self stringValue];
|
return [self stringValue];
|
||||||
}
|
}
|
||||||
|
@ -1670,21 +1670,34 @@ static NSColor *shadowCol;
|
||||||
switch (_cell.type)
|
switch (_cell.type)
|
||||||
{
|
{
|
||||||
case NSTextCellType:
|
case NSTextCellType:
|
||||||
[self _drawAttributedText: [self attributedStringValue]
|
{
|
||||||
inFrame: cellFrame];
|
[self _drawAttributedText: [self attributedStringValue]
|
||||||
|
inFrame: cellFrame];
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case NSImageCellType:
|
case NSImageCellType:
|
||||||
if (_cell_image)
|
if (_cell_image)
|
||||||
{
|
{
|
||||||
[self _drawImage: _cell_image
|
NSSize size;
|
||||||
inFrame: cellFrame
|
NSPoint position;
|
||||||
isFlipped: [controlView isFlipped]];
|
|
||||||
}
|
size = [_cell_image size];
|
||||||
break;
|
position.x = MAX(NSMidX(cellFrame) - (size.width/2.),0.);
|
||||||
|
position.y = MAX(NSMidY(cellFrame) - (size.height/2.),0.);
|
||||||
|
/*
|
||||||
|
* Images are always drawn with their bottom-left corner
|
||||||
|
* at the origin so we must adjust the position to take
|
||||||
|
* account of a flipped view.
|
||||||
|
*/
|
||||||
|
if ([controlView isFlipped])
|
||||||
|
position.y += size.height;
|
||||||
|
[_cell_image compositeToPoint: position operation: NSCompositeSourceOver];
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case NSNullCellType:
|
case NSNullCellType:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_cell.shows_first_responder)
|
if (_cell.shows_first_responder)
|
||||||
|
@ -2199,27 +2212,6 @@ static NSColor *shadowCol;
|
||||||
RELEASE (attributes);
|
RELEASE (attributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
- (void) _drawImage: (NSImage *)anImage inFrame: (NSRect)aRect
|
|
||||||
isFlipped: (BOOL)flipped
|
|
||||||
{
|
|
||||||
NSSize size;
|
|
||||||
NSPoint position;
|
|
||||||
|
|
||||||
size = [anImage size];
|
|
||||||
position.x = MAX(NSMidX(aRect) - (size.width/2.),0.);
|
|
||||||
position.y = MAX(NSMidY(aRect) - (size.height/2.),0.);
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Images are always drawn with their bottom-left corner
|
|
||||||
* at the origin so we must adjust the position to take
|
|
||||||
* account of a flipped view.
|
|
||||||
*/
|
|
||||||
if (flipped)
|
|
||||||
position.y += size.height;
|
|
||||||
|
|
||||||
[anImage compositeToPoint: position operation: NSCompositeSourceOver];
|
|
||||||
}
|
|
||||||
|
|
||||||
- (BOOL) _sendsActionOn:(int)eventTypeMask
|
- (BOOL) _sendsActionOn:(int)eventTypeMask
|
||||||
{
|
{
|
||||||
return (_action_mask & eventTypeMask);
|
return (_action_mask & eventTypeMask);
|
||||||
|
|
|
@ -145,10 +145,9 @@ NSString *GSMovableToolbarItemPboardType = @"GSMovableToolbarItemPboardType";
|
||||||
// ---
|
// ---
|
||||||
|
|
||||||
@implementation GSToolbarButton
|
@implementation GSToolbarButton
|
||||||
+ (void) initialize
|
+ (Class) cellClass
|
||||||
{
|
{
|
||||||
if (self == [GSToolbarButton class])
|
return [GSToolbarButtonCell class];
|
||||||
[GSToolbarButton setCellClass: [GSToolbarButtonCell class]];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
- (id) initWithToolbarItem: (NSToolbarItem *)toolbarItem
|
- (id) initWithToolbarItem: (NSToolbarItem *)toolbarItem
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue