added newt example with buttons. updated newt wrapper. -- noch.

This commit is contained in:
Norayr Chilingarian 2015-03-11 02:13:06 +04:00
parent 712244b161
commit 0aecdbd935
5 changed files with 142 additions and 1 deletions

View file

@ -5,6 +5,7 @@ VOC = /opt/voc/bin/voc
all:
$(VOC) -s newt.Mod newttest.Mod -m
$(VOC) -s newt.Mod newttest2.Mod -m
clean:
rm *.h

View file

@ -35,6 +35,21 @@ NEWTvARGvAPPEND*= -1;
TYPE Int32* = INTEGER;
Int64* = LONGINT;
ComponentStruct* = RECORD
height*, width*,
top*, left*,
takesFocus*,
isMapped*: Int32
END;
Component* = POINTER TO ComponentStruct;
ExitStruct* = RECORD
reason*: Int32;
watch*, key*: Int32;
co* : Component;
END;
PROCEDURE -newtInit(): Int32
"newtInit()";
@ -123,6 +138,22 @@ BEGIN
newtPopHelpLine();
END PopHelpLine;
PROCEDURE -newtSuspend()
"newtSuspend()";
PROCEDURE Suspend*();
BEGIN
newtSuspend()
END Suspend;
PROCEDURE -newtResume()
"newtResume()";
PROCEDURE Resume*;
BEGIN
newtResume()
END Resume;
PROCEDURE -newtBell()
"newtBell()";
@ -137,6 +168,86 @@ BEGIN
newtGetScreenSize(cols, rows)
END GetScreenSize;
PROCEDURE -newtCenteredWindow(width, height: Int32; title: ARRAY OF CHAR): Int32
"newtCenteredWindow(width, height, title)";
PROCEDURE CenteredWindow*(width, height: Int32; title: ARRAY OF CHAR): Int32;
BEGIN
RETURN newtCenteredWindow(width, height, title)
END CenteredWindow;
PROCEDURE -newtOpenWindow(left, top, width, height: Int32; title: ARRAY OF CHAR): Int32
"newtOpenWindow(left, top, width, height, title)";
PROCEDURE OpenWindow*(left, top, width, height: Int32; title: ARRAY OF CHAR): Int32;
BEGIN
RETURN newtOpenWindow(left, top, width, height, title)
END OpenWindow;
PROCEDURE -newtPopWindow()
"newtPopWindow()";
PROCEDURE PopWindow*();
BEGIN
newtPopWindow
END PopWindow;
PROCEDURE -newtForm(vertBar: Component; help: ARRAY OF CHAR; flags: Int32): Component
"newtForm(vertBar, help, flags)";
PROCEDURE Form*(vertBar: Component; help: ARRAY OF CHAR; flags: Int32): Component;
BEGIN
RETURN newtForm(vertBar, help, flags);
END Form;
PROCEDURE -newtFormAddComponent(form, co: Component)
"newtFormAddComponent(form, co)";
PROCEDURE FormAddComponent*(form, co: Component);
BEGIN
newtFormAddComponent(form, co);
END FormAddComponent;
PROCEDURE -newtRunForm(form: Component): Component
"newtRunForm(form)";
PROCEDURE RunForm*(form: Component): Component; (* obsolete *)
BEGIN
RETURN newtRunForm(form)
END RunForm;
PROCEDURE -newtFormRun(co: Component; VAR es: ExitStruct)
"newtFormRun(co, es)";
PROCEDURE FormRun*(co: Component; VAR es: ExitStruct);
BEGIN
newtFormRun(co, es)
END FormRun;
PROCEDURE -newtFormDestroy(form: Component)
"newtFormDestroy(form)";
PROCEDURE FormDestroy*(form: Component);
BEGIN
newtFormDestroy(form)
END FormDestroy;
PROCEDURE -newtButton(left, top: Int32; text: ARRAY OF CHAR): Component
"newtButton(left, top, text)";
PROCEDURE Button*(left, top: Int32; text: ARRAY OF CHAR): Component;
BEGIN
RETURN newtButton(left, top, text)
END Button;
PROCEDURE -newtCompactButton(left, top: Int32; text: ARRAY OF CHAR): Component
"newtCompactButton(left, top, text)";
PROCEDURE CompactButton*(left, top: Int32; text: ARRAY OF CHAR): Component;
BEGIN
RETURN newtCompactButton(left, top, text);
END CompactButton;
BEGIN

View file

@ -3,6 +3,7 @@ MODULE newttest;
IMPORT newt, oocIntStr, Unix;
VAR i, j, k : newt.Int32;
str : ARRAY 32 OF CHAR;
fo, co : newt.Component;
BEGIN
i := newt.Init();
newt.Cls();
@ -28,7 +29,9 @@ newt.PopHelpLine();
newt.Refresh();
i := Unix.Sleep(1);
fo := newt.Form(NIL, "aaa", 0);
co := newt.Button(15, 15, "OK");
newt.FormAddComponent(fo, co);
newt.WaitForKey();
newt.Delay(30);
i := newt.Finished();

View file

@ -0,0 +1,26 @@
MODULE newttest2;
IMPORT newt, oocIntStr, Unix;
VAR i, j, k : newt.Int32;
str : ARRAY 32 OF CHAR;
form, b1, b2, comp: newt.Component;
BEGIN
i := newt.Init();
newt.Cls();
str := "hello world!";
i := newt.OpenWindow(10, 5, 40, 6, "Button Sample");
b1 := newt.Button(10, 1, "OK");
b2 := newt.CompactButton(22, 2, "Cancel");
form := newt.Form(NIL, "aaa", 0);
newt.FormAddComponent(form, b1);
newt.FormAddComponent(form, b2);
comp := newt.RunForm(form);
newt.WaitForKey();
newt.Delay(30);
newt.FormDestroy(form);
i := newt.Finished();
END newttest2.

BIN
voc

Binary file not shown.