00001
00002
00003
00004
00005
00006
00007
00008
00009
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
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
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
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
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
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
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))
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 }