aboutsummaryrefslogtreecommitdiff
path: root/src/icon.h
blob: ad9645ac1c9619a4c9e0a4f8f42f68871e548c14 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
/**
 * @file icon.h
 * @author Joe Wingbermuehle
 * @date 2004-2006
 *
 * @brief Header file for icon functions.
 *
 */

#ifndef ICON_H
#define ICON_H

struct ClientNode;

/** Structure to hold a scaled icon. */
typedef struct ScaledIconNode {

	int width;   /**< The scaled width of the icon. */
	int height;  /**< The scaled height of the icon. */

	Pixmap image;
	Pixmap mask;
#ifdef USE_XRENDER
	Picture imagePicture;
	Picture maskPicture;
#endif

	struct ScaledIconNode *next;

} ScaledIconNode;

/** Structure to hold an icon. */
typedef struct IconNode {

	char *name;                    /**< The name of the icon. */
	struct ImageNode *image;       /**< The image data. */
	struct ScaledIconNode *nodes;  /**< Scaled versions of the icon. */
	
	struct IconNode *next;         /**< The next icon in the list. */
	struct IconNode *prev;         /**< The previous icon in the list. */

} IconNode;

#ifdef USE_ICONS

/*@{*/
void InitializeIcons();
void StartupIcons();
void ShutdownIcons();
void DestroyIcons();
/*@}*/

/** Add an icon path.
 * This adds a path to the list of icon search paths.
 * @param path The icon path to add.
 */
void AddIconPath(char *path);

/** Render an icon.
 * This will scale an icon if necessary to fit the requested size. The
 * aspect ratio of the icon is preserved.
 * @param icon The icon to render.
 * @param d The drawable on which to place the icon.
 * @param x The x offset on the drawable to render the icon.
 * @param y The y offset on the drawable to render the icon.
 * @param width The width of the icon to display.
 * @param height The height of the icon to display.
 */
void PutIcon(IconNode *icon, Drawable d, int x, int y,
	int width, int height);

/** Load an icon for a client.
 * @param np The client.
 */
void LoadIcon(struct ClientNode *np);

/** Load an icon.
 * @param name The name of the icon to load.
 * @return A pointer to the icon (NULL if not found).
 */
IconNode *LoadNamedIcon(const char *name);

/** Destroy an icon.
 * @param icon The icon to destroy.
 */
void DestroyIcon(IconNode *icon);

/** Create and initialize a new icon structure.
 * @return The new icon structure.
 */
IconNode *CreateIcon();

#else

#define ICON_DUMMY_FUNCTION 0

#define InitializeIcons()               ICON_DUMMY_FUNCTION
#define StartupIcons()                  ICON_DUMMY_FUNCTION
#define ShutdownIcons()                 ICON_DUMMY_FUNCTION
#define DestroyIcons()                  ICON_DUMMY_FUNCTION
#define AddIconPath( a )                ICON_DUMMY_FUNCTION
#define PutIcon( a, b, c, d, e, f )     ICON_DUMMY_FUNCTION
#define LoadIcon( a )                   ICON_DUMMY_FUNCTION
#define LoadNamedIcon( a )              ICON_DUMMY_FUNCTION
#define DestroyIcon( a )                ICON_DUMMY_FUNCTION

#endif /* USE_ICONS */

#endif /* ICON_H */