📄 ch33.htm
字号:
<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>
-->
<UL>
<LI><A HREF="#Heading1">- 33 -</A>
<UL>
<LI><A HREF="#Heading2">Interviews</A>
<UL>
<LI><A HREF="#Heading3">What Is the Interviews System?</A>
<LI><A HREF="#Heading4">How to Get and Install Interviews</A>
<LI><A HREF="#Heading5">TIP</A>
<LI><A HREF="#Heading6">Sample Applications</A>
<UL>
<LI><A HREF="#Heading7">FIGURE 33.1.</A>
<LI><A HREF="#Heading8">FIGURE 33.2.</A>
</UL>
<LI><A HREF="#Heading9">Listing 33.1. The</A>
<LI><A HREF="#Heading10">binary files for Interviews.</A>
<LI><A HREF="#Heading11">TIP</A>
<LI><A HREF="#Heading12">idraw</A>
<UL>
<LI><A HREF="#Heading13">FIGURE 33.3.</A>
</UL>
<LI><A HREF="#Heading14">TIP</A>
<UL>
<LI><A HREF="#Heading15">idraws Pull-Down Menus</A>
</UL>
<LI><A HREF="#Heading16">Changes to Xdefaults</A>
<LI><A HREF="#Heading17">ibuild</A>
<UL>
<LI><A HREF="#Heading18">FIGURE 33.4.</A>
</UL>
<LI><A HREF="#Heading19">TIP</A>
<LI><A HREF="#Heading20">TIP</A>
<LI><A HREF="#Heading21">TIP</A>
<LI><A HREF="#Heading22">NOTE</A>
<LI><A HREF="#Heading23">NOTE</A>
<LI><A HREF="#Heading24">NOTE</A>
<LI><A HREF="#Heading25">CAUTION</A>
<UL>
<LI><A HREF="#Heading26">ibuilds Pull-Down Menus</A>
<LI><A HREF="#Heading27">Generating Source Files</A>
</UL>
<LI><A HREF="#Heading28">NOTE</A>
<UL>
<LI><A HREF="#Heading29">Subclasses</A>
</UL>
<LI><A HREF="#Heading30">Code Generation</A>
<UL>
<LI><A HREF="#Heading31">Additional Resources in Xdefaults</A>
</UL>
<LI><A HREF="#Heading32">Building an Application with ibuild</A>
<UL>
<LI><A HREF="#Heading33">FIGURE 33.5.</A>
<LI><A HREF="#Heading34">FIGURE 33.6.</A>
<LI><A HREF="#Heading35">FIGURE 33.7.</A>
</UL>
<LI><A HREF="#Heading36">NOTE</A>
<UL>
<LI><A HREF="#Heading37">FIGURE 33.8.</A>
</UL>
<LI><A HREF="#Heading38">NOTE</A>
<LI><A HREF="#Heading39">CAUTION</A>
<LI><A HREF="#Heading40">CAUTION</A>
<UL>
<LI><A HREF="#Heading41">Adding Interactors</A>
<UL>
<LI><A HREF="#Heading42">FIGURE 33.9.</A>
<LI><A HREF="#Heading43">FIGURE 33.10.</A>
<LI><A HREF="#Heading44">FIGURE 33.11.</A>
</UL>
</UL>
<LI><A HREF="#Heading45">NOTE</A>
<LI><A HREF="#Heading46">Listing 33.2. The Sample</A>
<LI><A HREF="#Heading47">1.h file.</A>
<LI><A HREF="#Heading48">Listing 33.3.</A>
<LI><A HREF="#Heading49">The Sample1.c file.</A>
<LI><A HREF="#Heading50">Listing 33.4.</A>
<LI><A HREF="#Heading51">Adding code to the callback function.</A>
<LI><A HREF="#Heading52">NOTE</A>
<LI><A HREF="#Heading53">Summary</A>
</UL>
</UL>
</UL>
<P>
<HR SIZE="4">
<H2 ALIGN="CENTER"><A NAME="Heading1<FONT COLOR="#000077">- 33 -</FONT></H2>
<H2 ALIGN="CENTER"><A NAME="Heading2<FONT COLOR="#000077">Interviews</FONT></H2>
<P><I>by Kamran Husain</I></P>
<P>IN THIS CHAPTER</P>
<UL>
<LI>What Is the Interviews System?
<P>
<LI>How to Get and Install Interviews
<P>
<LI>Sample Applications
<P>
<LI>idraw<TT></TT>
<P>
<LI><BR>
Changes to Xdefaults
<P>
<LI>ibuild<TT></TT>
<P>
<LI><BR>
Code Generation
<P>
<LI>Building an Application with ibuild
</UL>
<P><BR>
In this chapter, you will learn about the Interviews C++ class library development
system. You will learn about the tools available for Interviews and how to use them
to create front-end GUI applications.</P>
<P>Interviews offers a rich set of C++ functionality and tools for building applications.
This chapter can't possibly do it justice in the space provided. By reading to the
end of the chapter, though, you will get a feel for creating truly object-oriented
applications using Interviews.</P>
<P>To get the most out of this chapter, you need some knowledge of how to run the
C++ compiler and how to program in object-oriented languages. If you have not already
done so, you should install the X window package with at least Motif window manager
(<TT>mwm</TT>) or the OPEN LOOK manager (<TT>olwm</TT>).
<H3 ALIGN="CENTER"><A NAME="Heading3<FONT COLOR="#000077">What Is the Interviews
System?</FONT></H3>
<P>The Interviews subsystem is a windowing system for X Window. Interviews is copyrighted
by The Board of Trustees of the Leland Stanford Junior University. Interviews was
developed by Mark Linton's group at Stanford.</P>
<P>What makes Interviews an interesting environment is that it provides an object-oriented
approach to building user interfaces. All components within Interviews, such as windows,
menus, scrollbars, and so on, are objects with inherited behavior. The name Interviews
is derived from the package presenting an interactive view of some data. For example,
a front end to a database provides an interactive view to the data in the database.
<H3 ALIGN="CENTER"><A NAME="Heading4<FONT COLOR="#000077">How to Get and Install
Interviews</FONT></H3>
<P>The Interviews kit is distributed in two packages: iv1 and iv2. The first package,
iv1, contains the binary and source files for the libraries. The second package includes
the man pages and a PostScript reference manual for the Interviews system.</P>
<P>The Interviews package is included on the CD that comes with this book.
<DL>
<DT></DT>
</DL>
<DL>
<DD>
<HR>
<A NAME="Heading5<FONT COLOR="#000077"><B>TIP:</B> </FONT>I recommend that
you print the PostScript version of the Interviews manual if you plan on developing
any applications in Interviews. This manual is in the file <TT>/usr/doc/interviews/
refman.PS</TT>. You need a PostScript printer to print this document, or you can
view this manual via <TT>ghostscript</TT>.
</DL>
<H3 ALIGN="CENTER"><A NAME="Heading6<FONT COLOR="#000077">Sample Applications</FONT></H3>
<P>The Interviews package comes with several applications found in the <TT>/usr/interviews</TT>/<TT>bin</TT>
directory. Applications to give you an idea of some of Interviews' potential are
shown in the <TT>dclock</TT> and <TT>idemo</TT> applications, shown in Figures 33.1
and 33.2.<BR>
<BR>
<A NAME="Heading7<A HREF="../art/33/28lnx01a.jpg"><FONT COLOR="#000077"><B>FIGURE
33.1</B>.</FONT></A><FONT COLOR="#000077"> </FONT><I>The Interviews <TT>dclock</TT>
application.</I>
<H6></H6>
<P><A NAME="Heading8<A HREF="../art/33/28lnx02.jpg"><FONT COLOR="#000077"><B>FIGURE
33.2.</B></FONT></A><FONT COLOR="#000077"><I> </I></FONT><I>A demo application with
Interviews. <BR>
</I><BR>
The list of other ready-to-run applications under Interviews is shown in Listing
33.1.</P>
<P>We will cover some of these applications in a bit more detail in this chapter.
The rest you can try out on your own.
<H3 ALIGN="CENTER"><A NAME="Heading9<FONT COLOR="#000077">Listing 33.1. The
binary files for Interviews.</FONT></H3>
<PRE><FONT COLOR="#0066FF">$ ls -al /usr/interviews/bin
total 1187
drwxr-xr-x 2 root root 1024 Nov 5 17:40 .
drwxr-xr-x 6 root root 1024 Nov 5 17:40 ..
-rwxr-xr-x 1 root root 9220 Apr 17 1994 alert
-rwxr-xr-x 1 root root 82 Apr 17 1994 cpu
-rwxr-xr-x 1 root root 17412 Apr 17 1994 dclock
-rwxr-xr-x 1 root root 259076 Apr 17 1994 doc
-rwxr-xr-x 1 root root 1616 Apr 17 1994 ibmkmf
-rwxr-xr-x 1 root root 689156 Apr 17 1994 ibuild
-rwxr-xr-x 1 root root 37892 Apr 17 1994 iclass
-rwxr-xr-x 1 root root 17412 Apr 17 1994 idemo
-rwxr-xr-x 1 root root 115716 Apr 17 1994 idraw
-rwxr-xr-x 1 root root 9220 Apr 17 1994 ifc
-rwxr-xr-x 1 root root 642 Apr 17 1994 ivmkmf
-rwxr-xr-x 1 root root 13316 Apr 17 1994 logo
-rwxr-xr-x 1 root root 17412 Apr 17 1994 mailbox
-rwxr-xr-x 1 root root 1736 Apr 17 1994 remind
</FONT></PRE>
<DL>
<DT><FONT COLOR="#0066FF"></FONT></DT>
</DL>
<DL>
<DD>
<HR>
<A NAME="Heading11<FONT COLOR="#000077"><B>TIP:</B> </FONT>You can always try
the applications in <TT>/usr/interviews/bin</TT> from an <TT>xterm</TT> by running
the command as a background process. For example, to run the <TT>ibuild</TT> application,
type the command <TT>ibuild &</TT>. If you do not run <TT>ibuild</TT> as a background
process, you can press Ctrl-z to put it in the background of a <TT>bash</TT> shell.
<HR>
</DL>
<H3 ALIGN="CENTER"><A NAME="Heading12<FONT COLOR="#000077">idraw</FONT></H3>
<P>Let's start with an application in the Interviews package. Learning this application
will familiarize you with Interviews and working with its development tools. (See
Figure 33.3.)</P>
<P>The <TT>idraw</TT> application lets you draw rectangles, polygons, ellipses, and
other shapes interactively. Drawings are stored in files that can be printed on a
PostScript printer. You can open an existing drawing by typing a filename on the
command line when starting up <TT>idraw</TT>.</P>
<P>You must engage a tool before you can use it. You engage a tool by clicking on
its icon, or by typing the character that is below and to the right of its icon.
The icon of the drawing tool that's engaged appears in inverted colors. When it is
engaged, you use the tool by clicking the left mouse button in the drawing area.</P>
<P>The Select, Move, Scale, Stretch, Rotate, and Alter tools manipulate existing
graphics. Magnify makes a part of the view expand to fill the entire view.<BR>
<BR>
<A NAME="Heading13<A HREF="../art/33/28lnx03.jpg"><FONT COLOR="#000077"><B>FIGURE
33.3.</B></FONT></A><FONT COLOR="#000077"> </FONT><I>The <TT>idraw</TT> application's
main screen. </I><BR>
<BR>
Text, Line, Multiline, Open Spline, Ellipse, Rectangle, Polygon, and Closed Spline
create new graphics. Each tool works as follows:
<UL>
<LI>Select is used to select a graphic, unselecting all others.
<P>
<LI>A graphic is selected if its handles are visible. Handles are small inverse-video
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -