Example #1
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;
		}
	}
}
Example #2
0
void main()
{
	int gd=DETECT, gm, maxx, maxy, x, y, button;

	initgraph(&gd, &gm, "c:/tc/bgi");
	maxx=getmaxx();
	maxy=getmaxy();

	rectangle(0,56,maxx,maxy);
	setviewport(1,57,maxx-1,maxy-1,1);

	gotoxy(26,1);
	printf("DEMONSTRATION : MOUSE IN C");
	gotoxy(28,2);
	printf("BY: OSHO PRAKASH GIRI");

	if(initmouse()==0)
	{
		closegraph();
		restorecrtmode();
		printf("\nMOUSE DRIVER NOT LOADED");
		exit();
	}

	restrictmouseptr(1,57,maxx-1,maxy-1);
	showmouseptr();

	getch();
}
int main()
{    	int xi,yi,xo,yo,x,y;
	int gdriver=DETECT,gmode;
	initgraph(&gdriver,&gmode,"D:\\BORLANDC\\BGI");
      //	int xmax=getmaxx();
      //	int ymax=getmaxy();
	initmouse();
	showmouse();
	getmouse(&xi,&yi);
	getmouse(&xo,&yo);
	int h,r ;
	float m=pow((xo-xi),2);
	float n=pow((yo-yi),2);
	r=sqrt(m+n);
	xi=xi + ((xo-xi)/2);
	yi=yi +((yo-yi)/2);
 //	circle(xi,yi,10);
	h=1-r;
	x=0;y=r;
	while(x<=y)
	{      	crc(x,y,xi,yi);
		if(h<0)
		{
			h=h+(2*x)+1 ;
		}
		else
		{       h=h+(2*(x-y))+1 ;
			y=y-1;
		}
		x++;
	}
	getch();
	closegraph();
	return 0;
}
Example #4
0
void editor_init(void)
{
    Text *txt = text_load(NULL);

    vga_init();
    print_init();
	view_main_window();

    editor.root =  GetMenu(CHINESE);
    if(!(editor.root)){
        messagebox_manager("load menu failed.");
        getch();
        text_free(txt);
        exit(1);
    }
    view_main_menu(editor.root);
    if(!txt){
        messagebox_manager("open empty file failed.");
    }
    editor.cli = clipborad_init();

    initmouse();
    fprintf(stderr,"logging...\n");
    showmouseptr();
    editor.txt = txt;
    editor.mode = MENU;
}
Example #5
0
void TextMode(void)
  {
  union REGS r;


#ifdef MOUSE
  int m;

  if (mouinstall)
    {
    m=moucur(2);
    if (m) moucur(0);
    }
#endif
  r.h.ah = 0;
  r.h.al = TMODE;
  int86(0x10,&r,&r);
  CurMode=TMODE;

#ifdef MOUSE
  if (mouinstall)
    {
    initmouse();
    MXlatx=MouseMaxx/79;
    if (MXlatx==0) MXlatx=1;
    MXlaty=MouseMaxy/24;
    if (MXlaty==0) MXlaty=1;
    if (m) moucur(TRUE);
    }
#endif
  SetTextColors();
  }
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]);
     }
   }
Example #7
0
void main(int argc,char *argv[])
  {
  if (initmouse()==FALSE)
    { 
    errorbox("GameMaker requires a Microsoft","compatible mouse! (Q)uit",30);
    exit(quit);
    }
#ifndef DEBUG
  Palette(5,10,10,10);
  Palette(7,16,16,16);
#endif
  mouclearbut();
  randomize();

#ifdef CHKREG
  if ((argc >= 2)&&(strcmpi(argv[1],"REGISTER") == 0)) regi();
  firststart();
#else
  gmmain();
#endif
  Palette(5,42,0,42);
  Palette(7,42,42,42);
  clrbox(0,0,79,24,7);
  exit(quit);
  }
Example #8
0
void GraphMode(void)
  {
  union REGS r;
#ifdef MOUSE
  int m;

  if (mouinstall)
    {
    m=moucur(2);
    if (m) moucur(0);
    }
#endif

  r.h.ah = 0;
  r.h.al = GMODE;
  CurMode=GMODE;
  int86(0x10,&r,&r);

#ifdef MOUSE
  if (mouinstall)
    {
    initmouse();
    MXlatx= MouseMaxx/319;     //    MXlatx=2;
    if (MXlatx==0) MXlatx=1;
    MXlaty= MouseMaxy/199;
    if (MXlaty==0) MXlaty=1;
    if (m) moucur(TRUE);
    }
#endif
  }
   void graphics()
   {
	d=DETECT;
	initgraph(&d,&m,"c:\\tc\\");
	initmouse();
	mx=getmaxx();
	my=getmaxy();
   }
Example #10
0
void UIAPI uispawnend()
/**********************/
{
    restorekeyb();
    if( MouseInstalled ) initmouse( TRUE );
    uiswap();
    _ui_refresh(1);
}
Example #11
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;
		}
	}
}
Example #12
0
int GUIInitMouse( int param )
{
    int init;

    Param = param;
#ifdef __DOS__
    if( GraphicsMouse ) {
        init = uiinitgmouse( param );
        if( GraphicsDlg ) {
            FlipCharacterMap();
        }
    } else {
        init = initmouse( param );
    }
#else
    init = initmouse( param );
#endif
    GMouseOn = true;
    return( init );
}
Example #13
0
void main()
{
 int gdriver = DETECT, gmode;
 initgraph(&gdriver, &gmode, "\\tc\\bgi");
 cleardevice();
 king("ch1");
 int Mstatus = initmouse();
 int button,m,n;
 if(Mstatus == 0 )
  outtextxy(50,50, "Mouse Support Not Available");
 settextstyle(2,0,4);
 while(1)
{ showmouseptr();
  getmousepos(&button,&m,&n);
  if(m>245 && m<325 && n>220 && n<232)
  { setcolor(RED);
    outtextxy(250,220,"PLAYER vs PLAYER"); }
  else
  { setcolor(WHITE);
    outtextxy(250,220,"PLAYER vs PLAYER");
  if(m>245 && m<325 && n>240 && n<252)
  { setcolor(RED);
    outtextxy(250,240,"CHESS PUZZLES");  }
  else
  { setcolor(WHITE);
    outtextxy(250,240,"CHESS PUZZLES");
  if(m>245 && m<325 && n>260 && n<272)
  { setcolor(RED);
    outtextxy(250,260,"BACK");  }
  else
  { setcolor(WHITE);
    outtextxy(250,260,"BACK"); }}}
  if(button == 1)
  { if(m>245 && m<325 && n>220 && n<232)
    { hidemouseptr();
      video(450,150);
      createnewfile();
      spawnl(P_WAIT,"load.exe", NULL);  // load
      spawnl(P_WAIT,"chess.exe", NULL);  // player vs player
      cleardevice();
      king("ch1"); }
    if(m>245 && m<325 && n>240 && n<252)
    { hidemouseptr();
      video(450,150);
      spawnl(P_WAIT,"menu6.exe", NULL); } // chess puzzles menu
//      exit(0); }
    if(m>245 && m<325 && n>260 && n<272)
    { hidemouseptr();
      video(450,150);
//      spawnl(P_WAIT,"g:\\exe\\menu1.exe", NULL);  // back to main menu
      break; }}}}
Example #14
0
void
threadmain(int argc, char **argv)
{
	char *p;
	int lfd;

	p = "300x40@100,100";
	
	ARGBEGIN{
	case 'W':
		p = ARGF();
		break;
	case 't':
		textmode = 1;
		break;
	case 'k':
		nokill = 1;
		break;
	default:
		usage();
	}ARGEND;

	if(argc != 1)
		usage();

	winsize = p;

	title = argv[0];

	lfd = dup(0, -1);
	Binit(&b, lfd, OREAD);

	rbar = Rect(0, 0, 60, 1);
	if (!textmode){
		if(initdraw(0, nil, "bar") < 0)
			sysfatal("initdraw: %r");
		initcolor();
		if((mc = initmouse(nil, screen)) == nil)
			sysfatal("initmouse: %r");
		if((kc = initkeyboard(nil)) == nil)
			sysfatal("initkeyboard: %r");
		display->locking = 1;
		threadcreate(resizethread, nil, STACK);
		threadcreate(keyboardthread, nil, STACK);
		threadcreate(mousethread, nil, STACK);
		resize();
		unlockdisplay(display);
	}
	proccreate(updateproc, nil, STACK);
}
Example #15
0
void main()
{
	int gd=DETECT,gm,maxx,maxy,x,y,button;

	initgraph(&gd,&gm,"C:\\TC");
	maxx=getmaxx();
	maxy=getmaxy();

	rectangle(0,56,maxx,maxy);
	setviewport(1,57,maxx-1,maxy-1,1);

	gotoxy(26,1);
	printf("MOUSE DEMONSTRATION PROGRAM");

	if(initmouse()==0)
	{
		closegraph();
		restorecrtmode();
		printf("\nMouseDriver not loaded");
		exit(0);
	}

	restrictmouseptr(1,57,maxx-1,maxy-1);
	showmouseptr();

	gotoxy(1,2);
	printf("Left Button");

	gotoxy(15,2);
	printf("Right Button");

	gotoxy(55,3);
	printf("Press Any Key to Exit...");

	while(!kbhit())
	{
		getmousepos(&button,&x,&y);

		gotoxy(5,3);
		(button & 1)==1? printf("DOWN") : printf("UP  ");

		gotoxy(20,3);
		(button & 2)==2? printf("DOWN") : printf("UP  ");

		gotoxy(65,2);
		printf("x=%03d y=%03d",x,y);
	}
}
Example #16
0
bool UIAPI uiinit( int install )
/******************************/
{
    bool    initialized;

    initialized = uistart();

    if( initialized ) {
#ifdef __UNIX__
        _initmouse( install );
#else
        initmouse( install );
#endif
    }
    return( initialized );
}
Example #17
0
/*
 * UsrScrnMode -- setup the user screen mode
 */
