home *** CD-ROM | disk | FTP | other *** search
/ Amiga Elysian Archive / AmigaElysianArchive.iso / prog / c / precg105.lha / source / VSlider.c < prev    next >
C/C++ Source or Header  |  1992-12-24  |  4KB  |  181 lines

  1. /* ==========================================================================
  2. **
  3. **                         VSlider.c
  4. ** ©1991 WILLISoft
  5. **
  6. ** ==========================================================================
  7. */
  8.  
  9. #include <stdio.h>
  10. #include "minmax.h"
  11. #include "Vslider.h"
  12. #include "VSliderClass.h"
  13. #include <proto/exec.h>
  14. #include <proto/intuition.h>
  15. #include <proto/graphics.h>
  16. #include "amigamem.h"
  17.  
  18.  
  19.    tPoint VSlider_AskSize( VSlider *self,
  20.                            PIXELS  Width,
  21.                            PIXELS  Height )
  22.    {
  23.       tPoint size;
  24.  
  25.       size.x = MAX( Width,  10 );
  26.       size.y = MAX( Height, 20 );
  27.  
  28.       return size;
  29.    }
  30.  
  31.  
  32.  
  33.    LONG VSlider_Value( VSlider *self )
  34.    {
  35.       return self->Prop.VertPot;
  36.    }
  37.  
  38.  
  39.    USHORT VSlider_KnobSize( VSlider *self )
  40.    {
  41.       return self->Prop.VertBody;
  42.    }
  43.  
  44.  
  45.    LONG VSlider_SetValue( VSlider *self, LONG value )
  46.    {
  47.       struct pcgWindow *window;
  48.       struct PropInfo   propinfo;
  49.       USHORT position;
  50.       
  51.       position = value;
  52.       propinfo = self->Prop;
  53.  
  54.       if ((window = InteractorWindow( self )) &&
  55.           (window->Window))
  56.       {
  57.          NewModifyProp( &self->eg.g, window->Window, NULL, propinfo.Flags,
  58.             propinfo.HorizPot,  position,
  59.             propinfo.HorizBody, propinfo.VertBody,
  60.             1 );
  61.       }
  62.       else
  63.       {
  64.          self->Prop.VertPot  = position;
  65.       }
  66.  
  67.       return position;
  68.    }
  69.  
  70.  
  71.    USHORT VSlider_SetKnobSize( VSlider *self, USHORT knobsize )
  72.    {
  73.       struct pcgWindow *window;
  74.       struct PropInfo   propinfo;
  75.  
  76.       propinfo = self->Prop;
  77.  
  78.       if ((window = InteractorWindow( self )) &&
  79.           (window->Window))
  80.       {
  81.          NewModifyProp( &self->eg.g, window->Window, NULL, propinfo.Flags,
  82.             propinfo.HorizPot,  propinfo.VertPot,
  83.             propinfo.HorizBody, knobsize,
  84.             1 );
  85.       }
  86.       else
  87.       {
  88.          self->Prop.VertBody = knobsize;
  89.       }
  90.  
  91.       return knobsize;
  92.    }
  93.  
  94.    #ifdef BUILDER
  95.    #include "BuilderMethods.h"
  96.    #include "GraphicObject_Builder.h"
  97.    #include "Positioner_Builder.h"
  98.    #include "Positioner_Coder.h"
  99.  
  100.    Slider *VSlider_New( VSlider *self )
  101.    {
  102.       Slider *new_vslider = NULL;
  103.       Point loc, size;
  104.  
  105.       if (new_vslider = (VSlider *) Amalloc(sizeof(VSlider)))
  106.       {
  107.          loc  = Location(self);
  108.          size = Size(self);
  109.  
  110.          VSlider_Init( new_vslider, loc.x, loc.y, size.x, size.y,
  111.                        self->eg.Pens, Title(self) );
  112.          GiveItAName( new_vslider );
  113.       }
  114.       return new_vslider;
  115.    }
  116.    struct BuilderMethods VSlider_bm;
  117.    #endif
  118.  
  119.  
  120.    BOOL VSlider_elaborated = FALSE;
  121.  
  122.    struct PositionerClass VSlider_Class;
  123.  
  124.    void VSliderClass_Init( struct PositionerClass *class )
  125.    {
  126.       SliderClass_Init( class );
  127.       class->isa         = SliderClass();
  128.       class->ClassName   = "VSlider";
  129.       class->AskSize     = VSlider_AskSize;
  130.       class->SetValue    = VSlider_SetValue;
  131.       class->Value       = VSlider_Value;
  132.       class->SetKnobSize = VSlider_SetKnobSize;
  133.       class->KnobSize    = VSlider_KnobSize;
  134.  
  135.    #ifdef BUILDER
  136.       go_InitBuilderMethods( &VSlider_bm );
  137.       VSlider_bm.New        = VSlider_New;
  138.       VSlider_bm.PropEdit   = Positioner_PropEdit;
  139.       VSlider_bm.WriteCode  = Positioner_WriteCode;
  140.       class->BuilderMethods = &VSlider_bm;
  141.    #endif
  142.  
  143.    }
  144.  
  145.  
  146.    struct PositionerClass *VSliderClass( void )
  147.    {
  148.       if (! VSlider_elaborated)
  149.       {
  150.          VSliderClass_Init( &VSlider_Class );
  151.          VSlider_elaborated = TRUE;
  152.       }
  153.  
  154.       return &VSlider_Class;
  155.    }
  156.  
  157.  
  158.    void VSlider_Init( VSlider    *self,
  159.                       PIXELS     LeftEdge,
  160.                       PIXELS     TopEdge,
  161.                       PIXELS     Width,
  162.                       PIXELS     Height,
  163.                       pcg_3DPens Pens,
  164.                       char      *label )
  165.    {
  166.       Point size;
  167.  
  168.       size = VSlider_AskSize( self, Width, Height );
  169.  
  170.       Slider_Init( self, LeftEdge, TopEdge, size.x, size.y, Pens );
  171.       SetTitle( self, label );
  172.       SetTextAlignment( self, tx_XCENTER | tx_BOTTOM | tx_OUTSIDE, STD_XPAD, STD_YPAD );
  173.  
  174.       self->eg.isa        = VSliderClass();
  175.       self->Prop.Flags   |= FREEVERT;
  176.       self->Prop.VertBody = 0x4000;
  177.    }
  178.  
  179.  
  180.  
  181.