rheintz@zaphod.ncsa.uiuc.edu (04/13/89)
This resource file contains an MDEF (menu definition procedure) and a MENU both with ID's of 550. The Color menu allows the user to select any color from the current color table. This MDEF is used in the NCSA Layout 1.1 program and is public domain. To use the Color menu, copy the MDEF and MENU resources as you normally would (like using a resource editor). If you already use ID number 550 as a MENU, just change the MENU ID. If you already use ID number 550 for an MDEF you must change the MENU resource (page Inside Mac I-364) as well as changing the MDEF ID. There are no special requirements for initializing the color menu. It can be added to the Menu bar or as a sub menu just like any other menu as described in Inside Macintosh. For example, to add the menu call colorMenu: MenuHandle; colorMenu = GetMenu(550); InsertMenu(colorMenu, 0); If you use the MBAR resource, just add 550 ID to it. I tried this with PixelPaint and it worked just fine. The interface to the color menu is through the standard macintosh calls. The color menu returns a number from 1 to 256 corresponding to the color table index of 0 to 255. In otherwords, subtract 1 from the return value of the color menu (itemNo) to get the index into the color table. If you want the RGB value, just call theColor: RGBColor; Index2Color(itemNo-1, &theColor); There are two modes to the color menu. The default mode is the easiest and has already been described. This is the mode that the colorbar is initialized to. In this mode, When the color menu is first selected, the current selected color and index number at the bottom of the color menu are blank. The second mode provides the user more information. When the user first clicks on the color bar, the current color and index number displays at the bottom of the color menu. What the current color is, is up to the application. For example in NCSA Layout 1.1, there is the CanvasColor menu. When the user first clicks on the color menu, the current canvas color and index number appear at the bottom of the color menu. This has to be set by the application. To switch to the second mode call: SetItemIcon(ColorMenu, 1, 1); To set the color to the current index into the color table colorIndex: INTEGER; SetItemMark(ColorMenu, 1, colorIndex); Sometimes it is useful to use both modes. For instance in NCSA Layout 1.1 if the selected text is all one color, I use the second mode. However if the selected text is more than one color I switch back to the default mode so the user realizes that more than one color is selected. To switch to the default mode call: SetItemIcon(ColorMenu,1,0); Well thats the whole interface. If there are any questions, just email me at rheintz@ncsa.uiuc.edu. (This file must be converted with BinHex 4.0) :#@0[E'pb6@9ZG3""8&"-2j!%!*!)"QeRR3#3"!%!N!-'&`!!"4F!N!0@!!!$fJ! !!pTJ*ZaJ*["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