home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Elysian Archive
/
AmigaElysianArchive.iso
/
prog
/
c
/
precg105.lha
/
source
/
ArrowGadget.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-12-24
|
4KB
|
166 lines
#include "ArrowGadget.h"
#include "ArrowGadgetClass.h"
#include "AmigaMem.h"
#include <proto/exec.h>
#include <proto/graphics.h>
#include <proto/intuition.h>
typedef struct ArrowHead
{
Border ArrowBorder;
enum ArrowTypes Direction;
} ArrowHead;
ArrowGadget *ArrowGadget_New( ArrowGadget *self )
{
ArrowGadget *new_agadget = NULL;
ArrowHead *head = NULL;
enum ArrowTypes direction = UpArrow;
if (new_agadget = (ArrowGadget *) Amalloc(sizeof(ArrowGadget)))
{
head = (ArrowHead*) self->BoxBorder->BottomRight.NextBorder;
if (head)
direction = head->Direction;
ArrowGadget_Init( new_agadget, self->Location.x, self->Location.y,
direction, self->Pens );
}
return new_agadget;
}
void ArrowGadget_CleanUp( ArrowGadget *self )
{
Afree( self->BoxBorder->BottomRight.NextBorder );
self->BoxBorder->BottomRight.NextBorder = NULL;
}
tPoint ArrowGadget_size = {16,14};
tPoint ArrowGadget_AskSize( ArrowGadget *self )
{
return ArrowGadget_size;
}
BOOL ArrowGadget_elaborated = FALSE;
struct ValuatorClass ArrowGadget_Class;
void ArrowGadgetClass_Init( struct ValuatorClass *class )
{
BoolGadgetClass_Init( class );
class->isa = BoolGadgetClass();
class->ClassName = "ArrowGadget";
/* -------- Commented-out methods are inherited) ----------------*/
/* class->New = ArrowGadget_New;*/
class->CleanUp = ArrowGadget_CleanUp;
/* class->Location = ArrowGadget_Location;*/
/* class->SetLocation = ArrowGadget_SetLocation;*/
/* class->Size = ArrowGadget_Size;*/
/* class->SetSize = ArrowGadget_SetSize;*/
class->AskSize = ArrowGadget_AskSize;
class->SizeFlags = GraphicObject_SizeFlagsNone;
/* class->Render = NULL;*/
/* class->FirstGadget = ArrowGadget_FirstGadget;*/
/* class->nGadgets = ArrowGadget_nGadgets;*/
/* class->IDCMPFlags = ArrowGadget_IDCMPFlags;*/
/* class->ClaimEvent = ArrowGadget_ClaimEvent;*/
/* class->EnableIactor = ArrowGadget_EnableIactor;*/
/* class->isEnabled = ArrowGadget_isEnabled;*/
/* class->Activate = NULL;*/
/* class->isActive = NULL;*/
}
struct ValuatorClass *ArrowGadgetClass( void )
{
if (! ArrowGadget_elaborated)
{
ArrowGadgetClass_Init( &ArrowGadget_Class );
ArrowGadget_elaborated = TRUE;
}
return &ArrowGadget_Class;
}
SHORT UpArrowPoints[] =
{ 4,10, 7,3, 8,3, 11,10, 10,10, 8,5, 7,5, 5,10 };
ArrowHead UpArrowHead =
{ { 0, 0, 0, 0, JAM1, 8, UpArrowPoints, NULL }, UpArrow };
SHORT DownArrowPoints[] =
{ 4,3, 7,10, 8,10, 11,3, 10,3, 8,8, 7,8, 5,3 };
ArrowHead DownArrowHead =
{ { 0, 0, 0, 0, JAM1, 8, DownArrowPoints, NULL }, DownArrow };
SHORT LeftArrowPoints[] =
{ 11,3, 4,6, 4,7, 11,10, 11,9, 6,7, 6,6, 11,4 }; /* ArrowPoints */
ArrowHead LeftArrowHead =
{ { 0, 0, 0, 0, JAM1, 8, LeftArrowPoints, NULL }, LeftArrow };
SHORT RightArrowPoints[] =
{ 4,3, 11,6, 11,7, 4,10, 4,9, 9,7, 9,6, 4,4 }; /* ArrowPoints */
ArrowHead RightArrowHead =
{ { 0, 0, 0, 0, JAM1, 8, RightArrowPoints, NULL }, RightArrow };
void ArrowGadget_Init( ArrowGadget *self,
PIXELS LeftEdge,
PIXELS TopEdge,
enum ArrowTypes Direction,
pcg_3DPens Pens )
{
ArrowHead *Head;
BoolGadget_Init( self, LeftEdge, TopEdge,
ArrowGadget_size.x, ArrowGadget_size.y,
Pens, NULL );
self->isa = ArrowGadgetClass();
self->g.Activation = GADGDURATION;
if (Head = (ArrowHead*) Acalloc(1, sizeof(ArrowHead)))
{
switch (Direction)
{
case UpArrow:
*Head = UpArrowHead;
break;
case DownArrow:
*Head = DownArrowHead;
break;
case LeftArrow:
*Head = LeftArrowHead;
break;
case RightArrow:
*Head = RightArrowHead;
break;
}
self->BoxBorder->BottomRight.NextBorder = (Border *) Head;
Head->Direction = Direction;
Head->ArrowBorder.FrontPen = Pens.FrontPen;
}
}