Subversion Repositories Kolibri OS

Rev

Rev 9410 | Rev 9448 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 9410 Rev 9431
Line 17... Line 17...
17
    along with CEdit. If not, see .
17
    along with CEdit. If not, see .
18
*)
18
*)
Line 19... Line 19...
19
 
19
 
Line 20... Line 20...
20
MODULE Tabs;
20
MODULE Tabs;
Line 21... Line 21...
21
 
21
 
Line 22... Line 22...
22
IMPORT List, K := KolibriOS, RW;
22
IMPORT List, K := KolibriOS, RW, U := Utils;
23
 
23
 
Line 40... Line 40...
40
    tTabs* = POINTER TO RECORD
40
    tTabs* = POINTER TO RECORD
Line 41... Line 41...
41
 
41
 
42
        strings: List.tList;
42
        strings: List.tList;
43
        first, current: INTEGER;
43
        first, current: INTEGER;
44
        width, height: INTEGER;
44
        width, height: INTEGER;
Line 45... Line 45...
45
        x, y: INTEGER
45
        x, y, freeX: INTEGER
Line -... Line 46...
-
 
46
 
-
 
47
    END;
-
 
48
 
-
 
49
 
-
 
50
PROCEDURE DblClicked* (t: tTabs; x, y: INTEGER): BOOLEAN;
46
 
51
	RETURN (x > t.freeX) & U.between(t.y, y, t.y + t.height - 1)
47
    END;
52
END DblClicked;
48
 
53
 
49
 
54
 
50
PROCEDURE drawTab (t: tTabs; id, x, y, width, height: INTEGER; s: ARRAY OF CHAR; modified: BOOLEAN);
55
PROCEDURE drawTab (t: tTabs; id, x, y, width, height: INTEGER; s: ARRAY OF CHAR; modified: BOOLEAN);
Line 100... Line 105...
100
END Width;
105
END Width;
Line 101... Line 106...
101
 
106
 
102
 
107
 
103
PROCEDURE draw* (t: tTabs);
108
PROCEDURE draw* (t: tTabs);
104
VAR
109
VAR
105
    x, y, xmax, n, width: INTEGER;
110
    x, y, xmax, n, width, i: INTEGER;
106
    item: List.tItem;
111
    item: List.tItem;
107
    scroll: BOOLEAN;
112
    scroll: BOOLEAN;
108
BEGIN
113
BEGIN
109
    y := t.y;
114
    y := t.y;
110
    x := t.x;
115
    x := t.x;
111
    K.DrawRect(x, y - (curTabHeight - tabHeight), t.width + (2*scrWidth + 2), t.height + (curTabHeight - tabHeight) - 1, K.winColor);
116
    K.DrawRect(x, y - (curTabHeight - tabHeight), t.width + (2*scrWidth + 2), t.height + (curTabHeight - tabHeight) - 1, K.winColor);
-
 
117
    IF Width(t, 0, t.strings.count - 1) > t.width THEN
-
 
118
        INC(x, 2*scrWidth);
112
    IF Width(t, 0, t.strings.count - 1) > t.width THEN
119
        K.DeleteButton(btnID - 1);
113
        INC(x, 2*scrWidth);
120
        K.DeleteButton(btnID - 2);
114
        K.CreateButton(btnID - 1, t.x, t.y, scrWidth, t.height - 1, K.btnColor, "<");
121
        K.CreateButton(btnID - 1, t.x, y, scrWidth, t.height - 1, K.btnColor, "<");
115
        K.CreateButton(btnID - 2, t.x + scrWidth, t.y, scrWidth, t.height - 1, K.btnColor, ">");
122
        K.CreateButton(btnID - 2, t.x + scrWidth, y, scrWidth, t.height - 1, K.btnColor, ">");
116
        scroll := TRUE
123
        scroll := TRUE
117
    ELSE
124
    ELSE
118
        t.first := 0;
125
        t.first := 0;
119
        scroll := FALSE
126
        scroll := FALSE
Line 120... Line 127...
120
    END;
127
    END;
-
 
128
    xmax := x + t.width - 1;
-
 
129
 
-
 
130
    n := t.strings.count - 1;
121
    xmax := x + t.width - 1;
131
    FOR i := 0 TO n DO
122
 
132
    	K.DeleteButton(i + btnID)
123
    n := t.strings.count - 1;
133
    END;
124
    WHILE (n >= 0) & (Width(t, n, t.strings.count - 1) <= t.width) DO
134
    WHILE (n >= 0) & (Width(t, n, t.strings.count - 1) <= t.width) DO
125
        DEC(n)
135
        DEC(n)
Line 138... Line 148...
138
    item := List.getItem(t.strings, t.first);
148
    item := List.getItem(t.strings, t.first);
139
    n := t.first;
149
    n := t.first;
140
    WHILE (item # NIL) & (x <= xmax) DO
150
    WHILE (item # NIL) & (x <= xmax) DO
141
        width := tabWidth(item(tItem));
151
        width := tabWidth(item(tItem));
142
        IF x + width - 1 <= xmax THEN
152
        IF x + width - 1 <= xmax THEN
143
            drawTab(t, n, x + 1, y, width, t.height, item(tItem).val, item(tItem).modified)
153
            drawTab(t, n, x + 1, y, width, t.height, item(tItem).val, item(tItem).modified);
144
        END;
-
 
145
        INC(n);
154
        	INC(n);
146
        INC(x, width);
155
        	INC(x, width);
147
        item := item.next
156
        	item := item.next
-
 
157
        ELSE
-
 
158
        	item := NIL
148
    END
159
        END
-
 
160
    END;
-
 
161
    t.freeX := x
149
END draw;
162
END draw;
Line 150... Line 163...
150
 
163
 
151
 
164