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

CheckBox Class Reference

#include <checkbox.h>

Inheritance diagram for CheckBox:

ScrnObj Nodes List of all members.

Public Methods

 CheckBox (char *, int, int, int, int)
 CheckBox (char *, int, int, int, int, int, int)
 CheckBox (char *, int, int, int)
 CheckBox (char *, int, int, int, int, int)
void Init (Display *, int, int)
 ~CheckBox ()
void Draw ()
void Erase ()
BOOLEAN ButtonBounds (int, int)
Message Dispatch (Message &)
int GetXDim ()
int GetYDim ()
void ChangeStatus (BOOLEAN)
int BoxId ()
int CenterPtX ()
int CenterPtY ()
void SetPseudo (BOOLEAN)
void DisableBox ()
void EnableBox ()

Protected Methods

 CheckBox (void)
void animate_box ()
void animate_frame ()
Message mouse_msg (Message &)
Message key_msg (Message &)
Message command_msg (Message &)
BOOLEAN status ()
void disable_box ()
void enable_box ()

Protected Attributes

int X2
int Y2
int xdim
int ydim
int Color
int BkColor
int IdNum
BOOLEAN Activated
BOOLEAN BStatus
BOOLEAN Able

Private Methods

void set_constants (char *, int, int, int, int)
void image_size ()
void image_size (int, int)
void prep_screen (int)
void name_button (int)
void fill_box ()
void empty_box (int)
void draw_check ()

Private Attributes

int string_height
int string_width
int COLORFILL
int Type
char string [80]

Constructor & Destructor Documentation

CheckBox::CheckBox void    [inline, protected]
 

Definition at line 52 of file checkbox.h.

00052 { }

CheckBox::CheckBox char *   ,
int   ,
int   ,
int   ,
int   
[inline]
 

Definition at line 96 of file checkbox.h.

References image_size(), set_constants(), ScrnObj::X, X2, xdim, ScrnObj::Y, Y2, and ydim.

00097   {set_constants(name, color, fcolor, Id, type); image_size();
00098   xdim=X2-X; ydim=Y2-Y;}

CheckBox::CheckBox char *   ,
int   ,
int   ,
int   ,
int   ,
int   ,
int   
[inline]
 

Definition at line 100 of file checkbox.h.

References image_size(), set_constants(), ScrnObj::X, X2, xdim, ScrnObj::Y, Y2, and ydim.

00101   {set_constants(name, color, fcolor, Id, type); image_size(x2, y2);
00102   xdim=X2-X; ydim=Y2-Y;}

CheckBox::CheckBox char *   ,
int   ,
int   ,
int   
[inline]
 

Definition at line 104 of file checkbox.h.

References image_size(), set_constants(), ScrnObj::X, X2, xdim, ScrnObj::Y, Y2, and ydim.

00105   {set_constants(name, color, BLUE, Id, type); image_size();
00106   xdim=X2-X; ydim=Y2-Y;}

CheckBox::CheckBox char *   ,
int   ,
int   ,
int   ,
int   ,
int   
[inline]
 

Definition at line 108 of file checkbox.h.

References image_size(), set_constants(), ScrnObj::X, X2, xdim, ScrnObj::Y, Y2, and ydim.

00109   {set_constants(name, color, BLUE, Id, type); image_size(x2, y2);
00110   xdim=X2-X; ydim=Y2-Y;}

CheckBox::~CheckBox   [inline]
 

Definition at line 61 of file checkbox.h.

References Erase().

00062     {if (Drawn) Erase();}


Member Function Documentation

void CheckBox::animate_box   [inline, protected]
 

Reimplemented in Nodes.

Definition at line 143 of file checkbox.h.

References BOXCOLOR, empty_box(), and fill_box().

Referenced by ChangeStatus(), command_msg(), and mouse_msg().

00144   {if (BStatus) fill_box(); else empty_box(BOXCOLOR);}

void CheckBox::animate_frame   [protected]
 

Reimplemented in Nodes.

Definition at line 162 of file checkbox.c.

