void main()
{
  int gm,i,count, gd=DETECT,choice=1,width=0;
  char **buffer;

  initgraph(&gd,&gm,"c:\\tc\\bgi");

  if(initmouse()==0)
    {
      printf("\nUnable to intialize Mouse......");
      exit();
     }
  count=sizeof(menu)/sizeof(char*);
  settextstyle(TRIPLEX_FONT,0,3);
  displaymenu(menu,count,100,100);

  for(i=0;i<count;i++)
     {
       if (textwidth(menu[i])>width)
	   width=textwidth(menu[i]);
      }

   buffer=malloc(sizeof(menu));
   savemenu(menu,buffer,width,count,100,100);

   while(choice!=6)
     {
	choice=getresponse(menu,buffer,width,count,100,100);
	gotoxy(50,15);
	printf("\n\n\nYou have selected %s",menu[choice-1]);
     }
   }
void NetPlayerInfoView::calc_view_width_height()
{
	view_width_ = 0;
	int height = 0;
	if (player_pic_)
	{
		view_width_ = max(view_width_, player_pic_->get_width());
		height += player_pic_->get_height() + margin_;
	}

	Gobang::set_font(Gobang::font_default, name_font_size_, true);
	if (player_name_.length() > 0)
	{
		view_width_ = max(view_width_, textwidth(player_name_.c_str()));
		height += textheight(player_name_.c_str()) + margin_;
	}

	Gobang::set_font(Gobang::font_default, ready_font_size_);
	if(is_ready_)
	{
		view_width_ = max(view_width_, textwidth("Ready!"));
		height += textheight("Ready!") + margin_;
		if (is_playing_)
		{
			view_width_ = max(view_width_, playing_indicator_->get_width());
			height += playing_indicator_->get_height() + margin_;
		}
	}
	else if (!is_opposite_)
	{
		view_width_ = max(view_width_, button_ready_->get_width());
		height += button_ready_->get_height() + margin_;
	}
	view_height_ = height;
}
Exemplo n.º 3
0
void Style::normal_KEY_Shear() {
	setlinestyle(SOLID_LINE, 0, NORM_WIDTH);
	setcolor(BLACK);
	int sx = Event::item_drawing_area->layer->startx, sy = MAXY - 75, ex = Event::item_drawing_area->layer->endx, ey = MAXY - 50;
	rectangle(sx, sy, ex, ey);
	setfillstyle(SOLID_FILL, WHITE);
	bar(sx + 1, sy + 1, ex, ey);
	int textw = 0, texth = textheight("a"), y = (sy + ey - texth) / 2, x = sx + y - sy,
		lx = x + textw;
	setbkcolor(WHITE);
	outtextxy(x + textw, y, "X shear = ");
	textw = textw + textwidth("X shear = ");
	outtextxy(x + textw, y, InputText);
	textw = textw + textwidth(InputText);
	if (POS < 85) {
		lx = x + textw;
	}
	outtextxy(x + textw, y, " Y shear = ");
	textw = textw + textwidth(" Y shear = ");
	outtextxy(x + textw, y, InputText + 85);
	textw = textw + textwidth(InputText + 85);
	if (POS >= 85 && POS < 170) {
		lx = x + textw;
	}
	line(lx, y, lx, y + texth);
	setfillstyle(EMPTY_FILL, WHITE);
}
Exemplo n.º 4
0
void Report(int c,char *msg1,char *msg2)
 {
  int i,k,l;
  int twidth1;
  int twidth2;
  int Y=getmaxy()/2;
  settextstyle(7,0,3);
  twidth1=textwidth(msg1);
  twidth2=textwidth(msg2);
  for(i=Y,k=((getmaxx()-twidth1)/2),l=((getmaxx()-twidth2)/2);i>50;i--)
   {
    if(kbhit())
     {
      getch();
      break;
     }
    setcolor(15);
    outtextxy(k,i,msg1);
    setcolor(12);
    line(k,i+33,k+twidth1-7,i+33);
    setcolor(c);
    outtextxy(l,i+35,msg2);
    delay(21);
    setcolor(9);
    outtextxy(k,i,msg1);
    line(k,i+33,k+twidth1-7,i+33);
    outtextxy(l,i+35,msg2);
   }
  }
Exemplo n.º 5
0
 button(int x1,int y1)
 {x=x1;y=y1;flag=0;
  h=charheight+4;w=639-x1-2;
  w1=textwidth(" PLAY : ");
  w2=textwidth(" PAUSE : ");
  set1(flag,1);
 }
