Backports from trunk

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/branches/gnustep_stable_20070311@25792 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Adam Fedor 2007-12-27 16:28:44 +00:00
parent 3352a25907
commit 65fa5805e2
7 changed files with 891 additions and 786 deletions

View file

@ -1,3 +1,40 @@
2007-11-05 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSFont.m (-initWithName:matrix:fix:screenFont:role:): Add
fallback for missing standard fonts.
* Backport from trunk.
2007-11-03 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSControl.m,
* Source/NSMenuItem.m (-initWithCoder:, -encodeWithCoder:): Better
support for keyed encoding (Tag, separator,...).
* Backport from trunk.
2007-11-01 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSBrowser.m (+initialize): Create titleCell here to have
it available for browsers loaded from Gorm files.
* Source/NSBrowser.m (GSBrowserTitleCell): Add method
drawingRectForBounds: and correct drawWithFrame:inView:.
* Source/NSBrowser.m (-displayAllColumns, -displayColumn:): Mark
for redraw.
* Backport from trunk.
2007-11-01 Fred Kiefer <FredKiefer@gmx.de>
* Source/NSTableView.m (-draggingUpdated:): Use
currentDropOperation instead of NSTableViewDropAbove.
* Source/NSDocument.m (-windowForSheet): Return nil instead of
mainWindow, when there is no associated window.
Patches by Wolfgang Lux <wolfgang.lux@gmail.com>.
* Backport from trunk.
2007-10-30 Adam Fedor <fedor@gnu.org>
* gnustep-gui.spec.in: Change Copyright to License.
* Backport from trunk.
2007-10-29 Fred Kiefer <FredKiefer@gmx.de> 2007-10-29 Fred Kiefer <FredKiefer@gmx.de>
* COPYING: Add GPL file. * COPYING: Add GPL file.

View file

@ -200,16 +200,21 @@ static NSTextFieldCell *titleCell;
@end @end
@implementation GSBrowserTitleCell @implementation GSBrowserTitleCell
- (NSRect) drawingRectForBounds: (NSRect)theRect
{
// This adjustment must match the drawn border
return NSInsetRect(theRect, 2, 2);
}
- (void) drawWithFrame: (NSRect)cellFrame inView: (NSView*)controlView - (void) drawWithFrame: (NSRect)cellFrame inView: (NSView*)controlView
{ {
if (NSIsEmptyRect (cellFrame) || ![controlView window]) if (NSIsEmptyRect (cellFrame))
{ {
return; return;
} }
[[GSTheme theme] drawGrayBezel: cellFrame withClip: NSZeroRect]; [[GSTheme theme] drawGrayBezel: cellFrame withClip: NSZeroRect];
[self drawInteriorWithFrame: NSInsetRect(cellFrame, 1.0, 1.0) [self drawInteriorWithFrame: cellFrame inView: controlView];
inView: controlView];
} }
@end @end
@ -840,6 +845,7 @@ static NSTextFieldCell *titleCell;
- (void) displayAllColumns - (void) displayAllColumns
{ {
[self tile]; [self tile];
[self setNeedsDisplay: YES];
} }
/** <p>Updates the NSBrowser to display the column with the given index.</p> /** <p>Updates the NSBrowser to display the column with the given index.</p>
@ -856,13 +862,10 @@ static NSTextFieldCell *titleCell;
[self tile]; [self tile];
// Update and display title of column // Display title of column
if (_isTitled) if (_isTitled)
{ {
[self lockFocus]; [self setNeedsDisplayInRect: [self titleFrameOfColumn: column]];
[self drawTitleOfColumn: column
inRect: [self titleFrameOfColumn: column]];
[self unlockFocus];
} }
// Display column // Display column
@ -1247,8 +1250,8 @@ static NSTextFieldCell *titleCell;
} }
_separatesColumns = flag; _separatesColumns = flag;
[self setNeedsDisplay:YES];
[self tile]; [self tile];
[self setNeedsDisplay:YES];
} }
/**<p> Returns YES if the title of a column is set to the string value of /**<p> Returns YES if the title of a column is set to the string value of
@ -2065,6 +2068,11 @@ static NSTextFieldCell *titleCell;
// Initial version // Initial version
[self setVersion: 1]; [self setVersion: 1];
scrollerWidth = [NSScroller scrollerWidth]; scrollerWidth = [NSScroller scrollerWidth];
/* Create the shared titleCell if it hasn't been created already. */
if (!titleCell)
{
titleCell = [GSBrowserTitleCell new];
}
} }
} }
@ -2076,13 +2084,6 @@ static NSTextFieldCell *titleCell;
- (id) initWithFrame: (NSRect)rect - (id) initWithFrame: (NSRect)rect
{ {
NSSize bs; NSSize bs;
//NSScroller *hs;
/* Created the shared titleCell if it hasn't been created already. */
if (!titleCell)
{
titleCell = [GSBrowserTitleCell new];
}
self = [super initWithFrame: rect]; self = [super initWithFrame: rect];
@ -2597,16 +2598,7 @@ static NSTextFieldCell *titleCell;
NSString *title = [aDecoder decodeObjectForKey: @"NSFirstColumnTitle"]; NSString *title = [aDecoder decodeObjectForKey: @"NSFirstColumnTitle"];
NSString *sep = [aDecoder decodeObjectForKey: @"NSPathSeparator"]; NSString *sep = [aDecoder decodeObjectForKey: @"NSPathSeparator"];
long flags; long flags;
// start //
NSSize bs; NSSize bs;
//NSScroller *hs;
/* Created the shared titleCell if it hasn't been created already. */
if (!titleCell)
{
titleCell = [GSBrowserTitleCell new];
}
// Class setting // Class setting
_browserCellPrototype = [[[NSBrowser cellClass] alloc] init]; _browserCellPrototype = [[[NSBrowser cellClass] alloc] init];
@ -2999,7 +2991,6 @@ static NSTextFieldCell *titleCell;
inMatrix: matrix]; inMatrix: matrix];
} }
[sc setNeedsDisplay: YES];
[bc setIsLoaded: YES]; [bc setIsLoaded: YES];
if (column > _lastColumnLoaded) if (column > _lastColumnLoaded)
@ -3028,6 +3019,8 @@ static NSTextFieldCell *titleCell;
// Get the title even when untitled, as this may change later. // Get the title even when untitled, as this may change later.
[self setTitle: [self _getTitleOfColumn: column] ofColumn: column]; [self setTitle: [self _getTitleOfColumn: column] ofColumn: column];
// Mark for redisplay
[self displayColumn: column];
} }
/* Get the title of a column. */ /* Get the title of a column. */

