home *** CD-ROM | disk | FTP | other *** search
- /* ******************************************************************** */
- /* C code generated by: */
- /* Visual Arts Version 2.0 */
- /* Copyright 1994 Danny Y. Wong All rights reserved */
- /* Calgary, Alberta (CANADA) */
- /* Partial of the code is copyright by Jaba Development */
- /* ******************************************************************** */
-
- #include "VisualArts.h"
-
- #define ID_ObjID6 0
- #define ID_ObjID7 1
- #define ID_ObjID2 2
- #define ID_ObjID5 3
- #define ID_ObjID8 4
- #define ID_ObjID4 5
- #define ID_ObjID9 6
- #define ID_ObjID1 7
- #define ID_ObjID3 8
-
- #define ContextSNumGads 9
-
- #include "MultiMain.h"
-
- int ObjID6Obj(struct VAobject VAObject);
- int ObjID7Obj(struct VAobject VAObject);
- int ObjID2Obj(struct VAobject VAObject);
- int ObjID5Obj(struct VAobject VAObject);
- int ObjID8Obj(struct VAobject VAObject);
- int ObjID4Obj(struct VAobject VAObject);
- int ObjID9Obj(struct VAobject VAObject);
- int ObjID1Obj(struct VAobject VAObject);
- int ObjID3Obj(struct VAobject VAObject);
-
- int GetPubScreen(void);
- void ClosePubScreen(void);
- int OpenContextSWindow(char windtitle[80]);
- void CloseContextSWindow(void);
- int ContextSHandler(void);
- int ContextSMainHandler(void);
- void DrawContextSObjs(void);
- int main(int argc, char *argv[]);
- extern void SubPrg(void);
-
- UBYTE *PubScrName = NULL;
- struct DrawInfo *ScrDrawInfo = NULL;
- APTR VisualInfo = NULL;
- struct Screen *Scr = NULL;
- struct WindowNode *ContextSActiveWind = NULL;
- struct Gadget *ContextSGList = NULL;
- struct Gadget *ContextSGadgets[ContextSNumGads];
- struct IntuiMessage ContextSMsg;
- UWORD ContextSLeft = 0;
- UWORD ContextSTop = 28;
- UWORD ContextSWidth = 279;
- UWORD ContextSHeight = 79;
- struct IntuitionBase *IntuitionBase = NULL;
- struct List *ContextSWindList;
- UWORD ContextSTotalWindows = 0;
- UWORD ContextSNumWindows = 0;
- struct TextAttr topaz8 = { (STRPTR)"topaz.font", 8, 0x00, 0x01 };
- struct TextAttr topaz800 = { (STRPTR)"topaz.font", 8, 0x00, 0x00 };
-
- UBYTE *ModelsLabels[] = {
- (UBYTE *)"Amiga 500",
- (UBYTE *)"Amiga 1000",
- (UBYTE *)"Amiga 2000",
- (UBYTE *)"Amiga 3000",
- (UBYTE *)"Amiga 4000",
- (UBYTE *)"Amiga CDTV",
- (UBYTE *)"Amiga CD32",
- NULL
- };
-
- UBYTE *answerLabels[] = {
- (UBYTE *)"Yes",
- (UBYTE *)"No",
- NULL
- };
-
- WORD ContextSGadTypes[] = {
- BUTTON_KIND,
- BUTTON_KIND,
- STRING_KIND,
- STRING_KIND,
- CHECKBOX_KIND,
- MX_KIND,
- CYCLE_KIND,
- LISTVIEW_KIND,
- PALETTE_KIND,
- };
-
- struct NewGadget ContextSNGads[] = {
- 168, 2, 71, 12, (UBYTE *)"Button",&topaz800, ID_ObjID6, PLACETEXT_IN, NULL, (APTR)ObjID6Obj,
- 168, 16, 71, 12, (UBYTE *)"Toggle",&topaz800, ID_ObjID7, PLACETEXT_IN, NULL, (APTR)ObjID7Obj,
- 6, 30, 87, 12, (UBYTE *)"", &topaz800, ID_ObjID2, PLACETEXT_LEFT, NULL, (APTR)ObjID2Obj,
- 58, 50, 72, 12, (UBYTE *)"String", &topaz800, ID_ObjID5, PLACETEXT_LEFT, NULL, (APTR)ObjID5Obj,
- 213, 31, 26, 11, (UBYTE *)"Cool", &topaz800, ID_ObjID8, PLACETEXT_LEFT, NULL, (APTR)ObjID8Obj,
- 143, 30, 17, 16, (UBYTE *)"", &topaz800, ID_ObjID4, PLACETEXT_LEFT, NULL, (APTR)ObjID4Obj,
- 177, 50, 62, 12, (UBYTE *)"OK", &topaz800, ID_ObjID9, PLACETEXT_LEFT, NULL, (APTR)ObjID9Obj,
- 5, 2, 87, 28, (UBYTE *)"", &topaz800, ID_ObjID1, PLACETEXT_ABOVE, NULL, (APTR)ObjID1Obj,
- 99, 2, 61, 25, (UBYTE *)"", &topaz800, ID_ObjID3, PLACETEXT_ABOVE, NULL, (APTR)ObjID3Obj,
- };
-
- ULONG ContextSNTags[] = {
- TAG_DONE,
- TAG_DONE,
- GTST_MaxChars, 255, (STRINGA_Justification), GACT_STRINGLEFT, TAG_DONE,
- (GTST_String), (ULONG)"Visual Arts", GTST_MaxChars, 255, (STRINGA_Justification), GACT_STRINGLEFT, TAG_DONE,
- TAG_DONE,
- (GTMX_Labels), (ULONG)&answerLabels[0], (GTMX_Active), 0, (GTMX_Spacing), 1, TAG_DONE,
- (GTCY_Labels), (ULONG)&answerLabels[0], (GTCY_Active), 0, TAG_DONE,
- (GTLV_ShowSelected), 99, (GTLV_Labels), NULL, (GTLV_Top), 0, (GTLV_ScrollWidth), 16, (LAYOUTA_Spacing), 0, TAG_DONE,
- (GTPA_Depth), 2, (GTPA_Color), 1, (GTPA_ColorOffset), 0, TAG_DONE,
- };
-
-
- int GetPubScreen(void)
- {
- if (!(Scr = LockPubScreen(PubScrName)))
- return(1L);
-
- if (!(VisualInfo = GetVisualInfo(Scr, TAG_DONE)))
- return(2L);
-
- if (!(ScrDrawInfo = GetScreenDrawInfo(Scr)))
- return(3L);
- return(0L);
- }
-
- void ClosePubScreen(void)
- {
- if (VisualInfo)
- FreeVisualInfo(VisualInfo);
- if (Scr)
- UnlockPubScreen(NULL, Scr);
- if (ScrDrawInfo)
- FreeScreenDrawInfo(Scr, ScrDrawInfo);
- }
-
- int OpenContextSWindow(char windtitle[80])
- {
- struct NewGadget NewGad;
- struct Gadget *Gad;
- register UWORD i, j;
- UWORD offsetx = Scr->WBorLeft;
- UWORD offsety = Scr->WBorTop + Scr->RastPort.TxHeight + 1;
- int k=0;
- int LVStrGads[] = {ID_ObjID2, -1 };
-
- if (ContextSNumWindows == 0)
- {
- if (!(Gad = CreateContext(&ContextSGList)))
- return(1L);
-
- for (i=0, j=0; i < ContextSNumGads; i++)
- {
- CopyMem((char *)&ContextSNGads[i], (char *)&NewGad, (long)sizeof(struct NewGadget));
-
- NewGad.ng_VisualInfo = VisualInfo;
- NewGad.ng_LeftEdge += offsetx;
- NewGad.ng_TopEdge += offsety;
-
- if (ContextSNTags[j] == GTLV_ShowSelected && ContextSNTags[j+1] == 99)
- ContextSNTags[j+1] = (ULONG)ContextSGadgets[LVStrGads[k++]];
- ContextSGadgets[i] = Gad = CreateGadgetA((ULONG)ContextSGadTypes[i], Gad, &NewGad,
- (struct TagItem *)&ContextSNTags[j]);
- while (ContextSNTags[j])
- j +=2;
- j++;
- if (!Gad)
- return(2L);
- }
- ContextSGadgets[1]->Activation |= GACT_TOGGLESELECT;
- }
- if (!(ContextSActiveWind = AddWindowNode(ContextSWindList, windtitle, ContextSHandler)))
- return(1);
- if (!(ContextSActiveWind->nn_Window = OpenWindowTags(NULL,
- WA_Left, ContextSLeft,
- WA_Top, ContextSTop,
- WA_Width, ContextSWidth,
- WA_Height, ContextSHeight - Scr->WBorTop,
- WA_NewLookMenus, TRUE,
- WA_IDCMP, IDCMP_CLOSEWINDOW | IDCMP_NEWSIZE | IDCMP_MOUSEBUTTONS | IDCMP_MOUSEMOVE | IDCMP_GADGETUP | IDCMP_GADGETDOWN | IDCMP_INTUITICKS | IDCMP_ACTIVEWINDOW | IDCMP_INACTIVEWINDOW ,
- WA_Flags, WFLG_SIZEGADGET | WFLG_SIZEBRIGHT | WFLG_DEPTHGADGET |
- WFLG_CLOSEGADGET ,
- WA_Gadgets, ContextSGList,
- WA_Title, windtitle,
- WA_ScreenTitle, "Visual Arts V2.0 Copyright 1994 Danny Y. Wong All Rights Reserved.",
- WA_PubScreen, Scr,
- WA_MinWidth, 160,
- WA_MinHeight, 50,
- WA_MaxWidth, 640,
- WA_MaxHeight, 200,
- TAG_DONE)))
- return(3L);
-
- if (++ContextSNumWindows == 1)
- CreateContextSLists();
- GT_RefreshWindow(ContextSActiveWind->nn_Window, NULL);
- RefreshGadgets(ContextSGadgets[0], ContextSActiveWind->nn_Window, NULL);
- GT_SetGadgetAttrs(ContextSGadgets[7], ContextSActiveWind->nn_Window, NULL,
- GTLV_Labels, ContextSLists[0], TAG_END);
- return(0L);
- }
-
- void CloseContextSWindow(void)
- {
- struct WindowNode *WindNode;
- struct Node *tempNode;
-
- if (tempNode = FindName(ContextSWindList, ContextSActiveWind->nn_Window->Title))
- {
- if (WindNode = FindWindowNode(ContextSWindList, ContextSActiveWind->nn_Window->Title))
- {
- if (ContextSTotalWindows == 1)
- WindNode = NULL;
- else
- {
- if (WindNode->ID == 1)
- WindNode = FindWindowNode(ContextSWindList, tempNode->ln_Succ->ln_Name);
- else
- WindNode = FindWindowNode(ContextSWindList, tempNode->ln_Pred->ln_Name);
- }
- DelWindowNode(ContextSWindList, ContextSActiveWind->nn_Window->Title);
- if (ContextSActiveWind->nn_Window)
- CloseWindow(ContextSActiveWind->nn_Window);
- if (WindNode)
- {
- ContextSActiveWind = WindNode;
- ReMakeWindowID(ContextSWindList);
- WindowToFront(ContextSActiveWind->nn_Window);
- ActivateWindow(ContextSActiveWind->nn_Window);
- }
- }
- }
- }
-
- int ContextSHandler(void)
- {
- struct IntuiMessage *msg;
- struct VAobject VAObject;
- int running = 1;
- int (*func)(struct VAobject VAObject);
- struct WindowNode *WindNode;
- ULONG class;
- UWORD code;
-
- while (msg=GT_GetIMsg(ContextSActiveWind->nn_Window->UserPort))
- {
- CopyMem((char *)msg, (char *)&ContextSMsg, (long)sizeof(struct IntuiMessage));
- class = msg->Class;
- code = msg->Code;
-
- GT_ReplyIMsg(msg);
- switch(class)
- {
-
- case IDCMP_MOUSEBUTTONS :
- break;
-
- case IDCMP_MOUSEMOVE :
- break;
-
- case IDCMP_INTUITICKS :
- break;
-
- case IDCMP_NEWSIZE:
- break;
-
- case IDCMP_CLOSEWINDOW:
- CloseContextSWindow();
- if (--ContextSNumWindows == 0)
- {
- if (ContextSGList)
- FreeGadgets(ContextSGList);
- }
- return(1);
- break;
-
- case IDCMP_ACTIVEWINDOW:
- case IDCMP_INACTIVEWINDOW:
- if (!IntuitionBase->ActiveWindow)
- {
- ActivateWindow(ContextSActiveWind->nn_Window);
- break;
- }
- WindNode = FindWindowNode(ContextSWindList, IntuitionBase->ActiveWindow->Title);
- if (WindNode)
- ContextSActiveWind = WindNode;
- break;
-
- case IDCMP_GADGETUP:
- VAObject.va_Window = (struct Window *)ContextSActiveWind->nn_Window ;
- VAObject.va_Gadget = (struct Gadget *)msg->IAddress;
- VAObject.va_IntuiMsg = (struct IntuiMessage *)msg;
- VAObject.va_Flags = 0;
- VAObject.va_UserData = 0;
- func = (void *)((struct Gadget *)ContextSMsg.IAddress)->UserData;
- if (func != NULL)
- running = func(VAObject);
- break;
-
- }
- }
- return(running);
- }
-
- int ContextSMainHandler(void)
- {
- int running = 1;
- ULONG windsig, signals;
-
- struct WindowNode *WindNode;
- int (*func)(void);
- while (running == 1)
- {
- windsig = 1L << ContextSActiveWind->nn_Window->UserPort->mp_SigBit;
- signals = Wait( windsig );
- if (signals & windsig)
- {
- if (WindNode = FindWindowNode(ContextSWindList, ContextSActiveWind->nn_Window->Title))
- {
- func = (void *)WindNode->UserData;
- running = func();
- if (ContextSTotalWindows == 0)
- running = 0;
- }
- }
- }
- return(running);
- }
-
- int main(int argc, char *argv[])
- {
- int rc;
-
- IntuitionBase=(struct IntuitionBase *)OpenLibrary("intuition.library",0);
- if (IntuitionBase == NULL)
- exit(0);
- if (!(GetPubScreen()))
- {
- ContextSWindList = GetNewList();
- for (rc=0; rc < 2; rc++)
- ContextSLists[rc]=GetNewList();
- SubPrg(); //open subprg window
- if (!(OpenContextSWindow("Visual Arts -- Context Sensitive Demo")))
- rc = ContextSMainHandler();
- for (rc=0; rc < 2; rc++)
- FreeList(ContextSLists[rc]);
- FreeWindowList(ContextSWindList);
- ClosePubScreen();
- }
- if (IntuitionBase)
- CloseLibrary((struct Library *)IntuitionBase);
- }
-