FB2 Reader: fixed rolling up

git-svn-id: svn://kolibrios.org@9912 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
Anton Krotov 2023-04-11 21:53:43 +00:00
parent 7028e04565
commit 21c201190a
4 changed files with 90 additions and 54 deletions

Binary file not shown.

View File

@ -119,6 +119,7 @@ VAR
sb: box_lib.scrollbar; sb: box_lib.scrollbar;
urlstr* : S.STRING; urlstr* : S.STRING;
DrawStatus, DrawToolbar: PROCEDURE; DrawStatus, DrawToolbar: PROCEDURE;
win_size_x, win_size_y: INTEGER;
PROCEDURE PushRef(ref: XML.TAG); PROCEDURE PushRef(ref: XML.TAG);
@ -1543,7 +1544,7 @@ END CleanHistory;
PROCEDURE Save; PROCEDURE Save;
VAR history: File.FS; win_size_x, win_size_y, size, pos: INTEGER; VAR history: File.FS; size, pos: INTEGER;
PROCEDURE WriteInt(history: File.FS; x: INTEGER); PROCEDURE WriteInt(history: File.FS; x: INTEGER);
BEGIN BEGIN
@ -1578,7 +1579,6 @@ BEGIN
IF File.WriteChar(history, 0X) THEN END; IF File.WriteChar(history, 0X) THEN END;
WriteInt(history, fsize2); WriteInt(history, fsize2);
WriteInt(history, chksum); WriteInt(history, chksum);
SU.GetWindowSize(win_size_x, win_size_y);
WriteInt(history, win_size_x); WriteInt(history, win_size_x);
WriteInt(history, win_size_y); WriteInt(history, win_size_y);
WriteInt(history, Settings.PADDING.LRpc); WriteInt(history, Settings.PADDING.LRpc);
@ -1792,6 +1792,13 @@ BEGIN
END Set_b_pict; END Set_b_pict;
PROCEDURE SetWinSize* (x, y: INTEGER);
BEGIN
win_size_x := x;
win_size_y := y
END SetWinSize;
BEGIN BEGIN
clickRef := NIL; clickRef := NIL;
hoverRef := NIL; hoverRef := NIL;

View File

