The Browser Takes Shape #
I fixed the disabling bug, I simply added a check in the Refresh function to disabled the editor if it wasn't in the front. Then I worked on the main part of the Icon Browser, having a list in the dialog which contains all the icon IDs and names, and a preview of the currently selected icon.
I found some sample code at the Macintosh C website for dealing with lists, and using that it wasn't hard at all. The trickies parts were to sort the list by ID and displaying multiple icon types. Icons can be stored using either new style resource ('icns') or old style ones ('icl8', 'ICN#', etc.), or both. When building the list there shouldn't be any duplicate IDs, but all the types should be listed. This involved having a search function to see which icons were already in the list, and I used a sequential search algorithm for this. However I might consider re-implementing it as a binary search, since that's probably one of the things the IB is looking for.
Right now the Icon Browser is implemented as a collection of functions, but I keep passing similar things to the functions (list handle, IDs) so it might make more sense as a class. However I'm only going to use one instance in my program, although it might have applicability in other programs too.
I'll decide on that later. In the meantime I'll work on adding a grid, which are simply a bunch of lines to separate the magnified pixels. I'm thinking of extending this concept so that the interval and grid colors can be set by the user. It would be useful in aligning things.
Post a Comment