mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-23 02:04:20 +00:00
* Headers/AppKit/NSTextAttachment.h
* Source/NSTextAttachment.m: Use NSUInteger and bring closer to the Apple implementation. * Source/GSHorizontalTypesetter.m (-layoutLineNewParagraph:): For attachments use the cell origin y flipped. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@37704 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
0b26fec21a
commit
51c43eae39
4 changed files with 46 additions and 32 deletions
|
@ -1,3 +1,11 @@
|
|||
2014-02-23 Fred Kiefer <FredKiefer@gmx.de>
|
||||
|
||||
* Headers/AppKit/NSTextAttachment.h
|
||||
* Source/NSTextAttachment.m: Use NSUInteger and bring closer to
|
||||
the Apple implementation.
|
||||
* Source/GSHorizontalTypesetter.m (-layoutLineNewParagraph:): For
|
||||
attachments use the cell origin y flipped.
|
||||
|
||||
2014-02-20 18:48-EST Gregory John Casamento <greg.casamento@gmail.com>
|
||||
|
||||
* Source/NSWindow.m: (-setFrame:): Correct window resize when
|
||||
|
|
|
@ -72,10 +72,10 @@ enum {
|
|||
- (void)drawWithFrame:(NSRect)cellFrame inView:(NSView *)controlView;
|
||||
- (void)drawWithFrame:(NSRect)cellFrame
|
||||
inView:(NSView *)controlView
|
||||
characterIndex:(unsigned)charIndex;
|
||||
characterIndex:(NSUInteger)charIndex;
|
||||
- (void)drawWithFrame:(NSRect)cellFrame
|
||||
inView:(NSView *)controlView
|
||||
characterIndex:(unsigned)charIndex
|
||||
characterIndex:(NSUInteger)charIndex
|
||||
layoutManager:(NSLayoutManager *)layoutManager;
|
||||
- (void)highlight:(BOOL)flag
|
||||
withFrame:(NSRect)cellFrame
|
||||
|
@ -117,14 +117,14 @@ The class uses -cellSize and -cellBaselineOffset to return a rect.
|
|||
-(NSRect) cellFrameForTextContainer: (NSTextContainer *)textContainer
|
||||
proposedLineFragment: (NSRect)lineFrag
|
||||
glyphPosition: (NSPoint)position
|
||||
characterIndex: (unsigned int)charIndex;
|
||||
characterIndex: (NSUInteger)charIndex;
|
||||
|
||||
|
||||
- (BOOL)wantsToTrackMouse;
|
||||
- (BOOL)wantsToTrackMouseForEvent:(NSEvent *)theEvent
|
||||
inRect:(NSRect)cellFrame
|
||||
ofView:(NSView *)controlView
|
||||
atCharacterIndex:(unsigned)charIndex;
|
||||
atCharacterIndex:(NSUInteger)charIndex;
|
||||
- (BOOL)trackMouse:(NSEvent *)theEvent
|
||||
inRect:(NSRect)cellFrame
|
||||
ofView:(NSView *)controlView
|
||||
|
@ -132,7 +132,7 @@ The class uses -cellSize and -cellBaselineOffset to return a rect.
|
|||
- (BOOL)trackMouse:(NSEvent *)theEvent
|
||||
inRect:(NSRect)cellFrame
|
||||
ofView:(NSView *)controlView
|
||||
atCharacterIndex:(unsigned)charIndex
|
||||
atCharacterIndex:(NSUInteger)charIndex
|
||||
untilMouseUp:(BOOL)flag;
|
||||
- (void)setAttachment:(NSTextAttachment *)anObject;
|
||||
- (NSTextAttachment *)attachment;
|
||||
|
@ -153,6 +153,11 @@ The class uses -cellSize and -cellBaselineOffset to return a rect.
|
|||
@interface NSTextAttachment : NSObject <NSCoding> {
|
||||
NSFileWrapper *_fileWrapper;
|
||||
id <NSTextAttachmentCell>_cell;
|
||||
struct GSTextAttachmentFlagsType {
|
||||
// total 32 bits. 31 bits left.
|
||||
unsigned cell_explicitly_set: 1;
|
||||
unsigned unused:31;
|
||||
} _taflags;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -968,7 +968,7 @@ restart: ;
|
|||
|
||||
g->size = r.size;
|
||||
g->pos.x = p.x + r.origin.x;
|
||||
g->pos.y = p.y + r.origin.y;
|
||||
g->pos.y = p.y - r.origin.y;
|
||||
|
||||
p.x = g->pos.x + g->size.width;
|
||||
|
||||
|
|
|
@ -49,15 +49,16 @@
|
|||
|
||||
- (void)drawWithFrame: (NSRect)cellFrame
|
||||
inView: (NSView *)controlView
|
||||
characterIndex: (unsigned)charIndex
|
||||
characterIndex: (NSUInteger)charIndex
|
||||
{
|
||||
// cellFrame.origin.y -= cellFrame.size.height;
|
||||
[self drawWithFrame: cellFrame
|
||||
inView: controlView];
|
||||
}
|
||||
|
||||
- (void)drawWithFrame: (NSRect)cellFrame
|
||||
inView: (NSView *)controlView
|
||||
characterIndex: (unsigned)charIndex
|
||||
characterIndex: (NSUInteger)charIndex
|
||||
layoutManager: (NSLayoutManager *)layoutManager
|
||||
{
|
||||
[self drawWithFrame: cellFrame
|
||||
|
@ -73,7 +74,7 @@
|
|||
- (NSRect)cellFrameForTextContainer: (NSTextContainer *)textContainer
|
||||
proposedLineFragment: (NSRect)lineFrag
|
||||
glyphPosition: (NSPoint)position
|
||||
characterIndex: (unsigned)charIndex
|
||||
characterIndex: (NSUInteger)charIndex
|
||||
{
|
||||
NSRect aRect;
|
||||
|
||||
|
@ -90,7 +91,7 @@
|
|||
- (BOOL)wantsToTrackMouseForEvent: (NSEvent *)theEvent
|
||||
inRect: (NSRect)cellFrame
|
||||
ofView: (NSView *)controlView
|
||||
atCharacterIndex: (unsigned)charIndex
|
||||
atCharacterIndex: (NSUInteger)charIndex
|
||||
{
|
||||
return [self wantsToTrackMouse];
|
||||
}
|
||||
|
@ -154,7 +155,7 @@
|
|||
- (BOOL)trackMouse: (NSEvent *)theEvent
|
||||
inRect: (NSRect)cellFrame
|
||||
ofView: (NSView *)controlView
|
||||
atCharacterIndex: (unsigned)charIndex
|
||||
atCharacterIndex: (NSUInteger)charIndex
|
||||
untilMouseUp: (BOOL)flag
|
||||
{
|
||||
if ([controlView respondsToSelector: @selector(delegate)])
|
||||
|
@ -235,27 +236,8 @@
|
|||
|
||||
- (void)setAttachment: (NSTextAttachment *)anObject
|
||||
{
|
||||
NSFileWrapper *fileWrap = [anObject fileWrapper];
|
||||
|
||||
// Do not retain the attachment
|
||||
_attachment = anObject;
|
||||
|
||||
if (fileWrap != nil)
|
||||
{
|
||||
NSImage *icon = nil;
|
||||
NSString *fileName = [fileWrap filename];
|
||||
|
||||
if (fileName != nil)
|
||||
{
|
||||
// Try to set the image to the file wrapper content
|
||||
icon = [[NSImage alloc] initByReferencingFile: fileName];
|
||||
}
|
||||
if (icon == nil)
|
||||
icon = RETAIN([fileWrap icon]);
|
||||
|
||||
[self setImage: icon];
|
||||
RELEASE(icon);
|
||||
}
|
||||
}
|
||||
|
||||
- (NSTextAttachment *)attachment
|
||||
|
@ -307,9 +289,8 @@
|
|||
self = [super init];
|
||||
if (self != nil)
|
||||
{
|
||||
ASSIGN(_fileWrapper, fileWrapper);
|
||||
_cell = [[NSTextAttachmentCell alloc ] init];
|
||||
[_cell setAttachment: self];
|
||||
[self setFileWrapper: fileWrapper];
|
||||
}
|
||||
return self;
|
||||
}
|
||||
|
@ -322,6 +303,25 @@
|
|||
{
|
||||
[_cell setAttachment: self];
|
||||
}
|
||||
if (_taflags.cell_explicitly_set == 0)
|
||||
{
|
||||
if (fileWrapper != nil)
|
||||
{
|
||||
NSImage *icon = nil;
|
||||
NSString *fileName = [fileWrapper filename];
|
||||
|
||||
if (fileName != nil)
|
||||
{
|
||||
// Try to set the image to the file wrapper content
|
||||
icon = [[NSImage alloc] initByReferencingFile: fileName];
|
||||
}
|
||||
if (icon == nil)
|
||||
icon = RETAIN([fileWrapper icon]);
|
||||
|
||||
[(NSTextAttachmentCell*)_cell setImage: icon];
|
||||
RELEASE(icon);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
- (NSFileWrapper *)fileWrapper
|
||||
|
@ -337,6 +337,7 @@
|
|||
- (void)setAttachmentCell: (id <NSTextAttachmentCell>)cell
|
||||
{
|
||||
ASSIGN(_cell, cell);
|
||||
_taflags.cell_explicitly_set = 1;
|
||||
if ([_cell respondsToSelector: @selector(setAttachment:)] == YES)
|
||||
{
|
||||
[_cell setAttachment: self];
|
||||
|
|
Loading…
Reference in a new issue