1 /*
2  * icon.hh - Defines the icon widget.
3  * Copyright (C) 2001 Frank Hale
4  * frankhale@yahoo.com
5  * http://sapphire.sourceforge.net/
6  *
7  * Updated: 19 July 2001
8  *
9  * NOTE:
10  *
11  * 	This code borrows a little from fspanel.c and desklaunch.c so
12  * credits go to the authors who wrote those two programs.
13  *
14  * I borrowed the GC and grill drawing code from fspanel.
15  * I borrowed GNOME and MWM hints stuff from desklaunch.
16  *
17  * fspanel: http://www.chatjunkies.org/fspanel/
18  * desklaunch : http://www.kensden.pwp.blueyonder.co.uk/Oroborus/
19  *
20  *
21  * This program is free software; you can redistribute it and/or
22  * modify it under the terms of the GNU General Public License
23  * as published by the Free Software Foundation; either version 2
24  * of the License, or any later version.
25  *
26  * This program is distributed in the hope that it will be useful,
27  * but WITHOUT ANY WARRANTY; without even the implied warranty of
28  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
29  * GNU General Public License for more details.
30  *
31  * You should have received a copy of the GNU General Public License
32  * along with this program; if not, write to the Free Software
33  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
34  */
35 
36 #ifndef _ICON_HH_
37 #define _ICON_HH_
38 
39 #include <iostream>
40 #include <string>
41 #include <X11/Xlib.h>
42 #include <X11/xpm.h>
43 #include <X11/extensions/shape.h>
44 #include <stdlib.h>
45 
46 class Icon
47 {
48 private:
49 	Display *dpy;
50 	Window icon_win, root, parent_win;
51 	Visual *visual;
52 	int screen, depth;
53 	unsigned int x,y,w,h;
54 	Pixmap icon_pixmap, icon_pixmap_mask;
55 	XpmAttributes icon_pixmap_attr;
56 	XSetWindowAttributes attr;
57 
58 	std::string exe;
59 
60 private:
61 	void configureWindow();
62 
63 public:
64 	Icon(Display *d, Window parent);
65 	Icon(Display *d, std::string iconFilename, Window parent);
66 	~Icon();
67 
68 	bool loadPixmap(std::string iconFilename);
69 
setExecuteCommand(std::string command)70 	void setExecuteCommand(std::string command) { exe=command; }
71 
getX() const72 	unsigned int getX() const { return x; }
getY() const73 	unsigned int getY() const { return y; }
getWidth() const74 	unsigned int getWidth() const { return w; }
getHeight() const75 	unsigned int getHeight() const { return h; }
76 
77 	void executeCommand();
78 
79 	void updateXYPos(); // Makes sure the x,y variables are updated.
80 
getIconWindow() const81 	Window getIconWindow() const { return icon_win; }
82 };
83 
84 #endif
85