List-view - %lv[options]

In this section:

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. One of the arguments for %lv (List 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. In the report view, additional information about each item can be displayed in columns to the right of the icon and label. The Microsoft Explorer uses a list view in order to display directory information. Here is a Fortran 95 example that illustrates the concept. For further details see %lv (List View).

INTEGER N
PARAMETER (N=20)
CHARACTER*36 info(N),Colour,icons*60
INTEGER rgb(N-1),sel(N-1),view,hwnd,winio@,RGB@
COMMON info,rgb,hwnd
EXTERNAL call_back
INTEGER call_back,i
sel=0;rgb=0
rgb(1)=RGB@(255,0,0)
rgb(2)=RGB@(0,255,0)
rgb(3)=RGB@(0,0,255)
rgb(4)=RGB@(0,255,255)
rgb(5)=RGB@(255,0,255)
rgb(6)=RGB@(255,255,0)
info(1)='|Colour_90|Red|Green|Blue'
info(2)=Colour('|ARed|', rgb(1))
info(3)=Colour('|BGreen|', rgb(2))
info(4)=Colour('|CBlue|', rgb(3))
info(5)=Colour('|DCyan|', rgb(4))
info(6)=Colour('|EMagenta|', rgb(5))
info(7)=Colour('|FYellow|', rgb(6))
view=1
icons='red,green,blue,cyan,magenta,yellow,blank'
i=winio@('%ww%sy[3d]%ca[Listview sample]&')
i=winio@('%mn[Views[Icon]]&', 'SET',view,0)
i=winio@('%mn[[Report]]&', 'SET',view,1)
i=winio@('%mn[[Small icon]]&','SET',view,2)
i=winio@('%mn[[List]]&', 'SET',view,3)
i=winio@('%pv%`^lv[edit_labels,single_selection]&',
+ 240,120,info,N,sel,view,icons,call_back)
i=winio@('%ff%cn%10`rs%lc','Selected colour',hwnd)
END

CHARACTER*36 FUNCTION Colour(name,rgb)
CHARACTER(*) name
INTEGER rgb,r,g,b
CHARACTER*3 rc,gc,bc
r=AND(255,rgb)
g=AND(255,RS(rgb,8))
b=AND(255,RS(rgb,16))
WRITE(rc,'(i3)') r
WRITE(gc,'(i3)') g
WRITE(bc,'(i3)') b
rc=ADJUSTL(rc)
gc=ADJUSTL(gc)
bc=ADJUSTL(bc)
WRITE(Colour,'(6a)') name,rc(1:LEN_TRIM(rc)),'|',
+ gc(1:LEN_TRIM(gc)),'|',bc(1:LEN_TRIM(bc))
END

INTEGER FUNCTION call_back()
INCLUDE <windows.ins>
INTEGER N
PARAMETER (N=20)
CHARACTER*36 info(N)
INTEGER rgb(N-1),hwnd,row
COMMON info,rgb,hwnd
CHARACTER*36 Colour,name
call_back=2
SELECT CASE(clearwin_string@('CALLBACK_REASON'))
CASE('SET_SELECTION')
row=clearwin_info@('ROW_NUMBER')
CALL set_control_text_colour@(hwnd,rgb(row))
CASE('END_EDIT')
name=clearwin_string@('EDITED_TEXT')
row=clearwin_info@('ROW_NUMBER')
info(row+1)(3:)=Colour(name(1:LEN_TRIM(name))//'|',rgb(row))
CALL window_update@(info)
END SELECT
END

RESOURCES
red ICON red.ico
green ICON green.ico
blue ICON blue.ico
cyan ICON cyan.ico
magenta ICON magenta.ico
yellow ICON yellow.ico
blank ICON blank.ico

The winio@ statement that generates the list-view is:

i=winio@('%`^lv[edit_labels,single_selection]&',
+ 240,120,info,N,sel,view,icons,call_back)

Here is an outline of the meaning of the symbols and variables used in this statement:

grave accent

a list of icons (called icons) is supplied

caret

a call-back function (called call_back) is supplied

edit_labels

an option that enables the names of the colours to be edited by the user

single_selection

an option that ensures that at most one colour can be selected at a time

240

the initial width of the list-view in pixels

120

the initial height of the list-view in pixels

info

an array of strings that defines each row; the first row defines the column headings; the first character on subsequent rows is an index (A, B, C,...) that selects an icon from the list of icons; different fields are separated by a pipe '|' symbol.

N

a parameter defining the maximum number of rows

sel

an integer array to mark the current selection

icons

a string of icon resources

call_back

a call-back function that is used when a selection is made and when the end of label editing is detected.


 

 

Basket
Empty
 
Copyright © 1999-2024 Silverfrost Limited