Article View: comp.sys.next.programmer
Article #614Re: -=?=- dumping text into an invisible text object -=?=-
From: Charles Herrick
Date: Fri, 10 Apr 1992 18:31
Date: Fri, 10 Apr 1992 18:31
52 lines
2111 bytes
2111 bytes
Charles Herrick writes
> Bubalah's,
> I've got some email out on this, but it's driving me crazy so ...
well, so my good friend and mentor Scott Hess helped me fix my very bogus
code, and here is some code that works. It allows you to print a section
of text that you've selected in a Text object. Happy Hacking :-).
By the way,
docView = [myScrollView docView];
BEGIN--CUT HERE--
- print:sender {
// this works because of Scott Hess, bless him!!
// the MenuCell button with tag == 0 is the "Print All" menu button
if (![[sender selectedCell] tag])
[docView printPSCode:self];
else {
NXSelPt start, end;
int length;
[docView getSel:&start :&end];
length = end.cp - start.cp;
if (length) // something selected, print it {
id invisibleWindow;
static id textObject = nil;
NXStream *stream;
NXRect frameRect;
stream = NXOpenMemory(NULL,0,NX_READWRITE);
[docView writeRichText:stream from:start.cp to:end.cp];
[docView getFrame:&frameRect]; // gotta have a real frameRect
if (!textObject) {
// so it won't complain during lockFocus
invisibleWindow = [[Window alloc] init];
textObject = [[[[Text alloc]
initFrame:&frameRect]
setMonoFont:NO]
setVertResizable:YES];
[[invisibleWindow contentView] addSubview:textObject];
}
else
[textObject setFrame:&frameRect];
NXSeek(stream, 0, NX_FROMSTART); // rewind the stream
[textObject readRichText:stream];
NXClose(stream);
[textObject sizeToFit]; // adjust the frameRect
[textObject printPSCode:self];
}
}
return self;
}
END--CUT HERE--
Technical Details
Message-ID:
<12163@tamsun.tamu.edu>Path:
arc1-ca.pugleaf.net!sparky!news.UU.NET!ogicse!uwm.edu!cs.utexas.edu!tamsun!maraba.tamu.eduReferences:
<12092@tamsun.tamu.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!news.UU.NET!ogicse!uwm.edu!cs.utexas.edu!tamsun!maraba.tamu.edu From: cnh5730@maraba.tamu.edu (Charles Herrick) Newsgroups: comp.sys.next.programmer Subject: Re: -=?=- dumping text into an invisible text object -=?=- Message-ID: <12163@tamsun.tamu.edu> Date: 10 Apr 92 18:31:16 GMT Article-I.D.: tamsun.12163 References: <12092@tamsun.tamu.edu> Sender: usenet@tamsun.tamu.edu Lines: 52