include "draw.s7i";
include "text.s7i";
const type: graph_file is sub null_file struct
var PRIMITIVE_WINDOW: win is PRIMITIVE_WINDOW.value;
var integer: line_delta is 0;
var integer: column_delta is 0;
var integer: height is 0;
var integer: width is 0;
var integer: line is 0;
var integer: column is 0;
var integer: min_x is 0;
var integer: min_y is 0;
var integer: lineStartX is 0;
var integer: curr_x is 0;
var integer: curr_y is 0;
var color: foreground is white;
var color: background is black;
end struct;
type_implements_interface(graph_file, text);
const func graph_file: open (in PRIMITIVE_WINDOW: graphWin) is func
result
var graph_file: aGraphFile is graph_file.value;
begin
aGraphFile.win := graphWin;
aGraphFile.line_delta := 13;
aGraphFile.column_delta := 6;
aGraphFile.height := height(graphWin) div aGraphFile.line_delta;
aGraphFile.width := width(graphWin) div aGraphFile.column_delta;
aGraphFile.line := 1;
aGraphFile.column := 1;
aGraphFile.min_x := 0;
aGraphFile.min_y := 0;
aGraphFile.lineStartX := 0;
aGraphFile.curr_x := 0;
aGraphFile.curr_y := 11;
end func;
const func graph_file: open (in PRIMITIVE_WINDOW: graphWin,
in integer: minX, in integer: minY) is func
result
var graph_file: aGraphFile is graph_file.value;
begin
aGraphFile.win := graphWin;
aGraphFile.line_delta := 13;
aGraphFile.column_delta := 6;
aGraphFile.height := (height(graphWin) - minY) div aGraphFile.line_delta;
aGraphFile.width := (width(graphWin) - minX) div aGraphFile.column_delta;
aGraphFile.line := 1;
aGraphFile.column := 1;
aGraphFile.min_x := minX;
aGraphFile.min_y := minY;
aGraphFile.lineStartX := minX;
aGraphFile.curr_x := minX;
aGraphFile.curr_y := minY + 11;
end func;
const func graph_file: open (in PRIMITIVE_WINDOW: graphWin,
in integer: minX, in integer: minY, in integer: width, in integer: height) is func
result
var graph_file: aGraphFile is graph_file.value;
begin
aGraphFile.win := graphWin;
aGraphFile.line_delta := 13;
aGraphFile.column_delta := 6;
aGraphFile.height := height div aGraphFile.line_delta;
aGraphFile.width := width div aGraphFile.column_delta;
aGraphFile.line := 1;
aGraphFile.column := 1;
aGraphFile.min_x := minX;
aGraphFile.min_y := minY;
aGraphFile.lineStartX := minX;
aGraphFile.curr_x := minX;
aGraphFile.curr_y := minY + 11;
end func;
const func graph_file: open (in PRIMITIVE_WINDOW: graphWin, in integer: lin_delta) is func
result
var graph_file: aGraphFile is graph_file.value;
begin
aGraphFile.win := graphWin;
aGraphFile.line_delta := lin_delta;
aGraphFile.column_delta := 6;
aGraphFile.height := height(graphWin) div aGraphFile.line_delta;
aGraphFile.width := width(graphWin) div aGraphFile.column_delta;
aGraphFile.line := 1;
aGraphFile.column := 1;
aGraphFile.min_x := 0;
aGraphFile.min_y := 0;
aGraphFile.lineStartX := 0;
aGraphFile.curr_x := 0;
aGraphFile.curr_y := 11;
end func;
const proc: close (inout graph_file: aGraphFile) is func
begin
aGraphFile.win := PRIMITIVE_WINDOW.value;
end func;
const proc: flush (in graph_file: aGraphFile) is func
begin
flushGraphic;
end func;
const proc: color (inout graph_file: aGraphFile, in color: col) is func
begin
aGraphFile.foreground := col;
end func;
const proc: color (inout graph_file: aGraphFile, in color: col1, in color: col2) is func
begin
aGraphFile.foreground := col1;
aGraphFile.background := col2;
end func;
const func integer: height (in graph_file: aGraphFile) is
return aGraphFile.height;
const func integer: width (in graph_file: aGraphFile) is
return aGraphFile.width;
const func integer: line (in graph_file: aGraphFile) is
return aGraphFile.line;
const func integer: column (in graph_file: aGraphFile) is
return aGraphFile.column;
const proc: clear (inout graph_file: aGraphFile,
in integer: upper, in integer: left, in integer: lower, in integer: right) is func
begin
rectTo(aGraphFile.win,
aGraphFile.min_x + aGraphFile.column_delta * pred(left),
aGraphFile.min_y + aGraphFile.line_delta * pred(upper),
aGraphFile.min_x + pred(aGraphFile.column_delta * right),
aGraphFile.min_y + pred(aGraphFile.line_delta * lower),
aGraphFile.background);
aGraphFile.line := upper;
aGraphFile.column := left;
aGraphFile.lineStartX := aGraphFile.min_x;
aGraphFile.curr_x := aGraphFile.min_x + aGraphFile.column_delta * left - 6;
aGraphFile.curr_y := aGraphFile.min_y + aGraphFile.line_delta * upper - 2;
end func;
const proc: clear (inout graph_file: aGraphFile) is func
begin
clear(aGraphFile, 1, 1, height(aGraphFile), width(aGraphFile));
end func;
const proc: cursor (ref graph_file: aGraphFile, ref boolean: active) is noop;
const proc: v_scroll (inout graph_file: aGraphFile,
in integer: upper, in integer: left, in integer: lower, in integer: right,
in integer: count) is func
begin
if count > 0 then
copyArea(aGraphFile.win, aGraphFile.win,
aGraphFile.min_x + aGraphFile.column_delta * pred(left),
aGraphFile.min_y + aGraphFile.line_delta * pred(upper + count),
aGraphFile.column_delta * succ(right - left),
aGraphFile.line_delta * succ(lower - upper - count),
aGraphFile.min_x + aGraphFile.column_delta * pred(left),
aGraphFile.min_y + aGraphFile.line_delta * pred(upper));
rect(aGraphFile.win,
aGraphFile.min_x + aGraphFile.column_delta * pred(left),
aGraphFile.min_y + aGraphFile.line_delta * (lower - count),
aGraphFile.column_delta * succ(right - left),
aGraphFile.line_delta * count,
black);
elsif count < 0 then
copyArea(aGraphFile.win, aGraphFile.win,
aGraphFile.min_x + aGraphFile.column_delta * pred(left),
aGraphFile.min_y + aGraphFile.line_delta * pred(upper),
aGraphFile.column_delta * succ(right - left),
aGraphFile.line_delta * succ(lower - upper + count),
aGraphFile.min_x + aGraphFile.column_delta * pred(left),
aGraphFile.min_y + aGraphFile.line_delta * pred(upper - count));
end if;
end func;
const proc: h_scroll (ref graph_file: aGraphFile,
in integer: upper, in integer: left, in integer: lower, in integer: right,
in integer: count) is func
begin
noop;
end func;
const proc: setPos (inout graph_file: aGraphFile, in integer: line, in integer: column) is func
begin
aGraphFile.line := line;
aGraphFile.column := column;
aGraphFile.lineStartX := aGraphFile.min_x;
aGraphFile.curr_x := aGraphFile.min_x + aGraphFile.column_delta * column - 6;
aGraphFile.curr_y := aGraphFile.min_y + aGraphFile.line_delta * line - 2;
end func;
const proc: setPosXY (inout graph_file: aGraphFile, in integer: xPos, in integer: yPos) is func
begin
aGraphFile.lineStartX := aGraphFile.min_x + xPos;
aGraphFile.curr_x := aGraphFile.min_x + xPos;
aGraphFile.curr_y := aGraphFile.min_y + yPos;
aGraphFile.line := (aGraphFile.curr_y + 2) div aGraphFile.line_delta;
aGraphFile.column := (aGraphFile.curr_x + 6) div aGraphFile.column_delta;
end func;
const proc: setLine (inout graph_file: aGraphFile, in integer: line) is func
begin
aGraphFile.line := line;
aGraphFile.curr_y := aGraphFile.min_y + aGraphFile.line_delta * line - 2;
end func;
const proc: setColumn (inout graph_file: aGraphFile, in integer: column) is func
begin
aGraphFile.column := column;
aGraphFile.curr_x := aGraphFile.min_x + aGraphFile.column_delta * column - 6;
end func;
const proc: write (inout graph_file: aGraphFile, in string: stri) is func
begin
DRAW_TEXT(aGraphFile.win, aGraphFile.curr_x, aGraphFile.curr_y, stri,
colorPixel(aGraphFile.foreground), colorPixel(aGraphFile.background));
aGraphFile.column +:= length(stri);
aGraphFile.curr_x +:= aGraphFile.column_delta * length(stri);
end func;
const proc: writeln (inout graph_file: aGraphFile) is func
begin
incr(aGraphFile.line);
aGraphFile.column := 1;
aGraphFile.curr_x := aGraphFile.lineStartX;
aGraphFile.curr_y +:= aGraphFile.line_delta;
end func;
const proc: moveLeft (inout graph_file: aGraphFile, in string: stri) is func
begin
aGraphFile.column -:= length(stri);
aGraphFile.curr_x -:= aGraphFile.column_delta * length(stri);
end func;
const proc: erase (inout graph_file: aGraphFile, in string: stri) is func
begin
DRAW_TEXT(aGraphFile.win, aGraphFile.curr_x, aGraphFile.curr_y, "" lpad length(stri),
colorPixel(aGraphFile.foreground), colorPixel(aGraphFile.background));
aGraphFile.column +:= length(stri);
aGraphFile.curr_x +:= aGraphFile.column_delta * length(stri);
end func;
const proc: cursorOn (inout graph_file: aGraphFile, in char: cursorChar) is func
begin
DRAW_TEXT(aGraphFile.win, aGraphFile.curr_x, aGraphFile.curr_y, str(cursorChar),
colorPixel(aGraphFile.background), colorPixel(aGraphFile.foreground));
end func;
const proc: cursorOff (inout graph_file: aGraphFile, in char: cursorChar) is func
begin
DRAW_TEXT(aGraphFile.win, aGraphFile.curr_x, aGraphFile.curr_y, str(cursorChar),
colorPixel(aGraphFile.foreground), colorPixel(aGraphFile.background));
end func;
const proc: box (ref graph_file: aGraphFile) is noop;
const proc: clear_box (ref graph_file: aGraphFile) is noop;