Back to index

plt-scheme  4.2.1
wx_imgx.h
Go to the documentation of this file.
00001 /*
00002  * File:     wx_imgx.h
00003  * Purpose:  
00004  *
00005  *                       wxWindows 1.50
00006  * Copyright (c) 2004-2009 PLT Scheme Inc.
00007  * Copyright (c) 1993 Artificial Intelligence Applications Institute,
00008  *                   The University of Edinburgh
00009  *
00010  *                     Author: Julian Smart
00011  *                        Date: 7-9-93
00012  *
00013  * Permission to use, copy, modify, and distribute this software and its
00014  * documentation for any purpose is hereby granted without fee, provided
00015  * that the above copyright notice, author statement and this permission
00016  * notice appear in all copies of this software and related documentation.
00017  *
00018  * THE SOFTWARE IS PROVIDED "AS-IS" AND WITHOUT WARRANTY OF ANY KIND, EXPRESS,
00019  * IMPLIED OR OTHERWISE, INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF
00020  * MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
00021  *
00022  * IN NO EVENT SHALL THE ARTIFICIAL INTELLIGENCE APPLICATIONS INSTITUTE OR THE
00023  * UNIVERSITY OF EDINBURGH BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT OR
00024  * CONSEQUENTIAL DAMAGES OF ANY KIND, OR ANY DAMAGES WHATSOEVER RESULTING FROM
00025  * LOSS OF USE, DATA OR PROFITS, WHETHER OR NOT ADVISED OF THE POSSIBILITY OF
00026  * DAMAGE, AND ON ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH
00027  * THE USE OR PERFORMANCE OF THIS SOFTWARE.
00028  *
00029  */
00030 
00031 #ifndef wx_imgxh
00032 #define wx_imgxh
00033 
00034 #ifdef SVR4             /* SysV release 4 uses dirent */
00035 #ifndef sgi             /* but Silicon Graphics doesn't */
00036 #define DIRENT
00037 #endif
00038 #endif
00039 
00040 #ifdef VMS
00041 #include "unixlib.h"
00042 // some names are different
00043 #define rindex strrchr
00044 #define unlink delete
00045 #endif
00046 
00047 /* include files */
00048 #include <stdio.h>
00049 #include <math.h>
00050 #include <ctype.h>
00051 #include <string.h>
00052 
00053 #if !defined(__convexc__) && !defined(VMS) /* Convex doesn't have <memory.h> */
00054 #include <memory.h>             /* for 'memset()' prototype */
00055 #endif
00056 
00057 /* neither IBM AOS 4.3, Convex, nor BSD 4.3 on VAX have <malloc.h> */
00058 #if !defined(ibm032) && !defined(__convexc__) && \
00059     !(defined(vax) && !defined(ultrix)) && !defined(VMS)
00060 #if defined(hp300) || defined(hp800)
00061 #include <sys/malloc.h>                /* it's in 'sys' on HPs*/
00062 #else
00063 #include <stdlib.h>
00064 #endif
00065 #endif
00066 
00067 
00068 /* Comment following out to avoid problems with GNU string.h conflict */
00069 #ifndef wx_xview
00070 #include <X11/Xos.h>
00071 #endif
00072 #include <X11/Xlib.h>
00073 #include <X11/Xutil.h>
00074 #include <X11/cursorfont.h>
00075 #include <X11/keysym.h>
00076 
00077 #if defined(NEEDSTIME) || defined(NEEDSDIR)
00078 #include <sys/types.h>    /* only include <sys/types.h> once */
00079 #endif
00080 
00081 #ifdef NEEDSTIME
00082 #ifndef sgi              /* silicon graphics doesn't have timeb.h */
00083 #include <sys/timeb.h>
00084 #endif
00085 #include <signal.h>
00086 #if defined(sco) && !defined(NOTIMER)
00087 #include <sys/itimer.h>
00088 #endif
00089 #ifndef  sigmask
00090 #define  sigmask(m)      (1 << ((m)-1))
00091 #endif
00092 #endif
00093 
00094 #ifdef NEEDSDIR
00095 #ifdef sco
00096 #include <sys/ndir.h>
00097 #define lstat stat
00098 #else
00099 #ifndef ATT
00100 #include <sys/dir.h>
00101 #endif  /* ATT */
00102 #endif  /* sco */
00103 #include <sys/param.h>
00104 #include <sys/stat.h>
00105 #ifdef DIRENT
00106 #include <dirent.h>
00107 #endif
00108 #endif
00109 
00110 #ifdef NEEDSVARARGS
00111 #include <varargs.h>
00112 #endif
00113 
00114 /* signal macros */
00115 #ifdef SVR4
00116 #define HOLD_SIG         sighold(SIGALRM)  /* block ALRM sig from occurring */
00117 #define RELEASE_SIG      sigrelse(SIGALRM)
00118 #define PAUSE_SIG        sigpause(SIGALRM) /* sleep until ALRM signal */
00119 #else
00120 #define HOLD_SIG         sigblock(sigmask(SIGALRM))
00121 #define RELEASE_SIG      sigblock(0)
00122 #define PAUSE_SIG        sigpause(0)
00123 #endif
00124 
00125 
00126 #ifdef i386
00127 #define UNCOMPRESS    "/usr/local/bin/uncompress"   /* uncompress program */
00128 #undef  HOLD_SIG
00129 #define HOLD_SIG      /* don't know how to handle signals  MWS 10/18/90 */
00130 #undef  RELEASE_SIG
00131 #define RELEASE_SIG   /* */
00132 #undef  PAUSE_SIG
00133 #define PAUSE_SIG     /* */
00134 #else
00135 #define UNCOMPRESS "/usr/ucb/uncompress"   /* for uncompressing .Z files */
00136 #endif
00137 
00138 #define PROGNAME  "xv"             /* used in resource database */
00139 
00140 #define DEFINFOGEOM "-10+10"       /* default position of info window */
00141 #define DEFDIRGEOM  "-10-10"       /* default position of directory window */
00142 #define DEFCTRLGEOM "+400+400"     /* default position of ctrl window */
00143 #define DEFGAMGEOM  "+10-10"       /* default position of gamma window */
00144 
00145 #define INFOWIDE 500               /* (fixed) size of info window */
00146 #define INFOHIGH 250
00147 
00148 #define CTRLWIDE 440               /* (fixed) size of control window */
00149 #define CTRLHIGH 295
00150 
00151 #define DIRWIDE  300               /* (fixed) size of directory window */
00152 #define DIRHIGH  420
00153 
00154 #define GAMWIDE  366               /* (fixed) size of Gamma window */
00155 #define GAMHIGH  356
00156 
00157 #define MAXNAMES 1024   /* max # of files (more than this?  Get REAL!) */
00158 
00159 /* strings in the INFOBOX (used in SetISTR and GetISTR) */
00160 #define NISTR         9    /* number of ISTRs */
00161 #define ISTR_INFO     0
00162 #define ISTR_WARNING  1
00163 #define ISTR_FILENAME 2
00164 #define ISTR_FORMAT   3
00165 #define ISTR_RES      4
00166 #define ISTR_CROP     5
00167 #define ISTR_EXPAND   6
00168 #define ISTR_COLOR    7
00169 #define ISTR_COLOR2   8
00170 
00171 /* potential values of 'infomode', used in info box drawing routines */
00172 #define INF_NONE 0    /* empty box */
00173 #define INF_STR  1    /* just ISTR_INFO */
00174 #define INF_PART 2    /* filename, format, size and infostr */
00175 #define INF_FULL 3    /* INF_PART + clipping, expansion, colorinfo */
00176 
00177 
00178 /* buttons in the ctrl window */
00179 #define NBUTTS  20
00180 #define BNEXT   0
00181 #define BPREV   1
00182 #define BCROP   2
00183 #define BUNCROP 3
00184 #define BNORM   4
00185 #define BMAX    5
00186 #define BUP2    6
00187 #define BDN2    7
00188 #define BUP10   8
00189 #define BDN10   9
00190 #define BQUIT   10
00191 #define B4BY3   11
00192 #define BSAVE   12
00193 #define BROTL   13
00194 #define BINFO   14
00195 #define BGAMMA  15
00196 #define BASPECT 16
00197 #define BROTR   17
00198 #define BMAXPECT 18
00199 #define BACROP   19
00200 
00201 /* buttons in the 'save' window */
00202 #define S_NBUTTS 4
00203 #define S_BOPEN  0
00204 #define S_BSAVE  1
00205 #define S_BCANC  2
00206 #define S_BQUIT  3
00207 
00208 
00209 /* buttons in the 'gamma' window */
00210 #define G_NBUTTS  17
00211 #define G_BAPPLY  0
00212 #define G_BNOGAM  1
00213 #define G_BRESET  2
00214 #define G_BDEF    3
00215 #define G_BGTYPE  4
00216 #define G_BCLOSE  5
00217 #define G_BUP_BR  6
00218 #define G_BDN_BR  7
00219 #define G_BUP_CN  8
00220 #define G_BDN_CN  9
00221 #define G_BHSVRGB 10
00222 #define G_B1      11
00223 #define G_B2      12
00224 #define G_B3      13
00225 #define G_B4      14
00226 #define G_BSET    15
00227 #define G_BUNDO   16
00228 
00229 
00230 /* definitions of first char of dirnames[i] (filetype) */
00231 #define C_FIFO  'f'    /* FIFO special file */
00232 #define C_CHR   'c'    /* character special file */
00233 #define C_DIR   'd'    /* directory */
00234 #define C_BLK   'b'    /* block special file */
00235 #define C_LNK   'l'    /* symbolic link */
00236 #define C_SOCK  's'    /* socket */
00237 #define C_REG   ' '    /* regular file */
00238 
00239 
00240 /* random string-placing definitions */
00241 #define SPACING 3      /* vertical space between strings */
00242 #define ASCENT   (mfinfo->ascent)
00243 #define DESCENT  (mfinfo->descent)
00244 #define CHIGH    (ASCENT + DESCENT)
00245 #define LINEHIGH (CHIGH + SPACING)
00246 
00247 
00248 #define STDINSTR "<stdin>"
00249 
00250 typedef unsigned char byte;
00251 
00252 typedef struct { Window win;            /* window ID */
00253                int len;               /* length of major axis */
00254                int vert;              /* true if vertical, else horizontal */
00255                int active;            /* true if scroll bar can do anything*/
00256                int min,max;           /* min/max values 'pos' can take */
00257                int val;               /* 'value' of scrollbar */
00258                int page;              /* amt val change on pageup/pagedown */
00259                int tpos;              /* thumb pos. (pixels from tmin) */
00260                int tmin,tmax;         /* min/max thumb offsets (from 0,0) */
00261                int tsize;             /* size of thumb (in pixels) */
00262                unsigned long fg,bg;   /* colors */
00263                void (*drawobj)();     /* redraws obj controlled by scrl*/
00264                int uplit, dnlit;      /* true if up&down arrows are lit */
00265               } SCRL;
00266 
00267 typedef struct { Window win;            /* parent window */
00268                int x,y,w,h;           /* size of button rectangle */
00269                int lit;               /* if true, invert colors */
00270                int active;            /* if false, stipple gray */
00271                int toggle;            /* if true, clicking toggles state */
00272                unsigned long fg,bg;   /* colors */
00273                char *str;             /* string in button */
00274               } BUTT;
00275 
00276 
00277 typedef struct { Window win;            /* window */
00278                int x,y,w,h;           /* size of window */
00279                unsigned long fg,bg;   /* colors */
00280                char **str;            /* ptr to list of strings */
00281                int   nstr;            /* number of strings */
00282                int   selected;        /* number of 'selected' string */
00283                int   nlines;          /* number of lines shown at once */
00284                SCRL  scrl;            /* scrollbar that controls list */
00285                int   filetypes;       /* true if filetype icons to be drawn*/
00286                int   dirsonly;        /* if true, only dirs selectable */
00287               } LIST;
00288 
00289 
00290 typedef struct rbutt { Window        win;      /* parent window */
00291                      int           x,y;      /* position in parent */
00292                      char         *str;      /* the message string */
00293                      int           selected; /* selected or not */
00294                      int           active;   /* selectable? */
00295                      struct rbutt *next;     /* pointer to next in group */
00296                      unsigned long fg,bg;    /* colors */
00297                    } RBUTT;
00298 
00299 /* 25-8 bit conversion stuff */
00300 #define       MAX_CMAP_SIZE 256
00301 #define       COLOR_DEPTH   8
00302 #define       MAX_COLOR     256
00303 #define       B_DEPTH              5             /* # bits/pixel to use */
00304 #define       B_LEN         (1<<B_DEPTH)
00305 #define       C_DEPTH              2
00306 #define       C_LEN         (1<<C_DEPTH)  /* # cells/color to use */
00307 
00308 typedef       struct colorbox {
00309   struct colorbox *next, *prev;
00310   int              rmin,rmax, gmin,gmax, bmin,bmax;
00311   int              total;
00312 } CBOX;
00313 
00314 typedef struct {
00315   int num_ents;
00316   int entries[MAX_CMAP_SIZE][2];
00317 } CCELL;
00318 
00319 extern byte           gamcr[];   /* gamma correction curve */
00320 extern byte           fsgamcr[]; /* gamma correction curve (for FS dither) */
00321 extern XPoint                ghand[];
00322 
00323 /* MACROS */
00324 #define CENTERX(f,x,str) ((x)-XTextWidth(f,str,strlen(str))/2)
00325 #define CENTERY(f,y) ((y)-((f->ascent+f->descent)/2)+f->ascent)
00326 
00327 /* RANGE forces a to be in the range b..c (inclusive) */
00328 #define RANGE(a,b,c) { if (a<b) a=b;  if (a>c) a=c; }
00329 
00330 /* PTINRECT returns '1' if x,y is in rect (inclusive) */
00331 #define PTINRECT(x,y,rx,ry,rw,rh) \
00332            ((x)>=(rx) && (y)>=(ry) && (x)<=(rx)+(rw) && (y)<=(ry)+(rh))
00333 
00334 /* MONO returns total intensity of r,g,b components */
00335 #define MONO(rd,gn,bl) (((rd)*11 + (gn)*16 + (bl)*5) >> 5)  /*.33R+ .5G+ .17B*/
00336 
00337 typedef struct { byte *pic;                  /* image data */
00338                int   w, h;                 /* size */
00339                int   type;                 /* PIC8 or PIC24 */
00340 
00341                byte  r[256],g[256],b[256];
00342                                            /* colormap, if PIC8 */
00343 
00344                int   frmType;              /* def. Format type to save in */
00345                int   colType;              /* def. Color type to save in */
00346                char  fullInfo[128];        /* Format: field in info box */
00347                char  shrtInfo[128];        /* short format info */
00348                char *comment;              /* comment text */
00349                
00350                int   numpages;             /* # of page files, if >1 */
00351                char  pagebname[64];        /* basename of page files */
00352               } PICINFO;
00353 
00354 /* constants for setting radio buttons in dirW */
00355 #define F_COLORS    0
00356 #define F_FORMAT    1
00357 
00358 #define F_FULLCOLOR 0
00359 #define F_GREYSCALE 1
00360 #define F_BWDITHER  2
00361 #define F_REDUCED   3
00362 
00363 #define F_GIF       0
00364 #define F_PM        1
00365 #define F_PBMRAW    2
00366 #define F_PBMASCII  3
00367 #define F_XBM       4
00368 #define F_SUNRAS    5
00369 #define F_BMP       6
00370 #define F_PS        7
00371 #define F_IRIS      8
00372 
00373 #ifdef HAVE_JPEG
00374 #define F_JPEG      9
00375 #endif
00376 
00377 #ifdef HAVE_TIFF
00378 #ifdef HAVE_JPEG
00379 #define F_TIFF      10
00380 #else
00381 #define F_TIFF      9
00382 #endif
00383 #endif
00384 
00385 /* indicies into conv24MB */
00386 #define CONV24_8BIT  0
00387 #define CONV24_24BIT 1
00388 #define CONV24_SEP1  2
00389 #define CONV24_LOCK  3
00390 #define CONV24_SEP2  4
00391 #define CONV24_FAST  5
00392 #define CONV24_SLOW  6
00393 #define CONV24_BEST  7
00394 #define CONV24_MAX   8
00395 
00396 /* values 'picType' can take */
00397 #define PIC8  CONV24_8BIT
00398 #define PIC24 CONV24_24BIT
00399 
00400 void InitFSDTables(void);
00401 void xvDestroyImage(XImage *image);
00402 void xvbzero(char *s, int len);
00403 
00404 #endif // wx_imgx