The window would look more interesting with a textured background. We decide that a 4x4 pixmap with two lines between opposite corners forming an X would make an interesting background texture.
| ?- create_pixmap(Pix, [size(4,4)]), draw_segments(Pix, [segment(0,0,3,3), segment(0,3,3,0)]), win(Window), put_window_attributes(Window, [background(Pix)]). Pix = pixmap(2383840), Window = window(2376568)
The first line is as simple as it looks: it creates a 4x4 pixel pixmap. The second line draws the X. Note that coordinates are given with (0,0) as the northwest corner pixel, so (3,3) is the southeast corner. Then the third line installs the new pixmap as the background pattern.
You might be wondering why the window didn't change. The reason is simple: the background is used to fill parts of the window that have been cleared. The easiest way to get the new background displayed is to use your window manager to either iconify and then uniconify the window, or to push it behind another window and then pull it back to the front. You could also do it by calling
| ?- win(Window), clear_window(Window). Window = window(2376568)
Again we need to refresh the window:
| ?- win(Window), draw_string(Window, 2, 19, 'Hello, world!!'). Window = window(2376568)
That doesn't look terribly interesting. Try drawing the string in white instead of black.
| ?- win(Window), get_screen_attributes([white_pixel(Pix)]), put_graphics_attributes(Window, [foreground(Pix)]), draw_string(Window, 2, 19, 'Hello, world!!'). Window = window(2376568), Pix = 0
The second line determines the pixel value for white on our screen. X
does not establish a standard pixel value for black and white, so you
must determine it explicitly. In fact, X doesn't even guarantee that
white_pixel/1 attributes will yield
black and white, but they are logical black and white.
The third line sets the foreground color, the color to draw in, to
white. Finally, we draw our message. The default
drawing color in ProXL is
black_pixel; this is why you didn't have to
specify it earlier. But now that we've specified white, all drawing
will be done in white until we change it again.