diff options
author | Pixel <pixel@nobis-crew.org> | 2009-11-04 11:56:41 -0800 |
---|---|---|
committer | Pixel <pixel@nobis-crew.org> | 2009-11-04 11:59:33 -0800 |
commit | d577d991b97ae2b5ee1af23641bcffc3f83af5b2 (patch) | |
tree | 590639d50205d1bcfaff2a7d2dc6ebf3f373c7ed /iup/test/dial.c |
Initial import. Contains the im, cd and iup librairies, and a "working" Makefile for them under linux.
Diffstat (limited to 'iup/test/dial.c')
-rwxr-xr-x | iup/test/dial.c | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/iup/test/dial.c b/iup/test/dial.c new file mode 100755 index 0000000..727934c --- /dev/null +++ b/iup/test/dial.c @@ -0,0 +1,111 @@ +#include <stdlib.h> +#include <stdio.h> + +#include "iup.h" +#include "iupcontrols.h" + +static int help_cb(Ihandle* ih) +{ + printf("HELP_CB(%s)\n", IupGetName(ih)); + return IUP_DEFAULT; +} + +static void printdial(Ihandle* ih, double a, char* color) +{ + Ihandle* label = NULL; + char* u = NULL; + char* type = IupGetAttribute(ih, "TYPE"); + + switch(type[0]) + { + case 'V': + label = IupGetHandle("lbl_v"); + u = "deg"; + break; + case 'H': + label = IupGetHandle("lbl_h"); + u = "rad"; + break; + case 'C': + label = IupGetHandle("lbl_c"); + u = "deg"; + break; + } + + if (label) + { + IupSetfAttribute(label, "TITLE", "%.3g %s", a, u); + IupSetAttribute(label, "BGCOLOR", color); + } +} + +static int mousemove(Ihandle* ih, double a) +{ + printdial(ih, a, "0 255 0"); + return IUP_DEFAULT; +} + +static int button_press(Ihandle* ih, double a) +{ + printdial(ih, a, "255 0 0"); + return IUP_DEFAULT; +} + +static int button_release(Ihandle* ih, double a) +{ + printdial(ih, a, NULL); + return IUP_DEFAULT; +} + +void DialTest(void) +{ + char *error = NULL; + Ihandle *dlg, *dial_h, *dial_v, *dial_c; + + error = IupLoad("dial.led"); + if (error) + { + error = IupLoad("../test/dial.led"); + if (error) + { + IupMessage("%s\n", error); + return; + } + } + + dlg = IupGetHandle("dlg"); + dial_h = IupGetHandle("dial_h"); + dial_v = IupGetHandle("dial_v"); + dial_c = IupGetHandle("dial_c"); + + IupSetFunction("dial_mousemove", (Icallback)mousemove); + IupSetFunction("dial_buttonpress", (Icallback)button_press); + IupSetFunction("dial_buttonrelease", (Icallback)button_release); + + IupSetCallback(dial_h, "HELP_CB", help_cb); + IupSetCallback(dial_v, "HELP_CB", help_cb); + + IupSetAttribute(dial_h, "EXPAND", "HORIZONTAL"); + IupSetAttribute(dial_v, "EXPAND", "VERTICAL"); + +// IupSetAttribute(dlg, "HELPBUTTON", "YES"); +// IupSetAttribute(dlg, "DIALOGFRAME", "YES"); + + IupShow(dlg); +} + +#ifndef BIG_TEST +int main(int argc, char* argv[]) +{ + IupOpen(&argc, &argv); + IupControlsOpen(); + + DialTest(); + + IupMainLoop(); + + IupClose(); + + return EXIT_SUCCESS; +} +#endif |