summaryrefslogtreecommitdiff
path: root/iup/test/getparam.c
diff options
context:
space:
mode:
authorPixel <pixel@nobis-crew.org>2009-11-04 11:56:41 -0800
committerPixel <pixel@nobis-crew.org>2009-11-04 11:59:33 -0800
commitd577d991b97ae2b5ee1af23641bcffc3f83af5b2 (patch)
tree590639d50205d1bcfaff2a7d2dc6ebf3f373c7ed /iup/test/getparam.c
Initial import. Contains the im, cd and iup librairies, and a "working" Makefile for them under linux.
Diffstat (limited to 'iup/test/getparam.c')
-rwxr-xr-xiup/test/getparam.c98
1 files changed, 98 insertions, 0 deletions
diff --git a/iup/test/getparam.c b/iup/test/getparam.c
new file mode 100755
index 0000000..fbda6bb
--- /dev/null
+++ b/iup/test/getparam.c
@@ -0,0 +1,98 @@
+/* IupGetParam Example in C
+ Shows a dialog with all the possible fields.
+*/
+#include <stdlib.h>
+#include <stdio.h>
+
+#include <iup.h>
+#include <iupcontrols.h>
+
+static int param_action(Ihandle* dialog, int param_index, void* user_data)
+{
+ switch(param_index)
+ {
+ case -1:
+ printf("IupGetParam - OK\n");
+ break;
+ case -2:
+ printf("IupGetParam - Map\n");
+ break;
+ case -3:
+ printf("IupGetParam - Cancel\n");
+ break;
+// case 1:
+// return 0;
+ default:
+ {
+ Ihandle* param;
+ char param_str[50];
+ sprintf(param_str, "PARAM%d", param_index);
+ param = (Ihandle*)IupGetAttribute(dialog, param_str);
+ printf("%s = %s\n", param_str, IupGetAttribute(param, "VALUE"));
+ break;
+ }
+ }
+ return 1;
+}
+
+void GetParamTest(void)
+{
+ int pboolean = 1;
+ int pinteger = 3456;
+ float preal = 3.543f;
+ int pinteger2 = 192;
+ float preal2 = 0.5f;
+ float pangle = 90;
+ char pstring[100] = "string text";
+ char pcolor[100] = "255 0 128";
+ int plist = 2;
+ char pstring2[200] = "second text\nsecond line";
+ char file_name[500] = "test.jpg";
+
+ if (!IupGetParam("Title", param_action, 0,
+ "Boolean: %b[No,Yes]\n"
+ "Integer: %i\n"
+ "Real 1: %r\n"
+ "Sep1 %t\n"
+ "Integer: %i[0,255]\n"
+ "Real 2: %r[-1.5,1.5,0.05]\n"
+ "Sep2 %t\n"
+ "Angle: %a[0,360]\n"
+ "String: %s\n"
+ "List: %l|item1|item2|item3|\n"
+ "File: %f[OPEN|*.bmp;*.jpg|CURRENT|NO|NO]\n"
+ "Color: %c{Color Tip}\n"
+ "Sep3 %t\n"
+ "Multiline: %m\n",
+ &pboolean, &pinteger, &preal, &pinteger2, &preal2, &pangle, pstring, &plist, file_name, pcolor, pstring2, NULL))
+ return;
+
+ IupMessagef("IupGetParam",
+ "Boolean Value: %d\n"
+ "Integer: %d\n"
+ "Real 1: %g\n"
+ "Integer: %d\n"
+ "Real 2: %g\n"
+ "Angle: %g\n"
+ "String: %s\n"
+ "List Index: %d\n"
+ "FileName: %s\n"
+ "Color: %s\n"
+ "Multiline: %s",
+ pboolean, pinteger, (double)preal, pinteger2, (double)preal2, (double)pangle, pstring, plist, file_name, pcolor, pstring2);
+}
+
+#ifndef BIG_TEST
+int main(int argc, char* argv[])
+{
+ IupOpen(&argc, &argv);
+
+ GetParamTest();
+
+ IupMainLoop();
+
+ IupClose();
+
+ return EXIT_SUCCESS;
+}
+#endif