Arthur_P_Bebak@cup.portal.com (01/21/90)
I am in the midst of an excursion into the uncharted depths of the list manager, and, of course, can't get it to work (please, suppress your gasps of amazement...). I have a simple shell program which opens up a simple window and at the appropriate menu choice executes the following routine (assume the correct .h files): extern WindowRecord window; /* window */ extern WindowPtr myWindow; /* pointer to current window */ ListHandle theList; /* a handle to the list */ list() { Rect rectView,dataBounds; Point cSize; Cell theCell; char string[10]; FontInfo info; /* set up the font and cell size */ TextFont(systemFont); GetFontInfo(&info); cSize.h = 230; cSize.v = info.ascent+info.descent+info.leading; /* set up the view and data bounds rectangles */ SetRect(&rectView, 30,30,260,260); FrameRect(&rectView); SetRect(&dataBounds,0,0,1,0); /* Give my creature LIFE!!! */ theList = LNew(&rectView,&dataBounds,cSize,0,myWindow, TRUE,FALSE,FALSE,TRUE); /* add the string */ SetPt(&theCell,0,0); strcat(string,"Test1"); CtoPstr(string); LAddToCell(string,strlen(string),theCell,theList); /* turn on drawing, probably redundant given my LNew call */ LDoDraw(TRUE,theList); LDraw(theCell,theList); } /* list */ Now, being the gullible person that I am I would imagine that I should get a nice rectangle with an inactive scroll bar on the right, and with "Test1" prominently displayed near its top. But Nooooooooo... all I get is a blank rectangle with the aforementioned inactive scroll bar at the right. So I thinks to myself, thinks I, "Arthur old boy, you've overlooked something obvious, like perhaps LdUpdate". So being in the habit of listening to myself I add the following update procedure to be called during an update event: extern ListHandle theList; /* a handle to the list */ void UserUpdate(wPtr) WindowPtr wPtr; { GrafPtr theCurrentPort; GetPort(&theCurrentPort); SetPort(wPtr); BeginUpdate(wPtr); LUpdate(wPtr->visRgn,theList); EndUpdate(wPtr); SetPort(theCurrentPort); } /* user update */ My reward for this effort? The menu bar locks up (can't pull down my menu) and about 30 seconds later La Bomba!! The ol' 02 error and the option of Restart or shoot the Mac. So, fellow sufferers, what could I possibly be doing wrong? We're talking LSC 2.14 and a vanilla Mac SE with no weirdness in the system file. I've read IM IVand the MacTutor article (Vol3 #4) but still can't see it. Mucho Obligado for any help. Email or post at your discretion. Programmatically yours, Arthur the List Slayer Arthur_Bebak@cup!portal.com {ucbvax,decwrl,decvax,seismo,hplabs}sun!cup.portal. com!Arthur_Bebak "Never explain, never apologize!"
mxmora@unix.SRI.COM (Matt Mora) (01/23/90)
I noticed two things. You created a one column list but didnot add any rows. In article <26163@cup.portal.com> Arthur_P_Bebak@cup.portal.com writes: >SetRect(&dataBounds,0,0,1,0); ^^^^^^^^ If you do it this way you must call LAddRow. or you can set the last value to the number of rows that you want. ( ex. if you want a list of 10 items then call Setrect(&databounds,0,0,1,10) ) or ... >SetPt(&theCell,0,0); >strcat(string,"Test1"); >CtoPstr(string); >LAddToCell(string,strlen(string),theCell,theList); Your adding data to no cells. You must first add some rows. try... Laddrow(count,rownum,thelist) Lsetcell(...) Sorry but I don't Know C well enought to fill in the blanks :-) -- ___________________________________________________________ Matthew Mora SRI International mxmora@unix.sri.com ___________________________________________________________
tim@hoptoad.uucp (Tim Maroney) (01/23/90)
I tried to mail this, but the address at the bottom of the message bounced. In article <26163@cup.portal.com> Arthur_P_Bebak@cup.portal.com writes: >/* add the string */ >SetPt(&theCell,0,0); >strcat(string,"Test1"); Strike one -- string has not been initialized, so strcat will give unpredictable results. Try strcpy instead. >CtoPstr(string); >LAddToCell(string,strlen(string),theCell,theList); Strike two -- you're calling a C string routine (strlen) on a string you just converted to Pascal. This will give unpredictable results. Strike three -- you're setting a cell that does not exist. You gave a dataBounds which had no rows, and did not do an LAddRow to create a row. The LAddToCell should work, but I wonder why you don't do an LSetCell instead? You're not really appending, after all. This is weirdly similar to the strcat/strcpy confusion above. -- Tim Maroney, Mac Software Consultant, sun!hoptoad!tim, tim@toad.com "Our newest idol, the Superman, celebrating the death of godhead, may be younger than the hills; but he is as old as the shepherds." - Shaw, "On Diabolonian Ethics"