References BkColor, BOXSIZE, CBORDERX, CFRAME, Viewport::Circle(), Circle, ScrnObj::Disp, Viewport::Done(), Viewport::FastDraw(), Viewport::Rectangle(), Viewport::SetColor(), Viewport::SetLineStyle(), Square, string_height, ScrnObj::X, and ScrnObj::Y.

Referenced by mouse_msg().

00163 {
00164   int x=X+CBORDERX;
00165   int y=(int)Y+((string_height-BOXSIZE)/2);
00166   int radius;
00167 
00168   Disp->FastDraw();
00169 
00170   if (Activated)
00171     Disp->SetColor(BLACK);
00172   else
00173     Disp->SetColor(BkColor);
00174 
00175   Disp->SetLineStyle(SOLID_LINE, 0, CFRAME);
00176   switch(Type) {
00177     case Square:
00178       Disp->Rectangle(x-CFRAME+1, y-CFRAME+1, x+BOXSIZE+CFRAME-1, y+BOXSIZE+CFRAME-1);
00179       break;
00180     case Circle:
00181       radius = (int)(BOXSIZE/2);
00182       Disp->Circle(x+radius, y+radius, radius+CFRAME-1);
00183       break;
00184   }
00185 
00186   Disp->Done();
00187 }

int CheckBox::BoxId   [inline]
 

Definition at line 115 of file checkbox.h.

References IdNum.

Referenced by Group::disable_proc(), Group::enable_proc(), and Group::id_to_int().

00116   {return IdNum;}

BOOLEAN CheckBox::ButtonBounds int   ,
int   
 

Definition at line 189 of file checkbox.c.

References False, True, ScrnObj::X, and ScrnObj::Y.

Referenced by Nodes::mouse_msg(), and mouse_msg().

00190 {
00191   // Mouse will call and supply the coordinates of its position
00192   //  It's up to the button itself to determine it's bounds.
00193 
00194   if ((Mx<=X2) && (Mx>=X) && (My<=Y2) && (My>=Y))
00195     return True;
00196   else
00197     return False;
00198 }

int CheckBox::CenterPtX   [inline]
 

Definition at line 118 of file checkbox.h.

References BOXSIZE, and ScrnObj::X.

00119   {return X+BOXSIZE/2;}

int CheckBox::CenterPtY   [inline]
 

Definition at line 121 of file checkbox.h.

References BOXSIZE, and ScrnObj::Y.

00122   {return Y+BOXSIZE/2;}

void CheckBox::ChangeStatus BOOLEAN    [inline]
 

Reimplemented in Nodes.

Definition at line 112 of file checkbox.h.

References animate_box(), BOOLEAN, and BStatus.

Referenced by Group::DisableBox().

00113   {BStatus=bswitch; animate_box();}

Message CheckBox::command_msg Message   [protected]
 

Reimplemented in Nodes.

Definition at line 269 of file checkbox.c.

References animate_box(), BStatus, ButtonMsg, Message::code, Message::d1, Disable, disable_box(), Enable, enable_box(), IdNum, Off, RequestStatus, status(), and Status.

Referenced by Dispatch().

00270 {
00271   if(msg.d1 != IdNum)
00272     return NullMsg;
00273 
00274   switch (msg.code) {
00275     case Disable:
00276       BStatus=Off;
00277       animate_box();
00278       disable_box();
00279       return Acknowledged;
00280     case Enable:
00281       enable_box();
00282       return Acknowledged;
00283     case RequestStatus:
00284       return Message(ButtonMsg, Status, IdNum, (int)status());
00285   }
00286   return NullMsg;
00287 }

void CheckBox::disable_box   [inline, protected]
 

Reimplemented in Nodes.

Definition at line 152 of file checkbox.h.

References Able, empty_box(), name_button(), No, and OFFCOLOR.

Referenced by command_msg(), and DisableBox().

void CheckBox::DisableBox   [inline]
 

Definition at line 127 of file checkbox.h.

References disable_box().

00128   {disable_box();}

Message CheckBox::Dispatch Message   [virtual]
 

Reimplemented from ScrnObj.

Reimplemented in Nodes.

