Author: mlytwyn
Date: Wed Apr 6 20:44:24 2016
New Revision: 39633
URL: http://svn.gna.org/viewcvs/gnustep?rev=39633&view=rev
Log:
Merge with revision 39619 of GUI main branch
Modified:
libs/gui/branches/gnustep_testplant_branch/Source/NSAttributedString.m
libs/gui/branches/gnustep_testplant_branch/Source/NSBrowserCell.m
Modified: libs/gui/branches/gnustep_testplant_branch/Source/NSAttributedString.m
URL:
http://svn.gna.org/viewcvs/gnustep/libs/gui/branches/gnustep_testplant_branch/Source/NSAttributedString.m?rev=39633&r1=39632&r2=39633&view=diff
==============================================================================
--- libs/gui/branches/gnustep_testplant_branch/Source/NSAttributedString.m
(original)
+++ libs/gui/branches/gnustep_testplant_branch/Source/NSAttributedString.m
Wed Apr 6 20:44:24 2016
@@ -39,6 +39,7 @@
#import <Foundation/NSFileManager.h>
#import <Foundation/NSPathUtilities.h>
#import <Foundation/NSRange.h>
+#import <Foundation/NSSet.h>
#import <Foundation/NSString.h>
#import <Foundation/NSValue.h>
@@ -50,6 +51,7 @@
#import "AppKit/NSColor.h"
#import "AppKit/NSFileWrapper.h"
#import "AppKit/NSFont.h"
+#import "AppKit/NSFontDescriptor.h"
#import "AppKit/NSFontManager.h"
// For the colour name spaces
#import "AppKit/NSGraphics.h"
@@ -1519,9 +1521,20 @@
return nil;
}
+- (NSFontDescriptor*)_substituteFontDescriptorFor: (unichar)uchar
+{
+ NSString *chars = [NSString stringWithCharacters: &uchar length: 1];
+ NSCharacterSet *requiredCharacterSet = [NSCharacterSet
characterSetWithCharactersInString: chars];
+ NSDictionary *fontAttributes = [NSDictionary dictionaryWithObjectsAndKeys:
requiredCharacterSet, NSFontCharacterSetAttribute, nil];
+ NSSet *mandatoryKeys = [NSSet setWithObjects: NSFontCharacterSetAttribute,
nil];
+ NSFontDescriptor *fd = [NSFontDescriptor fontDescriptorWithFontAttributes:
fontAttributes];
+ return [fd matchingFontDescriptorWithMandatoryKeys: mandatoryKeys];
+}
+
- (NSFont*)_substituteFontFor: (unichar)uchar font: (NSFont*)baseFont
{
NSFont *subFont;
+ NSFontDescriptor *descriptor;
// Caching one font may lead to the selected substitution font not being
// from the prefered list, although there is one there with this character.
@@ -1538,6 +1551,22 @@
return subFont;
}
+ // Fast way with font descriptors
+ descriptor = [self _substituteFontDescriptorFor: uchar];
+ if (descriptor != nil)
+ {
+ NSCharacterSet *newSet = [descriptor objectForKey:
NSFontCharacterSetAttribute];
+ if ([newSet characterIsMember: uchar])
+ {
+ NSString *fName = [descriptor objectForKey: NSFontFamilyAttribute];
+
+ ASSIGN(lastFont, fName);
+ ASSIGN(lastSet, newSet);
+ return [self _substituteFontWithName: fName font: baseFont];
+ }
+ }
+
+
subFont = [self _substituteFontFor: uchar font: baseFont fromList:
[[NSFontManager sharedFontManager] availableFonts]];
if (subFont != nil)
Modified: libs/gui/branches/gnustep_testplant_branch/Source/NSBrowserCell.m
URL:
http://svn.gna.org/viewcvs/gnustep/libs/gui/branches/gnustep_testplant_branch/Source/NSBrowserCell.m?rev=39633&r1=39632&r2=39633&view=diff
==============================================================================
--- libs/gui/branches/gnustep_testplant_branch/Source/NSBrowserCell.m
(original)
+++ libs/gui/branches/gnustep_testplant_branch/Source/NSBrowserCell.m Wed Apr
6 20:44:24 2016
@@ -40,13 +40,11 @@
#import "AppKit/NSEvent.h"
#import "AppKit/NSWindow.h"
#import "GSGuiPrivate.h"
+#import "GNUstepGUI/GSTheme.h"
/*
* Class variables
*/
-static NSImage *_branch_image;
-static NSImage *_highlight_image;
-
static Class _colorClass;
// GNUstep user default to have NSBrowserCell in bold if non leaf
@@ -66,8 +64,6 @@
if (self == [NSBrowserCell class])
{
[self setVersion: 1];
- ASSIGN(_branch_image, [NSImage imageNamed: @"common_3DArrowRight"]);
- ASSIGN(_highlight_image, [NSImage imageNamed: @"common_3DArrowRightH"]);
/*
* Cache classes to avoid overheads of poor compiler implementation.
@@ -90,7 +86,7 @@
*/
+ (NSImage*) branchImage
{
- return _branch_image;
+ return [[GSTheme theme] branchImage];
}
/**<p>Returns the default hightlited branch image</p>
@@ -98,7 +94,7 @@
*/
+ (NSImage*) highlightedBranchImage
{
- return _highlight_image;
+ return [[GSTheme theme] highlightedBranchImage];
}
/*
@@ -330,93 +326,15 @@
*/
- (void) drawInteriorWithFrame: (NSRect)cellFrame inView: (NSView *)controlView
{
- NSRect title_rect = cellFrame;
- NSImage *branch_image = nil;
- NSImage *cell_image = [self image];
-
- if (_cell.is_highlighted || _cell.state)
- {
- if (!_browsercell_is_leaf)
- branch_image = [object_getClass(self) highlightedBranchImage];
- if (nil != [self alternateImage])
- cell_image = [self alternateImage];
-
- // If we are highlighted, fill the background
- [[self highlightColorInView: controlView] setFill];
- NSRectFill(cellFrame);
- }
- else
- {
- if (!_browsercell_is_leaf)
- branch_image = [object_getClass(self) branchImage];
-
- // (Don't fill the background)
- }
-
- // Draw the branch image if there is one
- if (branch_image)
- {
- NSRect imgRect;
-
- imgRect.size = [branch_image size];
- imgRect.origin.x = MAX(NSMaxX(title_rect) - imgRect.size.width - 4.0,
0.);
- imgRect.origin.y = MAX(NSMidY(title_rect) - (imgRect.size.height/2.),
0.);
-
- if (controlView != nil)
- {
- imgRect = [controlView centerScanRect: imgRect];
- }
-
- [branch_image drawInRect: imgRect
- fromRect: NSZeroRect
- operation: NSCompositeSourceOver
- fraction: 1.0
- respectFlipped: YES
- hints: nil];
-
- title_rect.size.width -= imgRect.size.width + 8;
- }
-
- // Skip 2 points from the left border
- title_rect.origin.x += 2;
- title_rect.size.width -= 2;
-
- // Draw the cell image if there is one
- if (cell_image)
- {
- NSRect imgRect;
-
- imgRect.size = [cell_image size];
- imgRect.origin.x = NSMinX(title_rect);
- imgRect.origin.y = MAX(NSMidY(title_rect) - (imgRect.size.height/2.),0.);
-
- if (controlView != nil)
- {
- imgRect = [controlView centerScanRect: imgRect];
- }
-
- [cell_image drawInRect: imgRect
- fromRect: NSZeroRect
- operation: NSCompositeSourceOver
- fraction: 1.0
- respectFlipped: YES
- hints: nil];
-
- title_rect.origin.x += imgRect.size.width + 4;
- title_rect.size.width -= imgRect.size.width + 4;
- }
-
- // Draw the body of the cell
- if (_cell.in_editing)
- {
- [self _drawEditorWithFrame: cellFrame inView: controlView];
- }
- else
- {
- [self _drawAttributedText: [self attributedStringValue]
- inFrame: title_rect];
- }
-}
+ [[GSTheme theme] drawBrowserInteriorWithFrame: cellFrame
+ withCell: self
+ inView: controlView
+ withImage: [self image]
+ alternateImage: [self alternateImage]
+ isHighlighted: [self isHighlighted]
+ state: [self state]
+ isLeaf: [self isLeaf]];
+ }
/*
* NSCoding protocol
_______________________________________________
Gnustep-cvs mailing list
[email protected]
https://mail.gna.org/listinfo/gnustep-cvs