home *** CD-ROM | disk | FTP | other *** search
/ The CDPD Public Domain Collection for CDTV 3 / CDPDIII.bin / pd / programming / utils / dialoglib / examples.lha / test05.c < prev    next >
C/C++ Source or Header  |  1993-03-09  |  3KB  |  125 lines

  1. #include <exec/nodes.h>
  2. #include <exec/lists.h>
  3. #include <libraries/gadtools.h>
  4. #include <utility/tagitem.h>
  5. #include <proto/exec.h>
  6. #include <proto/gadtools.h>
  7. #include <proto/intuition.h>
  8. #include <proto/utility.h>
  9. #include <dialog/dialog.h>
  10.  
  11. struct Screen *myScreen;
  12. APTR myVisualInfo;
  13.  
  14. STRPTR labels[] = { "This", "That", "Neither", NULL };
  15.  
  16. VOID dialog( VOID )
  17. {
  18.     DialogElement root, vstack, hstack1, hstack, hspring, ok, hstack2, *termination;
  19.     DialogElement cycle1, cycle2, cycle3, cycle4;
  20.     ULONG error = 0;
  21.  
  22.     initDialogElement( &root, NULL, dispatchRoot, &error,
  23.         DA_Screen, myScreen,
  24.         DA_Member, &vstack,
  25.         WA_Activate, TRUE,
  26.         WA_DragBar, TRUE,
  27.         TAG_DONE );
  28.     initDialogElement( &vstack, &root, dispatchVStack, &error,
  29.         DA_Member, &hstack1,
  30.         DA_Member, &hstack,
  31.         DA_Member, &hstack2,
  32.         TAG_DONE );
  33.     initDialogElement( &hstack, &root, dispatchHStack, &error,
  34.         DA_Member, &hspring,
  35.         DA_Member, &ok,
  36.         DA_Member, &hspring,
  37.         TAG_DONE );
  38.     initDialogElement( &hspring, &root, dispatchHSpring, &error, TAG_DONE );
  39.     initDialogElement( &ok, &root, dispatchButton, &error,
  40.         NGDA_TextAttr, myScreen->Font,
  41.         NGDA_VisualInfo, myVisualInfo,
  42.         NGDA_GadgetText, "_Ok",
  43.         GT_Underscore, '_',
  44.         DA_EquivalentKey, 'O',
  45.         DA_Termination, TRUE,
  46.         TAG_DONE );
  47.     initDialogElement( &hstack1, &root, dispatchHStack, &error,
  48.         DA_Member, &cycle1,
  49.         DA_Member, &cycle4,
  50.         TAG_DONE );
  51.     initDialogElement( &hstack2, &root, dispatchHStack, &error,
  52.         DA_Member, &cycle3,
  53.         DA_Member, &cycle2,
  54.         TAG_DONE );
  55.     initDialogElement( &cycle1, &root, dispatchCycle, &error,
  56.         NGDA_TextAttr, myScreen->Font,
  57.         NGDA_VisualInfo, myVisualInfo,
  58.         NGDA_GadgetText, "placement left",
  59. /*        NGDA_Flags, PLACETEXT_LEFT,    *** default *** */
  60.         GTCY_Labels, labels,
  61.         TAG_DONE );
  62.     initDialogElement( &cycle2, &root, dispatchCycle, &error,
  63.         NGDA_TextAttr, myScreen->Font,
  64.         NGDA_VisualInfo, myVisualInfo,
  65.         NGDA_GadgetText, "placement right",
  66.         NGDA_Flags, PLACETEXT_RIGHT,
  67.         GTCY_Labels, labels,
  68.         TAG_DONE );
  69.     initDialogElement( &cycle3, &root, dispatchCycle, &error,
  70.         NGDA_TextAttr, myScreen->Font,
  71.         NGDA_VisualInfo, myVisualInfo,
  72.         NGDA_GadgetText, "placement above",
  73.         NGDA_Flags, PLACETEXT_ABOVE,
  74.         GTCY_Labels, labels,
  75.         TAG_DONE );
  76.     initDialogElement( &cycle4, &root, dispatchCycle, &error,
  77.         NGDA_TextAttr, myScreen->Font,
  78.         NGDA_VisualInfo, myVisualInfo,
  79.         NGDA_GadgetText, "placement below",
  80.         NGDA_Flags, PLACETEXT_BELOW,
  81.         GTCY_Labels, labels,
  82.         TAG_DONE );
  83.  
  84.     if( error )
  85.         goto cleanup;
  86.  
  87.     termination = runSimpleDialog( &root,
  88.         WA_Title, "Example : GadTools CYCLE",
  89.         WA_InnerWidth, 300,
  90.         WA_InnerHeight, 200,
  91.         TAG_DONE );
  92.  
  93. cleanup:
  94.     cleanupDialogElement( &cycle1 );
  95.     cleanupDialogElement( &cycle2 );
  96.     cleanupDialogElement( &cycle3 );
  97.     cleanupDialogElement( &cycle4 );
  98.     cleanupDialogElement( &ok );
  99.     cleanupDialogElement( &hstack );
  100.     cleanupDialogElement( &hspring );
  101.     cleanupDialogElement( &hstack1 );
  102.     cleanupDialogElement( &hstack2 );
  103.     cleanupDialogElement( &vstack );
  104.     cleanupDialogElement( &root );
  105. }
  106.  
  107. main( int argc, char *argv[] )
  108. {
  109.     myScreen = LockPubScreen( NULL );
  110.     if( !myScreen )
  111.         goto cleanup;
  112.  
  113.     myVisualInfo = GetVisualInfo( myScreen, TAG_DONE );
  114.     if( !myVisualInfo )
  115.         goto cleanup;
  116.  
  117.     dialog();
  118.  
  119. cleanup:
  120.     if( myVisualInfo )
  121.         FreeVisualInfo( myVisualInfo );
  122.     if( myScreen )
  123.         UnlockPubScreen( NULL, myScreen );
  124. }
  125.