// XGWin.h // C++ Library for easy XLib- usage. // Written by Rainer Malaka and Kay-Ole Behrmann // // This File Declares: // XMonoWin for Windows with Black/White Graphics (0=Black,1=White) // XGrayWin for Windows with GrayLeves 0=Black, MAXLEVELS=White // XColorWin for Windows with Colors. //XMonoWin is fast and does not need much Memory. // //XGrayWin is moderately fast (depends on how many GCs a server can cache, // and how many Graylevels are defined through MAXLEVELS) and needs much // memory for GC-Allocation for each Graylevel. All XGrayWins use the same // GCs, only the first incarnation allocates them. // //XColorWin is slow, but does not need much memory. The GC is modified // for each pixel drawn. // // **** Don`t forget to use Flush after drawing ! **** // #include "X11/Xlib.h" #include "X11/Xatom.h" #include "X11/Xutil.h" // Vorgehen, um verschiedene Farben zum Zeichnen zu benutzen: // - entweder: viele verschiedene GCs vorher erzeugen und dann benutzen // - oder : bei jedem Aufruf der Zeichenfunktion XSetForeground aufrufen #define MAXLEVELS 128 // Anzahl der Graustufen in XGrayWin. Darf nicht allzu // gross sein, da fuer jede graustufe ein GC angelegt wird! class XMonoWin { int screen_num; /* screen of display, normalerweise 0 */ Screen *screen_ptr; /* dummy */ GC gc_white; GC gc_black; Window win; XFontStruct *font_info; void loadFont(XFontStruct **font_info); void hole_GCs(void); public: XMonoWin(nsl_string name, int dx, int dy, int x, int y); // Constructor ~XMonoWin(); // Destructor void Line (int x1, int y1, int x2, int y2, int col=0); // col=0 void Dot (int x1, int y1, int col=0); // means void Rect (int x1, int y1, int width, int height, int col=0); void Text (int x1, int y1, char *text, int col=0); // black void Flush(void); // Don't forget ! void ClearArea(int x1,int y1,int dx,int dy); void Clear(void); }; //***************************************************************************** class XGrayWin { int screen_num; /* screen of display, normalerweise 0 */ Screen *screen_ptr; /* dummy */ Window win; XFontStruct *font_info; void loadFont(XFontStruct **font_info); void hole_GCs(void); public: XGrayWin(char *name, int dx, int dy, int x, int y); // Constructor ~XGrayWin(); // Destructor void Line (int x1, int y1, int x2, int y2, float col=0); void Dot (int x1, int y1, float col=0); void Rect (int x1, int y1, int width, int height, float col=0); void Text (int x1, int y1, char *text, float col=0); void DrawText (int x1, int y1, char *text, float col=0); void Flush(void); // Don't forget ! void ClearArea(int x1,int y1,int dx,int dy); void Clear(void); }; //***************************************************************************** class XColorWin { int screen_num; /* screen of display, normalerweise 0 */ Screen *screen_ptr; /* dummy */ GC gc_universal; /* one for all */ Colormap default_cmap; /* Colormap fur XAllocColorCells */ XColor color_universal; XColor def_red; /* basic colors */ XColor def_green; /* ..will be */ XColor def_blue; /* ..mixed */ XColor alldefs[4096]; Window win; XStandardColormap best_map_info; unsigned long PlaneMasks[1]; unsigned long Pixels[256]; XFontStruct *font_info; void loadFont(XFontStruct **font_info); void hole_GCs(void); public: XColorWin(char *name, int dx, int dy, int x, int y); // Constructor ~XColorWin(); // Destructor void Line (int x1, int y1, int x2, int y2, float Rlevel,float Glevel, float Blevel); void Dot (int x1, int y1, float Rlevel,float Glevel, float Blevel); void Text (int x1, int y1, char *text, float Rlevel,float Glevel, float Blevel); void DrawText (int x1, int y1, char *text, float Rlevel,float Glevel, float Blevel); void Flush(void); // Don't forget ! void ClearArea(int x1,int y1,int dx,int dy); void Clear(void); };