| 1 |
/* @(#)iic.c 19.1 (ESO-DMD) 02/25/03 13:54:47 */ |
| 2 |
/*=========================================================================== |
| 3 |
Copyright (C) 1995 European Southern Observatory (ESO) |
| 4 |
|
| 5 |
This program is free software; you can redistribute it and/or |
| 6 |
modify it under the terms of the GNU General Public License as |
| 7 |
published by the Free Software Foundation; either version 2 of |
| 8 |
the License, or (at your option) any later version. |
| 9 |
|
| 10 |
This program is distributed in the hope that it will be useful, |
| 11 |
but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 |
GNU General Public License for more details. |
| 14 |
|
| 15 |
You should have received a copy of the GNU General Public |
| 16 |
License along with this program; if not, write to the Free |
| 17 |
Software Foundation, Inc., 675 Massachusetts Ave, Cambridge, |
| 18 |
MA 02139, USA. |
| 19 |
|
| 20 |
Correspondence concerning ESO-MIDAS should be addressed as follows: |
| 21 |
Internet e-mail: [email protected] |
| 22 |
Postal address: European Southern Observatory |
| 23 |
Data Management Division |
| 24 |
Karl-Schwarzschild-Strasse 2 |
| 25 |
D 85748 Garching bei Muenchen |
| 26 |
GERMANY |
| 27 |
===========================================================================*/ |
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
/* ----------------------------------------------------------------- */ |
| 32 |
/* --------- IIC -------------------------------------------------- */ |
| 33 |
|
| 34 |
/* ----------------------------------------------------------------- */ |
| 35 |
/* !! all cursor coords are relative to the associated memory !! */ |
| 36 |
/* !! (or to the ididev in case of memory = -1) !! */ |
| 37 |
/* !! (0,0 = bottom left) */ |
| 38 |
/* ----------------------------------------------------------------- */ |
| 39 |
|
| 40 |
/* file IIC.C : contains the following routines |
| 41 |
* |
| 42 |
* IICINC_C : Initialize Cursor; |
| 43 |
* IICSCV_C : Set Cursor Visibility; |
| 44 |
* IICRCP_C : Read Cursor Position; |
| 45 |
* IICWCP_C : Write Cursor Position; |
| 46 |
* |
| 47 |
*********************************************************************** |
| 48 |
* V 1.1 871201: P. Santin - Trieste Astronomical Observatory * |
| 49 |
* V 2.0 881208: K. Banse - ESO Garching * |
| 50 |
|
| 51 |
010514 last modif |
| 52 |
|
| 53 |
*********************************************************************** |
| 54 |
*/ |
| 55 |
|
| 56 |
|
| 57 |
# include <idi.h> |
| 58 |
# include <idistruct.h> |
| 59 |
# include <proto_idi.h> |
| 60 |
|
| 61 |
static int i, dxsize, dysize; |
| 62 |
|
| 63 |
static CURS_DATA *curs; |
| 64 |
static CONF_DATA *conf; |
| 65 |
static MEM_DATA *mem; |
| 66 |
|
| 67 |
|
| 68 |
/************************************************************************ |
| 69 |
* IICINC_C routine : initialize cursor * |
| 70 |
* * |
| 71 |
* synopsis IICINC_C (display , memid , curn , cursh , curcol , xcur , * |
| 72 |
* ycur); * |
| 73 |
* * |
| 74 |
* int display; input display identifier * |
| 75 |
* int memid; input memory identifier * |
| 76 |
* int curn; input cursor number * |
| 77 |
* int cursh; input cursor shape * |
| 78 |
* int curcol; input cursor color * |
| 79 |
* int xcur; input X cursor position * |
| 80 |
* int ycur; input Y cursor position * |
| 81 |
************************************************************************/ |
| 82 |
|
| 83 |
int IICINC_C (display , memid , curn , cursh , curcol , xcur , ycur) |
| 84 |
|
| 85 |
int display , memid , curn , cursh , curcol , xcur , ycur; |
| 86 |
|
| 87 |
{ |
| 88 |
|
| 89 |
if (ididev[display].opened == 0) return(DEVNOTOP); |
| 90 |
|
| 91 |
/* check cursor number */ |
| 92 |
|
| 93 |
if ((curn < 0) || (curn >= ididev[display].ncurs)) return(ILLCURID); |
| 94 |
|
| 95 |
conf = ididev [display].confptr; |
| 96 |
curs = ididev[display].cursor[curn]; |
| 97 |
|
| 98 |
/* set cursor parameters */ |
| 99 |
|
| 100 |
curs->sh = cursh; |
| 101 |
curs->col = curcol; |
| 102 |
curs->vis = 0; |
| 103 |
if (xcur >= 0) |
| 104 |
{ |
| 105 |
curs->xpos = xcur; |
| 106 |
curs->ypos = ycur; |
| 107 |
} |
| 108 |
|
| 109 |
return(II_SUCCESS); |
| 110 |
} |
| 111 |
|
| 112 |
/************************************************************************ |
| 113 |
* IICSCV_C routine : set cursor visibility * |
| 114 |
* * |
| 115 |
* synopsis IICSCV_C (display , curn , vis); * |
| 116 |
* * |
| 117 |
* int display; input display identifier * |
| 118 |
* int curn; input cursor number * |
| 119 |
* int vis; input visibility [1 / 0] * |
| 120 |
*************************************************************************/ |
| 121 |
|
| 122 |
int IICSCV_C (display , curn , vis) |
| 123 |
|
| 124 |
int display , curn , vis; |
| 125 |
|
| 126 |
{ |
| 127 |
|
| 128 |
if (ididev[display].opened == 0) return(DEVNOTOP); |
| 129 |
|
| 130 |
/* check cursor number */ |
| 131 |
if ((curn < 0) || (curn >= ididev[display].ncurs)) return(ILLCURID); |
| 132 |
|
| 133 |
curs = ididev[display].cursor[curn]; |
| 134 |
|
| 135 |
if (curs->sh == -1) return(CURNOTDEF); |
| 136 |
if (curs->vis == vis) return(II_SUCCESS); /* nothing to do */ |
| 137 |
|
| 138 |
dysize = ididev[display].ysize - 1; |
| 139 |
|
| 140 |
if (vis == 0) /* so curs->vis = 1 */ |
| 141 |
draw_curs(display,2,dysize,curn,curs->xpos,curs->ypos,curs->sh,curs->col); |
| 142 |
|
| 143 |
else /* so curs->vis = 0 */ |
| 144 |
draw_curs(display,0,dysize,curn,curs->xpos,curs->ypos,curs->sh,curs->col); |
| 145 |
|
| 146 |
curs->vis = vis; /* curs->vis updated ... */ |
| 147 |
|
| 148 |
return(II_SUCCESS); |
| 149 |
} |
| 150 |
|
| 151 |
/************************************************************************ |
| 152 |
* IICRCP_C routine : read cursor position * |
| 153 |
* * |
| 154 |
* synopsis IICRCP_C (display, inmemid, curn, xcur, ycur, outmemid)* |
| 155 |
* * |
| 156 |
* int display; input display identifier * |
| 157 |
* int inmemid; input input memory identifier * |
| 158 |
* int curn; input cursor number * |
| 159 |
* int *xcur; output X cursor position * |
| 160 |
* int *ycur; output Y cursor position * |
| 161 |
* int *outmemid; output output memory identifier * |
| 162 |
*************************************************************************/ |
| 163 |
|
| 164 |
int IICRCP_C (display , inmemid , curn , xcur , ycur , outmemid) |
| 165 |
|
| 166 |
int display , inmemid , curn , *xcur , *ycur , *outmemid; |
| 167 |
|
| 168 |
{ |
| 169 |
|
| 170 |
if (ididev[display].opened == 0) return(DEVNOTOP); |
| 171 |
|
| 172 |
conf = ididev [display].confptr; |
| 173 |
|
| 174 |
/* check cursor number */ |
| 175 |
if ((curn < 0) || (curn >= ididev[display].ncurs)) return(ILLCURID); |
| 176 |
|
| 177 |
curs = ididev[display].cursor[curn]; |
| 178 |
if (curs->sh == -1) /* shape = -1 : not initialized */ |
| 179 |
return(CURNOTDEF); |
| 180 |
|
| 181 |
*xcur = curs->xpos; |
| 182 |
*ycur = curs->ypos; |
| 183 |
|
| 184 |
/* search current memory for cursor */ |
| 185 |
|
| 186 |
*outmemid = 0; |
| 187 |
for (i=0; i<conf->nmem; i++) |
| 188 |
{ |
| 189 |
mem = conf->memory[i]; |
| 190 |
if (mem->visibility == 1) |
| 191 |
{ |
| 192 |
*outmemid = i; |
| 193 |
break; |
| 194 |
} |
| 195 |
} |
| 196 |
|
| 197 |
return(II_SUCCESS); |
| 198 |
} |
| 199 |
|
| 200 |
/************************************************************************ |
| 201 |
* IICWCP_C routine : write cursor position * |
| 202 |
* * |
| 203 |
* synopsis IICWCP_C (display , memid , curn , xcur , ycur); * |
| 204 |
* * |
| 205 |
* int display; input display identifier * |
| 206 |
* int memid; input memory identifier * |
| 207 |
* int curn; input cursor number * |
| 208 |
* int xcur; input X cursor position * |
| 209 |
* int ycur; input Y cursor position * |
| 210 |
************************************************************************/ |
| 211 |
|
| 212 |
int IICWCP_C (display , memid , curn , xcur , ycur) |
| 213 |
|
| 214 |
int display , memid , curn , xcur , ycur; |
| 215 |
|
| 216 |
{ |
| 217 |
|
| 218 |
if (ididev[display].opened == 0) return(DEVNOTOP); |
| 219 |
|
| 220 |
conf = ididev [display].confptr; |
| 221 |
|
| 222 |
/* check cursor number */ |
| 223 |
if ((curn < 0) || (curn >= ididev[display].ncurs)) |
| 224 |
return(ILLCURID); |
| 225 |
|
| 226 |
dxsize = ididev[display].xsize - 1; |
| 227 |
dysize = ididev[display].ysize - 1; |
| 228 |
|
| 229 |
/* printf("IICCWP: xcur, ycur, dxsize, dysize = %d, %d, %d, %d\n", |
| 230 |
xcur,ycur,dxsize,dysize); */ |
| 231 |
|
| 232 |
curs = ididev[display].cursor[curn]; |
| 233 |
if (curs->sh == -1) return(CURNOTDEF); |
| 234 |
|
| 235 |
/* store new cursor position */ |
| 236 |
|
| 237 |
if (xcur < 0) |
| 238 |
xcur = 0; |
| 239 |
else |
| 240 |
{ |
| 241 |
if (xcur > dxsize) xcur = dxsize; |
| 242 |
} |
| 243 |
|
| 244 |
if (ycur < 0) |
| 245 |
ycur = 0; |
| 246 |
else |
| 247 |
{ |
| 248 |
if (ycur > dysize) ycur = dysize; |
| 249 |
} |
| 250 |
|
| 251 |
curs->xpos = xcur; |
| 252 |
curs->ypos = ycur; |
| 253 |
|
| 254 |
return(II_SUCCESS); |
| 255 |
|
| 256 |
} |