home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
17 Bit Software 1: Collection A
/
17Bit_Collection_A.iso
/
files
/
223.dms
/
223.adf
/
Source
/
starhlp.c
< prev
next >
Wrap
C/C++ Source or Header
|
1988-07-25
|
12KB
|
454 lines
/*=========================================================================
Starhlp.c -- This module handles all help requests for the starchart
program.
Credits for Star Chart:
Robert L. Hill of the Orange County, CA. Amiga Friends User Group
wrote the original version of StarChart in AmigaBasic
The star data and many of the main functions of this
version are derived from that program.
Ray R. Larson wrote the c version 1.0 of StarChart, 'intuitionizing'
and enhancing the speed and functions of the original.
Copyright (c) 1986 by Ray R. Larson
This program may be freely distributed and copied, but may not be sold
without the permission of the author. If you modify or enhance it,
please include the above credits (and please send me a copy!).
Ray R. Larson
6425 Central Ave. #304
El Cerrito, CA 94530
BitNet LARSON@UCBCMSA
=========================================================================*/
/*------------Header file for all of the standard stuff----*/
/*-------------plus definitions of global structures-------*/
#include "star.h"
#include <clib/macros.h>
/* macros for checking userport and timerport bits */
#define USERBIT 1L << hlpwin->UserPort->mp_SigBit
#define TIMERBIT 1L << timerport->mp_SigBit
extern struct MsgPort *timerport; /* for timing signals */
extern struct timerequest timermsg;
/* symbolic gadget names */
#define UPGADGET 1
#define DOWNGADGET 2
#define POTGADGET 3
extern struct Window *w, *OpenWindow();
extern struct IntuiMessage *GetMsg();
/***************************************************************
* All of the text and gadgets needed for the HELP window follow.
**************************************************************/
/***********************************************
* The Scroll Selection List up (arrow) gadget *
**********************************************/
UWORD UpArrowData[15] = {
0xfffc,
0xfcfc,
0xf87c,
0xf03c,
0xe01c,
0xc00c,
0x8004,
0xfcfc,
0xfcfc,
0xfcfc,
0xfcfc,
0xfcfc,
0xfcfc,
0xfffc
};
struct Image UpArrow =
{
0,0,
14,
14,
1,
&UpArrowData[0],
0x1, 0x0,
NULL
};
struct Gadget UpGadget =
{ /* Up a line gadget */
NULL, /* next gadget */
626,10, /* location */
12,14,
GADGIMAGE|GADGHNONE, /* flags */
GADGIMMEDIATE, /* activation */
BOOLGADGET|REQGADGET, /* type */
(APTR) &UpArrow, /* rendering */
NULL, /* rendering */
NULL, /* text */
0, /* mutual exlcude */
NULL, /* string info */
UPGADGET, /* gadget id */
NULL /* special info*/
};
/*************************************************
* The Scroll Selection List down (arrow) gadget *
************************************************/
UWORD DownArrowData[15] = {
0xfffc,
0xfcfc,
0xfcfc,
0xfcfc,
0xfcfc,
0xfcfc,
0xfcfc,
0x8004,
0xc00c,
0xe01c,
0xf03c,
0xf87c,
0xfcfc,
0xfffc
};
struct Image DownArrow =
{
0,0,
14,
14,
1,
&DownArrowData[0],
0x1, 0x0,
NULL
};
struct Gadget DownGadget =
{ /* Down a line gadget */
&UpGadget, /* next gadget */
626,185, /* location */
12,14,
GADGIMAGE|GADGHNONE, /* flags */
GADGIMMEDIATE, /* activation */
BOOLGADGET|REQGADGET, /* type */
(APTR) &DownArrow, /* rendering */
NULL, /* rendering */
NULL, /* text */
0, /* mutual exlcude */
NULL, /* string info */
DOWNGADGET, /* gadget id */
NULL /* special info*/
};
/***************************************************
* The Scroll Selection list up down Potentiometer *
**************************************************/
struct PropInfo KnobInfo =
{
AUTOKNOB | FREEVERT | PROPBORDERLESS,
0,
0, /* VertPot */
0,
0x7fff, /* VertBody */
0,0,0,0,0,0
};
struct Image KnobImage =
{
0,0,
0,0,0,
NULL,
0,0,
NULL
};
struct Gadget scroll_control =
{ /* Potentiometer line gadget */
&DownGadget, /* next gadget */
626,24, /* location */
14,161,
GADGHNONE, /* flags */
RELVERIFY, /* activation */
PROPGADGET|REQGADGET, /* type */
(APTR) &KnobImage, /* rendering */
NULL, /* rendering */
NULL, /* text */
0, /* mutual exlcude */
(APTR)&KnobInfo, /* string info */
POTGADGET, /* gadget id */
NULL /* special info*/
};
extern struct Screen *scr;
struct NewWindow helpwind =
{ 0,0, /* Left and Top edges */
640,200, /* Width and Height */
0,1, /* DetailPen and BlockPen colors */
GADGETUP | GADGETDOWN
| CLOSEWINDOW,/* IDCMPFlags for the window*/
/* Flags for the window */
WINDOWCLOSE | ACTIVATE,
&scroll_control,/* First gadget in list */
NULL, /* Checkmark - use the default check */
NULL, /* Title -set later */
NULL, /* Screen - set after screen is opened */
NULL, /* No Custom bitmap here either */
640, /* MinWidth, MinHeight, MaxW & MaxH */
200, /* no window sizing so these should be ignored */
6400,
200,
CUSTOMSCREEN, /* sure is */
};
/**************************************************************************
* Help data is located in starhlpdat.c, it is stored as a set of *char[]
* initialized structures;
*************************************************************************/
/* ABOUT STARCHART help */
extern SHORT abouthelplines;
extern char *abouthelptext[];
/* project menu help */
extern SHORT projhelplines;
extern char *projhelptext[];
/* parameters menu help */
extern SHORT parmhelplines;
extern char *parmhelptext[];
/* options menu help */
extern SHORT opthelplines;
extern char *opthelptext[];
/* constellations menu help */
extern SHORT conshelplines;
extern char *conshelptext[];
#define PROJECT 0L
#define PARMS 1L
#define OPTIONS 2L
#define ABOUTHELP 4L
#define CONHELP 7L
do_help_req(HelpNum)
LONG HelpNum;
{
struct Window *hlpwin;
struct Gadget *curgadget;
struct IntuiMessage *msg;
BOOL result, finished, timeout=FALSE;
SHORT i, j, topline, code, nlines;
ULONG class, vpot, vbody, flags, linesize;
char **text;
switch (HelpNum)
{
case PROJECT:
helpwind.Title = (UBYTE *)"StarChart Help for Project Menu";
nlines = projhelplines;
text = &projhelptext[0];
break;
case PARMS:
helpwind.Title = (UBYTE *)"StarChart Help for Parameters Menu";
nlines = parmhelplines;
text = &parmhelptext[0];
break;
case OPTIONS:
helpwind.Title = (UBYTE *)"StarChart Help for Options Menu";
nlines = opthelplines;
text = &opthelptext[0];
break;
case ABOUTHELP:
helpwind.Title = (UBYTE *)"About StarChart and how to use it.";
nlines = abouthelplines;
text = &abouthelptext[0];
break;
case CONHELP:
helpwind.Title = (UBYTE *)"StarChart Help for Constellations Menus";
nlines = conshelplines;
text = &conshelptext[0];
break;
}
/* set the proportional gadget body size */
flags = FREEVERT | AUTOKNOB;
KnobInfo.Flags = FREEVERT | AUTOKNOB;
vbody = (ULONG)(0xFFFF / (nlines/16));
KnobInfo.VertBody = (USHORT)vbody;
linesize = vbody / 16L;
KnobInfo.HorizBody= 0;
KnobInfo.VertPot = 0;
topline = 0;
helpwind.Screen = scr;
if((hlpwin = OpenWindow(&helpwind)) == NULL)
{ puts("Can't open the help window!!\n");
return(FALSE);
}
finished = FALSE;
PrintPage(hlpwin,text,0,nlines);
while (!finished)
{
if ((msg = GetMsg(hlpwin->UserPort)) == NULL)
{
Wait((USERBIT));
continue;
}
if (msg == NULL) continue;
class = msg->Class;
code = msg->Code;
curgadget = (struct Gadget *)msg->IAddress;
ReplyMsg(msg);
switch (class) {
case CLOSEWINDOW: finished = TRUE; break;
case GADGETUP:
if (curgadget->GadgetID == POTGADGET)
{
if(KnobInfo.VertPot == 0xFFFF)
topline = nlines - 17;
else topline = (KnobInfo.VertPot / linesize) - 3;
if (topline < 0) topline = 0;
if ((topline+17) >= nlines)
topline = nlines-17;
}
PrintPage(hlpwin,text,topline,nlines);
break;
case GADGETDOWN:
switch (curgadget->GadgetID)
{
case UPGADGET:
topline--;
if (topline <= 0)
{ topline = 0;
break;
}
vpot = KnobInfo.VertPot - linesize;
if (vpot < 0) vpot = 0;
PrintPage(hlpwin,text,topline,nlines);
ModifyProp(&scroll_control,hlpwin,NULL,
flags,0L,vpot,0L,vbody);
break;
case DOWNGADGET:
topline++;
if (topline >= nlines-17)
{ topline = nlines-17;
break;
}
vpot = KnobInfo.VertPot + linesize;
if (vpot > 0xFFFF) vpot = 0xFFFF;
PrintPage(hlpwin,text,topline,nlines);
ModifyProp(&scroll_control,hlpwin,NULL,
flags,0L,vpot,0L,vbody);
break;
} /* end of gadget switch */
break;
} /* end of class switch */
} /* end while-not finished main loop */
CloseWindow(hlpwin);
return(TRUE);
} /* end of do_help_req */
/*********** print out the next set of lines ********/
PrintPage(win,text,topline, maxline)
struct Window *win;
char *text[];
SHORT topline,maxline;
{
SHORT i, j;
/* clear the screen */
SetAPen(win->RPort,0L);
RectFill(win->RPort,2L,11L,625L,188L);
/* put out some text */
SetAPen(win->RPort,1L);
for (i = topline, j = 0;j < 19 && i < maxline; j++, i++)
{
Move(win->RPort,5L,(LONG)((j*9)+20));
Text(win->RPort,text[i],(LONG)strlen(text[i]));
}
} /* end of PrintPage */
PrintHelp(filename)
UBYTE *filename;
{
FILE *outfile, *fopen();
ULONG saveflags;
SHORT i;
outfile = fopen(filename,"w");
if (outfile == NULL) return(-1);
do_Snooze(w); /* put up a sleepy cloud pointer */
saveflags = w->IDCMPFlags;
ModifyIDCMP(w,0L); /* block intuition messages */
/* ABOUT STARCHART help */
for(i=0; i<abouthelplines; i++)
fprintf(outfile,"%s\n",abouthelptext[i]);
fprintf(outfile,"\n\n\n");
/* project menu help */
for(i=0; i<projhelplines; i++)
fprintf(outfile,"%s\n",projhelptext[i]);
fprintf(outfile,"\n\n\n");
/* parameters menu help */
for(i=0; i<parmhelplines; i++)
fprintf(outfile,"%s\n",parmhelptext[i]);
fprintf(outfile,"\n\n\n");
/* options menu help */
for(i=0; i<opthelplines; i++)
fprintf(outfile,"%s\n",opthelptext[i]);
fprintf(outfile,"\n\n\n");
/* constellations menu help */
for(i=0; i<conshelplines; i++)
fprintf(outfile,"%s\n",conshelptext[i]);
fprintf(outfile,"\n\n\n");
fclose(outfile);
ModifyIDCMP(w,saveflags); /* restore intuition messages */
do_StarSprite(w); /* put back the star pointer */
return(0);
}