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

checkbox.h

Go to the documentation of this file.
00001 /*************************************************************************
00002  *
00003  *  AUTHOR: Wilson T
00004  *
00005  *  TITLE:  checkbox.h
00006  *
00007  *  DATE: April 25, 1993
00008  *
00009  *  PURPOSE: Declaration of checkbox class and constants.
00010  *
00011  *************************************************************************/
00012 
00013 
00014 #ifndef _CHECKBOX_H
00015 #define _CHECKBOX_H
00016 
00017 
00018 #include <stdlib.h>
00019 #include "typedefs.h"
00020 #include "scrnobj.h"
00021 #include "viewport.h"
00022 #include "display.h"
00023 #include "messages.h"
00024 
00025 typedef bool BOOLEAN;
00026 enum Type {Square, Circle};
00027 
00028         /*************************
00029          *                       *
00030          * Constant Declarations *
00031          *                       *
00032          *************************/
00033 
00034 const int CBORDERX  = 4;  // Border space from box to edge
00035 const int CBORDERY  = 4;  // " "
00036 const int CFRAME  = 2;  // Additional highlighting of checkbox when Active
00037 const int CFONT = SMALL_FONT;
00038 const int CFONT_SIZE= 5;
00039 const int BOXSIZE = 10; // For both circle and square... a box dimension
00040 const int FILLSIZE  = 1;  // Border of fill graphics from box
00041 const int BOXBORDER = 4;  // Space between box and text.
00042 const int BOXCOLOR  = LIGHTGRAY;
00043 const int OFFCOLOR  = DARKGRAY;
00044 
00045 class CheckBox:public ScrnObj{
00046   int string_height, string_width, COLORFILL, Type;
00047   char  string[80];
00048 protected:
00049   int  X2, Y2, xdim, ydim;
00050   int Color, BkColor, IdNum;
00051   BOOLEAN Activated, BStatus, Able;
00052   CheckBox (void) { }
00053 public:
00054   CheckBox        (char*, int, int, int, int);
00055   CheckBox        (char*, int, int, int, int, int, int);
00056   // Default fillcolor set...
00057   CheckBox        (char*, int, int, int);
00058   CheckBox        (char*, int, int, int, int, int);
00059 
00060   void Init       (Display *, int, int);
00061   ~CheckBox       ()
00062     {if (Drawn) Erase();}
00063   void  Draw        ();
00064   void Erase      ();
00065   BOOLEAN ButtonBounds  (int, int);
00066   Message Dispatch    (Message &);
00067   int GetXDim     ();
00068   int GetYDim     ();
00069   void ChangeStatus   (BOOLEAN);
00070   int BoxId       ();
00071   int CenterPtX     ();
00072   int CenterPtY     ();
00073   void SetPseudo      (BOOLEAN);
00074   void DisableBox     ();
00075   void EnableBox      ();
00076 protected:
00077   void animate_box  ();
00078   void animate_frame  ();
00079   Message mouse_msg (Message &);
00080   Message key_msg (Message &);
00081   Message command_msg (Message &);
00082   BOOLEAN status    ();
00083   void disable_box  ();
00084   void enable_box ();
00085 private:
00086   void set_constants  (char*, int, int, int, int);
00087   void  image_size  ();
00088   void  image_size  (int, int);
00089   void prep_screen  (int);
00090   void name_button  (int);
00091   void fill_box   ();
00092   void empty_box    (int);
00093   void draw_check ();
00094 };
00095 
00096 inline CheckBox::CheckBox(char *name, int color, int fcolor, int Id, int type)
00097   {set_constants(name, color, fcolor, Id, type); image_size();
00098   xdim=X2-X; ydim=Y2-Y;}
00099 
00100 inline CheckBox::CheckBox(char *name, int color, int fcolor, int Id, int type, int x2, int y2)
00101   {set_constants(name, color, fcolor, Id, type); image_size(x2, y2);
00102   xdim=X2-X; ydim=Y2-Y;}
00103 
00104 inline CheckBox::CheckBox(char *name, int color, int Id, int type)
00105   {set_constants(name, color, BLUE, Id, type); image_size();
00106   xdim=X2-X; ydim=Y2-Y;}
00107 
00108 inline CheckBox::CheckBox(char *name, int color, int Id, int type, int x2, int y2)
00109   {set_constants(name, color, BLUE, Id, type); image_size(x2, y2);
00110   xdim=X2-X; ydim=Y2-Y;}
00111 
00112 inline void CheckBox::ChangeStatus(BOOLEAN bswitch)
00113   {BStatus=bswitch; animate_box();}
00114 
00115 inline int CheckBox::BoxId()
00116   {return IdNum;}
00117 
00118 inline int CheckBox::CenterPtX()
00119   {return X+BOXSIZE/2;}
00120 
00121 inline int CheckBox::CenterPtY()
00122   {return Y+BOXSIZE/2;}
00123 
00124 inline void CheckBox::SetPseudo(BOOLEAN state)
00125   {Able=state;}
00126 
00127 inline void CheckBox::DisableBox()
00128   {disable_box();}
00129 
00130 inline void CheckBox::EnableBox()
00131   {enable_box();}
00132 
00133 inline void CheckBox::image_size(int x2, int y2)
00134   {X2 = X+x2; Y2 = Y+y2;}
00135 
00136 inline void CheckBox::image_size()
00137   {X2 = X+string_width+(2*CBORDERX) + (BOXSIZE+BOXBORDER);
00138   Y2 = Y+((BOXSIZE>string_height)?BOXSIZE:string_height);}
00139 
00140 inline BOOLEAN CheckBox::status()
00141   {return BStatus;}
00142 
00143 inline void CheckBox::animate_box()
00144   {if (BStatus) fill_box(); else empty_box(BOXCOLOR);}
00145 
00146 inline int CheckBox::GetXDim()
00147   {return xdim;}
00148 
00149 inline int CheckBox::GetYDim()
00150   {return ydim;}
00151 
00152 inline void CheckBox::disable_box()
00153   {Able=No; empty_box(OFFCOLOR); name_button(OFFCOLOR);}
00154 
00155 inline void CheckBox::enable_box()
00156   {Able=Yes; empty_box(BOXCOLOR); name_button(Color);}
00157 
00158 
00159 
00160 #endif

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