Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

transpop.c

Go to the documentation of this file.
00001 /*************************************************************************
00002  *
00003  *  AUTHOR: Wilson T
00004  *
00005  *  TITLE:  trans.h
00006  *
00007  *  DATE: May 1, 1993
00008  *
00009  *  PURPOSE:  Declaration of group class for checkboxes.
00010  *
00011  *************************************************************************/
00012 
00013 #include <assert.h>
00014 #include "ui.h"
00015 #include "checkbox.h"
00016 #include "group.h"
00017 #include "typedefs.h"
00018 #include "button.h"
00019 #include "popupwin.h"
00020 
00021 const int TWinXDim = 200;
00022 const int TWinYDim = 150;
00023 
00024 int UserInterface::TransPop(byte bv, int color)
00025 {
00026   int Mode=0, i=0;
00027 
00028   // CREATE WINDOW
00029   PopUpWin *w = new PopUpWin(TWinXDim, TWinYDim, RED, WHITE,
00030     "Mode of Transportation", WHITE);
00031   assert(w !=NULL);
00032   w->Init(&theDisplay, 640/2-TWinXDim/2, 480/2-TWinYDim/2);
00033 
00034   // CREATE CHECKBOXES
00035   CheckBox *ch[3];
00036   ch[0] = new CheckBox("Taxi", BLACK, color, 1000, Square);
00037   ch[1] = new CheckBox("Bus", BLACK, color, 1001, Square);
00038   ch[2] = new CheckBox("Subway", BLACK, color, 1002, Square);
00039   for(i=0; i<3; i++)
00040     assert(ch[i] !=NULL);
00041 
00042   // CREATE PUSHBUTTONS
00043   PushButton *pb[2];
00044   pb[1] = new PushButton ("Cancel", BLUE, 901);
00045   pb[0] = new PushButton ("Done", BLUE, 900, pb[1]->GetXDim(), pb[1]->GetYDim());
00046   for(i=0; i<2; i++)
00047     assert(pb[i] !=NULL);
00048 
00049   //CREATE GROUP AND ADD CHECKBOXES
00050   Group *modes = new Group(3, 1000);
00051     assert(modes !=NULL);
00052   w->Client().Add(modes, 0, 0);
00053   for(i=0; i<3; i++)
00054     modes->Add(ch[i], 20, 20+(i*20));
00055 
00056   //ADD PUSHBUTTONS AND GROUP TO POP-UP WINDOW
00057   w->Client().Add(pb[0], w->Client().GetMaxX()/2-65, w->Client().GetMaxY()-pb[0]->GetYDim()-5);
00058   w->Client().Add(pb[1], w->Client().GetMaxX()/2+5, w->Client().GetMaxY()-pb[1]->GetYDim()-5);
00059 
00060   //DRAW POP-UP WINDOW
00061   w->Draw();
00062 
00063   int def = 0;
00064   if(!(bv & TaxiMask))
00065     modes->DisableBox(1000);
00066   else
00067     def = 1000;
00068   if(!(bv & BusMask))
00069     modes->DisableBox(1001);
00070   else if (!def) def = 1001;
00071   if(!(bv & SubwayMask))
00072     modes->DisableBox(1002);
00073   else if (!def) def = 1002;
00074 
00075   Mode=def-1000;
00076   Message DoneMsg(ButtonMsg, ButtonPress, 900), m;
00077   Message CancelMsg(ButtonMsg, ButtonPress, 901);
00078   do {
00079     m=w->Dispatch(Mouse.Event());
00080     if((m.origin==ButtonMsg)&&(m.code==Status)&&(m.d2)) //Checkbox on
00081       Mode=m.d1-1000;
00082   } while((m != DoneMsg) && (m != CancelMsg));
00083 
00084   delete w;
00085 
00086   if(m==CancelMsg)
00087     return (-1);
00088   else
00089     return Mode;
00090 }

Generated on Sun Jul 6 23:07:16 2003 for Scotland Yard by doxygen1.2.15