mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-05-31 08:50:57 +00:00
Import testsuite
git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gui/trunk@32225 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
03bc4d79d6
commit
251b1edd94
23 changed files with 1991 additions and 0 deletions
69
Tests/gui/TextSystem/repeatedAttachmentCellHeight.m
Normal file
69
Tests/gui/TextSystem/repeatedAttachmentCellHeight.m
Normal file
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
copyright 2004 Alexander Malmberg <alexander@malmberg.org>
|
||||
|
||||
Check that the layour process doesn't get stuck if we try to make a cell fill
|
||||
the entire height of a line frag.
|
||||
*/
|
||||
|
||||
#include <Foundation/NSAutoreleasePool.h>
|
||||
#include <Foundation/NSString.h>
|
||||
#include <AppKit/NSApplication.h>
|
||||
#include <AppKit/NSAttributedString.h>
|
||||
#include <AppKit/NSLayoutManager.h>
|
||||
#include <AppKit/NSTextContainer.h>
|
||||
#include <AppKit/NSTextStorage.h>
|
||||
|
||||
@interface MyCell : NSTextAttachmentCell
|
||||
@end
|
||||
|
||||
@implementation MyCell
|
||||
|
||||
-(NSRect) cellFrameForTextContainer: (NSTextContainer *)textContainer
|
||||
proposedLineFragment: (NSRect)lineFrag
|
||||
glyphPosition: (NSPoint)p
|
||||
characterIndex: (unsigned int)charIndex
|
||||
{
|
||||
static int count;
|
||||
/* This should only be called once. */
|
||||
if (count)
|
||||
exit(1);
|
||||
count++;
|
||||
return NSMakeRect(0,-p.y,50,lineFrag.size.height);
|
||||
}
|
||||
|
||||
@end
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
unichar chars[4]={'a','b','c',NSAttachmentCharacter};
|
||||
CREATE_AUTORELEASE_POOL(arp);
|
||||
NSTextStorage *text;
|
||||
NSLayoutManager *lm;
|
||||
NSTextContainer *tc;
|
||||
NSTextAttachment *ta;
|
||||
|
||||
[NSApplication sharedApplication];
|
||||
|
||||
text=[[NSTextStorage alloc] init];
|
||||
lm=[[NSLayoutManager alloc] init];
|
||||
tc=[[NSTextContainer alloc] initWithContainerSize: NSMakeSize(500,5000)];
|
||||
[lm addTextContainer: tc];
|
||||
[text addLayoutManager: lm];
|
||||
|
||||
ta=[[NSTextAttachment alloc] init];
|
||||
[ta setAttachmentCell: [[MyCell alloc] init]];
|
||||
|
||||
[text beginEditing];
|
||||
[text appendAttributedString:
|
||||
[[NSAttributedString alloc] initWithString:
|
||||
[NSString stringWithCharacters: chars length: 4]]];
|
||||
[text addAttribute: NSAttachmentAttributeName
|
||||
value: ta
|
||||
range: NSMakeRange(3,1)];
|
||||
[text endEditing];
|
||||
[lm usedRectForTextContainer: tc];
|
||||
|
||||
DESTROY(arp);
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue