コード例 #1
0
ファイル: glwidget.c プロジェクト: pgramage/gaspware
static void drawbutton(gl_button *bt) {
    Int32 lw = getlwidth();
    Int32 cl = getcolor();
    Int32 oriwin = winget();
    int cfg, bg;
    
    winset(bt->win);
    linewidth(1);
    locate_button(bt);
    
    cfg = *(bt->state)?bt->bg:bt->fg;
    bg  = *(bt->state)?((bt->type == BUTTON)?bt->fg:bt->active_c):bt->bg;
	
    color(bg);
    rectf(bt->x, bt->y, bt->x + bt->width, bt->y + bt->height);
    
    color(bt->fg);
    rect (bt->x, bt->y, bt->x + bt->width, bt->y + bt->height);

    if (bt->label != NULL) {
	color(cfg);
	cmov2(bt->x, bt->y + 0.05 * bt->height);
	charstr(bt->label);
    }
    
    winset(oriwin);
    color(cl);
    linewidth(lw);
    
    sleep(0);
}
コード例 #2
0
ファイル: winZoom.c プロジェクト: sprax/coldz
void
backTrack (void *v, int device, int mouseDown)
{
pWmj    cW = (pWmj)v, pW = cW->prev;
/* WmjAct *Ap = (device == LEFTMOUSE ? cW->lefMouse : cW->midMouse); */
pDmj    cD = &cW->D;
long    bxA, byA, nxA, nyA, oxA,oyA, wx,ww,wy,wh;
long    widA = winget();

  if (! mouseDown)  return;

  getorigin(&wx,&wy);
  getsize(  &ww,&wh); ww -= 1; wh -= 1;

  oxA = bxA = (getvaluator(MOUSEX) - wx);
  oyA = byA = (getvaluator(MOUSEY) - wy);

  cursoff();
  drawmode(OVERDRAW);

  while(getbutton(device)) {
    nxA  = getvaluator(MOUSEX) - wx; if (nxA < 0)  nxA = 0;  else if (nxA > ww)  nxA = ww;
    nyA  = getvaluator(MOUSEY) - wy; if (nyA < 0)  nyA = 0;  else if (nyA > wh)  nyA = wh;
    if (nxA != oxA || nyA != oyA) {
      /* winset(widA); */
      color(BLACK);             /* black erases */
      sboxi(bxA,byA,oxA,oyA);   /* NB: sbox is faster than rect, but less flex */
      color(RED);                     /* set color of new circle */
      sboxi(bxA,byA,nxA,nyA);
      oxA = nxA,  oyA = nyA;
    }
  }
  color(BLACK);
  sboxi(bxA,byA,oxA,oyA);
  drawmode(NORMALDRAW);
  cpack(FcGRN);
  sboxi(bxA,byA,nxA,nyA);

  if (pW) {
    pDmj        pD = &pW->D;
    flt         pzX = pW->zX, zX = pzX/cW->zX;
    flt         pzY = pW->zY, zY = pzY/cW->zY;
    long        L = cD->l*pzX, B = cD->b*pzY;
    wrn("bT: id: %d  pD->lb: %3d %3d   zXY: %.1f %.1f", pW->id, pD->l, pD->b,    zX,    zY);
    wrn("bT: id: %d  cD->lb: %3d %3d  czXY: %.1f %.1f", cW->id, cD->l, cD->b,cW->zX,cW->zY);
    winset(pW->id);
    drawmode(OVERDRAW);
    color(YELLOW);
    sboxi(L + bxA*zX, B + byA*zY, L + oxA*zX, B + oyA*zY);
    drawmode(NORMALDRAW);
  }
  winset(widA);
  curson();
}
コード例 #3
0
ファイル: winZoom.c プロジェクト: sprax/coldz
void
rubberRectZoid (void *v, int device, int mouseDown)
{
static	WmjAct	backAct;
pWmj	cW = (pWmj)v;
WmjAct *Ap = (device == LEFTMOUSE ? cW->lefMouse : cW->midMouse);
/* Tetra  *trp  = Ap->data; */
flt     zX = cW->zX, zY = cW->zY;
long    bxA, byA, nxA, nyA, oxA,oyA, wx,ww,wy,wh;
long	widA = winget();

  if (! mouseDown)  return;

  getorigin(&wx,&wy);       
  getsize(  &ww,&wh); ww -= 1; wh -= 1;

  oxA = bxA = (getvaluator(MOUSEX) - wx);
  oyA = byA = (getvaluator(MOUSEY) - wy);

  cursoff();
  drawmode(OVERDRAW);

  while(getbutton(device)) {
    nxA  = getvaluator(MOUSEX) - wx; if (nxA < 0)  nxA = 0;  else if (nxA > ww)  nxA = ww;
    nyA  = getvaluator(MOUSEY) - wy; if (nyA < 0)  nyA = 0;  else if (nyA > wh)  nyA = wh;
    if (nxA != oxA || nyA != oyA) {

      winset(widA);
      color(BLACK);                   /* black erases */
      sboxi(bxA,byA,oxA,oyA);
      color(RED);                     /* set color of new circle */
      sboxi(bxA,byA,nxA,nyA);
      oxA = nxA,  oyA = nyA;
    }
  }
  color(BLACK);
  sboxi(bxA,byA,oxA,oyA);
  drawmode(NORMALDRAW);
  cpack(FcGRN);
  sboxi(bxA,byA,nxA,nyA);

  if (bxA > nxA)  nxA = bxA, bxA = oxA;
  if (byA > nyA)  nyA = byA, byA = oyA;
  wrn("rubberRectZ B4 showSub: %4d  %4d  %4d  %4d   zX:%.2f  zY:%.2f",bxA,byA,nxA,nyA, zX, zY);

  backAct = *Ap;
  backAct.func = &testChain;
  cW->next = showSub(cW,   bxA/zX,byA/zY,nxA/zX,nyA/zY,"subA",zX*2.0,zY*2.0,5);
  cW->next->lefMouse = &backAct;
  cW->next->prev = cW;

  winset(widA);
  curson();
}
コード例 #4
0
ファイル: glwidget.c プロジェクト: pgramage/gaspware
static void drawslider(gl_slider *sl) {
    Int32 lw = getlwidth();
    Int32 cl = getcolor();
    Int32 oriwin = winget();
    long co;
    int i;
    Screencoord x, y;
    Int32 xo, yo;
    
    winset(sl->win);
    linewidth(1);
   
    update_slider_value(sl);
    locate_slider(sl);
    
    if (sl->txbg == -1) {
	/* first time, get bg color */
	cmov2(sl->x + sl->len + sl->thick, sl->y);
	getcpos(&x, &y);
	getorigin(&xo, &yo);
	x -= xo;
	y -= yo;
	i = lrectread(x, y, x, y, &co);
	sl->txbg = co;
#ifdef DEBUG
	printf("textbg = %d, bytes = %d x %d (soll %g) y %d (soll %g)\n",
	       co,i,x,sl->x + sl->len + sl->thick,
	       y,sl->y);	
#endif
    }
    color(sl->bg);
    rectf(sl->x, sl->y, sl->x+sl->thick+sl->len, sl->y+sl->height);
    color(sl->fg);
    rect (sl->x, sl->y, sl->x+sl->thick+sl->len, sl->y+sl->height);
    rectf(sl->x + sl->len * (sl->value - sl->min)/(sl->max - sl->min),
	  sl->y,
	  sl->x + sl->len * (sl->value - sl->min)/(sl->max - sl->min) + sl->thick,
	  sl->y + sl->height);
    if (sl->buf != NULL) {
	color(sl->txbg);
	cmov2(sl->x + sl->len + sl->thick, sl->y);
	charstr(sl->buf);
	color(sl->fg);
	sprintf(sl->buf + 1, sl->format, sl->value);
	cmov2(sl->x + sl->len + sl->thick, sl->y);
	charstr(sl->buf);
    }
    
    winset(oriwin);
    color(cl);
    linewidth(lw);
    
    sleep(0);
}
コード例 #5
0
ファイル: matplot.c プロジェクト: B-Rich/tcoffee
/* plot_mat: creates a simple colour-coded dot representation of Mat,
 * which is assumed to be a Row x Col matrix. The colours vary from
 * blue for Lowval values to red for Upval values. Values lower than
 * Lowval will be black, higher than Upval will be white.
 * Plotting is performed in window no. Gid.
 * Call winclose() to dispose of this window.
 */
