//=============================================================
#commands start at 7700
#include testree.sc end;
//=============================================================
TreeLine StatusLine
{
(scTree..scTree)
{
'~F7~ New', cmInsert, kbF7;
'~F8~ Delete', cmDelete, kbF8;
'F3', cmPick, kbF3;
'~+~ Open', cmTreeOpenNode, kbGrayPlus;
'~-~ Close', cmTreeCloseNode, kbGrayMinus;
' ', cmRotateList_1, kbSpace;
}
}
//=============================================================
interface DiffTree (,,scTree);
//-------------------------------------------------------------
create view
var
cOwner: comp;
as select
*
from
synonym BBB T1
where
((
cOwner == T1.CAAA
))
;
//-------------------------------------------------------------
Var
myNumber : array [11..20] of integer; // номера записей
info : array [11..20] of string; // полезная информация
myOwner : array [11..20] of integer; // ссылка на родителя
curRec : integer; // текущая запись
i : integer;
//-------------------------------------------------------------
tree myTree
fields
if(TreeGetNodeTable(myTree) = #T1, T1.Info, info[curRec]) 'Info' : [20];
end;
//-------------------------------------------------------------
handleEvent
cmTreeTop:
{
TreeSetNodeTable(myTree, #T1);
cOwner := 0;
}
cmTreeUp:
{
case (TreeGetNodeTable(myTree)) of
#T1:
cOwner := T1.CAAA;
tnNoTable:
cOwner := myOwner[curRec];
end;
}
cmTreeDown:
{
case (TreeGetNodeTable(myTree)) of
#T1:
{
if (T1.Nrec = 2) or (T1.Nrec = 3) or (T1.Nrec = 5) then
TreeSetNodeTable(myTree, tnNoTable);
cOwner := T1.Nrec;
}
tnNoTable:
cOwner := myNumber[curRec];
end;
}
cmDoGetFirst:
{
for (i:=11; i<=20; i:=i+1)
if (myOwner[i] = cOwner)
{
curRec := i;
break;
}
if curRec <> i then
Abort;
}
cmDoGetPrev:
{
if (curRec <= 11)
{
abort;
exit;
}
for (i:=curRec-1; i>=11; i:=i-1)
{
if (myOwner[i] = cOwner)
{
curRec := i;
break;
}
}
if curRec <> i then
Abort;
}
cmDoGetNext:
{
if (curRec >= 20)
{
Abort;
exit;
}
for (i:=curRec+1; i<=20; i:=i+1)
if (myOwner[i] = cOwner)
{
curRec := i;
break;
}
if curRec <> i then
Abort;
}
cmDoGetLast:
{
for (i:=20; i>=11; i:=i-1)
if (myOwner[i] = cOwner)
{
curRec := i;
break;
}
if curRec <> i then
Abort;
}
cmGetAddr:
ReturnPosition(curRec);
cmGetDirect:
curRec:=SetPosition;
cmDoFind:
{
var c : integer;
c := comp(SearchValue);
if (c < 11) or (c > 20) or (integer(c) <> c) then
{
Abort;
exit;
}
curRec := c;
}
cmInit:
{
cOwner := 0;
curRec := 11;
for (i:=11; i<=20; i:=i+1)
{
info[i] := 'Информация #' + String(i);
myNumber[i] := i;
}
myOwner[11]:=2;
myOwner[12]:=2;
myOwner[13]:=3;
myOwner[14]:=5;
myOwner[15]:=5;
myOwner[16]:=14;
myOwner[17]:=15;
myOwner[18]:=15;
myOwner[19]:=16;
myOwner[20]:=19;
}
cmTreeNeedOwner :
{
case (TreeGetNodeTable(myTree)) of
#T1:
TreeJumpToRecord(myTree, T1.CAAA);
tnNoTable:
{
if myOwner[curRec] < 11 then
TreeJumpToRecordEx(myTree, #T1, myOwner[curRec])
else
TreeJumpToRecord(myTree, myOwner[curRec]);
}
end;
}
cmTreeNodeType :
{
if (TreeGetNodeTable(myTree) = tnNoTable) then
case curRec of
11, 12, 13, 17, 18, 20:
TreeSetNodeType(myTree, 2);
end;
}
end;
end