Exemplo n.º 6
0
void popup()
{
    int x1,x2,y1,y2, i,
        nRec = 13; // Numero de rectangulos
    x1 = x2 = (WIDTH/2);
    y1 = y2 = (HEIGHT/2);

    setfillstyle(1,0x00CCFF);
    for(i=0; i<nRec; x1-=15, y1-=10, x2+=15, y2+=10, i++)
    {
        bar(x1, y1, x2, y2);
        delay(15);
    }

    // ¡PERDISTE!
    setbkcolor(0x00CCFF);
    setcolor(0x0054D3);
    settextstyle(3, HORIZ_DIR, 6);
    outtextxy(WIDTH/2-textwidth("¡PERDISTE!")/2, y1+textheight("P")/2, "¡PERDISTE!");

    setcolor(0x4b78F2);
    settextstyle(3, HORIZ_DIR, 3);
    outtextxy(WIDTH/2-textwidth("Presiona cualquier tecla")/2, y1+textheight("P")*4, "Presiona cualquier tecla");

    settextstyle(3, HORIZ_DIR, 3);
    outtextxy(WIDTH/2-textwidth("para continuar")/2, y1+textheight("P")*5, "para continuar");
}
Exemplo n.º 7
0
void user_save()
{
	int a,b,w,px,i=-1;
	char filename[60],ch;
	restrictmouseptr(0,0,xmax,20);
	hidemouseptr();
	a=textwidth("Enter File Name");
	setfillstyle(1,BLUE);
	bar(0,0,xmax,20);
	setcolor(BLACK);
	outtextxy(10,5,"Enter File Name:");
	setfillstyle(1,WHITE);
	bar((a+10),2,(a+410),18);
	setfillstyle(1,CYAN);
	a=textwidth("No");
	bar((xmax-10-a),2,(xmax-10),18);
	b=a+10+textwidth("Save");
	bar((xmax-10-b),2,(xmax-20-a),18);
	setcolor(BLACK);
	outtextxy((xmax-9-b),3,"Save");
	outtextxy((xmax-9-a),3,"No");
	px=textwidth("Enter File Name")+10;
	while(1)
	{
	ch=get_filename(px,4);
	if(ch==13||ch==27)
	break;
	w=textwidth("A");
	px+=w;
	filename[++i]=ch;
	}
	filename[++i]='\0';
	showmouseptr();
	for(;;)
	{
		getmousepos(&button,&mousex,&mousey);
		if(mousex>(xmax-10-a)&&mousex<(xmax-10)&&button==1)       //deny loading/saving
		{
			button_hover((xmax-10-a),2,(xmax-10),18);
			hidemouseptr();
			initmouse();
			top_panel_default();
			top_panel_buttons(tool_but_num,0,1);
			showmouseptr();
			break;
		}
	else if(mousex>(xmax-10-b)&&mousex<(xmax-20-a)&&button==1)        //confirm loading/saving
		{
			button_hover((xmax-10-b),2,(xmax-20-a),18);
			save_bitmap(filename);
			hidemouseptr();
			initmouse();
			top_panel_default();
			top_panel_buttons(tool_but_num,0,1);
			showmouseptr();
			break;
		}
	}
}
Exemplo n.º 8
0
/*************************************************************************
 *
 *N  displaymessage
 *
 *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 *
 *   Purpose:
 *P
 *     This function displays a list of text strings in a
 *     popup text window.  The list must be NULL-terminated.  Must be in
 *     graphics mode to call this function.
 *E
 *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 *
 *   Parameters:
 *A
 *    string <input> == (char *) first text string to be displayed.
 *    ... <input> == (char *) variable list of text strings to be displayed.
 *E
 *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 *
 *   History:
 *H
 *    Barry Michaels    August 1991                        DOS Turbo C
 *E
 *************************************************************************/