void plot_mat(long Gid, double **Mat, unsigned int Row, unsigned int Col, 
		    double Lowval, double Upval)
{
    register unsigned int i,j;
    
    winset(Gid);    /* make this the current window */
   
    reshapeviewport();
    cpack(RGB_BLACK);
    clear();
    
    for (i=0; i<Row; i++)           /* scans Mat */
	for (j=0; j<Col; j++)
	{
	    /* select code color for Mt values */
	    cpack(rainbow_ramp(Mat[i][j], Lowval, Upval));

	    /* plot the point */
	    rectfi(j, Row-i, j+1, Row-i-1);
 	}

    /* flush graphics */
    if (Dblbuffer) swapbuffers(); else gflush();
}
コード例 #6
0
ファイル: glwidget.c プロジェクト: pgramage/gaspware
static int updatebutton(int x, int y, gl_button *bt) {
    Int32 xo, yo;
    Int16 xx, yy;
    Int32  oriwin = winget();
    int oldstate;

#ifdef DEBUG
    printf("updatebutton: button with label %s - ", bt->label);
#endif
    
    winset(bt->win);
    locate_button(bt);
    
    getorigin(&xo, &yo);
    x -= xo;
    y -= yo;
    if (x < bt->scx0 || y > bt->scy0 ||
	x > bt->scx1 ||	y < bt->scy1) {
	winset(oriwin);
	bt->changed = FALSE;
#ifdef DEBUG
	printf("x = %d y = %d, btscx0 = %d btscx1 = %d btscy0 = %d btscy1 = %d\n",
	       x, y, bt->scx0,  bt->scx1, bt->scy0,  bt->scy1);
	puts("click not inside - return(FALSE)");
#endif
	return(FALSE);
    }
    oldstate = *(bt->state);
    *(bt->state) = (bt->type == BUTTON)?TRUE:!oldstate;
    drawbutton(bt);
    
    while (qread(&xx) != LEFTMOUSE); /* wait for LEFTMOUSE release */

    if (qtest()) qread(&xx); else {
	xx = getvaluator(MOUSEX);      
	fprintf(stderr, 
		"updatebutton: This should not happen, tie() seems to fail.\n");
    }
    if (qtest()) qread(&yy); else {
	yy = getvaluator(MOUSEY);
	fprintf(stderr, 
		"updatebutton: This should not happen, tie() seems to fail.\n");
    }
    getorigin(&xo, &yo);
    x = xx - xo;
    y = yy - yo;

    if (!(bt->changed = !(
			  x < bt->scx0 || y > bt->scy0 ||
			  x > bt->scx1 || y < bt->scy1
			  )
	  )) *(bt->state) = oldstate;

    if (bt->type == BUTTON) {
	*(bt->state) = FALSE;
	usleep(50000);
    }
    drawbutton(bt);
    if (oriwin != bt->win) winset(oriwin);

    if (bt->callback != NULL && bt->changed) {
	bt->callback(bt, *(bt->state));
    }
#ifdef DEBUG
    printf("return(%s)\n", bt->changed?"true":"false");
#endif
    return(bt->changed);
}
コード例 #7
0
ファイル: glwidget.c プロジェクト: pgramage/gaspware
static int updateslider(int x, int y, gl_slider *sl) {
    Int32 xo, yo;
    Int16 xx, yy;
    double orival;
    Int32  oriwin = winget();
    int dev;
    
    orival = sl->value;
    update_slider_value(sl);
    winset(sl->win);

    getorigin(&xo, &yo);
    x -= xo;
    y -= yo;

#ifdef DEBUG
    printf("updateslider: slider label %s - ", sl->buf);
#endif    
    locate_slider(sl);
    
    if (x < sl->scx0 || y > sl->scy0 ||
	x > sl->scx1 + sl->sc_thick  ||	y < sl->scy1) {
	winset(oriwin);
	if (orival != sl->value) {
	    /* This is used when the click is not for this slider, but
	       update_slider_value() has changed the value... */
	    if (sl->callback != NULL) sl->callback(sl, sl->value);
#ifdef DEBUG
	    puts("return(-1)");
#endif
	    return(-1);
	} else {
#ifdef DEBUG
	    puts("return(FALSE)");
#endif
	    return(FALSE);
	}
    }
	
    while (qtest() == 0 || (dev = qread(&xx)) != LEFTMOUSE) {
	/* getorigin(&xo, &yo); */
	setslider(getvaluator(MOUSEX) - xo, sl);
	usleep(100000);
    } 
#ifdef DEBUG
    printf("updateslider: got an event, dev = %d val = %d\n", dev, (int)xx);
    if (qtest()) {
	int dev; 
	dev = qread(&xx);
	printf("updateslider: qtest() for x is true. dev = %d, val = %d\n",
	       dev, (int)xx);
    } else {
	xx = getvaluator(MOUSEX);
	printf("updateslider: qtest() for x is FALSE!. x = %d\n", (int)xx);
    }
    if (qtest()) {
	int dev; 
	dev = qread(&yy);
	printf("updateslider: qtest() for y is true. dev = %d, val = %d\n",
	       dev, (int)yy);
    } else {
	yy = getvaluator(MOUSEY);
	printf("updateslider: qtest() for y is FALSE!. y = %d\n", (int)yy);
    }
    setslider((int)(xx-xo), sl);
#else
    if (qtest()) qread(&xx);
    if (qtest()) {
	qread(&yy);
	setslider((int)(xx-xo), sl);
    } else 
      fprintf(stderr, 
	      "updateslider: This should not happen, tie() seems to fail.\n");
#endif
    winset(oriwin);
    if (sl->value != orival) {
	if (sl->callback != NULL) sl->callback(sl, sl->value);
	return(TRUE);
#ifdef DEBUG
	puts("return(TRUE)");
#endif
    } else {
#ifdef DEBUG
	puts("return(FALSE)");
#endif
	return(FALSE);
    }
}
コード例 #8
0
ファイル: Events.c プロジェクト: gibyfred/Starbird
/*
 half OK w95
 */
