~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Tina4/src/tv/tv_pick.c

Version: ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /**@(#)
  2 **/
  3 #include <stdio.h>
  4 #include <string.h>
  5 #include <math.h>
  6 #include <tina/tv.h>
  7 #include <tina/tvfuncs.h>
  8 #include <tina/sysfuncs.h>
  9 #include <tina/mathfuncs.h>
 10 
 11 void    tv_set_pick(Tv * tv, Tv_pick pick)
 12 {
 13     if (tv == NULL)
 14         return;
 15 
 16     list_rm(tv->pick.picklist, tv->pick.free);
 17     /* tv_repaint(tv);  */
 18 
 19     tv->pick = pick;
 20     if (tv->tv_screen != NULL && tv->activity == PICK)
 21         (void) tv_set_activity_message(tv);
 22 }
 23 
 24 void    tv_set_pick_reset(Tv * tv, void (*reset) ( /* ??? */ ))
 25 {
 26     if (tv->pick_reset != reset)
 27     {
 28         (*tv->pick_reset) ();
 29         tv->pick_reset = reset;
 30     }
 31 }
 32 
 33 void    tv_pick_proc(Tv * tv, int state, Ipos pos)
 34 {
 35     static void *picked;
 36     static int type;
 37     Tv_pick *pick = &tv->pick;
 38     List   *ref_addtostart();
 39 
 40     switch (state)
 41     {
 42     case LEFT_DOWN:
 43         tv_set_overlay(tv);     /* also calls tv_save_draw */
 44         picked = (*pick->closest) (tv, pos, &type);
 45         (*pick->draw) (tv, picked, type);
 46         break;
 47     case LEFT_DRAG:
 48         (*pick->draw) (tv, picked, type);
 49         picked = (*pick->closest) (tv, pos, &type);
 50         (*pick->draw) (tv, picked, type);
 51         break;
 52     case LEFT_UP:
 53         (*pick->draw) (tv, picked, type);
 54         if (picked != NULL)
 55             pick->picklist = ref_addtostart(pick->picklist, picked, type);
 56         tv_reset_draw(tv);
 57         tv_save_draw(tv);
 58         tv_color_set(tv, green);
 59         (*pick->draw) (tv, picked, type);
 60         tv_reset_draw(tv);
 61         break;
 62     case MIDDLE_DOWN:
 63         (*pick->func) (tv, pick->picklist);
 64         list_rm(pick->picklist, pick->free);
 65         pick->picklist = NULL;
 66         if (pick->do_repaint)
 67             tv_repaint(tv);
 68         break;
 69     case RIGHT_DOWN:
 70         list_rm(pick->picklist, pick->free);
 71         pick->picklist = NULL;
 72         if (pick->do_repaint)
 73             tv_repaint(tv);
 74         break;
 75     }
 76 }
 77 
 78 static void *null_closest(void)
 79 {
 80     return (NULL);
 81 }
 82 
 83 Tv_pick null_pick(void)
 84 {
 85     Tv_pick pick = {Tv_pick_id};
 86 
 87     (void) strcpy(pick.name, "null");
 88     pick.picklist = NULL;
 89     pick.closest = null_closest;
 90     pick.highlight = null_function;
 91     pick.draw = null_function;
 92     pick.func = null_function;
 93     pick.free = null_function;
 94     pick.do_repaint = true;
 95     return (pick);
 96 }
 97 
 98 #ifndef ANSIFYING
 99 #ifdef __STRICT_ANSI__
100 
101 Tv_pick pick_define(int case_flag,...)
102 {
103     Tv_pick pick = {Tv_pick_id};
104     va_list ap;
105 
106     va_start(ap, case_flag);
107 
108     pick = null_pick();
109     pick.picklist = NULL;
110     while (case_flag)
111     {
112         switch (case_flag)
113         {
114         case PICK_NAME:
115             (void) strcpy(pick.name, (char *) va_arg(ap, char *));
116             break;
117         case PICK_CLOSEST:
118             pick.closest = (void *((*) ())) va_arg(ap, void *);
119             break;
120         case PICK_HIGHLIGHT:
121             pick.highlight = (void (*) ()) va_arg(ap, void *);
122             break;
123         case PICK_DRAW:
124             pick.draw = (void (*) ()) va_arg(ap, void *);
125             break;
126         case PICK_FUNC:
127             pick.func = (void (*) ()) va_arg(ap, void *);
128             break;
129         case PICK_FREE:
130             pick.free = (void (*) ()) va_arg(ap, void *);
131             break;
132         case PICK_REPAINT:
133             pick.do_repaint = (Bool) va_arg(ap, int);
134             break;
135         }
136         case_flag = (int) va_arg(ap, int);
137     }
138     va_end(ap);
139     return (pick);
140 }
141 
142 #else
143 
144 Tv_pick pick_define(va_alist)
145         va_dcl
146 {
147     Tv_pick pick = {Tv_pick_id};
148     int     case_flag;
149     va_list ap;
150 
151     va_start(ap);
152 
153     pick = null_pick();
154     pick.picklist = NULL;
155     while ((case_flag = (int) va_arg(ap, int)) != NULL)
156     {
157         switch (case_flag)
158         {
159         case PICK_NAME:
160             (void) strcpy(pick.name, (char *) va_arg(ap, char *));
161             break;
162         case PICK_CLOSEST:
163             pick.closest = (void *((*) ())) va_arg(ap, void *);
164             break;
165         case PICK_HIGHLIGHT:
166             pick.highlight = (void (*) ()) va_arg(ap, void *);
167             break;
168         case PICK_DRAW:
169             pick.draw = (void (*) ()) va_arg(ap, void *);
170             break;
171         case PICK_FUNC:
172             pick.func = (void (*) ()) va_arg(ap, void *);
173             break;
174         case PICK_FREE:
175             pick.free = (void (*) ()) va_arg(ap, void *);
176             break;
177         case PICK_REPAINT:
178             pick.do_repaint = (Bool) va_arg(ap, int);
179             break;
180         }
181     }
182     va_end(ap);
183     return (pick);
184 }
185 
186 #endif                          /* __STRICT_ANSI__ */
187 #endif                          /* ANSIFYING */
188 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.