ubuntu で Xlib プログラミングをやってみる。
コンパイル ・Xlib.h は/usr/include/X11 ディレクトリにある。 ・コンパイルする際のコマンドは以下のようになる。 gcc -I/usr/include/X11 -L/usr/lib/X11 -o exefile main.c -lX11 ここで exefile は出力ファイル、main.c はソースファイル。
専用変数 変数 | 説明 | Display | Xサーバを識別するための変数型 | Window | ウィンドウを識別するための型変数 | XEvent | イベントを読み込むために必要な変数型 | Colormap | カラーマップを表す変数型 | XColor | RGB 値やピクセル値が格納される変数型 | GC | グラフィックスコンテキスト。描画に必要な属性情報が格納される変数 |
関数 関数 | 説明 | Display* XOpenDisplay ( char* display_name ) | Xサーバと接続する | Window DefaultRootWindow( Display* ) | ルートウィンドウを取得する | int DefaultScreen( Display* ) | スクリーンを取得する | unsigned long WhitePixel( Display*, int screen ) | 白色のピクセル値を取得する | unsigned long BlackPixel( Displa* , int screen ) | 黒色のピクセル値を取得する | Window XCreateSimpleWindow(...) | ウィンドウを作る | XSelectInput( Display*, Window, long event_mask ) | イベントを通知する。event_mask はKeyPressMask など | XMapWindow( Display*, Window ) | 画面に表示するために、ウィンドウをマップする | XMoveWindow( Display*, Window, int, int ) | ウィンドウを移動する | XFlush( Display* ) | 明示的にリクエストバッファをフラッシュする | XNextEvent( Display*, *XEvent ) | Xサーバからイベントを読み込む | XDestroyWindow( Display*, Window ) | ウィンドウを破棄する | XCloseDisplay( Display* ) | Xサーバとの接続を切断する | Colormap DefaultColormap( Display*, int screen) | カラーマップのIDを取得する | XAllocNamedColor( ... ) | 色名を指定して対応するピクセル値を取得する | int Xpending( Display* ) | イベントキューから取り出されていないイベントの数を取得する |
描画関数 関数 | 説明 | GC XCreateGC( Display*, Drawable, unsigned long, XGCValues* ) | GC を生成する | FreeGC( Display*, GC ) | GC を解放する | XDrawPoint( Display*, Drawable, GC, int x, int y) | ピクセルに描画する | XDrawPoints( Display*, Drawable, GC, XPoint*, int npoints, int mode ) | ピクセルに描画する | XDrawLine( Display*, Drawable, GC, int x1, int y1, int x2, int y2 ) | 線を引く | XDrawLines( Display*, Drfawable, GC, XPoint*, int npoints, int mode) | 線を引く | XDrawSegments(Display*, Drawable, GC, XSegments*, int nsegments) | 線を引く | XDrawRectangle(... , int x, int y, unsigned int width, unsigned int height) | 長方形を描画する | XFillRectangle( 同上 ) | 塗りつぶした長方形を描画する | XDrawRectangles( ... , XRectangle*, int nrects ) | 長方形を描画する | XFillRectangles( 同上 ) | 塗りつぶした長方形を描画する | XDrawArc( ... , int x, int y, unsigned int width, unsigned int height, int angle1, int angle 2 ) | 円弧を描画する。角度の単位は1/64 | XFillArc( 同上 ) | 円弧を塗りつぶす | XDrawArcs( ... , XArc arcs, int narcs ) | 円弧を描画する | XFillArcs( 同上 ) | 円弧を塗りつぶす | XFillPolygon( ... , XPoint* points, int npoints, int shape, int mode ) | ポリゴンの塗りつぶし | XDrawString( ... , int x, int y, char*, string, int length ) | 文字列を描画する | XDrawImageString( 同上 ) | 文字列を描画する。文字の背景も描画する | Pixmap XCreatePixmap( Display*, Drawable, unsigned int width, unsigned int height, unsigned int depth ) | ピクスマップを生成する | XFreePixmap( Display*, Pixmap ) | ピクスマップを解放する | XClearArea( Display*, Window, int x, int y, unsigned int width, unsigned int height, Book exposures ) | ウィンドウ内の長方形領域をクリアする | XClearWindow( Display*, Window ) | ウィンドウ全体をクリアする | XCopyArea( Display*, Drawable src, Drawable dest, GC, int src_x, int src_y, unsigned int width, unsigned int height, int dest_x, int dest_y ) | drawable の内容をコピーする | XCopyPlane( 同上 , unsigned long plane ) | 深さの異なる drawable 間でコピーする |
参考リンク |