Path: utzoo!mnetor!uunet!lll-winken!lll-lcc!rutgers!ucla-cs!zen!ucbvax!hplabs!hp-pcd!hpcvlo!julie From: julie@hpcvlo.HP.COM (Julie Skeen) Newsgroups: comp.windows.x Subject: Re: Xr11 Example Programs (fixes) Message-ID: <3940060@hpcvlo.HP.COM> Date: 28 Dec 87 22:20:11 GMT References: <3940058@hpcvlo.HP.COM> Organization: Hewlett-Packard Co., Corvallis, OR, USA Lines: 112 /* * add a Title Bar to Hello World */ #include #include /* * fill a structure to define a Title Bar */ xrTitleBarInfo titleBarInfo = { 0, /* windowId */ {0,0,0,0}, /* editor rectangle */ XrVISIBLE | XrSENSITIVE, /* editor state */ -1, -1, /* editor colors - use defaults */ NULL, /* editor font - use defaults */ "Hello World", /* Title name */ NULL, /* gadget1 - unused */ NULL, /* gadget2 - unused */ }; xrWindowData windowData; main() { Display *display; int screen; Window windowId; XSetWindowAttributes wAttribs; /* Open the display specified by the environment variable DISPLAY */ if ((display=XOpenDisplay (0)) == NULL) { printf ("Cannot open display: %s\n", getenv ("DISPLAY")); exit (1); } screen = DefaultScreen (display); /* 1. Initialize Xrlib */ if (XrInit (display, screen, NULL) == FALSE) { printf ("Could not initialize Xrlib\n"); exit (1); } /* Create a window and put it on the display */ windowId = XCreateSimpleWindow (display, RootWindow(display, screen), 50, 50, 400, 200, 3, BlackPixel(display, screen), WhitePixel(display, screen)); wAttribs.override_redirect = TRUE; XChangeWindowAttributes (display, windowId, CWOverrideRedirect, &wAttribs); XMapWindow (display, windowId); /* 2. Register this window with Xrlib functionality */ XrSetRect (&windowData.windowRect, 50, 50, 400, 200); windowData.foreTile = BlackPixmap; windowData.backTile = WhitePixmap; XrInput (windowId, MSG_ADDWINDOW, &windowData); /* 3. Draw the Title Bar */ titleBarInfo.editorWindowId = windowId; XrTitleBar (NULL, MSG_NEW, &titleBarInfo); /* write the hello world string into the window */ XSetForeground (display, xrEditorGC1, BlackPixel(display, screen)); XDrawString (display, windowId, xrEditorGC1, 100, 80, "Hello World", 11); /* Send all of those instructions to the X window server to process */ XFlush (display); /* Sleep, close display, and exit */ sleep (5); XCloseDisplay (display); }