home *** CD-ROM | disk | FTP | other *** search
- #include "xdmconsole.h"
-
- Display *disp;
- Window win;
- GC wingc;
- XFontStruct *font;
- XEvent thebigevent;
- XSizeHints hinthint;
- Cursor wincurs, opwincurs;
- int screen;
- long foreg, backg;
- int winw, winh;
-
-
- int initwin(width, height, x, y, border, trans, name)
- int width, height, x, y, border, trans;
- char *name;
- {
-
- if (win > 0) return(-1);
-
- if ((disp = XOpenDisplay("unix:0.0")) == NULL) exit(0);
- screen=DefaultScreen(disp);
-
- if (x < 0) x = (int) ((DisplayWidth(disp, screen) - width) /2);
- if (y < 0) y = (int) (DisplayHeight(disp, screen) - (height + 30));
-
- backg=WhitePixel(disp, screen);
- foreg=BlackPixel(disp, screen);
-
- win=XCreateSimpleWindow(disp, DefaultRootWindow(disp),
- x, y, width, height,
- border, foreg, backg);
-
- wingc=XCreateGC(disp, win, 0, 0);
- XSetBackground(disp, wingc, backg);
- XSetForeground(disp, wingc, foreg);
-
- XStoreName(disp, win, name);
-
- if (trans) XSetTransientForHint(disp, win, win);
- winh=height;
- winw=width;
- }
-
- int winfont(fontname)
- char *fontname;
- {
- int ndirs;
- char **dir;
-
- dir = XGetFontPath(disp, &ndirs);
- dir[ndirs] = (char *) malloc(sizeof("/usr/lib/X11/fonts/75dpi")+2);
- strcpy(dir[ndirs++], "/usr/lib/X11/fonts/75dpi");
- XSetFontPath(disp, dir, ndirs);
- font=XLoadQueryFont(disp, fontname);
- XSetFont(disp, wingc, font->fid);
- XFreeFontPath(dir);
- }
-
- int wincursor(cursor)
- char *cursor;
- {
- wincurs=XCreateFontCursor(disp, XC_gumby);
- XDefineCursor(disp, win, wincurs);
- }
-
- int winevents(event)
- long event;
- {
- XSelectInput(disp, win, event);
- }
-
-
- int winprint(x, y, string)
- int x, y;
- char *string;
- {
- XDrawString(disp, win, wingc, x, y, string, strlen(string));
- XFlush(disp);
- }
-
- int winwrapprint(x, y, string, inc)
- int x, y;
- char *string;
- int inc;
- {
- int count=0;
- if (XTextWidth(font, string, strlen(string)) > winw)
- {
- for (count=strlen(string); XTextWidth(font, string, count) > winw; count--);
- XDrawString(disp, win, wingc, x, y, string, count);
- scrollup(inc);
- XDrawString(disp, win, wingc, x, y, &string[count+1], strlen(&string[count+1]));
- XFlush(disp);
- return(1);
- }
- XDrawString(disp, win, wingc, x, y, string, strlen(string));
- XFlush(disp);
- return(0);
- }
-
- int showwin()
- {
- XMapRaised(disp, win);
- XFlush(disp);
- XNextEvent(disp, &thebigevent);
- }
-
- int clearwin()
- {
- XClearWindow(disp, win);
- }
-
- int scrollup(lineheight)
- int lineheight;
- {
- int x, y, height, width;
-
- x=0;
- y=lineheight;
- width=winw;
- height=winh-lineheight;
- XCopyArea(disp, win, win, wingc, x, y, width, height, 0, 0);
- XClearArea(disp, win, 0, height, width, lineheight, False);
- XFlush(disp);
- }
-
- int windeath()
- {
- XFreeFont(disp, font);
- XFreeGC(disp, wingc);
- XDestroyWindow(disp, win);
- win = 0;
- XCloseDisplay(disp);
- }
-