forked from KolibriOS/kolibrios
CEdit: refactoring; fixed memory leak
git-svn-id: svn://kolibrios.org@9448 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
b87234501d
commit
e4ec81f666
Binary file not shown.
@ -25,10 +25,10 @@ IMPORT
|
||||
G := Graph, T := Text, E := Encodings,
|
||||
CB := Clipboard, Languages,
|
||||
ChangeLog, Scroll, CheckBox,
|
||||
RW, Ini, EB := EditBox, Icons, Tabs, Timer;
|
||||
RW, Ini, EB := EditBox, Tabs, Toolbar;
|
||||
|
||||
CONST
|
||||
HEADER = "CEdit (17-dec-2021)";
|
||||
HEADER = "CEdit (20-dec-2021)";
|
||||
|
||||
ShellFilter = "";
|
||||
EditFilter = "SH|INC|TXT|ASM|OB07|C|CPP|H|PAS|PP|LUA|INI|JSON";
|
||||
@ -38,6 +38,7 @@ CONST
|
||||
scrollWidth = 22;
|
||||
|
||||
btnClose = 1;
|
||||
|
||||
btnNew = 20;
|
||||
btnOpen = 21;
|
||||
btnSave = 22;
|
||||
@ -62,12 +63,10 @@ CONST
|
||||
|
||||
btnHeight = 25;
|
||||
btnWidth = 75;
|
||||
btnTop = Menu.MainMenuHeight + 3;
|
||||
toolBtnSize = 24;
|
||||
toolbarDelim = 7;
|
||||
iconPad = (toolBtnSize - Icons.SIZE) DIV 2;
|
||||
|
||||
TOP = btnTop + toolBtnSize + 10 + Tabs.tabHeight;
|
||||
toolbarTop = Menu.MainMenuHeight + 3;
|
||||
|
||||
TOP = toolbarTop + Toolbar.BtnSize + 10 + Tabs.tabHeight;
|
||||
RIGHT = scrollWidth - 2;
|
||||
BOTTOM = scrollWidth + 18;
|
||||
|
||||
@ -206,11 +205,13 @@ VAR
|
||||
|
||||
menuActive: BOOLEAN;
|
||||
|
||||
icons: INTEGER;
|
||||
grayIcons: INTEGER;
|
||||
toolbar: Toolbar.tToolbar;
|
||||
|
||||
IPC: ARRAY 64 OF INTEGER;
|
||||
|
||||
CursorTime, CurrentTime: INTEGER;
|
||||
timerEnabled: BOOLEAN;
|
||||
|
||||
|
||||
PROCEDURE WritePos (y: INTEGER);
|
||||
VAR
|
||||
@ -235,11 +236,12 @@ PROCEDURE resetTimer;
|
||||
BEGIN
|
||||
IF EditBox_Focus(FindEdit) OR EditBox_Focus(ReplaceEdit) OR EditBox_Focus(GotoEdit) THEN
|
||||
T.hideCursor;
|
||||
Timer.kill
|
||||
timerEnabled := FALSE
|
||||
ELSE
|
||||
T.showCursor;
|
||||
Timer.create(mainTID)
|
||||
END
|
||||
timerEnabled := TRUE
|
||||
END;
|
||||
CursorTime := CurrentTime
|
||||
END resetTimer;
|
||||
|
||||
|
||||
@ -283,7 +285,8 @@ CONST
|
||||
VAR
|
||||
top, left, right, bottom, x, y, width: INTEGER;
|
||||
BEGIN
|
||||
Timer.kill;
|
||||
timerEnabled := FALSE;
|
||||
CursorTime := CurrentTime;
|
||||
width := minWidth + LENGTH(s)*fontWidth;
|
||||
left := (canvas.width - width) DIV 2 + LEFT;
|
||||
top := (canvas.height - height) DIV 2 + TOP;
|
||||
@ -326,73 +329,6 @@ BEGIN
|
||||
END Replaced;
|
||||
|
||||
|
||||
PROCEDURE drawIcon (icons, idx, x: INTEGER);
|
||||
BEGIN
|
||||
Icons.draw(icons, idx, x + iconPad, btnTop + iconPad)
|
||||
END drawIcon;
|
||||
|
||||
|
||||
PROCEDURE toolbarIcons;
|
||||
VAR
|
||||
x, color, ico: INTEGER;
|
||||
BEGIN
|
||||
x := searchLeft + (toolBtnSize + 5)*2;
|
||||
IF text.modified THEN
|
||||
ico := icons
|
||||
ELSE
|
||||
ico := grayIcons
|
||||
END;
|
||||
drawIcon(ico, 5, x);
|
||||
|
||||
IF text.edition # NIL THEN
|
||||
x := searchLeft + (toolBtnSize + 5)*4 + toolbarDelim*2;
|
||||
IF ChangeLog.isFirstGuard(text.edition) THEN
|
||||
ico := grayIcons
|
||||
ELSE
|
||||
ico := icons
|
||||
END;
|
||||
drawIcon(ico, 37, x);
|
||||
|
||||
x := searchLeft + (toolBtnSize + 5)*5 + toolbarDelim*2;
|
||||
IF ChangeLog.isLastGuard(text.edition) THEN
|
||||
ico := grayIcons
|
||||
ELSE
|
||||
ico := icons
|
||||
END;
|
||||
drawIcon(ico, 36, x)
|
||||
END;
|
||||
|
||||
IF T.selected(text) THEN
|
||||
color := K.caseColor
|
||||
ELSE
|
||||
color := K.disCaseColor
|
||||
END;
|
||||
|
||||
x := searchLeft + (toolBtnSize + 5)*6 + toolbarDelim*3;
|
||||
K.DrawRect(x, btnTop, toolBtnSize, toolBtnSize, K.toolbarColor);
|
||||
K.DrawText69(x + (toolBtnSize - 12) DIV 2, btnTop + (toolBtnSize - 9) DIV 2 + 2, color, "AB");
|
||||
INC(x, toolBtnSize + 5);
|
||||
K.DrawRect(x, btnTop, toolBtnSize, toolBtnSize, K.toolbarColor);
|
||||
K.DrawText69(x + (toolBtnSize - 12) DIV 2, btnTop + (toolBtnSize - 9) DIV 2 + 2, color, "ab");
|
||||
|
||||
x := searchLeft + (toolBtnSize + 5)*8 + toolbarDelim*4;
|
||||
IF buildScript # "" THEN
|
||||
ico := icons
|
||||
ELSE
|
||||
ico := grayIcons
|
||||
END;
|
||||
drawIcon(ico, 54, x);
|
||||
|
||||
INC(x, toolBtnSize + 5);
|
||||
IF runScript # "" THEN
|
||||
ico := icons
|
||||
ELSE
|
||||
ico := grayIcons
|
||||
END;
|
||||
drawIcon(ico, 53, x)
|
||||
END toolbarIcons;
|
||||
|
||||
|
||||
PROCEDURE getIdx (text: T.tText): INTEGER;
|
||||
VAR
|
||||
i: INTEGER;
|
||||
@ -499,7 +435,14 @@ BEGIN
|
||||
G.DrawCanvas(canvas, LEFT, TOP);
|
||||
NotFound;
|
||||
Replaced;
|
||||
toolbarIcons
|
||||
Toolbar.enable(toolbar, btnSave, text.modified);
|
||||
Toolbar.enable(toolbar, btnUndo, ~ChangeLog.isFirstGuard(text.edition));
|
||||
Toolbar.enable(toolbar, btnRedo, ~ChangeLog.isLastGuard(text.edition));
|
||||
Toolbar.enable(toolbar, btnUpper, T.selected(text));
|
||||
Toolbar.enable(toolbar, btnLower, T.selected(text));
|
||||
Toolbar.enable(toolbar, btnBuild, buildScript # "");
|
||||
Toolbar.enable(toolbar, btnRun, runScript # "");
|
||||
Toolbar.drawIcons(toolbar)
|
||||
END
|
||||
END repaint;
|
||||
|
||||
@ -580,17 +523,7 @@ END SearchPanel;
|
||||
|
||||
PROCEDURE draw_window;
|
||||
VAR
|
||||
width, height, x: INTEGER;
|
||||
|
||||
|
||||
PROCEDURE drawToolbarBtn (id, x: INTEGER);
|
||||
BEGIN
|
||||
K.DrawRect(x, btnTop, toolBtnSize, toolBtnSize, K.toolbarColor);
|
||||
K.DrawLine(x, btnTop + toolBtnSize, x + toolBtnSize, btnTop + toolBtnSize, K.shadowColor);
|
||||
K.DrawLine(x + toolBtnSize, btnTop, x + toolBtnSize, btnTop + toolBtnSize, K.shadowColor);
|
||||
K.CreateButton(id + ORD({30}), x, btnTop, toolBtnSize, toolBtnSize, K.btnColor, "");
|
||||
END drawToolbarBtn;
|
||||
|
||||
width, height: INTEGER;
|
||||
|
||||
BEGIN
|
||||
K.BeginDraw;
|
||||
@ -607,42 +540,7 @@ BEGIN
|
||||
K.DrawRect(LEFT + canvas.width + 1, TOP + canvas.height, scrollWidth - 1, scrollWidth, K.winColor);
|
||||
Menu.DrawMain(mainMenu);
|
||||
|
||||
x := searchLeft;
|
||||
|
||||
drawToolbarBtn(btnNew, x);
|
||||
drawIcon(icons, 2, x);
|
||||
INC(x, toolBtnSize + 5);
|
||||
|
||||
drawToolbarBtn(btnOpen, x);
|
||||
drawIcon(icons, 0, x);
|
||||
INC(x, toolBtnSize + 5);
|
||||
|
||||
drawToolbarBtn(btnSave, x);
|
||||
INC(x, toolBtnSize + 5 + toolbarDelim);
|
||||
|
||||
drawToolbarBtn(btnSearch, x);
|
||||
drawIcon(icons, 49, x);
|
||||
INC(x, toolBtnSize + 5 + toolbarDelim);
|
||||
|
||||
drawToolbarBtn(btnUndo, x);
|
||||
INC(x, toolBtnSize + 5);
|
||||
|
||||
drawToolbarBtn(btnRedo, x);
|
||||
INC(x, toolBtnSize + 5 + toolbarDelim);
|
||||
|
||||
drawToolbarBtn(btnUpper, x);
|
||||
INC(x, toolBtnSize + 5);
|
||||
|
||||
drawToolbarBtn(btnLower, x);
|
||||
INC(x, toolBtnSize + 5 + toolbarDelim);
|
||||
|
||||
drawToolbarBtn(btnBuild, x);
|
||||
INC(x, toolBtnSize + 5);
|
||||
|
||||
drawToolbarBtn(btnRun, x);
|
||||
INC(x, toolBtnSize + 5);
|
||||
|
||||
toolbarIcons;
|
||||
Toolbar.draw(toolbar);
|
||||
|
||||
DrawState(text, width, height);
|
||||
IF search & searchOpened THEN
|
||||
@ -668,7 +566,8 @@ END mouse;
|
||||
PROCEDURE stopTimer;
|
||||
BEGIN
|
||||
T.hideCursor;
|
||||
Timer.kill;
|
||||
timerEnabled := FALSE;
|
||||
CursorTime := CurrentTime;
|
||||
repaint
|
||||
END stopTimer;
|
||||
|
||||
@ -832,6 +731,7 @@ BEGIN
|
||||
Confirm
|
||||
ELSE
|
||||
Tabs.delete(tabs, n);
|
||||
T.destroy(texts[n]);
|
||||
FOR i := n + 1 TO textsCount - 1 DO
|
||||
texts[i - 1] := texts[i]
|
||||
END;
|
||||
@ -1065,9 +965,7 @@ END Script;
|
||||
PROCEDURE ShowSearchPanel (goto: BOOLEAN);
|
||||
VAR
|
||||
i: INTEGER;
|
||||
(*flag: BOOLEAN;*)
|
||||
BEGIN
|
||||
(*flag := FALSE;*)
|
||||
IF T.selected(text) & ~goto THEN
|
||||
T.getSelectedText(text, new_searchText);
|
||||
IF new_searchText # "" THEN
|
||||
@ -1079,7 +977,6 @@ BEGIN
|
||||
searchText := new_searchText;
|
||||
EB.setValue(FindEdit, searchText);
|
||||
notFound := ~T.search(text, searchText, cs, whole);
|
||||
(*flag := TRUE*)
|
||||
END
|
||||
END
|
||||
END;
|
||||
@ -1092,7 +989,7 @@ BEGIN
|
||||
IF goto THEN
|
||||
SetFocus(GotoEdit, TRUE)
|
||||
ELSE
|
||||
SetFocus(FindEdit, (*~flag*)TRUE)
|
||||
SetFocus(FindEdit, TRUE)
|
||||
END
|
||||
END ShowSearchPanel;
|
||||
|
||||
@ -1203,7 +1100,7 @@ BEGIN
|
||||
Menu.option(subEOL, menuCR, T.getEol(text) = RW.EOL_CR);
|
||||
|
||||
IF menu # NIL THEN
|
||||
Timer.kill;
|
||||
timerEnabled := FALSE;
|
||||
IF Menu.opened(menu) THEN
|
||||
Menu.close(menu)
|
||||
END;
|
||||
@ -1230,13 +1127,7 @@ VAR
|
||||
item: List.tItem;
|
||||
BEGIN
|
||||
scrollIPC := FALSE;
|
||||
IF IPC[0] = Timer.ID THEN
|
||||
IF IPC[4] = Timer.n THEN
|
||||
T.toggleCursor;
|
||||
repaint
|
||||
END;
|
||||
IPC[2] := 0
|
||||
ELSIF IPC[0] = mainTID THEN
|
||||
IF IPC[0] = mainTID THEN
|
||||
IF IPC[2] = Scroll.ScrollIPC THEN
|
||||
Scroll.receiveIPC(IPC, scrollIPC)
|
||||
END;
|
||||
@ -1870,8 +1761,8 @@ BEGIN
|
||||
END
|
||||
END;
|
||||
CASE btn OF
|
||||
|Tabs.btnID - 1: Tabs.scroll(tabs, -1); switch := TRUE; repaint
|
||||
|Tabs.btnID - 2: Tabs.scroll(tabs, +1); switch := TRUE; repaint
|
||||
|Tabs.btnLeft: Tabs.scroll(tabs, -1); switch := TRUE; repaint
|
||||
|Tabs.btnRight: Tabs.scroll(tabs, +1); switch := TRUE; repaint
|
||||
|
||||
|0:
|
||||
|
||||
@ -2049,7 +1940,6 @@ VAR
|
||||
i: INTEGER;
|
||||
BEGIN
|
||||
K.GetSystemColors;
|
||||
Icons.get(icons, grayIcons);
|
||||
FOR i := 0 TO 1 DO
|
||||
IF ~K.RolledUp() THEN
|
||||
K.ClientSize(width, height);
|
||||
@ -2092,7 +1982,6 @@ VAR
|
||||
firstClickX, firstClickY, time: INTEGER;
|
||||
BEGIN
|
||||
K.GetSystemColors;
|
||||
Icons.get(icons, grayIcons);
|
||||
modified := FALSE;
|
||||
switch := FALSE;
|
||||
closing := FALSE;
|
||||
@ -2153,6 +2042,22 @@ BEGIN
|
||||
Menu.AddMainItem(mainMenu, "program", menuProgram);
|
||||
Menu.AddMainItem(mainMenu, "tools", menuTools);
|
||||
|
||||
Toolbar.create(toolbar, searchLeft, toolbarTop);
|
||||
Toolbar.add(toolbar, btnNew, 2, "");
|
||||
Toolbar.add(toolbar, btnOpen, 0, "");
|
||||
Toolbar.add(toolbar, btnSave, 5, "");
|
||||
Toolbar.delimiter(toolbar);
|
||||
Toolbar.add(toolbar, btnSearch, 49, "");
|
||||
Toolbar.delimiter(toolbar);
|
||||
Toolbar.add(toolbar, btnUndo, 37, "");
|
||||
Toolbar.add(toolbar, btnRedo, 36, "");
|
||||
Toolbar.delimiter(toolbar);
|
||||
Toolbar.add(toolbar, btnUpper, -1, "AB");
|
||||
Toolbar.add(toolbar, btnLower, -1, "ab");
|
||||
Toolbar.delimiter(toolbar);
|
||||
Toolbar.add(toolbar, btnBuild, 54, "");
|
||||
Toolbar.add(toolbar, btnRun, 53, "");
|
||||
|
||||
Ini.getSettings(buildScript, runScript, debugScript);
|
||||
IF fileName = "" THEN
|
||||
text := T.New();
|
||||
@ -2188,9 +2093,17 @@ BEGIN
|
||||
K.SetEventsMask({0, 1, 2, 5, 6, 31});
|
||||
Menu.init(resetTimer);
|
||||
draw_window;
|
||||
Timer.create(mainTID);
|
||||
timerEnabled := TRUE;
|
||||
CursorTime := K.GetTickCount();
|
||||
WHILE TRUE DO
|
||||
CASE K.WaitForEvent() OF
|
||||
CurrentTime := K.GetTickCount();
|
||||
IF (CurrentTime - CursorTime > Ini.blink) & timerEnabled THEN
|
||||
CursorTime := CurrentTime;
|
||||
T.toggleCursor;
|
||||
repaint
|
||||
END;
|
||||
CASE K.EventTimeout(10) OF
|
||||
|0:
|
||||
|1: Redraw(resized, width, height, cliWidth, cliHeight)
|
||||
|2: KeyDown(K.GetKey())
|
||||
|3: BtnClick
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
MODULE ChangeLog;
|
||||
|
||||
IMPORT List, Lines, (*API,*) SYSTEM;
|
||||
IMPORT List, Lines, API, SYSTEM;
|
||||
|
||||
TYPE
|
||||
tIntItem = POINTER TO RECORD (List.tItem)
|
||||
@ -29,7 +29,7 @@ TYPE
|
||||
tBoolItem = POINTER TO RECORD (List.tItem)
|
||||
adr: INTEGER; val: BOOLEAN; save: BOOLEAN
|
||||
END;
|
||||
(*
|
||||
|
||||
tUntypedPtr = POINTER TO RECORD (List.tItem)
|
||||
p: INTEGER
|
||||
END;
|
||||
@ -37,13 +37,13 @@ TYPE
|
||||
tTypedPtr = POINTER TO RECORD (List.tItem)
|
||||
p: List.tItem
|
||||
END;
|
||||
*)
|
||||
|
||||
tGuard* = POINTER TO RECORD (List.tItem)
|
||||
saved*: BOOLEAN
|
||||
END;
|
||||
|
||||
tLog* = POINTER TO RECORD
|
||||
Log*: List.tList;
|
||||
Log*, Pointers*: List.tList;
|
||||
guard: tGuard;
|
||||
isLast: BOOLEAN
|
||||
END;
|
||||
@ -104,18 +104,11 @@ END redo;
|
||||
PROCEDURE clear (guard: tGuard);
|
||||
VAR
|
||||
item: List.tItem;
|
||||
(*res: INTEGER;*)
|
||||
BEGIN
|
||||
CL.isLast := TRUE;
|
||||
REPEAT
|
||||
item := List.pop(CL.Log);
|
||||
IF item # guard THEN
|
||||
(*
|
||||
IF item IS tUntypedPtr THEN
|
||||
res := API._DISPOSE(item(tUntypedPtr).p)
|
||||
ELSIF item IS tTypedPtr THEN
|
||||
DISPOSE(item(tTypedPtr).p)
|
||||
END;*)
|
||||
DISPOSE(item)
|
||||
END
|
||||
UNTIL item = guard;
|
||||
@ -253,14 +246,14 @@ BEGIN
|
||||
changeWord(SYSTEM.ADR(v), SYSTEM.ADR(x))
|
||||
END changePtr;
|
||||
|
||||
(*
|
||||
|
||||
PROCEDURE typedPtr (p: List.tItem);
|
||||
VAR
|
||||
item: tTypedPtr;
|
||||
BEGIN
|
||||
NEW(item);
|
||||
item.p := p;
|
||||
List.append(Log, item)
|
||||
List.append(CL.Pointers, item)
|
||||
END typedPtr;
|
||||
|
||||
|
||||
@ -270,9 +263,9 @@ VAR
|
||||
BEGIN
|
||||
NEW(item);
|
||||
item.p := p;
|
||||
List.append(Log, item)
|
||||
List.append(CL.Pointers, item)
|
||||
END untypedPtr;
|
||||
*)
|
||||
|
||||
|
||||
PROCEDURE set* (_CL: tLog);
|
||||
BEGIN
|
||||
@ -288,13 +281,44 @@ BEGIN
|
||||
newLog.guard := NIL;
|
||||
newLog.isLast := TRUE;
|
||||
newLog.Log := List.create(NIL);
|
||||
newLog.Pointers := List.create(NIL);
|
||||
CL := newLog;
|
||||
Lines.setMaxLength(maxLength)
|
||||
RETURN newLog
|
||||
END create;
|
||||
|
||||
|
||||
PROCEDURE destroy* (VAR log: tLog);
|
||||
VAR
|
||||
item: List.tItem;
|
||||
res: INTEGER;
|
||||
BEGIN
|
||||
IF log # NIL THEN
|
||||
item := List.pop(log.Log);
|
||||
WHILE item # NIL DO
|
||||
DISPOSE(item);
|
||||
item := List.pop(log.Log)
|
||||
END;
|
||||
DISPOSE(log.Log);
|
||||
|
||||
item := List.pop(log.Pointers);
|
||||
WHILE item # NIL DO
|
||||
IF item IS tUntypedPtr THEN
|
||||
res := API._DISPOSE(item(tUntypedPtr).p)
|
||||
ELSIF item IS tTypedPtr THEN
|
||||
DISPOSE(item(tTypedPtr).p)
|
||||
END;
|
||||
DISPOSE(item);
|
||||
item := List.pop(log.Pointers)
|
||||
END;
|
||||
DISPOSE(log.Pointers);
|
||||
|
||||
DISPOSE(log)
|
||||
END
|
||||
END destroy;
|
||||
|
||||
|
||||
BEGIN
|
||||
List.init(changeInt, changePtr);
|
||||
Lines.init(changeInt, changePtr, changeBool, changeBool2(*, typedPtr, untypedPtr*))
|
||||
Lines.init(changeInt, changePtr, changeBool, changeBool2, typedPtr, untypedPtr)
|
||||
END ChangeLog.
|
@ -45,7 +45,6 @@ TYPE
|
||||
PROCEDURE paint* (chkbox: tCheckBox);
|
||||
VAR
|
||||
canvas: G.tCanvas;
|
||||
(*r1, r2, g1, g2, b1, b2: BYTE;*)
|
||||
BEGIN
|
||||
canvas := chkbox.canvas;
|
||||
IF canvas # NIL THEN
|
||||
@ -61,10 +60,6 @@ BEGIN
|
||||
G.DLine(canvas, 2, 6, 7, -1);
|
||||
G.DLine(canvas, 7, 13, 9, 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);
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
MODULE Clipboard;
|
||||
|
||||
IMPORT SYSTEM, K := KOSAPI, E := Encodings, Lines;
|
||||
IMPORT SYSTEM, KOSAPI, E := Encodings, Lines, K := KolibriOS;
|
||||
|
||||
CONST
|
||||
TTEXT = 0;
|
||||
@ -35,7 +35,7 @@ TYPE
|
||||
|
||||
PROCEDURE free (ptr: INTEGER);
|
||||
BEGIN
|
||||
ptr := K.free(ptr)
|
||||
ptr := KOSAPI.free(ptr)
|
||||
END free;
|
||||
|
||||
|
||||
@ -52,7 +52,7 @@ VAR
|
||||
BEGIN
|
||||
cnt := bufSize(buffer) DIV 2;
|
||||
size := cnt + 12;
|
||||
a := K.malloc(size);
|
||||
a := KOSAPI.malloc(size);
|
||||
ASSERT(a # 0);
|
||||
SYSTEM.PUT32(a + 4, TTEXT);
|
||||
SYSTEM.PUT32(a + 8, 1);
|
||||
@ -70,8 +70,8 @@ BEGIN
|
||||
DEC(cnt)
|
||||
END;
|
||||
SYSTEM.PUT32(a, size);
|
||||
K.sysfunc2(54, 3);
|
||||
K.sysfunc4(54, 2, size, a)
|
||||
K.CBDelSlot;
|
||||
K.CBWrite(size, a)
|
||||
END put;
|
||||
|
||||
|
||||
@ -80,7 +80,7 @@ VAR
|
||||
res: tBuffer;
|
||||
BEGIN
|
||||
NEW(res);
|
||||
res.dataPtr := K.malloc(bufSize*SYSTEM.SIZE(WCHAR) + 4096);
|
||||
res.dataPtr := KOSAPI.malloc(bufSize*SYSTEM.SIZE(WCHAR) + 4096);
|
||||
ASSERT(res.dataPtr # 0);
|
||||
res.pos := res.dataPtr
|
||||
RETURN res
|
||||
@ -139,9 +139,9 @@ VAR
|
||||
res: BOOLEAN;
|
||||
BEGIN
|
||||
res := FALSE;
|
||||
n := K.sysfunc2(54, 0);
|
||||
n := K.CBCount();
|
||||
IF n > 0 THEN
|
||||
ptr := K.sysfunc3(54, 1, n - 1);
|
||||
ptr := K.CBRead(n - 1);
|
||||
SYSTEM.GET32(ptr, size);
|
||||
SYSTEM.GET32(ptr + 4, typ);
|
||||
SYSTEM.GET(ptr + 8, x);
|
||||
@ -159,7 +159,7 @@ BEGIN
|
||||
ptr := 0;
|
||||
cnt := 0;
|
||||
IF available() THEN
|
||||
ptr := K.sysfunc3(54, 1, K.sysfunc2(54, 0) - 1);
|
||||
ptr := K.CBRead(K.CBCount() - 1);
|
||||
SYSTEM.GET32(ptr, cnt);
|
||||
DEC(cnt, 12);
|
||||
INC(ptr, 12)
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
MODULE Graph;
|
||||
|
||||
IMPORT SYSTEM, K := KOSAPI, Lines, Languages;
|
||||
IMPORT SYSTEM, KOSAPI, Lines, Languages;
|
||||
|
||||
CONST
|
||||
|
||||
@ -61,7 +61,7 @@ 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);
|
||||
KOSAPI.sysfunc7(65, canvas.bitmap, canvas.width*65536 + canvas.height, x*65536 + y, 32, 0, 0)
|
||||
END DrawCanvas;
|
||||
|
||||
|
||||
@ -285,7 +285,7 @@ BEGIN
|
||||
ELSE
|
||||
color := canvas.textColor
|
||||
END;
|
||||
K.sysfunc6(4, x*65536 + y, font + color, SYSTEM.ADR(c), 1, canvas.bitmap - 8)
|
||||
KOSAPI.sysfunc6(4, x*65536 + y, font + color, SYSTEM.ADR(c), 1, canvas.bitmap - 8)
|
||||
END;
|
||||
INC(x, canvas.font.width);
|
||||
INC(i);
|
||||
@ -307,7 +307,7 @@ VAR
|
||||
canvas: tCanvas;
|
||||
BEGIN
|
||||
NEW(canvas);
|
||||
canvas.bitmap := K.malloc(width*height*4 + 8);
|
||||
canvas.bitmap := KOSAPI.malloc(width*height*4 + 8);
|
||||
ASSERT(canvas.bitmap # 0);
|
||||
SYSTEM.PUT32(canvas.bitmap, width);
|
||||
SYSTEM.PUT32(canvas.bitmap + 4, height);
|
||||
@ -322,7 +322,7 @@ END CreateCanvas;
|
||||
PROCEDURE destroy* (VAR canvas: tCanvas);
|
||||
BEGIN
|
||||
IF canvas # NIL THEN
|
||||
canvas.bitmap := K.free(canvas.bitmap);
|
||||
canvas.bitmap := KOSAPI.free(canvas.bitmap);
|
||||
DISPOSE(canvas)
|
||||
END
|
||||
END destroy;
|
||||
|
@ -31,7 +31,7 @@ VAR
|
||||
winColor*, textColor*, btnColor*, btnTextColor*,
|
||||
toolbarColor*, scrollColor*, scrollBkColor*,
|
||||
borderColor*, shadowColor*, (*darkColor,*) lightColor*,
|
||||
caseColor*, disCaseColor*: INTEGER;
|
||||
textToolbarColor*, disTextToolbarColor*: INTEGER;
|
||||
|
||||
|
||||
PROCEDURE GetCommandLine* (): INTEGER;
|
||||
@ -62,9 +62,9 @@ BEGIN
|
||||
END EndDraw;
|
||||
|
||||
|
||||
PROCEDURE WaitForEvent* (): INTEGER;
|
||||
RETURN KOSAPI.sysfunc1(10)
|
||||
END WaitForEvent;
|
||||
PROCEDURE EventTimeout* (t: INTEGER): INTEGER;
|
||||
RETURN KOSAPI.sysfunc2(23, t)
|
||||
END EventTimeout;
|
||||
|
||||
|
||||
PROCEDURE ThreadInfo (offsa, offsb: INTEGER; VAR a, b: INTEGER);
|
||||
@ -319,11 +319,6 @@ PROCEDURE GetControlKeys* (): SET;
|
||||
END GetControlKeys;
|
||||
|
||||
|
||||
PROCEDURE malloc* (size: INTEGER): INTEGER;
|
||||
RETURN KOSAPI.malloc(size)
|
||||
END malloc;
|
||||
|
||||
|
||||
PROCEDURE SetIPC* (buffer: ARRAY OF INTEGER);
|
||||
BEGIN
|
||||
KOSAPI.sysfunc4(60, 1, SYSTEM.ADR(buffer[0]), LEN(buffer)*SYSTEM.SIZE(INTEGER))
|
||||
@ -355,8 +350,8 @@ BEGIN
|
||||
|
||||
toolbarColor := lightColor;(*0DFDFDFH;*)
|
||||
shadowColor := borderColor;(*0808080H;*)
|
||||
caseColor := 00000FFH;
|
||||
disCaseColor := borderColor;(*0808080H*)
|
||||
textToolbarColor := 00000FFH;
|
||||
disTextToolbarColor := borderColor;(*0808080H*)
|
||||
END GetSystemColors;
|
||||
|
||||
|
||||
@ -391,4 +386,31 @@ BEGIN
|
||||
END SetCaption;
|
||||
|
||||
|
||||
PROCEDURE CBCount* (): INTEGER;
|
||||
RETURN KOSAPI.sysfunc2(54, 0)
|
||||
END CBCount;
|
||||
|
||||
|
||||
PROCEDURE CBRead* (slot: INTEGER): INTEGER;
|
||||
RETURN KOSAPI.sysfunc3(54, 1, slot)
|
||||
END CBRead;
|
||||
|
||||
|
||||
PROCEDURE CBWrite* (size, ptr: INTEGER);
|
||||
BEGIN
|
||||
KOSAPI.sysfunc4(54, 2, size, ptr)
|
||||
END CBWrite;
|
||||
|
||||
|
||||
PROCEDURE CBDelSlot*;
|
||||
BEGIN
|
||||
KOSAPI.sysfunc2(54, 3)
|
||||
END CBDelSlot;
|
||||
|
||||
|
||||
PROCEDURE GetThreadSlot* (tid: INTEGER): INTEGER;
|
||||
RETURN KOSAPI.sysfunc3(18, 21, tid)
|
||||
END GetThreadSlot;
|
||||
|
||||
|
||||
END KolibriOS.
|
@ -40,18 +40,18 @@ TYPE
|
||||
PmovInt = PROCEDURE (VAR v: INTEGER; x: INTEGER);
|
||||
PmovBool = PROCEDURE (VAR v: BOOLEAN; x: BOOLEAN);
|
||||
PmovPtr = PROCEDURE (VAR v: List.tItem; x: List.tItem);
|
||||
(*
|
||||
|
||||
PTypedPtr = PROCEDURE (p: List.tItem);
|
||||
PUntypedPtr = PROCEDURE (p: INTEGER);
|
||||
*)
|
||||
|
||||
|
||||
VAR
|
||||
|
||||
_movInt: PmovInt;
|
||||
_movBool, _movBool2: PmovBool;
|
||||
_movPtr: PmovPtr;
|
||||
(* _typedPtr: PTypedPtr;
|
||||
_untypedPtr: PUntypedPtr;*)
|
||||
_typedPtr: PTypedPtr;
|
||||
_untypedPtr: PUntypedPtr;
|
||||
|
||||
pMaxLength, tab*: INTEGER;
|
||||
tabs*: BOOLEAN;
|
||||
@ -83,7 +83,6 @@ END movPtr;
|
||||
|
||||
PROCEDURE malloc (size: INTEGER): INTEGER;
|
||||
VAR
|
||||
ptr: INTEGER;
|
||||
maxLength: INTEGER;
|
||||
BEGIN
|
||||
ASSERT(pMaxLength # 0);
|
||||
@ -92,9 +91,8 @@ BEGIN
|
||||
SYSTEM.PUT(pMaxLength, size)
|
||||
END;
|
||||
size := size*WCHAR_SIZE + 4;
|
||||
INC(size, (-size) MOD 32);
|
||||
ptr := API._NEW(size)
|
||||
RETURN ptr
|
||||
INC(size, (-size) MOD 32)
|
||||
RETURN API._NEW(size)
|
||||
END malloc;
|
||||
|
||||
|
||||
@ -109,9 +107,9 @@ BEGIN
|
||||
END;
|
||||
IF ~line.temp THEN
|
||||
movInt(line.ptr, newPtr);
|
||||
(* IF newPtr # 0 THEN
|
||||
IF newPtr # 0 THEN
|
||||
_untypedPtr(newPtr)
|
||||
END*)
|
||||
END
|
||||
END;
|
||||
line.ptr := newPtr
|
||||
END free;
|
||||
@ -124,9 +122,9 @@ BEGIN
|
||||
NEW(line);
|
||||
line.label := FALSE;
|
||||
ASSERT(line # NIL);
|
||||
(* IF ~temp THEN
|
||||
IF ~temp THEN
|
||||
_typedPtr(line)
|
||||
END;*)
|
||||
END;
|
||||
line.next := NIL;
|
||||
line.prev := NIL;
|
||||
IF ~temp THEN
|
||||
@ -136,7 +134,7 @@ BEGIN
|
||||
line.ptr := malloc(1);
|
||||
ASSERT(line.ptr # 0);
|
||||
IF ~temp THEN
|
||||
(*_untypedPtr(line.ptr);*)
|
||||
_untypedPtr(line.ptr);
|
||||
movInt(line.ptr, line.ptr)
|
||||
END;
|
||||
SYSTEM.PUT16(line.ptr, 0);
|
||||
@ -472,14 +470,14 @@ BEGIN
|
||||
END chCase;
|
||||
|
||||
|
||||
PROCEDURE init* (movInt: PmovInt; movPtr: PmovPtr; movBool, movBool2: PmovBool(*; typedPtr: PTypedPtr; untypedPtr: PUntypedPtr*));
|
||||
PROCEDURE init* (movInt: PmovInt; movPtr: PmovPtr; movBool, movBool2: PmovBool; typedPtr: PTypedPtr; untypedPtr: PUntypedPtr);
|
||||
BEGIN
|
||||
_movInt := movInt;
|
||||
_movPtr := movPtr;
|
||||
_movBool := movBool;
|
||||
_movBool2 := movBool2;
|
||||
(* _typedPtr := typedPtr;
|
||||
_untypedPtr := untypedPtr;*)
|
||||
_typedPtr := typedPtr;
|
||||
_untypedPtr := untypedPtr;
|
||||
END init;
|
||||
|
||||
|
||||
|
@ -20,7 +20,7 @@
|
||||
MODULE Menu;
|
||||
|
||||
IMPORT
|
||||
SYSTEM, G := Graph, List, K := KolibriOS, KOSAPI;
|
||||
SYSTEM, G := Graph, List, K := KolibriOS;
|
||||
|
||||
CONST
|
||||
fontHeight = 22;
|
||||
@ -259,26 +259,26 @@ BEGIN
|
||||
TextColor := disSelForeColor
|
||||
END
|
||||
END;
|
||||
Y := y + (fontHeight - 16) DIV 2;
|
||||
G.SetColor(canvas, BkColor);
|
||||
G.FillRect(canvas, 1, y, m.width - 1, y + fontHeight - 4);
|
||||
G.SetTextColor(canvas, TextColor);
|
||||
G.SetBkColor(canvas, BkColor);
|
||||
G.TextOut2(canvas, LEFT, y + (fontHeight - 16) DIV 2 - 2, item.text, LENGTH(item.text));
|
||||
G.TextOut2(canvas, LEFT, Y - 2, item.text, LENGTH(item.text));
|
||||
|
||||
G.SetColor(canvas, TextColor);
|
||||
IF item.check = 1 THEN
|
||||
G.DLine(canvas, 4, 7, y + (fontHeight - 16) DIV 2 + 5, -1);
|
||||
G.DLine(canvas, 4, 7, y + (fontHeight - 16) DIV 2 + 6, -1);
|
||||
G.DLine(canvas, 7, 12, y + (fontHeight - 16) DIV 2 + 8, 1);
|
||||
G.DLine(canvas, 7, 12, y + (fontHeight - 16) DIV 2 + 9, 1);
|
||||
G.DLine(canvas, 4, 7, Y + 5, -1);
|
||||
G.DLine(canvas, 4, 7, Y + 6, -1);
|
||||
G.DLine(canvas, 7, 12, Y + 8, 1);
|
||||
G.DLine(canvas, 7, 12, Y + 9, 1);
|
||||
ELSIF item.check = 2 THEN
|
||||
G.FillRect(canvas, 6, y + fontHeight DIV 2 - 4, 10, y + fontHeight DIV 2)
|
||||
END;
|
||||
|
||||
IF item.child # NIL THEN
|
||||
X := m.width - 9;
|
||||
Y := y + (fontHeight - 16) DIV 2 + 2;
|
||||
G.Triangle(canvas, X, Y, X, Y + 8, G.triRight)
|
||||
G.Triangle(canvas, X, Y + 2, X, Y + 10, G.triRight)
|
||||
END;
|
||||
|
||||
INC(y, fontHeight);
|
||||
@ -391,8 +391,8 @@ END submenu;
|
||||
PROCEDURE [stdcall] window (m: tMenu);
|
||||
VAR
|
||||
x, y: INTEGER;
|
||||
key, temp: INTEGER;
|
||||
msState: SET;
|
||||
key, temp: INTEGER;
|
||||
shift, ctrl: BOOLEAN;
|
||||
BEGIN
|
||||
m.selItem := ORD(m.keyboard) - 1;
|
||||
@ -400,7 +400,8 @@ BEGIN
|
||||
m.keyboard := FALSE;
|
||||
K.SetEventsMask({0, 1, 5});
|
||||
WHILE TRUE DO
|
||||
CASE K.WaitForEvent() OF
|
||||
CASE K.EventTimeout(100) OF
|
||||
|0:
|
||||
|1:
|
||||
draw_window(m)
|
||||
|2:
|
||||
@ -408,15 +409,9 @@ BEGIN
|
||||
key := K.GetKey();
|
||||
IF ~shift & ~ ctrl THEN
|
||||
IF key DIV 65536 = 72 THEN
|
||||
DEC(m.selItem);
|
||||
IF m.selItem < 0 THEN
|
||||
m.selItem := m.items.count - 1
|
||||
END
|
||||
m.selItem := (m.selItem - 1) MOD m.items.count
|
||||
ELSIF key DIV 65536 = 80 THEN
|
||||
INC(m.selItem);
|
||||
IF m.selItem >= m.items.count THEN
|
||||
m.selItem := 0
|
||||
END
|
||||
m.selItem := (m.selItem + 1) MOD m.items.count
|
||||
ELSIF key DIV 65536 = 28 THEN
|
||||
IF m.selItem >= 0 THEN
|
||||
click(m, m.selItem)
|
||||
@ -504,7 +499,7 @@ VAR
|
||||
BEGIN
|
||||
IF m.tid = 0 THEN
|
||||
L := level(m);
|
||||
IF KOSAPI.sysfunc3(18, 21, TIDs[L]) = 0 THEN
|
||||
IF K.GetThreadSlot(TIDs[L]) = 0 THEN
|
||||
m.winX := x;
|
||||
m.winY := y;
|
||||
SYSTEM.PUT(SYSTEM.ADR(stack[L][LEN(stack[0]) - 1]), m);
|
||||
|
@ -24,6 +24,8 @@ IMPORT List, K := KolibriOS, RW, U := Utils;
|
||||
CONST
|
||||
|
||||
btnID* = 100;
|
||||
btnLeft* = btnID - 1;
|
||||
btnRight* = btnID - 2;
|
||||
tabHeight* = 22;
|
||||
curTabHeight = 26;
|
||||
scrWidth = 15;
|
||||
@ -116,10 +118,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.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, ">");
|
||||
K.DeleteButton(btnLeft);
|
||||
K.DeleteButton(btnRight);
|
||||
K.CreateButton(btnLeft, t.x, y, scrWidth, t.height - 1, K.btnColor, "<");
|
||||
K.CreateButton(btnRight, t.x + scrWidth, y, scrWidth, t.height - 1, K.btnColor, ">");
|
||||
scroll := TRUE
|
||||
ELSE
|
||||
t.first := 0;
|
||||
@ -199,7 +201,8 @@ VAR
|
||||
item: List.tItem;
|
||||
BEGIN
|
||||
item := List.getItem(t.strings, n);
|
||||
List.delete(t.strings, item)
|
||||
List.delete(t.strings, item);
|
||||
DISPOSE(item)
|
||||
END delete;
|
||||
|
||||
|
||||
|
@ -2398,9 +2398,7 @@ END resize;
|
||||
PROCEDURE destroy* (VAR text: tText);
|
||||
BEGIN
|
||||
IF search(text, "", FALSE, FALSE) THEN END;
|
||||
WHILE text.last # NIL DO
|
||||
DelLine(text, text.last(tLine))
|
||||
END;
|
||||
ChangeLog.destroy(text.chLog);
|
||||
DISPOSE(text.foundList);
|
||||
DISPOSE(text.cursor);
|
||||
DISPOSE(text.select2);
|
||||
|
@ -1,80 +0,0 @@
|
||||
(*
|
||||
Copyright 2021 Anton Krotov
|
||||
|
||||
This file is part of CEdit.
|
||||
|
||||
CEdit is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
CEdit is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with CEdit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*)
|
||||
|
||||
MODULE Timer;
|
||||
|
||||
IMPORT SYSTEM, K := KolibriOS, KOSAPI, Ini;
|
||||
|
||||
VAR
|
||||
stack: ARRAY 1024*64 OF INTEGER;
|
||||
ID*, n*, time, cnt: INTEGER;
|
||||
enabled: BOOLEAN;
|
||||
msg: ARRAY 3 OF INTEGER;
|
||||
|
||||
|
||||
PROCEDURE kill*;
|
||||
BEGIN
|
||||
enabled := FALSE;
|
||||
INC(n)
|
||||
END kill;
|
||||
|
||||
|
||||
PROCEDURE [stdcall] main (mainTID: INTEGER);
|
||||
CONST
|
||||
step = 5;
|
||||
BEGIN
|
||||
msg[0] := ID;
|
||||
msg[1] := 12;
|
||||
WHILE TRUE DO
|
||||
K.Pause(step);
|
||||
IF KOSAPI.sysfunc3(18, 21, mainTID) = 0 THEN
|
||||
ID := 0;
|
||||
K.Exit
|
||||
END;
|
||||
IF enabled THEN
|
||||
DEC(cnt, step);
|
||||
IF cnt <= 0 THEN
|
||||
K.SendIPC(mainTID, msg);
|
||||
cnt := time
|
||||
END
|
||||
END
|
||||
END
|
||||
END main;
|
||||
|
||||
|
||||
PROCEDURE create* (mainTID: INTEGER);
|
||||
BEGIN
|
||||
time := Ini.blink;
|
||||
cnt := time;
|
||||
enabled := TRUE;
|
||||
IF ID = 0 THEN
|
||||
stack[LEN(stack) - 1] := mainTID;
|
||||
ID := K.CreateThread(SYSTEM.ADR(main), stack)
|
||||
ELSE
|
||||
INC(n);
|
||||
msg[2] := n
|
||||
END
|
||||
END create;
|
||||
|
||||
|
||||
BEGIN
|
||||
ID := 0;
|
||||
msg[2] := 0;
|
||||
n := 0;
|
||||
END Timer.
|
151
programs/develop/cedit/SRC/Toolbar.ob07
Normal file
151
programs/develop/cedit/SRC/Toolbar.ob07
Normal file
@ -0,0 +1,151 @@
|
||||
(*
|
||||
Copyright 2021 Anton Krotov
|
||||
|
||||
This file is part of CEdit.
|
||||
|
||||
CEdit is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
CEdit is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with CEdit. If not, see <http://www.gnu.org/licenses/>.
|
||||
*)
|
||||
|
||||
MODULE Toolbar;
|
||||
|
||||
IMPORT
|
||||
Icons, K := KolibriOS;
|
||||
|
||||
CONST
|
||||
max = 14;
|
||||
|
||||
BtnSize* = 24;
|
||||
BtnInter = 5;
|
||||
DelimSize = 7;
|
||||
IconPad = (BtnSize - Icons.SIZE) DIV 2;
|
||||
|
||||
TYPE
|
||||
tButtonText = ARRAY 4 OF CHAR;
|
||||
|
||||
tButton = RECORD
|
||||
btn, icon, x: INTEGER;
|
||||
text: tButtonText;
|
||||
enabled: BOOLEAN
|
||||
END;
|
||||
|
||||
tToolbar* = RECORD
|
||||
buttons: ARRAY max OF tButton;
|
||||
x, y, cnt, width: INTEGER;
|
||||
icons, grayIcons: INTEGER
|
||||
END;
|
||||
|
||||
|
||||
PROCEDURE drawIcons* (toolbar: tToolbar);
|
||||
VAR
|
||||
i, icons, color: INTEGER;
|
||||
button: tButton;
|
||||
BEGIN
|
||||
i := 0;
|
||||
WHILE i < toolbar.cnt DO
|
||||
button := toolbar.buttons[i];
|
||||
IF button.btn # 0 THEN
|
||||
IF button.enabled THEN
|
||||
icons := toolbar.icons;
|
||||
color := K.textToolbarColor
|
||||
ELSE
|
||||
icons := toolbar.grayIcons;
|
||||
color := K.disTextToolbarColor
|
||||
END;
|
||||
IF button.icon # -1 THEN
|
||||
Icons.draw(icons, button.icon, button.x + IconPad, toolbar.y + IconPad)
|
||||
ELSE
|
||||
K.DrawRect(button.x, toolbar.y, BtnSize, BtnSize, K.toolbarColor);
|
||||
K.DrawText69(button.x + (BtnSize - LENGTH(button.text)*6) DIV 2, toolbar.y + (BtnSize - 9) DIV 2 + 2, color, button.text)
|
||||
END
|
||||
END;
|
||||
INC(i)
|
||||
END
|
||||
END drawIcons;
|
||||
|
||||
|
||||
PROCEDURE draw* (VAR toolbar: tToolbar);
|
||||
VAR
|
||||
i, x, y, btn: INTEGER;
|
||||
button: tButton;
|
||||
BEGIN
|
||||
Icons.get(toolbar.icons, toolbar.grayIcons);
|
||||
i := 0;
|
||||
WHILE i < toolbar.cnt DO
|
||||
button := toolbar.buttons[i];
|
||||
btn := button.btn;
|
||||
IF btn # 0 THEN
|
||||
x := button.x;
|
||||
y := toolbar.y;
|
||||
K.DrawRect(x, y, BtnSize, BtnSize, K.toolbarColor);
|
||||
K.DrawLine(x, y + BtnSize, x + BtnSize, y + BtnSize, K.shadowColor);
|
||||
K.DrawLine(x + BtnSize, y, x + BtnSize, y + BtnSize, K.shadowColor);
|
||||
K.CreateButton(btn + ORD({30}), x, y, BtnSize, BtnSize, K.btnColor, "")
|
||||
END;
|
||||
INC(i)
|
||||
END;
|
||||
drawIcons(toolbar)
|
||||
END draw;
|
||||
|
||||
|
||||
PROCEDURE enable* (VAR toolbar: tToolbar; btn: INTEGER; value: BOOLEAN);
|
||||
VAR
|
||||
i: INTEGER;
|
||||
BEGIN
|
||||
i := 0;
|
||||
WHILE (i < toolbar.cnt) & (toolbar.buttons[i].btn # btn) DO
|
||||
INC(i)
|
||||
END;
|
||||
IF i < toolbar.cnt THEN
|
||||
toolbar.buttons[i].enabled := value
|
||||
END
|
||||
END enable;
|
||||
|
||||
|
||||
PROCEDURE add* (VAR toolbar: tToolbar; btn, icon: INTEGER; text: tButtonText);
|
||||
VAR
|
||||
button: tButton;
|
||||
BEGIN
|
||||
ASSERT(toolbar.cnt < max);
|
||||
button.btn := btn;
|
||||
button.icon := icon;
|
||||
button.x := toolbar.width;
|
||||
button.text := text;
|
||||
button.enabled := TRUE;
|
||||
toolbar.buttons[toolbar.cnt] := button;
|
||||
INC(toolbar.cnt);
|
||||
IF btn # 0 THEN
|
||||
INC(toolbar.width, BtnSize + BtnInter)
|
||||
ELSE
|
||||
INC(toolbar.width, DelimSize)
|
||||
END
|
||||
END add;
|
||||
|
||||
|
||||
PROCEDURE delimiter* (VAR toolbar: tToolbar);
|
||||
BEGIN
|
||||
add(toolbar, 0, 0, "")
|
||||
END delimiter;
|
||||
|
||||
|
||||
PROCEDURE create* (VAR toolbar: tToolbar; x, y: INTEGER);
|
||||
BEGIN
|
||||
toolbar.x := x;
|
||||
toolbar.y := y;
|
||||
toolbar.cnt := 0;
|
||||
toolbar.width := x;
|
||||
Icons.get(toolbar.icons, toolbar.grayIcons)
|
||||
END create;
|
||||
|
||||
|
||||
END Toolbar.
|
Loading…
Reference in New Issue
Block a user