Puzzling Refreshes #
glypher/icns class: Improved saving of the icns. If the user doesn't specify a small size, rather than generating it and saving that too, I'm going just save the large version, and let the Finder do the interpolation of the small one. Same thing when the large size isn't specified. I've also added handling of icns which only contain one size to the display function. Also cleaned up the loading code, split it up into two functions (one for loading from the icns resource, and one from loading from the old style icons, if the icns isn't present).
The messiest part of glypher (and clip2icns too) is the handling of refreshes for dialogs. Right now I have this macro set up, which is called in the beginning, when the user chooses something from a menu or when an ID is typed in. But the macro is really ugly because it's not meant to have line breaks, so I have to put in a back slash at the end of each line. Plus it's impossible to debug, since it all gets put together in one line (the backslash makes the compiler ignore the line break after it). The only reason why I didn't make it a function was because I'm using so many local variables, so passing them as parameters would be a pain. The only think I can think of right now would be to make the whole dialog handling a class, and make the refresh a function of it, and then I can just access some variables within the class. But that's really misusing classes, since each class would have to be specialized for it's particular dialog, so reuse would be kinda of hard. Perhaps I could make a generic class using inheritance, but I think that's overkill. Hopefully I'll figure something out by the time I have to make the icon editor (although there each editing window will be a class in it's own, and since I can have many of them then I'm using the class in many places, so there's no misuse).
Post a Comment