#include <Pt/Forms/Icon.h>
Represents an image at one or more logical sizes. More...
Public Member Functions | |
| Icon () | |
| Creates an empty icon with a built-in provider. | |
| Icon (const Icon &icon) | |
| Shares images with icon until addImage() or clear(). | |
| Icon (IconProvider &provider) | |
| Attaches provider. The icon does not own it. | |
| ~Icon () | |
| Releases this copy. More... | |
| Icon & | operator= (const Icon &icon) |
| Shares images with icon until addImage() or clear(). | |
| bool | empty () const |
| Returns true when no images are registered. | |
| void | clear () |
| Removes all images from this icon. More... | |
| void | addImage (const Gfx::Image &image) |
| Registers image using its pixel size as the key. More... | |
| void | addImage (const Gfx::SizeF &size, const Gfx::Image &image) |
| Registers image at logical size size. More... | |
| void | addImage (const Gfx::SizeF &size, const System::Path &path) |
| Registers a file path at logical size size. More... | |
| void | addImage (double width, double height, const System::Path &path) |
| Registers a file path at width by height. | |
| const Gfx::Image & | getImage (const Gfx::SizeF &area) const |
| Returns an image for the requested area. More... | |
| Gfx::SizeF | minimumSize () const |
| Returns the smallest registered size, or an empty size. | |
| Gfx::SizeF | maximumSize () const |
| Returns the largest registered size, or an empty size. | |
An Icon is not a Widget. It supplies images to controls, which request an image for a layout area with getImage(). Label, PushButton, Panel, and list items accept an Icon through setIcon().
A default icon uses a built-in provider. Icon(IconProvider&) attaches a caller-owned provider that must outlive the icon. Copies share the same implementation until addImage() or clear() changes one copy.
addImage() registers an image or file path at a logical size. Passing only an image uses its pixel size as the key. The logical size may differ from the pixel size. Images registered by path load as PNG on first use through Application::loadImage(). A missing path produces an empty image.
getImage() returns the registered image for a requested area. The built-in provider selects the largest image that fits entirely in that area. An empty icon produces an empty image. minimumSize() and maximumSize() return the smallest and largest registered keys.
| ~Icon | ( | ) |
The last copy destroys the shared images and detaches from a custom provider.
| void clear | ( | ) |
Copies of this icon are not affected.
| void addImage | ( | const Gfx::Image & | image | ) |
Copies of this icon are not affected.
| void addImage | ( | const Gfx::SizeF & | size, |
| const Gfx::Image & | image | ||
| ) |
Copies of this icon are not affected. size may differ from the image pixel size.
| void addImage | ( | const Gfx::SizeF & | size, |
| const System::Path & | path | ||
| ) |
The image loads on first use. Copies of this icon are not affected.
| const Gfx::Image& getImage | ( | const Gfx::SizeF & | area | ) | const |
May load a path image on first use.