home *** CD-ROM | disk | FTP | other *** search
- /*
- *
- * Title : Presentation Manager Front End
- * System : Logger */
- #define Version "1.0"
- /* Copyright : John H. Winters
- * Date : 18th October, 1992
- * Author : John H. Winters
- *
- * Function : Handles the Presentation Manager front end.
- *
- *
- * Modification history.
- *
- * Version :
- * Date :
- * Author :
- * Changes :
- *
- */
-
- #include <stdio.h>
- #include <string.h>
- #include <stdlib.h>
- #include <time.h>
- #include <process.h>
- #define INCL_WINFRAMEMGR
- #define INCL_WINPOINTERS
- #include <os2.h>
-
- #include "global.h"
- #include "logging.h"
- #include "fe.h"
- #include "text.h"
-
- /*
- *============================================================================
- *
- * Hash defines.
- *
- *============================================================================
- */
-
- #define STACK_SIZE 2048
-
- /*
- *============================================================================
- *
- * Local data.
- *
- *============================================================================
- */
-
- static uint AutoDisplay = FALSE ;
- static t_TXT_Handle TextHandle = NULL ;
- static uint ThreadLooping = FALSE ;
- static uint WindowReady = FALSE ;
-
- /*
- *============================================================================
- *
- * Forward declarations.
- *
- *============================================================================
- */
-
- static void PM_Thread (
- void *reference) ;
-
- /*
- *============================================================================
- *
- * Externally visible routines.
- *
- *============================================================================
- */
-
- uint FE_BeginProcessing (void)
-
- /*
- * Function :
- * Start PM processing.
- *
- * Parameters :
- * None.
- *
- * Returns :
- * TRUE for success, FALSE for failure.
- *
- */
-
- {
- sint thread ;
-
- thread = _beginthread (PM_Thread,
- NULL,
- STACK_SIZE,
- NULL) ;
- if (thread == -1)
- {
- LOG_Error ("Failed to start PM thread.\n") ;
- return (FALSE) ;
- }
- else
- {
- return (TRUE) ;
- }
- }
-
-
- uint FE_LoadResources (void)
-
- /*
- * Function :
- * Null routine for now.
- *
- * Parameters :
- * None.
- *
- * Returns :
- * TRUE.
- *
- */
-
- {
- return (TRUE) ;
- }
-
-
- void FE_PutText (
- const U8 *text)
-
- /*
- * Function :
- * Put text to our window. May be called recursively and
- * must cope. Will not be called simultaneously from
- * separate threads.
- *
- * Parameters :
- * text The text to put.
- *
- * Returns :
- * None.
- *
- */
-
- {
- static uint WindowInUse = FALSE ;
-
- if ((WindowReady) &&
- (!WindowInUse))
- {
- WindowInUse = TRUE ;
- if (AutoDisplay)
- {
- TXT_DisplayWindow (TextHandle) ;
- }
- TXT_PutText (TextHandle, text) ;
- WindowInUse = FALSE ;
- }
- else
- {
- /*
- * Need to pop up a PM error box.
- */
- WinMessageBox (HWND_DESKTOP,
- HWND_DESKTOP,
- (u8 *) text,
- NULL,
- 0,
- MB_NOICON | MB_OK) ;
- }
- }
-
-
- void FE_WindDown (void)
-
- /*
- * Function :
- * Instructs the front end to close itself down.
- *
- * Parameters :
- * None.
- *
- * Returns :
- * None.
- *
- */
-
- {
- /*
- * What we do is send a message to the front end telling it the
- * user has clicked on Close.
- */
- if (ThreadLooping)
- {
- TXT_HideWindow (TextHandle) ;
- }
- }
-
- /*
- *============================================================================
- *
- * Local routines.
- *
- *============================================================================
- */
-
- static void PM_Thread (
- void *reference)
-
- /*
- * Function :
- * Presentation Manager polling thread.
- *
- * Parameters :
- * reference Ignored.
- *
- * Returns :
- * None.
- *
- */
-
- {
- HAB hab ;
- HMQ hmq ;
- QMSG qmsg ;
-
- reference = reference ;
- hab = WinInitialize (0) ;
- if (hab == NULL)
- {
- LOG_Error ("Failed to initialize PM.\n") ;
- }
- else
- {
- hmq = WinCreateMsgQueue (hab, DEFAULT_QUEUE_SIZE) ;
- if (hmq == NULL)
- {
- LOG_Error ("Failed to create message queue.\n") ;
- }
- else
- {
- TextHandle = TXT_CreateWindow (hab,
- 20,
- 128) ;
- if (TextHandle == NULL)
- {
- LOG_Error ("Failed to create a text window.\n") ;
- }
- else
- {
- if (TXT_DisplayWindow (TextHandle))
- {
- ThreadLooping = TRUE ;
- while (WinGetMsg (hab, &qmsg, NULL, 0, 0))
- {
- WinDispatchMsg (hab, &qmsg) ;
- }
- ThreadLooping = FALSE ;
- }
- TXT_HideWindow (TextHandle) ;
- }
- WinDestroyMsgQueue (hmq) ;
- }
- WinTerminate (hab) ;
- }
- exit (0) ;
- }
-
-