home *** CD-ROM | disk | FTP | other *** search
- /* =====================================================
- ** Created by the Precognition Interface Builder
- ** =====================================================
- **
- ** Link this file with 'Precognition.lib'
- **
- */
-
- #include "Precognition.h"
- #include "Intuition_Utils.h"
- #include "chainedwindows.h"
- #include "MsgWindow.h"
- #ifndef __GNUC__
- #include <clib/exec_protos.h>
- #include <clib/intuition_protos.h>
- #include <clib/graphics_protos.h>
- #endif
- #ifdef __GNUC__
- #include <proto/exec.h>
- #include <proto/intuition.h>
- #include <proto/graphics.h>
- #endif
- #ifdef __SASC
- #include <proto/exec.h>
- #include <proto/intuition.h>
- #include <proto/graphics.h>
- #endif
- #include <string.h>
- #include "BuilderWindow.h"
-
- extern struct MsgPort *shared_port;
- extern struct Screen *screen;
-
- /*
- ** The event loop is terminated when 'MsgWindow_Done' is true.
- */
-
-
- struct MsgWindow
- {
- pcgWindow w;
- BoolGadget bg_ok;
- struct IntuiText text;
- BOOL done;
- };
-
- /*=============== Prototypes ====================*/
-
-
- void MsgWindow_Init (
- struct MsgWindow *window,
- struct Screen *screen,
- char *text );
-
- void MsgWindow_CleanUp ( struct MsgWindow *window );
-
- ULONG MsgWindow_Respond (
- struct MsgWindow *window,
- struct IntuiMessage *event );
-
-
- extern struct BuilderWindow builderwindow;
-
- void MsgWindow_Init ( window, screen, text )
- struct MsgWindow *window;
- struct Screen *screen;
- char *text;
- {
-
- pcg_3DPens pens;
-
- window->done = FALSE;
- /* pens = StandardPens(); */
- pens = StandardScreenPens( screen );
-
- /* Initialize the window */
- pcgWindow_Init( &window->w,
- 0, 12, 464, 75, /* LeftEdge, TopEdge, Width, Height */
- 100, 50, 65535, 65535, /* min width & height, max width & height */
- "Precognition Builder", /* title */
- REFRESHWINDOW, /* IDCMPFlags */
- WINDOWDRAG | WINDOWDEPTH | SIMPLE_REFRESH | ACTIVATE, /* Flags */
- screen );
-
- window->w.SharedUserPort = shared_port;
-
- BoolGadget_Init( &window->bg_ok,
- 182, 56, 96, 14, /* LeftEdge, TopEdge, Width, Height */
- pens, "OK" );
- SetTextAlignment( (GraphicObject *)&window->bg_ok, tx_XCENTER | tx_YCENTER, 0, 0 );
- AddWindowPObject( &window->w, (GraphicObject*) &window->bg_ok );
-
- window->text.FrontPen = 1;
- window->text.BackPen = 0;
- window->text.DrawMode = JAM1;
- window->text.LeftEdge = 10;
- window->text.TopEdge = 20;
- window->text.ITextFont = &pcg_Topaz80;
- window->text.IText = text;
- window->text.NextText = NULL;
-
- }
-
-
- void MsgWindow_CleanUp ( window )
- struct MsgWindow *window;
- {
- CleanUp( (PObject *)&window->w );
- CleanUp( (PObject *)&window->bg_ok );
- }
-
-
- ULONG MsgWindow_Respond ( window, event )
- struct MsgWindow *window;
- struct IntuiMessage *event;
- {
-
- ULONG response, r;
- struct Window *intuition_window;
-
- response = 0L;
-
- /* check to see if 'event' happenned in this window */
- intuition_window = iWindow(&window->w);
- if( event->IDCMPWindow == intuition_window )
- {
- switch( event->Class )
- {
-
- case REFRESHWINDOW:
- BeginRefresh( intuition_window );
- Refresh( (Interactor *)&window->w );
- PrintIText( RPort( &window->w ), &window->text, 0, 0 );
- EndRefresh( intuition_window, TRUE );
- break;
-
- default:
- r = Respond( (Interactor *)&window->bg_ok, event );
- if( r & CHANGED_STATE )
- { /* bg_ok was hit. */
- response |= r;
- window->done = TRUE;
- }
- break;
-
- } /* end switch */
-
- } /* end if */
-
- return response;
- }
-
-
- void do_MsgWindow( char *text )
- {
- struct MsgWindow MsgWindow;
- struct Window *iw; /* Intuition window */
- struct IntuiMessage *imsg, event;
-
- EnableAllChainedWindows( FALSE );
-
- MsgWindow_Init( &MsgWindow, screen, text );
-
- if( ( iw = pcgOpenWindow( &MsgWindow.w ) ) != NULL )
- {
- PrintIText( RPort( &MsgWindow.w ), &MsgWindow.text, 0, 0 );
-
- /*====== Event Loop ================*/
- while ( ! MsgWindow.done )
- {
- imsg = WaitForMessage( shared_port );
- event = *imsg;
- ReplyMsg( (struct Message *)imsg );
-
- MsgWindow_Respond( &MsgWindow, &event );
-
- }
-
- pcgCloseWindow( &MsgWindow.w );
- }
- else /* Error : window couldn't be openned. */
- {
- ; /*** YOUR ERROR HANDLING HERE ***/
- }
-
- MsgWindow_CleanUp( &MsgWindow );
- EnableAllChainedWindows( TRUE );
-
- }
-
-