Definition at line 216 of file checkbox.c.

References command_msg(), GodMsg, key_msg(), KeyMsg, mouse_msg(), MouseMsg, and Message::origin.

Referenced by Group::disable_proc(), Group::DisableBox(), Group::Dispatch(), Group::enable_proc(), and Group::EnableBox().

00217 {
00218   switch(msg.origin) {
00219     case MouseMsg:
00220       return mouse_msg(msg);
00221     case KeyMsg:
00222       return key_msg(msg);
00223     case GodMsg:
00224       return command_msg(msg);
00225   }
00226   return msg;
00227 }

void CheckBox::Draw   [virtual]
 

Implements ScrnObj.

Reimplemented in Nodes.

Definition at line 63 of file checkbox.c.

References Viewport::Bar(), BOXCOLOR, BOXSIZE, CBORDERX, Circle, Color, ScrnObj::Disp, Viewport::Done(), ScrnObj::Drawn, Viewport::FastDraw(), Viewport::FillEllipse(), name_button(), Viewport::Rectangle(), Viewport::SetColor(), Viewport::SetFillStyle(), Square, string_height, ScrnObj::X, ScrnObj::Y, and Yes.

Referenced by Group::Draw().

00064 {
00065   int x=X+CBORDERX;
00066   int y=(int)Y+abs((string_height-BOXSIZE)/2);
00067 
00068   Disp->FastDraw();
00069   Disp->SetFillStyle(SOLID_FILL, BOXCOLOR);
00070   Disp->SetColor(BLACK);
00071 
00072   switch(Type) {
00073     case Square:
00074       Disp->Bar(x, y, x+BOXSIZE, y+BOXSIZE);
00075       Disp->Rectangle(x, y, x+BOXSIZE, y+BOXSIZE);
00076       break;
00077     case Circle:
00078       int radius = (int)(BOXSIZE/2);
00079       Disp->FillEllipse(x+radius, y+radius, radius, radius);
00080       break;
00081   }
00082 
00083   name_button(Color);
00084   Disp->Done();
00085   Drawn=Yes;
00086 }

void CheckBox::draw_check   [private]
 

Definition at line 144 of file checkbox.c.

References BOXSIZE, CBORDERX, ScrnObj::Disp, FILLSIZE, Viewport::Line(), Viewport::SetLineStyle(), string_height, ScrnObj::X, and ScrnObj::Y.

Referenced by fill_box().

00145 {
00146   int thickness=3;
00147 
00148   int x=X+CBORDERX+FILLSIZE, x2=X+CBORDERX+BOXSIZE-FILLSIZE;
00149   int y=(int)Y+abs((string_height-BOXSIZE)/2)+FILLSIZE;
00150   int y2=(int)Y+abs((string_height-BOXSIZE)/2)+BOXSIZE-FILLSIZE;
00151 
00152   int midx=x+(int)(.3333*(x2-x));
00153   int midy=y+(int)(.6666*(y2-y));
00154 
00155   Disp->SetLineStyle(SOLID_LINE, 0, 1);
00156   for(int count=0; count<thickness; count++) {
00157     Disp->Line(x, midy, midx, y2-thickness+count);
00158     Disp->Line(midx, y2-thickness+count, x2, y);
00159   }
00160 }

void CheckBox::empty_box int    [private]
 

Reimplemented in Nodes.

Definition at line 100 of file checkbox.c.

References Viewport::Bar(), BOXSIZE, BStatus, CBORDERX, Circle, ScrnObj::Disp, Viewport::Done(), Viewport::FastDraw(), Viewport::FillEllipse(), Off, Viewport::SetColor(), Viewport::SetFillStyle(), Square, string_height, ScrnObj::X, and ScrnObj::Y.

Referenced by animate_box(), disable_box(), and enable_box().

