Statically Yours #

Today I worked on the statics. I pondered if I should make the firstElement and lastElement pointers of my linked list of editors part of the static struct too, but in the end I decided not to, since they were used in a lot of places in my main.cp file, and then I'd have to make the structure public, or add lots of friends to the class, both of which I'd rather limit. Now I only have 3 global variables, the bool to see if I should quit or not, and the endpoints of the linked list. To make it more obvious I've added a g in front of their name, so they're called gIsDone, gFirstEditor and gLastEditor, and then hopefully the IB will understand that I know globals aren't normally supposed to be accessed in functions, but that I had no choice.

Implementing the static structure wasn't that hard, only problem I ran into was having a a static function to initialize them. For some reason the scope of the static function is limited to the file its defined in, so I couldn't do that in the icnsEditorClass.cp file, and had to include the function body itself in the .h file, which is included everywhere. Perhaps there's a work around, because it looks rather weird to have just one function there, while the rest are only prototypes.

I also improved the Icon Browser, so that it's not displayed when there are only 1 or 0 icons. When there's 1 icon then that's chosen by default to be edited, and where there are zero an error message is displayed saying that the file does not contain any icons (although I have to think of a mechanism to allow the user to create an icon for a file that doesn't have one yet).

I also did some house cleaning for the menu enabling/disabling part of my DoIdle function. The toolbox function DisableItem wants a menu handle and an item number, and it gets rather annoying to have to make a MenuHandle variable, call GetMenuHandle with the proper ID, and then call DisableItem when all I'm trying to do is disable only one command in a menu. So I added two more simple functions to my commonfunctions.cp file, EnableMenuItem and DisableMenuItem. They take as parameters an ID and an item number, and take care of the MenuHandle business. I know this is a very minor point, but I think that little things like this make a program seem more elegant.

[my journal has doubled in size in only a month, it's 20,000 words now...should make for some fun reading over the summer :p]

Post a Comment