home *** CD-ROM | disk | FTP | other *** search
/ The CDPD Public Domain Collection for CDTV 3 / CDPDIII.bin / pd / programming / utils / dialoglib / examples.lha / test04.c < prev    next >
C/C++ Source or Header  |  1993-03-09  |  2KB  |  97 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, hstack, hbumper, vstack, ok, *termination;
  19.     DialogElement mx1, mx2;
  20.     ULONG error = 0;
  21.  
  22.     initDialogElement( &root, NULL, dispatchRoot, &error,
  23.         DA_Screen, myScreen,
  24.         DA_Member, &hstack,
  25.         WA_Activate, TRUE,
  26.         WA_DragBar, TRUE,
  27.         TAG_DONE );
  28.     initDialogElement( &hstack, &root, dispatchHStack, &error,
  29.         DA_Member, &ok,
  30.         DA_Member, &hbumper,
  31.         DA_Member, &vstack,
  32.         DA_Alignment, 0,
  33.         TAG_DONE );
  34.     initDialogElement( &hbumper, &root, dispatchHBumper, &error, TAG_DONE );
  35.     initDialogElement( &vstack, &root, dispatchVStack, &error,
  36.         DA_Member, &mx1,
  37.         DA_Member, &mx2,
  38.         DA_Alignment, 0,
  39.         TAG_DONE );
  40.     initDialogElement( &ok, &root, dispatchButton, &error,
  41.         NGDA_TextAttr, myScreen->Font,
  42.         NGDA_VisualInfo, myVisualInfo,
  43.         NGDA_GadgetText, "_Ok",
  44.         GT_Underscore, '_',
  45.         DA_EquivalentKey, 'O',
  46.         DA_Termination, TRUE,
  47.         TAG_DONE );
  48.     initDialogElement( &mx1, &root, dispatchMX, &error,
  49.         NGDA_TextAttr, myScreen->Font,
  50.         NGDA_VisualInfo, myVisualInfo,
  51. /*        NGDA_Flags, PLACETEXT_LEFT,    *** default *** */
  52.         GTMX_Labels, labels,
  53.         GTMX_Spacing, 10,
  54.         TAG_DONE );
  55.     initDialogElement( &mx2, &root, dispatchMX, &error,
  56.         NGDA_TextAttr, myScreen->Font,
  57.         NGDA_VisualInfo, myVisualInfo,
  58.         NGDA_Flags, PLACETEXT_RIGHT,
  59.         GTMX_Labels, labels,
  60.         TAG_DONE );
  61.  
  62.     if( error )
  63.         goto cleanup;
  64.  
  65.     termination = runSimpleDialog( &root,
  66.         WA_Title, "Example : GadTools MX",
  67.         TAG_DONE );
  68.  
  69. cleanup:
  70.     cleanupDialogElement( &mx1 );
  71.     cleanupDialogElement( &mx2 );
  72.     cleanupDialogElement( &ok );
  73.     cleanupDialogElement( &vstack );
  74.     cleanupDialogElement( &hstack );
  75.     cleanupDialogElement( &hbumper );
  76.     cleanupDialogElement( &root );
  77. }
  78.  
  79. main( int argc, char *argv[] )
  80. {
  81.     myScreen = LockPubScreen( NULL );
  82.     if( !myScreen )
  83.         goto cleanup;
  84.  
  85.     myVisualInfo = GetVisualInfo( myScreen, TAG_DONE );
  86.     if( !myVisualInfo )
  87.         goto cleanup;
  88.  
  89.     dialog();
  90.  
  91. cleanup:
  92.     if( myVisualInfo )
  93.         FreeVisualInfo( myVisualInfo );
  94.     if( myScreen )
  95.         UnlockPubScreen( NULL, myScreen );
  96. }
  97.