00101 {
00102   Disp->FastDraw();
00103   int x=X+CBORDERX;
00104   int y=(int)Y+abs((string_height-BOXSIZE)/2);
00105 
00106   Disp->SetFillStyle(SOLID_FILL, color);
00107   switch(Type) {
00108     case Square:
00109       Disp->Bar(x+1, y+1, x+BOXSIZE-1, y+BOXSIZE-1);
00110       break;
00111     case Circle:
00112       int radius = (int)(BOXSIZE/2);
00113       Disp->SetColor(BLACK);
00114       Disp->FillEllipse(x+radius, y+radius, radius, radius);
00115       break;
00116   }
00117   Disp->Done();
00118 
00119   BStatus = Off;
00120 }

void CheckBox::enable_box   [inline, protected]
 

Reimplemented in Nodes.

Definition at line 155 of file checkbox.h.

References Able, BOXCOLOR, Color, empty_box(), name_button(), and Yes.

Referenced by command_msg(), and EnableBox().

void CheckBox::EnableBox   [inline]
 

Definition at line 130 of file checkbox.h.

References enable_box().

00131   {enable_box();}

void CheckBox::Erase   [virtual]
 

Reimplemented from ScrnObj.

Definition at line 88 of file checkbox.c.

References Viewport::Bar(), ScrnObj::Disp, Viewport::Done(), ScrnObj::Drawn, Viewport::FastDraw(), Viewport::GetBkColor(), No, Viewport::SetFillStyle(), ScrnObj::X, X2, ScrnObj::Y, Y2, and Yes.

Referenced by Group::Erase(), ~CheckBox(), and Nodes::~Nodes().

00089 {
00090   Disp->FastDraw();
00091 
00092   if(Drawn == Yes) {
00093     Drawn = No;
00094     Disp->SetFillStyle(SOLID_FILL, Disp->GetBkColor());
00095     Disp->Bar(X, Y, X2, Y2);
00096   }
00097   Disp->Done();
00098 }

void CheckBox::fill_box   [private]
 

Reimplemented in Nodes.

Definition at line 122 of file checkbox.c.

References BOXSIZE, BStatus, CBORDERX, Circle, COLORFILL, ScrnObj::Disp, Viewport::Done(), draw_check(), Viewport::FastDraw(), Viewport::FillEllipse(), FILLSIZE, On, Viewport::SetColor(), Viewport::SetFillStyle(), Square, string_height, ScrnObj::X, and ScrnObj::Y.

Referenced by animate_box().

00123 {
00124   Disp->FastDraw();
00125   int x=X+CBORDERX;
00126   int y=(int)Y+abs((string_height-BOXSIZE)/2);
00127 
00128   Disp->SetFillStyle(SOLID_FILL, COLORFILL);
00129   Disp->SetColor(COLORFILL);
00130   switch(Type) {
00131     case Square:
00132       draw_check();
00133       break;
00134     case Circle:
00135       int radius = (int)(BOXSIZE/2);
00136       Disp->FillEllipse(x+radius, y+radius, radius-FILLSIZE-2, radius-FILLSIZE-2);
00137       break;
00138   }
00139   Disp->Done();
00140 
00141   BStatus = On;
00142 }

int CheckBox::GetXDim   [inline, virtual]
 

Reimplemented from ScrnObj.

Definition at line 146 of file checkbox.h.

References xdim.

00147   {return xdim;}

int CheckBox::GetYDim   [inline, virtual]
 

Reimplemented from ScrnObj.

Definition at line 149 of file checkbox.h.

References ydim.

00150   {return ydim;}

void CheckBox::image_size int   ,
int   
[inline, private]
 

Reimplemented in Nodes.

Definition at line 133 of file checkbox.h.

References ScrnObj::X, X2, ScrnObj::Y, and Y2.

00134   {X2 = X+x2; Y2 = Y+y2;}

void CheckBox::image_size   [inline, private]
 

Reimplemented in Nodes.

Definition at line 136 of file checkbox.h.

References BOXBORDER, BOXSIZE, CBORDERX, string_height, string_width, ScrnObj::X, X2, ScrnObj::Y, and Y2.

Referenced by CheckBox().

void CheckBox::Init Display  ,
int   ,
int   
[virtual]
 

Reimplemented from ScrnObj.

Reimplemented in Nodes.

Definition at line 54 of file checkbox.c.

