![]() |
![]() HP OpenVMS Systems Documentation |
![]() |
DECwindows Motif Guide to Application Programming
10.3.4 Using Scrolled Windows for Small ScreensYou can use scrolled windows, such as an XmMainWindow widget with scroll bars or an XmBulletinBoardDialog widget with scroll bars, to present large windows on small screens. This implementation has the disadvantage of not displaying all of a window at one time; that is, the user has to use the scroll bars to view all portions of the window. This could mean that the user has to use the scroll bars to find push buttons or other widgets, but it does ensure that the application interface is available to the user.
When writing your application, you can automatically include scroll
bars on all large, and potentially large, windows without regard to
screen size. If you set the XmNscrollBarDisplayPolicy resource to
XmAS_NEEDED and the XmNscrollingPolicy resource to XmAUTOMATIC, the
scroll bars are displayed only when needed. The scroll bars might not
ever be needed, but they are always available.
You can specify the DXmNfitToScreenPolicy resource in your application's defaults file to automatically size all dialog widgets for a screen. DXmNfitToScreenPolicy is a resource of the dialog shell widget. When the DXmNfitToScreenPolicy resource is set to XmAS_NEEDED in an application's defaults file, the dialog shell automatically resizes and positions all dialog shells that are too big for the user's screen. As a side effect of the resizing, the dialog shell creates its own scroll bars, which allow the user to navigate to the occluded portions of the dialog box. The DXmNfitToScreenPolicy resource can be set only in an application's defaults file; it cannot be set in a UIL module or through a call to XtSetArg. The format for setting this resource is as follows:
10.3.6 Window Placement for Small Screens
If it is possible to do so, the Motif window manager places a window so
that it is not clipped by the boundaries of the screen, regardless of
the screen size. If clipping cannot be avoided, a window is placed so
that at least the upper-left corner of the window is on the screen.
Therefore, your application does not have to take any special
precautions when setting the XmNy and XmNy resources for widgets.
You can use color to enhance the visual appeal of your DECwindows application. However, how colors are supported and displayed depends on the visual type of the display hardware and the available color resources. Each screen has one or more visual types associated with it. The visual type identifies the characteristics of the screen, such as color or monochrome capability. Visual types partially determine the appearance of color on the screen and determine how a client can manipulate colormaps for a specified screen. Your application should not make any assumptions about the display hardware or the availability of color resources. Specifically, your application must do the following:
This policy is especially true if your application will be displayed on multiple hardware platforms. The sections that follow describe coding recommendations to follow when writing color applications that will be displayed on multiple hardware platforms.
See the X Window System by Scheifler and Gettys for a complete
description of the DECwindows color implementation. Some of that
information is summarized here for convenience. (The complete
description is also contained in the VMS DECwindows Xlib Programming Volume).
The basic philosophy for using color is to determine the color needs of your application and then determine how the display hardware can best support those needs. Therefore, before defining colors, use the following method to determine the default visual type of a screen:
The X Protocol defines the visual types shown in Table 10-3.
The OpenVMS DECburger demo application uses the code shown in Example 10-2 to test the XVisual.class member to see if it is being displayed on a color screen. DECburger implements a "customize background color" feature only for color screens.
10.4.1.1 Writable Color CellsColor cells can be read-only or writable, depending on the visual type. If the XVisual.class field indicates that the display has read-only color cells (StaticGray, StaticColor, TrueColor), an X error is generated if you attempt to allocate read/write color cells. When an application calls the XAllocColor routine to allocate a read-only color cell, it specifies the RGB values for the color it wants to use. The server then searches the colors that have already been allocated. If the requested color has been allocated, that pixel value is returned. Otherwise, the server allocates a color cell to store the specified RGB values or those that most closely match the specified RGB values. XAllocColor returns the pixel value that identifies the color cell in the XColor.pixel field. The application cannot change the RGB values of the cell.
Read-only color cells are shared among clients; that is, if another application also calls XAllocColor with these same RGB values, the pixel value is returned to that application as well. This does not count as an additional entry in the colormap.
For read/write color cells, the initial RGB values of the cells are
undefined. An application must call XStoreColor or XStoreColors to
store RGB values into the cells. Read/write cells should not be shared
because the RGB values of the cells can change.
You should not make any assumptions about the depth (number of planes) of a display. For example, if you assume that eight planes are available and the application is displayed on a screen with only four planes, unpredictable results will occur. Your application should call the XDefaultDepthofScreen or XPlanesofScreen routines to determine the maximum number of planes supported on a screen.
Remember that, on some systems, a single display can support multiple
screens. Each screen can have several different visual types supported
at different depths.
If your application is displayed on a system with limited color resources, your application should be prepared to deal with this lack of resources. For example, if your application wants to allocate 20 color cells, but only 10 are available, your application must determine how it wants to proceed. If your application cannot function without all the color cells, you might just print a message that insufficient color resources are available and exit. For example, the OpenVMS DECburger demo application uses the code shown in Example 10-3 to print a message and exit if it is unable to allocate a color cell.
If your application can function while allocating only some of the
color cells, allocate the color cells according to their priority. For
example, the color mixing widget tries to allocate 29 color cells to
represent the colors in the various color models, as described in
Section 10.4.1.3. The color mixing widget allocates the most important
color cells first. If all of the 29 cells are not available, the color
mix widget dims features as required.
Applications are required to present image data (bitmaps, pixmaps) to the X server in a format that the server expects; otherwise, errors occur. This becomes especially important if your application will be displayed on multiple hardware platforms that have different image formats. For example, assume that you used the /usr/examples/motif/bitmap.exe (UNIX) or DECW$EXAMPLES:BITMAP.EXE (OpenVMS) program to create the following bitmap. (Note that the bitmap example is not available with eXcursion for Windows NT.)
For example, BITMAP.EXE creates bitmaps with byte_order and bitmap_bit_order equal to LSBFirst. You could use this bitmap as data for an image on VAX displays, but it might cause errors when displayed on some PC servers. If your application will be displayed on multiple hardware platforms, you must provide for this possible conflict in image formats.
The sections that follow describe how to provide for this possible
conflict.
X11 servers and Xlib implementations exchange protocol information to set protocol-request size maximums, establish the byte order for protocol requests, and so forth. The server determines most of these connection parameters, including the image format order to use. To allow applications to determine the server's image format, the Xlib XOpenDisplay routine fills in a Display data with the following setup parameters provided by the server:
Xlib includes XImageByteOrder and XBitmapBitOrder routines that your
application can call to determine the image byte and bit order.
The XCreateImage routine does not let applications specify the byte_order and bitmap_bit_order of the data being used for the image. Therefore, your application must function as follows:
|