home *** CD-ROM | disk | FTP | other *** search
/ Gold Fish 2 / goldfish_vol2_cd1.bin / files / util / blank / gblanker / source / blankers / plasma / prefs.c < prev    next >
C/C++ Source or Header  |  1994-10-04  |  3KB  |  148 lines

  1. #include <exec/types.h>
  2. #include <exec/memory.h>
  3.  
  4. #include <intuition/intuition.h>
  5. #include <intuition/screens.h>
  6.  
  7. #include <libraries/gadtools.h>
  8.  
  9. #include <clib/exec_protos.h>
  10. #include <clib/intuition_protos.h>
  11. #include <clib/gadtools_protos.h>
  12.  
  13. #include "/Garshnelib/Garshnelib_protos.h"
  14. #include "/Garshnelib/Garshnelib_pragmas.h"
  15.  
  16. #include "Plasma.h"
  17. #include "Plasma_rev.h"
  18. #include "/main.h"
  19. #include "//defs.h"
  20.  
  21. struct fPrefObject
  22. {
  23.     LONG Mode;
  24.     LONG Depth;
  25.     LONG LimDimen;
  26.     LONG ExtendPal;
  27. };
  28.  
  29. struct fPrefObject nP;
  30. VOID *OldPrefs = 0L;
  31. STATIC const UBYTE VersTag[] = VERSTAG;
  32.  
  33. int BT_SAVEClicked( VOID )
  34. {
  35.     if( OldPrefs )
  36.     {
  37.         CopyMem( &nP, OldPrefs, sizeof( struct fPrefObject ));
  38.         SavePrefs( OldPrefs );
  39.         OldPrefs = 0L;
  40.     }
  41.     
  42.     return QUIT;
  43. }
  44.  
  45. int BT_TESTClicked( VOID )
  46. {
  47.     MessageServer( BM_SENDBLANK );
  48.  
  49.     return OK;
  50. }
  51.  
  52. int BT_SCREENClicked( VOID )
  53. {
  54.         ScreenModeRequest( PlasmaWnd, &nP.Mode, &nP.Depth );
  55.  
  56.         return OK;
  57. }
  58.  
  59. int BT_CANCELClicked( VOID )
  60. {
  61.     OldPrefs = 0L;
  62.     
  63.     return QUIT;
  64. }
  65.  
  66. int CY_DIMENClicked( VOID )
  67. {
  68.     nP.LimDimen = PlasmaMsg.Code;
  69.     
  70.     return OK;
  71. }
  72.  
  73. int SL_EXTPALClicked( VOID )
  74. {
  75.     nP.ExtendPal = PlasmaMsg.Code;
  76.  
  77.     return OK;
  78. }
  79.  
  80. #define BL_SetGadgetAttrs( Gad, Tag, Val ) GT_SetGadgetAttrs( PlasmaGadgets[Gad], PlasmaWnd, 0L, Tag, Val, TAG_END )
  81.  
  82. int PlasmaVanillaKey( VOID )
  83. {
  84.     switch( PlasmaMsg.Code ) {
  85.     case 's':
  86.         return BT_SAVEClicked();
  87.     case 't':
  88.         return BT_TESTClicked();
  89.     case 'c':
  90.         return QUIT;
  91.     case 'l':
  92.         BL_SetGadgetAttrs( GD_CY_DIMEN, GTCY_Active, 1 - nP.LimDimen );
  93.         return OK;
  94.     case 'L':
  95.         BL_SetGadgetAttrs( GD_CY_DIMEN, GTCY_Active, 1 - nP.LimDimen );
  96.         return OK;
  97.     case 'p':
  98.         BL_SetGadgetAttrs( GD_SL_EXTPAL, GTSL_Level, Inc( nP.ExtendPal, 1, 4 ));
  99.         return OK;
  100.     case 'P':
  101.         BL_SetGadgetAttrs( GD_SL_EXTPAL, GTSL_Level, Dec( nP.ExtendPal, 1, 0 ));
  102.         return OK;
  103.     default:
  104.         return OK;
  105.     }
  106. }
  107.  
  108. VOID DoPrefs( LONG command, VOID *Prefs )
  109. {
  110.     switch( command )
  111.     {
  112.     case STARTUP:
  113.         OldPrefs = Prefs;
  114.         CopyMem( Prefs, &nP, sizeof( struct fPrefObject ));
  115.         if( !SetupScreen())
  116.         {
  117.             PlasmaLeft = ( Scr->Width - ComputeX( PlasmaWidth ))/2 - Scr->WBorRight;
  118.             PlasmaTop = ( Scr->Height - ComputeY( PlasmaHeight ) - Font->ta_YSize )/2 - Scr->WBorBottom;
  119.             if( !OpenPlasmaWindow())
  120.             {
  121.                 BL_SetGadgetAttrs( GD_CY_DIMEN, GTCY_Active, nP.LimDimen );
  122.                 BL_SetGadgetAttrs( GD_SL_EXTPAL, GTSL_Level, nP.ExtendPal );
  123.             }
  124.             CloseDownScreen();
  125.         }
  126.         break;
  127.     case IDCMP:
  128.         if( HandlePlasmaIDCMP() != QUIT )
  129.             break;
  130.     case KILL:
  131.         ClosePlasmaWindow();
  132.         break;
  133.     }
  134. }
  135.  
  136. LONG WndSignal( VOID )
  137. {
  138.     return PlasmaWnd ? 1L << PlasmaWnd->UserPort->mp_SigBit : 0L;
  139. }
  140.  
  141. VOID FillDefaults( VOID *Prefs )
  142. {
  143.     struct fPrefObject fPO = { 0L, 4L, 0L, 2L };
  144.  
  145.     fPO.Mode = getTopScreenMode();
  146.     CopyMem( &fPO, Prefs, sizeof( struct fPrefObject ));
  147. }
  148.