References BkColor, ScrnObj::Disp, Viewport::GetBkColor(), ScrnObj::X, X2, ScrnObj::Y, and Y2.

Referenced by Group::Add().

00055 {
00056   X = x; X2+=X;
00057   Y = y; Y2+=Y;
00058 
00059   Disp = d;
00060   BkColor=Disp->GetBkColor();
00061 }

Message CheckBox::key_msg Message   [protected]
 

Reimplemented in Nodes.

Definition at line 261 of file checkbox.c.

Referenced by Dispatch().

00262 {
00263 /*  if (KeyBounds(msg.d1, msg.d2) && Able)
00264       return NullMsg; */
00265 
00266 return NullMsg;
00267 }

Message CheckBox::mouse_msg Message   [protected]
 

Reimplemented in Nodes.

Definition at line 229 of file checkbox.c.

References Able, Activated, animate_box(), animate_frame(), BStatus, ButtonBounds(), ButtonMsg, Message::code, Message::d1, Message::d2, False, IdNum, LMouseDown, LMouseStillDown, LMouseUp, Off, On, Status, and True.

Referenced by Dispatch().

00230 {
00231   if (ButtonBounds(msg.d1, msg.d2) && Able) {
00232     switch(msg.code) {
00233       case LMouseDown:
00234         Activated = True;
00235         animate_frame();
00236         return Acknowledged;
00237       case LMouseStillDown:
00238         if(!Activated) {
00239           Activated = True;
00240           animate_frame();
00241         }
00242         return NullMsg;
00243       case LMouseUp:
00244         Activated = False;
00245         BStatus = BStatus? Off : On;
00246         animate_frame();
00247         animate_box();
00248         return Message(ButtonMsg, Status, IdNum, BStatus);
00249       default:
00250         return NullMsg;
00251     }
00252   }
00253   if(msg.code==LMouseStillDown && Activated && Able) {
00254     Activated = False;
00255     animate_frame();
00256     animate_box();
00257   }
00258   return NullMsg;
00259 }

void CheckBox::name_button int    [private]
 

Definition at line 200 of file checkbox.c.

References BOXBORDER, BOXSIZE, CBORDERX, CFONT, CFONT_SIZE, ScrnObj::Disp, Viewport::OutTextXY(), Viewport::SetColor(), Viewport::SetTextStyle(), string, ScrnObj::X, X2, ScrnObj::Y, and Y2.

Referenced by disable_box(), Draw(), and enable_box().

00201 {
00202   int x, y, x2, y2;
00203 
00204   x = X+CBORDERX+BOXSIZE+BOXBORDER;
00205   y = Y;
00206   x2  = X2;
00207   y2  = Y2;
00208 
00209   Viewport surf (Disp, x, y, x2, y2);
00210 
00211   surf.SetColor(color);
00212   surf.SetTextStyle (CFONT, HORIZ_DIR, CFONT_SIZE);
00213   surf.OutTextXY(0, 0, string);
00214 }

void CheckBox::prep_screen int    [private]
 

Reimplemented in Nodes.

void CheckBox::set_constants char *   ,
int   ,
int   ,
int   ,
int   
[private]
 

Definition at line 20 of file checkbox.c.

References Able, Activated, BStatus, CFONT, CFONT_SIZE, Color, COLORFILL, ScrnObj::Drawn, False, IdNum, No, Off, Viewport::SetTextStyle(), string, string_height, string_width, Viewport::TextHeight(), Viewport::TextWidth(), Type, ScrnObj::X, ScrnObj::Y, and Yes.

Referenced by CheckBox().

00021 {
00022   /*****************************************************************
00023 
00024     Flag states of CheckBoxes...
00025 
00026       Activated - User input detected...
00027       BStatus - Whether the option is selected or not...
00028       Able    - Allow/disallow interaction with user...
00029 
00030    *****************************************************************/
00031 
00032   Activated   = False;
00033   BStatus   = Off;  // For now, may be a user-defined field later.
00034   Able      = Yes;
00035 
00036   Color   = color;
00037   COLORFILL   = fcolor;
00038   strcpy(string, name);
00039 
00040   IdNum = Id;
00041   Drawn = No;
00042   Type = type;
00043   X=0; Y=0;
00044 
00045   Viewport surf;
00046   surf.SetTextStyle(CFONT, HORIZ_DIR, CFONT_SIZE);
00047 
00048   string_height = surf.TextHeight(string);
00049   // Adjust for differing fonts...
00050   string_height = (int)(string_height+(string_height*.33));
00051   string_width  = surf.TextWidth(string);
00052 }

