jmm@thoth8.berkeley.edu.BERKELEY.EDU (01/17/88)
How do you sort resources? I'm using the names of the individual resources to fill a list, and I'd like to be able to sort the resources rather than sort the list every time it gets created. (The resource type is my own, and I'd like to reorganize the order that the individual resources appear in any way that I see fit, so I don't want to just sort by resource name.) Question 2: Is there a way to create a list without creating it in a specific window? I have a dialog that has two different lists, and the second list displayed depends on what is selected in the first list. I'd like to be able to generate all of the lists at once, and then display them when needed. James Moore ------------------------- | / Go raibh sonas agus / | jmm@bartleby.berkeley.edu / rath oraibh an / |--------------------------------------------| / Nollaig agus san / | The University of California only knows | / Athbhliain! / | me as a number. They couldn't care less | / / | what my opinions are. | ------------------------- |--------------------------------------------|
zrm@eddie.MIT.EDU (Zigurd R. Mednieks) (01/17/88)
In article <6577@jade.BERKELEY.EDU> jmm@thoth8.berkeley.edu () writes: > >Question 2: Is there a way to create a list without creating it in a specific >window? I have a dialog that has two different lists, and the second list >displayed depends on what is selected in the first list. I'd like to be >able to generate all of the lists at once, and then display them when needed. > I suspect the reason the List Manager wants a window pointer when a list is created is that it has to tell the window about its scroll bar. A way to get around this is to not draw the list until you need it. (Passing FALSE in the parameter DrawIt when you create the list.) Then, when you are done adding elements to it, use the LDoDraw call to turn drawing on, and call LUpdate to actually cause it to draw. Have fun, -Zigurd -- ------------------------------------------------------------------------ Zigurd Mednieks MURSU Corporation (617)424-0146 25 Exeter Street Boston, MA 02116
mms@gpu.utcs.toronto.edu (John J. Chew III) (01/20/88)
In article <7914@eddie.MIT.EDU> zrm@eddie.MIT.EDU (Zigurd R. Mednieks) writes: > In article <6577@jade.BERKELEY.EDU> jmm@thoth8.berkeley.edu () writes: > >Question 2: Is there a way to create a list without creating it in a specific > >window? I have a dialog that has two different lists, and the second list > >displayed depends on what is selected in the first list. I'd like to be > >able to generate all of the lists at once, and then display them when needed. > > > I suspect the reason the List Manager wants a window pointer when a > list is created is that it has to tell the window about its scroll > bar. A way to get around this is to not draw the list until you need > it. (Passing FALSE in the parameter DrawIt when you create the > list.) Then, when you are done adding elements to it, use the LDoDraw > call to turn drawing on, and call LUpdate to actually cause it to > draw. I haven't received jmm's original posting here yet, but concerning the above: I believe that the drawIt flag passed to LNew() and subsequently controlled by LDoDraw() affects only the drawing of the cells themselves and not the scroll bar(s), giving you something that looks like an empty list. I was about to suggest that you first draw the list somewhere outside the dialog's visible region (similar to HideDItem()) except that of course there is no easy way to move a list once installed. I suppose you could SetDItem the list to another location, change its rView field and MoveControl its scroll bars, but it seems awfully messy... jjc -- john j. chew (v3.0) poslfit@gpu.utcs.toronto.edu +1 416 463 5403 (300/1200 bps) poslfit@utorgpu.bitnet {cbosgd,decvax,mnetor,utai,utcsri,{allegra,linus}!utzoo}!utgpu!poslfit "Script-G for open, sub-delta for durchschnitt"
steele@unc.cs.unc.edu (Oliver Steele) (01/21/88)
jmm@thoth8.berkeley.edu () writes: >How do you sort resources? I'm using the names of the individual resources >to fill a list, and I'd like to be able to sort the resources rather than >sort the list every time it gets created. (The resource type is my own, and >I'd like to reorganize the order that the individual resources appear in >any way that I see fit, so I don't want to just sort by resource name.) The cheap trick here is to use AddResMenu() to add them all to the end of (empty) menu that you never draw (make one with NewMenu() and then dispose it after you're done with it), and read the names of the menu items from its data. Write me if you need source. ------------------------------------------------------------------------------ Oliver Steele ...!{decvax,ihnp4}!mcnc!unc!steele steele@cs.unc.edu "I thought your class was at nine." "It is, but I have to buy the books so I can do the reading." "Oh yeah, I forget your modus operandi."
mms@gpu.utcs.toronto.edu (John J. Chew III) (01/22/88)
In article <767@thorin.cs.unc.edu> steele@unc.UUCP (Oliver Steele) writes: > jmm@thoth8.berkeley.edu () writes: > >How do you sort resources? I'm using the names of the individual resources > >to fill a list, and I'd like to be able to sort the resources rather than > >sort the list every time it gets created. (The resource type is my own, and > >I'd like to reorganize the order that the individual resources appear in > >any way that I see fit, so I don't want to just sort by resource name.) > The cheap trick here is to use AddResMenu() to add them all to the > end of (empty) menu that you never draw (make one with NewMenu() and then > dispose it after you're done with it), and read the names of the > menu items from its data. Write me if you need source. A nicer way to sort things as you put them into a list is to use the LSearch() function: /* for each cell you want to add */ theCell.h=theCell.v=0; LSearch(dataPtr, dataLen, compareProc, &theCell, 1); LAddRow(1, theCell.v, 1); LSetCell(dataPtr, dataLen, theCell.1); ... where compareProc for a simple alpha sort would be: pascal int compareProc(ap, bp, al, bl) Byte *ap, *bp; int al, bl; { return IUMagString(ap, bp, al, bl)<=0; } However, to answer the original question of how to sort resources, the best way is to sort them before you create them and to create them in sorted order. The second best way is to decide what order they should be in, create a new resource fork and create copies of them in sorted order there. If you are determined to sort existing copies of resources, read the caveat in IM IV-16 and then: - obtain handles to all the resources to be sorted - call RsrcMapEntry on each to get the resource reference offset - sort the resource references (12 bytes located at the above-obtained offsets from TopMapHndl, assuming your resources are in the most-recently opened resource fork, which they had better be) - call ChangedResource() on one of your resource handles. jjc -- john j. chew (v3.0) poslfit@gpu.utcs.toronto.edu +1 416 463 5403 (300/1200 bps) poslfit@utorgpu.bitnet {cbosgd,decvax,mnetor,utai,utcsri,{allegra,linus}!utzoo}!utgpu!poslfit "Script-G for open, sub-delta for durchschnitt"