~ubuntu-branches/ubuntu/trusty/libcdk5/trusty

« back to all changes in this revision

Viewing changes to examples/traverse_ex.c

  • Committer: Bazaar Package Importer
  • Author(s): John Goerzen
  • Date: 2007-06-06 03:54:31 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20070606035431-ba4gdvw0h6ybffsu
Tags: 5.0.20060507-1
* New upstream release.
* Fixed header patching.  Patch from Robert Schiele.
  Closes: #402978, #416336.
* Update widget count in description.  Closes: #294709.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* $Id: traverse_ex.c,v 1.17 2004/09/01 00:20:38 tom Exp $ */
 
1
/* $Id: traverse_ex.c,v 1.21 2005/12/29 22:50:10 tom Exp $ */
2
2
 
3
 
#include "cdk.h"
 
3
#include <cdk_test.h>
4
4
 
5
5
#ifdef HAVE_XCURSES
6
6
char *XCursesProgramName = "entry_ex";
8
8
 
9
9
#define NumElements(a) ((sizeof a)/(sizeof a[0]))
10
10
 
11
 
static CDKOBJS *all_objects[3];
 
11
#define MY_MAX 3
 
12
 
 
13
static CDKOBJS *all_objects[MY_MAX];
12
14
 
13
15
static char *yes_no[] =
14
16
{
32
34
 * focus for traversal.  The names with leading "*" have some limitation
33
35
 * that makes them not useful in traversal.
34
36
 */
 
37
/* *INDENT-OFF* */
35
38
static const struct
36
39
{
37
40
   char *name;
39
42
}
40
43
menu_table[] =
41
44
{
42
 
   /* *INDENT-OFF* */
43
45
   { "(CDKGRAPH)",      vGRAPH },       /* no traversal (not active) */
44
46
   { "(CDKHISTOGRAM)",  vHISTOGRAM },   /* no traversal (not active) */
45
47
   { "(CDKLABEL)",      vLABEL },       /* no traversal (not active) */
67
69
   { "CDKTEMPLATE",     vTEMPLATE },
68
70
   { "CDKUSCALE",       vUSCALE },
69
71
   { "CDKUSLIDER",      vUSLIDER },
70
 
   /* *INDENT-ON* */
71
 
 
72
 
 
73
 
 
74
72
};
 
73
/* *INDENT-ON* */
75
74
 
76
75
static CDKOBJS *make_alphalist (CDKSCREEN *cdkscreen, int x, int y)
77
76
{
623
622
   if ((prior = all_objects[menu]) != 0)
624
623
   {
625
624
      EraseObj (prior);
626
 
      DestroyObj (prior);
 
625
      _destroyCDKObject (prior);
627
626
      all_objects[menu] = 0;
628
627
   }
629
628
 
659
658
   switch (input)
660
659
   {
661
660
   case KEY_ENTER:
662
 
      getCDKMenuCurrentItem ((CDKMENU *) object, &mp, &sp);
 
661
      getCDKMenuCurrentItem ((CDKMENU *)object, &mp, &sp);
663
662
 
664
 
      screen = ScreenOf ((CDKMENU *) object);
 
663
      screen = ScreenOf ((CDKMENU *)object);
665
664
      window = screen->window;
666
665
      mvwprintw (window, getmaxy (window) - 1, 0, "selection %d/%d", mp, sp);
667
666
      clrtoeol ();
700
699
   static int menuloc[] =
701
700
   {LEFT, LEFT, RIGHT};
702
701
 
703
 
   for (j = 0; j < 3; ++j)
 
702
   for (j = 0; j < MY_MAX; ++j)
704
703
   {
705
704
      for (k = 0; k < NumElements (menu_table); ++k)
706
705
      {
716
715
   initCDKColor ();
717
716
 
718
717
 
719
 
   menu = newCDKMenu (cdkscreen, menulist, 3, submenusize, menuloc,
 
718
   menu = newCDKMenu (cdkscreen, menulist, MY_MAX, submenusize, menuloc,
720
719
                      TOP, A_UNDERLINE, A_REVERSE);
721
720
   if (menu == 0)
722
721
   {
 
722
      destroyCDKScreen (cdkscreen);
723
723
      endCDK ();
 
724
 
724
725
      printf ("? Cannot create menus\n");
725
 
      exit (EXIT_FAILURE);
 
726
      ExitProgram (EXIT_FAILURE);
726
727
   }
727
728
   rebind_esc (ObjOf (menu));
728
729
 
730
731
 
731
732
   /* setup the initial display */
732
733
   make_any (cdkscreen, 0, vENTRY);
 
734
#if MY_MAX > 1
733
735
   make_any (cdkscreen, 1, vITEMLIST);
 
736
#if MY_MAX > 2
734
737
   make_any (cdkscreen, 2, vSELECTION);
 
738
#endif
 
739
#endif
735
740
 
736
741
   /* Draw the screen. */
737
742
   refreshCDKScreen (cdkscreen);
745
750
   popupLabel (cdkscreen, mesg, 3);
746
751
 
747
752
   /* Clean up and exit. */
748
 
   for (j = 0; j < 3; ++j)
 
753
   for (j = 0; j < MY_MAX; ++j)
749
754
   {
750
755
      if (all_objects[j] != 0)
751
 
         DestroyObj (all_objects[j]);
 
756
         _destroyCDKObject (all_objects[j]);
752
757
   }
 
758
   destroyCDKMenu (menu);
753
759
   destroyCDKScreen (cdkscreen);
754
760
   endCDK ();
755
 
   exit (EXIT_SUCCESS);
 
761
 
 
762
   ExitProgram (EXIT_SUCCESS);
756
763
}