home *** CD-ROM | disk | FTP | other *** search
- /* ******************************************************************** */
- /* C code generated by: */
- /* Visual Arts Version 1.0 */
- /* Copyright 1994 Danny Y. Wong All rights reserved */
- /* Calgary, Alberta (CANADA) */
- /* Partial of the code is copyright by Jaba Development */
- /* ******************************************************************** */
-
- #include <exec/types.h>
- #include <exec/memory.h>
- #include <exec/lists.h>
- #include <exec/nodes.h>
- #include <intuition/intuition.h>
- #include <intuition/gadgetclass.h>
- #include <graphics/displayinfo.h>
- #include <graphics/gfxbase.h>
- #include <graphics/gfxmacros.h>
- #include <libraries/gadtools.h>
- #include <libraries/dos.h>
- #include <libraries/asl.h>
-
- #include <clib/exec_protos.h>
- #include <clib/intuition_protos.h>
- #include <clib/gadtools_protos.h>
- #include <clib/graphics_protos.h>
- #include <clib/utility_protos.h>
- #include <clib/alib_protos.h>
- #include <clib/dos_protos.h>
- #include <clib/asl_protos.h>
- #include "string.h"
-
- #define ID_ok 0
- #define ID_ok1 1
- #define ID_wanted 2
-
- #define FunnyNumGads 3
- #include "Funny.h"
-
- int okObj(struct VAobject VAObject);
- int ok1Obj(struct VAobject VAObject);
- int wantedObj(struct VAobject VAObject);
-
- int GetPubScreen(void);
- void ClosePubScreen(void);
- int OpenFunnyWindow(char windtitle[80]);
- void CloseFunnyWindow(void);
- int FunnyHandler(void);
- int FunnyMainHandler(void);
- void DrawFunnyObjs(void);
- int main(int argc, char *argv[]);
-
- UBYTE *PubScrName = NULL;
- APTR VisualInfo = NULL;
- struct Screen *Scr = NULL;
- struct Window *FunnyWnd = NULL;
- struct Gadget *FunnyGList = NULL;
- struct Gadget *FunnyGadgets[3];
- struct IntuiMessage FunnyMsg;
- UWORD FunnyLeft = 128;
- UWORD FunnyTop = 22;
- UWORD FunnyWidth = 315;
- UWORD FunnyHeight = 152;
- struct TextAttr topaz8 = { (STRPTR)"topaz.font", 8, 0x00, 0x01 };
- struct TextAttr topaz800 = { (STRPTR)"topaz.font", 8, 0x00, 0x00 };
-
- struct IntuiText FunnyIText[] = {
- 2, 0, JAM2, 55, 94, &topaz800, (UBYTE *)"Wanted", &FunnyIText[1],
- 2, 0, JAM2, 17, 105, &topaz800, (UBYTE *)"$1,000,000 Alive", &FunnyIText[2],
- 1, 0, JAM2, 163, 5, &topaz800, (UBYTE *)"Name: Slippy Joe", &FunnyIText[3],
- 1, 0, JAM2, 243, 81, &topaz800, (UBYTE *)"", &FunnyIText[4],
- 1, 0, JAM2, 161, 14, &topaz800, (UBYTE *)"Age: 17 - 20", &FunnyIText[5],
- 1, 0, JAM2, 161, 24, &topaz800, (UBYTE *)"Weight: 160Lbs", &FunnyIText[6],
- 1, 0, JAM2, 161, 34, &topaz800, (UBYTE *)"Height: 5'10", &FunnyIText[7],
- 1, 0, JAM2, 160, 44, &topaz800, (UBYTE *)"Hair Color: Black", NULL,
- };
-
- UBYTE *WantedLabels[] = {
- (UBYTE *)"Slippy Joe",
- (UBYTE *)"Cool Kid",
- (UBYTE *)"Freddy",
- (UBYTE *)"Homer",
- (UBYTE *)"Dead Eye",
- (UBYTE *)"Sneakers",
- NULL
- };
-
- WORD FunnyGadTypes[] = {
- BUTTON_KIND,
- BUTTON_KIND,
- LISTVIEW_KIND,
- };
-
- struct NewGadget FunnyNGads[] = {
- 70, 125, 73, 12, (UBYTE *)"OK",&topaz800, ID_ok, PLACETEXT_IN, NULL, (APTR)okObj,
- 169, 125, 73, 12, (UBYTE *)"Cancel",&topaz800, ID_ok1, PLACETEXT_IN, NULL, (APTR)ok1Obj,
- 161, 53, 144, 68, (UBYTE *)"", &topaz800, ID_wanted, PLACETEXT_ABOVE, NULL, (APTR)wantedObj,
- };
-
- ULONG FunnyNTags[] = {
- TAG_DONE,
- TAG_DONE,
- (GTLV_Labels), NULL, (GTLV_Top), 0, (GTLV_ScrollWidth), 16, (LAYOUTA_Spacing), 0, TAG_DONE,
- };
-
-
- int GetPubScreen(void)
- {
- if (!(Scr = LockPubScreen(PubScrName)))
- return(1L);
-
- if (!(VisualInfo = GetVisualInfo(Scr, TAG_DONE)))
- return(2L);
- return(0L);
- }
-
- void ClosePubScreen(void)
- {
- if (VisualInfo)
- FreeVisualInfo(VisualInfo);
- if (Scr)
- UnlockPubScreen(NULL, Scr);
- }
-
- int OpenFunnyWindow(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;
-
- if (!(Gad = CreateContext(&FunnyGList)))
- return(1L);
-
- for (i=0, j=0; i < FunnyNumGads; i++)
- {
- CopyMem((char *)&FunnyNGads[i], (char *)&NewGad, (long)sizeof(struct NewGadget));
-
- NewGad.ng_VisualInfo = VisualInfo;
- NewGad.ng_LeftEdge += offsetx;
- NewGad.ng_TopEdge += offsety;
-
- FunnyGadgets[i] = Gad = CreateGadgetA((ULONG)FunnyGadTypes[i], Gad,&NewGad,
- (struct TagItem *)&FunnyNTags[j]);
- while (FunnyNTags[j])
- j +=2;
- j++;
- if (!Gad)
- return(2L);
- }
- if (!(FunnyWnd = OpenWindowTags(NULL,
- WA_Left, FunnyLeft,
- WA_Top, FunnyTop,
- WA_Width, FunnyWidth,
- WA_Height, FunnyHeight - Scr->WBorTop,
- WA_IDCMP, IDCMP_CLOSEWINDOW | IDCMP_NEWSIZE | IDCMP_MOUSEBUTTONS | IDCMP_MOUSEMOVE | IDCMP_GADGETUP | IDCMP_GADGETDOWN | IDCMP_REFRESHWINDOW | IDCMP_INTUITICKS ,
- WA_Flags, WFLG_CLOSEGADGET | WFLG_DEPTHGADGET | WFLG_SMART_REFRESH | WFLG_ACTIVATE | WFLG_DRAGBAR ,
- WA_Gadgets, FunnyGList,
- WA_Title, windtitle,
- WA_ScreenTitle, "Visual Arts V1.0 Copyright 1994 Danny Y. Wong All Rights Reserved.",
- WA_PubScreen, Scr,
- WA_MinWidth, 20,
- WA_MinHeight, 10,
- WA_MaxWidth, 640,
- WA_MaxHeight, 200,
- TAG_DONE)))
- return(3L);
-
- InitTempArea();
- FunnyWnd->RPort->TmpRas=&Temprast;
- FunnyWnd->RPort->AreaInfo=&areaInfo;
- DrawFunnyObjs();
- GT_RefreshWindow(FunnyWnd, NULL);
- CreateFunnyLists();
- GT_SetGadgetAttrs(FunnyGadgets[2], FunnyWnd, NULL,
- GTLV_Labels, FunnyLists[0], TAG_END);
- RefreshGadgets(FunnyGadgets[0], FunnyWnd, NULL);
- return(0L);
- }
-
- void CloseFunnyWindow(void)
- {
- if (FunnyWnd)
- CloseWindow(FunnyWnd);
- if (FunnyGList)
- FreeGadgets(FunnyGList);
- }
-
- int FunnyHandler(void)
- {
- struct IntuiMessage *msg;
- struct VAobject VAObject;
- int running = 1;
- int (*func)(struct VAobject VAObject);
- ULONG class;
- UWORD code;
-
- while (msg=GT_GetIMsg(FunnyWnd->UserPort))
- {
- CopyMem((char *)msg, (char *)&FunnyMsg, (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_GADGETDOWN :
- break;
-
- case IDCMP_INTUITICKS :
- break;
-
- case IDCMP_REFRESHWINDOW:
- GT_BeginRefresh(FunnyWnd);
- DrawFunnyObjs();
- GT_EndRefresh(FunnyWnd, NULL);
- break;
-
- case IDCMP_CLOSEWINDOW:
- return(0);
- break;
-
- case IDCMP_GADGETUP:
- VAObject.va_Window = (struct Window *)FunnyWnd;
- 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 *)FunnyMsg.IAddress)->UserData;
- running = func(VAObject);
- break;
-
- }
- }
- return(running);
- }
-
- void DrawFunnyObjs(void)
- {
- FunnyDrawRects(FunnyWnd);
- FunnyDrawCircles(FunnyWnd);
- FunnyDrawLine(FunnyWnd);
- PrintIText(FunnyWnd->RPort, FunnyIText, FunnyWnd->BorderLeft, FunnyWnd->BorderTop);
-
- }
-
- int FunnyMainHandler(void)
- {
- int running = 1;
- ULONG windsig, signals;
-
- while (running == 1)
- {
- windsig = 1L << FunnyWnd->UserPort->mp_SigBit;
- signals = Wait( windsig );
- if (signals & windsig)
- {
- running = FunnyHandler();
- }
- }
- return(running);
- }
-
- int main(int argc, char *argv[])
- {
- int rc;
-
- if (!(GetPubScreen()))
- {
- for (rc=0; rc < 1; rc++)
- FunnyLists[rc]=GetNewList();
- if (!(OpenFunnyWindow("Funny Demo")))
- {
- rc = FunnyMainHandler();
- CloseFunnyWindow();
- }
- for (rc=0; rc < 1; rc++)
- FreeList(FunnyLists[rc]);
- ClosePubScreen();
- }
- }
-