00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047 #include "drawTv_mouse.h"
00048
00049 #if HAVE_CONFIG_H
00050 #include <config.h>
00051 #endif
00052
00053 #include <string.h>
00054
00055 #if HAVE_STDARG_H
00056 # include <stdarg.h>
00057 # define VA_START(a, f) va_start(a, f)
00058 #else
00059 # if HAVE_VARARGS_H
00060 # include <varargs.h>
00061 # define VA_START(a, f) va_start(a)
00062 # endif
00063 #endif
00064 #ifndef VA_START
00065 error no variadic api available
00066 #endif
00067
00068 #include <tina/sys/sysDef.h>
00069 #include <tina/sys/sysPro.h>
00070 #include <tinatool/draw/draw_TvDef.h>
00071 #include <tinatool/draw/draw_TvPro.h>
00072
00073
00074 Tv_mouse null_mouse(void);
00075
00076 void tv_set_mouse(Tv * tv, Tv_mouse mouse)
00077 {
00078 if (tv == NULL)
00079 return;
00080
00081 tv->mouse = mouse;
00082 if (tv->tv_screen != NULL && tv->activity == MOUSE)
00083 (void) tv_set_activity_message(tv);
00084 }
00085
00086 void tv_set_mouse_reset(Tv * tv, void (*reset) ( ))
00087 {
00088 if (tv->mouse_reset != reset)
00089 {
00090 (*tv->mouse_reset) ();
00091 tv->mouse_reset = reset;
00092 }
00093 }
00094
00095 Tv_mouse null_mouse(void)
00096 {
00097 Tv_mouse mouse = {Tv_mouse_id};
00098
00099 (void) strcpy(mouse.name, "null");
00100
00101 (void) strcpy(mouse.left_name, "null");
00102 mouse.left_down = null_function;
00103 mouse.left_drag = null_function;
00104 mouse.left_up = null_function;
00105
00106 (void) strcpy(mouse.middle_name, "null");
00107 mouse.middle_down = null_function;
00108 mouse.middle_drag = null_function;
00109 mouse.middle_up = null_function;
00110
00111 (void) strcpy(mouse.right_name, "null");
00112 mouse.right_down = null_function;
00113 mouse.right_drag = null_function;
00114 mouse.right_up = null_function;
00115
00116 return (mouse);
00117 }
00118
00119 Tv_mouse
00120 #if HAVE_STDARG_H
00121 mouse_define(int case_flag,...)
00122 #else
00123 mouse_define(case_flag, va_alist)
00124 int case_flag;
00125 va_dcl
00126 #endif
00127 {
00128 Tv_mouse mouse = null_mouse();
00129 va_list ap;
00130
00131 VA_START(ap, case_flag);
00132
00133 while (case_flag)
00134 {
00135 switch (case_flag)
00136 {
00137 case MOUSE_NAME:
00138 (void) strcpy(mouse.name, (char *) va_arg(ap, char *));
00139 break;
00140 case LEFT_NAME:
00141 (void) strcpy(mouse.left_name, (char *) va_arg(ap, char *));
00142 break;
00143 case LEFT_DOWN:
00144 mouse.left_down = (void (*) ()) va_arg(ap, void *);
00145 break;
00146 case LEFT_DRAG:
00147 mouse.left_drag = (void (*) ()) va_arg(ap, void *);
00148 break;
00149 case LEFT_UP:
00150 mouse.left_up = (void (*) ()) va_arg(ap, void *);
00151 break;
00152 case MIDDLE_NAME:
00153 (void) strcpy(mouse.middle_name, (char *) va_arg(ap, char *));
00154 break;
00155 case MIDDLE_DOWN:
00156 mouse.middle_down = (void (*) ()) va_arg(ap, void *);
00157 break;
00158 case MIDDLE_DRAG:
00159 mouse.middle_drag = (void (*) ()) va_arg(ap, void *);
00160 break;
00161 case MIDDLE_UP:
00162 mouse.middle_up = (void (*) ()) va_arg(ap, void *);
00163 break;
00164 case RIGHT_NAME:
00165 (void) strcpy(mouse.right_name, (char *) va_arg(ap, char *));
00166 break;
00167 case RIGHT_DOWN:
00168 mouse.right_down = (void (*) ()) va_arg(ap, void *);
00169 break;
00170 case RIGHT_DRAG:
00171 mouse.right_drag = (void (*) ()) va_arg(ap, void *);
00172 break;
00173 case RIGHT_UP:
00174 mouse.right_up = (void (*) ()) va_arg(ap, void *);
00175 break;
00176 }
00177 case_flag = (int) va_arg(ap, int);
00178 }
00179 va_end(ap);
00180 return (mouse);
00181 }
00182
00183
00184 void tv_mouse_proc(Tv * tv, int state, Ipos pos)
00185 {
00186 Tv_mouse *mouse = &tv->mouse;
00187
00188 switch (state)
00189 {
00190 case LEFT_DOWN:
00191 (*mouse->left_down) (tv, pos);
00192 break;
00193 case LEFT_DRAG:
00194 (*mouse->left_drag) (tv, pos);
00195 break;
00196 case LEFT_UP:
00197 (*mouse->left_up) (tv, pos);
00198 break;
00199 case MIDDLE_DOWN:
00200 (*mouse->middle_down) (tv, pos);
00201 break;
00202 case MIDDLE_DRAG:
00203 (*mouse->middle_drag) (tv, pos);
00204 break;
00205 case MIDDLE_UP:
00206 (*mouse->middle_up) (tv, pos);
00207 break;
00208 case RIGHT_DOWN:
00209 (*mouse->right_down) (tv, pos);
00210 break;
00211 case RIGHT_DRAG:
00212 (*mouse->right_drag) (tv, pos);
00213 break;
00214 case RIGHT_UP:
00215 (*mouse->right_up) (tv, pos);
00216 break;
00217 }
00218 }