MODULE TeletextBrowser;
IMPORT
TeletextDecoder, KernelLog;
CONST
VbiUndefined = TeletextDecoder.VbiUndefined;
TYPE
TeletextPage* = OBJECT
END TeletextPage;
LoadProc* = PROCEDURE{DELEGATE}() : TeletextPage;
TeletextBrowser* = OBJECT
VAR
page-, subPage: LONGINT;
suite-: TeletextDecoder.TeletextSuite;
pgSet: TeletextDecoder.TeletextPageSet;
pgData*: TeletextDecoder.TeletextPage;
content*: TeletextPage;
channel-: ARRAY 33 OF CHAR;
refreshInterval*: LONGINT;
rotating*: BOOLEAN;
transparent*: BOOLEAN;
loadProc*: LoadProc;
PROCEDURE &Init*(suite: TeletextDecoder.TeletextSuite);
BEGIN
IF suite = NIL THEN
KernelLog.String("{TeletextBrowser.Init} Parameter 'suite' = NIL"); KernelLog.Ln;
RETURN
END;
SELF.suite := suite;
COPY(suite.channel.name, channel);
page := 0;
pgSet := suite.pages[page];
pgData := pgSet.data;
IF pgData # NIL THEN
subPage := pgData.subPageNo
END
END Init;
PROCEDURE HasSubpages*() : BOOLEAN;
BEGIN
IF pgData = NIL THEN
RETURN FALSE
END;
RETURN pgData # pgData.nextSub
END HasSubpages;
PROCEDURE SetSuite*(suite: TeletextDecoder.TeletextSuite);
BEGIN
Init(suite)
END SetSuite;
PROCEDURE SetSuiteFromFreq*(freq: LONGINT);
BEGIN
Init(TeletextDecoder.SelectTeletextSuite(freq))
END SetSuiteFromFreq;
PROCEDURE ReloadPage*() : TeletextPage;
VAR
sub: LONGINT;
tmp: TeletextPage;
BEGIN
sub := subPage;
BEGIN {EXCLUSIVE}
pgData := pgSet.data
END;
WHILE (pgData # NIL) & (sub # pgData.subPageNo) DO
tmp := GetNextSubpage()
END;
RETURN loadProc()
END ReloadPage;
PROCEDURE GetNextPage*() : TeletextPage;
BEGIN
page := pgSet.next;
IF page = VbiUndefined THEN
RETURN NIL
END;
pgSet := suite.pages[page];
BEGIN {EXCLUSIVE}
pgData := pgSet.data
END;
IF pgData # NIL THEN
subPage := pgData.subPageNo
END;
RETURN loadProc()
END GetNextPage;
PROCEDURE GetPreviousPage*() : TeletextPage;
BEGIN
page := pgSet.prev;
IF page = VbiUndefined THEN
RETURN NIL
END;
pgSet := suite.pages[page];
BEGIN {EXCLUSIVE}
pgData := pgSet.data
END;
IF pgData # NIL THEN
subPage := pgData.subPageNo
END;
RETURN loadProc()
END GetPreviousPage;
PROCEDURE GetNextSubpage*() : TeletextPage;
BEGIN
IF pgData = NIL THEN
RETURN NIL
END;
BEGIN {EXCLUSIVE}
pgData := pgData.nextSub
END;
subPage := pgData.subPageNo;
RETURN loadProc()
END GetNextSubpage;
PROCEDURE GetPreviousSubpage*() : TeletextPage;
BEGIN
IF pgData = NIL THEN
RETURN NIL
END;
BEGIN {EXCLUSIVE}
pgData := pgData.prevSub
END;
subPage := pgData.subPageNo;
RETURN loadProc()
END GetPreviousSubpage;
PROCEDURE GetPage*(page: LONGINT) : TeletextPage;
BEGIN
page := page - 100;
SELF.page := page;
IF (page < 0) OR (page >= 800) OR (suite = NIL) OR (suite.pages[page].data = NIL) THEN
BEGIN {EXCLUSIVE}
pgData := NIL
END
ELSE
pgSet := suite.pages[page];
BEGIN {EXCLUSIVE}
pgData := pgSet.data
END;
subPage := pgData.subPageNo
END;
RETURN loadProc()
END GetPage;
END TeletextBrowser;
END TeletextBrowser.
SystemTools.Free TeletextBrowser ~