Esempio n. 1
0
int designerinit()
{
 int i,flag = 1,quit = 0,ctr=0;
 sel = 0;
 char ch;
 char help[][50] = {"                                       \0",//0
		    "Click On Buttons to activate event     \0",//1
		    "Select a desired lens                  \0",//2
		    "Enter X coord of optical centre of lens\0",//3
		    "Sorry!!!Enter X coord below 600        \0",//4
		    "Enter Radius of First Interface        \0",//5
		    "Enter Radius of Second Interface       \0",//6
		    "Sorry!!!Enter radius between 60 and 200\0",//7
		    "Enter Radius of curved Interface       \0",//8
		    "Enter Refractive Index of Lens         \0",//9
		    "Sorry!!!Enter RI from 0.5 to 2.0(exc.1)\0",//10
		    "New Lens Inserted                      \0",//11
		    "Sorry!!!Overflow of Lenses(Max : 6)    \0",//12
		    "Enter Lens Number to be Modified       \0",//13
		    "Enter Value(1 to \0"                      ,//14
		    "Sorry!!!Underflow of Lenses            \0",//15
		    "Lens Removed                           \0",//16
		    "Lens Modified                          \0",//17
		    "Sorry!!!Enter X coord above \0"           ,//18
		    "\0",//19
		    "\0",//20
		    "\0",//21
		   };
 loadbitmap(pic);
 lensfinit();
 setcolor(12);
 rectangle(10,10,getmaxx()-10,getmaxy()-10);
 rectangle(15,15,getmaxx()-15,getmaxy()-15);
 setfillstyle(SOLID_FILL,15);floodfill(12,12,12);
 setcolor(10);rectangle(50,55,200,175);rectangle(45,50,205,180);
 setfillstyle(SOLID_FILL,12);floodfill(47,57,10);
 setcolor(12);rectangle(30,220,230,320);
 setcolor(10);line(80,184,80,210);line(60,197,80,184);line(80,210,60,197);
 setfillstyle(SOLID_FILL,1);floodfill(75,197,10);
 line(170,184,170,210);line(190,197,170,184);line(170,210,190,197);floodfill(175,197,10);
 rectangle(95,186,155,212);floodfill(97,188,10);outtextxy(102,195,"SELECT");
 setcolor(11);outtextxy(235,37,"HELP:");
 gotoxy(36,3);cout<<"Click on buttons to activate event";
 outtextxy(233,52,"INPUT:");
 setcolor(12);line(287,65,600,65);
 settextstyle(DEFAULT_FONT,HORIZ_DIR,1);setcolor(11);
 outtextxy(30,37,"LENS:");
 window(80,26,425,440,1,"DONE",0);
 window(80,26,535,440,1,"QUIT",0);
 window(80,26,315,440,1,"BACK",0);
 setfillstyle(SOLID_FILL,1);settextstyle(DEFAULT_FONT,HORIZ_DIR,1);
 rectangle(255,276,575,294);floodfill(257,278,10);outtextxy(375,282,"REMOVE LENS");
 rectangle(255,298,575,316);floodfill(257,300,10);outtextxy(375,303,"MODIFY LENS");
 erase(51,56,199,174);
 gotoxy(10,3);cout<<"                    ";
 gotoxy(10,3);puts(lens[ctr].name);
 drawlens(lens[ctr],1);
 MM.reset();directvideo = 0;MM.show();
 while(quit==0)
 {
  if(MM.leftPressed)
  {
   if((mousechk(60,184,80,210)==1)&&flag==1)
   {
    if(ctr==0)ctr = 5; else --ctr;
    erase(51,56,199,174);
    gotoxy(10,3);cout<<"                    ";
    gotoxy(10,3);puts(lens[ctr].name);
    gotoxy(36,3);puts(help[2]);
    drawlens(lens[ctr],1);
    delay(600);
   }
   if((mousechk(170,184,190,210)==1)&&flag==1)
   {
    if(ctr==5)ctr = 0; else ++ctr;
    erase(51,56,199,174);
    gotoxy(10,3);cout<<"                    ";
    gotoxy(10,3);puts(lens[ctr].name);
    gotoxy(36,3);puts(help[2]);
    drawlens(lens[ctr],1);
    delay(600);
   }
   if((mousechk(95,186,155,212)==1)&&flag==1)
   {
    gotoxy(10,3);cout<<"                    ";
    gotoxy(10,3);puts(lens[ctr].name);
    gotoxy(36,3);puts(help[2]);
    if(sel<6) {flag = 0;selectlens(lens[ctr],flag,help,sel,0);}
    else {gotoxy(36,3);puts(help[12]);}
    delay(600);
   }
   if((mousechk(255,298,575,316)==1)&&flag==1)
   {
    if(sel!=0)
    {
     gotoxy(10,3);cout<<"                    ";
     gotoxy(10,3);puts(lens[ctr].name);
     gotoxy(36,3);puts(help[13]);
     flag = 0;
     do
     {
      gotoxy(37,4);puts(help[0]);
      gotoxy(37,4);cin>>i;
      gotoxy(36,3);puts(help[0]);
      gotoxy(36,3);puts(help[14]);
      gotoxy(54,3);cout<<sel<<")";
     } while(!(i>=1&&i<=sel));
     gotoxy(36,3);puts(help[0]);
     selectlens(lensf[i-1],flag,help,sel,i);
    }
    else
    {
     gotoxy(36,3);puts(help[0]);
     gotoxy(36,3);puts(help[15]);
    }
     delay(600);
   }
   if((mousechk(255,270,575,288)==1)&&flag==1)
   {
    if(sel!=0)
    {
     gotoxy(36,3);puts(help[0]);
     gotoxy(36,3);puts(help[16]);
     for(i=0;i<sel;i++)
     {
      gotoxy(5,i+15);
      cout<<"                       ";
     }
     --sel;
     for(i = 0;i<sel;i++)
     {
      gotoxy(5,i+15);
      cout<<i+1<<" ";
      puts(lensf[i].name);
     }
    }
    else
    {
     gotoxy(36,3);puts(help[0]);
     gotoxy(36,3);puts(help[15]);
    }
    delay(600);
   }
   if((mousechk(495,427,575,453)==1)&&flag==1)
   {
    for(i=0;i<5;i++)
    {
     window(80,26,535,440,4,"QUIT",0);delay(50);
     window(80,26,535,440,14,"QUIT",0);delay(50);
    }
    delay(1000);
    quit = 1; return 6;
   }
   if((mousechk(275,427,355,453)==1)&&flag==1)
   {
    for(i = 0;i<5;i++)
    {
     window(80,26,315,440,4,"BACK",0);delay(50);
     window(80,26,315,440,14,"BACK",0);delay(50);
    }
    delay(1000);
    quit = 1; return 0;
   }
   if((mousechk(385,427,465,453)==1)&&flag==1)
   {
    for(i = 0;i<5;i++)
    {
     window(80,26,425,440,4,"DONE",0);delay(50);
     window(80,26,425,440,14,"DONE",0);delay(50);
    }
    delay(1000);
    quit = 1;return 7;
   }
  }
Esempio n. 2
0
static void
run (const gchar      *name,
     gint              nparams,
     const GimpParam  *param,
     gint             *nreturn_vals,
     GimpParam       **return_vals)
{
  static GimpParam   values[1];
  GimpDrawable      *drawable;
  GimpRunMode        run_mode;
  GimpPDBStatusType  status = GIMP_PDB_SUCCESS;

  INIT_I18N ();

  run_mode = param[0].data.d_int32;

  values[0].type          = GIMP_PDB_STATUS;
  values[0].data.d_status = status;

  *nreturn_vals = 1;
  *return_vals  = values;

  drawable = gimp_drawable_get (param[2].data.d_drawable);

  switch(run_mode)
    {
    case GIMP_RUN_INTERACTIVE:
      gimp_get_data (PLUG_IN_PROC, &lvals);
      if (!lens_dialog (drawable))
        return;
      break;

    case GIMP_RUN_NONINTERACTIVE:
      if (nparams != 7)
        status = GIMP_PDB_CALLING_ERROR;

      if (status == GIMP_PDB_SUCCESS)
        {
          lvals.refraction      = param[3].data.d_float;
          lvals.keep_surr       = param[4].data.d_int32;
          lvals.use_bkgr        = param[5].data.d_int32;
          lvals.set_transparent = param[6].data.d_int32;
        }

      if (status == GIMP_PDB_SUCCESS && (lvals.refraction < 1.0))
        status = GIMP_PDB_CALLING_ERROR;
      break;

    case GIMP_RUN_WITH_LAST_VALS:
      gimp_get_data (PLUG_IN_PROC, &lvals);
      break;

    default:
      break;
    }

  gimp_tile_cache_ntiles (2 * (drawable->width / gimp_tile_width () + 1));
  gimp_progress_init (_("Applying lens"));
  drawlens (drawable, NULL);

  if (run_mode != GIMP_RUN_NONINTERACTIVE)
    gimp_displays_flush ();
  if (run_mode == GIMP_RUN_INTERACTIVE)
    gimp_set_data (PLUG_IN_PROC, &lvals, sizeof (LensValues));

  values[0].data.d_status = status;

  gimp_drawable_detach (drawable);
}