![]() |
![]() HP OpenVMS Systems Documentation |
![]() |
DECwindows Motif Guide to Application Programming
9.2.7 Setting an Entry Coordinate PositionGenerally, your application does not have to be concerned with positioning entries because the SVN widget does this automatically. However, if you specify a tree style of DXmSvnKuserDefinedTree, the SVN widget uses the x- and y-coordinates you specify to position entries. Your application can call the DXmSvnSetEntryPosition and DXmSvnGetEntryPosition Toolkit routines to set and get the x- and y-coordinates for an entry. The following example gets the x- and y-coordinates of the parent entries and adds a hard-coded value of 30 for both the x- and y-coordinates of all children. FALSE is a Boolean value that indicates that the position information should be interpreted internally by the SVN widget.
9.2.8 Setting an Entry PositionThe DXmSvnPositionDisplay routine lets you position a specified entry at the top, middle, or bottom of the display without concern for the number of entries being displayed. You provide the DXmSvnPositionDisplay routine with the ID of the SVN widget, the entry number of the entry you want to position, and one of the following constants to specify position:
In the following code example, note that the tag argument specifies one of the position constants:
Because the call to this routine is not the result of a callback,
disable the SVN widget. If the position is not equal to
DXmSvnKpositionNextPage and DXmSvnKpositionPreviousPage, find out which
entries are currently selected. Then, position the first of those
entries according to the specified position constant. Enable the SVN
widget.
The SVN widget selection routines allow your application to:
For example, the following code fragment gets the current selections:
This example gets the entry numbers of the current selections in the selections argument. The number of current selections (number_selected) is returned by the DXmSvnGetNumSelections routine.
If you want your SVN widget to support multiple selections, you must
set the DXmSvnNmultipleSelections resource to TRUE.
The SVN widget manipulation routines allow your application to:
The following example shows how to add an entry:
When a user double clicks on an entry in the SVN demo application, the DXmSvnNselectAndConfirm callback routine opens the entry if it is not already opened and calls the DXmSvnAddEntry routine to add any children that the element might have. This call adds one entry (starting after zero) with a level of zero. The address of the first entry in the data hierarchy, _Node, is passed as a tag, and the entry appears in the scroll index window (if activated) when the user drags the slider. The following example shows how to delete an entry:
The after argument, in this case node_number, is the entry number after which to delete entries. The count argument, in this case node->number, is the number of entries to delete. Assume that node_number had a value of 1 and node->number had a value of 3. The example would delete entries 2, 3, and 4. If you want to delete the children of an entry, pass the parent's entry number in the after argument and the number of its children in the count argument. In the following example, entries are set sensitive or insensitive depending on the value of the application-specified tag argument. Because the call to this code is not the result of a callback, the example disables and enables the SVN widget.
9.2.11 Manipulating Column Mode EntriesColumn mode allows your application to split the SVN widget display into two columns, which are comprised of primary and secondary work windows. The DXmSvnNstartColumnComponent resource specifies the number of the last component in the primary work window; that is, the number of the component after which components are to be located in the secondary work window. For example, the following code fragment specifies that components numbered 4 and greater are to be located in the secondary work window.
You can select only the complete entry from the primary work window;
the secondary work window lets you select individual components within
an entry. You can call the DXmSvnInsertComponent and
DXmSvnRemoveComponent routines to add or remove components from an
entry.
Your application can call the DXmSvnFlushEntry routine to display an
entry on the screen while in outline mode. If the entry number you pass
to DXmSvnFlushEntry is one greater than the entry number of the last
displayed entry and there is enough space for the entry to fit, the
entry is appended to the set of visible entries. If there is not enough
blank space for the entry to fit, DXmSvnFlushEntry scrolls to the entry.
As described in Section 9.1.1, each entry in your hierarchy can display as many as 30 components of information, depending upon the amount of information users need. Components can be of three data types: text, pixmaps (icons), and widgets. Components you might want to use include:
The SVN widget manipulation routines allow your application to:
The following is an example of how to create and set a pixmap to be used as an icon:
This example creates two separate pixmaps: one for parent entries and
one for entries without children. The example then uses the
node->number field to determine if the selected
entry has children and sets the icon component accordingly. Because the
call to this code is not the result of a callback, the example disables
and enables the SVN widget.
Application users might want to highlight entries to make them stand out in a long list of entries. Another possible use of highlighting is to highlight the user's selection so that the user can confirm the selection. For example, when a user requests a pop-up menu by clicking MB3 on an entry, DECwindows Mail highlights the entry. The SVN widget allows your application to highlight one or more entries by framing them in dashed rectangular boxes. Your application decides how to treat the highlighted entries; the SVN widget does not assign any special significance to highlighted entries. The SVN widget includes routines that allow your application to:
Because the call to this code is not the result of a callback, the example disables and enables the SVN widget.
If your application is to use highlighting, you should set the
DXmSvnNexpectHighlighting resource to TRUE to leave
room for the highlight rectangle.
The SVN widget includes routines that allow your application to get the number of entries currently being displayed in the SVN window and then get the entry numbers, tag values, and y-coordinates associated with those entries. In the following example, DXmSvnGetDisplayed returns the entry numbers of the displayed entries to the array of integers specified by the disp_nums argument, does not use the tag argument value, and returns the y-coordinates to the disp_ys argument. The disp_count argument is the number returned by the DXmSvnGetNumDisplayed routine.
9.2.16 Dragging an EntryThe SVN widget includes an entry-dragging mechanism that lets a user click MB2 on an entry, drag that entry to a new location, and release MB2 to move the entry. The SVN widget also allows an application to implement an application-specific dragging mechanism. Your application can call the DXmSvnSetApplDragging routine to toggle between the SVN and application-specific dragging modes. If the DXmSvnNselectionsDraggedCallback callback routine is not null, and application-specific dragging is not set, a callback is generated when entries are being dragged with MB2. The SVN widget implements the dragging function; your application can use this callback to perform some dragging-related function.
If your application calls the DXmSvnSetApplDragging routine to set the
application-specific dragging mode, the DXmSvnNdraggingCallback is
generated when the user clicks on MB2. When the application dragging is
complete, the DXmSvnNdraggingEndCallback is generated. If your
application uses application-specific dragging, you must provide the
callback routines.
As described in Section 9.2.16, the SVN widget allows applications to implement their own application-specific entry dragging mechanism. As part of this dragging mechanism, your application can define the shape, size, and relative x and y origins of a "ghost" image that follows the entries as they are moved. The ghost resources are as follows:
The following example gets the x and y offsets of the ghost image. Then, it gets the current selections---that is, the entries being moved---and sets their new entry positions. The data->x and data->y fields of the callback indicate the origin of the ghost; that is, the data->x and data->y fields give the location of the ghost and not of the entry itself.
9.2.18 Setting Entry Font ListsThe SVN widget lets your application set default font lists for each entry level or to use one font list as the default for all entry levels. The font list resources are as follows:
The SVN demo application assigns a child level number (the first field in the data structure) to each entry in the hierarchy, as follows:
Therefore, if you set the DXmSvnNfontListLevel2 resource, all level 2 entries (children of P1, P2, P3, and P4) use the specified font list. The following example sets the DXmSvnNfontListLevel2 and DXmSvnNfontListLevel3 resources:
Note that you can set the font list for a component independently of
the font list for the entire entry. For example, if you use the
DXmSvnSetComponentText routine to specify a compound string, you can
use the fontlist argument to specify a font list for a
component.
This section describes the resources that are specific to tree mode.
The SVN widget includes routines that allow your application to get and
reinstate the tree position when the display mode is DXmSvnDisplayTree.
The routines provide a way to determine the exact positioning of the
display, based on x- and y-coordinates known internally by the SVN
widget, and to store that position for later use. When your application
restores the saved position, the SVN widget must be in the same state
(same size and number of entries) as when the position was saved.
Tree display mode entries are surrounded by an outline that makes the boundaries between entries clearer. You can use the DXmSvnNtreeArcWidth resource to specify an arc width for this outline. For example, the SVN demo application sets the DXmSvnNtreeArcWidth resource to allow users to toggle between oval (arc_width = 15) and rectangular (arc_width = 0) entries.
9.3.3 Centering Tree-Mode ComponentsThe DXmSvnNtreeCenteredComponents resource lets you vertically center all of the components within an entry. The SVN widget automatically alters the size of the entries to fit the centered components. For example, the SVN demo application sets the DXmSvnNtreeCenteredComponents resource to let users toggle between centered and "normal" components.
|