Next: Graphics Contexts Up: Xlib and Motif Previous: Xlib and Motif

Xlib Basics

Xlib provides the interface between the X Protocol and the application program.

The sort of tasks Xlib concerns itself with are:

Xlib deals with much lower level objects than widgets. When you write or draw in Xlib reference may be made to the following:

Display
- This structure is used by nearly every Xlib function. It contains details about the server and its screens.
Drawable
- this is an identifier to a structure that can contain graphics (i.e. it can be drawn to). There two common types:
Window
- A part of the screen.
Pixmap
- An off-screen store of graphical data.

Screen
- Information about a single screen of a display.
Graphics Context (GC)
- When we draw we need to specify things like line width, line style (e.g solid or dashed), colour, shading or filling patterns em etc.. In Xlib we pass such information to a drawing routine via a GC structure. This must be created (and values set) before the routine uses th GC. More than one GC can be used.
Depth
- the number of bits per pixel used to display data.
Visual
- This structure determines how a display handles screen output such as colour and depends on the number of bits per pixel.

If we are programming in Xlib alone we would have to create window ond open displays ourselves - see Xlib Handouts for details.

However if we are using a higher level toolkit such a Motif then we need to obtain this information from an appropriate widget.

Functions like XtDisplay(), XtWindow(), XtScreen() etc. can be used to obtain the ID of a given Xlib structure from a widget.

Default Values are typically of these structures are also typically used. Functions like DefaultDepthofScreen(), RootWindowofScreen() are examples.

We will look at the mechanics of this when we study Motif DrawingAreas in the next section.

Sometimes you may have to create an Xlib structure from scratch. The GC is most frequently created structure that concerns us.

Functions like XCreateGC() achieve this.



Next: Graphics Contexts Up: Xlib and Motif Previous: Xlib and Motif


Dave.Marshall@cm.cf.ac.uk
Tue May 24 16:52:56 BST 1994