home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 5 / DATAFILE_PDCD5.iso / utilities / s1 / sesanim / !SESanim / Sources / c / FrontEnd < prev    next >
Text File  |  1997-05-13  |  4KB  |  123 lines

  1. #include "Wimp.h"
  2. #include "Desklib:Event.h"
  3. #include "Desklib:Error.h"
  4. #include "Desklib:Window.h"
  5. #include "Desklib:Resource.h"
  6. #include "Desklib:WimpSwis.h"
  7. #include "Desklib:EventMsg.h"
  8. #include "Desklib:icon.h"
  9. #include "Desklib:screen.h"
  10. #include "Desklib:Pointer.h"
  11. #include "Desklib:Window.h"
  12. #include "Desklib:Template.h"
  13. #include "Desklib:Menu.h"
  14. #include "Desklib:Handler.h"
  15. static sprite_area usersp;
  16. static BOOL quit=FALSE;
  17. static window_handle info_window;
  18. static menu_ptr main_menu;
  19.  
  20. /*handles clicking on the icon bar icon*/
  21. static BOOL BarClick(event_pollblock *e, void *r){
  22.   if (e->data.mouse.button.data.menu){
  23.     Menu_Show(main_menu,e->data.mouse.pos.x,224);
  24.   }
  25.   return 1;
  26. }
  27.  
  28. static BOOL load(event_pollblock*e,void *r);
  29.  
  30. static BOOL Click(event_pollblock *e, void *r){
  31.   strcpy(e->data.message.data.dataload.filename,"<SesAnimate$Dir>.Gif");
  32.   load(e,r);
  33.   return 1;
  34. }
  35.  
  36. /*handles the icon bar menu*/
  37. static BOOL MainMenu(event_pollblock *e, void *r){
  38.   int g,h;
  39.   switch (e->data.words[0]){
  40.     case 1 :
  41.       Menu_GetFlags(main_menu,1,&g,&h);
  42.       Menu_SetFlags(main_menu,1,1-g,h);
  43.       break;
  44.     case 2 :quit=TRUE;break;
  45.   }
  46.   return 1;
  47. }
  48.  
  49. static BOOL save(event_pollblock * e ,void * r)
  50. {
  51.   message_block message;
  52.   message.header.size=256;
  53.   message.header.yourref=e->data.message.header.myref;
  54.   message.header.action=message_DATASAVEACK;
  55.   message.data.datasaveack.icon=e->data.message.data.datasave.icon;
  56.   message.data.datasaveack.pos=e->data.message.data.datasave.pos;
  57.   message.data.datasaveack.estsize=e->data.message.data.datasave.estsize;
  58.   message.data.datasaveack.filetype=e->data.message.data.datasave.filetype;
  59.   strcpy(message.data.datasaveack.filename,"<Wimp$ScrapDir>.Sprite!");
  60.   Wimp_SendMessage(18,&message,e->data.message.header.sender,0);
  61.   return 1;
  62. }
  63.  
  64. BOOL CheckLoaded(void){
  65.  char buffer[512];
  66.   if(!OS_ReadVarVal("Alias$InterGif",buffer,512)){
  67.     buffer[0]=0;
  68.     buffer[1]=0;
  69.     buffer[2]=0;
  70.     buffer[3]=0;
  71.     strcpy(buffer+4,"Please find InterGif first, then try again. Or, switch off buffering\0");
  72.     SWI(6,0,0x400DF,buffer,256,"SES Animater","!sesanim",1,"I'll try");
  73.     return 0;
  74.   }else{
  75.     return 1;
  76.   }
  77. }
  78.  
  79. static BOOL load(event_pollblock * e ,void * r)
  80. {
  81.   char text[512];
  82.   int g,h;
  83.   Menu_GetFlags(main_menu,1,&g,&h);
  84.   switch(g){
  85.     case 0 :sprintf(text,"<SesAnimate$Dir>.RunAnim %s",e->data.message.data.dataload.filename);Wimp_StartTask(text);break;
  86.     case 1 :if(CheckLoaded()){
  87.             sprintf(text,"InterGif -s -o <Wimp$Scrap> %s ",e->data.message.data.dataload.filename);
  88.             Wimp_StartTask(text);
  89.             Wimp_StartTask("<SesAnimate$Dir>.RunBuff <Wimp$Scrap>");
  90.             break;
  91.     }
  92.   }
  93. }
  94.  
  95.  
  96. void main(void){
  97.   icon_handle baricon;
  98.   event_pollblock event;
  99.   event_pollmask mask;
  100.   char appname[64] = "Animate";
  101.   Resource_Initialise("SESAnimate");
  102.   main_menu=Menu_New("Animate","Info,Buffered,Quit");
  103.   usersp = Sprite_LoadFile("<SESAnimate$Dir>.FrontSpri");
  104.   Event_Initialise(appname);
  105.   EventMsg_Initialise();
  106.   Template_LoadFile("FrontTemp");
  107.   Template_UseSpriteArea(usersp);
  108.   info_window=Window_Create("Info",80);
  109.   Menu_AddSubMenu(main_menu,0,(menu_ptr) info_window);
  110.   baricon= Icon_BarIcon("!sesanim",iconbar_RIGHT);
  111.   EventMsg_Claim(message_DATALOAD,event_ANY,load,NULL);
  112.   Event_Claim(event_CLICK,window_ICONBAR,event_ANY,BarClick,NULL);
  113.   Event_Claim(event_CLICK,info_window,event_ANY,Click,NULL);
  114.   Event_Claim(event_OPEN,event_ANY,event_ANY,Handler_OpenWindow,NULL);
  115.   Event_Claim(event_MENU,event_ANY,event_ANY,MainMenu,NULL);
  116.   EventMsg_Claim(message_DATASAVE,event_ANY,save,NULL);
  117.   while(!quit){
  118.     mask.value=1;
  119.     Wimp_Poll(mask,&event);
  120.     Event_Process(&event);
  121.   }
  122. }
  123.