// XGrayWin.C // C++ Library for easy XLib- usage // Compile this file with 'CC -c XAllWin.c -o XAllWin.o' // Compile your file with 'CC yourcode.c XGrayWin.o -lX11 -o yourname' // (g++ instead of CC is possible, but must be consequent for all files) // written by Rainer Malaka and Kay-Ole Behrman // 26.11.92 /* g++ -c -Wall -g XAllWin.c -o XAllWin.o */ //#include //#include //#include #include "nsl_include.h" #include "DLMwin.h" /**** Globale Variablen fuer alle : ****/ static int Xisda=-1; // -1:dontknow 0:nicht da 1: is da static Display *display=NULL;// screen+keyboard+maus, fuer alle objekte gleich /*** Globale Variablen, fuer alle Objekte vom Typ XGrayWin die selben : ***/ static GC colorgc[MAXLEVELS]; // GCs fuer verschiedene graustufen static GC redgc; static int GrayIncarnations=0; // Konstruktor-Aufrufe minus Destructor-Aufrufe static int AllIncarnations=0; // Konstruktor-Aufrufe minus Destructor-Aufrufe #ifndef NSL_PC #define IconWidth 40 #define IconHeight 40 static char MonoIconBits[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x81, 0x03, 0x21, 0x80, 0x70, 0x83, 0x84, 0x21, 0x40, 0x10, 0x82, 0x8c, 0x23, 0x20, 0x10, 0x44, 0x44, 0x22, 0x20, 0x18, 0x46, 0x46, 0x22, 0x10, 0x08, 0xe3, 0xe3, 0x22, 0x10, 0x08, 0xa1, 0xa0, 0x23, 0x09, 0xcc, 0x20, 0x31, 0xa1, 0x09, 0x7c, 0x10, 0x12, 0xe1, 0x05, 0x0e, 0x10, 0x14, 0x61, 0x06, 0x00, 0x08, 0x04, 0x23, 0x02, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8e, 0x91, 0x18, 0x00, 0x00, 0x4e, 0xb2, 0x24, 0x00, 0x00, 0x4a, 0xd2, 0x24, 0x00, 0x00, 0x8a, 0x91, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; static char GrayIconBits[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x81, 0x03, 0x21, 0x80, 0x70, 0x83, 0x84, 0x21, 0x40, 0x10, 0x82, 0x8c, 0x23, 0x20, 0x10, 0x44, 0x44, 0x22, 0x20, 0x18, 0x46, 0x46, 0x22, 0x10, 0x08, 0xe3, 0xe3, 0x22, 0x10, 0x08, 0xa1, 0xa0, 0x23, 0x09, 0xcc, 0x20, 0x31, 0xa1, 0x09, 0x7c, 0x10, 0x12, 0xe1, 0x05, 0x0e, 0x10, 0x14, 0x61, 0x06, 0x00, 0x08, 0x04, 0x23, 0x02, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xcc, 0x10, 0x05, 0x00, 0x00, 0x42, 0x29, 0x02, 0x00, 0x00, 0xca, 0x38, 0x02, 0x00, 0x00, 0x4c, 0x29, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; static char ColorIconBits[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x81, 0x03, 0x21, 0x80, 0x70, 0x83, 0x84, 0x21, 0x40, 0x10, 0x82, 0x8c, 0x23, 0x20, 0x10, 0x44, 0x44, 0x22, 0x20, 0x18, 0x46, 0x46, 0x22, 0x10, 0x08, 0xe3, 0xe3, 0x22, 0x10, 0x08, 0xa1, 0xa0, 0x23, 0x09, 0xcc, 0x20, 0x31, 0xa1, 0x09, 0x7c, 0x10, 0x12, 0xe1, 0x05, 0x0e, 0x10, 0x14, 0x61, 0x06, 0x00, 0x08, 0x04, 0x23, 0x02, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x04, 0x63, 0x00, 0x80, 0x90, 0x84, 0xa4, 0x00, 0x80, 0x90, 0x84, 0x64, 0x00, 0x00, 0x63, 0x1c, 0xa3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; #endif //*************************************************************************MONO void XMonoWin::loadFont(XFontStruct **font) { char *fontname = "9x15"; #ifndef NSL_PC if((*font = XLoadQueryFont(display,fontname)) == NULL) { printf("Font %s kann nicht geoeffnet werden\n",fontname); exit(1); } #endif }/*loadFont*/ //*************************************************************************MONO XMonoWin::XMonoWin(char* name, int dx, int dy, int x, int y) // constructor { #ifndef NSL_PC Pixmap icon_pixmap; unsigned border_width = 10; XSizeHints size_hints; XEvent report; XGCValues values; AllIncarnations++; // needed for XCloseDispay in destructor if(Xisda==-1) // ist dies der allererste Konstruktor ? { if((display = XOpenDisplay(NULL)) == NULL) // display ist global { printf("X-Server %s nicht erreichbar.\n",XDisplayName(NULL)); printf("Alle weiteren XGrayWin Aufrufe werden ignoriert! \n"); Xisda=0; return; } else Xisda=1; } if(Xisda==0) return; // kein X-Server verfuegbar if(display==NULL) exit(printf("interner XMonoWin Fehler : kein display\n")); screen_num = DefaultScreen(display); // normalerweise 0 screen_ptr = DefaultScreenOfDisplay(display); win = XCreateSimpleWindow(display,RootWindow(display,screen_num), x,y,dx,dy,border_width,BlackPixel(display,screen_num), WhitePixel(display,screen_num)); icon_pixmap = XCreateBitmapFromData(display,win,MonoIconBits,IconWidth,IconHeight); size_hints.flags = PPosition | PSize | PMinSize; size_hints.min_width = 10; size_hints.min_height = 10; XWMHints wm_hints; XClassHint class_hints; XTextProperty PName; if(XStringListToTextProperty(&name,1,&PName) == 0) { printf("Fehler beim Allokieren fuer Namen\n"); exit(1); } wm_hints.initial_state = NormalState; wm_hints.input = True; wm_hints.icon_pixmap = icon_pixmap; wm_hints.flags = StateHint | IconPixmapHint | InputHint; class_hints.res_name = name; class_hints.res_class = name; XSetWMProperties(display,win,&PName,&PName,NULL,0, &size_hints,&wm_hints,&class_hints); XSelectInput(display,win,ExposureMask); // welche events kommen an ? loadFont(&font_info); gc_black = XCreateGC(display,win,0,&values); XSetFont(display,gc_black,font_info->fid); XSetForeground(display,gc_black,BlackPixel(display,screen_num)); gc_white = XCreateGC(display,win,0,&values); XSetFont(display,gc_white,font_info->fid); XSetForeground(display,gc_white,WhitePixel(display,screen_num)); XMapWindow(display,win); do XNextEvent(display,&report); while(report.type != Expose || report.xexpose.count != 0); #endif }/*End of Constructor*/ //*************************************************************************MONO XMonoWin::~XMonoWin(void) /* Destructor */ { #ifndef NSL_PC AllIncarnations--; if(Xisda) { XUnloadFont(display,font_info->fid); // XFreeGC(display,gc_black); // XFreeGC(display,gc_white); if(AllIncarnations==0) XCloseDisplay(display); // also frees GCs (but leaves color black&white?) } #endif } //*************************************************************************MONO void XMonoWin::Flush(void) { #ifndef NSL_PC if(Xisda) XFlush(display); #endif }/*XGFlush*/ //*************************************************************************MONO void XMonoWin::Line(int x1, int y1, int x2, int y2, int col) { #ifndef NSL_PC if(Xisda) XDrawLine(display,win,col?gc_white:gc_black,x1,y1,x2,y2); #endif } //*************************************************************************GRAY void XMonoWin::Rect (int x1, int y1, int width, int height, int col) { #ifndef NSL_PC if(Xisda) XFillRectangle(display, win, col?gc_white:gc_black, x1, y1,width,height); #endif } //*************************************************************************MONO void XMonoWin::Dot(int x1, int y1, int col) { #ifndef NSL_PC if(Xisda) XDrawPoint(display,win,col?gc_white:gc_black,x1,y1); #endif } //*************************************************************************MONO void XMonoWin::Text(int x1, int y1, char* text, int col) /* Diese Prozedur loescht vorher auch den Bildschirminhalt, auf dem */ /* der String dargestellt wird. */ { #ifndef NSL_PC if(Xisda) { XClearArea(display,win,x1,y1-font_info->max_bounds.ascent, XTextWidth(font_info,text,strlen(text)), font_info->max_bounds.ascent + font_info->max_bounds.descent,0); XDrawString(display,win,col?gc_white:gc_black,x1,y1,text,strlen(text)); } #endif } //*************************************************************************MONO void XMonoWin::ClearArea(int x1,int y1,int dx,int dy) { #ifndef NSL_PC if(Xisda) XClearArea(display, win, x1,y1,dx,dy,0); #endif } //*************************************************************************MONO void XMonoWin::Clear() { #ifndef NSL_PC if(Xisda) XClearWindow(display,win); #endif } //*************************************************************************MONO //*************************************************************************GRAY void XGrayWin::loadFont(XFontStruct **font) { char *fontname = "9x15"; #ifndef NSL_PC if((*font = XLoadQueryFont(display,fontname)) == NULL) { printf("Font %s kann nicht geoeffnet werden\n",fontname); exit(1); } #endif }/*loadFont*/ //*************************************************************************GRAY void XGrayWin::hole_GCs(void) // private function, used by constructor { #ifndef NSL_PC XGCValues values; Colormap default_cmap; /* diese Colormap wollen wir benutzen */ int count; XColor colorcell_def; /* struct mit red,green,blue und pixel */ int black_red, black_green, black_blue; /* black=gray0 */ int white_red, white_green, white_blue; /* white=gray100 */ float level; default_cmap=DefaultColormap(display,screen_num); /* wie parent-window */ // used gray11 instead of gray0 for black, cause sun makes no difference // from gray0... gray20 (approx.), all seems to be black! xxx // used gray99 instead of gray100 (or white), because all allocated colors // will automatically be FREED at exit. // even white (which is certainly used by openwin2, too) is freed, because // openwin2 does not properly allocates white. // That's an openwin2 bug. openwin3 does it right. if(! XParseColor(display,default_cmap,"gray11",&colorcell_def))exit(11); black_red = colorcell_def.red; black_green= colorcell_def.green; black_blue = colorcell_def.blue; if(! XParseColor(display,default_cmap,"gray99",&colorcell_def))exit(11); white_red = colorcell_def.red; white_green= colorcell_def.green; white_blue = colorcell_def.blue; for(count=0; countfid); } if(! XParseColor(display,default_cmap,"red",&colorcell_def))exit(11); redgc=XCreateGC(display,win,0,&values); /* GC erzeugen */ XAllocColor(display, default_cmap, &colorcell_def); /* holt pixelwert */ XSetForeground(display, redgc, colorcell_def.pixel); /* wert rein */ XSetFont(display, redgc, font_info->fid); #endif } //*************************** constructor XGrayWin ************************GRAY XGrayWin::XGrayWin(char* name, // name des fensters int dx, int dy, // groesse des fensters int x, int y) // position auf bildschirm { #ifndef NSL_PC Pixmap icon_pixmap; unsigned border_width = 10; XSizeHints size_hints; XEvent report; AllIncarnations++; // needed for XCloseDispay in destructor GrayIncarnations++; // constructiong counts up, destructing down if(Xisda==-1) // ist dies der allererste Konstruktor ? { if((display = XOpenDisplay(NULL)) == NULL) // display ist global { printf("X-Server %s nicht erreichbar.\n",XDisplayName(NULL)); printf("Alle weiteren XGrayWin Aufrufe werden ignoriert! \n"); Xisda=0; return; } else Xisda=1; } if(Xisda==0) return; // kein X-Server verfuegbar if(display==NULL) exit(printf("interner XGrayWin Fehler : kein display\n")); screen_num = DefaultScreen(display); // normalerweise 0 screen_ptr = DefaultScreenOfDisplay(display); win = XCreateSimpleWindow(display,RootWindow(display,screen_num), x,y,dx,dy,border_width,BlackPixel(display,screen_num), WhitePixel(display,screen_num)); icon_pixmap = XCreateBitmapFromData(display,win,GrayIconBits,IconWidth,IconHeight); size_hints.flags = PPosition | PSize | PMinSize; size_hints.min_width = 10; size_hints.min_height = 10; XWMHints wm_hints; XClassHint class_hints; XTextProperty PName; if(XStringListToTextProperty(&name,1,&PName) == 0) { printf("Fehler beim Allokieren fuer Namen\n"); exit(1); } wm_hints.initial_state = NormalState; wm_hints.input = True; wm_hints.icon_pixmap = icon_pixmap; wm_hints.flags = StateHint | IconPixmapHint | InputHint; class_hints.res_name = name; class_hints.res_class = name; XSetWMProperties(display,win,&PName,&PName,NULL,0, &size_hints,&wm_hints,&class_hints); XSelectInput(display,win,ExposureMask); // welche events kommen an ? loadFont(&font_info); if(GrayIncarnations==1) // this is the first gray-constructor { hole_GCs(); } XMapWindow(display,win); do XNextEvent(display,&report); while(report.type != Expose || report.xexpose.count != 0); #endif }/*End of Constructor*/ //************************************************************************GRAY XGrayWin::~XGrayWin(void) // Destructor { #ifndef NSL_PC GrayIncarnations--; // AllIncarnations--; // needed for XCloseDispay in destructor if(Xisda) { XUnloadFont(display,font_info->fid); if(GrayIncarnations==0) // this destructor destructs last graywin { // die GC duerfen nicht explizit FREEd werden, denn dadurch werden auch // XColors Deallociert. Einige XColors sind aber nicht von uns erzeugt // worden, sondern mit anderen geteilt gewesen, d.h. dealloc befreit // z.B. die openwindows-farben !!! if(AllIncarnations==0) { XCloseDisplay(display); // das FREEd die GCs offensichtlich sowieso! } } } #endif } //*************************************************************************GRAY void XGrayWin::Flush(void) { #ifndef NSL_PC if(Xisda) XFlush(display); #endif }/*XGFlush*/ //*************************************************************************GRAY void XGrayWin::Line(int x1, int y1, int x2, int y2, float col) { #ifndef NSL_PC if(Xisda) { if(col>1.0) col=1.0; if(col>=0.0) XDrawLine(display, win, colorgc[(int)(col*(MAXLEVELS-1))], x1, y1, x2, y2); else XDrawLine(display, win, redgc, x1, y1, x2, y2); } #endif } //*************************************************************************GRAY void XGrayWin::Dot(int x1, int y1, float col) { #ifndef NSL_PC if(Xisda) { if(col>1.0) col=1.0; if(col>=0.0) XDrawPoint(display, win, colorgc[(int)(col*(MAXLEVELS-1))], x1, y1); else XDrawPoint(display, win, redgc, x1, y1); } #endif } //*************************************************************************GRAY void XGrayWin::Rect (int x1, int y1, int width, int height, float col) { #ifndef NSL_PC if(Xisda) { if(col>1.0) col=1.0; if(col>=0.0) XFillRectangle(display, win, colorgc[(int)(col*(MAXLEVELS-1))], x1, y1,width,height); else XFillRectangle(display, win, redgc, x1, y1,width,height); } #endif } //*************************************************************************GRAY void XGrayWin::Text(int x1, int y1, char* text, float col) /* Diese Prozedur loescht vorher auch den Bildschirminhalt, auf dem */ /* der String dargestellt wird. */ { #ifndef NSL_PC if(Xisda) { if(col>1.0) col=1.0; XClearArea(display,win,x1,y1-font_info->max_bounds.ascent, XTextWidth(font_info,text,strlen(text)), font_info->max_bounds.ascent + font_info->max_bounds.descent,0); if(col>=0.0) XDrawString(display,win,colorgc[(int)(col*(MAXLEVELS-1))],x1,y1,text,strlen(text)); else XDrawString(display,win,redgc,x1,y1,text,strlen(text)); } #endif } //*************************************************************************GRAY void XGrayWin::DrawText(int x1, int y1, char* text, float col) { #ifndef NSL_PC if(Xisda) { if(col>1.0) col=1.0; if(col>=0.0) XDrawString(display,win,colorgc[(int)(col*(MAXLEVELS-1))],x1,y1,text,strlen(text)); else XDrawString(display,win,redgc,x1,y1,text,strlen(text)); } #endif } //*************************************************************************GRAY void XGrayWin::ClearArea(int x1,int y1,int dx,int dy) { #ifndef NSL_PC if(Xisda) XClearArea(display, win, x1,y1,dx,dy,0); #endif } //*************************************************************************GRAY void XGrayWin::Clear() { #ifndef NSL_PC if(Xisda) XClearWindow(display,win); #endif } //*************************************************************************GRAY //***************************************************************************** //************************************************************************COLOR void XColorWin::loadFont(XFontStruct **font) { char *fontname = "9x15"; #ifndef NSL_PC if((*font = XLoadQueryFont(display,fontname)) == NULL) { printf("Font %s kann nicht geoeffnet werden\n",fontname); exit(1); } #endif }/*loadFont*/ //************************************************************************COLOR void XColorWin::hole_GCs(void) // private function, used by constructor { } //****************************** constructor *****************************COLOR XColorWin::XColorWin(char* name, // name des fensters int dx, int dy, // groesse des fensters int x, int y) // position auf bildschirm { #ifndef NSL_PC Pixmap icon_pixmap; unsigned border_width = 10; XSizeHints size_hints; XEvent report; XGCValues values; /* dummy */ XColor colorcell_def; /* struct mit red,green,blue und pixel */ exit(printf(" colorwin not ready\n")); if(Xisda==-1) // ist dies der allererste Konstruktor ? { if((display = XOpenDisplay(NULL)) == NULL) // display ist global { printf("X-Server %s nicht erreichbar.\n",XDisplayName(NULL)); printf("Alle weiteren XColorWin Aufrufe werden ignoriert! \n"); Xisda=0; return; } else Xisda=1; } if(Xisda==0) return; // kein X-Server verfuegbar if(display==NULL) exit(printf("interner XColorWin Fehler : kein display\n")); screen_num = DefaultScreen(display); // normalerweise 0 screen_ptr = DefaultScreenOfDisplay(display); win = XCreateSimpleWindow(display,RootWindow(display,screen_num), x,y,dx,dy,border_width,BlackPixel(display,screen_num), WhitePixel(display,screen_num)); icon_pixmap = XCreateBitmapFromData(display,win,ColorIconBits,IconWidth,IconHeight); size_hints.flags = PPosition | PSize | PMinSize; size_hints.min_width = 10; size_hints.min_height = 10; XWMHints wm_hints; XClassHint class_hints; XTextProperty PName; if(XStringListToTextProperty(&name,1,&PName) == 0) { printf("Fehler beim Allokieren fuer Namen\n"); exit(1); } wm_hints.initial_state = NormalState; wm_hints.input = True; wm_hints.icon_pixmap = icon_pixmap; wm_hints.flags = StateHint | IconPixmapHint | InputHint; class_hints.res_name = name; class_hints.res_class = name; XSetWMProperties(display,win,&PName,&PName,NULL,0, &size_hints,&wm_hints,&class_hints); XSelectInput(display,win,ExposureMask); // welche events kommen an ? loadFont(&font_info); default_cmap=DefaultColormap(display,screen_num); /* wie parent-window */ int count; Window rf=(Window)RootWindow(display, screen_num); // if( XGetRGBColormaps(display, rf, (XStandardColormap**)(&best_map_info), &count, XA_RGB_BEST_MAP)==0) // exit(printf("xgetrgbcolormaps fails\n")); // XCreateColormap(display, win, DefaulVisual(display,screen_num),AllocAll); // int ir,ig,ib; // XAllocColorCells(display, default_cmap, True, PlaneMasks, 0, Pixels,4096); // for(ir=0; ir<16; ir++) // for(ig=0; ig<16; ig++) // for(ib=0; ib<16; ib++) // { // alldefs[ir*256+ig*16+ib].red= ir*4096; // alldefs[ir*256+ig*16+ib].green=ig*4096; // alldefs[ir*256+ig*16+ib].blue= ib*4096; // } // XStoreColors(display, default_cmap, alldefs, 4096); // if(! XParseColor(display, default_cmap, "red", &def_red)) exit(11); // XAllocColor(display, default_cmap, &def_red); /* holt pixelwert */ // if(! XParseColor(display, default_cmap, "green", &def_green)) exit(12); // XAllocColor(display, default_cmap, &def_green); /* holt pixelwert */ // if(! XParseColor(display, default_cmap,"blue", &def_blue)) exit(13); // XAllocColor(display, default_cmap, &def_blue); /* holt pixelwert */ gc_universal=XCreateGC(display,win,0,&values); /* GC erzeugen */ // XSetForeground (determines color) handled by drawing routines XSetFont(display, gc_universal, font_info->fid); XMapWindow(display,win); do XNextEvent(display,&report); while(report.type != Expose || report.xexpose.count != 0); #endif }/*End of Constructor*/ //************************************************************************COLOR XColorWin::~XColorWin(void) // Destructor { #ifndef NSL_PC if(Xisda) { XUnloadFont(display,font_info->fid); // XFreeGC(display,gc_universal); XCloseDisplay(display); //xxx } #endif } //************************************************************************COLOR void XColorWin::Flush(void) { #ifndef NSL_PC if(Xisda) XFlush(display); #endif }/*XGFlush*/ //************************************************************************COLOR #ifdef lololo void XColorWin::Line(int x1, int y1, int x2, int y2, float Rlevel,float Glevel, float Blevel) { #ifndef NSL_PC if(Xisda) { if(Rlevel>1) Rlevel=1; if(Glevel>1) Glevel=1; if(Blevel>1) Blevel=1; if(Rlevel<0) Rlevel=0; if(Glevel<0) Glevel=0; if(Blevel<0) Blevel=0; color_universal.red =(int)(Rlevel*def_red.red +Glevel*def_red.green +Blevel*def_red.blue); color_universal.green=(int)(Rlevel*def_green.red+Glevel*def_green.green+Blevel*def_green.blue); color_universal.blue =(int)(Rlevel*def_blue.red +Glevel*def_blue.green +Blevel*def_blue.blue); XAllocColor(display, default_cmap, &color_universal); XSetForeground(display,gc_universal,color_universal.pixel); XDrawLine(display, win, gc_universal, x1, y1, x2, y2); } #endif } #endif //************************************************************************COLOR void XColorWin::Dot(int x1, int y1, float Rlevel,float Glevel, float Blevel) { #ifndef NSL_PC unsigned long pixelvalue; if(Xisda) { if(Rlevel>1) Rlevel=1; if(Glevel>1) Glevel=1; if(Blevel>1) Blevel=1; if(Rlevel<0) Rlevel=0; if(Glevel<0) Glevel=0; if(Blevel<0) Blevel=0; // index=(int)(Rlevel*16*256)+(int)(Glevel*16*16)+(int)(Blevel*16); // color_universal.red =(int)(Rlevel*def_red.red +Glevel*def_red.green +Blevel*def_red.blue); // color_universal.green=(int)(Rlevel*def_green.red+Glevel*def_green.green+Blevel*def_green.blue); // color_universal.blue =(int)(Rlevel*def_blue.red +Glevel*def_blue.green +Blevel*def_blue.blue); pixelvalue= best_map_info.base_pixel+ ((unsigned long)(0.5+(Rlevel*best_map_info.red_max))* best_map_info.red_mult)+ ((unsigned long)(0.5+(Glevel*best_map_info.green_max))* best_map_info.green_mult)+ ((unsigned long)(0.5+(Blevel*best_map_info.blue_max))* best_map_info.blue_mult); XSetForeground(display,gc_universal,pixelvalue); XDrawPoint(display, win, gc_universal, x1, y1); // XFreeColors(display, default_cmap, &color_universal.pixel, 1, 0); } #endif } //************************************************************************COLOR #ifdef lololo void XColorWin::Text(int x1, int y1, char* text, float Rlevel,float Glevel, float Blevel) /* Diese Prozedur loescht vorher auch den Bildschirminhalt, auf dem */ /* der String dargestellt wird. */ { #ifndef NSL_PC if(Xisda) { if(Rlevel>1) Rlevel=1; if(Glevel>1) Glevel=1; if(Blevel>1) Blevel=1; if(Rlevel<0) Rlevel=0; if(Glevel<0) Glevel=0; if(Blevel<0) Blevel=0; color_universal.red =(int)(Rlevel*def_red.red +Glevel*def_red.green +Blevel*def_red.blue); color_universal.green=(int)(Rlevel*def_green.red+Glevel*def_green.green+Blevel*def_green.blue); color_universal.blue =(int)(Rlevel*def_blue.red +Glevel*def_blue.green +Blevel*def_blue.blue); XAllocColor(display, default_cmap, &color_universal); XSetForeground(display,gc_universal,color_universal.pixel); XClearArea(display,win,x1,y1-font_info->max_bounds.ascent, XTextWidth(font_info,text,strlen(text)), font_info->max_bounds.ascent + font_info->max_bounds.descent,0); XDrawString(display,win,gc_universal,x1,y1,text,strlen(text)); } #endif } //************************************************************************COLOR void XColorWin::DrawText(int x1, int y1, char* text, float Rlevel,float Glevel, float Blevel) { #ifndef NSL_PC if(Xisda) { if(Rlevel>1) Rlevel=1; if(Glevel>1) Glevel=1; if(Blevel>1) Blevel=1; if(Rlevel<0) Rlevel=0; if(Glevel<0) Glevel=0; if(Blevel<0) Blevel=0; color_universal.red =(int)(Rlevel*def_red.red +Glevel*def_red.green +Blevel*def_red.blue); color_universal.green=(int)(Rlevel*def_green.red+Glevel*def_green.green+Blevel*def_green.blue); color_universal.blue =(int)(Rlevel*def_blue.red +Glevel*def_blue.green +Blevel*def_blue.blue); XAllocColor(display, default_cmap, &color_universal); XSetForeground(display,gc_universal,color_universal.pixel); XDrawString(display,win,gc_universal,x1,y1,text,strlen(text)); } #endif } #endif //************************************************************************COLOR void XColorWin::ClearArea(int x1,int y1,int dx,int dy) { #ifndef NSL_PC if(Xisda) XClearArea(display, win, x1,y1,dx,dy,0); #endif } //************************************************************************COLOR void XColorWin::Clear() { #ifndef NSL_PC if(Xisda) XClearWindow(display,win); #endif } //************************************************************************COLOR