2021-05-23 11:43:28 +02:00
|
|
|
(*
|
2023-04-13 21:16:45 +02:00
|
|
|
Copyright 2016, 2018, 2020-2023 Anton Krotov
|
2021-05-23 11:43:28 +02:00
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU Lesser General Public License as published by
|
|
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU Lesser General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Lesser General Public License
|
|
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*)
|
|
|
|
|
|
|
|
MODULE OpenDlg;
|
|
|
|
|
2022-01-16 08:18:30 +01:00
|
|
|
IMPORT sys := SYSTEM;
|
2021-05-23 11:43:28 +02:00
|
|
|
|
|
|
|
CONST
|
|
|
|
topen* = 0;
|
|
|
|
tsave* = 1;
|
|
|
|
tdir* = 2;
|
|
|
|
|
2023-04-13 21:16:45 +02:00
|
|
|
libName = "proc_lib.obj";
|
|
|
|
|
2021-05-23 11:43:28 +02:00
|
|
|
TYPE
|
|
|
|
|
|
|
|
DRAW_WINDOW = PROCEDURE;
|
|
|
|
|
|
|
|
tFilterArea = POINTER TO RECORD
|
|
|
|
size: INTEGER;
|
|
|
|
filter: ARRAY 4096 OF CHAR
|
|
|
|
END;
|
|
|
|
|
|
|
|
TDialog = RECORD
|
|
|
|
_type*,
|
|
|
|
procinfo,
|
|
|
|
com_area_name,
|
|
|
|
com_area,
|
|
|
|
opendir_path,
|
|
|
|
dir_default_path,
|
|
|
|
start_path: INTEGER;
|
|
|
|
draw_window: DRAW_WINDOW;
|
|
|
|
status*,
|
|
|
|
openfile_path,
|
|
|
|
filename_area: INTEGER;
|
|
|
|
filter_area: tFilterArea;
|
|
|
|
X, Y: INTEGER;
|
|
|
|
procinf: ARRAY 1024 OF CHAR;
|
|
|
|
s_com_area_name: ARRAY 32 OF CHAR;
|
|
|
|
s_opendir_path,
|
|
|
|
s_dir_default_path,
|
|
|
|
FilePath*,
|
|
|
|
FileName*: ARRAY 4096 OF CHAR
|
|
|
|
END;
|
|
|
|
|
|
|
|
Dialog* = POINTER TO TDialog;
|
|
|
|
|
|
|
|
VAR
|
|
|
|
|
|
|
|
filter_area: tFilterArea;
|
|
|
|
|
|
|
|
|
2023-04-13 21:16:45 +02:00
|
|
|
PROCEDURE [stdcall, libName, ""] OpenDialog_init (od: Dialog); END;
|
|
|
|
PROCEDURE [stdcall, libName, ""] OpenDialog_start (od: Dialog); END;
|
2022-01-16 08:18:30 +01:00
|
|
|
|
2021-05-23 11:43:28 +02:00
|
|
|
PROCEDURE Show*(od: Dialog; Width, Height: INTEGER);
|
|
|
|
BEGIN
|
|
|
|
IF od # NIL THEN
|
|
|
|
od.X := Width;
|
|
|
|
od.Y := Height;
|
2022-01-16 08:18:30 +01:00
|
|
|
OpenDialog_start(od)
|
2021-05-23 11:43:28 +02:00
|
|
|
END
|
|
|
|
END Show;
|
|
|
|
|
|
|
|
|
|
|
|
PROCEDURE replace (VAR str: ARRAY OF CHAR; c1, c2: CHAR);
|
|
|
|
VAR
|
|
|
|
i: INTEGER;
|
|
|
|
BEGIN
|
|
|
|
i := LENGTH(str) - 1;
|
|
|
|
WHILE i >= 0 DO
|
|
|
|
IF str[i] = c1 THEN
|
|
|
|
str[i] := c2
|
|
|
|
END;
|
|
|
|
DEC(i)
|
|
|
|
END
|
|
|
|
END replace;
|
|
|
|
|
|
|
|
|
|
|
|
PROCEDURE SetFilter* (dlg: Dialog; filter: ARRAY OF CHAR);
|
|
|
|
VAR
|
|
|
|
n, i: INTEGER;
|
|
|
|
BEGIN
|
|
|
|
IF filter = "" THEN
|
|
|
|
dlg.filter_area := NIL
|
|
|
|
ELSE
|
|
|
|
dlg.filter_area := filter_area;
|
|
|
|
filter_area.filter := filter;
|
|
|
|
n := LENGTH(filter_area.filter);
|
|
|
|
FOR i := 0 TO 3 DO
|
|
|
|
filter_area.filter[n + i] := "|"
|
|
|
|
END;
|
|
|
|
filter_area.filter[n + 4] := 0X;
|
|
|
|
filter_area.size := LENGTH(filter_area.filter);
|
|
|
|
replace(filter_area.filter, "|", 0X)
|
|
|
|
END
|
|
|
|
END SetFilter;
|
|
|
|
|
|
|
|
|
|
|
|
PROCEDURE Create*(draw_window: DRAW_WINDOW; _type: INTEGER; def_path, filter: ARRAY OF CHAR): Dialog;
|
|
|
|
VAR res: Dialog;
|
|
|
|
BEGIN
|
|
|
|
NEW(res);
|
|
|
|
IF res # NIL THEN
|
|
|
|
NEW(filter_area);
|
|
|
|
IF filter_area # NIL THEN
|
|
|
|
res.filter_area := filter_area;
|
|
|
|
res.s_com_area_name := "FFFFFFFF_open_dialog";
|
|
|
|
res.com_area := 0;
|
|
|
|
res._type := _type;
|
|
|
|
res.draw_window := draw_window;
|
|
|
|
COPY(def_path, res.s_dir_default_path);
|
|
|
|
SetFilter(res, filter);
|
|
|
|
res.X := 0;
|
|
|
|
res.Y := 0;
|
|
|
|
res.s_opendir_path := res.s_dir_default_path;
|
|
|
|
res.FilePath := "";
|
|
|
|
res.FileName := "";
|
|
|
|
res.status := 0;
|
|
|
|
res.procinfo := sys.ADR(res.procinf[0]);
|
|
|
|
res.com_area_name := sys.ADR(res.s_com_area_name[0]);
|
2022-01-05 21:32:53 +01:00
|
|
|
res.start_path := sys.SADR("/sys/File managers/opendial");
|
2021-05-23 11:43:28 +02:00
|
|
|
res.opendir_path := sys.ADR(res.s_opendir_path[0]);
|
|
|
|
res.dir_default_path := sys.ADR(res.s_dir_default_path[0]);
|
|
|
|
res.openfile_path := sys.ADR(res.FilePath[0]);
|
|
|
|
res.filename_area := sys.ADR(res.FileName[0]);
|
2022-01-16 08:18:30 +01:00
|
|
|
OpenDialog_init(res)
|
2021-05-23 11:43:28 +02:00
|
|
|
ELSE
|
|
|
|
DISPOSE(res)
|
|
|
|
END
|
|
|
|
END
|
|
|
|
RETURN res
|
|
|
|
END Create;
|
|
|
|
|
|
|
|
PROCEDURE Destroy*(VAR od: Dialog);
|
|
|
|
BEGIN
|
|
|
|
IF od # NIL THEN
|
|
|
|
DISPOSE(od.filter_area);
|
|
|
|
DISPOSE(od)
|
|
|
|
END
|
|
|
|
END Destroy;
|
|
|
|
|
|
|
|
|
|
|
|
END OpenDlg.
|