home *** CD-ROM | disk | FTP | other *** search
- /* ==========================================================================
- **
- ** HScroller.c
- **
- ** ©1991 WILLISoft
- **
- ** ==========================================================================
- */
-
- #include <string.h>
- #include "HScroller.h"
- #include "minmax.h"
- #include "HScrollerClass.h"
- #include "EmbossedGadgetClass.h"
- #include <proto/exec.h>
- #include "amigamem.h"
-
-
-
- tPoint HScroller_SetLocation( HScroller *self,
- PIXELS LeftEdge,
- PIXELS TopEdge )
- {
-
- Point Left_size, Slider_size;
- Point Left_pos, Right_pos;
-
-
- Left_size = Size( &self->leftarrow );
- Slider_size = Size( &self->hslider );
-
- SetLocation( &self->hslider, LeftEdge, TopEdge );
-
- Left_pos.x = LeftEdge + Slider_size.x;
- Left_pos.y = TopEdge;
- SetLocation( &self->leftarrow, Left_pos.x, Left_pos.y );
-
- Right_pos.x = Left_pos.x + Left_size.x;
- Right_pos.y = TopEdge;
- SetLocation( &self->rightarrow, Right_pos.x, Right_pos.y );
-
- self->posr.Location.x = LeftEdge;
- self->posr.Location.y = TopEdge;
-
- return Location( self );
- }
-
-
- tPoint HScroller_private_AskSize( HScroller *self,
- PIXELS Width,
- PIXELS Height,
- Point *Left_size,
- Point *Right_size,
- Point *Slider_size )
- {
- Point size;
-
- *Left_size = AskSize( &self->leftarrow, 0, 0 );
- *Right_size = AskSize( &self->rightarrow, 0, 0 );
-
- Slider_size->x = Width - (Left_size->x + Right_size->x);
- Slider_size->y = MAX( Left_size->y, Right_size->y );
-
- *Slider_size = AskSize( &self->hslider, Slider_size->x, Slider_size->y );
-
- size.x = Slider_size->x + Left_size->x + Right_size->x;
- size.y = Slider_size->y;
-
- return size;
- }
-
-
- tPoint HScroller_AskSize( HScroller *self,
- PIXELS Width,
- PIXELS Height )
- {
- Point Left_size, Right_size, Slider_size, size;
-
- size = HScroller_private_AskSize( self, Width, Height,
- &Left_size, &Right_size, &Slider_size );
-
- return size;
- }
-
-
- tPoint HScroller_SetSize( HScroller *self,
- PIXELS Width,
- PIXELS Height )
- {
-
- tPoint Left_size, Right_size, Slider_size, size;
- tPoint pos;
-
- size = HScroller_private_AskSize( self, Width, Height,
- &Left_size, &Right_size, &Slider_size );
-
- SetSize( &self->leftarrow, Left_size.x, Left_size.y );
- SetSize( &self->rightarrow, Right_size.x, Right_size.y );
- SetSize( &self->hslider, Slider_size.x, Slider_size.y );
-
- /* Now must fix the positions of leftarrow, down arrow. */
-
- pos = Location( self );
- SetLocation( self, pos.x, pos.y );
- self->posr.Size = size;
-
- return size;
- }
-
-
- #ifdef BUILDER
- #include "BuilderMethods.h"
- #include "GraphicObject_Builder.h"
- #include "Positioner_Builder.h"
- #include "Positioner_coder.h"
-
- struct BuilderMethods HScroller_bm;
-
- HScroller *HScroller_New( HScroller *self )
- {
- HScroller *new_HScroller = NULL;
-
- if (new_HScroller = (HScroller *) Amalloc(sizeof(HScroller)))
- {
- HScroller_Init( new_HScroller, self->posr.Location.x, self->posr.Location.y,
- self->posr.Size.x, self->Pens,
- Title(self) );
- GiveItAName( new_HScroller );
- }
- return new_HScroller;
- }
-
- #endif
-
-
- BOOL HScroller_elaborated = FALSE;
-
- struct PositionerClass HScroller_Class;
-
- #include "VScrollerClass.h"
-
- void HScrollerClass_Init( struct PositionerClass *class )
- {
- PositionerClass_Init( class );
- class->isa = PositionerClass();
- class->ClassName = "HScroller";
- class->CleanUp = VScroller_CleanUp;
- class->SetLocation = HScroller_SetLocation;
- class->AskSize = HScroller_AskSize;
- class->SetSize = HScroller_SetSize;
- class->SizeFlags = GraphicObject_SizeFlagsX;
- class->Render = VScroller_Render;
- class->SetInteractorWindow = VScroller_SetInteractorWindow;
- class->FirstGadget = VScroller_FirstGadget;
- class->nGadgets = VScroller_nGadgets;
- class->IDCMPFlags = VScroller_IDCMPFlags;
- class->ClaimEvent = VScroller_ClaimEvent;
- class->Respond = VScroller_Respond;
- class->Refresh = VScroller_Refresh;
- class->EnableIactor = VScroller_EnableIactor;
- class->isEnabled = EmbossedGadget_isEnabled;
- class->Activate = NULL;
- class->isActive = NULL;
- class->SetKnobSize = VScroller_SetKnobSize;
- class->SetValue = VScroller_SetValue;
- class->KnobSize = VScroller_KnobSize;
- class->Value = VScroller_Value;
- class->Title = VScroller_Title;
- class->TextAlignment = VScroller_TextAlignment;
- class->SetTitle = VScroller_SetTitle;
- class->SetTextAlignment = VScroller_SetTextAlignment;
- #ifdef BUILDER
- go_InitBuilderMethods( &HScroller_bm );
- HScroller_bm.New = HScroller_New;
- HScroller_bm.PropEdit = Positioner_PropEdit;
- HScroller_bm.WriteCode = Positioner_WriteCode;
- class->BuilderMethods = &HScroller_bm;
- #endif
-
- }
-
-
- struct PositionerClass *HScrollerClass( void )
- {
- if (! HScroller_elaborated)
- {
- HScrollerClass_Init( &HScroller_Class );
- HScroller_elaborated = TRUE;
- }
-
- return &HScroller_Class;
- }
-
-
-
-
- void HScroller_Init( HScroller *self,
- PIXELS LeftEdge,
- PIXELS TopEdge,
- PIXELS Width,
- pcg_3DPens Pens,
- char *label )
- {
- Gadget *g;
-
- Positioner_Init(self);
-
- self->posr.isa = HScrollerClass();
- self->posr.Location.x = LeftEdge;
- self->posr.Location.y = TopEdge;
- self->Pens = Pens;
-
- /*
- ** Initialize objects with dumb values, just so that they are now
- ** proper objects.
- */
-
- ArrowGadget_Init( &self->leftarrow, LeftEdge, TopEdge,
- LeftArrow, Pens );
- ArrowGadget_Init( &self->rightarrow, LeftEdge, TopEdge,
- RightArrow, Pens );
- HSlider_Init( &self->hslider, LeftEdge, TopEdge, 0, 0, Pens, NULL );
- self->hslider.eg.Next = &self->leftarrow;
- self->leftarrow.Next = &self->rightarrow;
-
- SetSize( self, Width, 0 );
-
- /* Chain the gadgets together. */
- g = FirstGadget( self );
- ChainGadgets( g, FirstGadget( &self->leftarrow ) );
- ChainGadgets( g, FirstGadget( &self->rightarrow ) );
-
- SetTitle( self, label );
- SetTextAlignment( self, tx_OUTSIDE | tx_LEFT | tx_YCENTER,
- STD_XPAD, STD_YPAD );
-
- }
-