 |
The ButtonFace Library eases the process
of creating pictural push buttons as well as pictural labels and message
dialogs. Pictural push buttons are like ordinary push buttons with the
exception that they show a tiny picture rather than text. The picture on
the button may change accordingly to the its actual state (normal, armed
or insensitive).
For a quick start you can just use the predefined pictures included
in the ButtonFace Library:
If you need buttons for other purposes than the provided ones cover, you
can craft your own pixmaps with one of the numerous picture editors (e.g.
pixmap or xpaint) and then use it with a push button. The documentation
accompanying the ButtonFace Library explains this in detail.
To create such a pictural push button within an application all you
need to do is to call one of the new convenience functions:
-
XmCreateStandardPushButton(Parent, Name, FaceType, Args, ArgCount)
-
XmCreateStandardPushButtonGadget(...)
-
XmCreatePixmapPushButton(Parent, Name, Normal, Armed, Insensitive, Args,
ArgCount)
-
XmCreatePixmapPushButtonGadget(...)
The same applies to pictural label widgets.
-
XmCreateStandardLabel(Parent, Name, FaceType, Args, ArgCount)
-
XmCreateStandardLabelGadget(...)
-
XmCreatePixmapLabel(Parent, Name, Normal, Insensitive, Args, ArgCount)
-
XmCreatePixmapLabelGadget(...)
In every case the pixmaps' background will be set to the button's background
so you don't have to worry about this. If a user wants to change the background
color he can do it if he wants and he will always get a sufficient result.
As a special feature the ButtonFace Library maintains a pixmap cache
for all buttons and labels. If you create two push button widgets using
the same pixmaps and background color only one set of pixmaps get created.
So this reduces the resource load on beside of the X server.
To provide a
consistent look-and-feel the ButtonFace Library also features new
message dialogs which behave much like the ones known from Motif. This
time the new dialogs use pictural push buttons and display much nicer icons
to indicate the sort of message (warning, error,...). In addition you may
also create the message dialog and get the user's answer with just one
line of code with the help of a new convenience function. Here is just
one example. The following line of code creates a message dialog, waits
for the user's response and finaly returns it:
answer = XmMessageBox(w, "Quit...",
"Do you really want to quit?",
MB_YESNO | MB_DEFAULT2, NULL);
This will create the message dialog as shown to the right.
Moreover the ButtonFace Library eases the process of localizing
an application: you can specify the push button's pixmaps in resource files.
This enables you to switch to another language with no pain.
But what do I need to use the ButtonFace Library?
-
Motif at least. This should be Motif 1.1 or 1.2 but since the ButtonFace
Library only uses documented calls it should also work seamless with
the upcomming Motif 2.0 (if it ever comes...)
-
The Xpm package ready installed. If you just don't have one ready at hand,
here is it! (Beware: this
is a link to the ftp server of the X Organisation in the USA.)
-
An ANSI C compliant compiler: gcc for example.
-
(some) artistic skills will help very much when crafting the pixmaps to
be used with your own pictural push buttons.
Here
you can take a look at the online documentation (contained in the file
ButtonFaceLib.doc).
And
here
you can get the source of the ButtonFace Library.
As
a second source outside Europe you can also get the package from ftp.x.org.
If
you rather want to download the full documentation in postscript
format you may want to follow this link.
Back to the Projects Page
Contents: Harald
Albrecht (albrecht@igpm.rwth-aachen.de)
Layout: Harald Albrecht
Last Change: 97/08/10 (ab) |