void displaymessage( char *string, ... )
{
   int         i,maxw,height,x,y,pad, nlines;
   panel_type  panel;
   char **text;
   va_list arglist;

   va_start(arglist,string);
   nlines = 1;
   while (va_arg(arglist,char *)) nlines++;
   va_end(arglist);

   text = (char **)vpfmalloc((nlines+1)*sizeof(char *));
   text[0] = string;
   va_start(arglist,string);
   for (i=1;i<nlines;i++) {
      text[i] = va_arg(arglist,char *);
   }
   va_end(arglist);

   settextstyle( SMALL_FONT, HORIZ_DIR, 4 );
   maxw = 0;
   height = 0;
   for (i=0;i<nlines;i++) {
      if (textwidth(text[i]) > maxw) maxw = textwidth(text[i]);
      height = height + textheight(text[i]) + 5;

   }
   if (maxw < (textwidth("Continue") + 10))
      maxw = textwidth("Continue") + 10;
   pad = (maxw*10)/100;
   maxw = maxw + (2*pad);
   if (maxw > getmaxx())
     maxw = getmaxx() - 8;
   height = height + 2*(textheight("Continue") + 5) + 5;

   create_panel( &panel, maxw, height, menucolor, menubordercolor );
   x = pad;
   y = 0;
   for (i=0;i<nlines;i++) {
      y = y + textheight(text[i]) + 5;
      create_label( text[i], x, y, SMALL_FONT, 4, menutextcolor, &panel );
   }
   y = height - (textheight("Continue") + 6);
   x = (maxw - (textwidth("Continue") + 10))/2;
   create_button( 27, "Continue", x, y, SMALL_FONT, 4,
		  menutextcolor, menucolor, menubordercolor, RELIEVED,
		  &panel );

   get_display_position( &x, &y, panel.window );

   display_panel( &panel, x, y );
   i = process_panel( &panel, i );

   destroy_panel( &panel );
   close_panel( &panel );

   free(text);
}
Exemplo n.º 9
0
void  EscolheDroga (void)
   {
   register int         delta_x, delta_y;
   char                      *pch, _i[5];


   delta_x  = PER_X (35);
   delta_y  = 12 * CharH;

   CriaJanelaGrafica(
		       M_PADRAO,
		       (MAXX      - delta_x)/2,
		       (PER_Y(85) - delta_y /2),
		       (MAXX      + delta_x)/2,
		       (PER_Y(85) + delta_y /2),
		       0,
		       ""
		    );

   AtivaJanelaGrafica(M_PADRAO, 0);
   setcolor ( bea_color[14] );

   clearviewport();

   Moldura();

   pch = "Qual a Droga ? ";
   delta_x = DELTA_X(50) - textwidth(pch)/2;

   delta_y = 8 * CharH;
   gprintf ( delta_x, delta_y, "4 - Outra");

   delta_y = 6 * CharH;
   gprintf ( delta_x, delta_y, "3 - %s", Droga_P[2]);

   delta_y-= 2 + CharH;
   gprintf ( delta_x, delta_y, "2 - %s", Droga_P[1]);

   delta_y-= 2 + CharH;
   gprintf ( delta_x, delta_y, "1 - %s", Droga_P[0]);

   delta_y-= 2*CharH;
   gprintf ( delta_x, delta_y, pch );

   do{
     LEITURA('n', delta_x + textwidth(pch),
	     delta_y, _i, 1, 1L, 4L);

     } while ( (*_i < '1') || (*_i > '4') );

   DadProv.bits.droga = *_i - '1';

   } /* End of EscolheDroga () */
Exemplo n.º 10
0
static void textxy(int width, uint16_t pp, uint16_t lineheight, char_t *str, uint16_t length, int *outx, int *outy)
{
    int x = 0, y = 0;
    char_t *a = str, *b = str, *end = str + length, *p = str + pp;
    while(1) {
        if(a == end ||  *a == '\n' || *a == ' ') {
            int count = a - b, w = textwidth(b, a - b);
            while(x + w > width) {
                if(x == 0) {
                    int fit = textfit(b, count, width);
                    if(p >= b && p < b + fit) {
                        break;
                    }
                    count -= fit;
                    b += fit;
                    y += lineheight;
                } else {
                    y += lineheight;
                    int l = utf8_len(b);
                    count -= l;
                    b += l;
                }
                x = 0;
                w = textwidth(b, count);
            }

            if(p >= b && p < b + count) {
                w = textwidth(b, p - b);
                a = end;
            }

            x += w;
            if(a == end) {
                break;
            }
            b = a;

            if(*a == '\n') {
                if(p == a) {
                    break;
                }
                b += utf8_len(b);
                y += lineheight;
                x = 0;
            }
        }
        a += utf8_len(a);
    }

    *outx = x;
    *outy = y;
}
Exemplo n.º 11
0
void NetPlayerInfoView::show()
{
	if (buffer_img_.img)
	{
		putimage(buffer_img_.x, buffer_img_.y, buffer_img_.img);
		delimage(buffer_img_.img);
		buffer_img_.img = NULL;
	}
	calc_view_width_height();
	buffer_img_.x = pos_x_;
	buffer_img_.y = pos_y_;
	int temp_viewport_left, temp_viewport_right, temp_viewport_top, temp_viewport_bottom;
	getviewport(&temp_viewport_left, &temp_viewport_top, &temp_viewport_right, &temp_viewport_bottom);
	setviewport(pos_x_, pos_y_, pos_x_ + view_width_, pos_y_ + view_height_);
	buffer_img_.img = newimage(view_width_, view_height_);
	putimage(buffer_img_.img, 0, 0, NULL);
	setviewport(temp_viewport_left, temp_viewport_top, temp_viewport_right, temp_viewport_bottom);

	int target_top = pos_y_;
	if (player_pic_)
	{
		player_pic_->show_image_with_alpha(pos_x_ + view_width_ / 2 - player_pic_->get_width() / 2, target_top, 1.0);
		target_top += player_pic_->get_width() + margin_;
	}

	setcolor(WHITE);
	if (player_name_.length() > 0)
	{
		Gobang::set_font(Gobang::font_default, name_font_size_, true);
		xyprintf(pos_x_ + view_width_ / 2 - textwidth(player_name_.c_str()) / 2, target_top, player_name_.c_str());
		target_top += textheight(player_name_.c_str()) + margin_;
	}

	if (is_ready_)
	{
		Gobang::set_font(Gobang::font_default, ready_font_size_);
		xyprintf(pos_x_ + view_width_ / 2 - textwidth("Ready!") / 2, target_top, "Ready!");
		target_top += textheight("Ready!") + margin_;
		if (is_playing_)
		{
			playing_indicator_->show_image_with_alpha(pos_x_ + view_width_ / 2 - playing_indicator_->get_width() / 2, target_top, 1.0);
			target_top += playing_indicator_->get_height() + margin_;
		}
	}
	else if (!is_opposite_)
	{
		button_ready_->set_position(pos_x_ + view_width_ / 2 - button_ready_->get_width() / 2, target_top);
		button_ready_->show();
		target_top += button_ready_->get_height() + margin_;
	}
}
Exemplo n.º 12
0
/*************************************************************************
 *
 *N  yes_no
 *
 *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 *
 *   Purpose:
 *P
 *     This function displays a panel asking the user a yes or no
 *     question and returns the response.  Must be in graphics mode to call
 *     this function.
 *E
 *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 *
 *   Parameters:
 *A
 *    text     <input>==(char *) question string.
 *    return  <output>==(int) yes (TRUE) or no (FALSE).
 *E
 *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 *
 *   History:
 *H
 *    Barry Michaels   May 1991                    DOS Turbo C
 *E
 *************************************************************************/
