home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Fresh Fish 10
/
Fresh_Fish_10_2352.bin
/
fishdisks
/
d1001.lha
/
Programs
/
AmigaGuide
/
AG_V39
/
Source
/
advaghelp.c
< prev
next >
Wrap
C/C++ Source or Header
|
1993-01-08
|
19KB
|
742 lines
/* aghelp.c
*
* (c) Copyright 1992 Commodore-Amiga, Inc. All rights reserved.
*
* This software is provided as-is and is subject to change; no warranties
* are made. All use is at your own risk. No liability or responsibility
* is assumed.
*
*/
#include <exec/types.h>
#include <exec/memory.h>
#include <exec/execbase.h>
#include <exec/libraries.h>
#include <intuition/screens.h>
#include <intuition/intuition.h>
#include <graphics/gfx.h>
#include <graphics/text.h>
#include <libraries/amigaguide.h>
#include <libraries/gadtools.h>
#include <utility/hooks.h>
#include <utility/tagitem.h>
#include <string.h>
#include <stdio.h>
#include <clib/alib_protos.h>
#include <clib/amigaguide_protos.h>
#include <clib/dos_protos.h>
#include <clib/exec_protos.h>
#include <clib/gadtools_protos.h>
#include <clib/graphics_protos.h>
#include <clib/intuition_protos.h>
#include <clib/utility_protos.h>
#include <pragmas/amigaguide_pragmas.h>
#include <pragmas/dos_pragmas.h>
#include <pragmas/exec_pragmas.h>
#include <pragmas/gadtools_pragmas.h>
#include <pragmas/graphics_pragmas.h>
#include <pragmas/intuition_pragmas.h>
#include <pragmas/utility_pragmas.h>
/*****************************************************************************/
#define DB(x) x
/*****************************************************************************/
void kprintf (void *, ...);
/*****************************************************************************/
#define BASENAME "ADVAGHELP"
#define BASENAME_LENGTH 9
/*****************************************************************************/
#define ASM __asm __saveds
#define REG(x) register __ ## x
/*****************************************************************************/
struct AppInfo
{
struct Process *ai_Process; /* Our process address */
struct Screen *ai_Screen; /* Screen that our application will open on */
APTR ai_VI; /* GadTools visual info */
struct Window *ai_Window; /* Window pointer */
struct Menu *ai_Menu; /* Menus */
/* Gadgets that we want to set attributes on */
struct Gadget *ai_GStatus; /* Status window */
/* Help related information */
LONG ai_NHID; /* Unique id */
ULONG ai_NHFlags; /* Help related flags */
UBYTE ai_NHName[64]; /* Unique name */
struct Hook ai_NHHook; /* Dynamic node host hook */
struct AmigaGuideHost *ai_NH; /* Dynamic node host */
AMIGAGUIDECONTEXT ai_AmigaGuide; /* Pointer to the AmigaGuide context */
struct NewAmigaGuide ai_NAG; /* Used to start AmigaGuide */
LONG ai_Region; /* Region that the mouse if over */
/* Control information */
BOOL ai_Done; /* Done yet? */
};
#define AGHF_CONTINUOUS (1L<<0)
/*****************************************************************************/
extern struct Library *SysBase;
extern struct Library *DOSBase;
struct Library *AmigaGuideBase;
struct Library *GadToolsBase;
struct Library *GfxBase;
struct Library *IntuitionBase;
struct Library *UtilityBase;
/*****************************************************************************/
/* Context ID's to be sent to AmigaGuide */
STRPTR context[] =
{
"MAIN",
"STATUS",
"LISTVIEW",
"ACCEPT",
"CANCEL",
"QUIT",
"NONCONTINUOUS",
"CONTINUOUS",
NULL
};
/*****************************************************************************/
#define MCMD_MAIN 0
#define MCMD_STATUS 1
#define MCMD_LISTVIEW 2
#define MCMD_ACCEPT 3
#define MCMD_CANCEL 4
#define MCMD_QUIT 5
#define MCMD_NONCONTINUOUS 6
#define MCMD_CONTINUOUS 7
/*****************************************************************************/
/* Simple little prompts to display within the status window */
STRPTR quickhelp[] =
{
"AGHelp main window.",
"Quick-Help or status window.",
"List of absolutely nothing.",
"Accept changes.",
"Cancel changes.",
"",
"Window sizing gadget.",
"Window drag bar.",
"Screen drag bar.",
"Window depth gadget.",
"Screen depth gadget.",
"Window zoom gadget.",
"",
"Window close gadget.",
NULL
};
#define MAX_REGION 14
/*****************************************************************************/
struct TextAttr topaz8 = {"topaz.font", 8,};
/*****************************************************************************/
#define IDCMP_FLAGS IDCMP_RAWKEY | IDCMP_CLOSEWINDOW | IDCMP_MENUPICK | IDCMP_MENUHELP | \
IDCMP_GADGETUP | IDCMP_MOUSEMOVE | IDCMP_GADGETHELP
/*****************************************************************************/
#define V(x) ((void *)(x))
struct NewMenu main_menu[] =
{
{NM_TITLE, "Project",},
{NM_ITEM, "Quit", "Q", NULL, NULL, V(MCMD_QUIT),},
{NM_TITLE, "Settings",},
{NM_ITEM, "Continuous Help?", "", CHECKIT | MENUTOGGLE, NULL, V(MCMD_NONCONTINUOUS),},
{NM_END,},
};
/*****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/
VOID DisplayError (LONG err)
{
printf ("%s\n", GetAmigaGuideString (err));
}
/*****************************************************************************/
void HandleEvents (struct AppInfo * ai)
{
struct Window *win = ai->ai_Window;
struct AmigaGuideMsg *agm;
struct IntuiMessage *imsg;
struct MenuItem *item;
ULONG sigr = 0L;
ULONG sigi = 0L;
ULONG sigb = 0L;
UWORD selection;
STRPTR label;
LONG region;
LONG qhelp;
LONG id;
/* Show that we're not done running the application yet */
ai->ai_Done = FALSE;
/* Get our signal bits */
sigb = AmigaGuideSignal (ai->ai_AmigaGuide);
sigi = (1L << win->UserPort->mp_SigBit);
/* Clear the AmigaGuide context */
SetAmigaGuideContext (ai->ai_AmigaGuide, 0L, NULL);
/* Continue until done */
while (!(ai->ai_Done))
{
/* Wait for something to happen */
sigr = Wait (sigb | sigi);
/* Pull Intuition & GadTools messages */
while (imsg = GT_GetIMsg (win->UserPort))
{
switch (imsg->Class)
{
case IDCMP_CLOSEWINDOW:
ai->ai_Done = TRUE;
break;
case IDCMP_MENUPICK:
selection = imsg->Code;
while (selection != MENUNULL)
{
item = ItemAddress (win->MenuStrip, selection);
switch ((LONG)MENU_USERDATA (item))
{
case MCMD_QUIT:
ai->ai_Done = TRUE;
break;
case MCMD_NONCONTINUOUS:
if (item->Flags & CHECKED)
ai->ai_NHFlags |= AGHF_CONTINUOUS;
else
ai->ai_NHFlags &= ~AGHF_CONTINUOUS;
break;
}
selection = item->NextSelect;
}
break;
case IDCMP_MENUHELP:
if (item = ItemAddress (win->MenuStrip, imsg->Code))
{
/* Get the context ID */
id = (LONG) MENU_USERDATA (item);
/* Adjust for being selected */
if (item->Flags & CHECKED)
id++;
/* Display the node */
SendAmigaGuideCmd (ai->ai_AmigaGuide, NULL, AGA_Context, id, TAG_DONE);
}
break;
case IDCMP_GADGETUP:
switch (((struct Gadget *)imsg->IAddress)->GadgetID)
{
case MCMD_ACCEPT:
case MCMD_CANCEL:
ai->ai_Done = TRUE;
break;
}
break;
case IDCMP_GADGETHELP:
qhelp = region = -1;
if (imsg->IAddress == NULL)
{
/* Not over our window */
DB (printf ("not over our window\n"));
}
else if (imsg->IAddress == (APTR) win)
{
/* Over our window */
DB (printf ("over window\n"));
qhelp = region = 0;
}
else
{
/*
* Detect system gadgets. Figure out by looking at
* system-gadget-type bits in GadgetType field:
*/
LONG sysgtype = ((struct Gadget *) imsg->IAddress)->GadgetType & 0xF0;
/* Set the region */
qhelp = (sysgtype >> 4) + 5;
region = HTFC_SYSGADS + sysgtype;
switch (sysgtype)
{
case GTYP_SIZING:
DB (printf ("Gadget Help for window sizing gadget\n"));
break;
case GTYP_WDRAGGING:
DB (printf ("Gadget Help for window drag-bar\n"));
break;
case GTYP_WUPFRONT:
DB (printf ("Gadget Help for window depth gadget\n"));
break;