home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Dream 52
/
Amiga_Dream_52.iso
/
Linux
/
Enlightenment
/
enl14.tgz
/
enl14.tar
/
enl14
/
events.c
< prev
next >
Wrap
C/C++ Source or Header
|
1997-11-21
|
3KB
|
189 lines
#include "enl.h"
void HandleEvent(XEvent *ev)
{
int type;
type=ev->type;
switch (ev->type)
{
case KeyPress:
break;
case KeyRelease:
break;
case ButtonPress:
HandlePress(ev);
break;
case ButtonRelease:
HandleRelease(ev);
break;
case MotionNotify:
while (XCheckTypedEvent(disp,type,ev));
HandleMotion(ev);
break;
case EnterNotify:
HandleIn(ev);
break;
case LeaveNotify:
HandleOut(ev);
break;
case FocusIn:
break;
case FocusOut:
break;
case DestroyNotify:
break;
case UnmapNotify:
break;
case MapRequest:
break;
case ConfigureRequest:
break;
case ResizeRequest:
break;
case CirculateRequest:
break;
case PropertyNotify:
break;
case ClientMessage:
break;
default:
break;
}
}
void HandlePress(XEvent *ev)
{
Button *b;
Slider *s;
int type;
b=FindWindowID(ev->xbutton.window,LIST_TYPE_BUTTON,&type);
if (b)
{
if (b->state==STATE_DISABLED) return;
ButtonClick(b,1);
mode.mode=MODE_NONE;
mode.strip=b->strip;
mode.button=b;
mode.px=ev->xbutton.x_root;
mode.py=ev->xbutton.y_root;
DoAction(ev,b->actions,b->num);
}
s=FindWindowID(ev->xbutton.window,LIST_TYPE_SLIDER,&type);
if (s)
{
SliderClick(s,1);
mode.mode=MODE_MOVE_SLIDER;
mode.slider=s;
mode.px=ev->xbutton.x_root;
mode.py=ev->xbutton.y_root;
return;
}
}
void HandleRelease(XEvent *ev)
{
Button *b;
Slider *s;
int type;
b=FindWindowID(ev->xbutton.window,LIST_TYPE_BUTTON,&type);
if (b)
{
if (b->state==STATE_DISABLED) return;
ButtonClick(b,0);
mode.mode=MODE_NONE;
mode.strip=b->strip;
mode.button=b;
DoAction(ev,b->actions,b->num);
return;
}
s=FindWindowID(ev->xbutton.window,LIST_TYPE_SLIDER,&type);
if (s)
{
SetSliderValue(s,GetSliderValue(s));
SliderClick(s,0);
mode.mode=MODE_NONE;
mode.slider=NULL;
return;
}
}
void HandleIn(XEvent *ev)
{
Button *b;
Slider *s;
int type;
b=FindWindowID(ev->xcrossing.window,LIST_TYPE_BUTTON,&type);
if (b)
{
if (b->state==STATE_DISABLED) return;
ButtonHilite(b,1);
mode.strip=b->strip;
mode.button=b;
DoAction(ev,b->actions,b->num);
}
s=FindWindowID(ev->xbutton.window,LIST_TYPE_SLIDER,&type);
if (s)
{
SliderHilite(s,1);
return;
}
}
void HandleOut(XEvent *ev)
{
Button *b;
Slider *s;
int type;
b=FindWindowID(ev->xcrossing.window,LIST_TYPE_BUTTON,&type);
if (b)
{
if (b->state==STATE_DISABLED) return;
ButtonHilite(b,0);
mode.strip=b->strip;
mode.button=b;
DoAction(ev,b->actions,b->num);
}
s=FindWindowID(ev->xbutton.window,LIST_TYPE_SLIDER,&type);
if (s)
{
SliderHilite(s,0);
return;
}
}
void HandleMotion(XEvent *ev)
{
int dx,dy;
if (mode.mode==MODE_MOVE_STRIP)
{
dx=ev->xmotion.x_root-mode.px;
dy=ev->xmotion.y_root-mode.py;
MoveStripBy(mode.strip,dx,dy);
mode.px+=dx;
mode.py+=dy;
}
else if (mode.mode==MODE_MOVE_BUTTON)
{
dx=ev->xmotion.x_root-mode.px;
dy=ev->xmotion.y_root-mode.py;
MoveButtonBy(mode.button,dx,dy);
mode.px+=dx;
mode.py+=dy;
}
else if (mode.mode==MODE_MOVE_SLIDER)
{
dx=ev->xmotion.x_root-mode.px;
dy=ev->xmotion.y_root-mode.py;
HandleSliderMouse(mode.slider,dx,dy);
mode.px+=dx;
mode.py+=dy;
DoSimpleAction(&mode.slider->action);
}
}