int yes_no( char *text )
{
   panel_type  panel;
   int         no_id = 27;
   int         yes_id = 13;
   int         x,y,width,height,maxheight,id=0;

   settextstyle( SMALL_FONT, HORIZ_DIR, 4 );

   width = 0;
   maxheight = 0;
   width = textwidth(text);
   maxheight = textheight(text);

   width = width + 50;
   if (width > getmaxx())
      width = getmaxx()-10;
   height = maxheight * 5;

   create_panel( &panel,width,height,menucolor,menubordercolor );

   y = maxheight;
   create_label( text,CENTER,y,SMALL_FONT,4,menutextcolor,&panel );
   y += maxheight;

   create_button( yes_id, "Yes",
		  3, height-textheight("Y")-6,
		  SMALL_FONT, 4,
		  menutextcolor, menucolor, menubordercolor, RELIEVED,
		  &panel );
   create_button( no_id, "No",
		  width-textwidth("No")-13,
		  height-textheight("No")-6,
		  SMALL_FONT, 4,
		  menutextcolor, menucolor, menubordercolor, RELIEVED,
		  &panel );

   get_display_position( &x, &y, panel.window );

   display_panel( &panel, x,y );

   id = process_panel(&panel, id);

   destroy_panel( &panel );
   close_panel( &panel );

   if (id == yes_id)
      return TRUE;
   else
      return FALSE;
}
Exemplo n.º 13
0
void menu()
{
    int op=-1, xm, ym, i, margin = 70;
    String opciones[] = {"Jugar", "Tienda", "Ayuda", "Créditos"};
    setbkcolor(0x0066F4);
    setfillstyle(1, 0x0066F4);
    setcolor(0x003988);
    settextstyle(2, HORIZ_DIR, 8);

    for(i=0; i<4; i++, margin+=50)
    {
        bar(WIDTH/2-textwidth(opciones[3])/2-5, HEIGHT/2+margin-10, WIDTH/2+textwidth(opciones[3])/2+5, HEIGHT/2+margin+textheight(opciones[3])+10);
        outtextxy(WIDTH/2-textwidth(opciones[i])/2, HEIGHT/2+margin, opciones[i]);
    }

    do
    {
        while(!ismouseclick(WM_LBUTTONDOWN));
        getmouseclick(WM_LBUTTONDOWN, xm, ym);
        margin = 70;
        for(i=0; i<4; i++, margin+=50)
            if(xm>WIDTH/2-textwidth(opciones[3])/2-5
               && xm<WIDTH/2+textwidth(opciones[0])/2-10
               && ym>HEIGHT/2+margin-10
               && ym<HEIGHT/2+margin+textheight(opciones[3])+10)
                {
                    op = i;
                    i=5;
                    break;
                }
    }while(op==-1);

    fflush(stdin);
    switch(op)
    {
        case 0:
            juego(3);
            break;
        case 1:
            tienda();
            break;
        case 2:
            ayuda();
            break;
        case 3:
            creditos();
            break;
    }
}
Exemplo n.º 14
0
static PyObject* emb_get_width(PyObject *self, PyObject *args)
{
	char *txt;
	if (!PyArg_ParseTuple(args, "s:get_width",&txt))
		return NULL;
	return Py_BuildValue("i",textwidth(txt));
}
Exemplo n.º 15
0
static void storeline(textlabel_t * lp, char *line, char terminator,
		      graph_t * g)
{
    double width = 0.0;

    lp->u.txt.line =
	ALLOC(lp->u.txt.nlines + 2, lp->u.txt.line, textline_t);
    lp->u.txt.line[lp->u.txt.nlines].str = line;
    width =
	textwidth(&(lp->u.txt.line[lp->u.txt.nlines]), lp->fontname,
		  lp->fontsize);
    lp->u.txt.line[lp->u.txt.nlines].just = terminator;
    lp->u.txt.nlines++;
    /* total width = max line width */
    if (lp->dimen.x < width)
	lp->dimen.x = width;
    /* recalculate total height */
#if !defined(DISABLE_CODEGENS) && !defined(HAVE_GD_FREETYPE) && !defined(ONLY_PLAIN_GEN) //maks
    if (Output_codegen == &GD_CodeGen)
	lp->dimen.y = textheight(lp->u.txt.nlines, lp->fontsize);
    else
	lp->dimen.y =
	    lp->u.txt.nlines * (int) (lp->fontsize * LINESPACING);
#else
    lp->dimen.y = lp->u.txt.nlines * (int) (lp->fontsize * LINESPACING);
#endif

}
Exemplo n.º 16
0
int main() {
	int x,y,i,j,n,unidad,modo;
	char sx[10],sy[10],sn[10];


	initgraph (&unidad,&modo,"c:\\bc\\bgi");
	if (graphresult() != 0) {
		cout << "Error al tratar de pasar al modo grafico\n";
		getch();
		return 1;
	}
	setpalette (3,YELLOW);
	setcolor (3);
	settextstyle (GOTHIC_FONT,HORIZ_DIR,3);
	i = textheight ("E");
	j = textwidth ("ESTRUCTURAS DE DATOS EN PASCAL");
	itoa(i,sx,10);
	itoa(j,sy,10);
	settextstyle (DEFAULT_FONT,HORIZ_DIR,1);
	char *p;
	int k = strlen (sx) +  strlen (sy) + 2;
	p = new char [k];
	strcpy (p,sx);
	strcat (p," ");
	strcat (p,sy);
	outtext (p);
	delete p;
	getch();
	closegraph();
	return 0;
}
Exemplo n.º 17
0
Arquivo: csort.c Projeto: eposts/Rich
void get_number( int *a_number, int *times, char *tstring, int *x, int *y )
{
int power;         /* 十的指数,用10的power来乘以数字 */
char achar[2];
char bchar = 0;
achar[1] = 0;

while ( bchar <= 47 || bchar >= 59 )  /* 允许的数字0-9 */
  {
   bchar = getch();
   if ( bchar == 13 )   /* 13 = CR; 用户按了ENTER建  */
     {
      bchar = 48;
      *times = 0;
      break;
     }
  }

 if ( *times )
   {
    achar[0] = bchar;

    outtextxy( *x, *y, achar );
    *x = *x + textwidth( achar );
    tstring[TIMES - ( (*times)--)] = achar[0];
    if ( *times )
    get_number( a_number, times, tstring, x, y );
   }

    power = (int)( pow10(( strlen( tstring ) - ((*times) + 1))));
    bchar = tstring[*times];
    *a_number += ( power  * ( bchar - 48 ));
    (*times )++;
}
Exemplo n.º 18
0
int text_height(int right, uint16_t lineheight, char_t *str, uint16_t length)
{
    int x = 0, y = 0;
    char_t *a = str, *b = a, *end = a + length;
    while(1) {
        if(a == end || *a == ' ' || *a == '\n') {
            int count = a - b, w = textwidth(b, count);
            while(x + w > right) {
                if(x == 0) {
                    int fit = textfit(b, count, right);
                    count -= fit;
                    if(fit == 0 && (count != 0 || *b == '\n')) {
                        return 0;
                    }
                    b += fit;
                    y += lineheight;
                } else {
                    y += lineheight;
                    int l = utf8_len(b);
                    count -= l;
                    b += l;
                }
                x = 0;
                w = textwidth(b, count);
            }

            x += w;
            b = a;

            if(a == end) {
                break;
            }

            if(*a == '\n') {
                y += lineheight;
                b += utf8_len(b);
                x = 0;
            }

        }
        a += utf8_len(a);
    }

    y += lineheight;

    return y;
}
Exemplo n.º 19
0
void forMyCollege()
 {
  int i,k;
  int twidth1;
  settextstyle(7,0,3);
  setcolor(15);
  sprintf(msg1,"By Computer Students G.P.T.C.Thirurangadi");
  twidth1=textwidth(msg1);
  outtextxy(((getmaxx()-twidth1)/2),getmaxy()/2-25,msg1);
  setcolor(9);
  delay(2500);
  sprintf(msg1,"By Computer Students G.P.T.C.Thirurangadi");
  twidth1=textwidth(msg1);
  outtextxy(((getmaxx()-twidth1)/2),getmaxy()/2-25,msg1);
  setcolor(15);

 }
