Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!mailrus!ames!apple!xanadu!kari From: kari@xanadu.COM (Kari Dubbelman) Newsgroups: su.macintosh,comp.sys.mac.programmer Subject: Re: How do I implement a toolbox window like MacPaint 2.0? Keywords: Mac Programming Button Highliting Palette GhostWindow Message-ID: Date: 9 Jul 89 19:34:07 GMT References: <3753@lindy.stanford.edu> Reply-To: kari@xanadu.UUCP (Kari Dubbelman) Organization: TeraCons, Cupertino Lines: 53 Seeing that you have at least two open questions that I can answer... You have hit upon two of the (more) weak spots in the Mac toolbox. Most other things at this programming level exist and work well. Inside Mac tells how to do these things. You cannot program the Mac without IM volumes I, IV, and (if you have color) V. Period. You probably also need IM-II and the TechNotes stack would not hurt. But to answer the button question, there is no built-in way to do it and this is a serious oversight in the Mac toolbox. IM (I-407) recommends you do something like this (with int16 a portable 16-bit integer; Warning - shooting-from-the-hip programming below) void highlightbutton(dialog,itemNumber) DialogPtr dialog; int16 itemNumber; { Rect displayRect; int16 itemType; Handle itemHandle; GetDItem(dialog,itemNumber,&itemType,&itemHandle,&displayRect); SetPort(dialog); /* Possibly unneccesary */ PenNormal(); /* Probably unnecessary */ PenSize(3,3); InsetRect(displayRect,-4,-4); FrameRoundRect(displayRect,16,16); } but this causes minor problems in modeless dialog boxes - this routine has to be called in the window update routine also, otherwise covering windows will cause (pieces of) the highlighting to disappear when removed. (Modal dialogs work OK). Second question, about a floating tool selection window: There is a system for doing exactly this, based on a variable called GhostWindow (I-287). I have not tried this myself, but concensus among developers I've listened to seems to be not to use this "feature" since it causes more problems than it solves. Just be careful so as not to deactivate any other window if you get a hit in the tool selection window. You may benefit from making this window have a built-in PICT handle for its contents - Draw the window in MacPaint, cut it with the lasso, cut it to the clipboard, go into MacDraw, Paste it out of there and save the picture as a PICT file. Then go into ResEdit and grab the PICT resource from the MacDraw save file and put into your programs resource file. Install it as the Window PICT and you have your icons. Highlight areas with InvertRect as appropriate. (Haven't tested this either... Caveat Implementor as the Romans used to say) -Kari