/* examples/panel/entier.c */ #include He_node *princ, *panel, *text; void entree_proc (He_node *hn) { int val = atoi(HeGetTextValue(hn)); printf ("L'entier lu est %d\n", val); } void butt_proc (He_node *hn) { char *nom = HeGetButtonLabel(hn), bla[100]; int val = atoi(HeGetTextValue(text)); if (!strcmp (nom, "--")) val -= 10; else if (!strcmp (nom, "-")) val --; else if (!strcmp (nom, "+")) val ++; else if (!strcmp (nom, "++")) val += 10; sprintf (bla, "%d", val); HeSetTextValue (text, bla); entree_proc(text); } int main (int argc, char *argv[]) { HeInit (&argc, &argv); princ = HeCreateFrame (); HeSetFrameLabel (princ, "Saisie d'un entier"); panel = HeCreatePanel (princ); HeCreateMessageP (panel, "Entier:", TRUE); text = HeCreateText (panel); HeSetTextVisibleLen (text, 8); HeSetTextNotifyProc (text, entree_proc); HeSetTextValue (text, "100"); HeCreateButtonP (panel, "--", butt_proc, NULL); HeCreateButtonP (panel, "-", butt_proc, NULL); HeCreateButtonP (panel, "+", butt_proc, NULL); HeCreateButtonP (panel, "++", butt_proc, NULL); HeFit(panel); HeFit(princ); return HeMainLoop (princ); }