//=========================================================
const
cmExport = 6001;
cmImport = 6002;
cmChangeImage1 = 6003;
cmChangeImage2 = 6004;
cmStoreToDsk = 6005;
cmLoadFromDsk = 6006;
cmChForamt = 6007;
cmDelSel = 6008;
end;
//=========================================================
#include marker.vih
#include test_marker.tb
//=========================================================
vipInterface MyMarker (Marker);
public:
procedure IMarker.MarkUnMark; // Перегруженные методы
procedure IMarker.Mark; //
procedure IMarker.UnMark; //
procedure IMarker.UnselectAll; //
procedure IMarker.SelectAll; //
end;
//=========================================================
interface MyMarker;
//---------------------------------------------------------
procedure MarkUnMark;
{
inherited::MarkUnMark;
}
//---------------------------------------------------------
procedure Mark;
{
inherited::Mark;
}
//---------------------------------------------------------
procedure UnMark;
{
inherited::UnMark;
}
//---------------------------------------------------------
procedure SelectAll;
{
inherited::SelectAll;
}
//---------------------------------------------------------
procedure UnselectAll;
{
inherited::UnselectAll;
}
end.
//=========================================================
interface MarkerDemo 'Использование маркеров' (,,scInterface) escClose;
toolBar MyToolBar;
//---------------------------------------------------------
table struct MyTable
(
nRec : comp,
wCode: word, // код
sName: string, // наименование
pole1: string, // просто так
Npp : word
)
with index
(
MyTable0 = nRec(Unique,Surrogate)
);
//---------------------------------------------------------
table struct MyTableMy
(
nRec : comp,
wCode: word, // код
sName: string, // наименование
pole1: string, // просто так
Npp : word
)
with index
(
MyTableMy0 = nRec(Unique,Surrogate)
);
//---------------------------------------------------------
table struct MyTableM
(
nRec : comp,
wCode: word, // код
sName: string, // наименование
pole1: string,
Npp : word
)
with index
(
MyTableM0 = nRec(Unique,Surrogate)
);
//---------------------------------------------------------
var
pMarker : IMarker(marker) new;
pMyMarker : IMarker(myMarker) new;
//---------------------------------------------------------
create view TestMarker
var
number: word;
marker : longint; // указатель на маркер
ind : longint; // индекс маркера
switch : word;
markerCount, i : longint; // счетчики записей в маркере
(
picked
)
as select
if(SearchMarker(marker, MyTableM.nRec, ind), 'V', ''), *
from
MyTable, MyTableM, MyTableMy
;
//---------------------------------------------------------
function MyTable_Add(add_n: word): boolean;
{
number := number + add_n;
ClearBuffer(#MyTable);
MyTable.wCode := add_n;
MyTable.sName := 'String N ' + String(add_n);
MyTable.pole1 := 'Pole N ' + String(add_n);
MyTable.Npp := number;
if insert current MyTable <> tsOk
{
message(''#3'Ошибка добавления записи в таблицу MyTable');
MyTable_Add := false;
}
else
MyTable_Add := true;
}
//---------------------------------------------------------
function MyTableMy_Add(add_n: word): boolean;
{
number := number + add_n;
ClearBuffer(#MyTableMy);
MyTableMy.wCode := add_n;
MyTableMy.sName := 'String N ' + String(add_n);
MyTableMy.pole1 := 'Pole N ' + String(add_n);
MyTableMy.Npp := number;
if insert current MyTableMy <> tsOk
{
message(''#3'Ошибка добавления записи в таблицу MyTableMy');
MyTableMy_Add := false;
}
else
MyTableMy_Add := true;
}
//---------------------------------------------------------
function MyTableM_Add(add_n: word): boolean;
{
number := number + add_n;
ClearBuffer(#MyTableM);
MyTableM.wCode := add_n;
MyTableM.sName := 'String N ' + String(add_n);
MyTableM.pole1 := 'Pole N ' + String(add_n);
MyTableM.Npp := number;
if insert current MyTableM <> tsOk
{
message(''#3'Ошибка добавления записи в таблицу MyTableM');
MyTableM_Add := false;
}
else
MyTableM_Add := true;
}
//---------------------------------------------------------
function MyTable_Fill: boolean;
{
var i : integer;
MyTable_Fill := false;
for (i := 0; i < 300; )
begin
MyTable_Add(i)
MyTableMy_Add(i)
MyTableM_Add(i)
i := i + 1;
end;
MyTable_Fill := true;
// перейдем на начало
if getfirst MyTable <> tsOk {};
if getfirst MyTableM <> tsOk {};
if getfirst MyTableMy <> tsOk {};
}
//---------------------------------------------------------
screen ScrUpTitle;
show at (,,,1);
<<
Броузер с автоматизированной пометкой записей
>>
end; // screen ScrUpTitle
//---------------------------------------------------------
browse brAutoMark 'AutoMarkerBrouse';
show at (,2,,10);
table MyTable;
recMarker = pMarker {MyTable.nRec};
fields
MyTable.nRec
'NREC'
('NREC ',,)
: [3], protect;
MyTable.Npp
'Nпп'
('Номер ',,)
: [3], protect;
MyTable.sName
'Наименование'
('Наименование',,)
: [10];
MyTable.pole1
'Текст'
('Просто текст',,)
: [10];
MyTable.wCode
'Код'
('Код ',,)
: [3], protect;
pMarker.pNRec
'NRECM'
('NRECM ',,)
: [10], protect;
end; // browse brAutoMark
//---------------------------------------------------------
browse brAutoMark2 'AutoMarkerBrouse2';
show at (,2,,10);
table MyTableM;
recMarker {MyTableM.nRec};
fields
MyTableM.nRec
'NREC'
('NREC ',,)
: [3], protect;
MyTableM.Npp
'Nпп'
('Номер ',,)
: [3], protect;
MyTableM.sName
'Наименование'
('Наименование',,)
: [10];
end; // browse brAutoMark2
//---------------------------------------------------------
browse brAutoMark3 'AutoMarkerInherited';
show at (,2,,10);
table MyTableMy;
recMarker = pMyMarker;
fields
MyTableMy.nRec
'NREC'
('NREC ',,)
: [3], protect;
MyTableMy.Npp
'Nпп'
('Номер ',,)
: [3], protect;
MyTableMy.sName
'Наименование'
('Наименование',,)
: [10];
end; // browse brAutoMark3
//---------------------------------------------------------
screen ScrMidleTitle;
show at (,11,,12);
<<
Броузер с ручной пометкой записей
>>
end; //screen ScrMidleTitle
//---------------------------------------------------------
browse brManual 'MarkerManualBrouse';
show at (,13,,20);
table MyTableM;
recMarker : if (picked = '','', 'bmTest1' );
fields
{Font = {Color = if(picked = '', 0, 3) }};
picked
'V'
: [1], skip;
MyTableM.nRec
'NREC'
('NREC ',,)
: [3], protect;
MyTableM.Npp
'Nпп'
('Номер ',,)
: [3], protect;
MyTableM.sName
'Наименование'
('Наименование',,)
: [10];
MyTableM.pole1
'Текст'
('Просто текст',,)
: [10];
MyTableM.wCode
'Код'
('Код ',,)
: [3], protect;
end; // browse brManual
//---------------------------------------------------------
screen scrButtonsTune
show at (,21,,);
fields
switch
('Переключатель формата',,)
: noprotect;
<<
(.) Броузер1 `
(.) Броузер2 `
(.) Inherited `
>>
end; // screen scrButtonsTune
//---------------------------------------------------------
procedure OneUnMarkPick;
{
DeleteMarker(marker, MyTableM.nRec)
}
//---------------------------------------------------------
procedure OneMarkPick;
{
InsertMarker(marker, MyTableM.nRec);
}
//---------------------------------------------------------
handleEvent
cmInit:
{
marker := 0;
number := 0;
MyTable_Fill;
Switch :=0;
marker:=InitMarker('TestMarker', 8, 100, 10);
pMarker.StoreName := 'TestName';
pMarker.Caption := (' Отмечено [%d] ');
pMyMarker.Caption := (' Отмечено [%d] ');
pMarker.AutoSave := True;
pMarker.LoadAuto := True;
SetFormat(brAutoMark);
}
cmCheckField :
{
case CurField of
#Switch :
{
if (switch = 0)
SetFormat(brAutoMark);
else if (switch = 2)
SetFormat(brAutoMark3);
else
SetFormat(brAutoMark2);
RescanPanel(#MyTable);
}
end;
}
cmStoreToDsk:
{
pMarker.StoreToDsk;
}
cmLoadFromDsk:
{
pMarker.LoadFromDsk;
ReReadRecord(#MyTable)
}
cmChangeImage1:
{
pMarker.ImageName := 'bmTest1';
RescanPanel(#MyTable);
}
cmChangeImage2:
{
pMarker.ImageName := 'bmTest2';
RescanPanel(#MyTable);
}
cmDone:
{
if (marker <> 0)
{
pMarker.ExportTo(marker);
DoneMarker(marker, 'TestMarker');
}
}
cmExport:
{
pMarker.ExportTo(marker); // Выгружаем в стандартный маркер
RescanPanel(#MyTableM);
}
cmImport:
{
pMarker.ImportFrom(marker); // Грузим из стандартного
RescanPanel(#MyTable);
}
cmSelAll:
{
if not updateTable
exit;
PushPos(#MyTableM);
_loop MyTableM OneMarkPick;
PopPos(#MyTableM);
RescanPanel(#MyTableM);
}
cmUnSelAll:
{
ClearMarker(marker);
RescanPanel(#MyTableM);
}
cmDoMarkUnMark: // Аналогично cmMarkUnMark в Галактике
{
if not updateTable
exit;
if SearchMarker(marker, MyTableM.nRec, ind)
OneUnMarkPick;
else
OneMarkPick;
if (getNext MyTableM = tsOk)
CallToNeighBours(#MyTableM, cmPosDown);
RescanPanel(#MyTableM);
}
cmDelSel:
{
pMarker.DeleteRec;
}
end; // handleEvent interface
end.