Introduction to X
- Features of X
- Industry standard
- Device Independent
- Motif : A high level toolkit
- Programs based on Motif:
- Xlib : lowest level
- Xt Intrinsics : hides details of Xlib
- Motif : builds on Xt and provides visual components.
The Client-Server Model
- The server is a program that controls all I/O.
- Creates and manipulates windows
- produces text and graphics
- handles input
- The client is a program that uses the I/O services of a server
The Window Hierarchy
- The window tree
- root window = entire screen
- every window has a parent window except for the root window
- windows can have child windows
- The X coordinate system
- upper left corner is (0, 0)
- x increases to the right and y increases downwards
Events
- The server communicates with clients by sending "events" to the client application
- X programs(client applications) are "event driven"
- they wait for an event
- they respond to the event
- then they wait for another event
Xt Intrinsics
- Xlib is low level
- Many lines of code required to perform common functions
- Xt is a toolkit for building UI toolkits
- defines an object-oriented architecture for UI components or "widgets" such as buttons, scrollbars and menus
- independent of any particular look or feel
Widgets
- A widget is a window + a data structure
- Two fundamental types of widgets
- Display widgets : for user info/ input
- Container widgets : for grouping other widgets together on the screen
- It implies a widget hierarchy or a widget tree
- The root of every widget tree is a shell widget
Xt Widget Classes
- Core
- Superclass for all other widget classes
- Composite
- contains and manages other child widgets
- Constraint
- subclass of the Composite class
- manage children using constraint information (size, position)
Xt Widget Class (contd.)
- Shell
- subclass of the composite class
- can have only one child
- three subclasses
- ApplicationShell
- provide the main windowfor an application
- OverrideShell
- no "decorations" and good for popup menus
- TransientShell
- displayed for short time (dialog boxes)
Event Dispatching
- Event Handlers
- Actions
- Callbacks
- functions to be called when some widget-specific condition occurs which is usually related to an event
Xt Resources
- Xt resources
- are customizable parameters supported by widgets
- control most aspects of widgets appearance and behavior
- it is possible to
- "hard code" resources
- retrieve them from a database allowing them to be specified outside the application i.e. user can change them without recompiling
The Core widget Class
- All widgets inherit the resources, callbacks and other behavior from Core
- rarely used directly
Core widget class Resources
- XmNx, XmNy
- XmNwidth, XmNheight
- XmNborderWidth
- XmNsensitive
- XmNancestorSensitive
- XmNcolormap
- XmNbackground
- XmNbackgroundPixmap
- XmNborderColor
- XmNborderPixmap
- XmNmappedWhenManaged
Primitive Motif Widgets
- XmPrimitive
- subclass of Core
- they do not support children
- also called "display" widget, since they usually display information
- Behaviors
- Top and bottom shadows
- Keyboard traversal of windows
- support for highlighting
XmPrimitive Class Resources
- XmNforeground
- XmNhighlightOnEnter
- XmNhighlightThickness
- XmNhighlightColor
- XmNshadowThickness
- XmNtopShadowColor, XmNbottomShadowColor
- XmNuserData
XmLabel Widget Class
- Provides support for XmPushButton, XmToggleButton, XmDrawnButton, XmCascadeButton
- used to display text or pixmap in a window
XmLabel Class Resources
- XmNalignment
- XmNlabelType
- XmNmarginHeight, XmNmarginWidth
- XmNmarginLeft, XmNmarginRight, XmNmarginTop, XmNmarginBottom
- XmNfontList
- XmNlabelPixmap
- XmNlabelString
- XmNinsensitivePixmap
- XmNrecomputeSize
XmPushButton Widget Class
- Very common
- characteristic Motif 3D look
- appear to protrude until pushed in
XmPushButton Class
- XmPushButton Class Resources
- XmNarmColor
- XmNarmPixmap
- XmNfillOnArm
- Callbacks
- XmNarmCallback
- XmNactivateCallback
- XmNdisarmCallback
XmSeparator Widget Class
- Used to separate areas of a window
- they can have several apperances
- no additional callbacks
- they support several resources
- XmNorientation
- XmHORIZONTAL and XmVERTICAL
- XmNseparatorType
- XmNO_LINE, XmSINGLE_LINE, XmDOUBLE_LINE, XmSINGLE_DASHED_LINE, XmDOUBLE_DASHED_LINE, XmSHADOW_ETCHED_OUT, XmSHADOW_ETCHED_IN, XmSHADOW_ETCHED_OUT_DASH, XmSHADOW_ETCHED_IN_DASH
Manager Widgets
- Used to combine child widgets into large applications
- They determine positions of the children
- must be subclasses of Xt's Composite class
- the Composite class provides support for handling multiple children
- the Constraint class supports position and size for each child
XmManager Widget Class
- Provides support for all Motif widgets that contain or manage other widgets
- inherit behavior from Core, Composite and Constraint
- is an abstract class and is never used directly
- adds support for
- top and bottom shadows
- input focus and keyboard navigation
XmManager Class Resources
- XmNforeground
- XmNshadowThickness
- XmNtopShadowColor, XmNbottomShadowColor
- XmNuserData
XmBulletinBoard Widget Class
- Simple layout strategy
- child is positioned by setting XmNx, XmNy resources
- don't usually move or resize children
- provides services and resources for subclasses
XmBulletinBoard Class Resources
- XmNshadowType
- XmSHADOW_IN, XmSHADOW_OUT, XmSHADOW_ETCHED_IN, XmSHADOW_ETCHED_OUT
- XmNshadowThickness
- XmNallowOverlap
- XmNresizePolicy
- XmRESIZE_NONE, XmRESIZE_ANY, XmRESIZE_GROW
- XmNbuttonFontList
- XmNlabelFontList
- XmNtextFontList
- XmNtextTranslations
- XmNfocusCallback
XmForm Widget Class
- Position their children based on values of constraint resources with each child
- resources specify child's position
- child can have "attachments" for their top, bottom, left, right sides
- supports dynamically resizable layouts
- flexible and widely used, but tricky to use
XmForm Class Resources
- XmNrubberPositioning
- XmNresizable
- XmNfractionBase
XmForm Class Constraint Resources
- XmNtopAttachment, XmNbottomAttachment, XmNleftAttachment, XmNrightAttachment
- XmATTACH_NONE, XmATTACH_FORM, XmATTACH_WIDGET, XmATTACH_OPPOSITE_WIDGET, XmATTACH_POSITION, XmATTACH_SELF
- XmNtopWidget, XmNbottomWidget, XmNleftWidget, XmNrightWidget
- XmNtopPosition, XmNbottomPosition, XmNleftPosition, XmNrightPosition
- XmNtopOffset, XmNbottomOffset, XmNleftOffset, XmNrightOffset
XmForm Attachment Error
- "Circular" attachments
- E.g. Do not attach the right side of widget A to the left side of widget B and the right side of widget B to the left side of widget A.
Shell Widget Class
- Abstract class of Composite
- Only supports one child
- Resources
- XmNallowShellResize
- XmNgeometry
- Callbacks
- XmNpopupCallback, XmNpopdownCallback
WmShell Widget Class
- Subclass of Shell class
- additional support for interacting with window manager
- Resources
- XmNbaseHeight, XmNbaseWidth
- XmNHeightInc, XmNwidthInc
- XmNinitialState
- XmNtitle
- XmNminWidth,XmNminHeight,XmNmaxWidth,XmNmaxHeight
- XmNiconPixmap
- XmNiconWindow