A Swatch-y Control #

clip2icns: A tester found another bug. When I exported to the clipboard, I assumed that the size of the picture that was to be placed in the clipboard would never changed. However, a kind of compression seems to be used, so the size varied somewhat. This would cause an unexpected end-of-file when trying to paste in the image in Photoshop, and a complete crash within the Finder. This took so long to track down because it only happened with some icons (ones where the size different by a large amount when compared with the size I previously hardcoded). I ended doing what I tried to do in the beginning, to set the size of the clipboard based on the size of the picture. But before I simply looked for a PictureSize function, and not finding one I had decided to hard code the size to 4662, the size of the my 80x32 test image. In the end it turned out that a PictureSize function is unnecessary, the GetHandleSize function is what I was looking for.

Also, I used my newly-gained experience with dialog event filters to write one for the icon import/export dialog. Basically it maps return to a click on the default button, escape or command period to the cancel button, and rejects all non-number keys (the only field where text can be typed in is the ID field, which is supposed to contain only numbers.)

Glypher: A (different) tester requested that I add an option for the glyph to be moved in 10 pixel increments when the shift key was held down (like Photoshop) so I did that (it was simply a matter if adding an IsKeyDown function, which changed the increment from 1 to 10 if the shift key was down).

Icon Mangler: I've changed my handling of resizing a bit. Now I have two functions, one which handles the user's clicks on the grow box and gets the nearest window size which conforms to the size ratio, and based on this sets a magnification variable within the editor class. Then another function gets the magnification variable and actually resizes the window to the proper size and repositions the controls. The reason why I did this is because this greatly simplifies the adding of a "Zoom In" and "Zoom Out" command, since I can simply increment/decrement the magnification variable and call the second function mentioned above. The only problem that I have is that it is not refreshing quite properly (some of the controls are not getting redrawn properly). Time to fix this...

Fixing that wasn't that hard. When I split up the resize the function into two, I left in the setting of the ports in the function that handled clicking in the grox box. So when I was resiging by using the grow box, everything worked ok, but when I used the menu the ports weren't set properly, and so the window wasn't refreshing properly (because InvalRect wasn't invalidating the proper places). I've also added two more constants, kMaxMagnification and kMinMagnification (current set to 10 and 4 respectively). These to constants are used to restrict the size of the window when resizing, and to disable the zoom in/out menu commands.

Then I started to add the setting of the foreground and background colors. I used a custom control, in which I'm drawing two overlapping squares (like Photoshop does it), and fill then with the fore/background colors. I want both of those color swatches to be drawn using the proper 3D border, so I used the DrawThemeGenericWell function, which draws the inner bevel. One of my problems was that the background color square is clipped off by the foreground color one, but I still want it to have a nice 3D border. In the end I used GetCPixel to get the colors of the bevels, and dre the one around the overlap region by hand. The reason why I had to do this was because I couldn't find a function/system global to obtain the bevel colors.

The handling of mouse clicks at this stage was pretty rudimentary. I simply returned a click in the kImageWellControlPart, no matter where within the control the user clicked. But it was enough for me to test the setting of the foreground color by using the system color picker (which can be done with one call, Apple is so nice :p).

Post a Comment