home *** CD-ROM | disk | FTP | other *** search
/ The CDPD Public Domain Collection for CDTV 3 / CDPDIII.bin / pd / programming / utils / dialoglib / examples.lha / test02.c < prev    next >
C/C++ Source or Header  |  1993-03-09  |  4KB  |  133 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. #include <stdio.h>
  11.  
  12. struct Screen *myScreen;
  13. APTR myVisualInfo;
  14.  
  15. VOID dialog( VOID )
  16. {
  17.     DialogElement root, vstack, hstack1, hstack, hspring, ok, hstack2, *termination;
  18.     DialogElement string1, string2, string3, string4;
  19.     UBYTE buffer1[32], buffer2[32], buffer3[32], buffer4[32];
  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, &string1,
  49.         DA_Member, &string4,
  50.         TAG_DONE );
  51.     initDialogElement( &hstack2, &root, dispatchHStack, &error,
  52.         DA_Member, &string3,
  53.         DA_Member, &string2,
  54.         TAG_DONE );
  55.     initDialogElement( &string1, &root, dispatchString, &error,
  56.         NGDA_TextAttr, myScreen->Font,
  57.         NGDA_VisualInfo, myVisualInfo,
  58.         NGDA_GadgetText, "placement left",
  59. /*        NGDA_Flags, PLACETEXT_LEFT,    *** default *** */
  60.         GTST_MaxChars, 31,
  61.         DA_Storage, buffer1,
  62.         TAG_DONE );
  63.     initDialogElement( &string2, &root, dispatchString, &error,
  64.         NGDA_TextAttr, myScreen->Font,
  65.         NGDA_VisualInfo, myVisualInfo,
  66.         NGDA_GadgetText, "placement right",
  67.         NGDA_Flags, PLACETEXT_RIGHT,
  68.         GTST_MaxChars, 31,
  69.         DA_Storage, buffer2,
  70.         TAG_DONE );
  71.     initDialogElement( &string3, &root, dispatchString, &error,
  72.         NGDA_TextAttr, myScreen->Font,
  73.         NGDA_VisualInfo, myVisualInfo,
  74.         NGDA_GadgetText, "placement above",
  75.         NGDA_Flags, PLACETEXT_ABOVE,
  76.         GTST_MaxChars, 31,
  77.         DA_Storage, buffer3,
  78.         TAG_DONE );
  79.     initDialogElement( &string4, &root, dispatchString, &error,
  80.         NGDA_TextAttr, myScreen->Font,
  81.         NGDA_VisualInfo, myVisualInfo,
  82.         NGDA_GadgetText, "placement below",
  83.         NGDA_Flags, PLACETEXT_BELOW,
  84.         GTST_MaxChars, 31,
  85.         DA_Storage, buffer4,
  86.         TAG_DONE );
  87.  
  88.     if( error )
  89.         goto cleanup;
  90.  
  91.     buffer1[0] = buffer2[0] = buffer3[0] = buffer4[0] = '\0';
  92.  
  93.     termination = runSimpleDialog( &root,
  94.         WA_Title, "Example : GadTools STRING",
  95.         WA_InnerWidth, 300,
  96.         WA_InnerHeight, 200,
  97.         TAG_DONE );
  98.  
  99.     printf( "buffer contents:\n%s\n%s\n%s\n%s\n", buffer1, buffer2, buffer3, buffer4 );
  100.  
  101. cleanup:
  102.     cleanupDialogElement( &string1 );
  103.     cleanupDialogElement( &string2 );
  104.     cleanupDialogElement( &string3 );
  105.     cleanupDialogElement( &string4 );
  106.     cleanupDialogElement( &ok );
  107.     cleanupDialogElement( &hstack );
  108.     cleanupDialogElement( &hspring );
  109.     cleanupDialogElement( &hstack1 );
  110.     cleanupDialogElement( &hstack2 );
  111.     cleanupDialogElement( &vstack );
  112.     cleanupDialogElement( &root );
  113. }
  114.  
  115. main( int argc, char *argv[] )
  116. {
  117.     myScreen = LockPubScreen( NULL );
  118.     if( !myScreen )
  119.         goto cleanup;
  120.  
  121.     myVisualInfo = GetVisualInfo( myScreen, TAG_DONE );
  122.     if( !myVisualInfo )
  123.         goto cleanup;
  124.  
  125.     dialog();
  126.  
  127. cleanup:
  128.     if( myVisualInfo )
  129.         FreeVisualInfo( myVisualInfo );
  130.     if( myScreen )
  131.         UnlockPubScreen( NULL, myScreen );
  132. }
  133.