home *** CD-ROM | disk | FTP | other *** search
/ Amiga MA Magazine 1998 #6 / amigamamagazinepolishissue1998.iso / coders / boopsi / appiconclass / tinytest.c < prev    next >
C/C++ Source or Header  |  1977-12-31  |  2KB  |  94 lines

  1. /*
  2. **      $VER: Short demo of the AppIconClass 1.0 (28.6.95) Doguet Emmanuel
  3. **
  4. **/
  5.  
  6. #include <proto/exec.h>
  7. #include <proto/alib.h>
  8. #include <proto/intuition.h>
  9. #include <Boopsi/AppIconClass.h>
  10.  
  11. #include <workbench/workbench.h>
  12. #include <workbench/startup.h>
  13.  
  14. #include <stdio.h>
  15.  
  16. #ifdef _DCC
  17. #include <lib/misc.h>
  18. #endif
  19.  
  20. int main( int argc, char **argv )
  21. {
  22. Class   *AppIconClass;
  23. Object  *MyIcon;
  24. ULONG   WaitMask;
  25. BOOL    running=TRUE;
  26. int i;
  27. struct  AppMessage  *AppMsg;
  28. struct  WBArg       *wa;
  29.  
  30.     /*
  31.     **  Init. the class
  32.     **/
  33.     if( !(AppIconClass=InitAppIconClass()) )
  34.     {
  35.         printf("Can't init the AppIconClass\n");
  36.         return(30);
  37.     }
  38.  
  39.     /*
  40.     **  Create the object
  41.     **/
  42.     MyIcon=NewObject( AppIconClass, NULL, GA_ID, 0, AIC_AppName, "TinyTest Dock", AIC_IconFileName, argv[0], TAG_END );
  43.  
  44.     if( MyIcon )
  45.     {
  46.         GetAttr( AIC_AppIconMask, MyIcon, &WaitMask );
  47.  
  48.         do{
  49.             Wait( WaitMask );
  50.  
  51.  
  52.             while( (AppMsg=(struct AppMessage *)DoMethod( MyIcon, GM_HANDLEINPUT )) )
  53.             {
  54.                 // If Icon clicked, end of program
  55.                 if( APP_CLICKED(AppMsg) )
  56.                     running=FALSE;
  57.                 else
  58.                 // We scan all the entries
  59.                 for(i=0, wa=AppMsg->am_ArgList; i<APP_NUMARGS(AppMsg); i++, wa++ )
  60.                 {
  61.                     if( APP_IS_DIR( wa ) )
  62.                         printf("You put a dir/volume on my AppIcon ;-)\n");
  63.                     else
  64.                     if( APP_IS_FILE( wa ) )
  65.                         printf("You put a file on my AppIcon ;-)\n");
  66.                     else
  67.                         printf("You put somethink like an AppIcon on my AppIcon ?? :-(\n");
  68.                 }
  69.                 ReplyMsg( (struct Message *)AppMsg );
  70.             }
  71.  
  72.         }while( running );
  73.     }
  74.     else
  75.         printf("Can't create the object :-(((\n");
  76.  
  77.     if( MyIcon )
  78.         DisposeObject( MyIcon );
  79.  
  80.     if( AppIconClass )
  81.         FreeAppIconClass( AppIconClass );
  82.  
  83.     return(0);
  84. }
  85.  
  86.  
  87. #ifdef _DCC
  88. int wbmain( struct WBStartup *w )
  89. {
  90.     OpenConsole("CON:0/400//50/TinyTest ouput");
  91.     return( main(1, &(w->sm_ArgList->wa_Name)) );
  92. }
  93. #endif
  94.