From 7de984b46af709437bebd6c2decfeb127aab8a09 Mon Sep 17 00:00:00 2001 From: Norayr Chilingarian Date: Wed, 11 Mar 2015 02:13:06 +0400 Subject: [PATCH] added newt example with buttons. updated newt wrapper. -- noch. Former-commit-id: 0aecdbd9354638ebd33df217c6d85326172cfc2a --- src/test/newt/Makefile | 1 + src/test/newt/newt.Mod | 111 ++++++++++++++++++++++++++++++++++++ src/test/newt/newttest.Mod | 5 +- src/test/newt/newttest2.Mod | 26 +++++++++ voc.REMOVED.git-id | 2 +- 5 files changed, 143 insertions(+), 2 deletions(-) create mode 100644 src/test/newt/newttest2.Mod diff --git a/src/test/newt/Makefile b/src/test/newt/Makefile index e0b4f643..0650e8fd 100644 --- a/src/test/newt/Makefile +++ b/src/test/newt/Makefile @@ -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 diff --git a/src/test/newt/newt.Mod b/src/test/newt/newt.Mod index cd3d95f1..1a3a10e1 100644 --- a/src/test/newt/newt.Mod +++ b/src/test/newt/newt.Mod @@ -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 diff --git a/src/test/newt/newttest.Mod b/src/test/newt/newttest.Mod index c367b72b..b9597fbe 100644 --- a/src/test/newt/newttest.Mod +++ b/src/test/newt/newttest.Mod @@ -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(); diff --git a/src/test/newt/newttest2.Mod b/src/test/newt/newttest2.Mod new file mode 100644 index 00000000..9cd02d99 --- /dev/null +++ b/src/test/newt/newttest2.Mod @@ -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. diff --git a/voc.REMOVED.git-id b/voc.REMOVED.git-id index 617b79d7..2e79cd41 100644 --- a/voc.REMOVED.git-id +++ b/voc.REMOVED.git-id @@ -1 +1 @@ -7ce73aa13bfab8e21eda71e0e351d5d5395e6bd3 \ No newline at end of file +6ba9f2d70e2bad97118512d33e656f8d3430596c \ No newline at end of file