/****************************************************************************/
/* File     : demo.def                                                      */
/*                                                                          */
/* Function : constants, types and variables for demo.c                     */
/*                                                                          */
/* Author   : Michael C. Ancutici                                           */
/*                                                                          */
/* Date     : V2                                                            */
/****************************************************************************/

#define HALF       256
#define FULL       65535
#define FULLprev   65279

#define YES        1
#define NO         0

#define PIC_X      105
#define PIC_Y      105
#define PIC_WIDTH  256
#define PIC_HEIGHT 256
#define DEPTHMAX   20
#define ZOOMMAX    5

#define BACKGR     0
#define GREEN      2
#define RED        1
#define BROWN      3
#define WHITE      4
#define BLACK      5  
#define BLUE       6

#define HTEXTN     2
#define DRECN      16
#define DTEXTN     16
#define ACRECN     12
#define ACTEXTN    12 

#define clear_status          XClearArea (display, dwindow, 0, dhint.height-34, \
                                          dhint.width, 34, False)  
#define init_color(c,r,g,b)   cbank[c].red=r;cbank[c].green=g;cbank[c].blue=b

#define inc_col(c)       if (c==FULL) c=0; else c+=4*256
#define dec_col(c)       if (c==0) c=FULL; else c-=4*256

#define ptr_in_x( nr )   event.xbutton.x > drec[ nr ].x && \
                         event.xbutton.x < drec[ nr ].x + drec[ nr ].width

#define ptr_in_y( nr )   event.xbutton.y > drec[ nr ].y && \
                         event.xbutton.y < drec[ nr ].y + drec[ nr ].height

#define ptr_in_rec( nr ) event.xbutton.x > drec[ nr ].x && \
                         event.xbutton.x < drec[ nr ].x + drec[ nr ].width && \
                         event.xbutton.y > drec[ nr ].y && \
                         event.xbutton.y < drec[ nr ].y + drec[ nr ].height


#define ptr_in_acx( nr )   event.xbutton.x > acrec[ nr ].x && \
                         event.xbutton.x < acrec[ nr ].x + acrec[ nr ].width

#define ptr_in_acy( nr )   event.xbutton.y > acrec[ nr ].y && \
                         event.xbutton.y < acrec[ nr ].y + acrec[ nr ].height

#define ptr_in_acrec( nr ) event.xbutton.x > acrec[ nr ].x && \
                         event.xbutton.x < acrec[ nr ].x + acrec[ nr ].width && \
                         event.xbutton.y > acrec[ nr ].y && \
                         event.xbutton.y < acrec[ nr ].y + acrec[ nr ].height
/****************************************************************************/

typedef char  string[150];
typedef short flag;
typedef struct {
  char  t[100];
  int   x, y, f;
  } text;
typedef struct {
  int   w, l, p, state;
  } zoom_tp;
typedef struct {
  int   x,y;
  } coord_tp;
typedef struct {
  unsigned short red, green, blue;
  unsigned long pixel;
  } mycolor;
/****************************************************************************/
zoom_tp    zoom = {PIC_WIDTH, 0, 1, 0};
coord_tp   zstack[8] = {{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}};
int        zsp = 0;

string     wname[] = {"Random Dot", "Analyze", "Help", "Colors"};

XRectangle drec [DRECN];
text       dtext [DTEXTN] 
             = {{"R a n d o m  D o t  S t e r e o  I m a g e s",          120, 35, 3},
                {"Universitaet S t u t t g a r t - Fakultaet Informatik", 160, 65, 2},
                {"Institute for Parallel and Distributed Supercomputers", 180, 85, 1},

                {"[h]   Help",    0,0,0},    /* index of text: 3,  rectangle: 4 */
                {"[q]   Quit",    0,0,0},    /* index of text: 4,  rectangle: 5 */
                {"[n]   New",     0,0,0},    /* index of text: 5,  rectangle: 6 */
                {"[a]   Analyze", 0,0,0},    /* index of text: 6,  rectangle: 7 */
		{"[c]   Colors",  0,0,0},    /* index of text: 7,  rectangle: 8 */
		{"[s]   Size",    0,0,0},    /* index of text: 8,  rectangle: 9 */
		{"[i]   Zoom in", 0,0,0},    /* index of text: 9,  rectangle: 10 */
                {"[o]   Zoom out",0,0,0},    /* index of text: 10, rectangle: 11 */
		{"[d]  Depth"  , 0,0,0},     /* index of text: 11, rectangle: 12 */
                {"[l]   Load"    ,0,0,0},    /* index of text: 12, rectangle: 13 */
                {"[w]  Write",   0,0,0},   /* index of text: 13, rectangle: 14 */

                {"[f]   front",   0,0,0},    /* index of text: 14, rectangle: 2 */
                {"[b]   back",    0,0,0}};   /* index of text: 15, rectangle: 3 */

XRectangle acrec [ACRECN]  
             = {{10,  10, 160,30}, {175, 10, 180,30},
                {125, 70, 50, 30}, {265, 70, 50, 30}, {390, 70,  50, 30},
                {125,120, 50, 30}, {265, 120,50, 30}, {390, 120, 50, 30},
                {125,170, 50, 30}, {265, 170,50, 30}, {390, 170, 50, 30},
                {365, 10, 75, 30}};

text       actext [ACTEXTN]
            = {{"[d]   Default Color Set", 20,  30,0},
               {"[m]   Mix",               185, 30,0},

               {"Red",90,90,0}, {"Green",210,90,0}, {"Blue",350,90,0},
               {"Red",90,140,0},{"Green",210,140,0},{"Blue",350,140,0},
               {"Red",90,190,0},{"Green",210,190,0},{"Blue",350,190,0},

               {"[o]   OK", 375, 30,0}};

/****************************************************************************/

flag       change_col_on ;
flag       done         = NO;
flag       additiv_on   = YES;
flag       size_on      = NO;
flag       size_changed = NO;
flag       aw_on        = NO;
flag       acw_on       = NO;
flag       hw_on        = NO;
flag       sign_on      = NO;
flag       apic_exist   = NO;

int        arcdist      = 0;
int        i, j, k;
int        screen;
int        format, bitmap_pad;
int        axmax, aymax;
int        button;
int        rdepth = 8;
int        adepth;

char       answer[10];
char       mpname[50];
char       *displayname = "";
char       gpic[PIC_WIDTH+1][PIC_HEIGHT+1];
char       rpic[PIC_WIDTH+1][PIC_HEIGHT+1];

XEvent     event;
XSizeHints mhint, dhint, ahint, hhint, achint;
XColor     cbank[7];
XImage     *mlimage,*mrimage,*rimage, *cimage, *bimage, *timage;
XSetWindowAttributes         dxswa;
Visual                *default_visual;

Display    *display;
Window     dwindow, hwindow, acwindow;
GC         dgc, agc, hgc, acgc;
Colormap   cmap;
KeySym     key;
Font       font[6];

unsigned int   depth;
unsigned long  foreground, background;
XColor     grey[DEPTHMAX];

struct {
  int  state, x1, x2, y1, y2, cx, cy;
  } rec;
/****************************************************************************/
