home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_progs / ui_utils / aib623.lha / source / requests.c < prev    next >
C/C++ Source or Header  |  1992-03-21  |  4KB  |  148 lines

  1. #include "aib.h"
  2. #include "extern.h"
  3.  
  4. /* prototypes */
  5.  
  6. int request(char *,char *, char *);
  7. void FontChoice(int);
  8. void load_project(void);
  9. void save_project(void);
  10.  
  11.  
  12. /* globals */
  13.  
  14. struct Window *reqwindow;
  15. struct EasyStruct mine= {
  16.   sizeof(struct EasyStruct),0,
  17.   0,0,0};
  18.  
  19.  
  20. /**** request  ******************************************************/
  21. int request(char *title, char *body, char *gads)
  22. {
  23.     int retval=0;
  24.     int args = 50;
  25.     LONG savedstate;
  26.     mine.es_Title=title;
  27.     mine.es_TextFormat= body;
  28.     mine.es_GadgetFormat = gads;
  29.    
  30.     savedstate = window->IDCMPFlags;
  31.     ModifyIDCMP(window,0);
  32.     retval = EasyRequestArgs( window, &mine, 0L, &args);
  33.     ModifyIDCMP(window,savedstate);
  34.     GT_RefreshWindow(window,NULL);
  35.     return(retval);
  36. }
  37.  
  38.  
  39. /********************  FONT REQUEST ******************************************/
  40.  
  41. void FontChoice (int type)
  42. {
  43.  LONG savedstate;
  44.  struct TextAttr *test;
  45.  static char Menudeal[256];
  46.  
  47.  FontRequester = (struct FontRequester *)AllocAslRequest(ASL_FontRequest,FontTags);
  48.  if (FontRequester != NULL)
  49.       {
  50.      savedstate = window->IDCMPFlags;
  51.          ModifyIDCMP(window,0);
  52.          if (AslRequest(FontRequester,NULL)) {
  53.         switch (type){
  54.         
  55.         case 1:  strcpy(MyFont, FontRequester->fo_Attr.ta_Name);
  56.              GFontSize = FontRequester->fo_Attr.ta_YSize;
  57.              /*          topaz80.ta_Style= FontRequester->fo_Attr.ta_Style;
  58.                          topaz80.ta_Flags= FontRequester->fo_Attr.ta_Flags; */
  59.            
  60.                     GT_SetGadgetAttrs(curr_font,window,NULL,
  61.                   GTTX_Text,MyFont,
  62.                 TAG_DONE);
  63.                     GT_SetGadgetAttrs(font_size,window,NULL,
  64.                 GTNM_Number,GFontSize,
  65.                     TAG_DONE);
  66.  
  67.              break;
  68.  
  69.          case 2: strcpy(Menudeal,FontRequester->fo_Attr.ta_Name);
  70.              menucta.ta_Name= Menudeal;
  71.              menucta.ta_YSize= FontRequester->fo_Attr.ta_YSize;
  72.                          menucta.ta_Style= FontRequester->fo_Attr.ta_Style;
  73.                          menucta.ta_Flags= FontRequester->fo_Attr.ta_Flags; 
  74.              test = &menucta;
  75.              if (!(CustomMenuFont = OpenDiskFont(test)))
  76.                 abort_me("Could not locate font");
  77.            
  78.                     GT_SetGadgetAttrs(menu_font,window,NULL,
  79.                   GTTX_Text,menucta.ta_Name,
  80.                 TAG_DONE);
  81.                     GT_SetGadgetAttrs(menu_size,window,NULL,
  82.                 GTNM_Number,menucta.ta_YSize,
  83.                     TAG_DONE);
  84.  
  85.              break;
  86.           }
  87.         
  88.                }
  89.      
  90.          ModifyIDCMP(window,savedstate);
  91.          FreeAslRequest(FontRequester);
  92.      GT_RefreshWindow(window,NULL);
  93.       }
  94.  
  95. }                
  96.  
  97.  
  98. /******************************* load request ******************************/
  99.  
  100. void load_project(void)
  101. {
  102. LONG savedstate;
  103. ULONG dirtag = TAG_IGNORE;
  104.  
  105. if (AslBase){
  106.             savedstate = window->IDCMPFlags;
  107.                 ModifyIDCMP(window,0);
  108.     if ( (FileRequester = AllocAslRequest(ASL_FileRequest,NULL)) )
  109.         AslRequestTags( (APTR) FileRequester,
  110.             ASL_Hail, "Select a .AIB File",
  111.             ASL_OKText,"LOAD",
  112.             ASL_Window,window,
  113.             ASL_Pattern,(ULONG)"#?.AIB",
  114.             TAG_DONE);
  115.  
  116.                  ModifyIDCMP(window,savedstate);
  117.          GT_RefreshWindow(window,NULL);
  118.     }
  119.  
  120.  
  121. }
  122.  
  123.  
  124. /****************************** save **************************/
  125. void save_project(void)
  126. {
  127. LONG savedstate;
  128. ULONG dirtag = TAG_IGNORE;
  129.  
  130. if (AslBase){
  131.                 savedstate = window->IDCMPFlags;
  132.                 ModifyIDCMP(window,0);
  133.     if ( (FileRequester = AllocAslRequest(ASL_FileRequest,NULL)) )
  134.         if (!(AslRequestTags( (APTR) FileRequester,
  135.             ASL_Hail, "Save with .AIB extension",
  136.             ASL_OKText,"SAVE",
  137.             ASL_Pattern, (ULONG)"#?.AIB",
  138.             ASL_Window,window,
  139.             TAG_DONE)))
  140.                 
  141.         abort_me("Could not open requester");
  142.  
  143.     }
  144.  
  145.                  ModifyIDCMP(window,savedstate);
  146.           GT_RefreshWindow(window,NULL);
  147. }
  148.