forked from KolibriOS/kolibrios
CEDIT: internal changes
git-svn-id: svn://kolibrios.org@9208 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
d38b3890d2
commit
c2885eb759
Binary file not shown.
@ -28,7 +28,7 @@ IMPORT
|
||||
RW, Ini, EB := EditBox, Icons, Tabs, Timer;
|
||||
|
||||
CONST
|
||||
header = "CEdit (24-sep-2021)";
|
||||
header = "CEdit (28-sep-2021)";
|
||||
|
||||
ShellFilter = "";
|
||||
EditFilter = "SH|ASM|TXT|INC|OB07|C|CPP|H|PAS|PP|LUA|INI|JSON";
|
||||
@ -195,7 +195,7 @@ VAR
|
||||
|
||||
replaced: INTEGER;
|
||||
|
||||
mainTID, delay: INTEGER;
|
||||
mainTID: INTEGER;
|
||||
|
||||
context, menuFile, menuEdit, menuSearch, menuEncoding,
|
||||
menuView, menuLanguage, menuProgram, menuTools,
|
||||
@ -231,7 +231,7 @@ VAR
|
||||
BEGIN
|
||||
res := FALSE;
|
||||
IF edit # NIL THEN
|
||||
res := 1 IN BITS(edit.flags)
|
||||
res := 1 IN edit.flags
|
||||
END
|
||||
RETURN res
|
||||
END EditBox_Focus;
|
||||
@ -252,9 +252,9 @@ END resetTimer;
|
||||
PROCEDURE EditBox_SetFocus (edit: EB.tEditBox; value: BOOLEAN);
|
||||
BEGIN
|
||||
IF value THEN
|
||||
edit.flags := ORD(BITS(edit.flags) + {1})
|
||||
INCL(edit.flags, 1)
|
||||
ELSE
|
||||
edit.flags := ORD(BITS(edit.flags) - {1})
|
||||
EXCL(edit.flags, 1)
|
||||
END;
|
||||
IF search & searchOpened THEN
|
||||
EB.paint(edit)
|
||||
@ -411,16 +411,16 @@ END WriteModified;
|
||||
|
||||
PROCEDURE DrawState (text: T.tText; width, height: INTEGER);
|
||||
VAR
|
||||
y, w, x: INTEGER;
|
||||
y: INTEGER;
|
||||
s: ARRAY 24 OF WCHAR;
|
||||
BEGIN
|
||||
y := (btnHeight - fontHeight) DIV 2 + btnTop;
|
||||
K.DrawRect(width - 32*fontWidth, y, 32*fontWidth, fontHeight, K.winColor);
|
||||
w := LENGTH(E.names[text.enc])*fontWidth;
|
||||
x := width - w;
|
||||
K.DrawText(x, y, K.textColor, E.names[text.enc]);
|
||||
w := LENGTH(RW.eolNames[text.eol])*fontWidth;
|
||||
DEC(x, w + 10);
|
||||
K.DrawText(x, y, K.textColor, RW.eolNames[text.eol]);
|
||||
s := "";
|
||||
U.append(s, RW.eolNames[text.eol]);
|
||||
U.append(s, 20X);
|
||||
U.append(s, E.names[text.enc]);
|
||||
K.DrawRect(width - LEN(s)*fontWidth, y, LEN(s)*fontWidth, fontHeight, K.winColor);
|
||||
K.DrawText(width - LENGTH(s)*fontWidth, y, K.textColor, s);
|
||||
y := height - (BOTTOM - scrollWidth) + (BOTTOM - scrollWidth - 16) DIV 2;
|
||||
K.DrawRect(LEFT + 16*fontWidth, TOP + canvas.height + scrollWidth, width - LEFT - 24*fontWidth, BOTTOM - scrollWidth + 1, K.winColor);
|
||||
K.DrawText866(LEFT + 16*fontWidth, y, K.textColor, text.fileName);
|
||||
@ -639,15 +639,11 @@ END draw_window;
|
||||
|
||||
PROCEDURE mouse (VAR x, y: INTEGER);
|
||||
VAR
|
||||
mouseX, mouseY,
|
||||
cliX, cliY,
|
||||
winX, winY: INTEGER;
|
||||
msState: SET;
|
||||
BEGIN
|
||||
K.MousePos(mouseX, mouseY);
|
||||
K.WinPos(winX, winY);
|
||||
K.ClientPos(cliX, cliY);
|
||||
x := mouseX - winX - cliX - LEFT;
|
||||
y := mouseY - winY - cliY - TOP;
|
||||
K.mouse(msState, x, y);
|
||||
DEC(x, LEFT);
|
||||
DEC(y, TOP)
|
||||
END mouse;
|
||||
|
||||
|
||||
@ -935,7 +931,7 @@ BEGIN
|
||||
EditBox0.text := K.malloc(EDITBOX_MAXCHARS + 2);
|
||||
ASSERT(EditBox0.text # 0);
|
||||
edit := EB.create(left, top, EditBox_Width, EDITBOX_MAXCHARS, EditBox0);
|
||||
edit.flags := 4002H;
|
||||
edit.flags := {1, 14};
|
||||
edit.text_color := 30000000H;
|
||||
EditBox_SetFocus(edit, FALSE)
|
||||
RETURN edit
|
||||
@ -947,7 +943,7 @@ BEGIN
|
||||
FindEdit := createEdit(searchLeft, TOP + 20);
|
||||
ReplaceEdit := createEdit(searchLeft, TOP + 20 + 55);
|
||||
GotoEdit := createEdit(searchLeft, TOP + 20 + 330);
|
||||
GotoEdit.flags := ORD(BITS(GotoEdit.flags) + BITS(8000H));
|
||||
INCL(GotoEdit.flags, 15);
|
||||
CheckBox.create("backward", BKW);
|
||||
CheckBox.create("match case", CS);
|
||||
CheckBox.create("whole word", WH);
|
||||
@ -992,16 +988,9 @@ VAR
|
||||
shift, ctrl: BOOLEAN;
|
||||
BEGIN
|
||||
K.getKBState(shift, ctrl);
|
||||
Scroll.MouseDown(hScroll, x + LEFT, y + TOP);
|
||||
Scroll.MouseDown(vScroll, x + LEFT, y + TOP);
|
||||
T.getScroll(text, scrollX, scrollY);
|
||||
T.scroll(text, hScroll.value - scrollX, vScroll.value - scrollY);
|
||||
IF search & searchOpened THEN
|
||||
CheckBox.MouseDown(BKW, x + LEFT, y + TOP);
|
||||
CheckBox.MouseDown(CS, x + LEFT, y + TOP);
|
||||
CheckBox.MouseDown(WH, x + LEFT, y + TOP);
|
||||
END;
|
||||
IF (0 <= x) & (x < canvas.width) & (0 <= y) & (y < canvas.height) THEN
|
||||
IF U.between(0, x, canvas.width - 1) & U.between(0, y, canvas.height - 1) THEN
|
||||
leftButton := TRUE;
|
||||
SetFocus(FindEdit, FALSE);
|
||||
IF ~shift THEN
|
||||
@ -1014,17 +1003,6 @@ BEGIN
|
||||
END click;
|
||||
|
||||
|
||||
PROCEDURE LeftButtonUp;
|
||||
BEGIN
|
||||
leftButton := FALSE;
|
||||
Scroll.MouseUp(hScroll);
|
||||
Scroll.MouseUp(vScroll);
|
||||
CheckBox.MouseUp(BKW);
|
||||
CheckBox.MouseUp(CS);
|
||||
CheckBox.MouseUp(WH);
|
||||
END LeftButtonUp;
|
||||
|
||||
|
||||
PROCEDURE Close;
|
||||
VAR
|
||||
cont: BOOLEAN;
|
||||
@ -1143,7 +1121,7 @@ VAR
|
||||
BEGIN
|
||||
IF menu = context THEN
|
||||
mouse(x, y);
|
||||
IF ~((0 <= x) & (x < canvas.width) & (0 <= y) & (y < canvas.height)) THEN
|
||||
IF ~(U.between(0, x, canvas.width - 1) & U.between(0, y, canvas.height - 1)) THEN
|
||||
menu := NIL
|
||||
END
|
||||
ELSE
|
||||
@ -1240,6 +1218,17 @@ BEGIN
|
||||
END ShowMenu;
|
||||
|
||||
|
||||
PROCEDURE setScript (VAR script: RW.tFileName);
|
||||
VAR
|
||||
temp: RW.tFileName;
|
||||
BEGIN
|
||||
OpenFile(temp, ShellFilter);
|
||||
IF temp # "" THEN
|
||||
script := temp
|
||||
END
|
||||
END setScript;
|
||||
|
||||
|
||||
PROCEDURE receiveIPC;
|
||||
VAR
|
||||
scrollIPC: BOOLEAN;
|
||||
@ -1254,36 +1243,11 @@ BEGIN
|
||||
IPC[2] := 0
|
||||
ELSIF IPC[0] = mainTID THEN
|
||||
IF IPC[2] = Scroll.ScrollIPC THEN
|
||||
Scroll.change(hScroll);
|
||||
Scroll.change(vScroll);
|
||||
T.scroll(text, ORD(hScroll.Inc) - ORD(hScroll.Dec), ORD(vScroll.Inc) - ORD(vScroll.Dec));
|
||||
|
||||
IF menuActive THEN
|
||||
draw_window;
|
||||
menuActive := FALSE
|
||||
ELSE
|
||||
repaint
|
||||
END;
|
||||
|
||||
IF 0 IN K.MouseState() THEN
|
||||
WHILE (0 IN K.MouseState()) & (delay > 0) DO
|
||||
K.Pause(1);
|
||||
DEC(delay)
|
||||
END;
|
||||
IF delay = 0 THEN
|
||||
IPC[0] := 0;
|
||||
IPC[1] := 0;
|
||||
scrollIPC := TRUE;
|
||||
Scroll.SendIPC;
|
||||
delay := 2
|
||||
ELSE
|
||||
delay := Scroll.Delay
|
||||
END
|
||||
ELSE
|
||||
delay := Scroll.Delay
|
||||
END
|
||||
Scroll.receiveIPC(IPC, scrollIPC)
|
||||
END;
|
||||
IF ~scrollIPC THEN
|
||||
IPC[2] := 0
|
||||
END
|
||||
ELSE
|
||||
IF ~Menu.isSender(IPC[0]) THEN
|
||||
IPC[2] := 0
|
||||
@ -1297,6 +1261,7 @@ BEGIN
|
||||
END
|
||||
END
|
||||
END;
|
||||
IF ~scrollIPC THEN
|
||||
CASE IPC[2] OF
|
||||
|0:
|
||||
|menuCut: T.key(text, ORD("X"), FALSE, TRUE)
|
||||
@ -1374,15 +1339,15 @@ BEGIN
|
||||
|menuBuild:
|
||||
Script(buildScript)
|
||||
|menuBuildScript:
|
||||
OpenFile(buildScript, ShellFilter)
|
||||
setScript(buildScript)
|
||||
|menuRun:
|
||||
Script(runScript)
|
||||
|menuRunScript:
|
||||
OpenFile(runScript, ShellFilter)
|
||||
setScript(runScript)
|
||||
|menuDebug:
|
||||
Script(debugScript)
|
||||
|menuDebugScript:
|
||||
OpenFile(debugScript, ShellFilter)
|
||||
setScript(debugScript)
|
||||
|menuUTF8BOM:
|
||||
text.enc := E.UTF8BOM
|
||||
|menuUTF8:
|
||||
@ -1422,7 +1387,6 @@ BEGIN
|
||||
|menuLower:
|
||||
T.chCase(text, FALSE)
|
||||
END;
|
||||
IF ~scrollIPC THEN
|
||||
IPC[0] := 0;
|
||||
IPC[1] := 0
|
||||
END
|
||||
@ -1820,7 +1784,7 @@ BEGIN
|
||||
|82, 91, 219, 92, 220: key := -1 (* insert, windows *)
|
||||
|93: ShowMenu(context); key := -1
|
||||
|83: key := 46
|
||||
|59, 62..66, 68, 87, 88: key := -1 (* F1, F4..F8, F10, F11, F12 *)
|
||||
|59, 62..66, 87, 88: key := -1 (* F1, F4..F8, F11, F12 *)
|
||||
ELSE
|
||||
IF ctrl THEN
|
||||
CASE keyCode OF
|
||||
@ -1996,7 +1960,7 @@ BEGIN
|
||||
IF ~resized THEN
|
||||
msState := K.MouseState();
|
||||
IF ~(0 IN msState) OR (16 IN msState) THEN
|
||||
LeftButtonUp
|
||||
leftButton := FALSE
|
||||
END;
|
||||
scroll := K.Scroll();
|
||||
IF scroll # 0 THEN
|
||||
@ -2010,20 +1974,15 @@ BEGIN
|
||||
repaint
|
||||
END
|
||||
END;
|
||||
IF Scroll.isActive(hScroll) THEN
|
||||
mouse(x, y);
|
||||
Scroll.MouseMove(hScroll, x + LEFT, y + TOP);
|
||||
|
||||
Scroll.mouse(hScroll);
|
||||
Scroll.mouse(vScroll);
|
||||
T.getScroll(text, scrollX, scrollY);
|
||||
T.scroll(text, hScroll.value - scrollX, 0);
|
||||
repaint
|
||||
END;
|
||||
IF Scroll.isActive(vScroll) THEN
|
||||
mouse(x, y);
|
||||
Scroll.MouseMove(vScroll, x + LEFT, y + TOP);
|
||||
T.getScroll(text, scrollX, scrollY);
|
||||
T.scroll(text, 0, vScroll.value - scrollY);
|
||||
IF (hScroll.value # scrollX) OR (vScroll.value # scrollY) THEN
|
||||
T.scroll(text, hScroll.value - scrollX, vScroll.value - scrollY);
|
||||
repaint
|
||||
END;
|
||||
|
||||
IF (8 IN msState) & ~(24 IN msState) THEN
|
||||
mouse(firstClickX, firstClickY);
|
||||
time := click(firstClickX, firstClickY)
|
||||
@ -2033,15 +1992,8 @@ BEGIN
|
||||
END;
|
||||
IF 24 IN msState THEN
|
||||
mouse(x, y);
|
||||
Scroll.MouseDown(hScroll, x + LEFT, y + TOP);
|
||||
Scroll.MouseDown(vScroll, x + LEFT, y + TOP);
|
||||
IF search & searchOpened THEN
|
||||
CheckBox.MouseDown(BKW, x + LEFT, y + TOP);
|
||||
CheckBox.MouseDown(CS, x + LEFT, y + TOP);
|
||||
CheckBox.MouseDown(WH, x + LEFT, y + TOP);
|
||||
END;
|
||||
IF (ABS(x - firstClickX) < 5) & (ABS(y - firstClickY) < 5) THEN
|
||||
IF (0 <= x) & (x < canvas.width) & (0 <= y) & (y < canvas.height) THEN
|
||||
IF U.between(-4, x - firstClickX, 4) & U.between(-4, y - firstClickY, 4) THEN
|
||||
IF U.between(0, x, canvas.width - 1) & U.between(0, y, canvas.height - 1) THEN
|
||||
leftButton := FALSE;
|
||||
T.selectWord(text);
|
||||
repaint
|
||||
@ -2054,16 +2006,15 @@ BEGIN
|
||||
END
|
||||
END;
|
||||
IF search & searchOpened THEN
|
||||
CheckBox.mouse(BKW);
|
||||
CheckBox.mouse(CS);
|
||||
CheckBox.mouse(WH);
|
||||
EditBox(FindEdit);
|
||||
EditBox(ReplaceEdit);
|
||||
EditBox(GotoEdit);
|
||||
IF CS.value # cs THEN
|
||||
cs := ~cs;
|
||||
notFound := ~T.search(text, searchText, cs, whole);
|
||||
repaint
|
||||
END;
|
||||
IF WH.value # whole THEN
|
||||
whole := ~whole;
|
||||
IF (CS.value # cs) OR (WH.value # whole) THEN
|
||||
cs := CS.value;
|
||||
whole := WH.value;
|
||||
notFound := ~T.search(text, searchText, cs, whole);
|
||||
repaint
|
||||
END
|
||||
@ -2095,6 +2046,20 @@ BEGIN
|
||||
END Redraw;
|
||||
|
||||
|
||||
PROCEDURE ScrollChange;
|
||||
BEGIN
|
||||
Scroll.change(hScroll);
|
||||
Scroll.change(vScroll);
|
||||
T.scroll(text, ORD(hScroll.Inc) - ORD(hScroll.Dec), ORD(vScroll.Inc) - ORD(vScroll.Dec));
|
||||
IF menuActive THEN
|
||||
draw_window;
|
||||
menuActive := FALSE
|
||||
ELSE
|
||||
repaint
|
||||
END
|
||||
END ScrollChange;
|
||||
|
||||
|
||||
PROCEDURE main;
|
||||
VAR
|
||||
err: INTEGER;
|
||||
@ -2103,7 +2068,6 @@ VAR
|
||||
resized: BOOLEAN;
|
||||
firstClickX, firstClickY, time: INTEGER;
|
||||
BEGIN
|
||||
delay := Scroll.Delay;
|
||||
K.GetSystemColors;
|
||||
Icons.get(icons, grayIcons);
|
||||
modified := FALSE;
|
||||
@ -2115,7 +2079,7 @@ BEGIN
|
||||
K.SetIPC(IPC);
|
||||
U.ptr2str(K.GetName(), AppPath);
|
||||
Ini.load(AppPath);
|
||||
LeftButtonUp;
|
||||
leftButton := FALSE;
|
||||
resized := FALSE;
|
||||
K.ScreenSize(winWidth, winHeight);
|
||||
winWidth := (winWidth*80) DIV 100 - (128 + 30);
|
||||
@ -2181,6 +2145,7 @@ BEGIN
|
||||
END;
|
||||
OD := OpenDlg.Create(draw_window, OpenDlg.topen, filePath, "");
|
||||
insert(0, text);
|
||||
Scroll.init(ScrollChange);
|
||||
Scroll.create(FALSE, canvas.width + 1, scrollWidth, scrollWidth, scrollWidth, hScroll);
|
||||
Scroll.create(TRUE, scrollWidth, canvas.height + 1, scrollWidth, scrollWidth, vScroll);
|
||||
T.resize(canvas.width, canvas.height);
|
||||
|
@ -84,26 +84,26 @@ BEGIN
|
||||
END create;
|
||||
|
||||
|
||||
PROCEDURE MouseDown* (VAR chkbox: tCheckBox; x, y: INTEGER);
|
||||
PROCEDURE mouse* (VAR chkbox: tCheckBox);
|
||||
VAR
|
||||
msState: SET;
|
||||
x, y: INTEGER;
|
||||
BEGIN
|
||||
K.mouse(msState, x, y);
|
||||
IF 0 IN msState THEN
|
||||
IF (chkbox.canvas # NIL) & ~chkbox.mouse THEN
|
||||
DEC(x, chkbox.left);
|
||||
DEC(y, chkbox.top);
|
||||
chkbox.mouse := TRUE;
|
||||
IF U.between(0, x, chkbox.width) & U.between(0, y, chkbox.height) THEN
|
||||
IF U.between(0, x, chkbox.width - 1) & U.between(0, y, chkbox.height - 1) THEN
|
||||
chkbox.value := ~chkbox.value;
|
||||
END;
|
||||
paint(chkbox)
|
||||
END
|
||||
END MouseDown;
|
||||
|
||||
|
||||
PROCEDURE MouseUp* (VAR chkbox: tCheckBox);
|
||||
BEGIN
|
||||
IF chkbox.canvas # NIL THEN
|
||||
ELSE
|
||||
chkbox.mouse := FALSE
|
||||
END
|
||||
END MouseUp;
|
||||
END mouse;
|
||||
|
||||
|
||||
END CheckBox.
|
@ -40,7 +40,7 @@ TYPE
|
||||
max: INTEGER;
|
||||
text*: INTEGER;
|
||||
mouse_variable: tEditBox;
|
||||
flags*,
|
||||
flags*: SET;
|
||||
|
||||
size,
|
||||
pos: INTEGER;
|
||||
@ -129,7 +129,7 @@ BEGIN
|
||||
new_textbox.text := KOSAPI.malloc(max_chars + 2);
|
||||
ASSERT(new_textbox.text # 0);
|
||||
new_textbox.mouse_variable := editbox_interlock;
|
||||
new_textbox.flags := 0
|
||||
new_textbox.flags := {}
|
||||
|
||||
RETURN new_textbox
|
||||
END create;
|
||||
|
@ -185,24 +185,24 @@ END DLine;
|
||||
PROCEDURE Triangle* (canvas: tCanvas; x1, y1, x2, y2: INTEGER; orientation: BOOLEAN);
|
||||
VAR
|
||||
i, a, b, d: INTEGER;
|
||||
line: PROCEDURE (canvas: tCanvas; c, c1, c2: INTEGER);
|
||||
BEGIN
|
||||
line := NIL;
|
||||
d := ORD(orientation)*2 - 1;
|
||||
IF y1 = y2 THEN
|
||||
i := y1;
|
||||
a := MIN(x1, x2);
|
||||
b := MAX(x1, x2);
|
||||
WHILE a <= b DO
|
||||
HLine(canvas, i, a, b);
|
||||
INC(i, d);
|
||||
INC(a);
|
||||
DEC(b)
|
||||
END
|
||||
line := HLine
|
||||
ELSIF x1 = x2 THEN
|
||||
i := x1;
|
||||
a := MIN(y1, y2);
|
||||
b := MAX(y1, y2);
|
||||
line := VLine
|
||||
END;
|
||||
IF line # NIL THEN
|
||||
WHILE a <= b DO
|
||||
VLine(canvas, i, a, b);
|
||||
line(canvas, i, a, b);
|
||||
INC(i, d);
|
||||
INC(a);
|
||||
DEC(b)
|
||||
@ -251,7 +251,7 @@ PROCEDURE TextOut* (canvas: tCanvas; x, y: INTEGER; text: INTEGER; n: INTEGER; d
|
||||
CONST
|
||||
WCHAR_SIZE = 2;
|
||||
VAR
|
||||
color, i, ecx: INTEGER;
|
||||
color, i, font: INTEGER;
|
||||
c: WCHAR;
|
||||
BEGIN
|
||||
IF (0 <= y) & (y <= canvas.height - canvas.font.height - 1) THEN
|
||||
@ -268,15 +268,16 @@ BEGIN
|
||||
canvas.color := canvas.backColor;
|
||||
FillRect(canvas, x, y, x + n*canvas.font.width, y + canvas.font.height);
|
||||
canvas.color := color;
|
||||
font := LSL(28H + canvas.font.size, 24);
|
||||
WHILE n > 0 DO
|
||||
SYSTEM.GET(text + i*WCHAR_SIZE, c);
|
||||
IF ~Lines.isSpace(c) THEN
|
||||
IF Languages.isDelim(c) THEN
|
||||
ecx := LSL(28H + canvas.font.size, 24) + delimColor
|
||||
color := delimColor
|
||||
ELSE
|
||||
ecx := LSL(28H + canvas.font.size, 24) + canvas.textColor
|
||||
color := canvas.textColor
|
||||
END;
|
||||
K.sysfunc6(4, x*65536 + y, ecx, SYSTEM.ADR(c), 1, canvas.bitmap - 8)
|
||||
K.sysfunc6(4, x*65536 + y, font + color, SYSTEM.ADR(c), 1, canvas.bitmap - 8)
|
||||
END;
|
||||
INC(x, canvas.font.width);
|
||||
INC(i);
|
||||
|
@ -369,4 +369,19 @@ BEGIN
|
||||
END getKBState;
|
||||
|
||||
|
||||
PROCEDURE mouse* (VAR msState: SET; VAR x, y: INTEGER);
|
||||
VAR
|
||||
mouseX, mouseY,
|
||||
cliX, cliY,
|
||||
winX, winY: INTEGER;
|
||||
BEGIN
|
||||
msState := MouseState();
|
||||
MousePos(mouseX, mouseY);
|
||||
WinPos(winX, winY);
|
||||
ClientPos(cliX, cliY);
|
||||
x := mouseX - winX - cliX;
|
||||
y := mouseY - winY - cliY
|
||||
END mouse;
|
||||
|
||||
|
||||
END KolibriOS.
|
@ -216,7 +216,7 @@ END escape;
|
||||
|
||||
PROCEDURE repaint (m: tMenu);
|
||||
VAR
|
||||
y, i, X, Y1, Y2: INTEGER;
|
||||
y, i, X, Y: INTEGER;
|
||||
item: tItem;
|
||||
BkColor, TextColor: INTEGER;
|
||||
canvas: G.tCanvas;
|
||||
@ -277,9 +277,8 @@ BEGIN
|
||||
|
||||
IF item.child # NIL THEN
|
||||
X := m.width - 9;
|
||||
Y1 := y + (fontHeight - 16) DIV 2 + 2;
|
||||
Y2 := Y1 + 8;
|
||||
G.Triangle(canvas, X, Y1, X, Y2, G.triRight)
|
||||
Y := y + (fontHeight - 16) DIV 2 + 2;
|
||||
G.Triangle(canvas, X, Y, X, Y + 8, G.triRight)
|
||||
END;
|
||||
|
||||
INC(y, fontHeight);
|
||||
@ -303,16 +302,6 @@ BEGIN
|
||||
END draw_window;
|
||||
|
||||
|
||||
PROCEDURE mouse (m: tMenu; VAR x, y: INTEGER);
|
||||
VAR
|
||||
mouseX, mouseY: INTEGER;
|
||||
BEGIN
|
||||
K.MousePos(mouseX, mouseY);
|
||||
x := mouseX - m.winX;
|
||||
y := mouseY - m.winY;
|
||||
END mouse;
|
||||
|
||||
|
||||
PROCEDURE close* (m: tMenu);
|
||||
VAR
|
||||
temp: INTEGER;
|
||||
@ -469,8 +458,7 @@ BEGIN
|
||||
END;
|
||||
repaint(m)
|
||||
|6:
|
||||
msState := K.MouseState();
|
||||
mouse(m, x, y);
|
||||
K.mouse(msState, x, y);
|
||||
IF (0 <= x) & (x < m.width) & (0 <= y) & (y < m.height) THEN
|
||||
m.active := TRUE;
|
||||
m.selItem := (y - TOP) DIV fontHeight;
|
||||
|
@ -2128,12 +2128,9 @@ BEGIN
|
||||
IF (i MOD 10 = 0) OR (i - 1 = text.cursor.Y) OR line.label THEN
|
||||
U.int2str(i, s);
|
||||
G.TextOut2(canvas, (numWidth - U.lg10(i) - 1)*wNum - wNum DIV 2, y, s, LENGTH(s))
|
||||
ELSIF i MOD 5 = 0 THEN
|
||||
G.SetColor(canvas, colors.numtext);
|
||||
G.HLine(canvas, y - inter DIV 2 + charHeight DIV 2, xNum - wNum, xNum)
|
||||
ELSE
|
||||
G.SetColor(canvas, colors.numtext);
|
||||
G.HLine(canvas, y - inter DIV 2 + charHeight DIV 2, xNum - wNum DIV 2, xNum)
|
||||
G.HLine(canvas, y - inter DIV 2 + charHeight DIV 2, xNum - wNum DIV (1 + ORD(i MOD 5 # 0)), xNum)
|
||||
END
|
||||
END;
|
||||
IF line.label THEN
|
||||
|
@ -24,7 +24,7 @@ IMPORT G := Graph, K := KolibriOS, U := Utils;
|
||||
CONST
|
||||
|
||||
ScrollIPC* = 0;
|
||||
Delay* = 40;
|
||||
DELAY = 40;
|
||||
|
||||
TYPE
|
||||
|
||||
@ -37,16 +37,29 @@ TYPE
|
||||
canvas*: G.tCanvas
|
||||
END;
|
||||
|
||||
tProcedure* = PROCEDURE;
|
||||
|
||||
VAR
|
||||
|
||||
ScrollChange: tProcedure;
|
||||
delay: INTEGER;
|
||||
|
||||
|
||||
PROCEDURE MouseUp (VAR scroll: tScroll);
|
||||
BEGIN
|
||||
scroll.Slider := -1;
|
||||
scroll.Inc := FALSE;
|
||||
scroll.Dec := FALSE;
|
||||
scroll.mouse := FALSE;
|
||||
END MouseUp;
|
||||
|
||||
|
||||
PROCEDURE create* (vertical: BOOLEAN; width, height: INTEGER; btnSize, sliderSize: INTEGER; VAR scroll: tScroll);
|
||||
VAR
|
||||
res: tScroll;
|
||||
BEGIN
|
||||
MouseUp(res);
|
||||
res.vertical := vertical;
|
||||
res.Inc := FALSE;
|
||||
res.Dec := FALSE;
|
||||
res.Slider := -1;
|
||||
res.mouse := FALSE;
|
||||
res.left := 0;
|
||||
res.top := 0;
|
||||
res.width := width;
|
||||
@ -279,12 +292,7 @@ BEGIN
|
||||
END setPos;
|
||||
|
||||
|
||||
PROCEDURE isActive* (scroll: tScroll): BOOLEAN;
|
||||
RETURN scroll.Inc OR scroll.Dec OR (scroll.Slider # -1)
|
||||
END isActive;
|
||||
|
||||
|
||||
PROCEDURE MouseMove* (VAR scroll: tScroll; x, y: INTEGER);
|
||||
PROCEDURE MouseMove (VAR scroll: tScroll; x, y: INTEGER);
|
||||
VAR
|
||||
c: INTEGER;
|
||||
BEGIN
|
||||
@ -300,13 +308,37 @@ BEGIN
|
||||
END MouseMove;
|
||||
|
||||
|
||||
PROCEDURE SendIPC*;
|
||||
PROCEDURE SendIPC;
|
||||
BEGIN
|
||||
K.SendIPC(K.ThreadID(), ScrollIPC)
|
||||
END SendIPC;
|
||||
|
||||
|
||||
PROCEDURE MouseDown* (VAR scroll: tScroll; x, y: INTEGER);
|
||||
PROCEDURE receiveIPC* (VAR IPC: ARRAY OF INTEGER; VAR scrollIPC: BOOLEAN);
|
||||
BEGIN
|
||||
scrollIPC := FALSE;
|
||||
ScrollChange;
|
||||
IF 0 IN K.MouseState() THEN
|
||||
WHILE (0 IN K.MouseState()) & (delay > 0) DO
|
||||
K.Pause(1);
|
||||
DEC(delay)
|
||||
END;
|
||||
IF delay = 0 THEN
|
||||
IPC[0] := 0;
|
||||
IPC[1] := 0;
|
||||
scrollIPC := TRUE;
|
||||
SendIPC;
|
||||
delay := 4
|
||||
ELSE
|
||||
delay := DELAY
|
||||
END
|
||||
ELSE
|
||||
delay := DELAY
|
||||
END
|
||||
END receiveIPC;
|
||||
|
||||
|
||||
PROCEDURE MouseDown (VAR scroll: tScroll; x, y: INTEGER);
|
||||
VAR
|
||||
c, size: INTEGER;
|
||||
BEGIN
|
||||
@ -342,16 +374,27 @@ BEGIN
|
||||
END MouseDown;
|
||||
|
||||
|
||||
PROCEDURE MouseUp* (VAR scroll: tScroll);
|
||||
PROCEDURE mouse* (VAR scroll: tScroll);
|
||||
VAR
|
||||
msState: SET;
|
||||
x, y: INTEGER;
|
||||
BEGIN
|
||||
IF scroll.mouse THEN
|
||||
scroll.Slider := -1;
|
||||
scroll.Inc := FALSE;
|
||||
scroll.Dec := FALSE;
|
||||
scroll.mouse := FALSE;
|
||||
K.mouse(msState, x, y);
|
||||
IF 0 IN msState THEN
|
||||
MouseDown(scroll, x, y);
|
||||
MouseMove(scroll, x, y)
|
||||
ELSIF scroll.mouse THEN
|
||||
MouseUp(scroll);
|
||||
paint(scroll)
|
||||
END
|
||||
END MouseUp;
|
||||
END mouse;
|
||||
|
||||
|
||||
PROCEDURE init* (_ScrollChange: tProcedure);
|
||||
BEGIN
|
||||
delay := DELAY;
|
||||
ScrollChange := _ScrollChange
|
||||
END init;
|
||||
|
||||
|
||||
END Scroll.
|
Loading…
Reference in New Issue
Block a user