home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Elysian Archive
/
AmigaElysianArchive.iso
/
prog
/
c
/
precg105.lha
/
source
/
BoolGadget.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-12-24
|
3KB
|
120 lines
#include "BoolGadget.h"
#include "BoolGadgetClass.h"
#include "EmbossedGadgetClass.h"
#include "pcgWindow.h"
#include <proto/exec.h>
#include "amigamem.h"
LONG BoolGadget_Value( BoolGadget *self )
{
return (self->g.Flags & SELECTED);
}
LONG BoolGadget_SetValue( BoolGadget *self, LONG selection )
{
struct pcgWindow *window;
window = InteractorWindow( self );
if (window->Window) /* window is open */
{
/* NOTE: This may not be KOSHER. The PROPER way is to remove
* the gadget from the window list, twiddle its bits, and
* then add it back to the list. (It does work, though.)
*/
Forbid();
if (selection)
self->g.Flags |= SELECTED;
else
self->g.Flags &= (~SELECTED);
Permit();
}
else /* Window is not open, can just do it the easy way */
{
if (selection)
self->g.Flags |= SELECTED;
else
self->g.Flags &= (~SELECTED);
}
return selection;
}
#ifdef BUILDER
#include "BuilderMethods.h"
#include "GraphicObject_Builder.h"
#include "BoolGadget_coder.h"
BoolGadget *BoolGadget_New( BoolGadget *self )
{
BoolGadget *new_self;
if (new_self = (BoolGadget*) Amalloc( sizeof(BoolGadget) ) )
{
char *label = Title(self);
BoolGadget_Init( new_self, self->Location.x, self->Location.y,
self->Size.x, self->Size.y, self->Pens, label );
GiveItAName( new_self );
}
return new_self;
}
struct BuilderMethods BoolGadget_bm;
#endif
BOOL BoolGadget_elaborated = FALSE;
struct ValuatorClass BoolGadget_Class;
void BoolGadgetClass_Init( struct ValuatorClass *class )
{
ValuatorClass_Init( class );
EmbossedGadgetClass_Init( class );
class->isa = ValuatorClass();
class->ClassName = "BoolGadget";
class->Value = BoolGadget_Value;
class->SetValue = BoolGadget_SetValue;
#ifdef BUILDER
class->BuilderMethods = &BoolGadget_bm;
go_InitBuilderMethods( &BoolGadget_bm );
BoolGadget_bm.New = BoolGadget_New;
BoolGadget_bm.WriteCode = BoolGadget_WriteCode;
#endif
}
struct ValuatorClass *BoolGadgetClass( void )
{
if (! BoolGadget_elaborated)
{
BoolGadgetClass_Init( &BoolGadget_Class );
BoolGadget_elaborated = TRUE;
}
return &BoolGadget_Class;
}
void BoolGadget_Init( BoolGadget *self,
PIXELS LeftEdge,
PIXELS TopEdge,
PIXELS Width,
PIXELS Height,
pcg_3DPens Pens,
char *Label )
{
EmbossedGadget_Init( self, LeftEdge, TopEdge, Width, Height,
GADGHCOMP, RELVERIFY, BOOLGADGET,
Pens, Label );
self->isa = BoolGadgetClass();
}