@ -121,25 +121,30 @@ END DrawStatus;
PROCEDURE DrawWindow; PROCEDURE DrawWindow;
BEGIN BEGIN
SU.GetSystemColors; SU.GetSystemColors;
SU.WindowRedrawStatus(1); SU.WindowRedrawStatus(1);
IF Window.created THEN IF Window.created THEN
Resize IF ~SU.RolledUp() THEN
ELSE Resize;
Window.created := TRUE DOM.SetWinSize(Window.width, Window.height)
END; END
SU.DefineAndDrawWindow(Window.left, Window.top, Window.width, Window.height, ELSE
SU.winColor, LSL(ORD({0, 1, 2}), 4) + 4 - ORD(DOM.loaded), Window.caption); Window.created := TRUE
SU.DrawRect(0, 0, Window.width - 2 * WINDOW_BEVEL - 1, CANVAS_TOP, SU.winColor); END;
SU.DrawRect(0, Window.height - SkinHeight - WINDOW_BEVEL - STATUSBAR_HEIGHT + 1, Window.width - 2 * WINDOW_BEVEL - 1, STATUSBAR_HEIGHT, SU.winColor); SU.DefineAndDrawWindow(Window.left, Window.top, Window.width, Window.height,
SU.DrawRect(0, 0, CANVAS_LEFT, Window.height - SkinHeight - WINDOW_BEVEL, SU.winColor); SU.winColor, LSL(ORD({0, 1, 2}), 4) + 4 - ORD(DOM.loaded), Window.caption);
SU.DrawRect(Window.width - 2 * WINDOW_BEVEL - CANVAS_LEFT - 1 - SCROLLBAR_WIDTH - 2, 0, CANVAS_LEFT + SCROLLBAR_WIDTH + 2, Window.height - SkinHeight - WINDOW_BEVEL, SU.winColor); IF ~SU.RolledUp() THEN
IF DOM.loaded THEN SU.DrawRect(0, 0, Window.width - 2 * WINDOW_BEVEL - 1, CANVAS_TOP, SU.winColor);
ToolBar; SU.DrawRect(0, Window.height - SkinHeight - WINDOW_BEVEL - STATUSBAR_HEIGHT + 1, Window.width - 2 * WINDOW_BEVEL - 1, STATUSBAR_HEIGHT, SU.winColor);
DOM.Draw; SU.DrawRect(0, 0, CANVAS_LEFT, Window.height - SkinHeight - WINDOW_BEVEL, SU.winColor);
DrawStatus SU.DrawRect(Window.width - 2 * WINDOW_BEVEL - CANVAS_LEFT - 1 - SCROLLBAR_WIDTH - 2, 0, CANVAS_LEFT + SCROLLBAR_WIDTH + 2, Window.height - SkinHeight - WINDOW_BEVEL, SU.winColor);
END; IF DOM.loaded THEN
SU.WindowRedrawStatus(2) ToolBar;
DOM.Draw;
DrawStatus
END
END;
SU.WindowRedrawStatus(2)
END DrawWindow; END DrawWindow;
@ -270,7 +275,10 @@ END IsFB2;
PROCEDURE main(title: ARRAY OF CHAR); PROCEDURE main(title: ARRAY OF CHAR);
VAR WinW, X1, Y1, X2, Y2, scr_pos: INTEGER; Win2: W.tWindow; resize: BOOLEAN; FilePath: S.STRING; defpath: BOOLEAN; VAR
WinW, X1, Y1, X2, Y2, scr_pos, ignore: INTEGER;
Win2: W.tWindow; resize: BOOLEAN;
FilePath: S.STRING; defpath: BOOLEAN;
BEGIN BEGIN
SkinHeight := SU.SkinHeight(); SkinHeight := SU.SkinHeight();
sb := box_lib.kolibri_new_scrollbar(10 * 65536 + 200, 10 * 65536 + 30, 25, 15, 10, 0, 0, 0, 0, 0); sb := box_lib.kolibri_new_scrollbar(10 * 65536 + 200, 10 * 65536 + 30, 25, 15, 10, 0, 0, 0, 0, 0);
@ -302,7 +310,8 @@ BEGIN
SU.SetEventsMask({0, 1, 2, 5, 31}); SU.SetEventsMask({0, 1, 2, 5, 31});
SU.GetScreenArea(X1, Y1, X2, Y2); SU.GetScreenArea(X1, Y1, X2, Y2);
WinW := (X2 - X1) DIV 2; WinW := (X2 - X1) DIV 2;
W.init(Window, WinW DIV 2, Y1, WinW, Y2 - Y1, title); SU.MinMax(WinW, 640, 65535);
W.init(Window, (X2 - X1 - WinW) DIV 2, Y1, WinW, Y2 - Y1, title);
Settings.Default; Settings.Default;
DOM.GetWinSize(FileName, Window.width, Window.height); DOM.GetWinSize(FileName, Window.width, Window.height);
@ -329,41 +338,52 @@ BEGIN
S.Append(Window.caption, FileName); S.Append(Window.caption, FileName);
Toolbar.create(toolbar, TOOLBAR_LEFT, TOOLBAR_TOP); Toolbar.create(toolbar, TOOLBAR_LEFT, TOOLBAR_TOP);
Toolbar.add(toolbar, BACK, 30, ""); Toolbar.add(toolbar, BACK, 30, "");
Toolbar.add(toolbar, FORWARD, 31, ""); Toolbar.add(toolbar, FORWARD, 31, "");
Toolbar.delimiter(toolbar); Toolbar.delimiter(toolbar);
Toolbar.add(toolbar, CONTENTS, 3, ""); Toolbar.add(toolbar, CONTENTS, 3, "");
Toolbar.delimiter(toolbar); Toolbar.delimiter(toolbar);
Toolbar.add(toolbar, SEARCH, 49, ""); Toolbar.add(toolbar, SEARCH, 49, "");
Toolbar.delimiter(toolbar); Toolbar.delimiter(toolbar);
Toolbar.add(toolbar, DESCR, 66, ""); Toolbar.add(toolbar, DESCR, 66, "");
Toolbar.delimiter(toolbar); Toolbar.delimiter(toolbar);
Toolbar.add(toolbar, SETTINGS, 60, ""); Toolbar.add(toolbar, SETTINGS, 60, "");
DOM.Open(FileName, DrawWindow, DrawStatus, DrawToolbar); DOM.Open(FileName, DrawWindow, DrawStatus, DrawToolbar);
IF resize THEN IF resize THEN
DOM.Resize(Window.width - 2 * CANVAS_LEFT - 2 * WINDOW_BEVEL - 1 - SCROLLBAR_WIDTH, Window.height - SkinHeight - CANVAS_TOP - WINDOW_BEVEL + 1 - STATUSBAR_HEIGHT) DOM.Resize(Window.width - 2 * CANVAS_LEFT - 2 * WINDOW_BEVEL - 1 - SCROLLBAR_WIDTH,
END; Window.height - SkinHeight - CANVAS_TOP - WINDOW_BEVEL + 1 - STATUSBAR_HEIGHT)
END;
DrawWindow; DrawWindow;
scr_pos := sb.position; scr_pos := sb.position;
WHILE TRUE DO WHILE TRUE DO
CASE SU.WaitForEvent() OF CASE SU.WaitForEvent() OF
|1 : DrawWindow |1 : DrawWindow
|2 : KeyDown |2 :
|3 : ButtonClick IF ~SU.RolledUp() THEN
|6 : box_lib.scrollbar_v_mouse(sb); KeyDown
IF sb.position # scr_pos THEN ELSE
DOM.ScrollBar; ignore := SU.GetKey()
DOM.Draw; END
scr_pos := sb.position; |3 : ButtonClick
END; |6 :
MouseEvent IF ~SU.RolledUp() THEN
END box_lib.scrollbar_v_mouse(sb);
END IF sb.position # scr_pos THEN
DOM.ScrollBar;
DOM.Draw;
scr_pos := sb.position;
END;
MouseEvent
ELSE
ignore := SU.MouseVScroll()
END
END
END
END main; END main;
BEGIN BEGIN
main("FB2 Reader v0.97a") main("FB2 Reader v0.97c")
END FB2READ. END FB2READ.

View File

@ -377,4 +377,13 @@ BEGIN
END GetSystemColors; END GetSystemColors;
PROCEDURE RolledUp* (): BOOLEAN;
VAR
buffer: ARRAY 1024 OF BYTE;
BEGIN
K.sysfunc3(9, sys.ADR(buffer[0]), -1)
RETURN ODD(LSR(buffer[70], 2))
END RolledUp;
END SysUtils. END SysUtils.