void CGameControllerRalla3::DrawHUD()
{
    if (m_PlayerWin == PLAYER_NULL)
    {
        if (m_ActivePlayer == PLAYER_1)
        {
            circle(mousex(), mousey(), 10);
            outtextxy(g_Game.GetScreenW()/2-textwidth("TURNO: JUGADOR 1")/2, dimTY+60, "TURNO: JUGADOR 1");
        }
        else
        {
            moveto(mousex()-10, mousey()-10);
            lineto(mousex()+10, mousey()+10);
            moveto(mousex()+10, mousey()-10);
            lineto(mousex()-10, mousey()+10);

            if (m_CPU)
                outtextxy(g_Game.GetScreenW()/2-textwidth("TURNO: CPU")/2, dimTY+120, "TURNO: CPU");
            else
                outtextxy(g_Game.GetScreenW()/2-textwidth("TURNO: JUGADOR 2")/2, dimTY+60, "TURNO: JUGADOR 2");
        }
    }
    else
    {
        const char *sBuff;
        if (m_PlayerWin == PLAYER_1)
            sBuff = "Gana el JUGADOR 1";
        else if (m_PlayerWin == PLAYER_2)
            sBuff = "Gana el JUGADOR 2";
        else if (m_PlayerWin == PLAYER_CPU)
            sBuff = "Gana la CPU";
        else
            sBuff = "EMPATE!";

        int xt = g_Game.GetScreenW()/2 - textwidth(sBuff)/2;
        int yt = g_Game.GetScreenH()/2 - textheight(sBuff)/2;

        outtextxy(xt, yt, sBuff);

        xt = g_Game.GetScreenW()/2 - textwidth("pulsa INTRO para reiniciar")/2;
        yt = g_Game.GetScreenH()/2 - textheight("pulsa INTRO para reiniciar")/2;
        yt += textheight(sBuff) + 15;
        outtextxy(xt, yt, "pulsa INTRO para reiniciar");
        rectangle(-1, yt-2, g_Game.GetScreenW()+1, yt-1 + textheight("pulsa INTRO para reiniciar") + 2);
    }
}
Exemplo n.º 21
0
int main(void)
{
   int gdriver = DETECT, gmode, errorcode;
   int midx, midy,tam=5,cor=15;
   char texto[35];
   int letra=0;
   time_t t;
   char *fname[] = { "DEFAULT font",
		  "TRIPLEX font",
		  "SMALL font",
		  "SANS SERIF font",
		  "GOTHIC font"
		};
   initgraph(&gdriver,&gmode,"\\bc\\bgi");
   errorcode = graphresult();
   if (errorcode != grOk)  /* an error occurred */
   {
      printf("Graphics error: %s\n", grapherrormsg(errorcode));
      printf("Press any key to halt:");
      getch();
      exit(1); /* terminate with an error code */
   }
   midx = getmaxx();
   midy = 240;

   printf("Digite o Texto: ");
   gets(texto);
   flushall();

   srand((unsigned) time(&t));
   cleardevice();
   while(!kbhit())
   {
     settextstyle(SANS_SERIF_FONT, HORIZ_DIR, tam);
     setcolor(cor);
     outtextxy(midx, midy, texto);
     delay(10);
     setcolor(0);
     outtextxy(midx, midy, texto);
     midx-=2;

     if(midx<=(textwidth(texto)*-1))
     {
       tam=rand()%10;
       cor=rand()%15;
       if(cor==0)
	 cor=1;
       midx=640;
       midy =rand()% 480;
       letra=rand()%5;
     }
   }

   /* clean up */
   closegraph();
   return 0;
}
Exemplo n.º 22
0
Arquivo: ui.c Projeto: draziw-/uTox
static void drawgroup(int UNUSED(x), int UNUSED(y), int UNUSED(w), int UNUSED(height))
{
    GROUPCHAT *g = sitem->data;

    drawalpha(BM_GROUP, LIST_RIGHT + SCALE * 5, SCALE * 5, BM_CONTACT_WIDTH, BM_CONTACT_WIDTH, LIST_MAIN);

    setcolor(C_TITLE);
    setfont(FONT_TITLE);
    drawtext(LIST_RIGHT + 30 * SCALE, 1 * SCALE, g->name, g->name_length);

    setcolor(LIST_MAIN);
    setfont(FONT_STATUS);
    drawtext(LIST_RIGHT + 30 * SCALE, 8 * SCALE, g->topic, g->topic_length);

    setcolor(GRAY(150));
    uint32_t i = 0;
    int k = LIST_RIGHT + 30 * SCALE;

    uint64_t time = get_time();

    unsigned int pos_y = 15;
    while(i < g->peers)
    {
        uint8_t *name = g->peername[i];
        if(name)
        {
            uint8_t buf[134];
            memcpy(buf, name + 1, name[0]);
            memcpy(buf + name[0], ", ", 2);

            int w = textwidth(buf, name[0] + 2);
            if (i == g->our_peer_number) {
                setcolor(C_GREEN);
            } else if (time - g->last_recv_audio[i] <= (uint64_t)1 * 1000 * 1000 * 1000) {
                setcolor(C_RED);
            } else {
                setcolor(GRAY(150));
            }

            if(k + w >= (utox_window_width - 32 * SCALE)) {
                if (pos_y == 15) {
                    pos_y += 6;
                    k = LIST_RIGHT + 30 * SCALE;
                } else {
                    drawtext(k, pos_y * SCALE, (uint8_t*)"...", 3);
                    break;
                }
            }

            drawtext(k, pos_y * SCALE, buf, name[0] + 2);

            k += w;
        }
        i++;
    }
}
Exemplo n.º 23
0
int user_new()
{
	int a,b;
	restrictmouseptr(0,0,xmax,20);
	hidemouseptr();
	a=textwidth("This Action will erase current drawing, Continue?")+10;
	setfillstyle(1,BLUE);
	bar(0,0,xmax,20);
	settextstyle(0,0,1);
	setcolor(BLACK);
	outtextxy(10,5,"This Action will erase current drawing, Continue?");
	setfillstyle(1,CYAN);
	bar((a+18),1,(a+18+textwidth("Ya")+2),18);
	outtextxy((a+20),5,"Ya");
	b=a+textwidth("Ya")+10;
	bar((b+18),1,(b+18+textwidth("Na")+2),18);
	outtextxy((b+20),5,"Na");
	showmouseptr();
	for(;;)
	{	
		getmousepos(&button,&mousex,&mousey);
		if(mousex>(a+20)&&mousex<b+10&&button==1)      //new confirm
		{
			hidemouseptr();
			initmouse();
			draw_canvas_default();
			top_panel_default();
			top_panel_buttons(tool_but_num,0,1);
			showmouseptr();
			arrcnt=-1;
			return 1;
		}
	else if(mousex>b+20&&mousex<(b+36)&&button==1)        //deny new
		{
			hidemouseptr();
			initmouse();
			top_panel_default();
			top_panel_buttons(tool_but_num,0,1);
			showmouseptr();
			return 0;
		}
	}
}
Exemplo n.º 24
0
/*************************************************************************
 *
 *N  displayinfo
 *
 *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 *
 *   Purpose:
 *P
 *     This function displays an array of text strings in a
 *     popup text window.  Must be in graphics mode to call this function.
 *E
 *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 *
 *   Parameters:
 *A
 *    text[] <input> == (char *) array of text strings to be displayed.
 *    nlines <input> == (int) number of text lines.
 *E
 *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 *
 *   History:
 *H
 *    Barry Michaels    June 1990    Original Version    DOS Turbo C
 *E
 *************************************************************************/
