?? rhl23.htm
字號(hào):
<BR>
<BR>
<LI>The number of display units are in character sizes for xterms.
<BR>
<BR>
</UL>
<P>A pixel is the smallest unit available on a screen. Usually, screens are displayed in 1024´768 pixels, 2048´2048 pixels, or something similar. The size of a pixel on screen is very much hardware-dependent. A 200´200 window appears as
different sizes on monitors with different resolutions.
<BR>
<P>The geometry parameter is of the following form:
<BR>
<BR>
<PRE>
<FONT COLOR="#000080">widthxheight[{+-}xoff{-+}yoff]</FONT></PRE>
<P>The height and width are usually given in pixels. In the case of xterms, height is given in lines, and width is given in characters per line. It is common to have a 24´80 xterm.
<BR>
<P>The xoff and yoff are offsets from the start of the left and top edges of the screen respectively. These represent the location of the window on the root window. The curly braces represent either the — or the + character, but not both.
<BR>
<TABLE BORDERCOLOR=#000040 BORDER=1 CELLSPACING=2 WIDTH="100%" CELLPADDING=2 >
<TR>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
+xoff
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
A positive offset from the left edge of the screen to the left edge of the window.</FONT>
<TR>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
-xoff
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
A negative offset from the right edge of the screen to the right edge of the window.</FONT>
<TR>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
+yoff
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
A positive offset from the top edge of the screen to the top edge of the window.</FONT>
<TR>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
-yoff
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
A negative offset from the bottom edge of the screen to the bottom edge of the window.</FONT>
</TABLE><P>A visual representation of the geometry is shown in Figure 23.5. For example, the line
<BR>
<BR>
<PRE>
<FONT COLOR="#000080">xterm -geometry -50+50 &</FONT></PRE>
<P>places the xterm on the top right corner, 50 pixels from the right edge of screen and 50 pixels from the top of the screen.
<BR>
<P><B> <A HREF="23rhl05.gif" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/23rhl05.gif">Figure 23.5. Window geometry.</A></B>
<BR>
<P>The following parameters specify the edges of the screen:
<BR>
<TABLE BORDERCOLOR=#000040 BORDER=1 CELLSPACING=2 WIDTH="100%" CELLPADDING=2 >
<TR>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
-0-0
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
Lower right corner</FONT>
<TR>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
-0+0
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
Upper right corner</FONT>
<TR>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
+0-0
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
Lower left corner</FONT>
<TR>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
+0+0
</FONT>
<TD VALIGN=top BGCOLOR=#80FFFF ><FONT COLOR=#000080>
Upper left corner</FONT>
</TABLE><BR>
<A NAME="E68E171"></A>
<H3 ALIGN=CENTER>
<CENTER>
<FONT SIZE=5 COLOR="#FF0000"><B>Using the Window Menu</B></FONT></CENTER></H3>
<BR>
<P>Using the window menu requires you to have the focus on a window. Let's look at a typical window menu. This also may be different on your screen, but the basic functionality listed here should exist for all later versions of Motif. Take the cursor to
the window menu button, and press the left button. The following menu (or something close to it) should appear:
<BR>
<PRE>
<FONT COLOR="#000080">Restore alt-F5
Move alt-F7
Size alt-F8
Minimize alt-F9
Maximize alt-F10
Lower alt-F3
Close alt-F4</FONT></PRE>
<BR>
<A NAME="E68E172"></A>
<H3 ALIGN=CENTER>
<CENTER>
<FONT SIZE=5 COLOR="#FF0000"><B>Using the Keyboard in X and the Meta Key</B></FONT></CENTER></H3>
<BR>
<P>It's important to bring this point up about the keyboard and its special keys under X. Keyboards come in different types, and the most important key for using keystrokes in X can be radically different from one keyboard to another. On PC-based
keyboards, it is usually the Alt key; on Macintoshes, it is the Command key; on Suns, it is Left, Alternate; and other keyboards use other keys. The list goes on.
<BR>
<P>In short, the Meta key is the special key for your keyboard. For a PC-based keyboard, this is the Alt key. So, do not look for a key called Meta on your keyboard. Where it says Meta, use Alt, Command, or whatever key your keyboard is mapped to.
<BR>
<P>Now you can invoke any item on this window menu in one of two ways:
<BR>
<UL>
<LI>Use the pointer. This way, you click on the window menu and press Button1. Now, move the cursor to the item you want, and release Button1; or, press the Meta key and the character that is underlined in the menu. For moving a window, you press Meta-M.
Note that this does not work on some Motif distributions.
<BR>
<BR>
</UL>
<BLOCKQUOTE>
<BLOCKQUOTE>
<HR ALIGN=CENTER>
<BR>
<NOTE>Alt-key combinations may not always work. In Metro's version of Motif 1.2, the Meta-F7 key allows moving a window, but the Meta-M key does not work at all. You may have a completely different experience with your keyboard.</NOTE>
<BR>
<HR ALIGN=CENTER>
</BLOCKQUOTE></BLOCKQUOTE>
<UL>
<LI>While the window has focus, press the Meta-function key combination. Then use the arrow keys on your keyboard to simulate the movement of the cursor, or just use the pointer.
<BR>
<BR>
</UL>
<P>Note that some of these functions may not be available for a menu shown for an icon. You might not be able to size or minimize an icon, but you can move, maximize, or close it.
<BR>
<BR>
<A NAME="E68E173"></A>
<H3 ALIGN=CENTER>
<CENTER>
<FONT SIZE=5 COLOR="#FF0000"><B>Using the Root Menu</B></FONT></CENTER></H3>
<BR>
<P>Click Button3 while the cursor is in the root window. You see a menu pop up on top of all the windows. This is known as the root menu. Keep in mind that this menu is very customizable, and may look radically different on your machine. You will learn all
about creating your own menu later in this chapter in the "Customizing Motif" section.
<BR>
<P>A typical root menu may list the following items. (Your system may have a different list depending on the type of Motif you purchased.)
<BR>
<PRE>
<FONT COLOR="#000080">"Root Menu"
New Window
Shuffle Up
Shuffle Down
Refresh
Utils >
Restart
Exit</FONT></PRE>
<P>While holding down Button1, move the cursor down the list to the item you want to select. When you get to the menu item you want, release the button. If you do not want to select any items, move the cursor off the menu and release the button.
<BR>
<P>In the previous list, the functionality can be set to the following:
<BR>
<UL>
<LI>New Window starts a new xterm and sets focus to it.
<BR>
<BR>
<LI>Refresh redraws the entire screen and all windows.
<BR>
<BR>
<LI>Restart kills mwm and restarts it.
<BR>
<BR>
<LI>Exit kills mwm and leaves you without a window manager. If this is the last command in your startup script, your windowing session terminates.
<BR>
<BR>
<LI>Shuffle Up and Shuffle Down shuffles the stacking order of the windows up or down. The current window with focus is moved down to the bottom when shuffling down, and the next highest window is given the focus. The last window in the stack is brought to
the top and given the focus when shuffling up.
<BR>
<BR>
<LI>The Utils item brings up another submenu with more choices to select from. See the "Customizing Motif" section, later in this chapter, for details on how to set your menu items.
<BR>
<BR>
</UL>
<P>Now, let's work with Motif clients.
<BR>
<BR>
<A NAME="E68E174"></A>
<H3 ALIGN=CENTER>
<CENTER>
<FONT SIZE=5 COLOR="#FF0000"><B>Working with Motif Clients</B></FONT></CENTER></H3>
<BR>
<P>Most programmers find the X Window system libraries too basic to work with, so they use the next building block called toolkits. The most common interface toolkit is the XtIntrinsics toolkit from MIT. This is called Xt. On top of Xt, you can have other
toolkits such as Motif or the Open Look Interface Toolkit (OLIT). When you are working with Motif, you are working with a Motif toolkit. In Motif, you are working with Motif Widgets.
<BR>
<P>Widgets help developers program consistent user interfaces in Motif. By using Widgets, programmers can quickly put together interfaces that have the same look and feel of all Motif applications.
<BR>
<P>Some Widgets display information. Some Widgets collect user input (mouse or keyboard) information. Some Widgets react to user input by changing their appearance or performing some programmed function. Some Widgets are simply containers for other
Wigdets. All Widgets can be customized in one form or another, whether it is appearance, font size or style, colors, or whatever other parameter is required.
<BR>
<P>All Widgets of the same type have two data structures with information that describes their attributes: class and instance. The instance data structure contains information for a specific Widget on the screen. The class information contains information
required for all Widgets of the class.
<BR>
<P>Widgets are grouped into several classes. Each class depends on the type of functionality offered by the Widget. Normally, the internal functions of a Widget are hidden from the applications programmer (encapsulation). A Widget class shares a set of
functions and data structures for all Widgets in that class. A new Widget class can be derived from an existing Widget class. The newly derived class can inherit all the data structures and functions of the parent class. A Widget is created and destroyed
during a Motif program execution.
<BR>
<BLOCKQUOTE>
<BLOCKQUOTE>
<HR ALIGN=CENTER>
<BR>
<NOTE>The destruction of a Widget is a bit more complicated, and will be discussed in detail in the next chapter.</NOTE>
<BR>
<HR ALIGN=CENTER>
</BLOCKQUOTE></BLOCKQUOTE>
<BLOCKQUOTE>
<BLOCKQUOTE>
<HR ALIGN=CENTER>
<BR>
<NOTE>This should sound familiar to C++ programmers. True polymorphism is somewhat harder to find in Widgets. This is all done in C. For C++ programmers, the class data structure is to the class for an object, as the instance data structure is to the
instance of an object.</NOTE>
<BR>
<HR ALIGN=CENTER>
</BLOCKQUOTE></BLOCKQUOTE>
<P>A Widget is really a pointer to a data structure when viewed in a debugger. This data structure is allocated on the creation of a Widget, and is destroyed when a Widget is destroyed.
<BR>
<P>Let's look at a typical application screen to see some Widgets in action. You will work with a demo application called xmdialogs, shown in Figure 23.6. The Widgets shown here will be described later in this chapter. The xmdialogs application can be
found in the /usr/bin/X11 directory. If you do not have this application, you can still learn about working with Widgets by applying these concepts to different applications.
<BR>
<BLOCKQUOTE>
<BLOCKQUOTE>
<HR ALIGN=CENTER>
<BR>
<NOTE>Don't worry if you cannot find this application on your machine. There are plenty of other applications just like this one. If you have the Motif 1.2.3 release or later from Metro Link, you will have this application in your /usr/bin/X11
directory.</NOTE>
<BR>
<HR ALIGN=CENTER>
</BLOCKQUOTE></BLOCKQUOTE>
<P><B> <A HREF="tppmsgs/msgs1.htm#137" tppabs="http://202.113.16.101/%7eeb%7e/Red%20Hat%20Linux%20Unleashed/23rhl06.gif">Figure 23.6. The </B><B>xmdialogs</B><B> demo application.</A></B>
<BR>
<P>Figure 23.6 shows a Menu bar, a File selection list with scrollbars, an Option button, some Radio and Toggle buttons, some Push buttons, some Labels, and a Text display dialog box.
<BR>
<P>The Actions and Help items are shown on a menu bar. By moving the pointer to either of these items and pressing Button1, you are presented with a menu of options very similar in operation to the window and root menu.
<BR>
<P>Underneath this menu bar is a list of items in a scrollable list. This Widget is of the type XmList. The XmList lets you keep a selection of items in a visible list. It has scroll bars to enable the user to scroll the list if the entire list isn't
visible. A programmer can set the number of items that are visible at one time. If you resize the window, and if the list box sizes itself proportionately with the window, the number of visible items in a list may change.
<BR>
<P>To select an item, move the pointer to the item of your choice and press Button1 once. The item is highlighted in a darker color. Some lists enable you to select more than one item, and others, just one item. In this application, you only select one
type of dialog box. (Figure 23.6 shows the bulletin board item to be the selected item.)
<BR>
<P>The scroll bars on the side of the list Widget are of the class XmScrollbar. A scroll bar is either a horizontal or vertical rectangle. There is a raised box in the rectangle called the slider box. This slider moves within the larger rectangle. The
movable space for the slider bar is called the scroll region. The ratio of the size of the slider bar to the scroll region is proportional to the size of the work area to the total area being viewed.
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -