home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Amiga Elysian Archive
/
AmigaElysianArchive.iso
/
prog
/
c
/
precg105.lha
/
source
/
VSlider.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-12-24
|
4KB
|
181 lines
/* ==========================================================================
**
** VSlider.c
** ©1991 WILLISoft
**
** ==========================================================================
*/
#include <stdio.h>
#include "minmax.h"
#include "Vslider.h"
#include "VSliderClass.h"
#include <proto/exec.h>
#include <proto/intuition.h>
#include <proto/graphics.h>
#include "amigamem.h"
tPoint VSlider_AskSize( VSlider *self,
PIXELS Width,
PIXELS Height )
{
tPoint size;
size.x = MAX( Width, 10 );
size.y = MAX( Height, 20 );
return size;
}
LONG VSlider_Value( VSlider *self )
{
return self->Prop.VertPot;
}
USHORT VSlider_KnobSize( VSlider *self )
{
return self->Prop.VertBody;
}
LONG VSlider_SetValue( VSlider *self, LONG value )
{
struct pcgWindow *window;
struct PropInfo propinfo;
USHORT position;
position = value;
propinfo = self->Prop;
if ((window = InteractorWindow( self )) &&
(window->Window))
{
NewModifyProp( &self->eg.g, window->Window, NULL, propinfo.Flags,
propinfo.HorizPot, position,
propinfo.HorizBody, propinfo.VertBody,
1 );
}
else
{
self->Prop.VertPot = position;
}
return position;
}
USHORT VSlider_SetKnobSize( VSlider *self, USHORT knobsize )
{
struct pcgWindow *window;
struct PropInfo propinfo;
propinfo = self->Prop;
if ((window = InteractorWindow( self )) &&
(window->Window))
{
NewModifyProp( &self->eg.g, window->Window, NULL, propinfo.Flags,
propinfo.HorizPot, propinfo.VertPot,
propinfo.HorizBody, knobsize,
1 );
}
else
{
self->Prop.VertBody = knobsize;
}
return knobsize;
}
#ifdef BUILDER
#include "BuilderMethods.h"
#include "GraphicObject_Builder.h"
#include "Positioner_Builder.h"
#include "Positioner_Coder.h"
Slider *VSlider_New( VSlider *self )
{
Slider *new_vslider = NULL;
Point loc, size;
if (new_vslider = (VSlider *) Amalloc(sizeof(VSlider)))
{
loc = Location(self);
size = Size(self);
VSlider_Init( new_vslider, loc.x, loc.y, size.x, size.y,
self->eg.Pens, Title(self) );
GiveItAName( new_vslider );
}
return new_vslider;
}
struct BuilderMethods VSlider_bm;
#endif
BOOL VSlider_elaborated = FALSE;
struct PositionerClass VSlider_Class;
void VSliderClass_Init( struct PositionerClass *class )
{
SliderClass_Init( class );
class->isa = SliderClass();
class->ClassName = "VSlider";
class->AskSize = VSlider_AskSize;
class->SetValue = VSlider_SetValue;
class->Value = VSlider_Value;
class->SetKnobSize = VSlider_SetKnobSize;
class->KnobSize = VSlider_KnobSize;
#ifdef BUILDER
go_InitBuilderMethods( &VSlider_bm );
VSlider_bm.New = VSlider_New;
VSlider_bm.PropEdit = Positioner_PropEdit;
VSlider_bm.WriteCode = Positioner_WriteCode;
class->BuilderMethods = &VSlider_bm;
#endif
}
struct PositionerClass *VSliderClass( void )
{
if (! VSlider_elaborated)
{
VSliderClass_Init( &VSlider_Class );
VSlider_elaborated = TRUE;
}
return &VSlider_Class;
}
void VSlider_Init( VSlider *self,
PIXELS LeftEdge,
PIXELS TopEdge,
PIXELS Width,
PIXELS Height,
pcg_3DPens Pens,
char *label )
{
Point size;
size = VSlider_AskSize( self, Width, Height );
Slider_Init( self, LeftEdge, TopEdge, size.x, size.y, Pens );
SetTitle( self, label );
SetTextAlignment( self, tx_XCENTER | tx_BOTTOM | tx_OUTSIDE, STD_XPAD, STD_YPAD );
self->eg.isa = VSliderClass();
self->Prop.Flags |= FREEVERT;
self->Prop.VertBody = 0x4000;
}