forked from KolibriOS/kolibrios
CEDIT: menu changes
git-svn-id: svn://kolibrios.org@9190 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
4918685b4a
commit
86da2194d2
Binary file not shown.
@ -8,7 +8,9 @@
|
||||
ctrl+U преобразовать в верхний регистр
|
||||
ctrl+F показать панель поиска
|
||||
Esc закрыть панель поиска; закрыть меню
|
||||
shift+Esc скрыть (свернуть) панель поиска
|
||||
F10 открыть главное меню
|
||||
shift+F10 открыть контекстное меню
|
||||
F3 найти следующий
|
||||
shift+F3 найти предыдущий
|
||||
ctrl+Z отменить
|
||||
|
@ -28,7 +28,7 @@ IMPORT
|
||||
RW, Ini, EB := EditBox, Icons, Tabs, Timer;
|
||||
|
||||
CONST
|
||||
header = "CEdit (11-sep-2021)";
|
||||
header = "CEdit (14-sep-2021)";
|
||||
|
||||
ShellFilter = "";
|
||||
EditFilter = "SH|ASM|TXT|INC|OB07|C|CPP|H|PAS|PP|LUA|INI|JSON";
|
||||
@ -55,8 +55,8 @@ CONST
|
||||
btnReplace = 61;
|
||||
btnReplaceAll = 62;
|
||||
btnGoto = 63;
|
||||
btnCloseFind = 64;
|
||||
btnHideFind = 65;
|
||||
btnCloseSearch = 64;
|
||||
btnHideSearch = 65;
|
||||
|
||||
mainMenuBtn = 70;
|
||||
|
||||
@ -82,10 +82,9 @@ CONST
|
||||
menuEditX = menuFileX + 4*fontWidth + 9;
|
||||
menuSearchX = menuEditX + 4*fontWidth + 9;
|
||||
menuEncodingX = menuSearchX + 6*fontWidth + 9;
|
||||
menuEOLX = menuEncodingX + 8*fontWidth + 9;
|
||||
menuViewX = menuEOLX + 3*fontWidth + 9;
|
||||
menuSyntaxX = menuViewX + 4*fontWidth + 9;
|
||||
menuProgramX = menuSyntaxX + 6*fontWidth + 9;
|
||||
menuViewX = menuEncodingX + 8*fontWidth + 9;
|
||||
menuLanguageX = menuViewX + 4*fontWidth + 9;
|
||||
menuProgramX = menuLanguageX + 8*fontWidth + 9;
|
||||
menuToolsX = menuProgramX + 7*fontWidth + 9;
|
||||
|
||||
menuCut = 1;
|
||||
@ -115,7 +114,7 @@ CONST
|
||||
menuColors = 1000;
|
||||
menuMaxColors = menuColors + Ini.MAX_SECTIONS - 1;
|
||||
|
||||
menuNone = 30;
|
||||
menuText = 30;
|
||||
menuC = 31;
|
||||
menuFasm = 32;
|
||||
menuIni = 33;
|
||||
@ -135,6 +134,7 @@ CONST
|
||||
menuUTF8 = 61;
|
||||
menuCP866 = 62;
|
||||
menuWin1251 = 63;
|
||||
menuEOL = 140;
|
||||
|
||||
menuPipet = 70;
|
||||
menuBoard = 71;
|
||||
@ -161,9 +161,9 @@ CONST
|
||||
menuNextBookmark = 132;
|
||||
menuPrevBookmark = 133;
|
||||
|
||||
menuLF = 140;
|
||||
menuCRLF = 141;
|
||||
menuCR = 142;
|
||||
menuLF = 141;
|
||||
menuCRLF = 142;
|
||||
menuCR = 143;
|
||||
|
||||
maxTexts = 32;
|
||||
|
||||
@ -198,8 +198,8 @@ VAR
|
||||
mainTID, delay: INTEGER;
|
||||
|
||||
context, menuFile, menuEdit, menuSearch, menuEncoding,
|
||||
menuEOL, menuView, menuSyntax, menuProgram, menuTools,
|
||||
subCurLine, subIndent, subCase, subBookmark: Menu.tMenu;
|
||||
menuView, menuLanguage, menuProgram, menuTools,
|
||||
subCurLine, subIndent, subCase, subBookmark, subEOL: Menu.tMenu;
|
||||
|
||||
mainMenu: Menu.tMain;
|
||||
|
||||
@ -520,7 +520,7 @@ BEGIN
|
||||
bottom := top + 395 + btnHeight + SEARCH_PADDING;
|
||||
color := K.borderColor;
|
||||
Rect(left, top, right, bottom, color);
|
||||
K.CreateButton(btnCloseFind, right - 20, top, 20, 20, 0EF999FH, "");
|
||||
K.CreateButton(btnCloseSearch, right - 20, top, 20, 20, 0EF999FH, "");
|
||||
K.DrawLine(right - 14, top + 5, right - 5, top + 14, 0FFFFFFH);
|
||||
K.DrawLine(right - 15, top + 5, right - 5, top + 15, 0FFFFFFH);
|
||||
K.DrawLine(right - 15, top + 6, right - 6, top + 15, 0FFFFFFH);
|
||||
@ -528,7 +528,7 @@ BEGIN
|
||||
K.DrawLine(right - 15, top + 15, right - 5, top + 5, 0FFFFFFH);
|
||||
K.DrawLine(right - 14, top + 15, right - 5, top + 6, 0FFFFFFH);
|
||||
|
||||
K.CreateButton(btnHideFind, right - 40, top, 20, 20, K.btnColor, "");
|
||||
K.CreateButton(btnHideSearch, right - 40, top, 20, 20, K.btnColor, "");
|
||||
K.DrawLine(right - 34, top + 14, right - 26, top + 14, K.btnTextColor);
|
||||
K.DrawLine(right - 34, top + 15, right - 26, top + 15, K.btnTextColor);
|
||||
|
||||
@ -703,7 +703,7 @@ BEGIN
|
||||
IF OD.FileName = "" THEN
|
||||
OD.FileName := "NewFile.";
|
||||
CASE text.lang OF
|
||||
|Languages.langNone: ext := "txt"
|
||||
|Languages.langText: ext := "txt"
|
||||
|Languages.langC: ext := "c"
|
||||
|Languages.langFasm: ext := "asm"
|
||||
|Languages.langIni: ext := "ini"
|
||||
@ -1045,19 +1045,19 @@ END Close;
|
||||
|
||||
PROCEDURE CloseMenu;
|
||||
BEGIN
|
||||
Menu.close(menuFile);
|
||||
Menu.close(menuEdit);
|
||||
Menu.close(menuSearch);
|
||||
Menu.close(menuEncoding);
|
||||
Menu.close(menuEOL);
|
||||
Menu.close(menuView);
|
||||
Menu.close(menuSyntax);
|
||||
Menu.close(menuProgram);
|
||||
Menu.close(menuTools);
|
||||
Menu.close(subEOL);
|
||||
Menu.close(subCurLine);
|
||||
Menu.close(subIndent);
|
||||
Menu.close(subCase);
|
||||
Menu.close(subBookmark);
|
||||
Menu.close(menuFile);
|
||||
Menu.close(menuEdit);
|
||||
Menu.close(menuSearch);
|
||||
Menu.close(menuEncoding);
|
||||
Menu.close(menuView);
|
||||
Menu.close(menuLanguage);
|
||||
Menu.close(menuProgram);
|
||||
Menu.close(menuTools);
|
||||
Menu.close(context)
|
||||
END CloseMenu;
|
||||
|
||||
@ -1161,11 +1161,6 @@ BEGIN
|
||||
Menu.option(menu, menuCP866, text.enc = E.CP866);
|
||||
Menu.option(menu, menuWin1251, text.enc = E.W1251);
|
||||
INC(x, menuEncodingX)
|
||||
ELSIF menu = menuEOL THEN
|
||||
Menu.option(menu, menuCRLF, text.eol = RW.EOL_CRLF);
|
||||
Menu.option(menu, menuLF, text.eol = RW.EOL_LF);
|
||||
Menu.option(menu, menuCR, text.eol = RW.EOL_CR);
|
||||
INC(x, menuEOLX)
|
||||
ELSIF menu = menuView THEN
|
||||
Menu.check(menu, menuNumbers, text.numbers);
|
||||
Menu.check(menu, menuFontSize, font = font2);
|
||||
@ -1173,8 +1168,8 @@ BEGIN
|
||||
Menu.option(menu, menuColors + i, Ini.curSectionNum = i)
|
||||
END;
|
||||
INC(x, menuViewX)
|
||||
ELSIF menu = menuSyntax THEN
|
||||
Menu.option(menu, menuNone, text.lang = Languages.langNone);
|
||||
ELSIF menu = menuLanguage THEN
|
||||
Menu.option(menu, menuText, text.lang = Languages.langText);
|
||||
Menu.option(menu, menuC, text.lang = Languages.langC);
|
||||
Menu.option(menu, menuFasm, text.lang = Languages.langFasm);
|
||||
Menu.option(menu, menuIni, text.lang = Languages.langIni);
|
||||
@ -1182,7 +1177,7 @@ BEGIN
|
||||
Menu.option(menu, menuLua, text.lang = Languages.langLua);
|
||||
Menu.option(menu, menuOberon, text.lang = Languages.langOberon);
|
||||
Menu.option(menu, menuPascal, text.lang = Languages.langPascal);
|
||||
INC(x, menuSyntaxX)
|
||||
INC(x, menuLanguageX)
|
||||
ELSIF menu = menuProgram THEN
|
||||
Menu.setEnabled(menu, menuBuild, buildScript # "");
|
||||
Menu.setEnabled(menu, menuDebug, debugScript # "");
|
||||
@ -1204,6 +1199,10 @@ BEGIN
|
||||
Menu.setEnabled(subCase, menuUpper, selected);
|
||||
Menu.setEnabled(subCase, menuLower, selected);
|
||||
|
||||
Menu.option(subEOL, menuCRLF, text.eol = RW.EOL_CRLF);
|
||||
Menu.option(subEOL, menuLF, text.eol = RW.EOL_LF);
|
||||
Menu.option(subEOL, menuCR, text.eol = RW.EOL_CR);
|
||||
|
||||
IF menu # NIL THEN
|
||||
Timer.kill;
|
||||
IF Menu.opened(menu) THEN
|
||||
@ -1332,8 +1331,8 @@ BEGIN
|
||||
font := font1
|
||||
END;
|
||||
resize
|
||||
|menuNone:
|
||||
T.setLang(text, Languages.langNone)
|
||||
|menuText:
|
||||
T.setLang(text, Languages.langText)
|
||||
|menuC:
|
||||
T.setLang(text, Languages.langC)
|
||||
|menuFasm:
|
||||
@ -1552,6 +1551,9 @@ BEGIN
|
||||
Menu.AddMenuItem(menu, menuUTF8, E.names[E.UTF8]);
|
||||
Menu.AddMenuItem(menu, menuCP866, E.names[E.CP866]);
|
||||
Menu.AddMenuItem(menu, menuWin1251, E.names[E.W1251]);
|
||||
Menu.delimiter(menu);
|
||||
Menu.AddMenuItem(menu, menuEOL, "EOL");
|
||||
Menu.child(menu, subEOL);
|
||||
RETURN Menu.create(menu, MenuItemClick, MenuKeyDown)
|
||||
END CreateMenuEncoding;
|
||||
|
||||
@ -1591,7 +1593,7 @@ BEGIN
|
||||
END CreateMenuView;
|
||||
|
||||
|
||||
PROCEDURE CreateMenuSyntax (): Menu.tMenu;
|
||||
PROCEDURE CreateMenuLanguage (): Menu.tMenu;
|
||||
VAR
|
||||
menu: List.tList;
|
||||
BEGIN
|
||||
@ -1604,9 +1606,9 @@ BEGIN
|
||||
Menu.AddMenuItem(menu, menuOberon, "Oberon");
|
||||
Menu.AddMenuItem(menu, menuPascal, "Pascal");
|
||||
Menu.delimiter(menu);
|
||||
Menu.AddMenuItem(menu, menuNone, "none");
|
||||
Menu.AddMenuItem(menu, menuText, "Text");
|
||||
RETURN Menu.create(menu, MenuItemClick, MenuKeyDown)
|
||||
END CreateMenuSyntax;
|
||||
END CreateMenuLanguage;
|
||||
|
||||
|
||||
PROCEDURE CreateMenuProgram (): Menu.tMenu;
|
||||
@ -1685,6 +1687,16 @@ BEGIN
|
||||
END CreateMenuBookmark;
|
||||
|
||||
|
||||
PROCEDURE HideSearch;
|
||||
BEGIN
|
||||
SetFocus(FindEdit, FALSE);
|
||||
searchOpened := FALSE;
|
||||
LEFT := searchLeft;
|
||||
resize;
|
||||
draw_window
|
||||
END HideSearch;
|
||||
|
||||
|
||||
PROCEDURE KeyDown (key: INTEGER);
|
||||
VAR
|
||||
keyCode: INTEGER;
|
||||
@ -1725,13 +1737,21 @@ BEGIN
|
||||
Script(runScript)
|
||||
END
|
||||
ELSIF keyCode = 68 THEN (* F10 *)
|
||||
key := -1;
|
||||
ShowMenu(menuFile)
|
||||
IF shift THEN
|
||||
ShowMenu(context)
|
||||
ELSE
|
||||
ShowMenu(menuFile)
|
||||
END;
|
||||
key := -1
|
||||
ELSIF keyCode = 1 THEN (* Esc *)
|
||||
key := -1;
|
||||
IF search THEN
|
||||
Search
|
||||
END
|
||||
IF shift THEN
|
||||
HideSearch
|
||||
ELSE
|
||||
Search
|
||||
END
|
||||
END;
|
||||
key := -1
|
||||
ELSIF (keyCode = 55) & (key DIV 256 MOD 256 = 52) THEN (* PrtScn *)
|
||||
key := -1
|
||||
ELSIF (keyCode = 14) & shift THEN (* shift+Backspace *)
|
||||
@ -1886,14 +1906,10 @@ BEGIN
|
||||
repaint
|
||||
|btnSearch:
|
||||
ShowSearchPanel
|
||||
|btnCloseFind:
|
||||
|btnCloseSearch:
|
||||
Search
|
||||
|btnHideFind:
|
||||
SetFocus(FindEdit, FALSE);
|
||||
searchOpened := FALSE;
|
||||
LEFT := searchLeft;
|
||||
resize;
|
||||
draw_window
|
||||
|btnHideSearch:
|
||||
HideSearch
|
||||
|btnUndo:
|
||||
T.undo(text);
|
||||
repaint
|
||||
@ -2109,10 +2125,11 @@ BEGIN
|
||||
subBookmark := CreateMenuBookmark();
|
||||
menuSearch := CreateMenuSearch();
|
||||
subBookmark.parent := menuSearch;
|
||||
subEOL := CreateMenuEOL();
|
||||
menuEncoding := CreateMenuEncoding();
|
||||
menuEOL := CreateMenuEOL();
|
||||
subEOL.parent := menuEncoding;
|
||||
menuView := CreateMenuView();
|
||||
menuSyntax := CreateMenuSyntax();
|
||||
menuLanguage := CreateMenuLanguage();
|
||||
menuProgram := CreateMenuProgram();
|
||||
menuTools := CreateMenuTools();
|
||||
|
||||
@ -2121,9 +2138,8 @@ BEGIN
|
||||
Menu.AddMainItem(mainMenu, "edit", menuEdit);
|
||||
Menu.AddMainItem(mainMenu, "search", menuSearch);
|
||||
Menu.AddMainItem(mainMenu, "encoding", menuEncoding);
|
||||
Menu.AddMainItem(mainMenu, "eol", menuEOL);
|
||||
Menu.AddMainItem(mainMenu, "view", menuView);
|
||||
Menu.AddMainItem(mainMenu, "syntax", menuSyntax);
|
||||
Menu.AddMainItem(mainMenu, "language", menuLanguage);
|
||||
Menu.AddMainItem(mainMenu, "program", menuProgram);
|
||||
Menu.AddMainItem(mainMenu, "tools", menuTools);
|
||||
|
||||
@ -2164,13 +2180,7 @@ BEGIN
|
||||
Timer.create(mainTID);
|
||||
WHILE TRUE DO
|
||||
CASE K.WaitForEvent() OF
|
||||
|1: (*IF Menu.redraw THEN*)
|
||||
Redraw(resized, width, height, cliWidth, cliHeight)
|
||||
(*ELSE
|
||||
Menu.Redraw;
|
||||
K.CreateWindow(30 + K.GetTickCount() MOD 128, 30 + K.GetTickCount() MOD 128, winWidth, winHeight, K.winColor, 73H, 0, 0, header);
|
||||
repaint
|
||||
END*)
|
||||
|1: Redraw(resized, width, height, cliWidth, cliHeight)
|
||||
|2: KeyDown(K.GetKey())
|
||||
|3: BtnClick
|
||||
|6: MouseEvent(resized, firstClickX, firstClickY, time)
|
||||
|
@ -24,7 +24,7 @@ IMPORT Lines;
|
||||
|
||||
CONST
|
||||
|
||||
langNone* = 0; langC* = 1; langOberon* = 2; langPascal* = 3;
|
||||
langText* = 0; langC* = 1; langOberon* = 2; langPascal* = 3;
|
||||
langFasm* = 4; langLua* = 5; langIni* = 6; langJSON* = 7;
|
||||
|
||||
csLang = {langC, langOberon, langLua, langIni, langJSON};
|
||||
@ -317,7 +317,7 @@ END Ini;
|
||||
PROCEDURE comments* (line: tLine; VAR depth, cond, pos: INTEGER; n: INTEGER; lang: INTEGER);
|
||||
BEGIN
|
||||
CASE lang OF
|
||||
|langNone:
|
||||
|langText:
|
||||
|langFasm:
|
||||
|langC,
|
||||
langJSON: C(line, depth, cond, pos, n)
|
||||
|
@ -20,7 +20,7 @@
|
||||
MODULE Menu;
|
||||
|
||||
IMPORT
|
||||
SYSTEM, G := Graph, List, K := KolibriOS, U := Utils, KOSAPI;
|
||||
SYSTEM, G := Graph, List, K := KolibriOS, KOSAPI;
|
||||
|
||||
CONST
|
||||
fontHeight = 22;
|
||||
@ -91,7 +91,6 @@ VAR
|
||||
TIDs: ARRAY maxLEVEL + 1 OF INTEGER;
|
||||
resetTimer: tProc;
|
||||
_open: PROCEDURE (m: tMenu; x, y: INTEGER);
|
||||
(*redraw*: BOOLEAN;*)
|
||||
(*
|
||||
backColor, foreColor, selBackColor, selForeColor,
|
||||
disBackColor, disForeColor, disSelBackColor, disSelForeColor: INTEGER;
|
||||
@ -354,7 +353,6 @@ BEGIN
|
||||
close(p);
|
||||
p := p.parent
|
||||
END;
|
||||
(*redraw := TRUE;*)
|
||||
exit(m)
|
||||
END
|
||||
END click;
|
||||
@ -373,7 +371,6 @@ END isActive;
|
||||
PROCEDURE closeChild (m: tMenu);
|
||||
BEGIN
|
||||
IF m.child # NIL THEN
|
||||
(*redraw := FALSE;*)
|
||||
close(m.child);
|
||||
m.child := NIL
|
||||
END
|
||||
@ -639,18 +636,11 @@ BEGIN
|
||||
RETURN m
|
||||
END create;
|
||||
|
||||
(*
|
||||
PROCEDURE Redraw*;
|
||||
BEGIN
|
||||
redraw := TRUE
|
||||
END Redraw;
|
||||
*)
|
||||
|
||||
PROCEDURE init* (_resetTimer: tProc);
|
||||
VAR
|
||||
i: INTEGER;
|
||||
BEGIN
|
||||
(*Redraw;*)
|
||||
resetTimer := _resetTimer;
|
||||
_open := open;
|
||||
FOR i := 0 TO maxLEVEL DO
|
||||
|
@ -126,7 +126,7 @@ BEGIN
|
||||
ELSIF ext = "JSON" THEN
|
||||
text.lang := Lang.langJSON
|
||||
ELSE
|
||||
text.lang := Lang.langNone
|
||||
text.lang := Lang.langText
|
||||
END
|
||||
END setName;
|
||||
|
||||
@ -2057,7 +2057,7 @@ VAR
|
||||
guard: tGuard;
|
||||
BEGIN
|
||||
IF text.search & search(text, text.searchText, text.cs, text.whole) THEN END;
|
||||
IF (text.lang # Lang.langNone) & text.comments THEN
|
||||
IF (text.lang # Lang.langText) & text.comments THEN
|
||||
Comments(text)
|
||||
END;
|
||||
IF text.guard THEN
|
||||
@ -2102,7 +2102,7 @@ BEGIN
|
||||
SetColor(colors.text, backColor);
|
||||
Len := MAX(line.length - text.scroll.X, 0);
|
||||
G.TextOut(canvas, padding.left, y, Lines.getPChar(line, text.scroll.X), MIN(Len, textsize.X + 1));
|
||||
IF text.lang # Lang.langNone THEN
|
||||
IF text.lang # Lang.langText THEN
|
||||
parse(text, line, y, backColor, text.lang)
|
||||
END;
|
||||
mark(line, y - inter DIV 2);
|
||||
@ -2330,7 +2330,7 @@ BEGIN
|
||||
ELSE
|
||||
errno := 1
|
||||
END;
|
||||
IF (text # NIL) & (text.lang # Lang.langNone) THEN
|
||||
IF (text # NIL) & (text.lang # Lang.langText) THEN
|
||||
Comments(text)
|
||||
END
|
||||
RETURN text
|
||||
|
@ -1,289 +0,0 @@
|
||||
(*
|
||||
Copyright 2016, 2017, 2020, 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 box_lib;
|
||||
|
||||
IMPORT sys := SYSTEM, KOSAPI;
|
||||
|
||||
|
||||
CONST
|
||||
|
||||
CHECKBOX_IS_SET* = 1;
|
||||
|
||||
|
||||
TYPE
|
||||
|
||||
checkbox* = POINTER TO RECORD
|
||||
|
||||
left_s*: INTEGER;
|
||||
top_s*: INTEGER;
|
||||
ch_text_margin*: INTEGER;
|
||||
color: INTEGER;
|
||||
border_color: INTEGER;
|
||||
text_color: INTEGER;
|
||||
text: INTEGER;
|
||||
flags*: SET;
|
||||
|
||||
(* Users can use members above this *)
|
||||
size_of_str: INTEGER
|
||||
|
||||
END;
|
||||
|
||||
|
||||
scrollbar* = POINTER TO RECORD
|
||||
|
||||
x_w: INTEGER;
|
||||
y_h*: INTEGER;
|
||||
btn_height: INTEGER;
|
||||
type: INTEGER;
|
||||
max_area*: INTEGER;
|
||||
cur_area*: INTEGER;
|
||||
position*: INTEGER;
|
||||
back_color: INTEGER;
|
||||
front_color: INTEGER;
|
||||
line_color: INTEGER;
|
||||
redraw: INTEGER;
|
||||
|
||||
delta: WCHAR;
|
||||
delta2: WCHAR;
|
||||
r_size_x: WCHAR;
|
||||
r_start_x: WCHAR;
|
||||
r_size_y: WCHAR;
|
||||
r_start_y: WCHAR;
|
||||
|
||||
m_pos: INTEGER;
|
||||
m_pos2: INTEGER;
|
||||
m_keys: INTEGER;
|
||||
run_size: INTEGER;
|
||||
position2: INTEGER;
|
||||
work_size: INTEGER;
|
||||
all_redraw: INTEGER;
|
||||
ar_offset: INTEGER
|
||||
|
||||
END;
|
||||
|
||||
edit_box* = POINTER TO RECORD
|
||||
width*,
|
||||
left*,
|
||||
top*,
|
||||
color*,
|
||||
shift_color,
|
||||
focus_border_color,
|
||||
blur_border_color,
|
||||
text_color*,
|
||||
max: INTEGER;
|
||||
text*: INTEGER;
|
||||
mouse_variable: edit_box;
|
||||
flags*,
|
||||
|
||||
size,
|
||||
pos: INTEGER;
|
||||
(* The following struct members are not used by the users of API *)
|
||||
offset, cl_curs_x, cl_curs_y, shift, shift_old, height, char_width: INTEGER
|
||||
END;
|
||||
|
||||
EditBoxKey = PROCEDURE (eb: edit_box);
|
||||
|
||||
|
||||
VAR
|
||||
|
||||
check_box_draw2 *: PROCEDURE (cb: checkbox);
|
||||
check_box_mouse2 *: PROCEDURE (cb: checkbox);
|
||||
init_checkbox2 : PROCEDURE (cb: checkbox);
|
||||
|
||||
scrollbar_h_draw *: PROCEDURE (sb: scrollbar);
|
||||
scrollbar_h_mouse *: PROCEDURE (sb: scrollbar);
|
||||
scrollbar_v_draw *: PROCEDURE (sb: scrollbar);
|
||||
scrollbar_v_mouse *: PROCEDURE (sb: scrollbar);
|
||||
|
||||
edit_box_draw *: PROCEDURE (eb: edit_box);
|
||||
__edit_box_key : EditBoxKey;
|
||||
edit_box_mouse *: PROCEDURE (eb: edit_box);
|
||||
edit_box_set_text *: PROCEDURE (eb: edit_box; text: INTEGER);
|
||||
|
||||
|
||||
PROCEDURE _edit_box_key (key: INTEGER; key_proc: EditBoxKey; text: edit_box);
|
||||
BEGIN
|
||||
sys.CODE(
|
||||
08BH, 045H, 008H, (* mov eax, dword [ebp + 8] *)
|
||||
08BH, 055H, 00CH, (* mov edx, dword [ebp + 12] *)
|
||||
08BH, 04DH, 010H, (* mov ecx, dword [ebp + 16] *)
|
||||
051H, (* push ecx *)
|
||||
0FFH, 0D2H (* call edx *)
|
||||
)
|
||||
END _edit_box_key;
|
||||
|
||||
|
||||
PROCEDURE edit_box_key* (text: edit_box; key: INTEGER);
|
||||
BEGIN
|
||||
_edit_box_key(key, __edit_box_key, text)
|
||||
END edit_box_key;
|
||||
|
||||
|
||||
PROCEDURE edit_box_get_value* (text: edit_box; VAR str: ARRAY OF CHAR);
|
||||
VAR
|
||||
ptr, max, i: INTEGER;
|
||||
|
||||
BEGIN
|
||||
ptr := text.text;
|
||||
max := text.max;
|
||||
ASSERT(max < LEN(str));
|
||||
i := 0;
|
||||
REPEAT
|
||||
sys.GET(ptr, str[i]);
|
||||
INC(i);
|
||||
INC(ptr)
|
||||
UNTIL (str[i - 1] = 0X) OR (i = max);
|
||||
str[i] := 0X
|
||||
END edit_box_get_value;
|
||||
|
||||
|
||||
PROCEDURE memset(adr: INTEGER; c: CHAR; n: INTEGER);
|
||||
BEGIN
|
||||
WHILE n > 0 DO
|
||||
sys.PUT(adr, c);
|
||||
INC(adr);
|
||||
DEC(n)
|
||||
END
|
||||
END memset;
|
||||
|
||||
|
||||
PROCEDURE check_box_set_value* (cb: checkbox; value: BOOLEAN);
|
||||
BEGIN
|
||||
IF cb # NIL THEN
|
||||
IF value THEN
|
||||
INCL(cb.flags, CHECKBOX_IS_SET)
|
||||
ELSE
|
||||
EXCL(cb.flags, CHECKBOX_IS_SET)
|
||||
END
|
||||
END
|
||||
END check_box_set_value;
|
||||
|
||||
|
||||
PROCEDURE check_box_get_value* (cb: checkbox): BOOLEAN;
|
||||
VAR res: BOOLEAN;
|
||||
BEGIN
|
||||
res := FALSE;
|
||||
IF cb # NIL THEN
|
||||
res := CHECKBOX_IS_SET IN cb.flags
|
||||
END
|
||||
RETURN res
|
||||
END check_box_get_value;
|
||||
|
||||
|
||||
PROCEDURE kolibri_new_check_box* (tlx, tly, sizex, sizey: INTEGER; label_text: ARRAY OF CHAR; text_margin: INTEGER): checkbox;
|
||||
VAR new_checkbox: checkbox;
|
||||
BEGIN
|
||||
NEW(new_checkbox);
|
||||
new_checkbox.left_s := tlx * 65536 + sizex;
|
||||
new_checkbox.top_s := tly * 65536 + sizey;
|
||||
new_checkbox.ch_text_margin := text_margin;
|
||||
new_checkbox.color := 80808080H;
|
||||
new_checkbox.border_color := 0000FF00H;
|
||||
new_checkbox.text_color := 00000000H;
|
||||
new_checkbox.text := KOSAPI.malloc(LENGTH(label_text) + 1);
|
||||
sys.MOVE(sys.ADR(label_text[0]), new_checkbox.text, LENGTH(label_text));
|
||||
new_checkbox.flags := {3};
|
||||
init_checkbox2(new_checkbox)
|
||||
RETURN new_checkbox
|
||||
END kolibri_new_check_box;
|
||||
|
||||
|
||||
PROCEDURE kolibri_scrollbar*(sb: scrollbar; x_w, y_h, btn_height, max_area, cur_area, position, back_color, front_color, line_color: INTEGER): scrollbar;
|
||||
BEGIN
|
||||
memset(sys.ADR(sb^), 0X, sys.SIZE(scrollbar));
|
||||
sb.x_w := x_w;
|
||||
sb.y_h := y_h;
|
||||
sb.btn_height := btn_height;
|
||||
sb.type := 1;
|
||||
sb.max_area := max_area;
|
||||
sb.cur_area := cur_area;
|
||||
sb.position := position;
|
||||
sb.line_color := line_color;
|
||||
sb.back_color := back_color;
|
||||
sb.front_color := front_color;
|
||||
sb.ar_offset := 1;
|
||||
sb.all_redraw := 1
|
||||
RETURN sb
|
||||
END kolibri_scrollbar;
|
||||
|
||||
PROCEDURE kolibri_new_scrollbar*(x_w, y_h, btn_height, max_area, cur_area, position, back_color, front_color, line_color: INTEGER): scrollbar;
|
||||
VAR sb: scrollbar;
|
||||
BEGIN
|
||||
NEW(sb);
|
||||
RETURN kolibri_scrollbar(sb, x_w, y_h, btn_height, max_area, cur_area, position, back_color, front_color, line_color)
|
||||
END kolibri_new_scrollbar;
|
||||
|
||||
|
||||
PROCEDURE kolibri_new_edit_box* (tlx, tly, width, max_chars: INTEGER; editbox_interlock: edit_box): edit_box;
|
||||
VAR
|
||||
new_textbox: edit_box;
|
||||
|
||||
BEGIN
|
||||
NEW(new_textbox);
|
||||
|
||||
new_textbox.width := width;
|
||||
new_textbox.left := tlx;
|
||||
new_textbox.top := tly;
|
||||
new_textbox.color := 0FFFFFFH;
|
||||
new_textbox.shift_color := 06A9480H;
|
||||
new_textbox.focus_border_color := 0;
|
||||
new_textbox.blur_border_color := 06A9480H;
|
||||
new_textbox.text_color := 0;
|
||||
new_textbox.max := max_chars;
|
||||
new_textbox.text := KOSAPI.malloc(max_chars + 2);
|
||||
ASSERT(new_textbox.text # 0);
|
||||
new_textbox.mouse_variable := editbox_interlock;
|
||||
new_textbox.flags := 0
|
||||
|
||||
RETURN new_textbox
|
||||
END kolibri_new_edit_box;
|
||||
|
||||
|
||||
PROCEDURE main;
|
||||
VAR Lib: INTEGER;
|
||||
|
||||
PROCEDURE GetProc(Lib, v: INTEGER; name: ARRAY OF CHAR);
|
||||
VAR a: INTEGER;
|
||||
BEGIN
|
||||
a := KOSAPI.GetProcAdr(name, Lib);
|
||||
ASSERT(a # 0);
|
||||
sys.PUT(v, a)
|
||||
END GetProc;
|
||||
|
||||
BEGIN
|
||||
Lib := KOSAPI.LoadLib("/rd/1/lib/box_lib.obj");
|
||||
ASSERT(Lib # 0);
|
||||
GetProc(Lib, sys.ADR(check_box_draw2), "check_box_draw2");
|
||||
GetProc(Lib, sys.ADR(check_box_mouse2), "check_box_mouse2");
|
||||
GetProc(Lib, sys.ADR(init_checkbox2), "init_checkbox2");
|
||||
GetProc(Lib, sys.ADR(scrollbar_h_draw), "scrollbar_h_draw");
|
||||
GetProc(Lib, sys.ADR(scrollbar_h_mouse), "scrollbar_h_mouse");
|
||||
GetProc(Lib, sys.ADR(scrollbar_v_draw), "scrollbar_v_draw");
|
||||
GetProc(Lib, sys.ADR(scrollbar_v_mouse), "scrollbar_v_mouse");
|
||||
GetProc(Lib, sys.ADR(edit_box_draw), "edit_box");
|
||||
GetProc(Lib, sys.ADR(__edit_box_key), "edit_box_key");
|
||||
GetProc(Lib, sys.ADR(edit_box_mouse), "edit_box_mouse");
|
||||
GetProc(Lib, sys.ADR(edit_box_set_text), "edit_box_set_text");
|
||||
END main;
|
||||
|
||||
|
||||
BEGIN
|
||||
main
|
||||
END box_lib.
|
Loading…
Reference in New Issue
Block a user