home *** CD-ROM | disk | FTP | other *** search
/ World of A1200 / World_Of_A1200.iso / programs / disk / misc / tracked / source.lha / sources / ST2.c < prev    next >
C/C++ Source or Header  |  1993-07-16  |  2KB  |  77 lines

  1.  
  2. /* ST2.c  custom message window, OS2.0 only */
  3.  
  4. #include <exec/memory.h>
  5. #include <intuition/intuition.h>
  6. #include <libraries/gadtools.h>
  7. #include <clib/intuition_protos.h>
  8. #include <clib/gadtools_protos.h>
  9.  
  10. extern struct TextAttr Style;
  11. extern APTR My_VisualInfo;
  12.  
  13. struct Requester *BlockInput();
  14. void UnBlockInput();
  15.  
  16. struct IntuiText
  17. ST2Text2 = {  1, 0, JAM2, 0, 32, &Style, NULL, NULL  },
  18. ST2Text  = {  1, 0, JAM2, 0, 22, &Style, NULL, &ST2Text2  };
  19.  
  20. #define ST2_OK 61
  21.  
  22. struct NewGadget ST2_OKNG =
  23. {  46, 52, 108, 12, NULL, &Style, ST2_OK, 0, NULL, NULL  };
  24.  
  25. void ShowText2(window, text, text2, buttontext)
  26. struct Window *window;
  27. UBYTE *text, *text2, *buttontext;
  28. {
  29.    struct IntuiMessage *imsg;
  30.    struct Requester *BI;
  31.    struct Window *STWindow;
  32.    struct Gadget *gad, *glist;
  33.    ULONG MW;
  34.    int i;
  35.  
  36.    BI = BlockInput(window);
  37.  
  38.    if (buttontext) ST2_OKNG.ng_GadgetText = buttontext;
  39.    else ST2_OKNG.ng_GadgetText = "  OK  ";
  40.    ST2Text.IText = text;
  41.    ST2Text2.IText = text2;
  42.  
  43.    for (i = 0; ST2_OKNG.ng_GadgetText[i] != 0; i++);
  44.    MW = 8*i;
  45.    ST2_OKNG.ng_Width = (UWORD) MW+12;
  46.    if (IntuiTextLength(&ST2Text2) > MW) MW = IntuiTextLength(&ST2Text2);
  47.    if (IntuiTextLength(&ST2Text) > MW) MW = IntuiTextLength(&ST2Text);
  48.    MW += 32;
  49.    ST2Text.LeftEdge = (UWORD) (MW - IntuiTextLength(&ST2Text)) / 2;
  50.    ST2Text2.LeftEdge = (UWORD) (MW - IntuiTextLength(&ST2Text2)) / 2;
  51.  
  52.    ST2_OKNG.ng_VisualInfo = My_VisualInfo;
  53.    ST2_OKNG.ng_LeftEdge = (UWORD) (MW - ST2_OKNG.ng_Width) / 2;
  54.    gad = CreateContext(&glist);
  55.    gad = CreateGadget(BUTTON_KIND, gad, &ST2_OKNG, TAG_END);
  56.  
  57.    STWindow = OpenWindowTags(NULL, WA_Title,     "Message",
  58.       WA_Gadgets,   glist,      WA_AutoAdjust,    TRUE,
  59.       WA_Top,          40,      WA_Left,           180,
  60.       WA_Width,        MW,      WA_InnerHeight,     60,
  61.       WA_DragBar,    TRUE,      WA_DepthGadget,   TRUE,
  62.       WA_Activate,   TRUE,
  63.       WA_IDCMP, BUTTONIDCMP,    TAG_END);
  64.  
  65.    PrintIText(STWindow->RPort, &ST2Text, 0L, 0L);
  66.  
  67.    if (!(imsg = GT_GetIMsg(STWindow->UserPort)))
  68.    {
  69.       Wait(1L << STWindow->UserPort->mp_SigBit);
  70.    }
  71.    GT_ReplyIMsg(imsg);
  72.    CloseWindow(STWindow);
  73.    FreeGadgets(glist);
  74.  
  75.    UnBlockInput(BI, window);
  76. }
  77.