void displayinfo( char *text[],
		  int  nlines )
{
   int         i,maxw,height,x,y,pad;
   panel_type  panel;

   arrow_cursor();
   settextstyle( SMALL_FONT, HORIZ_DIR, 4 );
   maxw = 0;
   height = 0;
   for (i=0;i<nlines;i++) {
      if (textwidth(text[i]) > maxw) maxw = textwidth(text[i]);
      height = height + textheight(text[i]) + 5;
   }
   if (maxw < (textwidth("Continue") + 10))
      maxw = textwidth("Continue") + 10;
   pad = (maxw*10)/100;
   maxw = maxw + (2*pad);
   if (maxw > getmaxx())
     maxw = getmaxx() - 8;
   height = height + 2*(textheight("Continue") + 10);

   create_panel( &panel, maxw, height, menucolor, menubordercolor );
   x = pad;
   y = 0;
   for (i=0;i<nlines;i++) {
      y = y + textheight(text[i]) + 3;
      create_label( text[i], x, y, SMALL_FONT, 4, menutextcolor, &panel );
   }
   y = height - (textheight("Continue") + 6);
   x = (maxw - (textwidth("Continue") + 10))/2;
   create_button( 27, "Continue", x, y, SMALL_FONT, 4,
		  menutextcolor, menucolor, menubordercolor, RELIEVED,
		  &panel );

   get_display_position( &x, &y, panel.window );

   display_panel( &panel, x, y );
   i = process_panel( &panel, i );

   destroy_panel( &panel );
   close_panel( &panel );
}
void afficher_menu(int dimy)
{  int px = 20;

   setfillstyle(SOLID_FILL, RED);
   bar(0, dimy + 8, 1202, dimy + 40);   /* Barre rouge pour la couleur de fond */

   setcolor(WHITE);
   settextstyle(DEFAULT_FONT, HORIZ_DIR, 2);
   outtextxy(px, dimy + 15, "(N)ouveau Fichier");
   px += textwidth("(N)ouveau Fichier") + 20;         /* Décaler la position horiz */

   outtextxy(px, dimy + 15, "(D)emarrer Auto");
   px += textwidth("(D)emarrer auto") + 20;           /* Décaler la position horiz */

   outtextxy(px, dimy + 15, "(ESC) Annuler Simulation");
   px += textwidth("(ESC) Annuler Simulation") + 20;  /* Décaler la position horiz */

   outtextxy(px, dimy + 15, "(Q)uitter");
}
Exemplo n.º 26
0
void Style::active_outtext() {
	setlinestyle(SOLID_LINE, 0, NORM_WIDTH);
	setcolor(BLACK);
	setfillstyle(SOLID_FILL, LIGHTGRAY);
	setbkcolor(LIGHTGRAY);
	rectangle(item->layer->startx, item->layer->starty, item->layer->endx, item->layer->endy);
	bar(item->layer->startx + 1, item->layer->starty + 1, item->layer->endx, item->layer->endy);
	outtextxy((item->layer->endx + item->layer->startx - textwidth(text)) / 2, (item->layer->endy + item->layer->starty - textheight(text)) / 2, text);
	setbkcolor(WHITE);
	setfillstyle(EMPTY_FILL, WHITE);
}
Exemplo n.º 27
0
Arquivo: menu.c Projeto: Cougar/pwm
/* Calculate the desired width of a menu window
 */
