[comp.sys.mac.programmer] how can I draw contents of modeless dialog?

er225711@unix.cis.pitt.edu (M Kikuchi) (06/08/90)

I'm trying to implement a modeless dialog using complete DLOG and 
DITL resources, but the contents of the item list are not drawn 
(i.e. I get just a plain white window).  When I replace my 
getNextEvent() loop with a ModalDialog() loop, everything is 
displayed just fine!  How do I draw the contents of a modeless 
dialog as contained in its item list?  If I do DrawControls(), only the 
buttons are drawn (but not statText or Icons, e.g.)  I tried TextBox() for my 
statText items but it drew nothing.  
<whine mode on>
Why do all these "programmer's companion" books dwell on modal dialogs and leave 
us modeless souls to fend for ourselves?  
-- 
---Martin Thurn          thurn@lcl.cmu.edu

"Wow!  Someone at CMU who doesn't have a bunch of
  numbers and plus signs in their name!"

kk@mcnc.org (Krzysztof Kozminski) (06/08/90)

In article <24766@unix.cis.pitt.edu> er225711@unix.cis.pittsburgh.edu (M Kikuchi) writes:
>I'm trying to implement a modeless dialog using complete DLOG and 
>DITL resources, but the contents of the item list are not drawn 

You need to use IsDialogEvent/DialogSelect calls.  Your event loop should
look something like:

   if (GetNextEvent(everyEvent,& CurrEvent)) {
      if (IsDialogEvent(&CurrEvent)) {
	/* You may want to intercept some events here */
	if (DialogSelect(&CurrEvent, &theDialog, &itemHit)) {
	  /* Process the event/item that got hit */
	}
      } else {
	/* Handle non-dialog events */
      }
		
DialogSelect will process the update/activate events for you.

For more details, see IM vol.1, pages somewhere around 400,
if I remember correctly.

KK
-- 
Kris Kozminski   kk@mcnc.org
"The party was a masquerade; the guests were all wearing their faces."

mxmora@unix.SRI.COM (Matt Mora) (06/08/90)

In article <24766@unix.cis.pitt.edu> er225711@unix.cis.pittsburgh.edu (M Kikuchi) writes:
>I'm trying to implement a modeless dialog using complete DLOG and 
>DITL resources, but the contents of the item list are not drawn 
>(i.e. I get just a plain white window).  When I replace my 
>getNextEvent() loop with a ModalDialog() loop, everything is 
>displayed just fine!  How do I draw the contents of a modeless 
>dialog as contained in its item list?  If I do DrawControls(), only the 

Try DrawDialog(dlg) or DialogSelect(evt, dlg, itemHit);


It depends on where (in your code) that you want your modaless dialog
to be drawn (redrawn). If in your eventloop you usally call
Dialog select after you call isdialog.

Draw dialog is for informational dialogs I think. I never used it yet.
I think you use drawdialog for stuff like "waiting for the laser writer..."
type dialogs. 

I think dialogselect is supposed to take care of the updating also.




-- 
___________________________________________________________
Matthew Mora                |   my Mac  Matt_Mora@sri.com
SRI International           |  my unix  mxmora@unix.sri.com
___________________________________________________________

kazim@Apple.COM (Alex Kazim) (06/08/90)

In article <24766@unix.cis.pitt.edu> er225711@unix.cis.pittsburgh.edu (M Kikuchi) writes:
>I'm trying to implement a modeless dialog using complete DLOG and 
>DITL resources, but the contents of the item list are not drawn 

Actually, both _ModalDialog and _DialogSelect make calls to, yes,
_DrawDialog (see p. I-418).  I remember having trouble about four years
ago, and spending all afternoon trying to find this call (it's nicely
tucked away.)

=====================================================================
Alex Kazim, Apple Computer
Been doin' this for too long
=====================================================================