X ウインドウシステムは、大きく、複雑な毛玉である。 Gnome ライブラリは、複雑な要素を良いラッパーで覆い隠すことにより、 物事を簡単にしようと努める。 それでも、より良いアプリケーションを書くために覚えておくべきことが、 何点かある。
The X Window System is a big and complex hairball. The Gnome libraries try to make things easy by wrapping the hard stuff with nice wrappers. Still, there are a few things you should keep in mind in order to write better applications.
この章は、X でのプログラミングの経験が少ないプログラマに向けられたものである。 もしあなたが、グラフィックコンテキストや、ドロウアブルや、 ビジュアルがどんなものか知らないのなら、この章を読むべきである。 もしあなたがすでに X でどうやればいいか知っていれば、この章を飛ばし、 楽しいこと(例えば、GNOME アプリケーションを書く)に移ることができる。
This chapter is aimed at programmers with little experience on X programming. If you do not know what graphics contexts, drawables, and visuals are, you should definitely read this chapter. If you already know your way around the X way of doing things, you may skip this chapter and move on to the fun stuff (i.e. writing GNOME applications).
この章は、GNOME アプリケーションを書く時に覚えておかなければならない X の概念を理解する、速成コースとなるよう書かれていることを覚えておいてほしい。 これは Xlib のマニュアルの代わりではない。 あなたは絶対に Xlib プログラマーズマニュアルとリファレンスマニュアルに 手を出すべきである。
Please note that this chapter is intended to be a small crash course on the X concepts you will need to keep in mind while writing Gnome applications. It is not a replacement for an Xlib manual. You should definitely get your hands on the Xlib programmer's and reference manuals.
ドロウアブルはあなたがその上に描くことができるものである。 X には二つのタイプのドロウアブルがあり、一つは ウインドウ で、もう一つは ピックスマップ である。 ピックスマップは、あなたが見ることのできない、オフスクリーンな存在である。 あなたは、ウインドウがスクリーンにマップ(表示)されている時、 それを見ることができる。
Drawables are things which you can paint on. X has two types of drawables, windows and pixmaps. Pixmaps are off-screen entities which you cannot see. You can see a window when it is mapped (shown) on the screen.
ウィンドウはツリー構造状に入れ子にすることができる。 ルートウィンドウを除くすべてのウィンドウは親を一つ持ち、 また、子をどんな数でも持つことができる。 ピックスマップは入れ子にすることができないし、親を持たない。
Windows can be nested in a tree structure. All windows except the root window have a single parent, but all windows may have any number of children. Pixmaps cannot be nested and they don't have parents.
ウィンドウには、親の中でのポジションを決める x/y/幅/高さのプロパティがある。 ピックスマップには、幅と高さのプロパティしかない。
Windows have x/y/width/height properties that define their position within their parent. Pixmaps only have width and height properties.
ウィンドウとピックスマップには多くの他のプロパティがある。 しかし、とても大事なプロパティは、ドロウアブルの ビジュアルクラス であり、これを次に議論したい。
Windows and pixmaps have many other properties. However, a very important property is the visual class of the drawable, which is what we will discuss next.