[comp.sys.next] Give my application an icon!

stouder@cmu.unige.ch (09/27/90)

I want to give an icon to my application.
As I didn't use IB to define my application's interface,
all the things I've read about APPICON, ICONHEADER and MAKEFILE
didn't seem to work, or I must be wrong somewhere.
Yeah, NeXT time I'll use IB, but in the meantime I'll appreciate to
add an icon to my program so if anybody has a solution...
Thanks.

Alain Stouder, DMI, University of Geneva

wiml@milton.u.washington.edu (William Lewis) (09/29/90)

In article <71@cmu.unige.ch> stouder@cmu.unige.ch writes:
>I want to give an icon to my application.
>As I didn't use IB to define my application's interface,
>all the things I've read about APPICON, ICONHEADER and MAKEFILE
>didn't seem to work, or I must be wrong somewhere.
>Yeah, NeXT time I'll use IB, but in the meantime I'll appreciate to
>add an icon to my program so if anybody has a solution...

  Well, I've had strange problems getting icons into my app even *with*
IB, but this is what you have to do to get the workspace manager to
recognize an icon. (This is the same thing IB does, but automatically).
The WM looks in a segment of your executeable named __ICON (two leading
underscores) for the appropriate files. The main one is in the
section named "__header" and is what app.iconheader usually goes into.
I'm not 100% sure about the meaning of the fields in iconheader,
but it goes like this in my apps, usually:

F AppName AppName app

  (where AppName is the name of my app; the others are literals). They
might be tab-separated, check the docs. Anyway, the first field ("F")
says that this line specifies the main icon for the app, rather than
for its doc files, for instance. The last field, "app", is the name of the
icon to use. To include an icon just put it in its own section as 
a TIFF file. So, if the above line were saved in the file "icon_spec"
you'd compile (rather, link) like this:

  cc -o destfilename obj1.o obj2.o ... -segcreate __ICON __header icon_spec
-segcreate __ICON app my_wonderful_icon.tiff -lNeXT_s ... blah blah

The -segcreate flag takes the next three words as a segment, section
within the segment, and a file to place there. 	If you look at an IB-generated
makefile, you can see it's putting appname.iconheader into __ICON.header
and /usr/lib/nib/defaultAppIcon.tiff into __ICON.app.

  IMHO, this ability to stuff your own data into the executeable
is very handy, especially as all you have to do to change it is
relink, not recompile. For instance, you could throw the RTF for your
help file into segment __RTF, section HelpPanel, and to change it just
edit the file with edit and re-make. Such fun =8)


-- 
 wiml@milton.acs.washington.edu       Seattle, Washington   
     (William Lewis)   |  47 41' 15" N   122 42' 58" W  
"These 2 cents will cost the net thousands upon thousands of 
dollars to send everywhere. Are you sure you want to do this?"