The ArtProvider class is used to customize the look of wxRuby
applications. When wxRuby needs to display an icon or a bitmap (e.g. in
the standard file dialog), it does not use a hard-coded resource but
asks ArtProvider for it instead. This way users can plug in their own
ArtProvider class and easily replace standard art with their own
version. All that is needed is to derive a class from ArtProvider,
override its create_bitmap method and
register the provider with
ArtProvider#push:
There’s another way of taking advantage of this class: you can use it in
your code and use platform native icons as provided by
ArtProvider#get_bitmap or
ArtProvider#get_icon.
Every bitmap is known to ArtProvider under an unique ID that is used by when
requesting a resource from it. The ID is represented by ArtID type and can
have one of these predefined values (you can see bitmaps represented by these
constants in the art provider section in the bigdemo sample):
Additionally, any string recognized by custom art providers registered using
push_provider may be used.
When running under GTK+ 2, GTK+ stock item IDs (e.g. "gtk-cdrom"
) may
be used as well. Additionally, if GTK was compiled against GTK+ >= 2.4, then
it is also possible to load icons from current icon theme by specifying their
name (without extension and directory components). Icon themes recognized
by GTK+ follow the
freedesktop.org Icon Themes specification. Note that themes are not guaranteed to contain all
icons, so ArtProvider may return Wx::NULL_BITMAP
or Wx::NULL_ICON
.
Default theme is typically installed in /usr/share/icons/hicolor
.
Client is the entity that calls ArtProvider’s GetBitmap or GetIcon
function. It is represented by ClientID type and can have one of these
values:
Client ID servers as a hint to ArtProvider that is supposed to help it to
choose the best looking bitmap. For example it is often desirable to use
slightly different icons in menus and toolbars even though they represent the
same action (e.g. _ART_FILE_OPEN
). Remember that this is really
only a hint for ArtProvider — it is common that
ArtProvider#get_bitmap
returns identical bitmap for different client values!
If you create your own custom Wx::ArtProvider subclasses, they must
include an instance method create_bitmap
. This method should accept
three arguments, as above, identifying the name, use and size of the
bitmap requested. The method should return a Wx::Bitmap
appropriate to the request, or nil
if the requested bitmap cannot be
supplied by the provider.
Note that it is not necessary for your custom Ruby ArtProvider classes
to perform any caching – wxRuby will cache repeated requests for the
same bitmap.
This is not part of ArtProvider’s public API and should not normally
be called directly in wxRuby code. Use
ArtProvider#get_bitmap or
ArtProvider#get_icon to query
ArtProvider for a resource.
Query registered providers for bitmap with given ID.
Wx::DEFAULT_SIZE
if size doesn’t matter.The bitmap if one of registered providers recognizes the ID or NullBitmap otherwise.
Same as ArtProvider#get_bitmap, but
return a Icon object (or Wx::NULL_ICON
on failure).
Registers a new art provider and adds it to the bottom of the providers
stack (i.e. it will be queried last).
Removes the latest added provider.
Registers a new art provider and adds it to the top of providers stack
(i.e. it will be queried first).
Removes a provider from the stack. The provider must have been added
previously.
[This page automatically generated from the Textile source at 2023-06-13 21:31:34 +0000]