home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 4
/
FreshFish_May-June1994.bin
/
bbs
/
mar94
/
os20
/
util
/
mcalc.lha
/
MCalc
/
Source
/
MCalc.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-12-31
|
64KB
|
2,490 lines
/*
Auto: smake MCalc
*/
/* $Revision Header built automatically *************** (do not edit) ************
**
** © Copyright by GuntherSoft
**
** File : SnakeSYS:CPrgs/MUICalc/MCalc.c
** Created on : Saturday, 02.10.93 02:12:50
** Created by : Kai Iske
** Current revision : V1.0
**
**
** Purpose
** -------
** - This is a quite flexible, powerful Calculator made for all
** those of you, who like to calc around ;) Even for
** programmers...
**
** Revision V1.0
** --------------
** created on Saturday, 02.10.93 02:12:50 by Kai Iske. LogMessage :
** --- Initial release ---
**
*********************************************************************************/
/**********************************************************************/
/* Externals to Scanner/Parser */
/**********************************************************************/
extern UWORD PCharRead;
extern UWORD PColumn;
extern UWORD PError;
extern UWORD NonDouble;
extern int yynerrs;
extern int yychar;
extern int yy_init;
extern int yy_start;
extern FILE *yyin, *yyout;
extern void *yy_current_buffer;
extern UWORD RXIntType;
extern UWORD RXIntBase;
extern UWORD RXIntSign;
extern UWORD RXIntAngle;
/**********************************************************************/
/* Aehm, SAS 6.50 seams to open up a window just as it likes ;) */
/**********************************************************************/
char __stdiowin[] = "NIL:";
/**********************************************************************/
/* External variables of ARexx module */
/**********************************************************************/
extern struct MUI_Command RXCommands[];
/**********************************************************************/
/* Routines for that module */
/**********************************************************************/
static BOOL OpenLibs(void);
static void CloseLibs(void);
static void SetMainWinCycle(void);
static BOOL OpenMainWin(void);
static void CloseMainWin(void);
static ULONG __saveds __asm InsertFunc(register __a0 struct Hook *MyHook, register __a2 APTR Obj, register __a1 APTR *Data);
static ULONG __saveds __asm DispConstructFunc(register __a0 struct Hook *MyHook, register __a2 APTR MemPool, register __a1 struct ListStruct *Data);
static ULONG __saveds __asm DispDestructFunc(register __a0 struct Hook *MyHook, register __a2 APTR MemPool, register __a1 struct ListStruct *Data);
static ULONG __saveds __asm DispViewFunc(register __a0 struct Hook *MyHook, register __a2 char **array, register __a1 struct ListStruct *Data);
static void InsertText(char *NewText);
static void WriteClip(char *Entry);
static void HandleInputs(void);
/**********************************************************************/
/* Library-Bases */
/**********************************************************************/
extern struct ExecBase *SysBase;
struct IntuitionBase *IntuitionBase = NULL;
struct GfxBase *GfxBase = NULL;
struct Library *UtilityBase = NULL;
struct Library *IconBase = NULL;
struct Library *MUIMasterBase = NULL;
struct Library *MathIeeeDoubBasBase = NULL;
struct Library *MathIeeeDoubTransBase = NULL;
struct Library *IFFParseBase = NULL;
/**********************************************************************/
/* The Objects */
/**********************************************************************/
static struct DiskObject *DObject = NULL;
APTR AppObject = NULL; // Is referenced through ARexx module
static APTR MainWindow;
static APTR InOutGroup;
static APTR InputGroup;
APTR InputString; // Is referenced through ARexx module
static APTR OutputGroup;
APTR OutputBox; // Is referenced through ARexx module
static APTR FunctionCycle;
static APTR PageObject;
static APTR InGads[61];
static APTR ExeObj;
static APTR ClrObj;
static APTR AllClrObj;
static APTR MainGroup;
static APTR FuncGroup;
static APTR InGroup;
static APTR PrefsWindow;
static APTR InOutObj;
static APTR DFuncObj;
static APTR DInObj;
static APTR TypeObj;
static APTR SizeObj;
static APTR SignObj;
static APTR AngleObj;
static APTR LinesObj;
static APTR LookObj;
static APTR ClearInObj;
static APTR FlushObj;
static APTR ClipObj;
static APTR OkObj;
static APTR SaveObj;
static APTR CancelObj;
/**********************************************************************/
/* Strings for Functions Cycle-Gadget */
/**********************************************************************/
static const char *FunctionEntries[] =
{
"Mathematical set",
"Programmer`s set",
NULL
};
/**********************************************************************/
/* Strings for Prefs-Cycles */
/**********************************************************************/
static const char *InOutLookEntries[] =
{
"Input then Output",
"Output then Input",
NULL
};
static const char *TypeEntries[] =
{
"Decimal",
"HexDecimal",
"Octal",
"Binary",
NULL
};
static const char *SizeEntries[] =
{
"8-Bit",
"16-Bit",
"32-Bit",
NULL
};
static const char *SignEntries[] =
{
"Signed",
"Unsigned",
NULL
};
static const char *AngleEntries[] =
{
"Radiant",
"Degree",
NULL
};
static const char *LookEntries[] =
{
"Input & Output",
"Output & Input",
"Input",
"Output",
NULL
};
static const char *LookTemplates[] =
{
"COL=0 DELTA=12 P=\033r MAW=100 MIW=0, COL=1 DELTA=12 P=\033r MAW=-1 MIW=-1",
"COL=1 DELTA=12 P=\033r MAW=-1 MIW=-1, COL=0 DELTA=12 P=\033r MAW=100 MIW=0",
"COL=0 DELTA=12 P=\033r MIW=100",
"COL=1 DELTA=12 P=\033r MIW=100"
};
/**********************************************************************/
/* Chars/String for window title */
/**********************************************************************/
static const char TypeChar[] =
{
'D',
'H',
'O',
'B'
};
static const char *BaseStr[] =
{
"8",
"16",
"32"
};
static const char SignChar[] =
{
'S',
'U',
};
static const char *AngleStr[] =
{
"RAD",
"DEG",
};
/**********************************************************************/
/* Menu-Definition */
/**********************************************************************/
static struct NewMenu MainMenuDef[] =
{
NM_TITLE, "Project", NULL, 0, NULL, NULL,
NM_ITEM, "Preferences...", "P", 0, NULL, (APTR)ID_PREFS,
NM_ITEM, NM_BARLABEL, NULL, 0, NULL, NULL,
NM_ITEM, "About...", "?", 0, NULL, (APTR)ID_ABOUT,
NM_ITEM, NM_BARLABEL, NULL, 0, NULL, NULL,
NM_ITEM, "Quit", "Q", 0, NULL, (APTR)ID_QUIT,
NM_TITLE, "Edit", NULL, 0, NULL, NULL,
NM_ITEM, "Clear", "X", 0, NULL, (APTR)ID_CLEAR,
NM_ITEM, "All Clear", "Y", 0, NULL, (APTR)ID_ALLCLEAR,
NM_TITLE, "History", NULL, 0, NULL, NULL,
NM_ITEM, "Pick left entry", "L", 0, NULL, (APTR)ID_PICKLEFT,
NM_ITEM, "Pick right entry", "R", 0, NULL, (APTR)ID_PICKRIGHT,
NM_ITEM, NM_BARLABEL, NULL, 0, NULL, NULL,
NM_ITEM, "Copy left entry", "F", 0, NULL, (APTR)ID_CLIPCUTLEFT,
NM_ITEM, "Copy right entry", "G", 0, NULL, (APTR)ID_CLIPCUTRIGHT,
NM_TITLE, "Display Bases", NULL, 0, NULL, NULL,
NM_ITEM, "Decimal", "D", CHECKIT|MENUTOGGLE, 14, (APTR)ID_DECIMAL,
NM_ITEM, "Hexadecimal", "H", CHECKIT|MENUTOGGLE, 13, (APTR)ID_HEXDECIMAL,
NM_ITEM, "Octal", "O", CHECKIT|MENUTOGGLE, 11, (APTR)ID_OCTAL,
NM_ITEM, "Binary", "B", CHECKIT|MENUTOGGLE, 7, (APTR)ID_BINARY,
NM_TITLE, "Size", NULL, 0, NULL, NULL,
NM_ITEM, "8 Bit", "8", CHECKIT|MENUTOGGLE, 6, (APTR)ID_8BIT,
NM_ITEM, "16 Bit", "16", CHECKIT|MENUTOGGLE, 5, (APTR)ID_16BIT,
NM_ITEM, "32 Bit", "32", CHECKIT|MENUTOGGLE, 3, (APTR)ID_32BIT,
NM_TITLE, "Sign", NULL, 0, NULL, NULL,
NM_ITEM, "Signed", "S", CHECKIT|MENUTOGGLE, 2, (APTR)ID_SIGNED,
NM_ITEM, "Unsigned", "U", CHECKIT|MENUTOGGLE, 1, (APTR)ID_UNSIGNED,
NM_TITLE, "Angle", NULL, 0, NULL, NULL,
NM_ITEM, "Radiant", "A", CHECKIT|MENUTOGGLE, 2, (APTR)ID_RAD,
NM_ITEM, "Degree", "E", CH