Version 6 (modified by 17 years ago) ( diff ) | ,
---|
Icon Tutorial
This page describes how to create icons for the WPS-Wizard icon engine. One of the key features of the engine is that you don't have to paint every single icon in an image manipulation application. Instead there is support for icon composing which means you build your image using several parts which are blended together. For example one choses a base icon and another image is resized and painted on top of that one and maybe additional text is added. The resulting image is not stored as an icon on the users system but only the paint commands are recorded in an initialization file and the image is constructed on the fly as soon as the icon is loaded by the system.
The images used for compositing have PNG format so alpha blending can be used.
Note: when talking about 'icon' in the following text an icon built by the icon engine is meant not one of the default eCS system icons.
This tutorial is mainly intended for icon package creators. Some of the techniques described here are useful when changing object icons, too.
How icons are stored
The engine uses paint commands recorded in an initialization file which are interpreted during icon loading. A pointer to the folder holding this ini file is stored in the users ini file OS2.INI:
Application key name: IconTheme Key name: IconFolder Contents: Path to folder holding the INI file
Be sure to keep the spelling for the keys.
Format of the initialization file
The name of the initialization file must be:
WPSWIZ-THEME.INI
All images used for composing icons are located in the directory holding the ini file or a subdirectory of it. The engine uses the ini file loction as an anchor and searches all parts referenced in paint commands relative to this anchor point.
Icons are searched based on the objects class name and the object ID. Custom icons created from the settings notebook of an object are referenced using a numeric key. This is not described here.
For every class in the system there may be a unique icon. This is used when no object specific icon can be found.
Application key name: Class name, e.g. CWDataFile, WPFolder, AMouse Key names: Various, will be described later Contents: Paint commands and references to files
Note that the application key name must reflect the exact spelling of the class.
For an object specific icon the object ID is used as the application key:
Application key name: Object ID, e.g. <XWP_SCREEN>, <WP_OS2SYS>, <WP_DESKTOP> Key names: Various, will be described later Contents: Paint commands and references to files
The application key must be exactly like the ID, this includes the opening and closing braces.
The Search order for icons is the following:
- Object specific icon referenced by numeric ID
- Object specific icon referenced by object ID
- Class specific icon referenced by class name
- Object specific eCS icon
- Class specific eCS icon
As can be seen the icon engine will fall back to the eCS icon handling when no engine icon can be found.
Creating an icon using compositing
The easiest way to create an icon for the engine is combining several icons to form a new image. The following sections will step through this compositing process. As an example the image for the multimedia folder from the Noia Warm icon set will be used.
(Note that this icon is scaled to 120x120 pixels)
1. Create the initialization file entry
At the moment creating icons which are part of an icon package is a little bit cumbersome. Changing existing icons is done as usual from the icon page of the settings notebook. This will change in the future.
The multimedia folder has the object ID <MMPM2_FOLDER>. If you have XWorkplace installed you may use the Details button on the icon page to query the ID of every object. Using an ini editor (eCS comes with regedit2.exe) enter the following into the ini file.
The path to the referenced image is relative to the place where the ini file is located.
After putting the path to the folder holding the ini file into your os2.ini (see above) restart the WPS (I already mentioned that creating themes is a little bit cumbersome...). Your multimedia folder should have the generic folder icon now.
2. Enhancing the base image
From now on things are way easier. Open the settings notebook of the multimedia folder object, go to the icon page and press the Browse button. A folder window will open which contains a single object labeled as <MMPM2_FOLDER>.
There is only one single object because the ini file only contains one entry for now. If you have an icon package installed the folder contains all defined icons for the package in question which may be several hundred.
Normally one would just drag one of the predefined icons to the icon page to assign a new icon but we intend to create a new one so we will use the icon editor to change the predefined icon shape.
Note that you won't do that when just editing the icon of some random object. In that case the Edit button on the icon page is used like for normal eCS icon management.
Double click on the object to show the settings notebook. Click the Edit button and the icon editor will be started.
The editor is basically a specialized ini file editor with a preview function for the images. On the left you have a listbox with the currently defined keys, the bottom text field shows the data associated with the selected key and on the right you find a preview area. Pressing the Repaint button will take the provided data from the keys and create the preview image.
Adding an overlay image
As mentioned early an icon will be created by composing it from several images.
Click New to create a new key with the following data.
Key name: OverlayImage Data: apps\kcmsound.png
Repainting the preview does not show any effect. So what's missing?
The icon engine uses paint commands describing the shape of the resulting icon which are interpreted during icon loading. Up to now no such commands are specified.
Create another key:
Key name: CairoCommands Data: <ctxt>save</><scale>0.01 0.01</><imgkey>OverlayImage # 1</><ctxt>restore</>