Solaris X Window System 開発ガイド

プログラム例

以下のプログラムは、透明オーバーレイの単純な例を示しています。このプログラムは透明オーバーレイウィンドウを作成し、ウィンドウのボーダを白で描画し、テキスト文字列を白で表示し、白で塗りつぶされた矩形を描画します。ペイント型はデフォルトで不透明に描画され、ウィンドウの背景はデフォルトで透明に描画されます。次の Makefile を使用して、このプログラムをコンパイルし、リンクしてください。

simple:

simple.c  	cc -I../ -I/usr/openwin/include -o simple simple.c ¥ 

	-L/usr/openwin/lib -lX11 -lXext

例 6-1 Transparent Overlay Example Program

#include <stdio.h>

 #include <X11/Xlib.h>  #include "X11/Xmd.h"  #include

<X11/extensions/transovl.h>  #include

<X11/extensions/transovlstr.h> Display 						*display;  Window

						window;  XSetWindowAttributes 						attribs; GC 						gc;  XGCValues

						gcvalues; main()  {   display = XOpenDisplay("");  

attribs.override_redirect = True;   attribs.border_pixel = WhitePixel(display,

0); window = XSolarisOvlCreateWindow(display,  				DefaultRootWindow(display),

 				100, 100, 500, 500, 10,  				CopyFromParent, InputOutput,CopyFromParent, 

				CWBorderPixel | CWOverrideRedirect, &attribs); gcvalues.font =

XLoadFont(display, "fixed");   gcvalues.foreground =

WhitePixel(display, 0); gc = XCreateGC(display, window, GCFont | GCForeground,

&gcvalues);   XMapWindow(display, window); XDrawString(display, window,

gc, 50, 50, "This is a test", 14);   XFillRectangle(display,

window, gc, 70, 70, 100, 100); XFlush(display); while   (1);}