home *** CD-ROM | disk | FTP | other *** search
/ BCI NET / BCI NET Dec 94.iso / archives / programming / source / gblanker3.5.src.lha / GSource / Blankers / Executor / prefs.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-04  |  2.5 KB  |  135 lines

  1. /*
  2.  *  Copyright (c) 1994 Michael D. Bayne.
  3.  *  All rights reserved.
  4.  *
  5.  *  Please see the documentation accompanying the distribution for distribution
  6.  *  and disclaimer information.
  7.  */
  8.  
  9. #include <libraries/gadtools.h>
  10.  
  11. #include <clib/exec_protos.h>
  12. #include <clib/intuition_protos.h>
  13. #include <clib/gadtools_protos.h>
  14.  
  15. #include <string.h>
  16.  
  17. #include "Executor.h"
  18. #include "Executor_rev.h"
  19. #include "/main.h"
  20. #include "//defs.h"
  21.  
  22. struct ModulePrefs
  23. {
  24.     BYTE StartString[128];
  25.     BYTE StopString[128];
  26. };
  27.  
  28. struct ModulePrefs nP;
  29. VOID *OldPrefs = 0L;
  30. STATIC const UBYTE VersTag[] = VERSTAG;
  31.  
  32. int BT_SAVEClicked( VOID )
  33. {
  34.     if( OldPrefs )
  35.     {
  36.         CopyMem( &nP, OldPrefs, sizeof( struct ModulePrefs ));
  37.         SavePrefs( OldPrefs );
  38.         OldPrefs = 0L;
  39.     }
  40.     
  41.     return QUIT;
  42. }
  43.  
  44. int BT_TESTClicked( VOID )
  45. {
  46.     MessageServer( BM_SENDBLANK );
  47.  
  48.     return OK;
  49. }
  50.  
  51. int BT_CANCELClicked( VOID )
  52. {
  53.     OldPrefs = 0L;
  54.     
  55.     return QUIT;
  56. }
  57.  
  58. int ST_STARTClicked( VOID )
  59. {
  60.     strcpy( nP.StartString, GetString( ExecutorGadgets[GD_ST_START] ));
  61.  
  62.     return OK;
  63. }
  64.  
  65. int ST_KILLClicked( VOID )
  66. {
  67.     strcpy( nP.StopString, GetString( ExecutorGadgets[GD_ST_KILL] ));
  68.  
  69.     return OK;
  70. }
  71.  
  72. #define BL_SetGadgetAttrs( Gad, Tag, Val ) GT_SetGadgetAttrs( ExecutorGadgets[Gad], ExecutorWnd, 0L, Tag, Val, TAG_END )
  73.  
  74. int ExecutorVanillaKey( VOID )
  75. {
  76.     switch( ExecutorMsg.Code ) {
  77.     case 's':
  78.         return BT_SAVEClicked();
  79.     case 't':
  80.         return BT_TESTClicked();
  81.     case 'c':
  82.         return QUIT;
  83.     case 'a':
  84.         ActivateGadget( ExecutorGadgets[GD_ST_START], ExecutorWnd, 0L );
  85.         return OK;
  86.     case 'k':
  87.         ActivateGadget( ExecutorGadgets[GD_ST_KILL], ExecutorWnd, 0L );
  88.         return OK;
  89.     default:
  90.         return OK;
  91.     }
  92. }
  93.  
  94. VOID DoPrefs( LONG command, VOID *Prefs )
  95. {
  96.     switch( command )
  97.     {
  98.     case STARTUP:
  99.         OldPrefs = Prefs;
  100.         CopyMem( Prefs, &nP, sizeof( struct ModulePrefs ));
  101.         if( !SetupScreen())
  102.         {
  103.             ExecutorLeft = ( Scr->Width - ComputeX( ExecutorWidth ))/2 - Scr->WBorRight;
  104.             ExecutorTop = ( Scr->Height - ComputeY( ExecutorHeight ) - Font->ta_YSize )/2 - Scr->WBorBottom;
  105.             if( !OpenExecutorWindow())
  106.             {
  107.                 BL_SetGadgetAttrs( GD_ST_START, GTST_String, nP.StartString );
  108.                 BL_SetGadgetAttrs( GD_ST_KILL, GTST_String, nP.StopString );
  109.             }
  110.             CloseDownScreen();
  111.         }
  112.         break;
  113.     case IDCMP:
  114.         if( HandleExecutorIDCMP() != QUIT )
  115.             break;
  116.     case KILL:
  117.         CloseExecutorWindow();
  118.         break;
  119.     }
  120. }
  121.  
  122. LONG WndSignal( VOID )
  123. {
  124.     return ExecutorWnd ? 1L << ExecutorWnd->UserPort->mp_SigBit : 0L;
  125. }
  126.  
  127. VOID FillDefaults( VOID *Prefs )
  128. {
  129.     struct ModulePrefs mPO;
  130.  
  131.     strcpy( mPO.StartString, "Blah Blah" );
  132.     strcpy( mPO.StopString, "Teleblah" );
  133.     CopyMem( &mPO, Prefs, sizeof( struct ModulePrefs ));
  134. }
  135.