Subversion Repositories Kolibri OS

Rev

Rev 9896 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 9896 Rev 9898
Line 1... Line 1...
1
(*
1
(*
2
    Copyright 2016, 2018, 2020-2022 Anton Krotov
2
    Copyright 2016, 2018, 2020-2023 Anton Krotov
Line 3... Line 3...
3
 
3
 
Line 4... Line 4...
4
    This file is part of fb2read.
4
    This file is part of fb2read.
5
 
5
 
Line 17... Line 17...
17
    along with fb2read. If not, see .
17
    along with fb2read. If not, see .
18
*)
18
*)
Line 19... Line 19...
19
 
19
 
Line 20... Line 20...
20
MODULE Settings;
20
MODULE Settings;
21
 
21
 
Line 22... Line 22...
22
IMPORT SU := SysUtils, W := Window, C := ColorDlg, DOM, S := Strings,
22
IMPORT SU := SysUtils, W := Window, C := ColorDlg, DOM, S := Strings, K := KOSAPI, File,
Line 54... Line 54...
54
  BtnW*     =       80;
54
  BtnW*     =       80;
Line 55... Line 55...
55
 
55
 
Line 56... Line 56...
56
 
56
 
57
VAR
57
VAR
58
 
58
 
59
  Window   : W.TWindow;
59
  Window   : W.tWindow;
60
  PID      : INTEGER;
60
  PID      : INTEGER;
Line 67... Line 67...
67
  sb       : ARRAY 7 OF box_lib.scrollbar;
67
  sb       : ARRAY 7 OF box_lib.scrollbar;
68
  check1   : box_lib.checkbox;
68
  check1   : box_lib.checkbox;
69
  check2   : box_lib.checkbox;
69
  check2   : box_lib.checkbox;
70
  OpenPict : OD.Dialog;
70
  OpenPict : OD.Dialog;
71
  picture  : INTEGER;
71
  picture  : INTEGER;
-
 
72
  picture_fsize : INTEGER;
Line 72... Line 73...
72
 
73
 
Line 73... Line 74...
73
  picture_path : S.STRING;
74
  picture_path : S.STRING;
74
 
75
 
75
 
76
 
76
PROCEDURE Close*;
77
PROCEDURE Close*;
77
VAR pid: INTEGER;
78
VAR pid: INTEGER;
78
BEGIN
79
BEGIN
79
  IF PID # 0 THEN
80
  IF PID # 0 THEN
80
    pid := PID;
81
    pid := PID;
-
 
82
    PID := 0;
81
    PID := 0;
