home *** CD-ROM | disk | FTP | other *** search
- /*
- *
- * $
- * $ FILE : requester.c
- * $ VERSION : 1
- * $ REVISION : 4
- * $ DATE : 08-Dec-93 21:26
- * $
- * $ Author : mvk
- * $
- *
- *
- ** This example shows how to work with the egsrequest.library.
- **
- ** The routines myError,myMSG and EventLoop opens
- ** the requester.
- **
- ** (c) by VIONA-Development 1992/94
- **
- */
-
-
- /*
- ** Init-Routines
- */
-
- #include "Global.h"
- #include "EventLoop.c"
- #include "makegadget.c"
-
- BOOL InitLibraries(struct OpenStructTyp *OS)
- {
- struct OpenStructTyp *p = &OS[0];
-
- while (p->Var != NULL)
- {
- if ((*(p->Var) = (ULONG)OpenLibrary(p->Name,p->Version)) == NULL)
- {
- printf(" Can't open %s version %d",p->Name, p->Version);
- return FALSE;
- }
- else
- { p ++; }
- }
- return TRUE;
- }
- /**/
-
- void CloseLibraries(struct OpenStructTyp *OS)
- {
- struct OpenStructTyp *p = &OS[0];
-
- while (p->Name != NULL)
- {
- CloseLibrary((void *)(*(p->Var)));
- *(p->Var) = NULL;
- p++;
- }
- }
- /**/
-
-
- /*
- ** Open a Requester in the middle of
- ** the Screen.
- **
- */
-
- void myMSG(char *string)
- {
- if ( string != NULL)
- {
- if ( EGSRequestBase == NULL)
- {
- printf("%s\n",string);
-
- }else{
-
- ErrorReq = (ER_SimpleReqPtr)ER_CreateSimpleReq(NULL,
- (char *)string,(char *)"OK");
-
- /*
- ** Open Requester in the middle of the Screen,
- **
- ** if you could !?
- */
-
- ErrorReq->Req.Nw->Flags |= EI_WINDOWCENTER;
- /*
- ErrorReq->Req.Nw->LeftEdge = Window->LeftEdge;
- ErrorReq->Req.Nw->TopEdge = Window->TopEdge;
- */
- ErrorReq->Req.Nw->Title ="eInputRecorder";
- ER_DoRequest(&(ErrorReq->Req)) ;
- }
- }
- }
-
- /*
- * Author: Markus van Kempen
- * Date : 9. November 92
- *
- * This routine is for Errorhandling.
- * It close all open thinks form the
- * program.
- *
- * if ende == TRUE the myError terminates
- * otherwise it returns
- *
- */
- void myError(char *string,int ende)
- {
-
- myMSG("Hello world !|This is a Requester !");
-
- myMSG(string);
-
- if ( Window != NULL )
- EI_CloseWindow(Window);
-
- if ( con != NULL )
- EB_DeleteGadContext(con);
-
- if ( FontforMenu != NULL )
- EG_CloseFont(FontforMenu);
-
- if ( Menu != NULL )
- EI_FreeMenu(Menu);
-
- if ( ErrorReq != NULL )
- ER_DeleteRequest(&(ErrorReq->Req));
-
- CloseLibraries(OpenStruct);
-
- if (ende)
- exit(0);
-
- }
- /**/
-
-
- /*
- ** myopen = It Opens all egs libraries
- ** and calls InitMenu from initmenu.c
- ** and calls CreateGads from makegadgets.c
- **
- **
- */
-
- struct EI_Window *myopen(void)
- {
- struct EI_Window *Window=NULL;
-
- if ( InitLibraries(OpenStruct) == FALSE)
- myError("Can't OpenLibrary",10);
-
-
- /*
- SEE Init_Menu.c
-
- Menu=InitMenu(FontforMenu);
-
-
- if ( Menu == NULL )
- myError("Could not build Menu",10);
-
- */
-
- Window=CreateGads(NULL);
-
- if (Window == NULL)
- myError("Could not open window",10);
- return(Window);
- }
-
-
- /*
- **
- ** start GUI
- **
- */
-
- void main(void)
- {
- Window=myopen(); /* see myopen.c */
-
- if(Window)
- HandleEvents(Window);
-
- myError(NULL,10);
- }
-
- /* ENDE */
-
-
-