wxArtProvider(3)

πŸ“¦
version 29.0.6 Β· 3 versions
, in ubuntu stonking

🌸 wxArtProvider 🌸

okay bestie, so this is the Erlang module wxArtProvider β€” it's an Erlang module definition, and it's the whole entire vibe for making your wxWidgets app look however you want. Let's get into it, no cap.


✨ NAME ✨

wxArtProvider β€” the wxArtProvider class is used to customize the look of wxWidgets application. periodt.


πŸŽ€ DESCRIPTION πŸŽ€

okay so here's the tea: when wxWidgets needs to display an icon or a bitmap (like, say, in the standard file dialog), it does not use a hard-coded resource. nope. instead it asks wxArtProvider for it. πŸ’… and that's the whole point β€” this way users can plug in their own wxArtProvider class and easily replace standard art with their own version. iconic behaviour honestly.

all you gotta do is derive a class from wxArtProvider, override either its wxArtProvider::CreateBitmap() (not implemented in wx) and/or its wxArtProvider::CreateIconBundle() (not implemented in wx) methods, and then register the provider with wxArtProvider::Push() (not implemented in wx):

oooh and heads up β€” if you need bitmap images (of the same artwork) that should be displayed at different sizes, you should probably consider overriding wxArtProvider::CreateIconBundle (not implemented in wx) and supplying icon bundles that contain different bitmap sizes. like, that's the move bestie.

there's another way of taking advantage of this class too: you can use it in your code and use platform native icons as provided by getBitmap/2 or getIcon/2. πŸ¦‹

πŸ” Identifying art resources

every bitmap and icon bundle are known to wxArtProvider under an unique ID that's used when requesting a resource from it. the ID is represented by the ?wxArtID type and can have one of these predefined values (you can see bitmaps represented by these constants in the page_samples_artprov):

plus, additionally, any string recognized by custom art providers registered using wxArtProvider::Push (not implemented in wx) may be used. πŸ’«

Note: When running under GTK+ 2, GTK+ stock item IDs (e.g. "gtk-cdrom") may be used as well: For a list of the GTK+ stock items please refer to the GTK+ documentation page. It is also possible to load icons from the 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 wxArtProvider may return ?wxNullBitmap or ?wxNullIcon. The default theme is typically installed in /usr/share/icons/hicolor.

πŸ‘‘ Clients

the client is the entity that calls wxArtProvider's getBitmap/2 or getIcon/2 function. it's represented by wxClientID type and can have one of these values:

  • wxART_TOOLBAR
  • wxART_MENU
  • wxART_BUTTON
  • wxART_FRAME_ICON
  • wxART_CMN_DIALOG
  • wxART_HELP_BROWSER
  • wxART_MESSAGE_BOX
  • wxART_OTHER (used for all requests that don't fit into any of the categories above)

client ID serve as a hint to wxArtProvider that is supposed to help it to choose the best looking bitmap. like for example it is often desirable to use slightly different icons in menus and toolbars even though they represent the same action (e.g. wxART_FILE_OPEN). but remember that this is really only a hint for wxArtProvider β€” it is common that getBitmap/2 returns identical bitmap for different client values! 😭 so don't come for it.

πŸ‘€ See

  • Examples
  • wxArtProvider

wxWidgets docs: wxArtProvider


🧚 DATA TYPES 🧚

wxArtProvider() :: wx:wx_object().

πŸ’– FUNCTIONS πŸ’–

  • getBitmap(Id, [Option]) -> wxBitmap:wxBitmap()

with the when clause:

Id :: unicode:chardata(),
Option ::
    {client, unicode:chardata()} |
    {size, {W :: integer(), H :: integer()}}.

query registered providers for bitmap with given ID. πŸ”₯

Return: The bitmap if one of registered providers recognizes the ID or wxNullBitmap otherwise.

  • getIcon(Id, [Option]) -> wxIcon:wxIcon()

with the when clause:

Id :: unicode:chardata(),
Option ::
    {client, unicode:chardata()} |
    {size, {W :: integer(), H :: integer()}}.

same as getBitmap/2, but return a wxIcon object (or ?wxNullIcon on failure). πŸ’œ


and that's the whole page bestie, you ate it. πŸ’…βœ¨

this little love letter came to you from Ericsson AB, documenting wx 2.6 β€” yes it's giving vintage but she still serves. wxArtProvider(3), out. πŸŽ€πŸ¦‹πŸ’–

πŸ“¦ where this page comes from