195 lines
7.8 KiB
HTML
195 lines
7.8 KiB
HTML
<!--startcut ==========================================================-->
|
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
|
|
<HTML>
|
|
<HEAD>
|
|
<title>Portable GUI C++ Libraries LG #30</title>
|
|
</HEAD>
|
|
<BODY BGCOLOR="#FFFFFF" TEXT="#000000" LINK="#0000FF" VLINK="#A000A0"
|
|
ALINK="#FF0000">
|
|
<!--endcut ============================================================-->
|
|
|
|
<H4>
|
|
"Linux Gazette...<I>making Linux just a little more fun!</I>"
|
|
</H4>
|
|
|
|
<P> <HR> <P>
|
|
<!--===================================================================-->
|
|
|
|
<center>
|
|
<H1><font color="maroon">Portable GUI C++ Libraries</font></H1>
|
|
<H4>By <a href="mailto:starkey@rmi.net">Sean C. Starkey</a></H4>
|
|
</center>
|
|
<P> <HR> <P>
|
|
|
|
Most well-written, non-graphics C++ code is portable, but major
|
|
problems occur when one tries to write portable applications for
|
|
graphical user interfaces. On Linux, the X Window System is used as the major
|
|
graphical user interface. GUI code written on Linux will not work
|
|
on MS Windows. Even though we all know that Linux is the better of the two,
|
|
some Linux developers would like to also support MS Windows
|
|
with its large number of users.
|
|
<p>
|
|
With a portable GUI C++ library, source code developed under Linux and X
|
|
can be compiled for other platforms, including MS Windows. Quite
|
|
a few GUI C++ libraries are available at this time, including
|
|
MFC and OWL for MS Windows. Unfortunately, none of these libraries are
|
|
portable to both X and MS Windows.
|
|
<p>
|
|
Desirable features in a portable GUI library include the following:
|
|
<p>
|
|
<ul>
|
|
<li> Support for a large number of platforms
|
|
<li> Easy to use, with good documentation
|
|
<li> A good set of widgets (or
|
|
controls, in Microsoft-speak) to use in your interface
|
|
</ul>
|
|
Other desirable features which are not GUI related are portable network
|
|
functionality, file I/O capabilities and some good container classes.
|
|
<p>
|
|
What are some of the problems faced by a portable GUI library?
|
|
One is that GUI code on different platforms varies widely. To create
|
|
a new window, MS Windows uses a completely different command than X, even
|
|
though the code uses the same programming language in both. Another problem is
|
|
subtle changes in event handling. All GUI applications are event
|
|
driven, but the events are different on different platforms. The
|
|
portable GUI library must take all of these differences into
|
|
consideration and supply a common interface for all platforms.
|
|
<p>
|
|
I have reviewed three different GUI C++ libraries which support both
|
|
X and MS Windows. All are free of charge with no royalties.
|
|
The source code for these libraries is available on the web sites cited in
|
|
Resources.
|
|
<p>
|
|
Since these libraries are written in C++, you have all the
|
|
advantages of object-oriented design. To create a new window, you
|
|
derive your own window class from the main window class. After adding
|
|
the appropriate code to handle events in your window, it is
|
|
finished.
|
|
<p>
|
|
<h3>wxWindows</h3>
|
|
<p>
|
|
<b>wxWindows</b> is by far the most active of the libraries available.
|
|
wxWindows was originally developed by Julian Smart, but has received
|
|
contributions from many others. The version of wxWindows reviewed in
|
|
this article is 1.68B. Version 2.0, a major rewrite of the library, is
|
|
rumored to be available in ``the near future''.
|
|
<p>
|
|
<b>wxWindows</b> is a very modular project. The main version is
|
|
available on the web site. In addition to the main version, there are
|
|
also many subprojects. Some of these subprojects include additional
|
|
widgets, an Xlib library port, a Macintosh port and many others. These
|
|
subprojects are described on the wxWindows web site (see Resources).
|
|
<p>
|
|
Note that the main version of wxWindows requires the Motif
|
|
toolkit. Motif is not free; therefore, most Linux installations do
|
|
not include it. Lesstif, a popular Motif clone, compiles and
|
|
works with wxWindows. There is also a side project which uses only
|
|
standard Xlib libraries so that wxWindows does not need Motif.
|
|
<p>
|
|
<b>wxWindows</b> has many features. Figure 1 is a screen capture of
|
|
the sample program distributed with wxWindows running on a
|
|
Linux system. Notice all of the widgets available to the
|
|
programmer. More screen shots are available on the wxWindows web
|
|
site.
|
|
<p>
|
|
<center>
|
|
<img src="./gx/starkey/2630f1.gif">
|
|
</center>
|
|
<P>
|
|
<center><B>Figure 1</B> </center>
|
|
<p>
|
|
One of best features of wxWindows is the on-line documentation. The
|
|
documentation comes in HTML, LaTeX and MS Windows help format. There
|
|
is also a very active mailing list for wxWindows, where many questions
|
|
can be answered. Trying to learn all of these new classes can be
|
|
confusing, and wxWindows does a good job of describing them.
|
|
<p>
|
|
If you don't want to download all of the wxWindows source code,
|
|
a distribution on CD is available. See the web site for more details.
|
|
<p>
|
|
<h3>V</h3>
|
|
<p>
|
|
<b>V</b> is another freely available library, and was developed by Dr. Bruce
|
|
E. Wampler. [See ``V--A Free C++ GUI Framework for X'',
|
|
<i>Linux Journal</i>, December 1996.] It is able to compile on X and MS Windows.
|
|
It is a complete
|
|
library, but does not have all of the fancy controls that wxWindows
|
|
has. Although not as fancy, in my opinion, V's source code is better
|
|
written and easier to understand than wxWindows.
|
|
<p>
|
|
V does not require the Motif libraries to build and run. All V source
|
|
code uses pure Xlib library calls, so it should be able to compile on
|
|
any Linux system with no difficulty.
|
|
<p>
|
|
V has quite a few widgets available as well. Figure 2 is a screen shot
|
|
of an example program distributed with the library. This look
|
|
is consistent on all platforms.
|
|
<p>
|
|
<center>
|
|
<img src="./gx/starkey/2630f2.gif">
|
|
</center>
|
|
<P>
|
|
<center><B>Figure 2</B> </center>
|
|
<p>
|
|
<h3>YACL</h3>
|
|
<p>
|
|
Another library worth looking at is YACL (Yet
|
|
Another Class Library). The author, M. A. Sridhar, reports that YACL
|
|
can compile on X, MS Windows and OS/2. Unfortunately, it looks as if
|
|
progress on YACL has been nonexistent since late 1996. The current
|
|
version of YACL, 1.60, is close to complete with a good set of classes and
|
|
widgets.
|
|
<p>
|
|
<center>
|
|
<img src="./gx/starkey/2630f3.gif">
|
|
</center>
|
|
<P>
|
|
<center><B>Figure 3</B> </center>
|
|
<p>
|
|
Figure 3 shows a screen shot of an example program distributed with
|
|
the library. This example shows some of the graphics primitives
|
|
available with YACL. YACL also has all of your basic widgets,
|
|
such as buttons, menus, choices and radio buttons.
|
|
<p>
|
|
One of YACL's biggest drawbacks is a lack of documentation. There
|
|
is a book about YACL: <i>Building Portable C++
|
|
Applications with YACL</i>, Addison-Wesley, 1996. I would suspect this book has
|
|
more information than the documentation distributed with the
|
|
library.
|
|
<p>
|
|
If you would like more information on any of these libraries, please
|
|
see their web page listed in the Resources table.
|
|
<P>
|
|
<h3>Resources</h3>
|
|
<p>
|
|
<b>wxWindows</b>: http://web.online.co.uk/julian.smart/wxwin/
|
|
<p>
|
|
<b>V</b>: http://www.objectcentral.com/vgui/vgui.htm
|
|
<p>
|
|
<b>YACL</b>: http://www.cs.sc.edu/~sridhar/yacl/
|
|
<p>
|
|
<b>User Interface Software Tools</b>:
|
|
http://www.cs.cmu.edu/afs/cs/user/bam/www/toolnames.html<br>
|
|
A good page for some other GUI libraries that are not necessarily
|
|
free, in C++ or supportive of the X Window System.
|
|
|
|
<!--===================================================================-->
|
|
<P> <hr> <P>
|
|
<center><H5>Copyright © 1998, Sean C. Starkey <BR>
|
|
Published in Issue 30 of <i>Linux Gazette</i>, July 1998</H5></center>
|
|
|
|
<!--===================================================================-->
|
|
<P> <hr> <P>
|
|
<A HREF="./index.html"><IMG ALIGN=BOTTOM SRC="../gx/indexnew.gif"
|
|
ALT="[ TABLE OF CONTENTS ]"></A>
|
|
<A HREF="../index.html"><IMG ALIGN=BOTTOM SRC="../gx/homenew.gif"
|
|
ALT="[ FRONT PAGE ]"></A>
|
|
<A HREF="./ayers4.html"><IMG SRC="../gx/back2.gif"
|
|
ALT=" Back "></A>
|
|
<A HREF="./koscielny.html"><IMG SRC="../gx/fwd.gif" ALT=" Next "></A>
|
|
<P> <hr> <P>
|
|
<!--startcut ==========================================================-->
|
|
</BODY>
|
|
</HTML>
|
|
<!--endcut ============================================================-->
|