Purpose |
To include a list view control. |
||||||||||||||||||||||||||||||||||||||||||||||||
Syntax |
winio@('%lv[options]',width,height,items,num_items,sel,view) |
||||||||||||||||||||||||||||||||||||||||||||||||
Modifiers |
Grave accent (`) - used to provide a list of icons or an integer array of check box states. Caret (^) - call-back function is provided. Question mark (?) - a help string is supplied. |
||||||||||||||||||||||||||||||||||||||||||||||||
Description |
A list view control is a window that displays a collection of items, each item consisting of an optional icon and a label. List view controls provide several ways of arranging items and displaying individual items. For example, additional information about each item can be displayed in columns to the right of the icon and label. This arrangement is called a report view. Microsoft Explorer uses a list view control in order to display directory information. width and height provide the dimensions of the control in pixels. num_items is an integer constant giving the number of rows in the report view + 1 (for the header). Blank rows are not displayed in the control. This means that the number of rows that are displayed can be changed under program control. The first blank row terminates the input. items is an array of num_items character strings the first describing the column headers and widths, then one string describing each row in turn (see the example below). sel is an integer array whose elements are set to 1 if the item is selected otherwise to zero. view is an integer variable in the range 0..3 that represents the type of view. 0=Icon view; 1=Report view; 2=Small icon view; 3=List view. These are available even when no icons are provided. If a grave accent is provided, icon_str is a character string giving a list of icon resources in the form 'icon1,icon2'. %lv can take a pivot (%pv (Pivot)). Also the right mouse button can be used to trigger a popup menu (%pm (Popup Menu)) defined in the parent window. Example CHARACTER*80 items(4) Here we have 3 rows with 2 columns. items(1) provides data for the column headings and widths. The first character defines the separator between the data for each column. In this example, the first column has the caption "Header". A trailing underscore followed by an integer provides the pixel width of the column. If this is omitted then the length of the text defines the width (a plus sign placed before the integer makes the heading centred whilst a minus sign makes it right justified). In this example the second column header is blank and the second column width is 50 pixels. The number of characters (80 in this case) must be sufficient to allow ClearWin+ to add the column width to each heading (4 characters per column). items(2) provides data for the first row of a report. Again the first character defines the separator. The second character defines the icon as an index (A,B,C...) into the list of icons 'icon1,icon2' (when a grave accent is used). Next comes the label and then the data for column two etc.. Options
| ||||||||||||||||||||||||||||||||||||||||||||||||
Label editing With BEGIN_EDIT you can get the index of the selected item by the call CLEARWIN_INFO@('ROW_NUMBER'). If your call-back function returns the value 4 then editing of this item is prevented. |
|||||||||||||||||||||||||||||||||||||||||||||||||
With EDIT_KEY_DOWN you can validate each character as it is typed. Use CLEARWIN_INFO@('KEYBOARD_KEY') to get the key and/or CLEARWIN_STRING@('EDITED_TEXT') to get the resulting string with the character inserted. If the call-back function returns the value 4 then the character is not accepted. If you want to translate the input key to another key then the call-back function must return the ASCII character code (31<code<256) of the translated key. With END_EDIT you can get the result of the edit by the call CLEARWIN_STRING@('EDITED_TEXT'). Having validated the label, you should then get the index using CLEARWIN_INFO@('ROW_NUMBER') and reconstruct the relevant row of the items array by adding an icon identifier and extra column data as required (otherwise the original data will be restored). Creating a blank row in response to a label edit is not recommended. Selecting a view INTEGER FUNCTION change_view() Column widths If a column width is changed at run time then ClearWin+ stores the new width in row 1 of the data. This means that the adjusted widths will be used when the control is redrawn. If you want to use the same widths when the program is re-used then you will need to save and restore the modified data. Cell editing CLEARWIN_INFO@('ROW_NUMBER') and CLEARWIN_INFO@('COLUMN_NUMBER') identify the cell that is being edited. When editing cells, use the arrow keys to move vertically and CTRL with arrow keys to move horizontally. This movement will step over any cells that are disabled. The selection array (with one element for each row) contains the row number of the current selection. However, when validating input it is simpler to use CLEARWIN_INFO@('COLUMN_NUMBER').
Call-back reasons
In response to a column click you might choose to sort the items using the given column index. Having reconstructed the data, you should then make a call to WINDOW_UPDATE@(items) in order to view the new order. |
|||||||||||||||||||||||||||||||||||||||||||||||||
See also |
%ms (Multi-select Box), %ls (List Box (or Combo Box)), %el (Editable Combo Box) |