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 <workbench/workbench.h>
- #include <workbench/startup.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 <clib/wb_protos.h>
- #include "string.h"
-
- #define ID_clear 0
- #define ID_ok 1
- #define ID_iconlist 2
-
- #define AppWindNumGads 3
- #include "AppWindow.h"
-
- int clearObj(struct VAobject VAObject);
- int okObj(struct VAobject VAObject);
- int iconlistObj(struct VAobject VAObject);
-
- int GetPubScreen(void);
- void ClosePubScreen(void);
- int OpenAppWindWindow(char windtitle[80]);
- void CloseAppWindWindow(void);
- int AppWindHandler(void);
- int AppWindMainHandler(void);
- int AppWindAppWindHandler(struct MsgPort *appwindport);
- void DrawAppWindObjs(void);
- int main(int argc, char *argv[]);
-
- UBYTE *PubScrName = NULL;
- APTR VisualInfo = NULL;
- struct Screen *Scr = NULL;
- struct Window *AppWindWnd = NULL;
- struct AppWindow *AppWindAppWind = NULL;
- struct MsgPort *AppWindAppWindPort = NULL;
- struct Gadget *AppWindGList = NULL;
- struct Gadget *AppWindGadgets[3];
- struct IntuiMessage AppWindMsg;
- UWORD AppWindLeft = 168;
- UWORD AppWindTop = 37;
- UWORD AppWindWidth = 228;
- UWORD AppWindHeight = 108;
- struct TextAttr topaz800 = { (STRPTR)"topaz.font", 8, 0x00, 0x00 };
- struct TextAttr topaz8265 = { (STRPTR)"topaz.font", 8, 2, 65 };
- struct TextAttr topaz8465 = { (STRPTR)"topaz.font", 8, 4, 65 };
-
- struct IntuiText AppWindIText[] = {
- 1, 0, JAM2, 7, 85, &topaz8465, (UBYTE *)"Drag Icons into the Window", NULL,
- };
-
- UBYTE *IconsLabels[] = {
- NULL
- };
-
- WORD AppWindGadTypes[] = {
- BUTTON_KIND,
- BUTTON_KIND,
- LISTVIEW_KIND,
- };
-
- struct NewGadget AppWindNGads[] = {
- 40, 70, 67, 12, (UBYTE *)"Clear",&topaz800, ID_clear, PLACETEXT_IN, NULL, (APTR)clearObj,
- 121, 70, 57, 12, (UBYTE *)"OK",&topaz800, ID_ok, PLACETEXT_IN, NULL, (APTR)okObj,
- 28, 14, 170, 52, (UBYTE *)"Program Names", &topaz8265, ID_iconlist, PLACETEXT_ABOVE, NULL, (APTR)iconlistObj,
- };
-
- ULONG AppWindNTags[] = {
- 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 OpenAppWindWindow(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(&AppWindGList)))
- return(1L);
-
- for (i=0, j=0; i < AppWindNumGads; i++)
- {
- CopyMem((char *)&AppWindNGads[i], (char *)&NewGad, (long)sizeof(struct NewGadget));
-
- NewGad.ng_VisualInfo = VisualInfo;
- NewGad.ng_LeftEdge += offsetx;
- NewGad.ng_TopEdge += offsety;
-
- AppWindGadgets[i] = Gad = CreateGadgetA((ULONG)AppWindGadTypes[i], Gad,&NewGad,
- (struct TagItem *)&AppWindNTags[j]);
- while (AppWindNTags[j])
- j +=2;
- j++;
- if (!Gad)
- return(2L);
- }
- if (!(AppWindWnd = OpenWindowTags(NULL,
- WA_Left, AppWindLeft,
- WA_Top, AppWindTop,
- WA_Width, AppWindWidth,
- WA_Height, AppWindHeight - Scr->WBorTop,
- WA_IDCMP, IDCMP_CLOSEWINDOW | IDCMP_NEWSIZE | IDCMP_MOUSEBUTTONS | IDCMP_MOUSEMOVE | IDCMP_GADGETUP | IDCMP_GADGETDOWN | IDCMP_INTUITICKS ,
- WA_Flags, WFLG_CLOSEGADGET | WFLG_DEPTHGADGET | WFLG_SMART_REFRESH | WFLG_RMBTRAP | WFLG_ACTIVATE | WFLG_DRAGBAR ,
- WA_Gadgets, AppWindGList,
- 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);
-
- if (AppWindAppWindPort = CreateMsgPort())
- {
- AppWindAppWind = AddAppWindow(1, 0, AppWindWnd, AppWindAppWindPort, NULL);
- if (AppWindAppWind == NULL)
- {
- CloseAppWindWindow();
- return(-1L);
- }
- }
- else
- return(-2L);
- DrawAppWindObjs();
- GT_RefreshWindow(AppWindWnd, NULL);
- CreateAppWindLists();
- GT_SetGadgetAttrs(AppWindGadgets[2], AppWindWnd, NULL,
- GTLV_Labels, AppWindLists[0], TAG_END);
- RefreshGadgets(AppWindGadgets[0], AppWindWnd, NULL);
- return(0L);
- }
-
- void CloseAppWindWindow(void)
- {
- struct AppMessage *appwindmsg;
-
- if (AppWindWnd)
- CloseWindow(AppWindWnd);
- if (AppWindGList)
- FreeGadgets(AppWindGList);
- if (AppWindAppWind)
- {
- RemoveAppWindow(AppWindAppWind);
- while (appwindmsg = (struct AppMessage *)GetMsg(AppWindAppWindPort))
- ReplyMsg((struct Message *)appwindmsg);
- DeleteMsgPort(AppWindAppWindPort);
- }
- }
-
- int AppWindHandler(void)
- {
- struct IntuiMessage *msg;
- struct VAobject VAObject;
- int running = 1;
- int (*func)(struct VAobject VAObject);
- ULONG class;
- UWORD code;
-
- while (msg=GT_GetIMsg(AppWindWnd->UserPort))
- {
- CopyMem((char *)msg, (char *)&AppWindMsg, (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_CLOSEWINDOW:
- return(0);
- break;
-
- case IDCMP_GADGETUP:
- VAObject.va_Window = (struct Window *)AppWindWnd;
- 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 *)AppWindMsg.IAddress)->UserData;
- running = func(VAObject);
- break;
-
- }
- }
- return(running);
- }
-
- void DrawAppWindObjs(void)
- {
- PrintIText(AppWindWnd->RPort, AppWindIText, AppWindWnd->BorderLeft, AppWindWnd->BorderTop);
-
- }
-
- int AppWindAppWindHandler(struct MsgPort *appwindport)
- {
- struct WBArg *wbargptr;
- struct AppMessage *appwindmsg;
- int i;
-
- while (appwindmsg = (struct AppMessage *)GetMsg(appwindport))
- {
- wbargptr = appwindmsg->am_ArgList;
-
- /* examine the icons dragged into the window here. */
- /* wbargptr->wa_Name ---> name of the icon */
- /* wbargptr->wa_Lock ---> directory this icon is in. */
-
- //we must detach the list before doing modifications
-
- GT_SetGadgetAttrs(AppWindGadgets[ID_iconlist], AppWindWnd, NULL,
- GTLV_Labels, ~0, TAG_DONE);
-
- //here we loop thru all the icons dragged in
- for (i=0; i < appwindmsg->am_NumArgs; i++)
- {
- //use VAs internal list routines to add a new node to the list
- AddNewNode(AppWindLists[0], wbargptr->wa_Name);
- wbargptr++;
- }
- ReplyMsg((struct Message *)appwindmsg);
- //now reattach the list to the listview with update values
- GT_SetGadgetAttrs(AppWindGadgets[ID_iconlist], AppWindWnd, NULL,
- GTLV_Labels, AppWindLists[0], TAG_DONE);
- }
- return(0);
- }
-
- int AppWindMainHandler(void)
- {
- int running = 1;
- ULONG windsig, signals;
-
- ULONG appwindsig;
-
- while (running == 1)
- {
- appwindsig = 1L << AppWindAppWindPort->mp_SigBit;
- windsig = 1L << AppWindWnd->UserPort->mp_SigBit;
- signals = Wait( windsig | appwindsig );
- if (signals & windsig)
- {
- running = AppWindHandler();
- }
- else
- if (signals & appwindsig)
- AppWindAppWindHandler(AppWindAppWindPort);
- }
- return(running);
- }
-
- int main(int argc, char *argv[])
- {
- int rc;
-
- if (!(GetPubScreen()))
- {
- for (rc=0; rc < 1; rc++)
- AppWindLists[rc]=GetNewList();
- if (!(OpenAppWindWindow("AppWindow Demo")))
- {
- rc = AppWindMainHandler();
- CloseAppWindWindow();
- }
- for (rc=0; rc < 1; rc++)
- FreeList(AppWindLists[rc]);
- ClosePubScreen();
- }
- }
-