In FOX 1.0, simply displaying an FXBitmap or FXImage typically required the construction of an FXCanvas widget and then handling that canvas' SEL_PAINT message in order to draw the bitmap or image into the canvas. FOX 1.2 introduces the FXBitmapFrame and FXImageFrame widgets (both subclasses of FXFrame) which may provide a much simpler way to render these kinds of graphics.
Displaying an FXImage inside an FXImageFrame is very straightforward. If you already have an image available, just pass it in as the second argument to the FXImageFrame constructor, e.g.
FXImage *image = new FXPNGImage(getApp(), pix); FXImageFrame *imageframe = new FXImageFrame(parent, image, FRAME_SUNKEN|FRAME_THICK|LAYOUT_FILL); |
You can of course retrieve a pointer to the image by calling the image frame's getImage() member function, or assign a new image using the setImage() member function. Also note that the FXImageFrame widget supports the JUSTIFY_LEFT, JUSTIFY_RIGHT, JUSTIFY_BOTTOM and JUSTIFY_TOP options, which can be specified at construction time or accessed later using the getJustify() and setJustify() member functions. By default, the image is simply centered inside the available space.
The FXBitmapFrame widget works similarly to the FXImageFrame widget, and supports the same options for justification of the bitmap inside the frame. One additional feature is that you can use the getOnColor(), getOffColor(), setOnColor() and setOffColor() member functions to specify which colors to use for the "on" and "off" bits in the bitmap. By default, the FXBitmapFrame will use pure black for the "on" bits and the window's background color for the "off" bits.
Finally, remember that bitmaps and images are shared resources and so the FXBitmapFrame and FXImageFrame will not destroy the currently assigned bitmap (image) when the frame is destroyed. In order to avoid memory leaks in your program, you must delete these objects separately.