bobh@twinkie.bellcore.com (Robert Hettmansperger) (04/03/91)
Hello, I'm in the process of developing my first "real" Mac program and have run up against a problem with the Dialog Manager. What I want to do is bring up a dialog box which has a "ROTATE" button. Basically, there is a static text item and an icon item in the dialog, which start with default values. Whenever the ROTATE button is pressed the text and associated icon should progress to the next of four possibilities (or return to the first possibility). To do this, I have set up four consecutive STR and ICON resources with the desired text and icons. When the dialog box is brought up initially, the first text/icon pair are displayed. I then call ModalDialog and if the ROTATE button was pressed, I use SetIText to change the text item (I get the new text with GetString) and SetDItem to change the icon (I get the new icon using GetIcon). The problem is that the text updates as I expected, but in order to get the new icon to appear, I have to call DrawDialog to redraw the entire dialog box. This is slow and makes the entire dialog flicker. I have tried almost everything to get just the icon redrawn and can't come up with anything else that works. Does anyone have any suggestions on how to update *only* the text and icon? Thanks, Bob Hettmansperger bobh@twinkie.bellcore.com
dweisman@umiami.ir.miami.edu (Ordinary Man) (04/04/91)
In article <1991Apr3.142215.2787@bellcore.bellcore.com>, bobh@twinkie.bellcore.com (Robert Hettmansperger) writes: > The problem is that the text updates as I expected, but in order to get the > new icon to appear, I have to call DrawDialog to redraw the entire dialog > box. This is slow and makes the entire dialog flicker. I have tried almost > everything to get just the icon redrawn and can't come up with anything else > that works. > > Does anyone have any suggestions on how to update *only* the text and icon? Well, I'll take a stab and say that it would probably be better to use a userItem for the icon resource instead of letting the Dialog Manager deal with it. Try setting the port to the Dialog and drawing in it just like it was a window (which in truth, it really is - type GrafPtr). Call PlotIcon to change the icon in the userItem. This sounds reasonable to me.... Use your method for updating the text. I'm not really sure you even need the userItem for this. If anyone thinks otherwise, please express yourselves. > Thanks, > > Bob Hettmansperger bobh@twinkie.bellcore.com You're welcome, Dan -- /-------------------------------------------------------------------------\ | Dan Weisman - University of Miami - Florida | || || || || | |--------------------------------------------------| || || ||\ /|| | | INTERNET -----> dweisman@umiami.IR.Miami.edu | || || || | || | | BITNET -----> dweisman@umiami | ||||||| || | || | |-------------------------------------------------------------------------| | "The more I get to see, the less I understand..." - Triumph | \_________________________________________________________________________/
dorner@pequod.cso.uiuc.edu (Steve Dorner) (04/04/91)
> The problem is that the text updates as I expected, but in order to get the > new icon to appear, I have to call DrawDialog to redraw the entire dialog > box. This is slow and makes the entire dialog flicker. Invalidate the item's rect, then call BeginUpdate, DrawDialog, and EndUpdate. Won't be any faster, but won't flicker. -- Steve Dorner, U of Illinois Computing Services Office Internet: s-dorner@uiuc.edu UUCP: uunet!uiucuxc!uiuc.edu!s-dorner
lim@iris.ucdavis.edu (Lloyd Lim) (04/04/91)
In article <1991Apr3.142215.2787@bellcore.bellcore.com> bobh@twinkie.bellcore.com (Robert Hettmansperger) writes: >Does anyone have any suggestions on how to update *only* the text and icon? If you're running on a Plus or better (most likely and you can check to make sure), you can invalidate the rects and then call UpdtDialog (or however it's spelled). It only redraws what's necessary. +++ Lloyd Lim Internet: lim@iris.eecs.ucdavis.edu America Online: LimUnltd Compuserve: 72647,660 US Mail: 215 Lysle Leach Hall, U.C. Davis, Davis, CA 95616
bobh@twinkie.bellcore.com (Robert Hettmansperger) (04/04/91)
In article <1991Apr3.142215.2787@bellcore.bellcore.com> I wrote: > >The problem is that the text updates as I expected, but in order to get the >new icon to appear, I have to call DrawDialog to redraw the entire dialog >box. This is slow and makes the entire dialog flicker. I have tried almost >everything to get just the icon redrawn and can't come up with anything else >that works. > Thanks to all who responded. The easiest solution turned out to be just to set the current GrafPort to the dialog box and call PlotIcon to draw the icon directly. Interestingly, the most common recommendation was to flag the icon's rectangle for updating with InvalRect. I couldn't get this to work at all. I'm not sure if it was just due to differences in the dialog vs. the window manager, or if I just wasn't doing it right. Thanks again, Bob Hettmansperger bobh@twinkie.bellcore.com P.S. Another suggestion was to make the icon a user item, but I couldn't manage to set up the procedure pointer to be called as the "item" in SetDItem. Anyone have suggestions on writing userItems with Think's C?
yossie@fnal.fnal.gov (Yossie Silverman) (04/05/91)
Draw the icon yourself! :-) Actually this is probably the best way. One other option that should work, but doesn't (as far as I can tell) is to InvalRect the rectagle of the icon and wait for the update loop to work on it. Cheers - Yossie --- yossie@fnal.fnal.gov; yossie@fnccf.bitnet What did the Caspian Sea? - Saki