4 // Copyright (c) 1998-2002 Per Liden
6 // This program is free software; you can redistribute it and/or modify
7 // it under the terms of the GNU General Public License as published by
8 // the Free Software Foundation; either version 2 of the License, or
9 // (at your option) any later version.
11 // This program is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 // GNU General Public License for more details.
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1307,
24 #include <X11/extensions/shape.h>
33 Xpm::Xpm(Display
* display
, Window root
, char** data
)
39 mAttributes
.valuemask
= 0;
40 error
= XpmCreatePixmapFromData(mDisplay
, root
, data
, &mImage
, &mMask
, &mAttributes
);
44 cerr
<< APPNAME
<< ": xpm image loaded but did not get all colors needed" << endl
;
48 cerr
<< APPNAME
<< ": could not load xpm image (not enough colors available)" << endl
;
53 cerr
<< APPNAME
<< ": could not load xpm image (not enough memory available)" << endl
;
59 cerr
<< APPNAME
<< ": could not load xpm image (image broken or corrupt)" << endl
;
73 XFreePixmap(mDisplay
, mImage
);
77 XFreePixmap(mDisplay
, mMask
);
81 void Xpm::setWindowPixmap(Window win
)
83 XResizeWindow(mDisplay
, win
, mAttributes
.width
, mAttributes
.height
);
84 XSetWindowBackgroundPixmap(mDisplay
, win
, mImage
);
87 void Xpm::setWindowPixmapShaped(Window win
)
89 XResizeWindow(mDisplay
, win
, mAttributes
.width
, mAttributes
.height
);
90 XSetWindowBackgroundPixmap(mDisplay
, win
, mImage
);
91 XShapeCombineMask(mDisplay
, win
, ShapeBounding
, 0, 0, mMask
, ShapeSet
);
94 void Xpm::drawString(int x
, int y
, char* text
)
100 font
= XLoadFont(mDisplay
, LABEL_FONT
);
102 gcv
.foreground
= WhitePixel(mDisplay
, DefaultScreen(mDisplay
));
103 gc
= XCreateGC(mDisplay
, mImage
, GCFont
| GCForeground
, &gcv
);
104 XDrawString(mDisplay
, mImage
, gc
, x
, y
, text
, strlen(text
));
105 XFreeGC(mDisplay
, gc
);
106 XUnloadFont(mDisplay
, font
);