home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Gold Fish 2
/
goldfish_vol2_cd1.bin
/
files
/
util
/
blank
/
gblanker
/
source
/
blankers
/
clock
/
prefs.c
< prev
next >
Wrap
C/C++ Source or Header
|
1994-10-03
|
4KB
|
212 lines
#include <exec/types.h>
#include <exec/memory.h>
#include <dos/dos.h>
#include <intuition/intuition.h>
#include <intuition/screens.h>
#include <intuition/gadgetclass.h>
#include <libraries/gadtools.h>
#include <libraries/asl.h>
#include <graphics/text.h>
#include <clib/exec_protos.h>
#include <clib/intuition_protos.h>
#include <clib/dos_protos.h>
#include <clib/gadtools_protos.h>
#include <clib/asl_protos.h>
#include "/Garshnelib/Garshnelib_protos.h"
#include "/Garshnelib/Garshnelib_pragmas.h"
#include <string.h>
#include "Clock.h"
#include "Clock_rev.h"
#include "//defs.h"
#include "/main.h"
struct ModulePrefs {
LONG Mode;
LONG Delay;
LONG Cycle;
LONG Secs;
LONG Military;
struct TextAttr Font;
BYTE fName[64];
};
struct ModulePrefs nP;
VOID *OldPrefs = 0L;
STATIC const UBYTE VersTag[] = VERSTAG;
int BT_SAVEClicked( VOID )
{
if( OldPrefs )
{
CopyMem( &nP, OldPrefs, sizeof( struct ModulePrefs ));
SavePrefs( OldPrefs );
OldPrefs = 0L;
}
return QUIT;
}
int BT_TESTClicked( VOID )
{
MessageServer( BM_SENDBLANK );
return OK;
}
int BT_SCREENClicked( VOID )
{
ScreenModeRequest( ClockWnd, &nP.Mode, 0L );
return OK;
}
int BT_CANCELClicked( VOID )
{
OldPrefs = 0L;
return QUIT;
}
int SL_DELAYClicked( VOID )
{
nP.Delay = ClockMsg.Code;
return OK;
}
int CY_MILClicked( VOID )
{
nP.Military = ClockMsg.Code;
return OK;
}
int CY_CYCLEClicked( VOID )
{
nP.Cycle = ClockMsg.Code;
return OK;
}
int CY_SECSClicked( VOID )
{
nP.Secs = ClockMsg.Code;
return OK;
}
int BT_FONTClicked( VOID )
{
struct FontRequester *fReq;
struct Library *AslBase;
AslBase = OpenLibrary( "asl.library", 37L );
if( !AslBase )
return OK;
fReq = ( struct FontRequester * )AllocAslRequestTags( ASL_FontRequest, ASL_FontName,
( LONG )nP.fName, ASL_FontHeight,
nP.Font.ta_YSize, ASL_MaxHeight, 100,
TAG_DONE );
if( fReq )
{
if( AslRequestTags( fReq, ASLFO_Window, ClockWnd, ASLFO_SleepWindow, TRUE, ASLFO_TitleText,
( LONG )"Please choose a font...", 0L ))
{
CopyMem( fReq->fo_Attr.ta_Name, nP.fName, 31 );
nP.Font.ta_YSize = fReq->fo_Attr.ta_YSize;
}
FreeAslRequest( fReq );
}
CloseLibrary( AslBase );
return OK;
}
#define BL_SetGadgetAttrs( Gad, Tag, Val ) GT_SetGadgetAttrs( ClockGadgets[Gad], ClockWnd, 0L, Tag, Val, TAG_END )
int ClockVanillaKey( VOID )
{
switch( ClockMsg.Code ) {
case 's':
return BT_SAVEClicked();
case 't':
return BT_TESTClicked();
case 'd':
return BT_SCREENClicked();
case 'c':
return QUIT;
case 'f':
return BT_FONTClicked();
case 'p':
BL_SetGadgetAttrs( GD_SL_DELAY, GTSL_Level, Inc( nP.Delay, 1, 120 ));
return OK;
case 'S':
BL_SetGadgetAttrs( GD_SL_DELAY, GTSL_Level, Dec( nP.Delay, 1, 0 ));
return OK;
default:
return OK;
}
}
#define ComputeX( x ) ((( FontX * x ) + 4 ) / 8 )
#define ComputeY( x ) ((( FontY * x ) + 4 ) / 8 )
VOID DoPrefs( LONG command, VOID *Prefs )
{
switch( command )
{
case STARTUP:
OldPrefs = Prefs;
CopyMem( Prefs, &nP, sizeof( struct ModulePrefs ));
if( !SetupScreen())
{
ClockLeft = ( Scr->Width - ComputeX( ClockWidth ))/2 - Scr->WBorRight;
ClockTop = ( Scr->Height - ComputeY( ClockHeight ) - Font->ta_YSize )/2 - Scr->WBorBottom;
if( !OpenClockWindow())
{
BL_SetGadgetAttrs( GD_SL_DELAY, GTSL_Level, nP.Delay );
BL_SetGadgetAttrs( GD_CY_MIL, GTCY_Active, nP.Military );
BL_SetGadgetAttrs( GD_CY_CYCLE, GTCY_Active, nP.Cycle );
BL_SetGadgetAttrs( GD_CY_SECS, GTCY_Active, nP.Secs );
}
CloseDownScreen();
}
break;
case IDCMP:
if( HandleClockIDCMP() != QUIT )
break;
case KILL:
CloseClockWindow();
break;
}
}
LONG WndSignal( VOID )
{
return ClockWnd ? 1L << ClockWnd->UserPort->mp_SigBit : 0L;
}
VOID FillDefaults( VOID *Prefs )
{
struct ModulePrefs *NewPrefs = ( struct ModulePrefs * )Prefs;
NewPrefs->Mode = getTopScreenMode();
NewPrefs->Delay = 60L;
NewPrefs->Cycle = 0L;
NewPrefs->Secs = 0L;
NewPrefs->Military = 0L;
NewPrefs->Font.ta_YSize = 11;
NewPrefs->Font.ta_Style = FS_NORMAL;
NewPrefs->Font.ta_Flags = FPB_ROMFONT;
strcpy( NewPrefs->fName, "topaz.font" );
}