View file

@ -911,6 +911,10 @@ static NSNotificationCenter *nc;
{ {
[aCoder encodeObject: [self cell] forKey: @"NSCell"]; [aCoder encodeObject: [self cell] forKey: @"NSCell"];
[aCoder encodeBool: [self isEnabled] forKey: @"NSEnabled"]; [aCoder encodeBool: [self isEnabled] forKey: @"NSEnabled"];
if (_tag)
{
[aCoder encodeInt: [self tag] forKey: @"NSTag"];
}
} }
else else
{ {
@ -936,6 +940,11 @@ static NSNotificationCenter *nc;
{ {
[self setEnabled: [aDecoder decodeBoolForKey: @"NSEnabled"]]; [self setEnabled: [aDecoder decodeBoolForKey: @"NSEnabled"]];
} }
if ([aDecoder containsValueForKey: @"NSTag"])
{
int tag = [aDecoder decodeIntForKey: @"NSTag"];
[self setTag: tag];
}
} }
else else
{ {

View file

@ -352,7 +352,7 @@ withContentsOfURL: (NSURL *)url
return win; return win;
} }
return [NSApp mainWindow]; return nil;
} }
/** /**

View file

@ -755,9 +755,38 @@ static void setNSFont(NSString *key, NSFont *font)
fontInfo = RETAIN([GSFontInfo fontInfoForFontName: fontName fontInfo = RETAIN([GSFontInfo fontInfoForFontName: fontName
matrix: fontMatrix matrix: fontMatrix
screenFont: screen]); screenFont: screen]);
cachedFlippedFont = placeHolder; if ((fontInfo == nil) && (aRole == RoleExplicit))
if (!screenFont) {
cachedScreenFont = placeHolder; /*
Last fallback: If a system font was explicitly requested
and this font does not exist, try to replace it with the
corresponding font in the current setup.
*/
if ([fontName isEqualToString: @"Helvetica"] &&
![font_roles[RoleSystemFont].defaultFont isEqualToString: @"Helvetica"])
{
fontInfo = RETAIN([GSFontInfo fontInfoForFontName:
font_roles[RoleSystemFont].defaultFont
matrix: fontMatrix
screenFont: screen]);
}
else if ([fontName isEqualToString: @"Helvetica-Bold"] &&
![font_roles[RoleBoldSystemFont].defaultFont isEqualToString: @"Helvetica-Bold"])
{
fontInfo = RETAIN([GSFontInfo fontInfoForFontName:
font_roles[RoleBoldSystemFont].defaultFont
matrix: fontMatrix
screenFont: screen]);
}
else if ([fontName isEqualToString: @"Courier"] &&
![font_roles[RoleUserFixedPitchFont].defaultFont isEqualToString: @"Courier"])
{
fontInfo = RETAIN([GSFontInfo fontInfoForFontName:
font_roles[RoleUserFixedPitchFont].defaultFont
matrix: fontMatrix
screenFont: screen]);
}
}
if (fontInfo == nil) if (fontInfo == nil)
{ {
DESTROY(fontName); DESTROY(fontName);
@ -796,9 +825,7 @@ static void setNSFont(NSString *key, NSFont *font)
RELEASE(fontName); RELEASE(fontName);
} }
TEST_RELEASE(fontInfo); TEST_RELEASE(fontInfo);
if (cachedFlippedFont != placeHolder)
DESTROY(cachedFlippedFont); DESTROY(cachedFlippedFont);
if (cachedScreenFont != placeHolder)
DESTROY(cachedScreenFont); DESTROY(cachedScreenFont);
[super dealloc]; [super dealloc];
} }
@ -858,7 +885,7 @@ static void setNSFont(NSString *key, NSFont *font)
- (NSFont *)_flippedViewFont - (NSFont *)_flippedViewFont
{ {
if (cachedFlippedFont == placeHolder) if (cachedFlippedFont == nil)
{ {
float fontMatrix[6]; float fontMatrix[6];
memcpy(fontMatrix, matrix, sizeof(matrix)); memcpy(fontMatrix, matrix, sizeof(matrix));
@ -978,7 +1005,7 @@ static BOOL flip_hack;
Note that if the font has no corresponding screen font, cachedScreenFont Note that if the font has no corresponding screen font, cachedScreenFont
will be set to nil. will be set to nil.
*/ */
if (cachedScreenFont == placeHolder) if (cachedScreenFont == nil)
cachedScreenFont = [placeHolder initWithName: fontName cachedScreenFont = [placeHolder initWithName: fontName
matrix: matrix matrix: matrix
fix: matrixExplicitlySet fix: matrixExplicitlySet

View file

@ -483,6 +483,10 @@ static Class imageClass;
{ {
if ([aCoder allowsKeyedCoding]) if ([aCoder allowsKeyedCoding])
{ {
if ([self isSeparatorItem])
{
[aCoder encodeBool: YES forKey: @"NSIsSeparator"];
}
[aCoder encodeObject: _title forKey: @"NSTitle"]; [aCoder encodeObject: _title forKey: @"NSTitle"];
[aCoder encodeObject: NSStringFromSelector(_action) forKey: @"NSAction"]; [aCoder encodeObject: NSStringFromSelector(_action) forKey: @"NSAction"];
[aCoder encodeObject: _keyEquivalent forKey: @"NSKeyEquiv"]; [aCoder encodeObject: _keyEquivalent forKey: @"NSKeyEquiv"];
@ -495,6 +499,11 @@ static Class imageClass;
[aCoder encodeInt: _keyEquivalentModifierMask forKey: @"NSKeyEquivModMask"]; [aCoder encodeInt: _keyEquivalentModifierMask forKey: @"NSKeyEquivModMask"];
[aCoder encodeInt: _mnemonicLocation forKey: @"NSMnemonicLoc"]; [aCoder encodeInt: _mnemonicLocation forKey: @"NSMnemonicLoc"];
[aCoder encodeInt: _state forKey: @"NSState"]; [aCoder encodeInt: _state forKey: @"NSState"];
[aCoder encodeBool: ![self isEnabled] forKey: @"NSIsDisabled"];
if (_tag)
{
[aCoder encodeInt: _tag forKey: @"NSTag"];
}
} }
else else
{ {
@ -529,28 +538,48 @@ static Class imageClass;
NSString *title; NSString *title;
NSString *action; NSString *action;
NSString *key; NSString *key;
NSImage *mixedImage; BOOL isSeparator = NO;
NSImage *onImage;
id target; if ([aDecoder containsValueForKey: @"NSIsSeparator"])
NSMenu *submenu; {
isSeparator = [aDecoder decodeBoolForKey: @"NSIsSeparator"];
}
if (isSeparator)
{
RELEASE(self);
return [NSMenuItem separatorItem];
}
title = [aDecoder decodeObjectForKey: @"NSTitle"]; title = [aDecoder decodeObjectForKey: @"NSTitle"];
action = [aDecoder decodeObjectForKey: @"NSAction"]; action = [aDecoder decodeObjectForKey: @"NSAction"];
key = [aDecoder decodeObjectForKey: @"NSKeyEquiv"]; key = [aDecoder decodeObjectForKey: @"NSKeyEquiv"];
mixedImage = [aDecoder decodeObjectForKey: @"NSMixedImage"];
onImage = [aDecoder decodeObjectForKey: @"NSOnImage"];
target = [aDecoder decodeObjectForKey: @"NSTarget"];
[aDecoder decodeObjectForKey: @"NSMenu"];
submenu = [aDecoder decodeObjectForKey: @"NSSubmenu"];
self = [self initWithTitle: title self = [self initWithTitle: title
action: NSSelectorFromString(action) action: NSSelectorFromString(action)
keyEquivalent: key]; keyEquivalent: key];
[self setTarget: target]; //[aDecoder decodeObjectForKey: @"NSMenu"];
[self setMixedStateImage: mixedImage];
[self setOnStateImage: onImage];
[self setSubmenu: submenu];
if ([aDecoder containsValueForKey: @"NSTarget"])
{
id target = [aDecoder decodeObjectForKey: @"NSTarget"];
[self setTarget: target];
}
if ([aDecoder containsValueForKey: @"NSMixedImage"])
{
NSImage *mixedImage = [aDecoder decodeObjectForKey: @"NSMixedImage"];
[self setMixedStateImage: mixedImage];
}
if ([aDecoder containsValueForKey: @"NSOnImage"])
{
NSImage *onImage = [aDecoder decodeObjectForKey: @"NSOnImage"];
[self setOnStateImage: onImage];
}
if ([aDecoder containsValueForKey: @"NSSubmenu"])
{
NSMenu *submenu = [aDecoder decodeObjectForKey: @"NSSubmenu"];
[self setSubmenu: submenu];
}
if ([aDecoder containsValueForKey: @"NSKeyEquivModMask"]) if ([aDecoder containsValueForKey: @"NSKeyEquivModMask"])
{ {
int keyMask = [aDecoder decodeIntForKey: @"NSKeyEquivModMask"]; int keyMask = [aDecoder decodeIntForKey: @"NSKeyEquivModMask"];
@ -566,6 +595,16 @@ static Class imageClass;
int state = [aDecoder decodeIntForKey: @"NSState"]; int state = [aDecoder decodeIntForKey: @"NSState"];
[self setState: state]; [self setState: state];
} }
if ([aDecoder containsValueForKey: @"NSIsDisabled"])
{
BOOL flag = [aDecoder decodeBoolForKey: @"NSIsDisabled"];
[self setEnabled: !flag];
}
if ([aDecoder containsValueForKey: @"NSTag"])
{
int tag = [aDecoder decodeIntForKey: @"NSTag"];
[self setTag: tag];
}
} }
else else
{ {

View file

@ -6237,7 +6237,7 @@ static BOOL selectContiguousRegion(NSTableView *self,
currentDragOperation = [_dataSource tableView: self currentDragOperation = [_dataSource tableView: self
validateDrop: sender validateDrop: sender
proposedRow: currentDropRow proposedRow: currentDropRow
proposedDropOperation: NSTableViewDropAbove]; proposedDropOperation: currentDropOperation];
} }
lastQuarterPosition = quarterPosition; lastQuarterPosition = quarterPosition;