Main Page | Alphabetical List | Data Structures | File List | Data Fields | Globals

drawTv_mouse.c

Go to the documentation of this file.
00001 /*********
00002  * Copyright (c) 2003, Division of Imaging Science and Biomedical Engineering,
00003  * University of Manchester, UK.  All rights reserved.
00004  * 
00005  * Redistribution and use in source and binary forms, with or without modification, 
00006  * are permitted provided that the following conditions are met:
00007  * 
00008  *   . Redistributions of source code must retain the above copyright notice, 
00009  *     this list of conditions and the following disclaimer.
00010  *    
00011  *   . Redistributions in binary form must reproduce the above copyright notice,
00012  *     this list of conditions and the following disclaimer in the documentation 
00013  *     and/or other materials provided with the distribution.
00014  * 
00015  *   . Neither the name of the University of Manchester nor the names of its
00016  *     contributors may be used to endorse or promote products derived from this 
00017  *     software without specific prior written permission.
00018  * 
00019  * 
00020  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
00021  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
00022  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
00023  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
00024  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
00025  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
00026  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00027  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
00028  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
00029  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
00030  * POSSIBILITY OF SUCH DAMAGE.
00031  *
00032  **********
00033  *
00034  * Program :    TINA
00035  * File    :  $Source: /home/tina/cvs/tina-tools/tinatool/draw/drawTv_mouse.c,v $
00036  * Date    :  $Date: 2003/10/01 16:02:47 $
00037  * Version :  $Revision: 1.2 $
00038  * CVS Id  :  $Id: drawTv_mouse.c,v 1.2 2003/10/01 16:02:47 tony Exp $
00039  *
00040  * Author  : Legacy TINA
00041  *
00042  * Notes :
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 /* HAVE_STDARG_H */
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 /* HAVE_STDARG_H */
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 }

Generated on Thu Nov 12 02:20:44 2009 for Tools by doxygen 1.3.6