home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 13 / AACD13.ISO / AACD / Resources / System / BoingBag1 / Contributions / InstallerNG / GUI-API / example / igui_CopylibConfirm.c < prev    next >
C/C++ Source or Header  |  1999-11-01  |  4KB  |  142 lines

  1.  
  2. #include "includes.h"
  3. #include "installergui_data.h"
  4.  
  5. /********************************************************************
  6.  *
  7.  *  DESCRIPTION
  8.  *
  9.  */
  10.  
  11. /********************************************************************
  12.  *
  13.  *  STATIC
  14.  *
  15.  */
  16.  
  17. /********************************************************************
  18.  *
  19.  *  EXTERN
  20.  *
  21.  */
  22.  
  23. /********************************************************************
  24.  *
  25.  *  PUBLIC
  26.  *
  27.  */
  28.  
  29. /********************************************************************
  30.  *
  31.  *  CODE
  32.  *
  33.  */
  34.  
  35. long __asm igui_CopylibConfirm(register __a0 APTR application,
  36.                                register __a1 struct FunctionEnvironment *localenv,
  37.                                register __d0 long srcver,
  38.                                register __d1 long destver)
  39. {
  40.   #ifdef DEBUG
  41.   DEBUG_MAKRO
  42.   #endif
  43.  
  44.   {
  45.     struct Application *app = (struct Application *) application;
  46.  
  47.     char *body;
  48.  
  49.     APTR obj;
  50.  
  51.     long retval = 1,
  52.          event,
  53.          args[5];
  54.  
  55.     // create an arg-array for the StringF function
  56.     args[0] = localenv->fe_Prompt;
  57.     args[1] = srcver >> 16;
  58.     args[2] = srcver & 0xffff;
  59.     args[4] = localenv->fe_Dest;
  60.  
  61.     // if destver equals ~0, then no destfile does exist!
  62.     if (destver != ~0)
  63.     {
  64.       char *body2;
  65.       long args2[2];
  66.  
  67.       args[3] = (long) app->app_Texts[COPYLIB_VERSION];
  68.  
  69.       args2[0] = destver >> 16;
  70.       args2[1] = destver & 0xffff;
  71.  
  72.       body2 = sav_StringF2(app->app_Texts[COPYLIB_PATTERN], &args);
  73.       if (!body2) { /* OUT OF MEMORY */ return(0); }
  74.  
  75.       body = sav_StringF2(body2, &args2);
  76.       sav_FreeVec(body2);
  77.     }
  78.  
  79.     // no destination file!
  80.     else
  81.     {
  82.       args[3] = (long) app->app_Texts[COPYLIB_NOVERSION];
  83.       body = sav_StringF2(app->app_Texts[COPYLIB_PATTERN], &args);
  84.     }
  85.  
  86.     // there was not enough free memory, to create the formatted text
  87.     if (!body) { /* OUT OF MEMORY */ return(0); }
  88.     else
  89.     {
  90.       // after we created the text, we can now create the object itself
  91.       obj = GroupObject,
  92.                    Child, HVSpace,
  93.                    Child, TextObject,
  94.                      MUIA_Frame, MUIV_Frame_None,
  95.                      MUIA_Text_Contents, localenv->fe_Prompt,
  96.                      MUIA_Text_SetMin, TRUE,
  97.                      MUIA_Text_PreParse, "\33c",
  98.                    End,
  99.                    Child, TextObject,
  100.                      MUIA_Background, MUII_TextBack,
  101.                      //MUIA_Frame, MUIV_Frame_Text,
  102.                      MUIA_Text_Contents, body,
  103.                      MUIA_Text_SetMin, TRUE,
  104.                      MUIA_Text_PreParse, "\33c",
  105.                    End,
  106.                    Child, HVSpace,
  107.                  End;
  108.  
  109.       // set the help text for this function
  110.       igui_SetHelp(app, (char *) localenv->fe_Help);
  111.  
  112.       //
  113.       if (guistuff_NewContent(app, obj))
  114.       {
  115.         // make the "cancel" button into a "skip this part" button
  116.         igui_NameCancel(app, app->app_Texts[BUTTON_SKIP]);
  117.  
  118.         // wait, until the user "proceeds", "skips" or confirms the "quit" action
  119.         do
  120.         {
  121.           event = igui_QuietWaitApp(app);
  122.  
  123.           if      (event == GUIEVENT_PROCEED) { retval = 1; break; }
  124.           else if (event == GUIEVENT_ABORT)   { retval = 0; break; }
  125.         }
  126.         while (guistuff_HandleGUIEvent(app, event));
  127.  
  128.         // restore the "cancel" button
  129.         igui_NameCancel(app, app->app_Texts[BUTTON_CANCEL]);
  130.       }
  131.  
  132.       // free the memory of the body-text
  133.       sav_FreeVec(body);
  134.     }
  135.  
  136.     //
  137.     igui_EmptyPanel(app);
  138.     return(retval);
  139.   }
  140. }
  141.  
  142.