Class are destined to control of associated in list data values. For example, it can be list of files.
ListItemNew(<nLrow>,<nLcol>,<nRrow>,<nRcol>[,<nColumns>[,<sDelimiter>[,<sColor>]]]) --> ListItem object
<ClassName> | LISTITEM |
<Item> | Array, array of data value |
<nTop> | Numeric, a LISTITEM viewport coordinates |
<nLeft> | Numeric, a LISTITEM viewport coordinates |
<nBottom> | Numeric, a LISTITEM viewport coordinates |
<nRight> | Numeric, a LISTITEM viewport coordinates |
<ColorSpec> | String, color specification. |
"clr1, clr2, clr3, clr4, clr5, clr6, clr7" | |
clr1 - border and items color | |
clr2 - current item colors if object in focus | |
clr3 - current item colors if object outof focus | |
clr4 - title colors | |
clr5 - selected item colors | |
clr6 - current selected item colors | |
clr7 - founded symbol colors | |
<ItemCount> | Numeric, items count |
<Buffer> | Numeric, the cuurent items number |
<First> | Numeric, the number of first element into viewport |
<ItemWin> | Numeric, items into viewport |
<Line> | Numeric, a current cursor coordinates - line |
<Col> | Numeric, a current cursor coordinates - column |
<Pos> | Numeric, a current column |
<ColWin> | Numeric, a number columns into viewport |
<RowWin> | Numeric, a number rows into viewport |
<LenCol> | Array, array with columns width |
<Title> | Array, array of string that contain columns titles |
<Delim> | String, columns delimiters |
<HasFocus> | Logical, is TRUE if object in focus |
<FindBuffer> | String, the find buffer |
ADDITEM | Add new element to listing. |
CLEAR | Remove all items from listing. |
CLEARFINDBUFFER | Crears find buffer. |
DELITEM | Delete an listing element. |
DOWN | Goes next element. |
DRAWTITLE | Draw columns header. |
END | Goes to last element of array <::Item>. |
FIND | Find substring. |
GETITEM | Gets current item. |
GETSELECTED | Returns selected items numbers. |
HANDLEKEY | Simple handle key. |
HOME | Goes to first element of array <::Item>. |
INSITEM | Insert new element into listing. |
KILLFOCUS | Kill focus. |
LEFT | Goes to left. |
LISTITEMNEW | LISTITEM object constructor. |
PAGEDOWN | Goes to next page of array <::Item>. |
PAGEUP | Goes to previouse page of array <::Item>. |
REFRESH | Refreshed viewport. |
RIGHT | Goes to right. |
SELECT | Select item. |
SETCOLUMNS | Set columns count. |
SETFOCUS | Set focus to object. |
SETITEM | Sets new current item. |
SETKEY | Set a code block associated with code key value. |
SETTITLE | Set columns header. |
SETWIDTHCOL | Set columns width. |
UP | Goes previous element. |
#include <inkey.ch> #define FA_NORMAL 0 #define FA_READONLY 1 #define FA_HIDDEN 2 #define FA_SYSTEM 4 #define FA_VOLUME 8 #define FA_DIRECTORY 16 #define FA_ARCHIVE 32 clear screen wopen(5, 5, 20, 30) li := ListItemNew(0, 0, maxrow(), maxcol()) // create new ListItem object wbox() fname = fileseek("./", FA_ARCHIVE+FA_VOLUME+FA_SYSTEM+FA_HIDDEN+FA_READONLY) do while !empty(fname) li:AddItem(fname, "R/N, N/W") // --> 1 fname = fileseek() enddo li:SetKey(K_ENTER, {|oLI, nKey| alert(toString(oLI:Buffer)+ " " + oLi:GetItem())}) li:SetFocus() do while .t. nKey := inkey(0) ret := li:HandleKey(nKey) if ret == -1 exit endif enddo wclose()
No dependies of platform.
Add new element to listing.
AddItem(<vData>[, <sColor>][, <sSelColor>]) --> 0 || 1
Returns 1 if element will be added.
AddItem() added new element to the end listing <::Item>.
Remove all items from listing.
Clear() --> NIL
No arguments
Returns NIL.
Clear() removes all items from a <::Item> and sets counters to zero.
Crears find buffer.
ClearFindBuffer() --> NIL
No arguments
Returns NIL.
ClearFindBuffer() is clears find buffer. <::FindBuffer> sets to empty string.
Delete an listing element.
DelItem(<nPos>) --> 0 || 1
Returns 1 if element will be deleted.
DelItem() is deletes an element <nPos> from an listing <::Item>. The contents of the element is lost, and all elements from <nPos>+1 position shifted up one element. The last element in the array discarded.
Goes next element.
Down() --> NIL
No arguments
Returns NIL.
Down() is moves cursor to next element of <::Item>.
Draw columns header.
DrawTitle() --> TRUE
No arguments
Returns TRUE.
DrawTitle() is drew headers for listing columns.
Goes to last element of array <::Item>.
End() --> NIL
No arguments
Returns NIL.
End() is moves cursor to the last element of <::Item> listing. The new current element will be len(<::Item>).
Find substring.
Find(<sStr>) --> TRUE || FALSE
Returns TRUE if searching is success.
Find() is addes substring <sStr> to the end of find buffer <::FindBuffer> and searching <::FindBuffer> within <::Item>. If <::FindBuffer> is empty, searching start with first element of <::Item>, in other searching start with current position <::Buffer>.
The <::FindBuffer> value is compared to the array element beginning with the leftmost character in the <::Item> element and proceeding until there are no more characters left in <::FindBuffer>. If <::FindBuffer> is found seraching stopped, <::Buffer> sets to position founded element and Find() returns TRUE. If there is no match, <::Buffer> no changed, <sStr> removes from a <::FIndBuffer> and Find() returns FALSE.
Gets current item.
GetItem() --> <vData>
No arguments
Returns data value of current element.
GetItem() is gets the current element <::Buffer> into listing <::Item>. If array <::Item> is empty, method return NIL.
Returns selected items numbers.
GetSelected() --> <aSelectedItems>
No arguments
Returns array of selected items numbers.
GetSelected() returns array of selected items numbers.
Simple handle key.
HandleKey(<nKey>) --> .T. || .F.
Returns one of numeric value :
-1 User request for the LISTITEM to lose input focus
0 Code block associated with <nKey> was evaluated
1 Unable to locate <nKey> in the dictionary, key was not processed
HandleKey() is evaluates code block that associated with key code <nKey>. The keypress/code block definition creates within SetKey() method.
A default key code cursor moves associates with corresponded methods Left(), Right(), Up(), Down() and more of LISTITEM class.
Goes to first element of array <::Item>.
Home() --> NIL
No arguments
Returns NIL.
Home() is moves cursor to the first element of <::Item> listing. The new current element will be 1.
Insert new element into listing.
InsItem(<vData>, <nPos>[, <sColor>][, <sSelColor>][, <lSelected>]) --> 0 || 1
Returns 1 if element will be inserted.
InsItem() inserted new element <vData> into listing <::Item>. New element inserted at position <nPos>. Before insertion, size of <::Item> increased by 1 and all elements with <nPos> shifted down one elemen.
Kill focus.
KillFocus() --> NIL
No arguments
Returns NIL.
KillFocus() is kils focus for object of LISTITEM class. Attribute <::HasFocus> take value FALSE.
Goes to left.
Left() --> NIL
No arguments
Returns NIL.
Left() is moves cursor to left of current column. The new current element will be <::Buffer> - <::RowWin>.
LISTITEM object constructor.
ListItemNew(<nLrow>,<nLcol>,<nRrow>,<nRcol>[,<nColumns>[,<sDelimiter>[,<sColor>]]]) --> ListItem object
<nLrow> | Numeric, a object coordinates |
<nLcol> | Numeric, a object coordinates |
<nRrow> | Numeric, a object coordinates |
<nRcol> | Numeric, a object coordinates |
<nColumns> | Numeric, a number columns into viewport. By default 1. |
<sDelimiter> | String, a columns delimiter. By default <|> |
<sColor> | String, a colors specification. By default "7/0, 7/0, 7/0, 7/0, 7/0, 7/0, 7/0" |
Method returns new LISTITEM object.
ListItemNew() is constructs and returns new LISTITEM object. That class can be used to edit, view, control associated in list data.
Goes to next page of array <::Item>.
PageDown() --> NIL
No arguments
Returns NIL.
PageDown() is moves cursor to the next page of <::Item> listing. The size of page is <::ItemWin>. The current element will be <::Buffer>+<::ItemWin>.
Goes to previouse page of array <::Item>.
PageUp() --> NIL
No arguments
Returns NIL.
PageUp() is moves cursor to the previouse page of <::Item> listing. The size of page is <::ItemWin>. The current element will be <::Buffer>-<::ItemWin>.
Refreshed viewport.
Refresh() --> NIL
No arguments
Returns NIL.
Refresh() is refreshes viewport. Called within methods of class LISTITEM automaticaly.
Goes to right.
Right() --> NIL
No arguments
Returns NIL.
Right() is moves cursor to right of current column. The new current element will be <::Buffer> + <::RowWin>.
Select item.
Select([<vItem>]) --> TRUE
Returns TRUE.
Select() is sets selected (one or more) items of listing <::Item>.
Set columns count.
SetColumns(<nCol>) --> TRUE || FALSE
Returns TRUE i success.
SetColumns() is sets columns count and sets new balanced width for all columns.
Set focus to object.
SetFocus() --> NIL
No arguments
Returns NIL.
SetFocus() is sets focus to object of LISTITEM class. Attribute <::HasFocus> take value TRUE.
Sets new current item.
SetItem(<nPos>) --> 0 || 1
Returns 1 if element with number <nPos> exist.
SetItem() is sets new current element with number <nPos>. If <nPos> is more than length of <::Item>, method returns 0. If array <::Item> is empty, method return NIL.
Set a code block associated with code key value.
SetKey(<nKey>[, <bData>]) --> bPreviouse
Returns the previouse block code if exist or returns current one <bData>.
SetKey() is sets a new code block associated with code <nKey>. When replacing an existing code block definition, it returns previous code block, in other returns current one. Its associated key code will be evaluated HandleKey() methods.
If <bData> is NIL, SetKey() returns old block code and remove keypress/code block definition.
A default key code is cursor moves(K_UP, K_DOWN, K_LEFT, K_RIGHT, K_PGUP, K_PGDN, K_HOME, K_END ....) associates with corresponded methods Left(), Right(), Up(), Down() and more.
Users code block take two parameters: link to LISTITEM object and key code; and can be returns one of next values:
-1 User request for the LISTITEM to lose input focus
0 Code block associated with <nKey> was evaluated
1 Unable to locate <nKey> in the dictionary, key was not processed
Set columns header.
SetTitle(<aTitle>) --> TRUE || FALSE
Returns TRUE if <aTitle> not empty.
SetTitle() is sets headers for listing columns. Headers sets for first len(<aTitle>) columns, the rest columns becomes empty header.
Set columns width.
SetWidthCol(<aWidth>) --> TRUE || FALSE
Returns TRUE in success.
SetWidthCol() is sets columns width. If <aWidth[i]>==0, for column with number <i> automaticaly sets balanced width.
Goes previous element.
Up() --> NIL
No arguments
Returns NIL.
Up() is moves cursor to previouse element of <::Item>.