void CheckBox::SetPseudo BOOLEAN    [inline]
 

Definition at line 124 of file checkbox.h.

References Able, and BOOLEAN.

00125   {Able=state;}

BOOLEAN CheckBox::status   [inline, protected]
 

Definition at line 140 of file checkbox.h.

References BOOLEAN, and BStatus.

Referenced by Nodes::command_msg(), and command_msg().

00141   {return BStatus;}


Member Data Documentation

BOOLEAN CheckBox::Able [protected]
 

Definition at line 51 of file checkbox.h.

Referenced by Nodes::animate_box(), Nodes::disable_box(), disable_box(), Nodes::enable_box(), enable_box(), Nodes::mouse_msg(), mouse_msg(), Nodes::set_constants(), set_constants(), and SetPseudo().

BOOLEAN CheckBox::Activated [protected]
 

Definition at line 51 of file checkbox.h.

Referenced by Nodes::mouse_msg(), mouse_msg(), Nodes::set_constants(), and set_constants().

int CheckBox::BkColor [protected]
 

Definition at line 50 of file checkbox.h.

Referenced by animate_frame(), Nodes::Init(), and Init().

BOOLEAN CheckBox::BStatus [protected]
 

Definition at line 51 of file checkbox.h.

Referenced by Nodes::ChangeStatus(), ChangeStatus(), command_msg(), Nodes::disable_box(), Nodes::empty_box(), empty_box(), Nodes::enable_box(), Nodes::EnableNode(), Nodes::fill_box(), fill_box(), Nodes::mouse_msg(), mouse_msg(), Nodes::set_constants(), set_constants(), and status().

int CheckBox::Color [protected]
 

Definition at line 50 of file checkbox.h.

Referenced by Draw(), enable_box(), and set_constants().

int CheckBox::COLORFILL [private]
 

Definition at line 46 of file checkbox.h.

Referenced by fill_box(), and set_constants().

int CheckBox::IdNum [protected]
 

Definition at line 50 of file checkbox.h.

Referenced by BoxId(), Nodes::command_msg(), command_msg(), Nodes::Draw(), Nodes::mouse_msg(), mouse_msg(), Nodes::set_constants(), and set_constants().

char CheckBox::string[80] [private]
 

Definition at line 47 of file checkbox.h.

Referenced by name_button(), and set_constants().

int CheckBox::string_height [private]
 

Definition at line 46 of file checkbox.h.

Referenced by animate_frame(), Draw(), draw_check(), empty_box(), fill_box(), image_size(), and set_constants().

int CheckBox::string_width [private]
 

Definition at line 46 of file checkbox.h.

Referenced by image_size(), and set_constants().

int CheckBox::Type [private]
 

Definition at line 46 of file checkbox.h.

Referenced by set_constants().

int CheckBox::X2 [protected]
 

Definition at line 49 of file checkbox.h.

Referenced by CheckBox(), Erase(), Nodes::image_size(), image_size(), Nodes::Init(), Init(), and name_button().

int CheckBox::xdim [protected]
 

Definition at line 49 of file checkbox.h.

Referenced by CheckBox(), and GetXDim().

int CheckBox::Y2 [protected]
 

Definition at line 49 of file checkbox.h.

Referenced by CheckBox(), Erase(), Nodes::image_size(), image_size(), Nodes::Init(), Init(), and name_button().

int CheckBox::ydim [protected]
 

Definition at line 49 of file checkbox.h.

Referenced by CheckBox(), and GetYDim().


The documentation for this class was generated from the following files:
Generated on Sun Jul 6 23:07:17 2003 for Scotland Yard by doxygen1.2.15