Okay, got that cleared up -- it has nothing to do with glyph stuff. Thanks
that has been eating at me for a while. Perhaps, if I could see what I am
doing wrong, I will become enlightened, but I am inclined to say that this
NSTextView implementation is stupid.
//BEGIN RANT//
First, I would like to know who at Apple came up with this brilliant idea?
I can hear it,
"Yeah, just design/program NSTextView to attach bmp, doc, rtfd, and
anything else with icons and filewrapper names. EXCEPT, yeah almost forgot,
make sure pdf and jpg files open in the view! Yeah, everybody'll love
that!"
//END RANT//
The implementation is very straightforward. An NSTextView in a MyDocument
that is setup as a delegate to MyDocument with an append file button. When
the user presses the append file button, the following code is executed....
most of which has already been pasted, but here it is for completeness
sake.
// BEGIN Another attempt at resolving jpg and pdf file attachment!
if ([filePath hasSuffix:@"jpg"] || [filePath hasSuffix:@"pdf"] ||
[filePath hasSuffix:@"jpeg"])
{
[theAttachment setAttachmentCell:bCell];
[bCell setAttachment:theAttachment];
}
// END Another attempt at resolving jpg and pdf file attachment
// New way using temporary directory
NSMutableString *myPath = [[[NSMutableString alloc]
initWithString:NSTemporaryDirectory()]autorelease];
[myPath appendString:[myFileWrapper preferredFilename]];
[projectFile createFileAtPath:myPath
contents:myData
attributes:nil];
[myWorkspace openFile:myPath];
}
///////////////// END CODE ////////////////////////
Just one more rant.... it is rediculous to have to go through so much to
disable such a feature. Where does one go to submit a Cocoa feature request
to have this disabled? Most implementors of NSTextView will NOT want a pdf
to display in a text view. Admittedly, some may.... those who are writing
PDF Viewers (like we need a dozen or so more of those) or parsing PDF
files, but the vast, vast majority of programmers do not want this. At the
very minimum, there should be a flag within NSTextView that programmers
flip with YES or NO to turn this feature off.
From: Douglas Davidson <email@hidden>
To: Kirt Cathey <email@hidden>
CC: email@hidden
Subject: Re: Disabling Display of JPG and PDF Files in NSTextView
Date: Wed, 14 Sep 2005 18:07:09 -0700
On Sep 14, 2005, at 2:40 PM, Kirt Cathey wrote:
First of all, thanks for helping out. Everything works without any
changes to the attachment cell, however, pdf and jpg do not appear
as icons -- they show up as opened images.
None of the text storage features are changed. Am just trying to
store those particular files as icons. Other files whose cells I do
not change -- Word, Excel -- work great.
I'm afraid I don't understand when you are calling this code, how
you are importing attachments into your text, how you are storing
your text, and so on. It's difficult to diagnose this without more
context.
As for glyphs, a glyph is a single displayable element in a
particular font. Glyphs often match up on a one-to-one basis with
characters, but not always--for example, the characters "fi" may be
displayed with a single fi ligature glyph in certain fonts; in some
cases a single character may require more than one glyph. In
addition, glyphs can be inserted without corresponding characters--
for example, hyphen glyphs in automatically hyphenated text.
The primary job of the text system is to convert the characters and
attributes in the text storage into a list of glyphs and positions
in the various text containers, so that the text views can be
displayed.
For most glyphs, we call upon Quartz to perform the display. In the
case of attachments, however, a placeholder glyph value
(NSControlGlyph) is used, and at display time the text attachment
cell is called upon to draw itself in the appropriate region.
None of this really has anything to do with how the text is saved;
that is entirely a function of the text storage.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden