dowdy@apple.UUCP (Tom Dowdy) (07/02/87)
Today I was working on a dialog that needed some standard Gray lines (horizontal and vertical) to separate portions of the dialog. I was going to use a UserItem but I asked someone else what they thought. They told me to use a PICT resource to do it. It's very simple. You have two PICT resources, one contains a vertical grey line, one a horizonal (I used MacDraw to create them). When you need a line in your dialog, you simply put the PICT in your DITL, and drag it(With ResEdit) to the desired size. Voila! Instant line. It's actually much better than a UserItem (most notably in a modeless dialog) as it gets updated for you, plus you don't have any extra code overhead for getting the item and drawing it. Plus, if you wanted to change it to a different pattern, thickness, what have you, it would be simple. (Users could even change it to a frilly boarder if that amused them) If you need odd shapes, four PICTs are required, one horizonal, one vertical and 45 degree left and right angles. With these you should be able to construct any basic line figure. You learn something new every day. Tom Dowdy CSNET: dowdy@apple.CSNET Apple Computer MS:27Y AppleLink:DOWDY1 20525 Mariani Ave UUCP: {sun,voder,amdahl,decwrl}!apple!dowdy Cupertino, CA 95014 "Plus ca change, Plus c'est la meme chose."
merchant@dartvax.UUCP (Peter Merchant) (07/06/87)
In article <1256@apple.UUCP>, dowdy@apple.UUCP (Tom Dowdy) writes: > Today I was working on a dialog that needed some standard Gray lines > (horizontal and vertical) to separate portions of the dialog. > > I was going to use a UserItem but I asked someone else what they thought. > They told me to use a PICT resource to do it. > > It's very simple. You have two PICT resources, one contains a vertical > grey line, one a horizonal (I used MacDraw to create them). When you > need a line in your dialog, you simply put the PICT in your DITL, > and drag it(With ResEdit) to the desired size. > > Tom Dowdy CSNET: dowdy@apple.CSNET Recently I had to do the same thing and I came up with the same idea. The problem is, it didn't work because it was in a Desk Accessory. It seems that Font/DA Mover (at least the version I have...3.2, I think) added the PICT resource but it didn't change the reference in the dialog box. I suppose I could have still done it with a bit of code to figure out what the resource number was and change the reference in the dialog box and then draw the dialog box. Next time you're in the neighborhood with "someone else", ask if there is a nice way to use the PICT resource in a DA. -- "They call it 'understanding', Peter Merchant (merchant@dartvax.UUCP) A willingness to grow."
dowdy@apple.UUCP (07/07/87)
In article <6608@dartvax.UUCP> merchant@dartvax.UUCP (Peter Merchant) writes: >In article <1256@apple.UUCP>, dowdy@apple.UUCP (Tom Dowdy) writes: >> [ article by myself conserning PICTs and Dialogs] > >Recently I had to do the same thing and I came up with the same idea. The >problem is, it didn't work because it was in a Desk Accessory. It seems >that Font/DA Mover (at least the version I have...3.2, I think) added the >PICT resource but it didn't change the reference in the dialog box. I suppose >I could have still done it with a bit of code to figure out what the resource >number was and change the reference in the dialog box and then draw the dialog >box. > >Next time you're in the neighborhood with "someone else", ask if there is a >nice way to use the PICT resource in a DA. I was in the neighborhood so I thought I would answer it myself. The problem described above concerns the renumbering of resources by the font/da mover. This can be a pain, for example, if you need a dialog in your DA, you call GetNewDialog, but you need the resource ID. The Font/DA mover will CHANGE this on you, so you need to somehow figure out what it was changed to. There are three ways to do this (that I know of): 1) Hard code your resource numbers. This doesn't work (as the above story points out) 2) Use named resources. Then find the resource via it's name, figure out its number. This is sort of a lazy way around this, but it works, and I have used it in the past. 3) Compute the IDs which have been renumbered. For an example of this, see MPW DA examples (the only one I have handy now)... HOWEVER: The problem described above concerns the renumbering of PICT resources that are used in a DITL. Quoting from Tech Note Number 23 on Font/DA Mover and DAs: "Sometimes, resource IDs are embedded in other resources. For example, DLOG resource contain the ID of the assciated DITL. In this case, and in two other specific cases of resource IDs in other resources, the FDAM will renumber the embedded resource ID as well as the resource itself: 1) DITL IDs contained in DLOG and ALRT resources 2) ICON, PICT and CNTL IDs contained in DITL resources ^^^^ 3) MDEF IDs contained in MENU resources." What this means is that if you include a PICT in a DITL, it will AUTOMATICALLY work, no matter what the PICT has been renumbered to. I have used PICTs in DITLs in DAs (don't you love all these abbrevs?) in the past with no problems. They were correctly numbered. So I'm thinking that the problem was that either your DITL/DLOG and/or PICT resources were not considered owned resources. Did you create them as such? For more information on owned resources, see "Resource IDs of Owned Resource" in the Resource Manager section of Inside Mac. As always, (as is suggested in the Tech Note), it is a good idea to move your DA to several disks in an attempt to "break" it. This will let you know if you are having owned resource problems. Tom Dowdy CSNET: dowdy@apple.CSNET Apple Computer MS:27Y AppleLink:DOWDY1 20525 Mariani Ave UUCP: {sun,voder,amdahl,decwrl}!apple!dowdy Cupertino, CA 95014 "Plus ca change, Plus c'est la meme chose."
garth@sigi.Colorado.EDU (Garth Snyder) (07/08/87)
>In article <1256@apple.UUCP>, dowdy@apple.UUCP (Tom Dowdy) writes: >> Today I was working on a dialog that needed some standard Gray lines >> (horizontal and vertical) to separate portions of the dialog. >> >> [Tom Dowdy describes using PICT resources to do this] In article <6608@dartvax.UUCP> merchant@dartvax.UUCP (Peter Merchant) writes: >Recently I had to do the same thing and I came up with the same idea. The >problem is, it didn't work because it was in a Desk Accessory. It seems >that Font/DA Mover (at least the version I have...3.2, I think) added the >PICT resource but it didn't change the reference in the dialog box. I suppose >I could have still done it with a bit of code to figure out what the resource >number was and change the reference in the dialog box and then draw the dialog >box. There is a resource numbering convention for things like PICT's that are owned by other resources, in this case a DITL (which in turn is owned by a DLOG...). I forget the exact details but I do remember using it within the last year for exactly this purpose with no problems whatsoever. You must know about this already since you were able to get Font/DA-Mover to move the PICT into your system file - it is just a question of playing around a little bit until you find the magic formula. -------------------- Garth Snyder UUCP: {hao,nbires}!boulder!garth Univ. of CO @ Boulder ARPA: garth@boulder.colorado.edu Boulder, CO 80302 DES Terrorist Spy LSD Cocaine Contra --------------------
Charlie_Alan_Bounds@cup.portal.com (07/11/87)
Peter Merchant writes : > Recently I had to do the same thing and I came up with the same idea. The > problem is, it didn't work because it was in a Desk Accessory. It seems > that Font/DA Mover (at least the version I have...3.2, I think) added the > PICT resource but it didn't change the reference in the dialog box. I suppos > I could have still done it with a bit of code to figure out what the resource > number was and change the reference in the dialog box and then draw the dialo > box. Try loading the DITL using GetResource and putting in the correct PICT id yourself. Then when the dialog manager gets control it finds the DITL already loaded and simply reuses it (but it will be purged when you terminate the dialog so you will have to load and patch it again if you wish to re-display the dialog) Charlie Bounds Charlie@cup.portal.com