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

button.h

Go to the documentation of this file.
00001 /*************************************************************************
00002  *
00003  *  AUTHOR: Wilson T
00004  *
00005  *  TITLE:  button.h
00006  *
00007  *  DATE: April 20, 1993
00008  *
00009  *  PURPOSE: Declaration of button class and constants.
00010  *
00011  *************************************************************************/
00012 
00013 #include <stdlib.h>
00014 #include "typedefs.h"
00015 #include "scrnobj.h"
00016 #include "viewport.h"
00017 #include "display.h"
00018 #include "messages.h"
00019 
00020 enum  SHADOW_STYLE {TOP_LEFT, BOTTOM_RIGHT, TOP_RIGHT, BOTTOM_LEFT};
00021 typedef bool BOOLEAN;
00022 
00023         /*************************
00024          *                       *
00025          * Constant Declarations *
00026          *                       *
00027          *************************/
00028 
00029 const int BORDERX = 3;  // Distance of button text from button bounds
00030 const int BORDERY = 2;   // " "
00031 const int SHADOWS = 2;
00032 const int FRAME = 1;
00033 const int FONT    = SMALL_FONT;
00034 const int FONT_SIZE = 5;
00035 
00036 class PushButton:public ScrnObj{
00037   void  *surface;
00038   int string_height, string_width, X2, Y2, xdim, ydim;
00039   char  string[80];
00040   int Color, IdNum;
00041   BOOLEAN Activated, Drawn;
00042 
00043 public:
00044   PushButton      (char*, int, int);
00045   PushButton      (char*, int, int, int, int);
00046   void Init       (Display *, int, int);
00047   ~PushButton     ()
00048     {if (Drawn) Erase(); delete surface;}
00049   void  Draw        ();
00050   void Erase      ();
00051   BOOLEAN ButtonBounds  (int, int);
00052   BOOLEAN ButtonStatus  ();
00053   int ButtonId      ();
00054   Message Dispatch    (Message &);
00055   int GetXDim     ();
00056   int GetYDim     ();
00057 private:
00058   void set_constants  (char *, int, int);
00059   void image_size ();
00060   void  image_size  (int, int);
00061   void draw_shadows (SHADOW_STYLE, int);
00062   void draw_frame ();
00063   void name_button  ();
00064   void depress_button ();
00065   void redraw   ();
00066   void animate_button ();
00067 };
00068 
00069 inline PushButton::PushButton(char *name, int color, int Id)
00070   {set_constants(name, color, Id); image_size();
00071    xdim=X2-X; ydim=Y2-Y;}
00072 
00073 inline PushButton::PushButton(char *name, int color, int Id, int x2, int y2)
00074   {set_constants(name, color, Id); image_size(x2, y2);
00075    xdim=X2-X; ydim=Y2-Y;}
00076 
00077 inline void PushButton::image_size(int x2, int y2)
00078   {X2 = X+x2; Y2 = Y+y2;}
00079 
00080 inline void PushButton::image_size()
00081   {X2 = X+string_width+(2*BORDERX)+(2*SHADOWS)+(2*FRAME);
00082   Y2 = Y+string_height+(2*BORDERY)+(2*SHADOWS)+(2*FRAME);}
00083 
00084 inline void PushButton::animate_button()
00085   {if (Activated) depress_button(); else redraw();}
00086 
00087 inline BOOLEAN PushButton::ButtonStatus()
00088   {return Activated;}
00089 
00090 inline int PushButton::ButtonId()
00091   {return IdNum;}
00092 
00093 inline int PushButton::GetXDim()
00094   {return xdim;}
00095 
00096 inline int PushButton::GetYDim()
00097   {return ydim;}

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