home *** CD-ROM | disk | FTP | other *** search
- /*
- ** $Id: termInfo.c,v 1.6 92/08/15 20:14:26 olsen Sta Locker: olsen $
- ** $Revision: 1.6 $
- ** $Date: 92/08/15 20:14:26 $
- **
- ** Support routines for the `About' requester
- **
- ** Copyright ⌐ 1990-1992 by Olaf `Olsen' Barthel & MXM
- ** All Rights Reserved
- */
-
- #include "termGlobal.h"
-
- /* 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;
- struct DiskObject *Icon = NULL;
- LONG Height,
- Width;
- struct Image *Image;
-
- SZ_SizeSetup(Screen,&UserFont,TRUE);
-
- if(IconBase = OpenLibrary("icon.library",0))
- {
- if(WBenchMsg)
- {
- if(WBenchMsg -> sm_ArgList)
- {
- if(WBenchMsg -> sm_ArgList -> wa_Name)
- Icon = GetDiskObjectNew(WBenchMsg -> sm_ArgList -> wa_Name);
- }
- }
-
- if(!Icon)
- Icon = GetDiskObjectNew("term");
-
- if(Icon)
- {
- if(Icon -> do_Type != WBTOOL)
- {
- FreeDiskObject(Icon);
-
- Icon = NULL;
- }
- }
- }
-
- Offset = Screen -> WBorTop + INTERHEIGHT;
-
- Height = Screen -> WBorTop + INTERHEIGHT + 17 * (UserFontHeight + 1) + INTERHEIGHT + Screen -> WBorBottom;
-
- if(!Ticks)
- Height += SZ_Height(BUTTON_KIND,0,0) + INTERHEIGHT;
-
- if(Icon)
- {
- Image = Icon -> do_Gadget . GadgetRender;
-
- if(Image -> TopEdge + Image -> Height + INTERHEIGHT + Height > Screen -> Height)
- {
- FreeDiskObject(Icon);
-
- Icon = NULL;
- }
- else
- {
- Offset += Image -> TopEdge + Image -> Height + INTERHEIGHT;
-
- Height += Image -> TopEdge + Image -> Height + INTERHEIGHT;
- }
- }
-
- /* Find the longest string. */
-
- for(i = MaxWidth = 0 ; i < 17 ; i++)
- {
- if((Length = SZ_TextWidth(LocaleString(MSG_TERMINFO_INFOTEXT1_TXT + i))) > MaxWidth)
- MaxWidth = Length;
- }
-
- if(Icon)
- {
- if(Image -> LeftEdge + Image -> Width > MaxWidth)
- MaxWidth = Image -> LeftEdge + Image -> Width;
- }
-
- Width = Screen -> WBorLeft + INTERWIDTH + MaxWidth + INTERWIDTH + Screen -> WBorRight;
-
- /* Open the window. */
-
- if(InfoWindow = OpenWindowTags(NULL,
- WA_Left, (Width < Screen -> Width) ? (Screen -> Width - Width) / 2 : 0,
- WA_Top, (Height < Screen -> Height) ? (Screen -> Height - Height) / 2 : 0,
- WA_Width, Width,
- WA_Height, Height,
- 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;
- WORD Len;
-
- memset(&NewGadget,0,sizeof(struct NewGadget));
-
- NewGadget . ng_Width = SZ_Width(BUTTON_KIND,LocaleString(MSG_TERMINFO_CONTINUE_TXT),0,NULL);
- NewGadget . ng_Height = SZ_Height(BUTTON_KIND,0,0);
- NewGadget . ng_GadgetText = LocaleString(MSG_TERMINFO_CONTINUE_TXT);
- NewGadget . ng_TextAttr = &UserFont;
- NewGadget . ng_VisualInfo = VisualInfo;
- NewGadget . ng_GadgetID = 0;
- NewGadget . ng_Flags = NULL;
- NewGadget . ng_LeftEdge = (InfoWindow -> Width - NewGadget . ng_Width) / 2;
- NewGadget . ng_TopEdge = InfoWindow -> Height - (Screen -> WBorBottom + INTERHEIGHT + NewGadget . ng_Height);
-
- 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;
-
- SetFont(InfoWindow -> RPort,UserTextFont);
-
- 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);
-
- /* Draw the icon if any. */
-
- if(Icon)
- DrawImage(IPort,Image,(InfoWindow -> Width - (Image -> Width + Image -> LeftEdge)) / 2,Screen -> WBorTop + INTERHEIGHT);
-
- /* Determine first line. */
-
- Top = Offset + UserFontBase;
-
- /* Walk down the text list. */
-
- for(i = 0 ; i < 17 ; i++)
- {
- /* Can we print this line? */
-
- if(Len = strlen(LocaleString(MSG_TERMINFO_INFOTEXT1_TXT + i)))
- {
- Length = SZ_TextWidth(LocaleString(MSG_TERMINFO_INFOTEXT1_TXT + i));
-
- /* Centre it. */
-
- Left = (InfoWindow -> GZZWidth - Length) / 2;
-
- /* Draw the shadow. */
-
- if(FgPen != BgPen)
- {
- SetAPen(IPort,BgPen);
- Move(IPort,Left + 1,Top + 1);
- Text(IPort,LocaleString(MSG_TERMINFO_INFOTEXT1_TXT + i),Len);
- }
-
- /* Draw the bright part. */
-
- SetAPen(IPort,FgPen);
- Move(IPort,Left,Top);
- Text(IPort,LocaleString(MSG_TERMINFO_INFOTEXT1_TXT + i),Len);
- }
-
- /* Jump to next line. */
-
- Top += UserFontHeight + 1;
- }
-
- /* 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);
- }
-
- if(Icon)
- FreeDiskObject(Icon);
-
- if(IconBase)
- CloseLibrary(IconBase);
-
- return(GotRexxMessage);
- }
-