/* AntiRight (c) 2003-2005 Jeffrey Bedard antiright@gmail.com This file is part of AntiRight. AntiRight is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. AntiRight is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with AntiRight; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "pongr.h" void set_font(char* fontname) { XFontStruct *font=XLoadQueryFont(display, fontname); if(font==NULL) { font=XLoadQueryFont(display, "fixed"); } XSetFont(display, gc, font->fid); XFreeFont(display, font); } unsigned int get_pixel(int red,int green,int blue) { XColor color; Colormap colormap; colormap=DefaultColormap(display,DefaultScreen(display)); color.red=red*256; color.green=green*256; color.blue=blue*256; color.flags=DoRed|DoGreen|DoBlue; XAllocColor(display,colormap,&color); return(color.pixel); } void draw_pixmap(Window window, int x, int y, char **data) { Pixmap bitmap; XpmAttributes attributes; XpmColorSymbol symbol; int status; symbol.name=NULL; symbol.value="none"; symbol.pixel=get_pixel(215, 215, 215); attributes.colorsymbols=&symbol; attributes.numsymbols=1; attributes.valuemask=XpmColorSymbols; status= XpmCreatePixmapFromData(display, RootWindow(display, DefaultScreen(display)), data, &bitmap, NULL, &attributes); if(status==XpmSuccess) { XCopyArea(display, bitmap, window, gc, 0, 0, attributes.width, attributes.height, x, y); XFreePixmap(display, bitmap); } } void set_foreground(int red,int green,int blue) { XSetForeground(display,gc,get_pixel(red,green,blue)); } void xprint(int x,int y,char *string) { XDrawString(display,win,gc,x,y,string,strlen(string)); } Window create_window(Window parent, int x, int y, int width, int height) { Window window; window=XCreateSimpleWindow(display, parent, x, y, width, height, 0, BlackPixel(display, DefaultScreen(display)), WhitePixel(display, DefaultScreen(display))); XMapWindow(display, window); XSelectInput(display,window, ExposureMask | KeyPressMask | KeyReleaseMask | StructureNotifyMask | ButtonPressMask| ButtonReleaseMask); return(window); } void draw_grey(Window window, int width, int height) { set_foreground( 215, 215, 215); XFillRectangle(display, window, gc, 0, 0, width, height); } void draw_shadow(Window window, int width, int height) { set_foreground( 215, 215, 215); XFillRectangle(display, window, gc, 0, 0, width, height); set_foreground( 0,0,0); XDrawLine(display, window, gc, width-1, 0, width-1, height-1); XDrawLine(display, window, gc, width-1, height-1, 0, height-1); set_foreground( 255, 255, 255); XDrawLine(display, window, gc, 0, height-1, 0, 0); XDrawLine(display, window, gc, 0, 0, width-1, 0); set_foreground( 0,0,0); } void release(Window window) { draw_shadow(window, 64, 16); } void draw_sunken(Window window, int width, int height) { set_foreground( 200, 200, 200); XFillRectangle(display, window, gc, 0, 0, width, height); set_foreground( 255,255,255); XDrawLine(display, window, gc, width-1, 0, width-1, height-1); XDrawLine(display, window, gc, width-1, height-1, 0, height-1); set_foreground( 0, 0, 0); XDrawLine(display, window, gc, 0, height-1, 0, 0); XDrawLine(display, window, gc, 0, 0, width-1, 0); } void press(Window window) { draw_sunken(window, 64, 16); }