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

group.c

Go to the documentation of this file.
00001 /*************************************************************************
00002  *
00003  *  AUTHOR: Wilson T
00004  *
00005  *  TITLE:  group.c
00006  *
00007  *  DATE: April 28, 1993
00008  *
00009  *  PURPOSE:  Definition of groups of checkboxes.
00010  *
00011  *************************************************************************/
00012 
00013 #include "group.h"
00014 
00015 Group::~Group()
00016 {
00017   for(int count=0; count<CurrentObj; count++)
00018     delete Boxes[count];
00019 
00020   free (Boxes);
00021 }
00022 
00023 void Group::Add(CheckBox *newbox, int x, int y)
00024 {
00025   if(CurrentObj!=NumObj) {
00026     Boxes[CurrentObj] = newbox;
00027     newbox->Init(Disp, x, y);
00028 
00029     CurrentObj++;
00030   }
00031 }
00032 
00033 Message Group::Dispatch(Message &msg)
00034 {
00035   int count=0;
00036   Message msg2;
00037 
00038   do{
00039     if((msg.origin==GodMsg)&&(msg.code==Disable)&&(msg.d1==IdNum))
00040       disable_proc();
00041     if((msg.origin==GodMsg)&&(msg.code==Enable)&&(msg.d1==IdNum))
00042       enable_proc();
00043 
00044     msg2=Boxes[count]->Dispatch(msg);
00045     if (msg2.code==Status) {
00046       switch(msg2.d2) {
00047         case On:
00048           off_last();
00049           break;
00050         case Off:
00051           if (CurrentId==count)
00052             Boxes[CurrentId]->ChangeStatus(On);
00053           break;
00054       }
00055       CurrentId=count;
00056     }
00057     count++;
00058   }while((count<CurrentObj)&&(msg2!=Acknowledged)&&(msg2.code!=Status));
00059 
00060   return msg2;
00061 }
00062 
00063 void Group::Draw()
00064 {
00065   Disp->FastDraw();
00066   for (int count=0; count<CurrentObj; count++)
00067     Boxes[count]->Draw();
00068 
00069   // Set Default button On...
00070   Boxes[Default]->ChangeStatus(On);
00071   Disp->Done();
00072 }
00073 
00074 void Group::Erase()
00075 {
00076   Disp->FastDraw();
00077   for (int count=0; count<CurrentObj; count++)
00078     Boxes[count]->Erase();
00079   Disp->Done();
00080 }
00081 
00082 void Group::DisableBox(int idnum)
00083 {
00084   int iteration;
00085   iteration=id_to_int(idnum);
00086 
00087   Boxes[iteration]->Dispatch (Message (GodMsg, Disable, idnum));
00088 
00089   if(Default==CurrentObj)
00090     Default=-1;
00091 
00092   if(Default==iteration) {
00093     Default=iteration+1;
00094     CurrentId=iteration+1;
00095     Boxes[iteration]->ChangeStatus(Off);
00096     Boxes[iteration]->Dispatch (Message (GodMsg, Disable, idnum));
00097     Boxes[Default]->ChangeStatus(On);
00098   }
00099 }
00100 
00101 void Group::EnableBox(int idnum)
00102 {
00103   int iteration;
00104   iteration=id_to_int(idnum);
00105 
00106   Boxes[iteration]->Dispatch (Message (GodMsg, Enable, idnum));
00107 
00108   if(iteration==0) {
00109     Default=0;
00110     CurrentId=0;
00111   }
00112 }
00113 
00114 int Group::id_to_int(int idnum)
00115 {
00116   int count=0;
00117 
00118   while (Boxes[count]->BoxId()!=idnum)
00119     count++;
00120 
00121   return count;
00122 }
00123 
00124 void Group::disable_proc()
00125 {
00126   int idnum;
00127 
00128   Disp->FastDraw();
00129   for(int count=0; count<CurrentObj; count++) {
00130     idnum=Boxes[count]->BoxId();
00131     Boxes[count]->Dispatch (Message (GodMsg, Disable, idnum));
00132   }
00133 
00134   Disp->Done();
00135 }
00136 
00137 void Group::enable_proc()
00138 {
00139   int idnum;
00140 
00141   Disp->FastDraw();
00142   for(int count=0; count<CurrentObj; count++) {
00143     idnum=Boxes[count]->BoxId();
00144     Boxes[count]->Dispatch (Message (GodMsg, Enable, idnum));
00145   }
00146 
00147   // Set Default button On...
00148   Boxes[Default]->ChangeStatus(On);
00149 
00150   Disp->Done();
00151 }

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