home *** CD-ROM | disk | FTP | other *** search
/ ftp.mactech.com 2010 / ftp.mactech.com.tar / ftp.mactech.com / csmpdigest / csmp-digest-v3-033 < prev    next >
Text File  |  2010-09-21  |  80KB  |  2,234 lines

  1. Received-Date: Thu, 9 Jun 1994 15:14:41 +0200
  2. From: pottier@clipper.ens.fr (Francois Pottier)
  3. Subject: csmp-digest-v3-033
  4. To: csmp-digest@ens.fr
  5. Date: Thu, 9 Jun 94 15:14:29 MET DST
  6. X-Mailer: ELM [version 2.3 PL11]
  7. Errors-To: listman@ens.fr
  8. Reply-To: pottier@clipper.ens.fr
  9. X-Sequence: 36
  10.  
  11. C.S.M.P. Digest             Thu, 09 Jun 94       Volume 3 : Issue 33
  12.  
  13. Today's Topics:
  14.  
  15.         (Summary) Flicker-Free Grey Rectange Dragging (w-code)
  16.         68K drivers, PPC completion routines: HOW?
  17.         Audio CD Configuration
  18.         Compression Manager help!
  19.         Fastest way to draw a line?
  20.         Finding application & document folders???
  21.         How to make a window "float" over other apps?
  22.         Installing Gestalts -- how to set up A5 world?
  23.         Looking for C code to display color PICT files
  24.         Palette updates??
  25.         PenPat((ConstPatternParam)gray) - why illegal cast?
  26.         SC++ and __vtbl?
  27.  
  28.  
  29.  
  30. The Comp.Sys.Mac.Programmer Digest is moderated by Francois Pottier
  31. (pottier@clipper.ens.fr).
  32.  
  33. The digest is a collection of article threads from the internet newsgroup
  34. comp.sys.mac.programmer.  It is designed for people who read c.s.m.p. semi-
  35. regularly and want an archive of the discussions.  If you don't know what a
  36. newsgroup is, you probably don't have access to it.  Ask your systems
  37. administrator(s) for details.  If you don't have access to news, you may
  38. still be able to post messages to the group by using a mail server like
  39. anon.penet.fi (mail help@anon.penet.fi for more information).
  40.  
  41. Each issue of the digest contains one or more sets of articles (called
  42. threads), with each set corresponding to a 'discussion' of a particular
  43. subject.  The articles are not edited; all articles included in this digest
  44. are in their original posted form (as received by our news server at
  45. nef.ens.fr).  Article threads are not added to the digest until the last
  46. article added to the thread is at least two weeks old (this is to ensure that
  47. the thread is dead before adding it to the digest).  Article threads that
  48. consist of only one message are generally not included in the digest.
  49.  
  50. The digest is officially distributed by two means, by email and ftp.
  51.  
  52. If you want to receive the digest by mail, send email to listserv@ens.fr
  53. with no subject and one of the following commands as body:
  54.     help                        Sends you a summary of commands
  55.     subscribe csmp-digest Your Name    Adds you to the mailing list
  56.     signoff csmp-digest            Removes you from the list
  57. Once you have subscribed, you will automatically receive each new
  58. issue as it is created.
  59.  
  60. The official ftp info is //ftp.dartmouth.edu/pub/csmp-digest.
  61. Questions related to the ftp site should be directed to
  62. scott.silver@dartmouth.edu. Currently no previous volumes of the CSMP
  63. digest are available there.
  64.  
  65. Also, the digests are available to WAIS users.  To search back issues
  66. with WAIS, use comp.sys.mac.programmer.src. With Mosaic, use
  67. http://www.wais.com/wais-dbs/comp.sys.mac.programmer.html.
  68.  
  69.  
  70. -------------------------------------------------------
  71.  
  72. >From squeegee@world.std.com (Stephen C. Gilardi)
  73. Subject: (Summary) Flicker-Free Grey Rectange Dragging (w-code)
  74. Date: Wed, 18 May 1994 23:07:25 GMT
  75. Organization: SQ Software via The World Public Access UNIX, Brookline, MA
  76.  
  77. Based on replies here, especially the one from Dean Yu, I have accomplished
  78. decent flicker-free dragging of a grey rectangle.  It still exhibits the 
  79. "cursor flicker in certain horizontal screen bands" problem, but to a much
  80. smaller degree than the code I originally posted.  I've noticed since then
  81. that Finder's selection rectangle, and the Drag Manager's grey rect dragging
  82. also exhibit the same cursor flicker to roughly the same extent as the code
  83. here.
  84.  
  85. I experimented with a VBL task (SlotVInstall).  It's complicated because
  86. one must install the task and make sure it is removed even if the application
  87. exits abnormally. This implies installing a patch on ExitToShell, etc.
  88. Also, the quality of the cursor tracking isn't acceptable (to me).  I read
  89. an article in develop that said that generally waiting for vbl isn't a good
  90. idea.  The author said for example that QuickTime doesn't sync to VBL.
  91.  
  92. Enclosed below is the code which I find acceptable.  It's a TCL (2.0)
  93. CPane::DoClick method.  Incorporate this into a "Nothing" TCL application
  94. (arrange for a DragPane to be displayed in a window).  Click and drag to
  95. see good dragging using Regions in action.  Option-Click and drag to see a
  96. simpler FrameRect-based algorithm.  The code is set up to use the simpler
  97. method if it can't get memory go allocate a region (probably overkill).
  98.  
  99. Thank you all very much for your help!
  100.  
  101. --Steve
  102.  
  103. Stephen C. Gilardi
  104. SQ Software
  105. squeegee@world.std.com
  106.  
  107. /* start of code */
  108.  
  109. extern RgnHandle gUtilRgn;
  110.  
  111. void    CDragPane::DoClick(
  112.     Point       hitPt,
  113.     short       modifierKeys,
  114.     long        when)
  115. {
  116.     Rect                dragRect;
  117.     Boolean             tryRegions;
  118.     RgnHandle           dragRgn;
  119.     Point               oldPt;
  120.     Boolean             savedAlloc;
  121.  
  122.     tryRegions = (modifierKeys & optionKey) ? false : true;
  123.  
  124.     PenNormal();
  125.     PenPat(&QDGLOBALS(gray));
  126.     PenMode(notPatXor);
  127.  
  128.     SetRect(&dragRect, 0, 0, 100, 100);
  129.  
  130.     OffsetRect(&dragRect, hitPt.h, hitPt.v);
  131.  
  132.     oldPt = hitPt;
  133.  
  134.     if (tryRegions) {
  135.         savedAlloc = SetAllocation(kAllocCanFail);
  136.         dragRgn = NewRgn();
  137.         SetAllocation(savedAlloc);
  138.     }
  139.     else
  140.         dragRgn = NULL;
  141.  
  142.     if (dragRgn) {
  143.         RectRgn(dragRgn, &dragRect);
  144.         CopyRgn(dragRgn, gUtilRgn);
  145.         InsetRgn(gUtilRgn, 1, 1);
  146.         DiffRgn(dragRgn, gUtilRgn, dragRgn);
  147.         PaintRgn(dragRgn);
  148.     }
  149.     else
  150.         FrameRect(&dragRect);
  151.  
  152.     while (WaitMouseUp()) {
  153.     
  154.         GetMouse(&hitPt);
  155.  
  156.         if (oldPt.h != hitPt.h || oldPt.v != hitPt.v) {
  157.  
  158.             if (dragRgn) {
  159.                 CopyRgn(dragRgn, gUtilRgn);
  160.                 OffsetRgn(gUtilRgn, hitPt.h - oldPt.h, hitPt.v - oldPt.v);
  161.                 XorRgn(dragRgn, gUtilRgn, dragRgn);
  162.                 PaintRgn(dragRgn);
  163.                 CopyRgn(gUtilRgn, dragRgn);
  164.             }
  165.             else {
  166.                 FrameRect(&dragRect);
  167.                 OffsetRect(&dragRect, hitPt.h - oldPt.h, hitPt.v - oldPt.v);
  168.                 FrameRect(&dragRect);
  169.             }
  170.  
  171.             oldPt = hitPt;
  172.         }
  173.  
  174.     }
  175.  
  176.     if (dragRgn) {
  177.         PaintRgn(dragRgn);
  178.         DisposeRgn(dragRgn);
  179.         SetEmptyRgn(gUtilRgn);
  180.     }
  181.     else
  182.         FrameRect(&dragRect);
  183.  
  184.     PenNormal();
  185. }
  186.  
  187. /* end of code */
  188.  
  189. +++++++++++++++++++++++++++
  190.  
  191. >From jc@vivitech.com (John Cooper)
  192. Date: Fri, 20 May 1994 15:13:16 GMT
  193. Organization: Vivid Technologies Inc.
  194.  
  195. I am reposting this post from last year from John Werner (where did he go,
  196. BTW?) that covers this very issue. I got very good results from using his
  197. C++ class.
  198.  
  199.    Note that in my application, I create the VBL task object in the init
  200. routine of my MouseDragTask object. It is then removed when the MouseDragTask
  201. object completes its task (when the mouse button is released).
  202.  
  203. - --------------------------------------------------------------------------
  204. In article <1993Jul8.215514.19857@vivitech.com>, jc@vivitech.com (John
  205. Cooper) wrote:
  206.  
  207. > I am developing an application that allows the user to drag outlines of
  208. > objects around the screen and "drop" them onto other objects in my main
  209. > app window. The problem I am encountering is an unsightly phase-in/phase-out
  210. > effect whenever the object outline is moved around the upper half of the
  211.  
  212. What's probably going on is that your object gets drawn after the electron
  213. beam has passed that part of the screen, then gets erased before the beam
  214. passes again.  This can make the object disappear in certain places.
  215.  
  216. The way to fix this is to synchronize your drawing to the VBL interrupts on
  217. the screen in question.  Your drawing loop will look something like this:
  218.  
  219.     Find the new mouse position
  220.     Calculate the new object position and outline.
  221.     Wait for the VBL interrupt
  222.     Erase the old outline
  223.     Draw the new one
  224.  
  225. The erase/draw steps need to be as fast as possible, so you can erase and
  226. redraw the object before the monitor starts being repainted by the electron
  227. beam.  That's why the calculations should get done before waiting for the
  228. VBL.
  229.  
  230. The only hard part is waiting for the VBL interrupt.  The usual way of
  231. doing this is to install a VBL task (using SlotVInstall or VInstall) that
  232. increments a global counter somewhere.  When you want to wait for an
  233. interrupt, your code sits in a tight loop waiting for the counter to
  234. change.
  235.  
  236. I have some code that does this for TCL apps.  It's on ftp.brown.edu in (I
  237. think) /pub/tcl/classes/CVblSync.something.  It will probably give you the
  238. general idea of what to do even for non-TCL programs.
  239.  
  240. -- 
  241. John Werner                      werner@soe.berkeley.edu
  242. UC Berkeley School of Education  510-596-5868 work, 655-6188 home
  243.  
  244.  
  245.  
  246. ---------------------------
  247.  
  248. >From afrancke@netcom.com (Andrew Francke)
  249. Subject: 68K drivers, PPC completion routines: HOW?
  250. Date: Thu, 19 May 1994 19:09:16 GMT
  251. Organization: Netcom Online Communications Services (408-241-9760 login: guest)
  252.  
  253. Scenario: You're using an old 68k driver (as in, 'DRVR') that somebody
  254. else provides (as in, you don't have source ripe for porting). The
  255. driver has completion routines for reads and writes that assume
  256. they're calling 68k code, stuffing something interesting in A0, etc.
  257.  
  258. Picture:
  259. +-----------+                         +----------------+
  260. +   680x0   +                         |  PPC Code Frag |
  261. +  Driver   + ------- callback ------\|   using driver |
  262. +           + -----w/A0 parameter----/|                |
  263. +-----------+                         +----------------+
  264.  
  265.  
  266. Question: Is there a way to prototype a function such that it may be
  267. compiled PPC native yet receive the parameter that vanilla 68k code
  268. would see in A0? Had I read the "converting to universal headers"
  269. article in d_e_v_e_l_o_p would I have known the answer? Is the answer
  270. contained deep within the bowels of NIM:PowerPC System Software?
  271.  
  272. +++++++++++++++++++++++++++
  273.  
  274. >From zstern@adobe.com (Zalman Stern)
  275. Date: Thu, 19 May 1994 22:14:20 GMT
  276. Organization: Adobe Systems Incorporated
  277.  
  278. Andrew Francke writes
  279. > Question: Is there a way to prototype a function such that it may be
  280. > compiled PPC native yet receive the parameter that vanilla 68k code
  281. > would see in A0? Had I read the "converting to universal headers"
  282. > article in d_e_v_e_l_o_p would I have known the answer? Is the answer
  283. > contained deep within the bowels of NIM:PowerPC System Software?
  284.  
  285. Handling the calling convention aspect is pretty straight forward with Mixed  
  286. Mode. If you look in the Universal Headers version of Files.h you'll see the  
  287. following:
  288.  
  289.     uppIOCompletionProcInfo     =  
  290. kRegisterBased|REGISTER_ROUTINE_PARAMETER(1,kRegisterA0,kFourByteCode)
  291.  
  292. That's the procinfo for the routine you are interested in. If you stitch  
  293. your PowerPC code into a routine descriptor with that procinfo and hand it  
  294. to whatever wants a 68K routine you'll be in business. The prototype for the  
  295. PowerPC routine is something like "void CompletionProc(void *A0Arg);". (This  
  296. all assumes there aren't any other oddities other than the register based  
  297. calling convention.) And yes, reading the Power Macintosh IM docs will help.
  298. --
  299. Zalman Stern           zalman@adobe.com            (415) 962 3824
  300. Adobe Systems, 1585 Charleston Rd., POB 7900, Mountain View, CA 94039-7900
  301.    Never let a "final candidate" subscript get above the age of consent.
  302.  
  303. ---------------------------
  304.  
  305. >From kamprath@aol.com (Kamprath)
  306. Subject: Audio CD Configuration
  307. Date: 16 May 1994 21:04:01 -0400
  308. Organization: America Online, Inc. (1-800-827-6364)
  309.  
  310. Do audio CDs have a data block which uniquely identifies a CD?  I ask because
  311. even though I know that song titles and CD title is not saved on the CD (or am
  312. I wrong), I want my program to be able to recognize a CD and be able to grab
  313. user-entered data from a file which does contain the info.  
  314.  
  315. Also, where in net-land (or Dev-CD land) can I find audio CD specs?  I've found
  316. sample code for accessing and some tech notes on the CD ROM driver, but nothing
  317. solely dealing with Audio CDs.
  318.  
  319. Thanks for any help,
  320. Michael Kamprath
  321. kamprath@aol.com
  322.  
  323. +++++++++++++++++++++++++++
  324.  
  325. >From u9119523@sys.uea.ac.uk (Graham Cox)
  326. Date: Thu, 19 May 1994 16:45:55 GMT
  327. Organization: School of Information Systems, UEA, Norwich
  328.  
  329. In article <2r9561$32g@search01.news.aol.com>, kamprath@aol.com (Kamprath)
  330. wrote:
  331.  
  332. > Do audio CDs have a data block which uniquely identifies a CD?  I ask because
  333. > even though I know that song titles and CD title is not saved on the CD (or am
  334. > I wrong), I want my program to be able to recognize a CD and be able to grab
  335. > user-entered data from a file which does contain the info.  
  336. > Also, where in net-land (or Dev-CD land) can I find audio CD specs?  I've found
  337. > sample code for accessing and some tech notes on the CD ROM driver, but nothing
  338. > solely dealing with Audio CDs.
  339. > Thanks for any help,
  340. > Michael Kamprath
  341. > kamprath@aol.com
  342.  
  343. Every CD has its serial number encoded on it, but NOT the title and track
  344. titles. The serial number is usually (but not necessarily) the same as its
  345. barcode number. I forget offhand exactly what calls you have to make to get
  346. it, but it's documented in the usual places (Apple CD-ROM handbook, e.g.).
  347. You can use this number to recover data from a database with title and
  348. track names. This is what Apple's CD Audio Player does.
  349.  
  350.  
  351. - ------------------------------------------------------------------------
  352. Graham
  353.  
  354. #include <Std_Disclaimer.h>
  355.  
  356. -Everyone is entitled to their opinion, no matter how wrong they may be...
  357. - ------------------------------------------------------------------------
  358.  
  359. +++++++++++++++++++++++++++
  360.  
  361. >From slavins@psy.man.ac.uk (Simon Slavin)
  362. Date: 20 May 94 17:43:30 GMT
  363. Organization: Psychology Department, University of Manchester, England, UK
  364.  
  365. In article 32g@search01.news.aol.com, kamprath@aol.com (Kamprath) writes:
  366. >Do audio CDs have a data block which uniquely identifies a CD?  I ask because
  367. >even though I know that song titles and CD title is not saved on the CD (or am
  368. >I wrong), I want my program to be able to recognize a CD and be able to grab
  369. >user-entered data from a file which does contain the info.  
  370. >
  371. >Also, where in net-land (or Dev-CD land) can I find audio CD specs?  I've found
  372. >sample code for accessing and some tech notes on the CD ROM driver, but nothing
  373. >solely dealing with Audio CDs.
  374.  
  375. As someone who has spent a few happy hours writing code for CD-ROM drives,
  376. especially the CS300, I'd better ante-up my 2c.
  377.  
  378. Part 1
  379. - ----
  380. There is *no* textual information standard for audio CDs.  There's no standard
  381. for storing the artist's name, the album name, or the track names.
  382. ["But ..."  "Hold on, let me explain."]
  383.  
  384. Part 2
  385. - ----
  386. There *is* a standard for the unique numbering of a CD.  There's a space for
  387. a unique (8-byte ?) number which could be assigned to each CD when the master
  388. is finished - sort of like an ISBN.  With each CD having a unique number,
  389. what happens is this:  You put your CD into the drive and your software
  390. comes up with default names for the album and the tracks (like "Track 1", etc.).
  391. You manually type in the names for the tracks and your software saves them
  392. away in a file somewhere, keyed by the CD's unique number.
  393. When you put the CD back in it reads the unique number, looks it up in the
  394. file, and retrieves the track names you typed in before.
  395.  
  396. Now sit down comfortably and grab your favorite drink:  here's the kicker ...
  397. No one uses the unique numbering system !  They all have the same code !
  398. (There may be exceptions, but all the ones I tested have the same code.)
  399. ["But ..."  "Hold on, let me explain."]
  400.  
  401. Part 3
  402. - ----
  403. [At this point I was tearing my hair out ...]
  404. What happens is that each driver which simulates this sort of thing makes
  405. up its own unique code from various bytes it's read off of the disk.
  406. There seems to be no standard for doing this.  The CD300 driver used in the
  407. AV Macs takes the lead-out time of the CD (i.e. its length) which is
  408. three BCD bytes long - minutes, seconds, frames, and the number of tracks
  409. on the CD - another byte.  This gives it a 4-byte code which it hopes
  410. is unique to that CD.
  411. Doubtless, eventually someone will find two CDs which are both same length and
  412. have the same number of tracks and complain that their software confuses them.
  413.  
  414. Thus endeth the lesson.  Feel free to go mad at your own pace.
  415.  
  416. The best source for Mac programming for Audio CDs and CD-ROM drives
  417. which use the Mac driver is the Mac technical note DV-22, in all the normal
  418. places you find Mac technical notes.
  419.  
  420. Simon.
  421. - -
  422. < "The natives showed considerable low cunning in using the brute force at >
  423. < their disposal." - Christopher Anvil               slavins@psy.man.ac.uk >
  424.  
  425.  
  426. +++++++++++++++++++++++++++
  427.  
  428. >From mxmora@unix.sri.com (Matt Mora)
  429. Date: 23 May 1994 10:14:37 -0700
  430. Organization: SRI International, Menlo Park, CA
  431.  
  432. In article <u9119523-190594164555@maclclab14.sys.uea.ac.uk> u9119523@sys.uea.ac.uk (Graham Cox) writes:
  433.  
  434. >Every CD has its serial number encoded on it, but NOT the title and track
  435. >titles. The serial number is usually (but not necessarily) the same as its
  436. >barcode number. I forget offhand exactly what calls you have to make to get
  437. >it, but it's documented in the usual places (Apple CD-ROM handbook, e.g.).
  438. >You can use this number to recover data from a database with title and
  439. >track names. This is what Apple's CD Audio Player does.
  440.  
  441. The old CD remote used the Numberoftracks and disc min,sec,frame as a unique
  442. id. There is a call to get the ISBN or the CD ID number from the disk. I 
  443. don't know if the new apple player program uses the new calls or relies on the
  444. old cd remote way of doing it. If you want your code to work on all Apple
  445. drive is doesn't make sence to use two different Unique id's.
  446.  
  447. Below is code to show you how to get at the data.
  448.  
  449.  
  450. Xavier
  451.  
  452.  
  453. - --------
  454.  
  455. typedef struct {            // Address Struct
  456.     Byte    track;
  457.     Byte    min;
  458.     Byte    sec;
  459.     Byte    frame;
  460. } Address;
  461.  
  462. typedef struct {
  463.     Address    discID;
  464.     short    resID;
  465. } diskType;
  466.  
  467. typedef struct {
  468.     short    version;
  469.     short    count;
  470.     diskType discList[];
  471. } index;
  472.  
  473.  
  474. index *MasterIndex;
  475. diskType *discs;
  476.  
  477.  
  478. void main (void)
  479. {
  480.   long  dirId;
  481.   short   oe;
  482.   short   resRef;
  483.   FSSpec  theSpec;
  484.   short   vRefNum;
  485.   Handle  h;
  486.   ResType rType = 'IndX';
  487.   short   i;
  488.   Address   tag;
  489.   short   resNum;
  490.   diskType dt;
  491.   short x;
  492.   short argc;
  493.   char **argv;
  494.   Str255  tempStr;
  495.   InitMac();
  496.   argc =  ccommand(&argv);
  497.   
  498.   oe  = FindFolder(-1,kPreferencesFolderType,false,&vRefNum,&dirId);
  499.   oe = FSMakeFSSpec(vRefNum,dirId,"\pCD Remote Programs",&theSpec);
  500.   resRef = FSpOpenResFile(&theSpec,fsRdWrPerm);
  501.   if (resRef != -1) {
  502.     h = GetResource(rType,128);
  503.     if (h) {
  504.       HLock(h);
  505.       MasterIndex = (index *)*h;
  506.       for (i=0 ;i<MasterIndex->count;i++) {
  507.         dt = (MasterIndex->discList[i]);
  508.         tag = dt.discID;
  509.         resNum = MasterIndex->discList[i].resID;
  510.         printf("Disk Id = %#lx\n",tag);
  511.         printf("Disk Res ID = %d\n",resNum);
  512.         
  513.         
  514.         x = 1;
  515.           GetIndString(tempStr,resNum,x);
  516.           p2cstr(tempStr);
  517.           printf("Album Title: %s\n",tempStr);
  518.           
  519.         while (tempStr[0] != 0){
  520.           x++;
  521.           GetIndString(tempStr,resNum,x);
  522.           p2cstr(tempStr);
  523.           if (tempStr[0] != 0)
  524.             printf("  Song %d : %s\n",x - 1,tempStr);
  525.           
  526.         }
  527.         printf("------------------\n");
  528.       }
  529.       HUnlock(h);
  530.       ReleaseResource(h);
  531.     }
  532.     CloseResFile(resRef);
  533.   }
  534.  
  535. }
  536. -- 
  537. ___________________________________________________________
  538. Matthew Xavier Mora                       Matt_Mora@sri.com
  539. SRI International                       mxmora@unix.sri.com
  540. 333 Ravenswood Ave                    Menlo Park, CA. 94025
  541.  
  542. +++++++++++++++++++++++++++
  543.  
  544. >From eesau@uta.fi (Esa Ristil{)
  545. Date: 24 May 1994 08:43:01 +0300
  546. Organization: University of Tampere, Finland
  547.  
  548. According to Matt Mora:
  549. >don't know if the new apple player program uses the new calls or relies on the
  550. >old cd remote way of doing it. If you want your code to work on all Apple
  551.  
  552. The new player uses the same old method.
  553.  
  554. -- 
  555.                        Esa Ristil{  *  eesau@uta.fi
  556.                              Homo homini lupus
  557.  
  558. ---------------------------
  559.  
  560. >From mas@rimmer.ngdc.noaa.gov (Mark Steele)
  561. Subject: Compression Manager help!
  562. Date: Fri, 20 May 1994 22:08:34 GMT
  563. Organization: CIRES
  564.  
  565. Suppose that I have a file that I know is a JFIF. I want to get some
  566. information on that image (dimensions, pixel depth, quality etc).
  567. How would I go about collecting this information? 
  568. Is there a compression manager function that will do this for me?
  569.  
  570. Thanks for any help,
  571. -Mark
  572.  
  573.  
  574. -- 
  575. Mark Steele                                     mas@rimmer.ngdc.noaa.gov
  576.                                           steelem@rintintin.colorado.edu
  577.  
  578. +++++++++++++++++++++++++++
  579.  
  580. >From Mark Hanrek <hanrek@cts.com>
  581. Date: 21 May 1994 09:33:15 GMT
  582. Organization: The Information Workshop
  583.  
  584. In article <mas-200594160451@192.149.148.115> Mark Steele,
  585. mas@rimmer.ngdc.noaa.gov writes:
  586.  
  587. > Suppose that I have a file that I know is a JFIF. I want to get some
  588. > information on that image (dimensions, pixel depth, quality etc).
  589. > How would I go about collecting this information? 
  590. > Is there a compression manager function that will do this for me?
  591.  
  592. There is example source code showing how to use the Image Compression
  593. Manager to decode JFIF files.  You can find it either on the QuickTime
  594. Developers Kit CD, or the regular Developer CD.  (not sure where I got
  595. it)  You might also be able to find it at ftp.apple.com in the snippets
  596. area.  It's called "JFIF->PICT".
  597.  
  598. In addition, use Archie or other means to locate "JPEG" on the internet,
  599. and you will zero in on the Independent JPEG Group's source code.
  600.  
  601. In there, you will find a particular .c source code file that reads the
  602. header information to discover what is known about a JPEG/JFIF file.
  603.  
  604. Hope this helps.
  605.  
  606. Mark Hanrek
  607.  
  608. +++++++++++++++++++++++++++
  609.  
  610. >From kehrer@informatik.uni-ulm.de (Juergen Kehrer)
  611. Date: 24 May 1994 06:13:45 GMT
  612. Organization: Uni-Ulm / Verteilte Systeme
  613.  
  614. Hi, 
  615. here a is some code to decompress a JFIF file/resource/datastructure:
  616.  
  617.  
  618. 00000000000000000000000000000000000000000000000000000000000000000000000
  619.  
  620. PROCEDURE DrawMJPEGFrame (aWindow : GrafPtr; DataSize: Integer; Data: Ptr);
  621.     VAR
  622.         savedPort: GrafPtr;
  623.         srcRect: Rect;
  624.         descH: ImageDescriptionHandle;
  625.         myErr: OSErr;
  626.         theName: Str31;
  627.  
  628.  
  629.     BEGIN
  630.         GetPort(savedPort);
  631.         SetPort(GrafPtr(aWindow));
  632.         descH := ImageDescriptionHandle(NewHandle(sizeof(ImageDescription)));
  633.         HLock(Handle(descH));
  634.         WITH descH^^ DO BEGIN
  635.             idSize := sizeof(ImageDescription);
  636.             cType := 'jpeg';    
  637.             resvd2 := $0;
  638.             dataRefIndex := 0;
  639.             version := 1;
  640.             revisionLevel := 1;
  641.             vendor := LongInt('appl');
  642.             temporalQuality := 0;
  643.             spatialQuality := 0;
  644.             width := 160;
  645.             height := 120;
  646.             hRes := Long2Fix(72);
  647.             vRes := Long2Fix(72);
  648.             dataSize := 0;
  649.             frameCount := 1;
  650.             theName := 'Photo - JPEG';
  651.             BlockMove(@theName[0], @name[0], LongInt(theName[0]) + 1);
  652.             depth := 24;
  653.             clutID := -1;
  654.         END;
  655.         WITH aWindow^.portRect DO
  656.             SetRect(srcRect, 0, 0, right - left, bottom - top);
  657.         myErr := DecompressImage(Data, descH, aWindow^.portPixMap, srcRect,              
  658.               aWindow^.portRect, srcCopy, NIL);
  659.         IF myErr <> noErr THEN BEGIN
  660.             ErrorHandling('Error -- DecompressImage: ', myErr);
  661.         END;
  662.         DisposeHandle(Handle(descH));
  663.         SetPort(savedPort);
  664.     END;    { DrawMJPEGFrame }
  665.  
  666.  
  667. 00000000000000000000000000000000000000000000000000000000000000000000000
  668.  
  669. As far as I remember you only have to fill cType, depth, clutID (-1)
  670. of the ImageDescriptionHandle. The decompressed frame is displayed in
  671. aWindow in fullsize.
  672.  
  673. Best regards,
  674.     J.Kehrer
  675.  
  676. ===============================================================
  677. Juergen Kehrer
  678. University of Ulm/Germany
  679. Dept of Distributed Systems
  680. Internet: kehrer@informatik.uni-ulm.de
  681. ===============================================================
  682.  
  683. ---------------------------
  684.  
  685. >From hoyer@cc.Helsinki.FI (Paul Hoyer)
  686. Subject: Fastest way to draw a line?
  687. Date: 23 May 1994 14:44:59 +0300
  688. Organization: University of Helsinki
  689.  
  690. I need a fast way to draw a line on the screen, an algorithm actually.
  691. Because what I'm doing isn't actually drawing the line (I'm stepping
  692. through each pixel and performing some calculations), I can't simply use
  693. the toolbox's line functions.
  694.  
  695. I would suppose that the fastest way would be to somehow get the line
  696. into the form: "2 pixels right, 3 up, then 2 right again etc...", but
  697. how? I remember reading somewhere something about "Fourier"-algorithms,
  698. or something. Would anybody happen to have such an algorithm to spare?
  699.  
  700. Thanks!
  701.  
  702. -P. Hoyer <hoyer@cc.helsinki.fi>
  703.  
  704.  
  705. +++++++++++++++++++++++++++
  706.  
  707. >From Jochen Meyer <jochen@blanc.north.de>
  708. Date: Tue, 24 May 94 20:20:01 +0200  (MES)
  709. Organization: Meyer & Son
  710.  
  711.  
  712. In article <2rq4vr$jkq@kruuna.Helsinki.FI>, Paul Hoyer writes:
  713.  
  714.  
  715. > I need a fast way to draw a line on the screen, an algorithm actually.
  716. > Because what I'm doing isn't actually drawing the line (I'm stepping
  717. > through each pixel and performing some calculations), I can't simply use
  718. > the toolbox's line functions.
  719. >  
  720. What you need is the "Bresenham" algorithm. It is *the* algorithm for line 
  721. drawing and is also being used in a lot of other ways. It is documented in 
  722. probably every computer graphics book and is fairly easy to understand and 
  723. implement.
  724.  
  725. Jochen
  726. jochen@blanc.north.de
  727.  
  728. +++++++++++++++++++++++++++
  729.  
  730. >From Jens Alfke <jens_alfke@powertalk.apple.com>
  731. Date: Wed, 25 May 1994 21:01:09 GMT
  732. Organization: Apple Computer
  733.  
  734. In article <2rq4vr$jkq@kruuna.Helsinki.FI> Paul Hoyer, hoyer@cc.Helsinki.FI
  735. writes:
  736. > I need a fast way to draw a line on the screen, an algorithm actually.
  737. > Because what I'm doing isn't actually drawing the line (I'm stepping
  738. > through each pixel and performing some calculations), I can't simply use
  739. > the toolbox's line functions.
  740.  
  741. As previously stated, the Bresenham algorithm is what you want. The standard
  742. graphics reference I give people is "Computer Graphics: Principles &
  743. Practice" by Foley, Van Dam, Feiner and Hughes (Addison-Wesley). Any
  744. bookstore with a half decent CS selection should have it. It's expensive but
  745. has so much stuff in it that you'll find it worthwhile.
  746.  
  747. Another point: If you plan on drawing this way, don't just call SetCPoint on
  748. every pixel or you'll find it's very slow. Make yourself a GWorld, find the
  749. PixMap and pixels, and write directly into the pixel buffer. Then you can
  750. call CopyBits to display your results.
  751.  
  752. --Jens Alfke
  753.   jens_alfke@powertalk              Rebel girl, rebel girl,
  754.             .apple.com              Rebel girl you are the queen of my world
  755.  
  756. +++++++++++++++++++++++++++
  757.  
  758. >From rlewis@opal.tufts.edu (Rob Lewis)
  759. Date: Thu, 26 May 1994 14:23:34 GMT
  760. Organization: New England Medical Center
  761.  
  762.  
  763.  
  764. Bresenham's algorithm for scan converting a line is the one you want.
  765. He not only invented the algorithm, but proved that it was the most
  766. efficient possible.  I don't have my graphics text with me, so I can't
  767. post it now, but you can find it in many graphics texts which you can
  768. find in a library.  
  769.  
  770. - -
  771.  
  772. Rob Lewis                          rlewis@opal.tufts.edu
  773. New England Medical Center         
  774. Neuroimaging Research Laboratory   --->  Audio ergo sum  <---
  775.  
  776. +++++++++++++++++++++++++++
  777.  
  778. >From Jens Alfke <jens_alfke@powertalk.apple.com>
  779. Date: Fri, 27 May 1994 19:10:42 GMT
  780. Organization: Apple Computer
  781.  
  782. Rob Lewis, rlewis@opal.tufts.edu writes:
  783. > Bresenham's algorithm for scan converting a line is the one you want.
  784. > He not only invented the algorithm, but proved that it was the most
  785. > efficient possible.
  786.  
  787. ...except that in recent years other people have optimized his algorithm to
  788. increase its speed by a factor of four. This isn't entirely fair; it
  789. increases the speed of calculating which pixels to set by a factor of four.
  790. In real graphics systems, actually plotting the pixel also takes some time,
  791. so the improvement isn't as great.
  792.  
  793. For more info, jaunt to comp.graphics.algorithms and wait for the
  794. infrequently-posted FAQ.
  795.  
  796. --Jens Alfke
  797.   jens_alfke@powertalk              Rebel girl, rebel girl,
  798.             .apple.com              Rebel girl you are the queen of my world
  799.  
  800. +++++++++++++++++++++++++++
  801.  
  802. >From dwareing@apanix.apana.org.au (David Wareing)
  803. Date: 31 May 94 02:25:32 GMT
  804. Organization: Apanix Public Access Unix, +61 8 373 5485 (5 lines)
  805.  
  806. Jens Alfke <jens_alfke@powertalk.apple.com> writes:
  807.  
  808. >Rob Lewis, rlewis@opal.tufts.edu writes:
  809. >> Bresenham's algorithm for scan converting a line is the one you want.
  810. >> He not only invented the algorithm, but proved that it was the most
  811. >> efficient possible.
  812.  
  813. >...except that in recent years other people have optimized his algorithm to
  814. >increase its speed by a factor of four. This isn't entirely fair; it
  815. >increases the speed of calculating which pixels to set by a factor of four.
  816. >In real graphics systems, actually plotting the pixel also takes some time,
  817. >so the improvement isn't as great.
  818.  
  819. I copied the following post the last time this subject raised its head.
  820. Thanks to Richard Johnson for posting it. As a special bonus, you get a
  821. circle drawing algo thrown in free. No steak knives though. I have not
  822. personally used or tested the code, so please direct all queries or
  823. queeries to Richard_Johnson@eaglesnest.albedo.com. You will have to roll
  824. your own draw routine though.
  825.  
  826. BTW, the drawing implementation is at least as important as the code
  827. itself. As Jens Alfke pointed out, create a GWorld, write directly to the
  828. pixmap (see the csmp FAQ) and then copy to the screen from there. Don't
  829. bother using SetCPixel or LineTo or anything like that - it would defeat
  830. the purpose of actually using a fast algo.
  831.  
  832. ===========================================================================
  833.  
  834.  
  835. From: Richard_Johnson@eaglesnest.albedo.com (Richard Johnson)
  836. Date: Wed, 12 Jan 94 20:19:06 PST
  837. Organization: Eagle's Nest BBS Fidonet 1:102/834.0 1-818-989-7845
  838.  
  839. Here's the bresnham line drawing code, and a circle drawing code. I hope
  840. the
  841. person who wanted the line drawing code a while back is still around. The
  842. beauty of these algorithms is that they don't use division or floating
  843. point
  844. numbers, both of which use a lot of processing time, but they still produce
  845. accurate results! Cool.
  846.  
  847. void DrawLine( short x1, short y1, short x2, short y2 )
  848. {
  849.      short xi,yi,dx,dy;
  850.  
  851.      if( x1 > x2 ) xi = -1; else xi = 1;
  852.      if( y1 > y2 ) yi = -1; else yi = 1;
  853.      dx = iabs(x2-x1);
  854.      dy = iabs(y2-y1);
  855.      WritePixel( win->RPort, x1,y1 );
  856.      if( dy > dx )
  857.      {
  858.           j = dy;
  859.           i = dy >> 1;
  860.           do
  861.           {
  862.                y1 += yi;
  863.                if( (i += dx) > dy ) { i -= dy; x1 += xi; }
  864.                WritePixel( win->RPort, x1,y1 );
  865.           } while( --j );
  866.      }
  867.      else
  868.      {
  869.           j = dx;
  870.           i = dx >> 1;
  871.           do
  872.           {
  873.                x1 += xi;
  874.                if( (i += dy) > dx ) { i -= dx; y1 += yi; }
  875.                WritePixel( win->RPort, x1,y1 );
  876.           } while( --j );
  877.      }
  878. }
  879.  
  880. void Circle( short cx, short cy, short radius )
  881. {
  882.      short x, y, d;
  883.  
  884.      x = 0;
  885.      y = radius;
  886.      d = 3 - 2 * radius;
  887.      do
  888.      {
  889.           WritePixel( win->RPort, cx + x, cy + y );
  890.           WritePixel( win->RPort, cx + y, cy + x );
  891.           WritePixel( win->RPort, cx + y, cy - x );
  892.           WritePixel( win->RPort, cx + x, cy - y );
  893.           WritePixel( win->RPort, cx - x, cy - y );
  894.           WritePixel( win->RPort, cx - y, cy - x );
  895.           WritePixel( win->RPort, cx - y, cy + x );
  896.           WritePixel( win->RPort, cx - x, cy + y );
  897.  
  898.           x++;
  899.  
  900.           if( d < 0 )
  901.                d += 4*x+6;
  902.           else
  903.           {
  904.                d += 4*(x-y)+10;
  905.                y--;
  906.           }
  907.  
  908.      } while( x <= y );
  909. }
  910.  
  911. -- Via DLG Pro v1.0
  912.  
  913. - -----------------------------------------------------------------------
  914. | Richard Johnson            richard_johnson@eaglesnest.albedo.com      |
  915. | fidonet 1:102/834.0:       richard_johnson@f834.n102.z1.fidonet.org   |
  916. - -----------------------------------------------------------------------
  917.  
  918. =========================================================================
  919.  
  920. --
  921. David Wareing
  922. Adelaide, South Australia         dwareing@apanix.apana.org.au
  923. - ------------------------------------------------------------
  924. Overflight Software - Macintosh Games & Multimedia Programming
  925.  
  926. ---------------------------
  927.  
  928. >From startz@u.washington.edu (Dick Startz)
  929. Subject: Finding application & document folders???
  930. Date: Mon, 09 May 1994 08:51:24 +0800
  931. Organization: University of Washington
  932.  
  933. Can someone tell me how to have my program identify both the folder
  934. containing my application (so I can find help files, etc.) and the folder
  935. containing the document the user double-clicked (for the open dialog,
  936. etc.).
  937.  
  938. I know one of these is the current directory at launch time, but which one?
  939. How do I nail down the other one?
  940.  
  941. (Some days me and Inside Mac have a communications problem.)
  942.  
  943. Thanks in advance.
  944. -Dick Startz
  945.  
  946. -- 
  947. Richard Startz                Internet::startz@u.washington.edu
  948. Professor of Economics        voice::         206-543-8172
  949. University of Washington      fax::           206-685-6419
  950. Seattle, WA 98195 USA
  951.  
  952. +++++++++++++++++++++++++++
  953.  
  954. >From jumplong@aol.com (Jump Long)
  955. Date: 14 May 1994 02:03:02 -0400
  956. Organization: America Online, Inc. (1-800-827-6364)
  957.  
  958. In article <startz-090594085124@128.95.72.95>, startz@u.washington.edu (Dick
  959. Startz) writes:
  960.  
  961. >Can someone tell me how to have my program identify both the folder
  962. >containing my application (so I can find help files, etc.) and the folder
  963. >containing the document the user double-clicked (for the open dialog,
  964. >etc.).
  965.  
  966. If you're running under System 7, then use GetProcessInfo() on your application
  967. (the current process) to get an FSSpec to your application.  The FSSpec will
  968. contain the volume reference number of the volume your application is on and
  969. the directory ID of the folder your application is in. As for the document
  970. files, you'll get their location from the open application Apple Events you get
  971. telling you what files to open.
  972.  
  973. Since you may be getting open application events that point to several
  974. documents in completely different locations (remember, the System 7 Finder lets
  975. you select files from different directories at the the same time and Finder
  976. alias files can resolve to files on different volumes), you shouldn't make too
  977. many assumptions about the standard location of document files.
  978.  
  979. - Jim Luther
  980.  
  981.  
  982. +++++++++++++++++++++++++++
  983.  
  984. >From gadget@engin.umich.edu (gadget)
  985. Date: 16 May 1994 00:04:37 GMT
  986. Organization: Never Never Land
  987.  
  988. >>Can someone tell me how to have my program identify both the folder
  989. >>containing my application (so I can find help files, etc.) and the folder
  990. >>containing the document the user double-clicked (for the open dialog,
  991. >>etc.).
  992. >
  993. >If you're running under System 7, then use GetProcessInfo() on your application
  994. >(the current process) to get an FSSpec to your application.  The FSSpec will
  995. >contain the volume reference number of the volume your application is on and
  996. >the directory ID of the folder your application is in. As for the document
  997. >files, you'll get their location from the open application Apple Events you get
  998. >telling you what files to open.
  999. >
  1000. >Since you may be getting open application events that point to several
  1001. >documents in completely different locations (remember, the System 7 Finder lets
  1002. >you select files from different directories at the the same time and Finder
  1003. >alias files can resolve to files on different volumes), you shouldn't make too
  1004. >many assumptions about the standard location of document files.
  1005.  
  1006. (why do I have to have more lines of text than included information? nice
  1007. news reader here... *agit*)
  1008.  
  1009. Is there source code for any of this available anywhere?  Cause I'd like
  1010. exacctly the same thing.  To open data files in my folder, and accept
  1011. the apple events.  I'm sure this has been optomised many times over by
  1012. lots of people, and I really don't need to do it again do I?
  1013.  
  1014. Tim
  1015.  
  1016.  
  1017.  
  1018.  
  1019.  
  1020.  
  1021.  
  1022.  
  1023.  
  1024. +++++++++++++++++++++++++++
  1025.  
  1026. >From startz@u.washington.edu (Dick Startz)
  1027. Date: Mon, 16 May 1994 08:36:41 +0800
  1028. Organization: University of Washington
  1029.  
  1030. In article <2r1pim$eqq@search01.news.aol.com>, jumplong@aol.com (Jump Long)
  1031. wrote:
  1032.  
  1033. > In article <startz-090594085124@128.95.72.95>, startz@u.washington.edu (Dick
  1034. > Startz) writes:
  1035. > >Can someone tell me how to have my program identify both the folder
  1036. > >containing my application (so I can find help files, etc.) and the folder
  1037. > >containing the document the user double-clicked (for the open dialog,
  1038. > >etc.).
  1039. > If you're running under System 7, then use GetProcessInfo() on your application
  1040. > (the current process) to get an FSSpec to your application.  The FSSpec will
  1041. > contain the volume reference number of the volume your application is on and
  1042. > the directory ID of the folder your application is in. As for the document
  1043. > files, you'll get their location from the open application Apple Events you get
  1044. > telling you what files to open.
  1045. > Since you may be getting open application events that point to several
  1046. > documents in completely different locations (remember, the System 7 Finder lets
  1047. > you select files from different directories at the the same time and Finder
  1048. > alias files can resolve to files on different volumes), you shouldn't make too
  1049. > many assumptions about the standard location of document files.
  1050. > - Jim Luther
  1051.  
  1052. Thanks, that helps!  Anyone want to chime in with System 6 advice???
  1053.  
  1054. -- 
  1055. Richard Startz                Internet::startz@u.washington.edu
  1056. Professor of Economics        voice::         206-543-8172
  1057. University of Washington      fax::           206-685-6419
  1058. Seattle, WA 98195 USA
  1059.  
  1060. +++++++++++++++++++++++++++
  1061.  
  1062. >From arentz@knoware.nl (Stefan Arentz)
  1063. Date: Tue, 17 May 1994 01:00:38 GMT
  1064. Organization: Lunatech Software Development
  1065.  
  1066. In article <startz-160594083641@128.95.72.95>
  1067. startz@u.washington.edu (Dick Startz) writes:
  1068.  
  1069. [Very useful advice from a FileSystem Guru deleted]
  1070.  
  1071. > Thanks, that helps!  Anyone want to chime in with System 6 advice???
  1072.  
  1073. How about:
  1074.  
  1075. OSErr RefNumToFSSpec(short theRefNum, FSSpec *theSpec) {
  1076.  
  1077.     FCBPBRec        paramBlock;
  1078.     OSErr            theError;
  1079.     Str255            theName;
  1080.  
  1081.     paramBlock.ioCompletion    = nil;
  1082.     paramBlock.ioNamePtr    = theName;
  1083.     paramBlock.ioVRefNum    = 0;
  1084.     paramBlock.ioRefNum        = theRefNum;
  1085.     paramBlock.ioFCBIndx    = 0;
  1086.     
  1087.     theError = PBGetFCBInfo(¶mBlock, false);
  1088.  
  1089.     if (theError == noErr) {
  1090.         theSpec->vRefNum = paramBlock.ioFCBVRefNum;
  1091.         theSpec->parID = paramBlock.ioFCBParID;
  1092.         CopyPString(theName, theSpec->name);
  1093.     }
  1094.     
  1095.     return(theError);
  1096.  
  1097. }
  1098.  
  1099. theError = RefNumToFSSpec(CurResFile(), &applicationFileSpec);
  1100.  
  1101. If you use System 6, and don't want the FSSpec, this code is simple to
  1102. modify...
  1103.  
  1104. - ----------------------------------------------------------------------
  1105.  
  1106. Stefan Arentz        --       arentz@knoware.nl       --        Lunatech
  1107.  
  1108. +++++++++++++++++++++++++++
  1109.  
  1110. >From startz@u.washington.edu (Dick Startz)
  1111. Date: Tue, 17 May 1994 08:24:42 +0800
  1112. Organization: University of Washington
  1113.  
  1114. In article <Cpx9H2.ABI@knoware.nl>, arentz@knoware.nl (Stefan Arentz)
  1115. wrote:
  1116.  
  1117. > How about:
  1118. > OSErr RefNumToFSSpec(short theRefNum, FSSpec *theSpec) {
  1119. >     FCBPBRec        paramBlock;
  1120. >     OSErr            theError;
  1121. >     Str255            theName;
  1122. >     paramBlock.ioCompletion    = nil;
  1123. >     paramBlock.ioNamePtr    = theName;
  1124. >     paramBlock.ioVRefNum    = 0;
  1125. >     paramBlock.ioRefNum        = theRefNum;
  1126. >     paramBlock.ioFCBIndx    = 0;
  1127. >     
  1128. >     theError = PBGetFCBInfo(¶mBlock, false);
  1129. >     if (theError == noErr) {
  1130. >         theSpec->vRefNum = paramBlock.ioFCBVRefNum;
  1131. >         theSpec->parID = paramBlock.ioFCBParID;
  1132. >         CopyPString(theName, theSpec->name);
  1133. >     }
  1134. >     
  1135. >     return(theError);
  1136. > }
  1137. > theError = RefNumToFSSpec(CurResFile(), &applicationFileSpec);
  1138. > If you use System 6, and don't want the FSSpec, this code is simple to
  1139. > modify...
  1140. > ------------------------------------------------------------------------
  1141. > Stefan Arentz        --       arentz@knoware.nl       --        Lunatech
  1142.  
  1143. Many thanks, that's just what I need!
  1144. To clarify my understanding, is it correct that CurResFile() gives you the
  1145. application resource file (assuming you call before you change the resource
  1146. file, of course) and that I can pick up the folder of the document the user
  1147. double-clicked on by GetVol() and the code above setting ioVRefNum? (Run-on
  1148. sentence apologies...)
  1149. -Dick Startz
  1150.  
  1151.  
  1152. -- 
  1153. Richard Startz                Internet::startz@u.washington.edu
  1154. Professor of Economics        voice::         206-543-8172
  1155. University of Washington      fax::           206-685-6419
  1156. Seattle, WA 98195 USA
  1157.  
  1158. +++++++++++++++++++++++++++
  1159.  
  1160. >From jumplong@aol.com (Jump Long)
  1161. Date: 21 May 1994 02:37:02 -0400
  1162. Organization: America Online, Inc. (1-800-827-6364)
  1163.  
  1164. In article <startz-160594083641@128.95.72.95>,
  1165. startz@u.washington.edu (Dick Startz) writes:
  1166.  
  1167. (in response to my last posting)
  1168.  
  1169. >Thanks, that helps!  Anyone want to chime in with System 6 advice???
  1170.  
  1171. System 6, what's that? :-)
  1172.  
  1173. Under System 6, you can use GetAppleParms (see IM II-58) to get the
  1174. reference number of your application. Then, use PBGetFCBInfo (or the
  1175. GetFileLocation function which calls PBGetFCBInfo) in MoreFiles) to
  1176. get the volume reference number and parent directory ID of your
  1177. application.
  1178.  
  1179. After your application is launched under System 6, you can use
  1180. CountAppFiles and GetAppFiles (also in IM II starting on page II-57)
  1181. to find out what files to open or print.  Since GetAppFiles returns
  1182. only a vRefNum and a file name in the AppFile record (there isn't a
  1183. directory ID field in the record), that means the value in the
  1184. vRefNum field is a working directory number. So, you'll need to pass
  1185. the vRefNum field in the AppFile record to GetWDInfo to get the real
  1186. volume reference number and parent directory ID of the file the
  1187. AppFile record refers to.
  1188.  
  1189. That's it.
  1190.  
  1191. - Jim Luther (back from a week at the WWDC)
  1192.  
  1193.  
  1194. ---------------------------
  1195.  
  1196. >From Thomas Reed <reed@medicine.wustl.edu>
  1197. Subject: How to make a window "float" over other apps?
  1198. Date: 19 May 1994 14:36:19 GMT
  1199. Organization: Washington University
  1200.  
  1201. I've got an application that displays a small timer window.  I'd like to
  1202. add an option that would allow the user to have this timer window "float"
  1203. above all other windows, so that the window is visible at all times. 
  1204. Does anyone know how I might be able to do this, and what the possible
  1205. effects of doing this are?  Is it the kind of thing that might break? 
  1206. Will it cause a lot of slowdown?
  1207.  
  1208. Thanks in advance!
  1209.  
  1210. -Thomas
  1211. =====================================================
  1212. Thomas Reed                    Washington University
  1213. Reed@telesphere.wustl.edu          Medical School
  1214. (also:  Reed@medicine.wustl.edu)
  1215. - ---------------------------------------------------
  1216. Clothes make the man.  Naked people have little or no
  1217. influence on society.  -- Mark Twain
  1218. =====================================================
  1219.  
  1220. +++++++++++++++++++++++++++
  1221.  
  1222. >From Matt Slot <fprefect@engin.umich.edu>
  1223. Date: 20 May 1994 04:32:05 GMT
  1224. Organization: University of Michigan
  1225.  
  1226. Thomas Reed, reed@medicine.wustl.edu writes:
  1227.  > I've got an application that displays a small timer window.  I'd like to
  1228.  > add an option that would allow the user to have this timer window "float"
  1229.  > above all other windows, so that the window is visible at all times. 
  1230.  > Does anyone know how I might be able to do this, and what the possible
  1231.  > effects of doing this are?  Is it the kind of thing that might break? 
  1232.  > Will it cause a lot of slowdown?
  1233.  
  1234. I have written a small background app which demonstrates how to use
  1235. the new Text Services floating windows. There is an app I posted to
  1236. Sumex called MemWin which shows the final product. If you like the looks
  1237. of the program, drop me a line and I will mail the source to you. (I
  1238. may send a copy to alt.sources.mac, but I want to fix up something 
  1239. tonite).
  1240.  
  1241. The information I found was in Inside Macintosh: Text, but that was not
  1242. sufficient to explain the intricacies. I ended up adding a jGNEFilter to
  1243. get clicks and updates (need to trap manually). The window *does* float
  1244. above all others, but it requires System 7.1 or later to get the Text
  1245. Services Manager support -- if you have that, you are using all supported
  1246. system software hooks. There is no apparent slowdown, and it works for
  1247. all systems I have tested.
  1248.  
  1249. Matt Slot
  1250. fprefect@engin.umich.edu
  1251.  
  1252. +++++++++++++++++++++++++++
  1253.  
  1254. >From tgaul@halcyon.com (Troy Gaul)
  1255. Date: 22 May 1994 04:43:51 GMT
  1256. Organization: Infinity Systems
  1257.  
  1258. In article <2rheg6$8hk@lastactionhero.rs.itd.umich.edu>, Matt Slot
  1259. <fprefect@engin.umich.edu> wrote:
  1260.  
  1261. > Thomas Reed, reed@medicine.wustl.edu writes:
  1262. >  > I've got an application that displays a small timer window.  I'd like to
  1263. >  > add an option that would allow the user to have this timer window "float"
  1264. >  > above all other windows, so that the window is visible at all times. 
  1265. >  > Does anyone know how I might be able to do this, and what the possible
  1266. >  > effects of doing this are?  Is it the kind of thing that might break? 
  1267. >  > Will it cause a lot of slowdown?
  1268. > I have written a small background app which demonstrates how to use
  1269. > the new Text Services floating windows. There is an app I posted to
  1270. > Sumex called MemWin which shows the final product. If you like the looks
  1271. > of the program, drop me a line and I will mail the source to you. (I
  1272. > may send a copy to alt.sources.mac, but I want to fix up something 
  1273. > tonite).
  1274. > The information I found was in Inside Macintosh: Text, but that was not
  1275. > sufficient to explain the intricacies. I ended up adding a jGNEFilter to
  1276. > get clicks and updates (need to trap manually). The window *does* float
  1277. > above all others, but it requires System 7.1 or later to get the Text
  1278. > Services Manager support -- if you have that, you are using all supported
  1279. > system software hooks. There is no apparent slowdown, and it works for
  1280. > all systems I have tested.
  1281.  
  1282. I've had problems with this and other programs that use a Text Services
  1283. Manager window. The problem is that at times, clicks 'fall through' to the
  1284. application that is below the window.  This problem doesn't seem to happen
  1285. consistently, but it seems I can make it happen fairly quickly if I am
  1286. trying.
  1287.  
  1288. I remember a hack that Don Brown wrote at MacHack last year that also had
  1289. this problem.  He wrote an INIT called TSMHelper that tried to compensate
  1290. for these 'misses', but still there were problems.
  1291.  
  1292. Another problem with this kind of window is that it doesn't seem to have
  1293. control over the cursor, so the cursor will depend upon whatever window it
  1294. happens to be floating on top of.  I suppose this would be tough to do,
  1295. even through a jGNEFilter, since other applications would expect to have
  1296. control of the current cursor
  1297.  
  1298. Just my $.02.
  1299.  
  1300. _troy
  1301. //////// //////___Troy Gaul_________________________tgaul@halcyon.com__ //
  1302.   //    //       Infinity Systems ; West Des Moines, Iowa              //
  1303.  //    //  //  "Insert witty quote here."                             //
  1304. //    //////________________________________________________________ //
  1305.  
  1306. +++++++++++++++++++++++++++
  1307.  
  1308. >From grobbins@apple.com (Grobbins)
  1309. Date: 22 May 1994 12:59:11 -0700
  1310. Organization: Skunkworks
  1311.  
  1312. In article <tgaul-210594233906@bellevue-ip9.halcyon.com>,
  1313. Troy Gaul <tgaul@halcyon.com> wrote:
  1314. >I've had problems with this and other programs that use a Text Services
  1315. >Manager window. The problem is that at times, clicks 'fall through' to the
  1316. >application that is below the window.  This problem doesn't seem to happen
  1317. >consistently, but it seems I can make it happen fairly quickly if I am
  1318. >trying.
  1319.  
  1320. The best theory I've heard to explain this (I haven't been able to confirm
  1321. it) is that the process manager is looking down the event queue for mouse
  1322. clicks that would change the current process, and it steals those
  1323. events to make the major switch occur more quickly.  Since the clicks never
  1324. reach the head of the event queue, GNEFilters never see them.
  1325.  
  1326. Grobbins             grobbins@apple.com
  1327.  
  1328. Usual disclaimers apply.
  1329.  
  1330. +++++++++++++++++++++++++++
  1331.  
  1332. >From rmah@panix.com (Robert S. Mah)
  1333. Date: Sun, 22 May 1994 22:32:09 -0500
  1334. Organization: One Step Beyond
  1335.  
  1336. grobbins@apple.com (Grobbins) wrote:
  1337.  
  1338. > Troy Gaul <tgaul@halcyon.com> wrote:
  1339. > >I've had problems with this and other programs that use a Text Services
  1340. > >Manager window. The problem is that at times, clicks 'fall through' to the
  1341. > >application that is below the window.  This problem doesn't seem to happen
  1342. > The best theory I've heard to explain this (I haven't been able to confirm
  1343. > it) is that the process manager is looking down the event queue for mouse
  1344. > clicks that would change the current process, and it steals those events
  1345. > to make the major switch occur more quickly.  Since the clicks never reach
  1346. > the head of the event queue, GNEFilters never see them.
  1347.  
  1348. I think you're right (or pretty close).  I had to patch PPostEvent (or was
  1349. it just _PostEvent?) to keep those clicks from reaching the system.  This 
  1350. works consistantly and only lets clicks that _I_ want through to the
  1351. system.
  1352.  
  1353. Cheers,
  1354. Rob
  1355. ___________________________________________________________________________
  1356. Robert S. Mah  -=-  One Step Beyond  -=-  212-947-6507  -=-  rmah@panix.com
  1357.  
  1358. ---------------------------
  1359.  
  1360. >From Thomas Reed <reed@medicine.wustl.edu>
  1361. Subject: Installing Gestalts -- how to set up A5 world?
  1362. Date: 16 May 1994 14:42:37 GMT
  1363. Organization: Washington University
  1364.  
  1365. I wanted to install some Gestalt selectors for a program I'm writing, but
  1366. there's just one small problem.  According to IM VI, I need to set up my
  1367. app's A5 world in the function that is called to return the result code. 
  1368. I've done this kind of stuff in VBL tasks, Notification Manager tasks,
  1369. and Sound Manager callback routines, but in every one of those cases,
  1370. there's a way to send the function the value of your app's A5.  But,
  1371. there's no way to pass this info to the result code function.  So how do
  1372. I do it?
  1373.  
  1374. Thanks in advance for any help!
  1375.  
  1376. -Thomas
  1377. =====================================================
  1378. Thomas Reed                    Washington University
  1379. Reed@telesphere.wustl.edu          Medical School
  1380. (also:  Reed@medicine.wustl.edu)
  1381. - ---------------------------------------------------
  1382. Clothes make the man.  Naked people have little or no
  1383. influence on society.  -- Mark Twain
  1384. =====================================================
  1385.  
  1386. +++++++++++++++++++++++++++
  1387.  
  1388. >From rgaros@bio.vu.nl (Rene G.A. Ros)
  1389. Date: Mon, 16 May 1994 17:57:18 GMT
  1390. Organization: VU Biology, Amsterdam, The Netherlands
  1391.  
  1392. reed@medicine.wustl.edu (Thomas Reed) writes:
  1393. : I wanted to install some Gestalt selectors for a program I'm writing, but
  1394. : there's just one small problem.  According to IM VI, I need to set up my
  1395. : app's A5 world in the function that is called to return the result code. 
  1396. : I've done this kind of stuff in VBL tasks, Notification Manager tasks,
  1397. : and Sound Manager callback routines, but in every one of those cases,
  1398. : there's a way to send the function the value of your app's A5.  But,
  1399. : there's no way to pass this info to the result code function.  So how do
  1400. : I do it?
  1401. :
  1402. You can use the GestaltValue code from Apple to install a long and don't
  1403. bother with your own GDEF function at all...
  1404. The GestaleValue Lib adds three functions: NewGestaltValue, ReplaceGestaltvalue,
  1405. and DeleteGestaltValue. These functions will be part of a future system
  1406. version and the library code already checks for this and will call the
  1407. GestaltValueDispatch trap when it is available.
  1408.  
  1409. See the Gestalt Selectors List for more info. Or download the GestaltValue
  1410. Lib from sumex (info-mac) mirrors. I think it is in the /dev directory.
  1411. And the Gestalt List is avalable as /dev/info/gestalt-selectors-24.hqx
  1412.  
  1413. Bye,
  1414. Rene
  1415.  
  1416. PS. I remember seeing your name with more postings about Gestalt. Isn't it
  1417. time to subscribe to the Gestalt Selectors List and receive updates as well?
  1418. Contact me (the editor of that list) for more info. Bye!
  1419.  
  1420. -- 
  1421.  
  1422. - ------------------------------------------------------------------------------
  1423.   Rene G.A. Ros                                      Amsterdam, The Nederlands
  1424.   rgaros@bio.vu.nl         rgaros@nikhefk.nikhef.nl          rener@htsa.aha.nl
  1425.  
  1426. +++++++++++++++++++++++++++
  1427.  
  1428. >From gurgle@netcom.com (Pete Gontier)
  1429. Date: Mon, 16 May 1994 19:46:37 GMT
  1430. Organization: cellular
  1431.  
  1432. Thomas Reed <reed@medicine.wustl.edu> writes:
  1433.  
  1434. >I wanted to install some Gestalt selectors for a program I'm writing,
  1435. >but there's just one small problem. According to IM VI, I need to set
  1436. >up my app's A5 world in the function that is called to return the
  1437. >result code. I've done this kind of stuff in VBL tasks, Notification
  1438. >Manager tasks, and Sound Manager callback routines, but in every one of
  1439. >those cases, there's a way to send the function the value of your app's
  1440. >A5. But, there's no way to pass this info to the result code function.
  1441. >So how do I do it?
  1442.  
  1443. This is not your only problem. The Gestalt Manager is very picky about
  1444. where it thinks your Gestalt selector function ought to live. If it's
  1445. not in the System Heap, the Gestalt Manager won't let you install the
  1446. function. There's also the problem of what to do when your app quits.
  1447. The Gestalt Manager doesn't support a call to remove your selector
  1448. function.
  1449.  
  1450. I once solved all three of these problems with a 68K hack. Those are
  1451. passe now that PowerPC is here. Neverthless, on the off chance you feel
  1452. like messing with it, here's the poop:
  1453.  
  1454. In the System Heap, allocate a struct and inside it a union and a
  1455. state variable. The state variable has two possible values indicating
  1456. the state of the union (yes, pun intended -- sue me). If your app is
  1457. running, the union should contain the relevant value of A5 and some code
  1458. to set it up and call code which lives inside your app. If your app is
  1459. not running, the union should contain code which returns a suitable
  1460. error code. Make sure the offsets into the struct are the same for
  1461. the code in both the active and inactive state. You might do this by
  1462. using the value of A5 as the state variable -- 0 indicates the block is
  1463. inactive, and anything in the struct after that value is assumed to be
  1464. code.
  1465.  
  1466. When your app starts up, it should check to see if the block in the
  1467. System Heap has already been installed by querying Gestalt for the
  1468. address of the function which corresponds to your selector. If it's not
  1469. there, create it in the active state. If it's there, assume it's in the
  1470. inactive state and rewrite it so that it's in the active state. When
  1471. your app quits (and it's best to do this in a patch to ExitToShell,
  1472. although I don't think I bothered), rewrite the block so it's in the
  1473. inactive state. (For some added safety, don't ever assume it's in the
  1474. inactive state and warn the user with a confirmation dialog before
  1475. transforming it.)
  1476.  
  1477. When you're done, you've just committed a nasty self-modifying code
  1478. trick, so all relevant caveats apply.
  1479.  
  1480. KEY POINT: you're much better off with AppleEvents.
  1481.  
  1482. But sometimes performance demands such disgusting hacks as the one I
  1483. have described here. There is even an Apple-described (although probably
  1484. not Apple-sanctioned) library for achieving this end, although the
  1485. relevant reference eludes me presently. Probably 'd e v e l o p'.
  1486.  
  1487. If you would like to strike a balance between performance and elegance,
  1488. consider an auxilliary system extension which implements your Gestalt
  1489. selector on your app's behalf. This sacrifices some user convenience
  1490. and a little bit of memory *and* makes you work a little bit if you
  1491. still want the meat of your Gestalt selector function inside your app.
  1492. However, on the up-side, it might even port to PowerPC without too much
  1493. of a hassle.
  1494. -- 
  1495.  Pete Gontier, CTO, Integer Poet Software; gurgle@netcom.com
  1496.  
  1497.  C   credo: "Trust the programmer."
  1498.  C++ credo: "Put the muzzle of a shotgun in your mouth and
  1499.              give the programmer the trigger..."
  1500.  
  1501. +++++++++++++++++++++++++++
  1502.  
  1503. >From arentz@knoware.nl (Stefan Arentz)
  1504. Date: Tue, 17 May 1994 00:54:57 GMT
  1505. Organization: Lunatech Software Development
  1506.  
  1507. In article <2r80otINNahl@medicine.wustl.edu>
  1508. Thomas Reed <reed@medicine.wustl.edu> writes:
  1509.  
  1510. > I wanted to install some Gestalt selectors for a program I'm writing, but
  1511. > there's just one small problem.  According to IM VI, I need to set up my
  1512. > app's A5 world in the function that is called to return the result code. 
  1513. > I've done this kind of stuff in VBL tasks, Notification Manager tasks,
  1514. > and Sound Manager callback routines, but in every one of those cases,
  1515. > there's a way to send the function the value of your app's A5.  But,
  1516. > there's no way to pass this info to the result code function.  So how do
  1517. > I do it?
  1518.  
  1519. Here's some that I used:
  1520.  
  1521. // RememberA5.h - Written by Stefan Arentz, May 1994
  1522.  
  1523. asm static void __GetA5Storage(void) {
  1524.         bsr.s   a             //
  1525.         dc.l    0             //  store A5 here
  1526.     a:  move.l  (sp)+,a0      //
  1527. }
  1528.  
  1529. asm static void RememberA5(void) {
  1530.         jsr    __GetA5Storage  //
  1531.         move.l a5,(a0)         //
  1532. }
  1533.  
  1534. asm static void SetUpA5(void) {
  1535.         move.l a5,-(sp)        //
  1536.         jsr    __GetA5Storage  //
  1537.         move.l (a0),a5         //
  1538. }
  1539.  
  1540. asm static void RestoreA5(void) {
  1541.         move.l (sp)+,a5        //
  1542. }
  1543.  
  1544. Now, to install the Gestalt selector you do the following:
  1545.  
  1546. #include "SetUpA5.h"
  1547.  
  1548. void foo(void) {
  1549.  
  1550.     // This stores the current value of A5 in __GetA5Storage.
  1551.     RememberA5();
  1552.     
  1553.     OSErr theError = NewGestalt(kMyGestaltSelector, MyGestaltProc);
  1554.  
  1555. }
  1556.  
  1557. pascal void MyGestaltProc(...) {
  1558.  
  1559.     // Remember the current A5 on the stack, and set A5
  1560.     // to the one we remembered before installing the selector. 
  1561.     
  1562.     SetUpA5();
  1563.     
  1564.     // Do your work here...
  1565.  
  1566.     // ...
  1567.  
  1568.     // And restore A5.  
  1569.     
  1570.     RestoreA5();
  1571.  
  1572. }
  1573.  
  1574. > Thanks in advance for any help!
  1575.  
  1576. You're welcome :-)
  1577.  
  1578. - ----------------------------------------------------------------------
  1579.  
  1580. Stefan Arentz        --       arentz@knoware.nl       --        Lunatech
  1581.  
  1582. +++++++++++++++++++++++++++
  1583.  
  1584. >From Dale_Semchishen@mindlink.bc.ca (Dale Semchishen)
  1585. Date: Tue, 17 May 94 10:47:39 -0700 (PDT)
  1586. Organization: MIND LINK! - British Columbia, Canada
  1587.  
  1588. In article <Cpx97L.A9t@knoware.nl>, arentz@knoware.nl (Stefan Arentz)
  1589. writes:
  1590. >
  1591. >
  1592. >         ... [ stuff deleted ] ...
  1593. >
  1594. > Here's some that I used:
  1595. >
  1596. > // RememberA5.h - Written by Stefan Arentz, May 1994
  1597. >
  1598. > asm static void __GetA5Storage(void) {
  1599. >         bsr.s   a             //
  1600. >         dc.l    0             //  store A5 here
  1601. >     a:  move.l  (sp)+,a0      //
  1602. > }
  1603. >
  1604. >         ... [ stuff deleted ] ...
  1605. >
  1606.  
  1607.  
  1608. Isn't this self-modifying code?
  1609.  
  1610. When memory protection is available on a future version
  1611. of the Mac OS I believe that the code segment will be protected
  1612. such that only read access will be allowed.
  1613.  
  1614. --
  1615. Dale_Semchishen@mindlink.bc.ca
  1616.  
  1617.  
  1618. +++++++++++++++++++++++++++
  1619.  
  1620. >From Bruce@hoult.actrix.gen.nz (Bruce Hoult)
  1621. Date: Thu, 19 May 1994 23:24:44 +1200 (NZST)
  1622. Organization: (none)
  1623.  
  1624. Dale_Semchishen@mindlink.bc.ca (Dale Semchishen) writes:
  1625. > Isn't this self-modifying code?
  1626. > When memory protection is available on a future version
  1627. > of the Mac OS I believe that the code segment will be protected
  1628. > such that only read access will be allowed.
  1629.  
  1630. You mean like it is for PowerMac native programs when virtual memory
  1631. is turned on?
  1632.  
  1633. ..course the posted code was 68K Asm, so the question is moot in that
  1634. case.
  1635.  
  1636.  
  1637. Also, that wasn't actually self-modifying code, since the memory location
  1638. in question is never exceuted as code, just used to store data, so it's
  1639. perfectly cache-safe.
  1640.  
  1641. -- Bruce
  1642.  
  1643. +++++++++++++++++++++++++++
  1644.  
  1645. >From gurgle@netcom.com (Pete Gontier)
  1646. Date: Fri, 20 May 1994 22:36:48 GMT
  1647. Organization: cellular
  1648.  
  1649. Dale_Semchishen@mindlink.bc.ca (Dale Semchishen) writes:
  1650.  
  1651. >> asm static void __GetA5Storage(void) {
  1652. >>         bsr.s   a             //
  1653. >>         dc.l    0             //  store A5 here
  1654. >>     a:  move.l  (sp)+,a0      //
  1655. >> }
  1656.  
  1657. >Isn't this self-modifying code?
  1658.  
  1659. Uh, sort of. Strictly speaking, yes. However, it does not succumb to the
  1660. pitfalls associated with self-modifying code currently. Note that the
  1661. DC.L declaration is data and stays that way. If it were ever executed
  1662. code, you might run into cache problems.
  1663.  
  1664. >When memory protection is available on a future version of the Mac OS
  1665. >I believe that the code segment will be protected such that only read
  1666. >access will be allowed.
  1667.  
  1668. On the other hand, I doubt this memory protection will ever appear on a
  1669. 68K-based Mac, so this code will not be present anyway. :-)
  1670. -- 
  1671.  Pete Gontier, CTO, Integer Poet Software; gurgle@netcom.com
  1672.  
  1673.  "Bedrock does support a form of drag and drop. Development dragged on
  1674.  for about two years, and then was dropped." -- Brian Clark
  1675.  
  1676. +++++++++++++++++++++++++++
  1677.  
  1678. >From mxmora@unix.sri.com (Matt Mora)
  1679. Date: 23 May 1994 10:19:34 -0700
  1680. Organization: SRI International, Menlo Park, CA
  1681.  
  1682. In article <gurgleCq4HHD.295@netcom.com> gurgle@netcom.com (Pete Gontier) 
  1683. writes:
  1684.  
  1685. >>When memory protection is available on a future version of the Mac OS
  1686. >>I believe that the code segment will be protected such that only read
  1687. >>access will be allowed.
  1688.  
  1689. >On the other hand, I doubt this memory protection will ever appear on a
  1690. >68K-based Mac, so this code will not be present anyway. :-)
  1691.  
  1692. Not so fast, Pete. That's not what the said a the WWDC. :-)
  1693.  
  1694.  
  1695. Xavier
  1696.  
  1697. -- 
  1698. ___________________________________________________________
  1699. Matthew Xavier Mora                       Matt_Mora@sri.com
  1700. SRI International                       mxmora@unix.sri.com
  1701. 333 Ravenswood Ave                    Menlo Park, CA. 94025
  1702.  
  1703. ---------------------------
  1704.  
  1705. >From rpoldrac@s.psych.uiuc.edu (Russ Poldrack)
  1706. Subject: Looking for C code to display color PICT files
  1707. Date: 24 May 1994 15:36:28 GMT
  1708. Organization: UIUC Department of Psychology
  1709.  
  1710. I need to display color PICT files to the screen using THINK C.  I
  1711. can't find any code in the archives that will help me do this, and my
  1712. translation of the Pascal code from IM5 won't work.  Any help would be
  1713. greatly appreciated.
  1714.  
  1715. Russ Poldrack
  1716. rpoldrac@s.psych.uiuc.edu
  1717.  
  1718. +++++++++++++++++++++++++++
  1719.  
  1720. >From kenlong@netcom.com (Ken Long)
  1721. Date: Tue, 24 May 1994 22:05:18 GMT
  1722. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  1723.  
  1724. : I can't find any code in the archives that will help me do this....
  1725.  
  1726. Then you are not looking in enough archives.
  1727.  
  1728. Check in the Apple ftp's dts directory - there are a lot of projects 
  1729. there that will read a pict.  I'll bet DTS/Draw would open  'PICT' file.
  1730.  
  1731. Also, look in the develop code files.  (Get an all-file list of any 
  1732. directories you look into.)  "Is this art?" may be one to check.
  1733.  
  1734. Look on the Mac FTP List.  There are ftp's listed, with archives, 
  1735. containing all sorts of C source code projects.  Chuck Hoffman's GTE ftp 
  1736. directory has Chassis v6, which will open a 'PICT' as I recall.  That 
  1737. file is on other ftp's as well.
  1738.  
  1739. Scour any and ALL potential locations for downloadable Think C example 
  1740. source.  Get another hard drive to handle it.  Example source is a 
  1741. successful programmer's way of saying "Here's how you do...!"  The more 
  1742. you have, the more answers you have.
  1743.  
  1744. -Ken-
  1745.  
  1746. +++++++++++++++++++++++++++
  1747.  
  1748. >From grobbins@apple.com (Grobbins)
  1749. Date: 25 May 1994 11:05:31 -0700
  1750. Organization: Skunkworks
  1751.  
  1752. In article <2rt6ts$86q@vixen.cso.uiuc.edu>,
  1753. Russ Poldrack <rpoldrac@s.psych.uiuc.edu> wrote:
  1754. >I need to display color PICT files to the screen using THINK C.  I
  1755. >can't find any code in the archives that will help me do this
  1756.  
  1757. Here's a basic routine from the code for SimpleDrag (documented in
  1758. develop 16, and available on the develop Bookmark CD.)  It extracts the
  1759. picture from a pict file into a handle, which can then be used in a
  1760. call to DrawPicture.  It is not suitable for some large picture files;
  1761. an incremental routine (more like what's done in IM V) would be better
  1762. for the general case.
  1763.  
  1764. Grobbins            grobbins@apple.com
  1765.  
  1766. Usual disclaimers apply.
  1767.  
  1768. ____________
  1769.  
  1770. from SimpleDrag.c:
  1771.  
  1772. // SetWindowPictureFromFile reads the PICT file specified by pictSpec
  1773. // and replaces the window's picture with the new one by calling
  1774. // SetWindowPicture
  1775.  
  1776. OSErr SetWindowPictureFromFile(FSSpecPtr pictSpec, WindowPtr theWindow)
  1777. {
  1778.     OSErr        retCode;
  1779.     short        pictRefNum;
  1780.     long        fileLength;
  1781.     Size        pictSize;
  1782.     Handle        tempHandle;
  1783.     
  1784.     pictRefNum = 0;
  1785.     tempHandle = nil;
  1786.     
  1787.     // open the file and find its size
  1788.     retCode = FSpOpenDF(pictSpec, fsRdPerm, &pictRefNum);
  1789.     if (retCode != noErr) goto Bail;
  1790.     
  1791.     retCode = GetEOF(pictRefNum, &fileLength);
  1792.     if (retCode != noErr) goto Bail;
  1793.     
  1794.     // skip over 512-byte pict file header
  1795.     retCode = SetFPos(pictRefNum, fsFromMark, 512);
  1796.     if (retCode != noErr) goto Bail;
  1797.  
  1798.     pictSize = fileLength - 512;
  1799.     
  1800.     // allocate a buffer for the file's picture data,
  1801.     // in temp memory if it is available
  1802.     if (gHasRealTempHandlesFlag)
  1803.         tempHandle = TempNewHandle(pictSize, &retCode);
  1804.     else {
  1805.         tempHandle = NewHandle(pictSize);
  1806.         retCode = MemError();
  1807.     }
  1808.     if (tempHandle == nil) goto Bail;
  1809.     
  1810.     // read in the picture data
  1811.     HLock(tempHandle);              // paranoid
  1812.     retCode = FSRead(pictRefNum, &pictSize, *tempHandle);
  1813.     HUnlock(tempHandle);
  1814.     if (retCode != noErr) goto Bail;
  1815.     
  1816.     // replace the window's picture with the new data
  1817.     retCode = SetWindowPicture(theWindow, (PicHandle) tempHandle);
  1818.     
  1819. Bail:
  1820.     if (pictRefNum != 0) FSClose(pictRefNum);
  1821.     if (tempHandle != nil) DisposeHandle(tempHandle);
  1822.     
  1823.     return retCode;
  1824. }
  1825.  
  1826.  
  1827. ---------------------------
  1828.  
  1829. >From td068515@LANCE.ColoState.Edu (Yimmit)
  1830. Subject: Palette updates??
  1831. Date: Fri, 20 May 1994 18:42:24 GMT
  1832. Organization: Imladris Occupants Inc.
  1833.  
  1834. Hi all!
  1835.  
  1836. I have a quick question that one of you may be able to answer.  I am working
  1837. on a program that opens TIFF files and has a floating window on screen at all
  1838. times.  My problem is that the palette I set for the window doesn't change the
  1839. device CLUT when I display the window.  I'm guessing this is because the 
  1840. floater still looks like the front window to the monitor driver (?)  How can I
  1841. force the palette to be used?  I have tried ActivatePalette sending the window
  1842. in, but it didn't work.  Does anyone have any ideas?  Thanks in advance!!
  1843. -->Tim Damon
  1844.  
  1845.  
  1846. +++++++++++++++++++++++++++
  1847.  
  1848. >From tr0ygt@aol.com (TR0Y GT)
  1849. Date: 20 May 1994 23:54:06 -0400
  1850. Organization: America Online, Inc. (1-800-827-6364)
  1851.  
  1852. In article <Cq46Mo.12H9@yuma.ACNS.ColoState.EDU>,
  1853. td068515@LANCE.ColoState.Edu (Yimmit) writes:
  1854.  
  1855. Make sure that the palette entries you get from the TIF file are
  1856. setup as pmTolerant + pmExplicit, with a tolorance value of 0.  I
  1857. think SetPalette and NSetPalette both allow you to adjust the palette
  1858. entries' usage in this way. After you do this, then
  1859. ActivatePalette(). Doing this will force good color arbitration in
  1860. your floating Window.
  1861.  
  1862. TR0YGT@aol.com
  1863.  
  1864. +++++++++++++++++++++++++++
  1865.  
  1866. >From Mark Hanrek <hanrek@cts.com>
  1867. Date: 21 May 1994 09:41:14 GMT
  1868. Organization: The Information Workshop
  1869.  
  1870. In article <Cq46Mo.12H9@yuma.ACNS.ColoState.EDU> Yimmit,
  1871. td068515@LANCE.ColoState.Edu writes:
  1872.  
  1873. > My problem is that the palette I set for the window doesn't change the
  1874. > device CLUT when I display the window. 
  1875.  
  1876. Someone else reported troubles recently when working with floating
  1877. windows. 
  1878.  
  1879. It may be possible to skip the whole issue and do what Forest Tanaka does
  1880. in his "ResetColors" example source code found on the Developer CD.
  1881.  
  1882. I have done it before with HyperCard and it works great.  What you do is
  1883. temporarily create a 1 pixel square window in the extreme upper left
  1884. corner of the screen, which is masked out because of the rounded corners
  1885. of the Mac's screens. ( look up there now :).  
  1886.  
  1887. Show this micro-dot window, NSetPalette, ActivatePalette, and then
  1888. dispose (or close, I can never remember which) the window, and go back to
  1889. what you were doing.
  1890.  
  1891. Hope this helps.
  1892.  
  1893. Mark Hanrek
  1894.  
  1895. +++++++++++++++++++++++++++
  1896.  
  1897. >From Joe Francis <Joe.Francis@dartmouth.edu>
  1898. Date: 23 May 1994 22:17:58 GMT
  1899. Organization: Smooth Roo Software
  1900.  
  1901. It's really weird that right after I post about this very problem it
  1902. comes up again.  I guess everyone is doing the same thing at the same
  1903. time.  
  1904.  
  1905. Tim Damon writes:
  1906. > working on a program that opens TIFF files and has a floating window
  1907. > on screen at all times.  My problem is that the palette I set for the
  1908. > window doesn't change the device CLUT when I display the window.  I'm
  1909. > guessing this is because the  floater still looks like the front
  1910. > window to the monitor driver (?)  How can I force the palette to be
  1911. > used?  I have tried ActivatePalette sending the window in, but it
  1912. > didn't work.  
  1913.  
  1914.  
  1915. TR0Y GT, tr0ygt@aol.com writes:
  1916. > Make sure that the palette entries you get from the TIFF file are
  1917. > setup as pmTolerant + pmExplicit, with a tolerance value of 0.  I
  1918. > think SetPalette and NSetPalette both allow you to adjust the palette
  1919. > entries' usage in this way. After you do this, then
  1920. > ActivatePalette(). Doing this will force good color arbitration in
  1921. > your floating Window.
  1922.  
  1923. He is probably already doing this.  If I understand him correctly,
  1924. its not that he is not using the Palette Manager, it's that the 
  1925. Palette manager refuses to honor ActivatePalette() requests for
  1926. anything other than the frontmost visible window in the application
  1927. window list.  He wants the Palette associated with his TIFF window
  1928. (sounds like we are writing the same app, Tim), not his floating window.
  1929.  
  1930. Mark Hanrek, hanrek@cts.com writes:
  1931. > What you do is
  1932. > temporarily create a 1 pixel square window in the extreme upper left
  1933. > corner of the screen, which is masked out because of the rounded corners
  1934. > of the Mac's screens. ( look up there now :).  
  1935. > Show this micro-dot window, NSetPalette, ActivatePalette, and then
  1936. > dispose (or close, I can never remember which) the window, and go back to
  1937. > what you were doing.
  1938.  
  1939. This approach is similar to my first cut at this problem (my first cut
  1940. was simply to figure out what my frontmost image window was, and bump
  1941. that palette up to the frontmost floating window).  The problem with
  1942. approaches like this is that it doesn't work well with multi-monitor 
  1943. setups.  
  1944.  
  1945. I don't think what I finally settled on is perfect either, but it's 
  1946. the best I can come up with so far.  The basic idea is: every time you
  1947. move, drag, or select a window, to briefly swap that window to the
  1948. front of the window list (by directly manipulating the window list),
  1949. call ActivatePalette(), and then call PaintOne() on the backmost 
  1950. floating  window with a region that corresponds to the structure
  1951. region of the selected window.
  1952.  
  1953. This seems to work perfectly except you get a brief flicker in the window
  1954. frame of any floating window that is over top of your image window.
  1955. (Actually, the flicker is only noticeable if the frames of the floating
  1956. window and the image window intersect.)
  1957.  
  1958. I posted source for using this with Dean Yu's floating windows code
  1959. to alt.source.mac just a few days ago.  I will email it to anyone
  1960. who wants it.
  1961.  
  1962. If you find problems, or come up with a better way, please let me know.
  1963.  
  1964. Thanks,
  1965. Joe Francis
  1966. Dartmouth College Information Systems
  1967.  
  1968. - ------------------------------------------------------------------------
  1969. "bolo needs to be on many machines just like MS Word" - Tempest
  1970. - ------------------------------------------------------------------------
  1971.  
  1972. +++++++++++++++++++++++++++
  1973.  
  1974. >From damon@CS.ColoState.EDU (Yimmit)
  1975. Date: Tue, 24 May 1994 03:49:02 GMT
  1976. Organization: Imladris Occupants Inc.
  1977.  
  1978. >TR0Y GT, tr0ygt@aol.com writes:
  1979. >> Make sure that the palette entries you get from the TIFF file are
  1980. >> setup as pmTolerant + pmExplicit, with a tolerance value of 0.  I
  1981. >> think SetPalette and NSetPalette both allow you to adjust the palette
  1982. >> entries' usage in this way. After you do this, then
  1983. >> ActivatePalette(). Doing this will force good color arbitration in
  1984. >> your floating Window.
  1985. >
  1986. >He is probably already doing this.  If I understand him correctly,
  1987. >its not that he is not using the Palette Manager, it's that the 
  1988. >Palette manager refuses to honor ActivatePalette() requests for
  1989. >anything other than the frontmost visible window in the application
  1990. >window list.  He wants the Palette associated with his TIFF window
  1991. >(sounds like we are writing the same app, Tim), not his floating window.
  1992.  
  1993. Yeah, I already performed this one, unfortunately, ActivatePalette() did not
  1994. seem to do anything!  I finally figured out that the window I was using did
  1995. not look like the front active window as far as the Mac was concerned. 
  1996. Apparently, ActivatePalette() only works when the srcWindow is THE front window.
  1997. My final solution, which seems to work, is to bring the TIFF window all the way
  1998. to the front, activate it's palette, then bring the floating windows back in
  1999. front of the image window.  This probably isn't the most elegant way since the
  2000. palette switch takes a while, and you can see the windows shuffling around, but
  2001. it works.
  2002.  
  2003. Thanks for all the replies!
  2004. -->Tim Damon
  2005.  
  2006. ---------------------------
  2007.  
  2008. >From dubois@primate.wisc.edu (Paul DuBois)
  2009. Subject: PenPat((ConstPatternParam)gray) - why illegal cast?
  2010. Date: 13 May 1994 16:43:25 -0500
  2011. Organization: Castra Parvulorum
  2012.  
  2013. Under THINK C 7 with the universal headers, the following line
  2014. results in "illegal cast".
  2015.  
  2016.     PenPat ((ConstPatternParam) gray);
  2017.  
  2018. How come?  This is legal in THINK C 6 with THINK's header files.
  2019. -- 
  2020. Paul DuBois
  2021. dubois@primate.wisc.edu
  2022.  
  2023. +++++++++++++++++++++++++++
  2024.  
  2025. >From jwbaxter@olympus.net (John W. Baxter)
  2026. Date: Fri, 13 May 1994 22:55:36 -0700
  2027. Organization: Internet for the Olympic Peninsula
  2028.  
  2029. In article <2r0s9tINN5eq@uakari.primate.wisc.edu>, dubois@primate.wisc.edu
  2030. (Paul DuBois) wrote:
  2031.  
  2032. > Under THINK C 7 with the universal headers, the following line
  2033. > results in "illegal cast".
  2034. >     PenPat ((ConstPatternParam) gray);
  2035. > How come?  This is legal in THINK C 6 with THINK's header files.
  2036.  
  2037. Patterns are different in the Universal headers (and in recent
  2038. pre-Universal MPW headers) than they were in the Think C 6 headers.  [They
  2039. are structs, not arrays.]  gray is now referenced as qd.gray, a pointer to
  2040. gray is now &qd.gray, and I haven't looked at ConstPatternParam but I
  2041. suspect it is a pointer to a const pattern, which would indeed cause an
  2042. illegal cast.
  2043. -- 
  2044. John Baxter    Port Ludlow, WA, USA  [West shore, Puget Sound]
  2045.    jwbaxter@pt.olympus.net
  2046.  
  2047. +++++++++++++++++++++++++++
  2048.  
  2049. >From sigurasg@rhi.hi.is (Sigurdur Asgeirsson)
  2050. Date: 17 May 1994 12:59:30 GMT
  2051. Organization: University of Iceland
  2052.  
  2053. In <2r0s9tINN5eq@uakari.primate.wisc.edu> dubois@primate.wisc.edu (Paul DuBois) writes:
  2054.  
  2055. >Under THINK C 7 with the universal headers, the following line
  2056. >results in "illegal cast".
  2057.  
  2058. >    PenPat ((ConstPatternParam) gray);
  2059.  
  2060. >How come?  This is legal in THINK C 6 with THINK's header files.
  2061.  
  2062.   If you look at the headers you'll see that a pattern used to be a char
  2063. array, but is now a struct containing a char array. In C and C++,
  2064. whenever you use an array it automagically degenerates to a pointer to
  2065. the type in question (except when used with sizeof). Furthermore, the
  2066. only allowable casts in C are between pointer types and various
  2067. int/float types, but what you're trying to do in the above code fragment
  2068. (with the new headers) amounts to casting something (probably a char*)
  2069. to a struct - this is not allowed. What you can do however is:
  2070.  
  2071.    PenPat(*(ConstPatternParam*)&gray);
  2072.  
  2073. -- 
  2074. Sigurdur Asgeirsson    | "Well you know, C isn't that hard, void (*(*f[])())()
  2075. Kambasel 26            | for instance declares f as an array of unspecified 
  2076. 109 Reykjavik, Iceland | size, of pointers to functions that return pointers to
  2077. sigurasg@rhi.hi.is     | functions that return void... I think"
  2078.  
  2079. ---------------------------
  2080.  
  2081. >From Jochen Meyer <jochen@blanc.north.de>
  2082. Subject: SC++ and __vtbl?
  2083. Date: Thu, 19 May 94 21:02:20 +0200  (MES)
  2084. Organization: Meyer & Son
  2085.  
  2086.  
  2087. Hello folks
  2088.  
  2089. After having updated from Symantec C++/MPW 6.01 to 7.0 I keep on getting a 
  2090. linker error:
  2091.  
  2092. > ### Link: Error: Undefined entry, name: (Error 28) "_vtbl__7gr_line"
  2093. >   Referenced from: __ct__7gr_lineFv in file: groby.o
  2094.  
  2095. not only for this class gr_line, but for a variety of classes, large and small, 
  2096. easy and complicated. Other classes - also very similar ones to the failing ones 
  2097. - seem to compile and link perfectly fine. I tried lots of compiler switches, 
  2098. read forward and backward through the manuals, looked for help in the info-mac 
  2099. and elsewhere, changed my code, but no chance. 
  2100.  
  2101. The error appeared for one class with the 6.01 compiler already but I could do 
  2102. without that class. Now I really can't work around this error. Also, I cannot 
  2103. continue my work, as long as that problem is not solved (the program does not 
  2104. link!!!)
  2105.  
  2106. So: If you already had a similar problem: PLEASE, PLEASE: HOW DID YOU GET IT TO 
  2107. WORK??? If not, at least send me a sympathetic mail.
  2108.  
  2109. Desperately
  2110. Jochen
  2111.  
  2112. --
  2113.  
  2114. | Jochen Meyer         |  Internet: jochen@blanc.north.de   |
  2115. | Heuberge 12b         |  phone: +49 - 4432 - 1609 (voice)  |
  2116. | D-27801 Neerstedt    |                                    |
  2117. |-----------------------------------------------------------|
  2118. | "Eat a live toad in the morning,                          |
  2119. |     and nothing worse can happen to you the day"          |
  2120.  
  2121. +++++++++++++++++++++++++++
  2122.  
  2123. >From afcjlloyd@aol.com (AFC JLloyd)
  2124. Date: 20 May 1994 03:31:04 -0400
  2125. Organization: America Online, Inc. (1-800-827-6364)
  2126.  
  2127. In article <94051921022000311@blanc.north.de>, Jochen Meyer
  2128. <jochen@blanc.north.de> writes:
  2129.  
  2130. > After having updated from Symantec C++/MPW 6.01 to 7.0 I keep on
  2131. getting a 
  2132. > linker error:
  2133. > > ### Link: Error: Undefined entry, name: (Error 28)
  2134. "_vtbl__7gr_line"
  2135. > >   Referenced from: __ct__7gr_lineFv in file: groby.o
  2136.  
  2137. Errors of this sort happen in several C++ compilers (see a very
  2138. recent Andy Koenig article in the C++ Report, sorry I don't have the
  2139. reference handy).  The problem happens because of something like
  2140. this:
  2141.  
  2142. 1) Each class must have a vtbl generated once and only once.
  2143. 2) Many translation units see the class declaration, so the compiler
  2144. can't generate a vtbl simply from seeing a class declaration.
  2145. 3) Class methods should be defined in one and only one translation
  2146. unit, so if some particular method is considered the "magic" method,
  2147. then the compiler can generate the vtbl in the translation unit that
  2148. defines the magic method.
  2149. 4) The compiler chooses some adhoc rule for defining the magic
  2150. method, such as the first virtual function listed in the class
  2151. declaration.
  2152. 5) Something subtle foils the adhoc rule.
  2153.  
  2154. The example Koenig gives is when a programmer simply neglects to
  2155. implement the "magic" method.  Since the method is never implemented,
  2156. the compiler is never triggered to generate the vtbl for the class.
  2157. This can be a subtle problem to diagnose, because it's possible that
  2158. the programmer hasn't yet written any code that uses the magic
  2159. method, so she doesn't get a linker error telling her that the method
  2160. is undefined, but she does get the undefined vtbl message.
  2161.  
  2162. Symantec C++ used to have a problem like this (which I'm pretty sure
  2163. has since been fixed) which happened when the first method declared
  2164. in the header was defined as an inline later in the .h file, like so:
  2165.  
  2166. class foo
  2167. {
  2168.    void function1(void);
  2169. };
  2170.  
  2171. inline void function1(void)
  2172. {
  2173.    ...
  2174. }
  2175.  
  2176. While the problem existed, there was a workaround to add the inline
  2177. keyword in the class declaration, or to simply move the function
  2178. definition into the class declaration:
  2179.  
  2180. class foo
  2181. {
  2182.    void function1(void) {...}
  2183. };
  2184.  
  2185. This workaround allowed the compiler to realized that it couldn't use
  2186. that method as the "magic" method.
  2187.  
  2188. To avoid this problem, I personally chose to use the following coding
  2189. style guidelines:
  2190.  
  2191. 1) Any class that has any virtual function must have a virtual
  2192. destructor.
  2193. 2) The virtual destructor is always the first method in the class
  2194. declaration.
  2195. 3) Virtual destructors are never declared to be inline.
  2196.  
  2197. By using these rules, the only times I've had undefined vtbl errors
  2198. is when I declare the destructor but forget to implement it (or when
  2199. the class is a template class and I have forgotten to instantiate it
  2200. with a #pragma template).
  2201.  
  2202. Jim Lloyd
  2203. afcjlloyd@aol.com
  2204.  
  2205.  
  2206. ---------------------------
  2207.  
  2208. End of C.S.M.P. Digest
  2209. **********************
  2210.  
  2211.  
  2212.