static int menu_width(WMenuData *mdata, int flags)
{
	int i=0, maxw=0, inc=0, w=0;
	WMenuEnt *ent=mdata->entries;
	
	if(!(flags&WMENU_NOTITLE))
		maxw=textwidth(GRDATA->font, mdata->title)+2*CF_MENUTITLE_H_SPACE
			 +GRDATA->stick_pixmap_w;
		
	for(; i<mdata->nentries; i++, ent++){
		w=textwidth(GRDATA->menu_font, ent->name);
		w+=2*CF_MENUENT_H_SPACE;
		if(ent->flags&WMENUENT_SUBMENU)
			inc=GRDATA->submenu_ind_w+CF_SUBMENU_IND_H_SPACE;
		if(w>maxw)
			maxw=w;
	}
	
	return maxw+inc;
}
Exemplo n.º 28
0
void leerTexto(int x,int y, char cadena[])
{
 char tecla, var;     
 int contador=0;
 cadena[0]='\0';
 
 do{
      //Si no se presiona una tecla, se imprimira un guion definidamente
      do{  //párpadeo
			 setcolor(15);
			 outtextxy(x+textwidth(cadena),y,"_       ");
			 retraso(50);
			 setcolor(0);
			 outtextxy(x+textwidth(cadena),y,"_       ");
			 retraso(50);
			 setcolor(15);
      }while(!kbhit());
     
      tecla = getch();
     
      if(tecla==0)  // si es código extendido
         tecla=getch();
        if(tecla==8 && contador > 0)  // se presion¢ <backspace>
			{
				 setcolor(BLACK);
				 outtextxy(x,y,cadena);  // se borra en la pantalla
				 cadena[--contador]='\0';  //se borr¢ £ltimo caracter del arreglo
				 setcolor( WHITE );
				 outtextxy(x,y,cadena);
			}
		 else
			{  
              if(tecla!=13)
              {  
				 cadena[contador++]=tecla;
				 cadena[contador]='\0';
				 outtextxy(x,y,cadena);
              }
            }    
  }while(tecla!=13); 
}
Exemplo n.º 29
0
static void drawtexth(int x, int y, char_t *str, uint16_t length, int d, int h, int hlen, uint16_t lineheight)
{
    // Draw cursor
    h -= d;
    if(h + hlen < 0 || h > length) {
        drawtext(x, y, str, length);
        return;
    } else if(hlen == 0) {
        drawtext(x, y, str, length);
        int w =  textwidth(str, h + hlen);
        drawvline(x + w, y, y + lineheight, COLOR_MAIN_TEXT);
        return;
    }

    if(h < 0) {
        hlen += h;
        h = 0;
        if(hlen < 0) {
            hlen = 0;
        }
    }

    if(h + hlen > length) {
        hlen = length - h;
    }

    int width;

    width = drawtext_getwidth(x, y, str, h);

    uint32_t color = setcolor(COLOR_SELECTION_TEXT);

    int w = textwidth(str + h, hlen);
    draw_rect_fill(x + width, y, w, lineheight, COLOR_SELECTION_BACKGROUND);
    drawtext(x + width, y, str + h, hlen);
    width += w;

    setcolor(color);

    drawtext(x + width, y, str + h + hlen, length - (h + hlen));
}
Exemplo n.º 30
0
/*************************************************************************
 *
 *N  info_window
 *
 *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 *
 *   Purpose:
 *P
 *     This function displays a temporary window to the screen with a
 *     single string of text.  Must be in graphics mode to call this
 *     function.
 *E
 *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 *
 *   Parameters:
 *A
 *    text    <input> == (char *)message to display.
 *    return <output> == (window_type) window created and displayed.
 *                       [Will need to be deleted]
 *E
 *::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
 *
 *   History:
 *H
 *    Barry Michaels   July 1990   Original Version   DOS Turbo C
 *E
 *************************************************************************/
window_type info_window( char *text )
{
   window_type w;
   int x,y;

   settextstyle(SMALL_FONT,HORIZ_DIR,4);
   settextjustify(LEFT_TEXT,BOTTOM_TEXT);
   if (textwidth(text) > getmaxx())
     x = getmaxx()-20;
    else
     x = textwidth(text) + 20;
   create_window( &w, x, textheight(text)+10,
		  menucolor,menubordercolor );
   get_display_position( &x, &y, w );
   open_window( &w, x,y );
   setcolor(menutextcolor);
   hidemousecursor();
   outtextxy( 10,textheight(text)+5,text );
   showmousecursor();
   return w;
}