83
    IF (picture # Data.Picture) & (picture # 0) THEN
82
    IF (picture # 0) & (picture # Data.Picture) THEN
84
    	picture := K.free(picture);
83
      LibImg.img_destroy(picture)
85
    	picture_fsize := 0
84
    END;
86
    END;
85
    C.Destroy(Color);
87
    C.Destroy(Color);
86
    OD.Destroy(OpenPict);
88
    OD.Destroy(OpenPict);
Line 87... Line 89...
87
    SU.TerminateThreadId(pid)
89
    SU.TerminateThreadId(pid)
88
  END
90
  END
89
END Close;
91
END Close;
90
 
92
 
Line 91... Line 93...
91
 
93
 
92
PROCEDURE ClearWindow;
94
PROCEDURE ClearWindow;
Line 128... Line 130...
128
VAR
130
VAR
Line 129... Line 131...
129
 
131
 
130
  X, Y, TextY       : INTEGER;
132
  X, Y, TextY       : INTEGER;
131
  WinW, WinH, SkinH : INTEGER;
133
  WinW, WinH, SkinH : INTEGER;
132
  i                 : INTEGER;
134
  i                 : INTEGER;
Line 133... Line 135...
133
  Rect              : W.TRect;
135
  Rect              : W.tRect;
134
 
136
 
135
BEGIN
137
BEGIN
136
  Rect.Left := 10;
138
  Rect.left := 10;
137
  Rect.Top := 85;
139
  Rect.top := 85;
138
  Rect.Width := 210;
140
  Rect.width := 210;
139
  Rect.Height := 255;
141
  Rect.height := 255;
Line 140... Line 142...
140
  SU.Box(Rect.Left, Rect.Top, Rect.Width, Rect.Height, SU.winColor, SU.borderColor);
142
  SU.Box(Rect.left, Rect.top, Rect.width, Rect.height, SU.winColor, SU.borderColor);
141
  SU.Box(Rect.Left + 230, Rect.Top, Rect.Width + 170, Rect.Height, SU.winColor, SU.borderColor);
143
  SU.Box(Rect.left + 230, Rect.top, Rect.width + 170, Rect.height, SU.winColor, SU.borderColor);
142
 
144
 
143
  WinW := Window.Width;
145
  WinW := Window.width;
144
  WinH := Window.Height;
146
  WinH := Window.height;
145
  SkinH := SU.SkinHeight();
147
  SkinH := SU.SkinHeight();
146
  X := 125;
148
  X := 125;
Line 176... Line 178...
176
  OutText(TextLeft + 230, Y, "epigraph");     PlusMinus(TextLeft + 330, Y - 6, MAX_EPIGRAPH,  0, sb[5]); Y := Y + BtnH + 10;
178
  OutText(TextLeft + 230, Y, "epigraph");     PlusMinus(TextLeft + 330, Y - 6, MAX_EPIGRAPH,  0, sb[5]); Y := Y + BtnH + 10;
177
  OutText(TextLeft + 230, Y, "line spacing"); PlusMinus(TextLeft + 330, Y - 6, MAX_InterLin,  0, sb[6]);
179
  OutText(TextLeft + 230, Y, "line spacing"); PlusMinus(TextLeft + 330, Y - 6, MAX_InterLin,  0, sb[6]);
Line 178... Line 180...
178
 
180
 
Line 179... Line 181...
179
  Y := Y - 6;
181
  Y := Y - 6;
180
 
182
 
Line 181... Line 183...
181
  SU.CreateButton(DAY,   (Rect.Width - (BtnW + 5 + BtnW)) DIV 2 + Rect.Left,                       Y, 80, BtnH, SU.btnColor, "Day"   );
183
  SU.CreateButton(DAY,   (Rect.width - (BtnW + 5 + BtnW)) DIV 2 + Rect.left,                       Y, 80, BtnH, SU.btnColor, "Day"   );
182
  SU.CreateButton(NIGHT, (Rect.Width - (BtnW + 5 + BtnW)) DIV 2 + Rect.Left + 5 + BtnW,            Y, 80, BtnH, SU.btnColor, "Night" );
184
  SU.CreateButton(NIGHT, (Rect.width - (BtnW + 5 + BtnW)) DIV 2 + Rect.left + 5 + BtnW,            Y, 80, BtnH, SU.btnColor, "Night" );
Line 183... Line 185...
183
 
185
 
Line 195... Line 197...
195
 
197
 
196
PROCEDURE DrawWindow;
198
PROCEDURE DrawWindow;
197
BEGIN
199
BEGIN
198
  SU.GetSystemColors;
200
  SU.GetSystemColors;
199
  SU.WindowRedrawStatus(1);
201
  SU.WindowRedrawStatus(1);
200
  SU.DefineAndDrawWindow(Window.Left, Window.Top, Window.Width, Window.Height,
202
  SU.DefineAndDrawWindow(Window.left, Window.top, Window.width, Window.height,
201
        SU.winColor, LSL(ORD({0, 1}), 4) + 4, Window.Caption);
203
        SU.winColor, LSL(ORD({0, 1}), 4) + 4, Window.caption);
202
  Buttons;
204
  Buttons;
203
  SU.WindowRedrawStatus(2)
205
  SU.WindowRedrawStatus(2)
Line 256... Line 258...
256
  Data.PADDING.CInt := sb[2].position;
258
  Data.PADDING.CInt := sb[2].position;
257
  Data.PADDING.Top  := sb[3].position;
259
  Data.PADDING.Top  := sb[3].position;
258
  Data.PARAGRAPH    := sb[4].position;
260
  Data.PARAGRAPH    := sb[4].position;
259
  Data.EPIGRAPH     := sb[5].position;
261
  Data.EPIGRAPH     := sb[5].position;
260
  Data.InterLin     := sb[6].position;
262
  Data.InterLin     := sb[6].position;
261
  IF Data.Picture # picture THEN
263
  IF (picture # 0) & (picture # Data.Picture) THEN
262
    IF Data.Picture # 0 THEN
264
  	IF Data.Picture # 0 THEN
263
      LibImg.img_destroy(Data.Picture)
265
    	Data.Picture := K.free(Data.Picture)
264
    END;
266
    END;
265
    Data.Picture := picture;
267
    Data.Picture := picture;
-
 
268
    Data.picture_fsize := picture_fsize;
266
    Ini.SetPicturePath(picture_path)
269
    Ini.SetPicturePath(picture_path)
267
  END;
270
  END;
268
  picture := 0;
271
  picture := 0;
-
 
272
  picture_fsize := 0;
269
  DOM.SetSettings(Data);
273
  DOM.SetSettings(Data);
270
  Close
274
  Close
271
END Apply;
275
END Apply;
Line 272... Line 276...
272
 
276
 
273
 
277
 
274
PROCEDURE LoadPicture(file_path: S.STRING);
278
PROCEDURE LoadPicture(file_path: S.STRING);
275
VAR ysize, img: INTEGER;
279
VAR fsize, img: INTEGER;
276
BEGIN
280
BEGIN
277
  img := LibImg.LoadFromFile(file_path, 10240000, ysize);
281
  img := File.Load(file_path, fsize);
278
  IF img # 0 THEN
282
  IF img # 0 THEN
279
    IF (picture # 0) & (picture # Data.Picture) THEN
283
    IF (picture # 0) & (picture # Data.Picture) THEN
280
      LibImg.img_destroy(picture)
284
      picture := K.free(picture)
-
 
285
    END;
281
    END;
286
    picture := img;
282
    picture := img;
287
    picture_fsize := fsize;
283
    picture_path := file_path
288
    picture_path := file_path
Line 333... Line 338...
333
  Data.PADDING.CInt := 6;
338
  Data.PADDING.CInt := 6;
334
  Data.PARAGRAPH    := 30;
339
  Data.PARAGRAPH    := 30;
335
  Data.EPIGRAPH     := 100;
340
  Data.EPIGRAPH     := 100;
336
  Data.InterLin     := 0;
341
  Data.InterLin     := 0;
337
  Data.Picture      := picture;
342
  Data.Picture      := picture;
-
 
343
  Data.picture_fsize := picture_fsize;
338
  DOM.SetSettings(Data)
344
  DOM.SetSettings(Data)
339
END Default;
345
END Default;
Line 340... Line 346...
340
 
346
 
341
 
347
 
342
PROCEDURE Show;
348
PROCEDURE Show;
343
VAR i, scrWidth, scrHeight: INTEGER;
349
VAR i, scrWidth, scrHeight: INTEGER;
344
BEGIN
350
BEGIN
345
  SU.SetEventsMask({0, 2, 5, 30, 31});
351
  SU.SetEventsMask({0, 2, 5, 30, 31});
346
  W.InitWindow(Window, 0, 0, 640, 420, "Settings");
352
  W.init(Window, 0, 0, 640, 420, "Settings");
347
  SU.GetScreenSize(scrWidth, scrHeight);
353
  SU.GetScreenSize(scrWidth, scrHeight);
348
  Window.Left := (scrWidth - Window.Width) DIV 2;
354
  Window.left := (scrWidth - Window.width) DIV 2;
349
  Window.Top  := (scrHeight - Window.Height) DIV 2;
355
  Window.top  := (scrHeight - Window.height) DIV 2;
350
  Color := C.Create(DrawWindow);
356
  Color := C.Create(DrawWindow);
351
  OpenPict := OD.Create(DrawWindow, 0, "/sys", "JPG|PNG|BMP|GIF");
357
  OpenPict := OD.Create(DrawWindow, 0, "/sys", "JPG|PNG|BMP|GIF");
-
 
358
  Data := DOM.Settings;
352
  Data := DOM.Settings;
359
  picture := Data.Picture;
353
  picture := Data.Picture;
360
  picture_fsize := Data.picture_fsize;
354
  DrawWindow;
361
  DrawWindow;
355
  WHILE TRUE DO
362
  WHILE TRUE DO
356
    CASE SU.WaitForEvent() OF
363
    CASE SU.WaitForEvent() OF
Line 407... Line 414...
407
  bpicture := "back picture";
414
  bpicture := "back picture";
408
  twocol := "two columns";
415
  twocol := "two columns";
409
  check2 := box_lib.kolibri_new_check_box(TextLeft, 10 + 5,               16, 16, sys.SADR(""), LENGTH(bpicture) * 8 + 5);
416
  check2 := box_lib.kolibri_new_check_box(TextLeft, 10 + 5,               16, 16, sys.SADR(""), LENGTH(bpicture) * 8 + 5);
410
  check1 := box_lib.kolibri_new_check_box(TextLeft, 10 + (BtnH + 10) + 5, 16, 16, sys.SADR(""), LENGTH(twocol)  * 8 + 5);
417
  check1 := box_lib.kolibri_new_check_box(TextLeft, 10 + (BtnH + 10) + 5, 16, 16, sys.SADR(""), LENGTH(twocol)  * 8 + 5);
411
  picture := 0;
418
  picture := 0;
-
 
419
  picture_fsize := 0;
412
  IF Ini.Picture # "" THEN
420
  IF Ini.Picture # "" THEN
413
    LoadPicture(Ini.Picture)
421
    LoadPicture(Ini.Picture)
414
  END
422
  END
415
END main;
423
END main;