home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Computer Club Elmshorn Atari PD
/
CCE_PD.iso
/
pc
/
0400
/
CCE_0423.ZIP
/
CCE_0423.PD
/
GEM.ZOO
/
slider.cc
< prev
next >
Wrap
C/C++ Source or Header
|
1992-04-26
|
1KB
|
60 lines
/////////////////////////////////////////////////////////////////////////////
//
// This file is public domain.
//
/////////////////////////////////////////////////////////////////////////////
#include "Slider.h"
Slider::Slider(int knob, int rack, GEMform& f) :
GEMobject(rack,&f),
K(knob,f,this)
{
// Should we enforce this?
TouchExit(TRUE);
K.TouchExit(TRUE);
f.CallBack(this);
f.CallBack(&K);
}
// Not implemented yet...
Slider::operator int() const { return 1; }
Slider::operator double() const { return 1; }
void Slider::operator() (int) {}
void Slider::operator() (double) {}
void Slider::Range(int min, int max) {}
void Slider::touch(int x, int y)
{
int halfw=K.me->ob_width/2;
int halfh=K.me->ob_height/2;
if (x<halfw) x=halfw;
if (y<halfh) y=halfh;
if (x>me->ob_width+halfw-K.me->ob_width) x=me->ob_width-K.me->ob_width+halfw;
if (y>me->ob_height+halfh-K.me->ob_height) y=me->ob_height-K.me->ob_height+halfh;
int OldX=K.me->ob_x,OldY=K.me->ob_y;
int NewX=x-K.me->ob_width/2,NewY=y-K.me->ob_height/2;
if (OldX!=NewX || OldY!=NewY) {
K.MoveTo(x-halfw,y-halfh);
form->RedrawObject(myindex,OldX,OldY,K.me->ob_width,K.me->ob_height);
form->RedrawObject(K.myindex);
}
}
Knob::Knob(int RSCindex, GEMform& f, GEMobject *tell) :
GEMobject(RSCindex,&f),
Tell(tell)
{ }
void Knob::touch(int x, int y)
{
Tell->touch(me->ob_x+x,me->ob_y+y);
}