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

viewport.c

Go to the documentation of this file.
00001 /**********************************************************************
00002 * FILE: viewport.c
00003 * AUTHOR: CAL
00004 * DATE: 25 April 1993
00005 * PURPOSE:
00006 *   Contains functions pertaining to Viewports.
00007 ***********************************************************************/
00008 
00009 #include "viewport.h"
00010 
00011 /**********************************************************************
00012 * Static data members
00013 ***********************************************************************/
00014 
00015 Viewport* Viewport::Context = NULL;
00016 int Viewport::Fast = 0;
00017 
00018 
00019 /**********************************************************************
00020 * Constructors
00021 ***********************************************************************/
00022 
00023 Viewport::Viewport (Viewport* parent, int x1, int y1, int x2, int y2)
00024 : SView (x1, y1, x2, y2)
00025 {
00026   Parent = parent;
00027   if (Parent)
00028   {
00029     SView.X1 += Parent->SView.X1;
00030     SView.Y1 += Parent->SView.Y1;
00031     SView.X2 += Parent->SView.X1;
00032     SView.Y2 += Parent->SView.Y1;
00033   }
00034   Install ();
00035 }
00036 
00037 Viewport::Viewport (void)
00038 {
00039   Parent = NULL;
00040   Install ();
00041 }
00042 
00043 
00044 void Viewport::Install (void)
00045 {
00046   SView.Install ();
00047   SColor.Install ();
00048   SFill.Install ();
00049   SLine.Install ();
00050   SText.Install ();
00051   SPos.Install ();
00052   Context = this;
00053 }
00054 
00055 
00056 void Viewport::Clear (void)
00057 {
00058   SwitchTo ();
00059   DoDraw ();
00060   setfillstyle (SOLID_FILL, SColor.BG);
00061   bar (0, 0, SView.X2, SView.Y2);
00062   DoneDraw ();
00063   SPos.X = SPos.Y = 0;
00064   Context = NULL;
00065 }
00066 
00067 
00068 int Viewport::TransX (int x)
00069 {
00070   if (!Parent)
00071     return x;
00072   else
00073     return (x - (Parent->TransX (SView.X1)));
00074 }
00075 
00076 int Viewport::TransY (int y)
00077 {
00078   if (!Parent)
00079     return y;
00080   else
00081     return (y - (Parent->TransY (SView.Y1)));
00082 }
00083 
00084 
00085 bool Viewport::InBounds (int x, int y)
00086 {
00087   return (bool) ((x >= 0) && (x <= GetMaxX()) &&
00088      (y >= 0) && (y <= GetMaxY()));
00089 }
00090 

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