void subEventLoop() 
{
   short     sVal, sXCurrent, sYCurrent;
   long      lDevice;
	float tmp;

   nCurrentDir = DIR_NONE;
   czclear(0x404040, getgdesc(GD_ZMAX));

   strcpy(Message, ReadyMesg);
   vDrawScene();
   qreset();
   while (TRUE) {

      if (qtest()) {
         lDevice = qread(&sVal);

         switch (lDevice)
			{

			case INPUTCHANGE:
				#ifdef DOFF
					printf(" %d, %d, %d\n", Win_ids[0], Win_ids[1], sVal);
				#endif
				if ( sVal != 0 )
					Input_win = sVal;
				else
					Input_win = -1;
				break;

            case REDRAW:
				if ( sVal == Win_ids[1] && Win_ids[1] != -1 )
					vDrawHelpScene();
				else if ( sVal == Win_ids[0] )
				{
					winset(Win_ids[0]);
               		reshapeviewport();
               		getsize(&nWinWidth, &nWinHeight);
               		getorigin(&nXWinOrigin, &nYWinOrigin);
					tmp = Speed;
					Speed = 0.0;
               		vDrawScene();
					Speed = tmp;
				}
            break;

         case RIGHTMOUSE:
               dopup(mainmenu);
               break;
  
			case SPACEKEY:
				if ( EMode == FALSE )
				{
					p1EventLoop();
					strcpy(Message, "");
				}
				if ( EMode == TRUE )    /* game over */
				{
					vDrawOverScene();
				}
				break;

			case RKEY:
				if ( Last_Actions[FIRE] == TRUE )
					vEventLoop((&vDrawScene));
				break;

         case QKEY:
				if ( Input_win == Win_ids[1] ) 
				{
					winclose(Input_win);
					Win_ids[1] != -1;
				}
				else if ( Input_win == Win_ids[0] )
				{
					winclose(Win_ids[0]);
					if ( Win_ids[1] != -1 )
						winclose(Win_ids[1]);
	               exit(0);
				}
				break;

             default:
               break;
         }
      }
	  else
		getdev(DR_NUM_BUT, Devs, Last_Actions);

   }
}
コード例 #9
0
ファイル: Events.c プロジェクト: gibyfred/Starbird
/*---------------------------------------------------------------------------
main play loop
---------------------------------------------------------------------------*/
void p1EventLoop() {

   short     sVal;
   long      lDevice;
   Matrix    mNewMat;
   int		 reset = TRUE, i;
	static OKMode = FALSE;

	PMode = TRUE;

    strcpy(Message, "");
    while (TRUE) 
	{

		if (qtest()) 
		{
    		lDevice = qread(&sVal);

        	switch (lDevice) 
			{

			case INPUTCHANGE:
				#ifdef DOFF
					printf(" %d, %d, %d\n", Win_ids[0], Win_ids[1], sVal);
				#endif
				if ( sVal != 0 )
					Input_win = sVal;
				else
					Input_win = -1;
				break;

            case REDRAW:
				if ( sVal == Win_ids[1] && Win_ids[1] != -1 )
					vDrawHelpScene();
				else if ( sVal == Win_ids[0] )
				{
					winset(Win_ids[0]);
               		reshapeviewport();
               		getsize(&nWinWidth, &nWinHeight);
               		getorigin(&nXWinOrigin, &nYWinOrigin);
/*
               		vDrawScene();
*/
				}
               break;

				case ESCKEY:
					if ( OKMode != TRUE)
						return;
					break;

            case QKEY:
				if ( Input_win == Win_ids[1] ) 
				{
					winclose(Input_win);
					Win_ids[1] != -1;
				}
				else if ( Input_win == Win_ids[0] )
				{
					winclose(Win_ids[0]);
					if ( Win_ids[1] != -1 )
						winclose(Win_ids[1]);
	               exit(0);
				}
                	break;
        	}
		}

		getdev(DR_NUM_BUT, Devs, Last_Actions);

		if ( Time == Time/REDRAW_RATE*REDRAW_RATE )
		{
			if ( Energy <= 0 )
			{
				EMode = TRUE;
				return;
			}
			else if ( Time >= END_TIME )
			{
				OKMode = TRUE;
				last_mesg();
			}
			else
				vDrawScene();
		}

		for ( i=0; i<DR_NUM_BUT; i++)
		{
			Last_Actions[i] = FALSE;
		}
		Time++;

	}
}
コード例 #10
0
ファイル: Events.c プロジェクト: gibyfred/Starbird
/*---------------------------------------------------------------------------
---------------------------------------------------------------------------*/
void vDrawHelpScene()
{
		winset(Win_ids[1]);
		vDrawHelp();
		winset(Win_ids[0]);
}
コード例 #11
0
ファイル: ingy.c プロジェクト: sprax/coldz