Icon Mania
Volume Number: 8>replyPtr Issue Number: 6>replyPtr$ Column Tag: Getting StartedÄ< 2Related Info: Window Manager Memory Manager Resource Manager>replyPtr Icon Mania! >replyPtr More on using WIND resources>replyPtr∑ 4By Dave Mark, MacTutor Regular Contributing AuthorÄ V Note: Source code files accompanying article are located on MacTech CD-ROM or>replyPtrÊ source code disks.>replyPtrı$:Our last program, PICTWindow, used a WIND resource to create a new window,>fixBtnName Mand then loaded a PICT resource, drawing it in the window. This month, we’ll explore>replyPtr Hsome new resources. We’ll start off in the usual way, using a WIND resource as the>fixBtnName basis for a window.>fixBtnName%$LIn this month's program, instead of using the window title described in the WIND>fixBtnName1 P resource, we'll load the title from a resource designed specifically to hold a text string.>fixBtnName= POnce we set the window's title, we'll load a color icon from the resource file, then plot>fixBtnNameI "it in random locations in the window.>fixBtnNameU$OThis may sound kind of weird, but just be patient! Once you see this program in>replyPtr action, I think you'll like it.>replyPtr {Building the IconMania Resources>replyPtr $@Create a new folder in your Development folder named IconMania. Next, launch>fixBtnName MResEdit by double-clicking on its icon in the Finder. When you get enough of the>replyPtr Oclown-in-the-box, click the mouse button. When the “Open FIle” dialog appears, click>replyPtr Athe New button, navigate into your new IconMania folder and create a resource file>replyPtr named IconMania.π.rsrc.>fixBtnName$7The first resource you’ll create is your WIND resource. Select Create New>replyPtr AResource from the Resource menu. When the scrolling list of resource types appears,>replyPtr Otype WIND (or select it from the scrolling list) and click the OK button. When the>replyPtr PWIND editing window appears, change your WIND to reflect the specifications shown in>fixBtnNameÙ Figure 1.>replyPtr>replyPtr#~#Figure 1: IconMania’s WIND resource.>replyPtr9$LNext, select Set 'WIND' Characteristics... from the WIND menu and delete anyappleE Gtext in the Window title: field. We'll pull our window title from the resource we create>replyPtrQ Jnext. Click the OK button, then close the WIND editing window and the WIND pickerapple] 5 window, leaving yourself at the main window for the resource file.>replyPtrK>replyPtraIFigure 2: The 'WIND' Characteristics dialog box with the window title deleted.>replyPtrw$>Once again, select Create New Resource from the Resource menu. This time, typealiasHandle Nthe four characters 'STR ', then click the OK button. The fourth character in thealiasHandle Oresource name is a space. If you leave the space off, ResEdit will stick it in there for>replyPtr Dyou, but don't forget that resource types are always four characters long.aliasHandle $AThe 'STR ' resource allows you to store a pascal string in the resource file.>replyPtr WRemember, a pascal string is a length byte, followed by that many bytes of text. Pascal>replyPtr Mstrings are associated with the Str255 data type. When the 'STR ' editing window>replyPtr Rappears, type some text in the field labeled "The String". This text will eventuallyaliasHandle &become the title of the IconMania window.aliases >replyPtr !Figure 3: The STR editing window.>replyPtr $FClose the STR editing window and the STR picker window, leaving only the mainaliases replyPtr‹ represents a color icon.aliasesË$LTake a look at the cicn editing window shown in Figure 4. The cicn editor uses aaliasesÙ Qseries of MacPaint like tools (shown on the left side of the window) to let you create a>replyPtrcustomGetFileSpair of icons and an icon mask (see the right side of the window). The color icon is a>replyPtr Vfull-blown color icon. When you click on the color icon on the right side, you'll havealias Vaccess to tools that let you select colors and patterns (The items in the Tools menu helpalias$ 1determine the colors available for