コンテンツにスキップ

Xlib

出典: フリー百科事典『ウィキペディア(Wikipedia)』

XlibX Window SystemCX使XXlib使Xlib使
Xlib使

Intrinsics (Xt)

Athena widget set (Xaw)

Motif

GTK

QtX11 

Tk

Xlib1985Unix (OS) GUI使XCBXlib

[]


XlibDisplay[1]

XlibDisplayUnixOSDisplayConnectionNumberXlibDisplayXlib Xlib

使

WindowsPixmapFontColormap32Xlib使

使121使Display

[]


Xliboutput bufferoutputoutput bufferoutput bufferXSyncXFlush

Xlib調XXlib使Xliboutput buffer



Expose

[]


Xlib

(一)XOpenDisplay, XCloseDisplay, ...

(二)XCreateWindow, XCreateGC,...XGetWindowProperty, ...

(三)XNextEvent, XPeekEvent, ...XLookupKeysym, XParseGeometry, XSetRegion, XCreateImage, XSaveContext, ...

[]



 /*
   ウィンドウに四角形を描画する簡単なXlibアプリケーション
 */

 #include <X11/Xlib.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>

 int main() {
   Display *d;
   int s;
   Window w;
   XEvent e;

                        /* サーバとのコネクションを開く */
   d=XOpenDisplay(NULL);
   if(d==NULL) {
     printf("Cannot open display\n");
     exit(1);
   }
   s=DefaultScreen(d);

                        /* ウィンドウ生成 */
   w=XCreateSimpleWindow(d, RootWindow(d, s), 10, 10, 100, 100, 1,
                         BlackPixel(d, s), WhitePixel(d, s));

                        /* 受け付けるイベントの種類を選択 */
   XSelectInput(d, w, ExposureMask | KeyPressMask);

                        /* ウィンドウを可視化 */
   XMapWindow(d, w);

                        /* イベントループ */
   while(1) {
     XNextEvent(d, &e);
                        /* ウィンドウの描画と再描画 */
     if(e.type==Expose) {
       XFillRectangle(d, w, DefaultGC(d, s), 20, 20, 10, 10);
       XDrawString(d, w, DefaultGC(d, s), 50, 50, "Hello, World!",strlen("Hello, World!"));
     }
                        /* キー押下で終了 */
     if(e.type==KeyPress)
       break;
   }

                        /* サーバとのコネクションを閉じる */
   XCloseDisplay(d);

   return 0;
 }

XOpenDisplayXCreateSimpleWindowXMapWindow

XFillRectangleExpose

XSelectInputexposeXNextEventoutput buffer

[]


XlibXlib使2

Intrinsics (Xt) XtXtXawMotif

Xlib使Xt使GTKQtX11FLTKX11

使Expose

XlibXCBX11XCB使Xlib

脚注[編集]

  1. ^ Display Structure on freedesktop CVS”. Tip search for: typedef struct _XDisplay Display. 2008年5月8日閲覧。

関連項目[編集]

外部リンク[編集]