bool UsrScrnMode( void )
{
#if 0
    if( UIData->height != ScrnLines ) {
        UIData->height = ScrnLines;
        if( _IsOn( SW_USE_MOUSE ) ) {
            /*
                This is a sideways dive into the UI to get the boundries of
                the mouse cursor properly defined.
            */
            initmouse( 1 );
        }
    }
#endif
    return( FALSE );
}
Example #18
0
void main()
{
int gdriver=DETECT,gmode;
int i,a,b,c,d,status,temp=0;
clrscr();
initgraph(&gdriver,&gmode,"C:\\TC\\BGI ");
line(320,100,310,110);
line(310,110,310,120);
line(310,120,320,130);
line(320,130,330,120);
line(330,120,330,110);
line(330,110,320,100);
a=310;
b=120;
c=320;
d=130;
left(a,b,c,d);
 showmouseptr();
 status=initmouse();

 while(!kbhit())
 {
 showmouseptr();
 again :
 getmouse(&x,&y,&click);

 if(click==1)
 {
 temp=temp+1;

 if(temp%2==0)
 {
 setfillstyle(SOLID_FILL,RED);
 floodfill(x,y,WHITE);
 delay(500);
 }

 else
 {
 setfillstyle(SOLID_FILL,BLUE);
 floodfill(x,y,WHITE);
 delay(500);
 }
 }
 }
getch();
}
Example #19
0
int menu()
{
	char *menu[]={"New Game","Option","Instruction","Exit"};
	int w=0,k,g=130,h=200;
	setbkcolor(0);
	initmouse();
	show();
	setcolor(8);
	settextstyle(1,0,2);
	for(k=0;k<4;k++)
	{
		outtextxy(g,h,menu[k]);
		h+=textheight(menu[k])+10;
	}
	settextstyle(4,0,5);
	setcolor(14);
	setpos(0,0);
	outtextxy(190,90,"SNAKE GAME");
	status("Select Any one using mouse pointer");
	while(1)
	{
		pos(&button,&n,&m);
		w=opt(n,m);
		settextstyle(1,0,2);
		g=130;
		h=200;
		for(k=0;k<4;k++)
		{
			if(w==k+1)
			{
				setcolor(11);
				outtextxy(g,h,menu[k]);
				h+=textheight(menu[k])+10;

				if(button==1)
					return w;
			}
			else
			{
				setcolor(8);
				outtextxy(g,h,menu[k]);
				h+=textheight(menu[k])+10;
			}
		}
	}
}
Example #20
0
/*---------------------------------------------------------
 Function: *

 Description:
 Initialize the INPUT SYSTEM.
 Prepare all available inputs and fill in device structures.
---------------------------------------------------------*/
void initinputs(int input)
{
   ndevices = 0;

// Dummy input device.
   device[ndevices].locked = 0;
   device[ndevices].name = "None";
   device[ndevices].getmotion = getnone;
   ndevices++;

   keyboard = joypad = mouse = 0;

// KEYBOARD.
   if (input & R_INPUT_KEYBOARD) {
      initkeyboard();
      if (keyboard) {
         device[ndevices].locked = 0;
         device[ndevices].name = "Keyboard";
         device[ndevices].getmotion = getkeyboard;
         ndevices++;
      }
   }

// JOYPAD.
   if (input & R_INPUT_JOYPAD) {
      initjoypad();
      if (joypad) {
         device[ndevices].locked = 0;
         device[ndevices].name = "Joypad";
         device[ndevices].getmotion = getjoypad;
         ndevices++;
      }
   }

// MOUSE.
   if (input & R_INPUT_MOUSE) {
      initmouse();
      if (mouse) {
         device[ndevices].locked = 0;
         device[ndevices].name = "Mouse";
         device[ndevices].getmotion = getmouse;
         ndevices++;
      }
   }
}
Example #21
0
void main()
{
int gd=DETECT,gm,maxx,maxy,x,y,button,prevx,prevy;

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

printf("Freehand drawing  with the mouse");

maxx=getmaxx();
maxy=getmaxy();
rectangle(0,0,maxx,maxy);
setviewport(1,1,maxx-1,maxy-1,1);

if(initmouse()==0)
	{
	closegraph();
	restorecrtmode();
	printf("Mouse driver not loaded");
	exit(1);
	}

restrictmouseptr(1,1,maxx-1,maxy-1);
showmouseptr();

while(!kbhit())
	{
	getmousepos(&button,&x,&y);
	if((button & 1)==1)
		{
		hidemouseptr();
		prevx=x;
		prevy=y;

		while((button & 1)==1)
			{
			line(prevx,prevy,x,y);
			prevx=x;
			prevy=y;
			getmousepos(&button,&x,&y);
			}

		showmouseptr();
		}
	}
}
Example #22
0
void main()
{
	int gd=DETECT,gm,maxx,maxy,x,y,button;

	initgraph(&gd,&gm,"c:\\tc\\bgi");
	maxx=getmaxx();
	maxy=getmaxy();

	rectangle(0,56,maxx,maxy);
	setviewport(1,57,maxx-1,maxy-1,1);
	gotoxy(26,1);
	printf("Mouse Demonstration Program!");

	if(initmouse()==0)
	{
		closegraph();
		restorecrtmode();
		printf("Mouse driver not loaded");
		exit(1);
	}
	restrictmouseptr(1,57,maxx-1,maxy-1);
	showmouseptr();
	gotoxy(1,2);
	printf("Left Button");
	gotoxy(15,2);
	printf("Right Button");
	gotoxy(55,3);
	printf("Press any key to exit");

	while(!kbhit())
	{
		getmousepos(&button,&x,&y);

		gotoxy(5,3);
		(button&1)==1 ? printf("DOWN"):printf("UP");

		gotoxy(20,3);
		(button&2)==2 ? printf("DOWN"):printf("UP");

		gotoxy(65,2);
		 printf("X=%03d y=%03d",x,y);

	}
}
Example #23
0
int main()
{    	int xi,yi;
	int gdriver=DETECT,gmode;
	initgraph(&gdriver,&gmode,"d:\\borlandc\\BGI");
      //	int xmax=getmaxx();
      //	int ymax=getmaxy();
	int rx , ry ;
	printf("Enter value or rx :") ;
	scanf("%d",&rx);
	printf("\nEnter value or ry :") ;
	scanf("%d",&ry);
	initmouse();
	showmouse();
	getmouse(&xi,&yi);
	putpixel(xi,yi,11);
	ellipse(xi,yi,rx,ry);
	getch();
	return 0;
}
Example #24
0
void top_message(char *message)
{
	top_panel_default();
	restrictmouseptr(0,0,xmax,20);
	hidemouseptr();
	setcolor(BLACK);
	outtextxy(10,3,message);
	showmouseptr();
	for(;;)
	{	
		getmousepos(&button,&mousex,&mousey);
		if(mousex>619&&button==1)      
		{
			hidemouseptr();
			button_hover((xmax-13),4,(xmax-4),11);
			initmouse();
			showmouseptr();
			return;
		}
	}
}
Example #25
0
void
init(void)
{
	mailfs = nsmount("mail", nil);
	if(mailfs == nil)
		sysfatal("mount mail: %r");
	mousectl = initmouse(nil, screen);
	if(mousectl == nil)
		sysfatal("initmouse: %r");
	initplumb();

	/* make background color */
	bgrnd = allocimage(display, Rect(0,0,1,1), screen->chan, 1, DWhite);
	blue = allocimage(display, Rect(0,0,1,1), screen->chan, 1, 0x008888FF);	/* blue-green */
	left = allocimage(display, leftright, GREY1, 0, DWhite);
	right = allocimage(display, leftright, GREY1, 0, DWhite);
	if(bgrnd==nil || blue==nil || left==nil || right==nil){
		fprint(2, "faces: can't create images: %r\n");
		threadexitsall("image");
	}

	loadimage(left, leftright, leftdata, sizeof leftdata);
	loadimage(right, leftright, rightdata, sizeof rightdata);

	/* initialize little fonts */
	tinyfont = openfont(display, "/lib/font/bit/misc/ascii.5x7.font");
	if(tinyfont == nil)
		tinyfont = font;
	mediumfont = openfont(display, "/lib/font/bit/pelm/latin1.8.font");
	if(mediumfont == nil)
		mediumfont = font;
	datefont = font;

	facep.y += datefont->height;
	if(datefont->height & 1)	/* stipple parity */
		facep.y++;
	faces = nil;
}
Example #26
0
void main()
{

// VARIABLE DECLARATIONS

int i=0,j=0,a,front=-1,rear=-1;
char ch,ch1;
int item;

// FUNCTION PROTOTYPE DECLARATIONS

void show();
void slidebar(int *rear,int *front);
void showqueuesize();
void slidebar();
void cpoiters();
void drawq();
void moveptrs(int *rear,int *front);
void insertq(int *rear,char c);
void deleteq(int *front);
void qdelete(int q[],int rear,int front);
void hidequeueinfo();
void shownumbers(int x1,int y1,int x2,int y2);
int initmouse();
void getmousepos(int *button,int *x,int *y);
void showmouseptr();
void restrictmouseptr(int a,int b,int c,int d);
void exitbutton(int x1,int y1,int x2,int y2,int e_x,int e_y,int xit_x,int xit_y);
void zoomin();

// CHECKING THE GRAPHICS DRIVER

int gd=DETECT,gm,maxx,maxy,x,y,button;
initgraph(&gd,&gm,"c:\\TC");

// GET THE MAXIMUM X AND Y CO ORDINATES

	maxx=getmaxx();
	maxy=getmaxy();

// DRAW THE BORDER FOR THE WINDOW

	rectangle(0,0,maxx,maxy);

// SET THE AREA WITHIN THE SCREEN WHERE GRAPHICAL O/P DISPLAYED

	setviewport(1,1,maxx-1,maxy-1,1);

// WRITE THE HEADDING

	gotoxy(150,1);
	settextstyle(TRIPLEX_FONT,HORIZ_DIR,3);
	setcolor(WHITE);
	setbkcolor(216);
	settextjustify(0,2);
	outtextxy(220,2," LINEAR QUEUE ");
	setcolor(RED);
	settextstyle(8,HORIZ_DIR,3);
	outtextxy(40,35,"DEVELOPED IN 'C'  : IT'S A KVSM PRODUCT");
	settextstyle(0,HORIZ_DIR,0);

// INITIALIZE MOUSE,IF IT DOESN'T GET INITIALIZED CLOSE GRAPHICS MODE

	if (initmouse()==0)
	{
		closegraph();
		restorecrtmode();
		printf("\nMouse Driver not installed");
		exit(1);
	}

// IF MOUSE DRIVER INITIALISED THEN
// RESTRICT THE MOUSE POINTER WITHIN THE COORDINATES GIVEN GIVEN BELOW

	restrictmouseptr(1,57,maxx-1,maxy-1);

// SHOW THE MOUSE POINTER

	showmouseptr();

// SET THE TEXT COLOR TO WHITE

	setcolor(WHITE);
	line(0,70,getmaxx(),70);
	line(0,400,getmaxx(),400);

	setcolor(14);
	outtextxy(65,115,"QUEUE OPERATIONS                      QUEUE STATUS");
	outtextxy(140,440,"Press the Key that is Highlighted or use Mouse.");
	setcolor(CYAN);
	line(65,125,190,125);
	line(368,125,464,125);

// CALL THE SHOW FUNCTION TO DRAW THE VARIOUS BUTTONS

	show();

// DRAW THE QUEUE

	drawq();

// DRAW THE POINTERS THAT IS FRONT AND REAR

	moveptrs(&rear,&front);

// SET THE LABEL M THAT WILL BE USED LATER FOR UNCONDITIONAL JUMP

	m:

// GO ON CHECKING WHETHER A KEY IS PRESSED OR NOT

	while (i==0)
	       {
	       if (kbhit())
	       {
	       ch=getche();

	       // CHECK IF THE KEY PRESSED IS E OR e
	       switch(ch)
	       {
	       case 'e':
	       case 'E':

	       {
	       // CALL THE FUNCTION THAT WILL BE FOR EXIT
	       zoomin();
	       }
	       reset:
	       case 'R':
	       case 'r':
	       {
	       // CALL THE RESET QUEUE FUNCTION
	       hidequeueinfo();
	       // CALL THE PROGRESSBAR
	       slidebar(&rear,&front);
	       // AGAIN DRAW THE QUEUE
	       drawq();
	       restrictmouseptr(1,57,maxx-1,maxy-1);
	       goto m;
	       }
	       queueinfo:
	       case 'A' :
	       case 'a':
	       {
	       // CALL THE FUNCTION TO GIVE INFORMATION ABOUT QUEUE
	       hidequeueinfo();
	       showqueuesize();
	       goto m;
	       }
	       delet:
	       case 'D':
	       case 'd':
	       {
	       //  CALL THE DELETE QUEUE OPERATIONS
	       hidequeueinfo();
	       deleteq(&front);
	       // CHECK IF QUEUE IS EMPTY, IF SO PRINT THE MESSAGE
		       if(rear==-1 || front==5 ||rear<front)
			{
			// CLEAR THE INFO, THERE IN INFORMATION PART
			hidequeueinfo();
			// DISPLAY THE TEXT IN THE INFORMATION PART
			outtextxy(200,430,"Queue is empty, you can't delete");
			}
			else
			{
			front=front+1;
			moveptrs(&rear,&front);
			}
		goto m;
	       }
	       ins:
	       case 'I':
	       case 'i':
	       {
	       // HERE IS THE OPERATIONS FOR INSERTING AN ELEMENT
	       hidequeueinfo();
	       if(rear==4)
			{
			hidequeueinfo();
			outtextxy(200,430,"Queue is full, you can't insert");
			goto m;
			}

	       // SHOWS THE NUMBERS AND CANCEL BUTTON
	       shownumbers(20,430,60,470);
	       // CHECK FOR WHAT KEY PRESSED

	       n:

	       while(j==0)
	       {
		 if (kbhit())
		  {
		   ch1=getche();

			       if(front==-1)
			       {
			       front=front+1;
			       }
		   switch(ch1)
		   {
		   cancel:
		   case 'C':
		   case 'c':
		       {
		       hidequeueinfo();
		       restrictmouseptr(1,57,maxx-1,maxy-1);
		       goto m;
		       }
		   zero:
		   case '0':
		       {
			       insertq(&rear,'0');
			       rear=rear+1;
			       moveptrs(&rear,&front);
			       hidequeueinfo();
			       restrictmouseptr(1,57,maxx-1,maxy-1);
			       goto m;
		       }
		   one:
		   case '1':
		       {
			       insertq(&rear,'1');
			       rear=rear+1;
			       moveptrs(&rear,&front);
			       hidequeueinfo();
			       restrictmouseptr(1,57,maxx-1,maxy-1);
			       goto m;
		       }
		   two:
		   case '2':
		       {
			       insertq(&rear,'2');
			       rear=rear+1;
			       moveptrs(&rear,&front);
			       hidequeueinfo();
			       restrictmouseptr(1,57,maxx-1,maxy-1);
			       goto m;
		       }
		   three:
		  case '3':
		       {
			       insertq(&rear,'3');
			       rear=rear+1;
			       moveptrs(&rear,&front);
			       hidequeueinfo();
			       restrictmouseptr(1,57,maxx-1,maxy-1);
			       goto m;
		       }
		  four:
		   case '4':
		       {
			       insertq(&rear,'4');
			       rear=rear+1;
			       moveptrs(&rear,&front);
			       hidequeueinfo();
			       restrictmouseptr(1,57,maxx-1,maxy-1);
			       goto m;
		       }
		   five:
		   case '5':
		       {
			       insertq(&rear,'5');
			       rear=rear+1;
			       moveptrs(&rear,&front);
			       hidequeueinfo();
			       restrictmouseptr(1,57,maxx-1,maxy-1);
			       goto m;
		       }
		   six:
		   case '6':
		       {
			       insertq(&rear,'6');
			       rear=rear+1;
			       moveptrs(&rear,&front);
			       hidequeueinfo();
			       restrictmouseptr(1,57,maxx-1,maxy-1);
			       goto m;
		       }
		   seven:
		   case '7':
		       {
			       insertq(&rear,'7');
			       rear=rear+1;
			       moveptrs(&rear,&front);
			       hidequeueinfo();
			       restrictmouseptr(1,57,maxx-1,maxy-1);
			       goto m;
		       }
		  eight:
		   case '8':
		       {
			       insertq(&rear,'8');
			       rear=rear+1;
			       moveptrs(&rear,&front);
			       hidequeueinfo();
			       restrictmouseptr(1,57,maxx-1,maxy-1);
			       goto m;
		       }
		   nine:
		   case '9':
		       {
			       insertq(&rear,'9');
			       rear=rear+1;
			       moveptrs(&rear,&front);
			       hidequeueinfo();
			       restrictmouseptr(1,57,maxx-1,maxy-1);
			       goto m;
		       }
		   default :
				hidequeueinfo();
				outtextxy(200,430,"Invalid Key Pressed ! Press a valid key");
				delay(550);
				hidequeueinfo();
				shownumbers(20,430,60,470);
				goto n;
		   }
		}
		else
		{
		//write code here to press the 0-----9 and cancel
		       getmousepos(&button,&x,&y);
		       if((button & 1)==1)
		       {
			       if(front==-1)
			       {
			       front=front+1;
			       }
		       }
		       if( (x>500 && x<getmaxx()-10 && y>445 && y<470) && (button & 1)==1)
			{
			goto cancel;
			}
		       if( (x>20 && x<60 && y>430 && y<470) && (button & 1)==1)
			{
			goto zero;
			}
		       if( (x>60 && x<100 && y>430 && y<470) && (button & 1)==1)
			{
			goto one;
			}
		       if( (x>100 && x<140 && y>430 && y<470) && (button & 1)==1)
			{
			goto two;
			}
		       if( (x>140 && x<180 && y>430 && y<470) && (button & 1)==1)
			{
			goto three;
			}
		       if( (x>180 && x<220 && y>430 && y<470) && (button & 1)==1)
			{
			goto four;
			}
		       if( (x>220 && x<260 && y>430 && y<470) && (button & 1)==1)
			{
			goto five;
			}
		       if( (x>260 && x<300 && y>430 && y<470) && (button & 1)==1)
			{
			goto six;
			}
		       if( (x>300 && x<340 && y>430 && y<470) && (button & 1)==1)
			{
			goto seven;
			}
		       if( (x>340 && x<380 && y>430 && y<470) && (button & 1)==1)
			{
			goto eight;
			}
		       if( (x>380 && x<420 && y>430 && y<470) && (button & 1)==1)
			{
			goto nine;
			}
		}
	}
	}
	 default :
			hidequeueinfo();
			outtextxy(220,420,"Please Press a Valid Key");
			goto m;
	 }
	 }
	 // ELSE CONDITION FOR THE IF AFTER THE FIRST WHILE
	 else
	       {

		  getmousepos(&button,&x,&y);
		  if( (x>50 && x<200 && y<370 && y>350) && (button & 1)==1)
			{
			//exit button click
			zoomin();
			}
		  if( (x>50 && x<200 && y>150 && y<170) && (button & 1)==1)
			{
			//clicked the queueinfo button
			goto queueinfo;
			}
		  if( (x>50 && x<200 && y>200 && y<220) && (button & 1)==1)
			{
			//clicked the insert button
			goto ins;
			}

		  if( (x>50 && x<200 && y>250 && y<270) && (button & 1)==1)
			{
			//clicked the delete button
			delay(500);
			goto delet;
			}
		  if( (x>50 && x<200 && y>300 && y<320) && (button & 1)==1)
			{
			//clicked the reset button
			goto reset;
			}

		}


	}

getche();
}
Example #27
0
void initvmd() {
  // Assume that VMD should not initialize or use MPI
  // It is conceivable we would want to be able to load the VMD
  // Python module into a MPI-based Python run, and enable the 
  // MPI features of VMD, but we'll have to determine the best way
  // to detect this and it will need to be tested since we may have
  // to handle this case differently than the normal MPI case where
  // VMD explicitly does MPI initialization and shutdown itself. 
  int mpienabled = 0;

  // If there's already a VMDapp in get_vmdapp, then we must be running
  // inside a standalone VMD instead of being loaded as a python extension.
  // Don't throw an error - just load the methods for interoperability
  // in case vmd.so is in the PYTHONPATH of the standalone application.
  if (get_vmdapp() != NULL) {
    (void)Py_InitModule((char *)"vmd", VMDAppMethods);
    return;
  }

  int argc=1;
  char *argv[1];
  argv[0] = Py_GetProgramFullPath();
  if (!VMDinitialize(&argc, (char ***) &argv, mpienabled)) {
    return;
  }

  // XXX this is a hack, and it would be better to tie this into 
  //     VMDApp more directly at some later point, but the regular
  //     VMD startup code is similarly lame, so we'll use it for now.
  const char *disp = getenv("VMDDISPLAYDEVICE");
  if (!disp) disp="text";

  int loc[2] = { 50, 50 };
  int size[2] = { 400, 400 };
  VMDgetDisplayFrame(loc, size);

  VMDApp *app = new VMDApp(1, argv, mpienabled);
  app->VMDinit(1, argv, disp, loc, size);

  // read application defaults
  VMDreadInit(app);

  // read user-defined startup files
  VMDreadStartup(app);

  set_vmdapp(app);

  // set my local static
  the_app = app;

  PyObject *vmdmodule = Py_InitModule((char *)"vmd", VMDAppMethods);

  initanimate();
  initatomsel();
  initaxes();
  initcolor();
  initdisplay();
  initgraphics();
  initimd();
  initlabel();
  initmaterial();
  initmolecule();
  initmolrep();
  initmouse();
  initrender();
  inittrans();
  initvmdmenu();

#ifdef VMDNUMPY
  initvmdnumpy();
#endif

  if (PyErr_Occurred()) return;

  static const char *modules[] = {
    "animate", "atomsel", "axes", "color", "display", "graphics",
    "imd", "label", "material", "molecule", "molrep", "mouse", 
    "render", "trans", "vmdmenu", "vmdnumpy"
  };
  for (unsigned i=0; i<sizeof(modules)/sizeof(const char *); i++) {
    const char *m = modules[i];
#if (PY_MAJOR_VERSION == 2) && (PY_MINOR_VERSION < 5)
#define CAST_HACK (char *)
#else 
#define CAST_HACK
#endif
    PyModule_AddObject(vmdmodule, CAST_HACK m, PyImport_ImportModule( CAST_HACK m));
  }
  event_tstate = PyThreadState_Get();
#if defined(VMD_SHARED)
  PyOS_InputHook = vmd_input_hook;
#endif
}
void sscreen( )
    {
       cleardevice( );

       Panel main_bar,Screen,tool;

       main_bar.init(0,0,getmaxx( ),getmaxy( ),IN,THIN);
       main_bar.show();

      char*txt="SUPER MARKET SUPERVISOR..ver-2r";
 {  int x1=0;
    int y1=0;
    int x2=getmaxx( );
    int y2=getmaxy( );
    int x=x1+13;
    int y=y1-1;


     setcolor(8);
	 rectangle(x1+4,y1+4,x2-5,y+41);
	 rectangle(x1+4,y+48,x2-5,y2-5);

       setcolor(15);
	 rectangle(x1+5,y+6,x2-4,y+42);
	 rectangle(x1+5,y+
	 49,x2-4,y2-4);

       setfillstyle(1,9);
	 bar(x1+8,y1+8,x2-8,y+38);
     settextstyle(8,0,4);
	 setcolor(0);
	   outtextxy(x,y,txt);
	   outtextxy(x+1,y,txt);

	 setcolor(14);
	   outtextxy(x+2,y-1,txt);
	   outtextxy(x+3,y-1,txt);
	   outtextxy(x+4,y-1,txt);
}
       tool.init(0,35,getmaxx(),55,IN,THIN);
       tool.show();

       Button Add,Delete,Modify,Search,About,Exit;
       Add.init(6,35,"Add         ",FLAT);
       Add.show( );

       Delete.init(111,35,"Delete      ",FLAT);
       Delete.show( );

       Modify.init(221,35,"Modify      ",FLAT);
       Modify.show( );

       Search.init(331,35,"Search      ",FLAT);
       Search.show( );


       About.init(441,35,"About       ",FLAT,0,0,7,1);
       About.show( );

       Exit.init(551,35,"Exit     ",FLAT);
       Exit.show( );

       Screen.init(5,53,632,467,IN,THICK,0);

       Screen.show( );

       setcolor(8);
	 rectangle(4,53,633,471);

       setcolor(15);
	 rectangle(5,54,634,472);
	 initmouse();

	while(1)
	{
	showmouse();
	 int ch=selc(Add,Delete,Modify,Search,About,Exit,30,32,50,31,48,18);

	 hidemouse();
	 wrkng(ch);

	}
    }
  void ccoc()
  {
     int rn,q;
     fstream f3;
	f3.open("pro//product",ios::app);
	f3.seekg(0);
	if(f3.fail())
	{

	outtextxy(40,40,"This is a deault file");
	}

	 int whcnt=0;
  do
  {

	 pro[whcnt].getdata();
	 rn=pro[whcnt].no();
	 if(rn==0)
	 {
	 goto last;
	 }
	q=chkred(rn);

	 if(q==1)
	 {
	 f3.seekg(ios::end);
	f3.write((char*)&pro[whcnt],sizeof(product));
	}

  Panel Check;

       Check.init(220,120,525,455,OUT,THIN);
       Check.show( );
       Check.shape("Choice Box");




       Button Next;
       Button Cancel;

       Next.init(265,260,"Next ",NORMAL,0,-2);
       Next.show( );

       Cancel.init(385,260,"Halt",NORMAL,0,-2);
       Cancel.show( );
       initmouse();
       showmouse();


     int i= selc(Next,Cancel,49,35);
     if(i!=1)
     { break;
     }

       Check.modify(220,120,525,455,OUT,THIN);
       Check.show();
       Check.shape("Add");
   whcnt++;
  } while(1);
  last:
  f3.close();
  }
Example #30
0
PyMODINIT_FUNC PyInit_mouse(void) { return initmouse(); }