home *** CD-ROM | disk | FTP | other *** search
/ Magazyn Exec 4 / CD_Magazyn_EXEC_nr_4.iso / Recent / dev / c / apputil.lha / apputil / requesters.c < prev    next >
Encoding:
C/C++ Source or Header  |  2000-11-04  |  2.0 KB  |  101 lines

  1. /*
  2.  * requesters.c
  3.  * ============
  4.  * Requester utility functions.
  5.  *
  6.  * Copyright (C) 1999-2000 HÃ¥kan L. Younes (lorens@hem.passagen.se)
  7.  */
  8.  
  9. #include <intuition/intuitionbase.h>
  10.  
  11. #include <proto/intuition.h>
  12.  
  13. #include "apputil.h"
  14.  
  15.  
  16. static UWORD __chip BUSY_POINTER[] = {
  17.   0x0000, 0x0000,
  18.   0x0400, 0x07C0,
  19.   0x0000, 0x07C0,
  20.   0x0100, 0x0380,
  21.   0x0000, 0x07E0,
  22.   0x07C0, 0x1FF8,
  23.   0x1FF0, 0x3FEC,
  24.   0x3FF8, 0x7FDE,
  25.   0x3FF8, 0x7FBE,
  26.   0x7FFC, 0xFF7F,
  27.   0x7EFC, 0xFFFF,
  28.   0x7FFC, 0xFFFF,
  29.   0x3FF8, 0x7FFE,
  30.   0x3FF8, 0x7FFE,
  31.   0x1FF0, 0x3FFC,
  32.   0x07C0, 0x1FF8,
  33.   0x0000, 0x07E0,
  34.   0x0000, 0x0000,
  35. };
  36.  
  37.  
  38. BOOL BlockWindow(struct Window *win, struct Requester *req) {
  39.   if (win != NULL && req != NULL) {
  40.     InitRequester(req);
  41.     if (Request(req, win)) {
  42.       if (IntuitionBase->LibNode.lib_Version >= 39L) {
  43.     SetWindowPointer(win, WA_BusyPointer, TRUE, TAG_DONE);
  44.       } else {
  45.     SetPointer(win, BUSY_POINTER, 16, 16, -6, 0);
  46.       }
  47.  
  48.       return TRUE;
  49.     }
  50.   }
  51.  
  52.   return FALSE;
  53. }
  54.  
  55.  
  56. VOID UnblockWindow(struct Window *win, struct Requester *req) {
  57.   if (IntuitionBase->LibNode.lib_Version >= 39L) {
  58.     SetWindowPointerA(win, NULL);
  59.   } else {
  60.     ClearPointer(win);
  61.   }
  62.   EndRequest(req, win);
  63. }
  64.  
  65.  
  66. LONG MessageRequesterA(struct Window *win, STRPTR title,
  67.                STRPTR textFmt, STRPTR gadFmt, APTR argList) {
  68.   struct EasyStruct es;
  69.   struct Window *reqWin;
  70.   struct Requester req;
  71.   BOOL blocking;
  72.   LONG retval;
  73.  
  74.   es.es_StructSize = sizeof es;
  75.   es.es_Flags = 0;
  76.   es.es_Title = title;
  77.   es.es_TextFormat = textFmt;
  78.   es.es_GadgetFormat = gadFmt;
  79.  
  80.   reqWin = BuildEasyRequestArgs(win, &es, NULL, argList);
  81.   if (win != NULL) {
  82.     blocking = BlockWindow(win, &req);
  83.   } else {
  84.     blocking = FALSE;
  85.   }
  86.   while ((retval = SysReqHandler(reqWin, NULL, TRUE)) == -2) {
  87.   }
  88.   if (blocking) {
  89.     UnblockWindow(win, &req);
  90.   }
  91.   FreeSysRequest(reqWin);
  92.  
  93.   return retval;
  94. }
  95.  
  96.  
  97. LONG MessageRequester(struct Window *win, STRPTR title,
  98.               STRPTR textFmt, STRPTR gadFmt, APTR arg, ...) {
  99.   return MessageRequesterA(win, title, textFmt, gadFmt, &arg);
  100. }
  101.