📄 452-455.html
字号:
<HTML>
<HEAD>
<TITLE>Linux Configuration and Installation:Programming in Linux</TITLE>
<META NAME="ROBOTS" CONTENT="NOINDEX, NOFOLLOW">
<SCRIPT>
<!--
function displayWindow(url, width, height) {
var Win = window.open(url,"displayWindow",'width=' + width +
',height=' + height + ',resizable=1,scrollbars=yes');
}
//-->
</SCRIPT>
</HEAD>
-->
<!--ISBN=1558285660//-->
<!--TITLE=Linux Configuration and Installation//-->
<!--AUTHOR=Patrick Volkerding//-->
<!--AUTHOR=Kevin Reichard//-->
<!--AUTHOR=Eric Foster//-->
<!--PUBLISHER=IDG Books Worldwide, Inc.//-->
<!--IMPRINT=M & T Books//-->
<!--CHAPTER=10//-->
<!--PAGES=452-455//-->
<!--UNASSIGNED1//-->
<!--UNASSIGNED2//-->
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="449-452.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="455-457.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
<P><BR></P>
<H4 ALIGN="LEFT"><A NAME="Heading10"></A><FONT COLOR="#000077">Using LessTif</FONT></H4>
<P>Everyone wants to use the Motif libraries until they find out that they’re an added-cost feature for Linux. Unfortunately, the Motif library is commercial software, which means you have to pay extra to get either the Motif library source code or a set of binaries for your platforms. Add to this hassle the frustrating nature of the complex Motif license for software developers, where it’s almost impossible to tell if you can actually distribute your applications, and you’re ready to scream.
</P>
<P>However, we’ve run across a great programming effort called LessTif, which is gaining more Motif functionality each day. While it’s not in completed form, we thought you might want to take a look at it, so we included it in the second CD-ROM’ s <B>programming/lesstif</B> directory.</P>
<P>LessTif is a workalike clone of the Motif libraries. That is, it is a set of programming libraries that look and act like the Motif libraries (Xm and Mrm). Under the hood, the code is entirely different. From a programmer’s perspective, though, LessTif has the same API as the Motif libraries and supports a number of Motif widgets, supporting more Motif widgets with each release. It uses public header files with the same name as their Motif counterparts.</P>
<P>For your programs, LessTif should allow your Motif programs to be recompiled under LessTif with no source code changes—at least in theory. We’ve had to make a few changes to get around the fact that LessTif is incomplete as we write this. Luckily, because LessTif is undergoing what looks like constant development, the problems we face today should gradually go away.</P>
<P>Distributed under the GNU license, you can use LessTif in free applications. You’ll probably want to check the GNU licenses before using LessTif for commercial software.</P>
<P><FONT SIZE="+1"><B>Installing LessTif</B></FONT></P>
<P>LessTif comes in source code format. All you need to do is run <B>xmkmf</B> and then <B>make</B> in the standard way to build X programs:</P>
<!-- CODE SNIP //-->
<PRE>
xmkmf
make
</PRE>
<!-- END CODE SNIP //-->
<P>If you run into any problems, there’s a file named <B>INSTALL</B> with the distribution.</P>
<P><FONT SIZE="+1"><B>Problems with LessTif</B></FONT></P>
<P>The developers of LessTif clearly let you know that LessTif is not a complete Motif clone by any means. This is only natural at this early stage in LessTif’s development. Even so, there’s quite a few things present in LessTif that will appeal to Motif programmers.
</P>
<P>LessTif, as incomplete free software, is not without its problems, as you’d expect. But each version gets better and better.</P>
<P><FONT SIZE="+1"><B>Editres Support</B></FONT></P>
<P><B>Editres</B> is an X application and protocol that allows programs compiled with the X Toolkit (Xt) Intrinsics library to export information on widget attributes to an outside program, namely, <B>editres</B> itself.</P>
<P>With <B>editres</B>, for example, you can change the font, colors, and text displayed with any widget, presuming an application supports the <B>editres</B> protocol. To do this, an application must set up an event-handling function and pass the special <B>editres</B> library call, <I>_XEditResCheckMessages</I>, as the handler. For example, the following code sets this up for a Motif application:</P>
<!-- CODE //-->
<PRE>
#include <X11/Xmu/Editres.h>
Widget toplevel;
void _XEditResCheckMessages();
/* ... */
XtAddEventHandler(toplevel,
(EventMask) 0,
True,
_XEditResCheckMessages,
NULL);
</PRE>
<!-- END CODE //-->
<P>With this set up, your Motif application will properly respond to the <B>editres</B> protocol.</P>
<P>The reason we mention this is that LessTif calls <I>XtAddEventHandler</I> automatically from the <I>Vendor</I> shell widget. Thus, all LessTif programs will support <B>editres</B>. But there’s a slight problem with this. <I>_XEditResCheckMessages</I> resides in the X miscellaneous utilities library (<B>libXmu.a</B>) and you must be sure to link this in.</P>
<P>To link with LessTif, you need to link in at least the following libraries, as shown in the following command:</P>
<!-- CODE SNIP //-->
<PRE>
cc -o foo foo.c -lXm -lXmu -lXt -lX11
</PRE>
<!-- END CODE SNIP //-->
<P>We mention this because you’re probably not linking in the Xmu library now. It’s nice that LessTif supports <B>editres</B> from the start, but you need to remember to link in the Xmu library.</P>
<P>All in all, for free software, it’s hard to complain about LessTif. LessTif isn’t ready for prime-time usage yet, but it has made great strides in recent months. You’ll probably want to track its progress and conduct some tests before using it. Better yet, you may want to volunteer to help the effort.</P>
<P><FONT SIZE="+1"><B>Finding out More about LessTif</B></FONT></P>
<P>You can look up the LessTif home page on the World Wide Web by accessing <A HREF="http://www.hungry.com/products/lesstif/">http://www.hungry.com/products/lesstif/</A>. You can also use FTP to acquire the latest version of LessTif, at machine <A HREF="ftp.hungry.com">ftp.hungry.com</A> in the <B>pub/hungry/lesstif</B> directory.</P><P><BR></P>
<CENTER>
<TABLE BORDER>
<TR>
<TD><A HREF="449-452.html">Previous</A></TD>
<TD><A HREF="../ewtoc.html">Table of Contents</A></TD>
<TD><A HREF="455-457.html">Next</A></TD>
</TR>
</TABLE>
</CENTER>
</td>
</tr>
</table>
<!-- begin footer information -->
</body></html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -