Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!vtserf!creatures!csgrad!davism From: davism@csgrad.cs.vt.edu Newsgroups: comp.sys.mac.programmer Subject: Problems with 'cicn's Summary: What am I doing wrong? Message-ID: <1326@creatures.cs.vt.edu> Date: 27 Jun 91 14:46:09 GMT Sender: usenet@creatures.cs.vt.edu Reply-To: davism@vtopus.cs.vt.edu (Mat Davis) Organization: Virginia Tech Computer Science, Blacksburg, VA Lines: 84 I'm trying to get "bouncing" buttons working using color icons. I'm using two icons per button, a "normal" image and a "pressed" image. Because I can't predict what color background they'll be drawn on, I need to compute bitmaps that are the difference of the two images (one normal-to-pressed and the other pressed-to-normal) so that I can use CopyMask to clean up the background after a press or a release. The code was working fine with THINK C 4.0.x and the TCL, but now I've converted it to MPW C++ and MacApp and it is no longer working. From inserting debugging code, it appears that I can't reliably use the colorIcon.iconMask bitmap anymore. I discovered in THINK C that the icon mask doesn't appear to be valid until *after* the cicn is drawn the first time (with PlotCIcon), but I'm not trying to use it until after the first draw. If anyone can provide any suggestions, I'd greatly appreciate it. -------------------------------------------------------------------------- Mat Davis Virginia Tech -------------------------------------------------------------------------- *** Problem code *** /*----------------------------------------------------------------------*/ static void createDiffBitmap (CIconHandle beforeIcon, CIconHandle afterIcon, BitMap *diffMap, Ptr bits) { // createDiffBitmap static Rect iconRect = { 0, 0, 32, 32 }; // Initialize 'diffMap' if (!bits) diffMap -> baseAddr = NewPtr (128); else { diffMap -> baseAddr = bits; memset (bits, 0, 128); } // else diffMap -> rowBytes = 4; diffMap -> bounds = iconRect; // Make sure we don't "colorize" the CopyBits RGBForeColor (&SysBlack); RGBBackColor (&SysWhite); // Make sure everything's locked down HLock ((Handle) beforeIcon); HLock ((Handle) afterIcon); #if 0 // This CopyBits to the screen doesn't *always* show the // correct bitmap (it does sometimes, though). CopyBits (&(**beforeIcon).iconMask, &qd.thePort -> portBits, &iconRect, &rect1, srcCopy, NULL); #endif // Straight copy of 'beforeIcon' to 'diffMap' CopyBits (&(**beforeIcon).iconMask, diffMap, &iconRect, &iconRect, srcCopy, NULL); // Now erase the bits of 'diffMap' that are in 'afterIcon' CopyBits (&(**afterIcon).iconMask, diffMap, &iconRect, &iconRect, srcBic, NULL); // Unlock both icons HUnlock ((Handle) beforeIcon); HUnlock ((Handle) afterIcon); } // createDiffBitmap