forked from KolibriOS/kolibrios
CEdit: added ctrl+T (new tab); small GUI changes
git-svn-id: svn://kolibrios.org@9431 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
8c8771e04d
commit
2689ca976d
Binary file not shown.
@ -33,7 +33,8 @@
|
||||
|
||||
ctrl+S сохранить
|
||||
ctrl+O открыть
|
||||
ctrl+N создать новый
|
||||
ctrl+N,
|
||||
ctrl+T создать новый
|
||||
ctrl+W закрыть файл
|
||||
ctrl+Tab переключиться на следующую вкладку
|
||||
|
||||
|
@ -28,7 +28,7 @@ IMPORT
|
||||
RW, Ini, EB := EditBox, Icons, Tabs, Timer;
|
||||
|
||||
CONST
|
||||
HEADER = "CEdit (11-dec-2021)";
|
||||
HEADER = "CEdit (17-dec-2021)";
|
||||
|
||||
ShellFilter = "";
|
||||
EditFilter = "SH|INC|TXT|ASM|OB07|C|CPP|H|PAS|PP|LUA|INI|JSON";
|
||||
@ -916,8 +916,10 @@ BEGIN
|
||||
IF nov = NIL THEN
|
||||
error("error opening file")
|
||||
ELSE
|
||||
T.SetPos(nov, 0, 0);
|
||||
insert(textsCount, nov);
|
||||
T.SetPos(nov, 0, 0)
|
||||
Scroll.setValue(hScroll, 0);
|
||||
Scroll.setValue(vScroll, 0)
|
||||
END
|
||||
ELSE
|
||||
SwitchTab(n)
|
||||
@ -1814,7 +1816,8 @@ BEGIN
|
||||
|45: key := ORD("X")
|
||||
|46: key := ORD("C")
|
||||
|47: key := ORD("V")
|
||||
|49: key := -1;
|
||||
|49,
|
||||
20: key := -1;
|
||||
NewFile
|
||||
ELSE
|
||||
key := -1
|
||||
@ -2011,6 +2014,10 @@ BEGIN
|
||||
leftButton := FALSE;
|
||||
T.selectWord(text);
|
||||
repaint
|
||||
ELSIF Tabs.DblClicked(tabs, x + LEFT, y + TOP) THEN
|
||||
leftButton := FALSE;
|
||||
NewFile;
|
||||
repaint
|
||||
END
|
||||
ELSE
|
||||
firstClickX := x;
|
||||
|
@ -26,6 +26,8 @@ CONST
|
||||
padding = 4;
|
||||
fontWidth = K.fontWidth;
|
||||
fontHeight = K.fontHeight;
|
||||
bColor = 0FFFFFFH;
|
||||
fColor = 0008000H;
|
||||
|
||||
|
||||
TYPE
|
||||
@ -43,21 +45,30 @@ TYPE
|
||||
PROCEDURE paint* (chkbox: tCheckBox);
|
||||
VAR
|
||||
canvas: G.tCanvas;
|
||||
(*r1, r2, g1, g2, b1, b2: BYTE;*)
|
||||
BEGIN
|
||||
canvas := chkbox.canvas;
|
||||
IF canvas # NIL THEN
|
||||
G.SetColor(canvas, K.winColor);
|
||||
G.clear(canvas);
|
||||
G.SetColor(canvas, 0FFFFFFH);
|
||||
G.SetColor(canvas, bColor);
|
||||
G.FillRect(canvas, 0, 0, fontHeight - 1, fontHeight - 1);
|
||||
G.SetColor(canvas, K.borderColor);
|
||||
G.Rect(canvas, 0, 0, fontHeight - 1, fontHeight - 1);
|
||||
IF chkbox.value THEN
|
||||
G.SetColor(canvas, 0008000H);
|
||||
G.SetColor(canvas, fColor);
|
||||
G.DLine(canvas, 2, 6, 6, -1);
|
||||
G.DLine(canvas, 2, 6, 7, -1);
|
||||
G.DLine(canvas, 7, 13, 9, 1);
|
||||
G.DLine(canvas, 7, 13, 10, 1)
|
||||
G.DLine(canvas, 7, 13, 10, 1);
|
||||
(*G.getRGB(bColor, r1, g1, b1);
|
||||
G.getRGB(fColor, r2, g2, b2);
|
||||
G.SetColor(canvas, (b1 + b2) DIV 2 + ((g1 + g2) DIV 2)*256 + ((r1 + r2) DIV 2)*65536);
|
||||
*)
|
||||
G.DLine(canvas, 2, 6, 8, -1);
|
||||
G.DLine(canvas, 7, 13, 11, 1);
|
||||
G.DLine(canvas, 2, 6, 5, -1);
|
||||
G.DLine(canvas, 7, 13, 8, 1);
|
||||
END;
|
||||
G.SetTextColor(canvas, K.textColor);
|
||||
G.SetBkColor(canvas, K.winColor);
|
||||
|
@ -51,6 +51,14 @@ TYPE
|
||||
END;
|
||||
|
||||
|
||||
PROCEDURE getRGB* (color: INTEGER; VAR r, g, b: BYTE);
|
||||
BEGIN
|
||||
b := color MOD 256;
|
||||
g := color DIV 256 MOD 256;
|
||||
r := color DIV 65536 MOD 256
|
||||
END getRGB;
|
||||
|
||||
|
||||
PROCEDURE DrawCanvas* (canvas: tCanvas; x, y: INTEGER);
|
||||
BEGIN
|
||||
K.sysfunc7(65, canvas.bitmap, canvas.width*65536 + canvas.height, x*65536 + y, 32, 0, 0);
|
||||
|
@ -20,7 +20,7 @@
|
||||
MODULE Icons;
|
||||
|
||||
IMPORT
|
||||
LibImg, K := KolibriOS, SYSTEM;
|
||||
LibImg, K := KolibriOS, Graph, SYSTEM;
|
||||
|
||||
CONST
|
||||
fileName = "/rd/1/Icons16.png";
|
||||
@ -93,9 +93,7 @@ BEGIN
|
||||
SYSTEM.GET8(data + 1, g);
|
||||
SYSTEM.GET8(data + 2, r);
|
||||
IF b + g + r = 765 THEN
|
||||
b := K.toolbarColor MOD 256;
|
||||
g := K.toolbarColor DIV 256 MOD 256;
|
||||
r := K.toolbarColor DIV 65536 MOD 256
|
||||
Graph.getRGB(K.toolbarColor, r, g, b)
|
||||
END;
|
||||
SYSTEM.PUT8(data, b);
|
||||
SYSTEM.PUT8(data + 1, g);
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
MODULE Tabs;
|
||||
|
||||
IMPORT List, K := KolibriOS, RW;
|
||||
IMPORT List, K := KolibriOS, RW, U := Utils;
|
||||
|
||||
CONST
|
||||
|
||||
@ -42,11 +42,16 @@ TYPE
|
||||
strings: List.tList;
|
||||
first, current: INTEGER;
|
||||
width, height: INTEGER;
|
||||
x, y: INTEGER
|
||||
x, y, freeX: INTEGER
|
||||
|
||||
END;
|
||||
|
||||
|
||||
PROCEDURE DblClicked* (t: tTabs; x, y: INTEGER): BOOLEAN;
|
||||
RETURN (x > t.freeX) & U.between(t.y, y, t.y + t.height - 1)
|
||||
END DblClicked;
|
||||
|
||||
|
||||
PROCEDURE drawTab (t: tTabs; id, x, y, width, height: INTEGER; s: ARRAY OF CHAR; modified: BOOLEAN);
|
||||
VAR
|
||||
x2, y2, color: INTEGER;
|
||||
@ -102,7 +107,7 @@ END Width;
|
||||
|
||||
PROCEDURE draw* (t: tTabs);
|
||||
VAR
|
||||
x, y, xmax, n, width: INTEGER;
|
||||
x, y, xmax, n, width, i: INTEGER;
|
||||
item: List.tItem;
|
||||
scroll: BOOLEAN;
|
||||
BEGIN
|
||||
@ -111,8 +116,10 @@ BEGIN
|
||||
K.DrawRect(x, y - (curTabHeight - tabHeight), t.width + (2*scrWidth + 2), t.height + (curTabHeight - tabHeight) - 1, K.winColor);
|
||||
IF Width(t, 0, t.strings.count - 1) > t.width THEN
|
||||
INC(x, 2*scrWidth);
|
||||
K.CreateButton(btnID - 1, t.x, t.y, scrWidth, t.height - 1, K.btnColor, "<");
|
||||
K.CreateButton(btnID - 2, t.x + scrWidth, t.y, scrWidth, t.height - 1, K.btnColor, ">");
|
||||
K.DeleteButton(btnID - 1);
|
||||
K.DeleteButton(btnID - 2);
|
||||
K.CreateButton(btnID - 1, t.x, y, scrWidth, t.height - 1, K.btnColor, "<");
|
||||
K.CreateButton(btnID - 2, t.x + scrWidth, y, scrWidth, t.height - 1, K.btnColor, ">");
|
||||
scroll := TRUE
|
||||
ELSE
|
||||
t.first := 0;
|
||||
@ -121,6 +128,9 @@ BEGIN
|
||||
xmax := x + t.width - 1;
|
||||
|
||||
n := t.strings.count - 1;
|
||||
FOR i := 0 TO n DO
|
||||
K.DeleteButton(i + btnID)
|
||||
END;
|
||||
WHILE (n >= 0) & (Width(t, n, t.strings.count - 1) <= t.width) DO
|
||||
DEC(n)
|
||||
END;
|
||||
@ -140,12 +150,15 @@ BEGIN
|
||||
WHILE (item # NIL) & (x <= xmax) DO
|
||||
width := tabWidth(item(tItem));
|
||||
IF x + width - 1 <= xmax THEN
|
||||
drawTab(t, n, x + 1, y, width, t.height, item(tItem).val, item(tItem).modified)
|
||||
END;
|
||||
drawTab(t, n, x + 1, y, width, t.height, item(tItem).val, item(tItem).modified);
|
||||
INC(n);
|
||||
INC(x, width);
|
||||
item := item.next
|
||||
ELSE
|
||||
item := NIL
|
||||
END
|
||||
END;
|
||||
t.freeX := x
|
||||
END draw;
|
||||
|
||||
|
||||
|
@ -106,7 +106,7 @@ BEGIN
|
||||
width := scroll.width;
|
||||
height := scroll.height;
|
||||
canvas := scroll.canvas;
|
||||
G.SetColor(canvas, K.winColor);
|
||||
G.SetColor(canvas, K.lightColor);
|
||||
G.clear(canvas);
|
||||
G.SetColor(canvas, K.borderColor);
|
||||
G.Rect(canvas, 0, 0, width - 1, height - 1);
|
||||
|
Loading…
Reference in New Issue
Block a user