home *** CD-ROM | disk | FTP | other *** search
/ Fresh Fish 8 / FreshFishVol8-CD2.bin / bbs / dev / bgui-1.1a.lha / BGUI / demos / filereq.c < prev    next >
C/C++ Source or Header  |  1994-08-03  |  7KB  |  179 lines

  1. ;/* Execute me to compile with DICE V3.0.
  2. dcc filereq.c -proto -mi -ms -mRR -3.0 -lbgui
  3. quit
  4. */
  5. /*
  6. **         $RCSfile: filereq.c,v $
  7. **      Description: Simple BGUI filereqclass demo.
  8. **        Copyright: (C) Copyright 1994 Jaba Development.
  9. **                   (C) Copyright 1994 Jan van den Baard.
  10. **                   All Rights Reserved.
  11. **
  12. **          $Author: jaba $
  13. **        $Revision: 1.2 $
  14. **            $Date: 1994/08/03 11:21:10 $
  15. **/
  16.  
  17. #include <exec/types.h>
  18. #include <libraries/gadtools.h>
  19. #include <libraries/asl.h>
  20. #include <libraries/bgui.h>
  21. #include <libraries/bgui_macros.h>
  22.  
  23. #include <clib/alib_protos.h>
  24.  
  25. #include <proto/exec.h>
  26. #include <proto/intuition.h>
  27. #include <proto/utility.h>
  28. #include <proto/bgui.h>
  29.  
  30. #include <stdlib.h>
  31. #include <stdio.h>
  32.  
  33. /*
  34. **      Library base pointer.
  35. **/
  36. struct Library  *BGUIBase       = NULL;
  37.  
  38. /*
  39. **      Bulk GetAttr(). This really belongs in amiga.lib... I think.
  40. **/
  41. ULONG GetAttrs( Object *obj, ULONG tag1, ... )
  42. {
  43.         struct TagItem          *tstate = ( struct TagItem * )&tag1, *tag;
  44.         ULONG                    num = 0L;
  45.  
  46.         while ( tag = NextTagItem( &tstate ))
  47.                 num += GetAttr( tag->ti_Tag, obj, ( ULONG * )tag->ti_Data );
  48.  
  49.         return( num );
  50. }
  51.  
  52. int main( int argc, char *argv[] )
  53. {
  54.         Object          *filereq;
  55.         ULONG            rc, dr, fl, pt, pa, l, t, w, h;
  56.  
  57.         /*
  58.         **      Open the library.
  59.         **/
  60.         if ( BGUIBase = OpenLibrary( BGUINAME, BGUIVERSION )) {
  61.                 /*
  62.                 **      Create a filerequester object.
  63.                 **/
  64.                 filereq = FileReqObject, ASLFR_DoPatterns, TRUE, EndObject;
  65.  
  66.                 if ( filereq ) {
  67.                         /*
  68.                         **      Pop the requester.
  69.                         **/
  70.                         if ( ! ( rc = DoRequest( filereq ))) {
  71.                                 /*
  72.                                 **      Obtain attribute values.
  73.                                 **/
  74.                                 GetAttrs( filereq, FRQ_Drawer,          &dr,
  75.                                                    FRQ_File,            &fl,
  76.                                                    FRQ_Pattern,         &pt,
  77.                                                    FRQ_Path,            &pa,
  78.                                                    FRQ_Left,            &l,
  79.                                                    FRQ_Top,             &t,
  80.                                                    FRQ_Width,           &w,
  81.                                                    FRQ_Height,          &h,
  82.                                                    TAG_END );
  83.                                 /*
  84.                                 **      Dump 'm on the console.
  85.                                 **/
  86.                                 printf( "Drawer                : %s\n"
  87.                                         "File                  : %s\n"
  88.                                         "Pattern               : %s\n"
  89.                                         "Path                  : %s\n"
  90.                                         "Left,Top,Width,Height : %ld,%ld,%ld,%ld\n",
  91.                                         dr, fl, pt, pa, l, t, w, h );
  92.                         } else if ( rc == FRQ_CANCEL )
  93.                                 /*
  94.                                 **      Requester canceled.
  95.                                 **/
  96.                                 puts("Canceled" );
  97.                         else
  98.                                 /*
  99.                                 **      Error.
  100.                                 **/
  101.                                 printf("Error %ld\n", rc );
  102.  
  103.                         /*
  104.                         **      Make it a save requester.
  105.                         **/
  106.                         if ( ! ( rc = SetAttrs( filereq, ASLFR_DoSaveMode, TRUE, TAG_END ))) {
  107.                                 /*
  108.                                 **      Pop the requester.
  109.                                 **/
  110.                                 if ( ! ( rc = DoRequest( filereq ))) {
  111.                                         /*
  112.                                         **      Obtain attribute values.
  113.                                         **/
  114.                                         GetAttrs( filereq, FRQ_Drawer,          &dr,
  115.                                                            FRQ_File,            &fl,
  116.                                                            FRQ_Pattern,         &pt,
  117.                                                            FRQ_Path,            &pa,
  118.                                                            FRQ_Left,            &l,
  119.                                                            FRQ_Top,             &t,
  120.                                                            FRQ_Width,           &w,
  121.                                                            FRQ_Height,          &h,
  122.                                                            TAG_END );
  123.                                         /*
  124.                                         **      Dump 'm to the console.
  125.                                         **/
  126.                                         printf( "Drawer                : %s\n"
  127.                                                 "File                  : %s\n"
  128.                                                 "Pattern               : %s\n"
  129.                                                 "Path                  : %s\n"
  130.                                                 "Left,Top,Width,Height : %ld,%ld,%ld,%ld\n",
  131.                                                 dr, fl, pt, pa, l, t, w, h );
  132.                                 } else if ( rc == FRQ_CANCEL )
  133.                                         /*
  134.                                         **      Requester canceled.
  135.                                         **/
  136.                                         puts("Canceled" );
  137.                                 else
  138.                                         /*
  139.                                         **      Error.
  140.                                         **/
  141.                                         printf("Error %ld\n", rc );
  142.                         } else
  143.                                 /*
  144.                                 **      Error with SetAttrs().
  145.                                 **/
  146.                                 printf( "Error %ld\n", rc );
  147.                         /*
  148.                         **      Diump the filerequester object.
  149.                         **/
  150.                         DisposeObject( filereq);
  151.                 } else
  152.                         puts( "unable to create filerequester object." );
  153.                 /*
  154.                 **      Close the library.
  155.                 **/
  156.                 CloseLibrary( BGUIBase );
  157.         } else
  158.                 puts( "unable to open the bgui.library" );
  159.  
  160.         return( 0 );
  161. }
  162.  
  163. #ifdef _DCC
  164. int wbmain( struct wbStartup *wbs )
  165. {
  166.         return( main( 0, NULL ));
  167. }
  168. #endif
  169.  
  170. /*
  171.  *      $Log: filereq.c,v $
  172.  * Revision 1.2  1994/08/03  11:21:10  jaba
  173.  * Switched to proto/ instead of clib/.
  174.  *
  175.  * Revision 1.1  1994/06/20  16:43:03  jaba
  176.  * Initial revision
  177.  *
  178.  */
  179.