home *** CD-ROM | disk | FTP | other *** search
/ The CDPD Public Domain Collection for CDTV 3 / CDPDIII.bin / pd / programming / utils / dialoglib / examples.lha / test01.c < prev    next >
C/C++ Source or Header  |  1993-03-09  |  3KB  |  119 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. VOID dialog( VOID )
  15. {
  16.     DialogElement root, vstack, hstack1, hstack, hspring, ok, hstack2, *termination;
  17.     DialogElement check1, check2, check3, check4;
  18.     ULONG error = 0;
  19.  
  20.     initDialogElement( &root, NULL, dispatchRoot, &error,
  21.         DA_Screen, myScreen,
  22.         DA_Member, &vstack,
  23.         WA_Activate, TRUE,
  24.         WA_DragBar, TRUE,
  25.         TAG_DONE );
  26.     initDialogElement( &vstack, &root, dispatchVStack, &error,
  27.         DA_Member, &hstack1,
  28.         DA_Member, &hstack,
  29.         DA_Member, &hstack2,
  30.         TAG_DONE );
  31.     initDialogElement( &hstack, &root, dispatchHStack, &error,
  32.         DA_Member, &hspring,
  33.         DA_Member, &ok,
  34.         DA_Member, &hspring,
  35.         TAG_DONE );
  36.     initDialogElement( &hspring, &root, dispatchHSpring, &error, TAG_DONE );
  37.     initDialogElement( &ok, &root, dispatchButton, &error,
  38.         NGDA_TextAttr, myScreen->Font,
  39.         NGDA_VisualInfo, myVisualInfo,
  40.         NGDA_GadgetText, "_Ok",
  41.         GT_Underscore, '_',
  42.         DA_EquivalentKey, 'O',
  43.         DA_Termination, TRUE,
  44.         TAG_DONE );
  45.     initDialogElement( &hstack1, &root, dispatchHStack, &error,
  46.         DA_Member, &check1,
  47.         DA_Member, &check4,
  48.         TAG_DONE );
  49.     initDialogElement( &hstack2, &root, dispatchHStack, &error,
  50.         DA_Member, &check3,
  51.         DA_Member, &check2,
  52.         TAG_DONE );
  53.     initDialogElement( &check1, &root, dispatchCheckBox, &error,
  54.         NGDA_TextAttr, myScreen->Font,
  55.         NGDA_VisualInfo, myVisualInfo,
  56.         NGDA_GadgetText, "placement left",
  57. /*        NGDA_Flags, PLACETEXT_LEFT,    *** default *** */
  58.         TAG_DONE );
  59.     initDialogElement( &check2, &root, dispatchCheckBox, &error,
  60.         NGDA_TextAttr, myScreen->Font,
  61.         NGDA_VisualInfo, myVisualInfo,
  62.         NGDA_GadgetText, "placement right",
  63.         NGDA_Flags, PLACETEXT_RIGHT,
  64.         TAG_DONE );
  65.     initDialogElement( &check3, &root, dispatchCheckBox, &error,
  66.         NGDA_TextAttr, myScreen->Font,
  67.         NGDA_VisualInfo, myVisualInfo,
  68.         NGDA_GadgetText, "placement above",
  69.         NGDA_Flags, PLACETEXT_ABOVE,
  70.         TAG_DONE );
  71.     initDialogElement( &check4, &root, dispatchCheckBox, &error,
  72.         NGDA_TextAttr, myScreen->Font,
  73.         NGDA_VisualInfo, myVisualInfo,
  74.         NGDA_GadgetText, "placement below",
  75.         NGDA_Flags, PLACETEXT_BELOW,
  76.         TAG_DONE );
  77.  
  78.     if( error )
  79.         goto cleanup;
  80.  
  81.     termination = runSimpleDialog( &root,
  82.         WA_Title, "Example : GadTools CHECKBOX",
  83.         WA_InnerWidth, 300,
  84.         WA_InnerHeight, 200,
  85.         TAG_DONE );
  86.  
  87. cleanup:
  88.     cleanupDialogElement( &check1 );
  89.     cleanupDialogElement( &check2 );
  90.     cleanupDialogElement( &check3 );
  91.     cleanupDialogElement( &check4 );
  92.     cleanupDialogElement( &ok );
  93.     cleanupDialogElement( &hstack );
  94.     cleanupDialogElement( &hspring );
  95.     cleanupDialogElement( &hstack1 );
  96.     cleanupDialogElement( &hstack2 );
  97.     cleanupDialogElement( &vstack );
  98.     cleanupDialogElement( &root );
  99. }
  100.  
  101. main( int argc, char *argv[] )
  102. {
  103.     myScreen = LockPubScreen( NULL );
  104.     if( !myScreen )
  105.         goto cleanup;
  106.  
  107.     myVisualInfo = GetVisualInfo( myScreen, TAG_DONE );
  108.     if( !myVisualInfo )
  109.         goto cleanup;
  110.  
  111.     dialog();
  112.  
  113. cleanup:
  114.     if( myVisualInfo )
  115.         FreeVisualInfo( myVisualInfo );
  116.     if( myScreen )
  117.         UnlockPubScreen( NULL, myScreen );
  118. }
  119.