home *** CD-ROM | disk | FTP | other *** search
- /**************************************************************************
- ***** Gadget Demo 3 *****
- ***** *****
- ***** by John J. Karcher *****
- ***** *****
- ***** 4 August 1992 *****
- ***** 10 Jan 1993 mvk *****
- ***** *****
- **************************************************************************/
-
- /*
- This program opens up a window with a single gadget in it, using
- egsgadbox.library. This one is similar to the last one, but the
- window is resizable and the gadget resizes with it!
- */
-
- #include <stdio.h>
- #include <exec/types.h>
- #include <proto/exec.h>
- #include <egs/egsintui.h>
- #include <egs/egsgadbox.h>
- #include <egs/proto/all.h>
-
-
- #define ACTION_GAD_ID 1000
-
-
- struct Library *EGSIntuiBase;
- struct Library *EGBBase;
-
- struct EB_GadContextNode *GadCon;
- struct EI_Window *Win;
-
-
- BYTE CreateGfx(void);
- BYTE CreateWindow(void);
-
-
- BYTE CreateGfx(void)
- {
- EB_GadBoxPtr root, help;
-
- BYTE ret = 0;
-
- if (GadCon = EB_CreateGadContext(NULL, NULL, -1, -1))
- {
- root = EB_CreateTextAction(GadCon, "Push Me", ACTION_GAD_ID, EB_FILL_ALL);
- root = EB_CreateBackBorder(GadCon, root, 0);
-
- root = EB_CreateMasterWindow(GadCon,Win,root);
-
- if (EB_ProcessGadBoxes(GadCon, root))
- {
- ret = 1;
- }
- }
-
- return ret;
- }
-
- BYTE CreateWindow(void)
- {
- BYTE ret = 0;
-
- if (CreateGfx())
- {
- GadCon->NewWin->Title = "EGS Gadget Demo 3";
- GadCon->NewWin->IDCMPFlags |= (EI_iCLOSEWINDOW | EI_iGADGETUP | EI_iNEWSIZE | EI_iSIZEVERIFY);
- GadCon->NewWin->Flags |= EI_WINDOWCENTER;
- GadCon->NewWin->Bordef.SysGadgets |= (EI_WINDOWCLOSE | EI_WINDOWSIZE);
- if (Win = EI_OpenWindow(GadCon->NewWin))
- {
- ret = 1;
- }
- }
-
- return ret;
- }
-
- main()
- {
- struct EI_EIntuiMsg *IMsg;
- struct EI_Gadget *TempGad;
- BYTE quit = 0;
-
- if (EGSIntuiBase = OpenLibrary("egsintui.library", 0))
- {
- if (EGBBase = OpenLibrary("egsgadbox.library", 0))
- {
- if (CreateWindow())
- {
- while (!quit)
- {
- WaitPort(Win->UserPort);
- if (IMsg = (struct EI_EIntuiMsg *)GetMsg(Win->UserPort))
- {
- if (IMsg->Class == EI_iCLOSEWINDOW)
- {
- quit = 1;
- }
- if (IMsg->Class == EI_iGADGETUP)
- {
- TempGad = (struct EI_Gadget *)IMsg->IAddress;
- if (TempGad->GadgetID == ACTION_GAD_ID)
- {
- printf("You pressed me!\n");
- }
- }
- if (IMsg->Class == EI_iSIZEVERIFY)
- {
- EI_RemoveGList(Win, GadCon->First, GadCon->Num);
- EB_DeleteGadContext(GadCon);
- GadCon = NULL;
- }
- if (IMsg->Class == EI_iNEWSIZE)
- {
- EI_LockIntuition();
- CreateGfx();
- if (GadCon)
- {
- EI_AddGList(Win, GadCon->First, GadCon->Num);
- }
- EI_UnlockIntuition();
- }
- ReplyMsg((struct Message *)IMsg);
- }
- }
- }
- if (Win) EI_CloseWindow(Win);
- if (GadCon) EB_DeleteGadContext(GadCon);
- CloseLibrary(EGBBase);
- }
- CloseLibrary(EGSIntuiBase);
- }
- }
-