Subversion Repositories Kolibri OS

Rev

Rev 9671 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
9522 akron1 1
(*
9915 akron1 2
    Copyright 2021-2023 Anton Krotov
9522 akron1 3
 
4
    This file is part of CEdit.
5
 
6
    CEdit is free software: you can redistribute it and/or modify
7
    it under the terms of the GNU General Public License as published by
8
    the Free Software Foundation, either version 3 of the License, or
9
    (at your option) any later version.
10
 
11
    CEdit is distributed in the hope that it will be useful,
12
    but WITHOUT ANY WARRANTY; without even the implied warranty of
13
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
    GNU General Public License for more details.
15
 
16
    You should have received a copy of the GNU General Public License
17
    along with CEdit. If not, see .
18
*)
19
 
20
MODULE StatusBar;
21
 
22
IMPORT G := Graph, U := Utils, K := KolibriOS;
23
 
24
TYPE
25
 
26
	tString = ARRAY 32 OF WCHAR;
27
 
28
	tStatusBar* = RECORD
29
 
30
		pos, sel, enc: tString;
31
		canvas: G.tCanvas
32
 
33
	END;
34
 
35
VAR
36
 
37
	SB: tStatusBar;
38
	font: G.tFont;
39
 
40
 
41
PROCEDURE setPos* (line, col: INTEGER);
42
VAR
43
	s1, s2: tString;
44
BEGIN
45
	U.int2str(line, s1);
46
	U.append(s1, ": ");
47
	U.int2str(col, s2);
48
	U.append(s1, s2);
49
	SB.pos := s1
50
END setPos;
51
 
52
 
9915 akron1 53
PROCEDURE setSel* (text: ARRAY OF WCHAR; first, second: INTEGER; delimiter: ARRAY OF WCHAR);
9522 akron1 54
VAR
55
	s1, s2: tString;
56
BEGIN
9915 akron1 57
	IF first # 0 THEN
58
		s1 := text;
59
		U.int2str(first, s2);
9522 akron1 60
		U.append(s1, s2);
9915 akron1 61
		U.append(s1, delimiter);
62
		U.int2str(second, s2);
9522 akron1 63
		U.append(s1, s2);
64
		SB.sel := s1
65
	ELSE
66
		SB.sel := ""
67
	END
68
END setSel;
69
 
70
 
71
PROCEDURE setEnc* (eol, enc: ARRAY OF WCHAR);
72
BEGIN
73
	SB.enc := eol;
74
	U.append(SB.enc, 20X + 20X);
75
	U.append(SB.enc, enc)
76
END setEnc;
77
 
78
 
9668 akron1 79
PROCEDURE height* (): INTEGER;
80
	RETURN font.height + 3
81
END height;
82
 
83
 
9522 akron1 84
PROCEDURE setWidth* (width: INTEGER);
85
BEGIN
86
	ASSERT(width > 0);
9668 akron1 87
	IF (SB.canvas = NIL) OR (SB.canvas.width # width) OR (SB.canvas.height # height()) THEN
9522 akron1 88
		G.destroy(SB.canvas);
9668 akron1 89
		SB.canvas := G.CreateCanvas(width, height());
9522 akron1 90
		G.SetFont(SB.canvas, font)
91
	END
92
END setWidth;
93
 
94
 
95
PROCEDURE TextOut (x: INTEGER; s: ARRAY OF WCHAR);
96
BEGIN
97
	G.TextOut2(SB.canvas, x, 2, s, LENGTH(s))
98
END TextOut;
99
 
100
 
101
PROCEDURE draw* (left, top: INTEGER);
102
BEGIN
9628 akron1 103
	G.SetColor(SB.canvas, K.colors.work);
104
	G.SetBkColor(SB.canvas, K.colors.work);
105
	G.SetTextColor(SB.canvas, K.colors.work_text);
9522 akron1 106
	G.clear(SB.canvas);
107
	TextOut(1, SB.pos);
9668 akron1 108
	TextOut(16*font.width, SB.sel);
109
	TextOut(SB.canvas.width - LENGTH(SB.enc)*font.width - 1, SB.enc);
9522 akron1 110
	G.DrawCanvas(SB.canvas, left, top)
111
END draw;
112
 
113
 
9668 akron1 114
PROCEDURE SetFont* (_font: G.tFont);
9522 akron1 115
BEGIN
9668 akron1 116
	font := _font;
117
	IF SB.canvas # NIL THEN
118
		setWidth(SB.canvas.width)
119
	END
120
END SetFont;
121
 
122
 
123
BEGIN
9522 akron1 124
	SB.canvas := NIL;
9671 akron1 125
	font := G.fonts[1]
9522 akron1 126
END StatusBar.