home *** CD-ROM | disk | FTP | other *** search
- /*
- ** $Id: termInfo.c,v 1.3 92/04/07 20:14:19 olsen Sta Locker: olsen $
- ** $Revision: 1.3 $
- ** $Date: 92/04/07 20:14:19 $
- **
- ** Support routines for the `About' requester
- **
- ** Copyright ⌐ 1990-1992 by Olaf `Olsen' Barthel & MXM
- ** All Rights Reserved
- */
-
- #include "termGlobal.h"
-
- /* The `term' logo. */
-
- STATIC UWORD __chip InfoBits[144] =
- {
- 0x07C0,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x07C0,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x07C0,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0x07C0,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,0x0000,
- 0xFFFF,0x8003,0xFF00,0x03C0,0xF001,0xF0FE,0x01FE,0x0000,
- 0xFFFF,0x801F,0xFFC0,0x03CF,0xF001,0xF7FF,0xCFFF,0x8000,
- 0x07C0,0x003E,0x01F0,0x03DF,0x0001,0xFE07,0xFC0F,0xC000,
- 0x07C0,0x0078,0x00F0,0x03F8,0x0001,0xF803,0xF003,0xE000,
- 0x07C0,0x00F0,0x0078,0x03F0,0x0001,0xF001,0xF003,0xE000,
- 0x07C0,0x01FF,0xFFF8,0x03E0,0x0001,0xF001,0xE003,0xE000,
- 0x07C0,0x01FF,0xFFF8,0x03E0,0x0001,0xF001,0xE003,0xE000,
- 0x07C0,0x01F0,0x0000,0x03E0,0x0001,0xF001,0xE003,0xE000,
- 0x07C0,0x00F0,0x0000,0x03E0,0x0001,0xF001,0xE003,0xE000,
- 0x07C0,0x00F8,0x0000,0x03E0,0x0001,0xF001,0xE003,0xE000,
- 0x07C0,0x007C,0x0000,0x03E0,0x0001,0xF001,0xE003,0xE000,
- 0x03E1,0xC03F,0x80F8,0x03E0,0x0001,0xF001,0xE003,0xE000,
- 0x03FF,0xC00F,0xFFF0,0x03E0,0x0001,0xF001,0xE003,0xE000,
- 0x00FE,0x0000,0xFF00,0x03E0,0x0001,0xF001,0xE003,0xE000
- };
-
- /* A dummy image structure. */
-
- STATIC struct Image InfoImage =
- {
- 0,0,
- 115,18,1,
- (UWORD *)&InfoBits[0],
- 0x03,0x00,
- (struct Image *)NULL
- };
-
- /* The real render info. */
-
- struct BitMap InfoBitMap;
-
- /* Height offset for the info window. */
-
- #define HEIGHT (((17 + 3) << 3) + 2)
-
- /* ShowInfo():
- *
- * Open a window, draw the `term' logo, show some text
- * and wait for user reaction (believe it or not, this took
- * me two hours to program!).
- */
-
- BYTE
- ShowInfo(BYTE Ticks)
- {
- struct Window *InfoWindow;
- LONG i,Length,MaxWidth,Offset = (Ticks ? 0 : 16);
- BYTE GotRexxMessage = FALSE;
-
- /* Find the longest string. */
-
- for(i = MaxWidth = 0 ; i < 17 ; i++)
- {
- if((Length = strlen(LocaleString(MSG_TERMINFO_INFOTEXT1_TXT + i))) > MaxWidth)
- MaxWidth = Length;
- }
-
- MaxWidth = (MaxWidth << 3) + 10;
-
- /* Open the window. */
-
- if(InfoWindow = OpenWindowTags(NULL,
- WA_Left, (Screen -> Width - MaxWidth) >> 1,
- WA_Top, (Screen -> Height - (HEIGHT + InfoImage . Height + 1 + Offset)) >> 1,
- WA_InnerWidth, MaxWidth,
- WA_InnerHeight, HEIGHT + InfoImage . Height + Offset,
- WA_IDCMP, IDCMP_VANILLAKEY | IDCMP_RAWKEY | IDCMP_MOUSEMOVE | IDCMP_MOUSEBUTTONS | IDCMP_INTUITICKS | IDCMP_INACTIVEWINDOW | BUTTONIDCMP,
- WA_ReportMouse, TRUE,
- WA_Activate, TRUE,
- WA_RMBTrap, TRUE,
- WA_SmartRefresh, TRUE,
- WA_GimmeZeroZero, TRUE,
- WA_CustomScreen, Screen,
- TAG_DONE))
- {
- struct Gadget *GadgetList = NULL,
- *Gadget = NULL;
-
- if(Ticks)
- goto Skip;
-
- if(Gadget = CreateContext(&GadgetList))
- {
- struct NewGadget NewGadget;
-
- memset(&NewGadget,0,sizeof(struct NewGadget));
-
- NewGadget . ng_Width = 120;
- NewGadget . ng_Height = 16;
- NewGadget . ng_GadgetText = LocaleString(MSG_TERMINFO_CONTINUE_TXT);
- NewGadget . ng_TextAttr = &DefaultFont;
- NewGadget . ng_VisualInfo = VisualInfo;
- NewGadget . ng_GadgetID = 0;
- NewGadget . ng_Flags = NULL;
- NewGadget . ng_LeftEdge = (InfoWindow -> Width - NewGadget . ng_Width) >> 1;
- NewGadget . ng_TopEdge = InfoWindow -> Height - (NewGadget . ng_Height + 8);
-
- Gadget = CreateGadget(BUTTON_KIND,Gadget,&NewGadget,
- GT_Underscore, '_',
- TAG_DONE);
-
- Skip: if(Gadget || Ticks)
- {
- struct RastPort *IPort;
- LONG Left,Top;
-
- struct IntuiMessage *Massage;
- BYTE Terminated = FALSE;
-
- BYTE FgPen,BgPen;
- LONG TickCount = 0;
- ULONG SignalSet;
-
- UBYTE TheKey,
- *Button;
-
- Button = LocaleString(MSG_TERMINFO_CONTINUE_TXT);
-
- while(*Button)
- {
- if(*Button++ == '_')
- {
- TheKey = ToUpper(*Button);
-
- break;
- }
- }
-
- if(Gadget)
- {
- AddGList(InfoWindow,GadgetList,(UWORD)-1,(UWORD)-1,NULL);
- RefreshGList(GadgetList,InfoWindow,NULL,(UWORD)-1);
- GT_RefreshWindow(InfoWindow,NULL);
- }
-
- /* Adapt the rendering pens accordingly. */
-
- switch(Config . ColourMode)
- {
- case COLOUR_EIGHT: FgPen = 7;
- BgPen = 4;
-
- break;
-
- case COLOUR_SIXTEEN: FgPen = 15;
- BgPen = 8;
-
- break;
-
- case COLOUR_AMIGA: BgPen = 1;
- FgPen = 2;
-
- break;
-
- case COLOUR_MONO: BgPen = 1;
- FgPen = 1;
-
- break;
- }
-
- if(Config . DisableBlinking & TERMINAL_FASTER)
- {
- if(FgPen == 2)
- FgPen = 1;
-
- BgPen = FgPen;
- }
-
- /* Just a shortcut. */
-
- IPort = InfoWindow -> RPort;
-
- /* Set up rendering modes. */
-
- SetDrMd(IPort,JAM1);
- SetFont(IPort,Topaz);
-
- /* Set up the logo. */
-
- InitBitMap(&InfoBitMap,IPort -> BitMap -> Depth,115,18);
-
- for(i = 0 ; i < IPort -> BitMap -> Depth ; i++)
- InfoBitMap . Planes[i] = (PLANEPTR)&InfoBits[0];
-
- if(FgPen != BgPen)
- {
- /* Draw the logo shadow. */
-
- SetWrMsk(IPort,BgPen);
- BltBitMapRastPort(&InfoBitMap,0,0,IPort,((InfoWindow -> GZZWidth - InfoImage . Width) >> 1) + 2,8 + 1,InfoImage . Width,InfoImage . Height,0xC0);
-
- /* Clear out the bright part. */
-
- SetWrMsk(IPort,~0);
- BltBitMapRastPort(&InfoBitMap,0,0,IPort,((InfoWindow -> GZZWidth - InfoImage . Width) >> 1),8,InfoImage . Width,InfoImage . Height,0x20);
- }
-
- /* Add the bright part. */
-
- SetWrMsk(IPort,FgPen);
- BltBitMapRastPort(&InfoBitMap,0,0,IPort,((InfoWindow -> GZZWidth - InfoImage . Width) >> 1),8,InfoImage . Width,InfoImage . Height,0xE0);
-
- /* Return to normal rendering. */
-
- SetWrMsk(IPort,~0);
-
- /* Determine first line. */
-
- Top = (InfoWindow -> GZZHeight - HEIGHT - Offset) + Topaz -> tf_Baseline - 1 + InfoImage . Height;
-
- /* Walk down the text list. */
-
- for(i = 0 ; i < 17 ; i++)
- {
- /* Can we print this line? */
-
- if(Length = strlen(LocaleString(MSG_TERMINFO_INFOTEXT1_TXT + i)))
- {
- /* Centre it. */
-
- Left = (InfoWindow -> GZZWidth - (Length << 3)) >> 1;
-
- /* Draw the shadow. */
-
- if(FgPen != BgPen)
- {
- SetAPen(IPort,BgPen);
- Move(IPort,Left + 2,Top + 1);
- Text(IPort,LocaleString(MSG_TERMINFO_INFOTEXT1_TXT + i),Length);
- }
-
- /* Draw the bright part. */
-
- SetAPen(IPort,FgPen);
- Move(IPort,Left,Top);
- Text(IPort,LocaleString(MSG_TERMINFO_INFOTEXT1_TXT + i),Length);
- }
-
- /* Jump to next line. */
-
- Top += Topaz -> tf_YSize;
- }
-
- /* Ignore any previously received input. */
-
- while(Massage = (struct IntuiMessage *)GetMsg(InfoWindow -> UserPort))
- ReplyMsg(Massage);
-
- if(Ticks)
- Say(LocaleString(MSG_TERMINFO_WELCOME_TO_TERM_TXT));
-
- ActivateWindow(InfoWindow);
-
- /* Wait for mouse/key event. */
-
- while(!Terminated)
- {
- SignalSet = Wait(SIG_REXX | (1 << InfoWindow -> UserPort -> mp_SigBit));
-
- if(Ticks)
- {
- if(SignalSet & SIG_REXX)
- {
- GotRexxMessage = TRUE;
- Terminated = TRUE;
- }
- }
-
- while(Massage = (struct IntuiMessage *)GetMsg(InfoWindow -> UserPort))
- {
- if(Ticks)
- {
- if(Massage -> Class == IDCMP_INTUITICKS)
- {
- if(TickCount++ == 50)
- Terminated = TRUE;
- }
- else
- Terminated = TRUE;
- }
- else
- {
- if((Massage -> Class == IDCMP_VANILLAKEY && ToUpper(Massage -> Code) == TheKey) || Massage -> Class == IDCMP_GADGETUP)
- Terminated = TRUE;
- }
-
- ReplyMsg(Massage);
- }
- }
-
- if(Gadget)
- RemoveGList(InfoWindow,GadgetList,(UWORD)-1);
- }
- }
-
- FreeGadgets(GadgetList);
-
- /* Close the window and exit. */
-
- CloseWindow(InfoWindow);
- }
-
- return(GotRexxMessage);
- }
-