X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/82e94f591f2638b07a4f28c096d94ec7e8571c20..5f9e369af0c834bbde0f7f5d2047abd736967f58:/docs/tech/tn0015.txt?ds=inline diff --git a/docs/tech/tn0015.txt b/docs/tech/tn0015.txt index 5575d2de90..32f9d80e9c 100644 --- a/docs/tech/tn0015.txt +++ b/docs/tech/tn0015.txt @@ -1,4 +1,4 @@ - How to add new bitmaps to wxWindows UI elements + How to add new bitmaps to wxWidgets UI elements =============================================== 0. Introduction @@ -10,7 +10,7 @@ code. This was previously done either by including the bitmap in win32 resource file (include/wx/msw/wx.rc) or by including XPM files in the code. wxArtProvider should be used instead, to allow users to customize the look of -their wxWindows app. This technote is a detailed description of steps needed +their wxWidgets app. This technote is a detailed description of steps needed when adding new bitmap/icon. 1. Adding new resource @@ -22,8 +22,8 @@ when adding new bitmap/icon. First of all, you have to add new wxArtID constant to include/wx/artprov.h. Look for "Art IDs" and add new definition to the list, e.g. #define wxART_MY_BITMAP wxART_MAKE_ART_ID(wxART_MY_BITMAP) - -Add it to docs/latex/wx/artprov.tex, too. + +Add it to interface/wx/artprov.h, too. It may happen that the intended use of the new resource doesn't fit into any of defined client categories (search for "Art clients" in the header). In case @@ -46,7 +46,7 @@ currently only used by the generic file dialog. Remember that wxArtProvider can be used by users, not only the library. Finally, wxDefaultArtProvider in $(wx)/src/common/artstd.cpp must be updated. -This consists of two steps: +This consists of two steps: a) add #include line for your XPM file, e.g. #include "../../art/my_bmp.xpm" b) add ART(...) line to wxDefaultArtProvider::CreateBitmap(). The first @@ -58,6 +58,35 @@ That's all. The bitmap is now available to wxArtProvider users. Note: there's no difference between icons and bitmaps, always treat them as bitmaps inside wx(Default)ArtProvider. +1b. Adding Tango version of the resource. +----------------------------------------- + +While all the bitmaps are provided in XPM format so that they are available in +all builds of wxWidgets, we also provide most of them in PNG format with full +transparency support that is not available in XPM. Another advantage of the PNG +versions is that the icons used are those of the Tango project and so have the +consistent look, unlike the XPM ones. + +So if you an icon exists in http://tango.freedesktop.org/Tango_Icon_Gallery you +should add it too. For this you need to: + +1. Convert the PNG to a C array of bytes suitable for inclusion in the code. + This is done using misc/scripts/png2c.py script, e.g. if the variable "f" + contains the name of the icon you want to add and you have installed Tango + icons in a standard location under a Linux system: + + ./misc/scripts/png2c.py -s /usr/share/icons/Tango/{16x16,24x24}/*/$f.png > + art/tango/${f//-/_}.h + + Of course, the same command may be ran with different paths under Windows. + Just remember to add both 16 and 24 pixel versions of the bitmap to the + header and use the "-s" option to embed the image size in its array name. + +2. Add #include for the newly created file to src/common/arttango.cpp. + +3. Add an entry to s_allBitmaps array in the same file. + + 2. Accessing the resource ------------------------- @@ -77,10 +106,10 @@ client is wxART_OTHER you may write only ------------------- It is highly desirable to let the users know what stock bitmaps are available -in wxWindows. The "artprov" sample serves this purpose: it contains a browser +in wxWidgets. The "artprov" sample serves this purpose: it contains a browser dialog that displays all available art resources. -It has to be updated to accomodate for new bitmaps. Fortunately, this is +It has to be updated to accommodate for new bitmaps. Fortunately, this is trivial: open $(wx)/samples/artprov/artbrows.cpp in text editor and ART_ICON(wxART_MY_BITMAP) line to the FillBitmaps() function. @@ -89,4 +118,3 @@ client to the end of the list. === EOF === -Version: $Id$