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

ScreenState.h

00001 #ifndef SCREENSTATE_H
00002 #define SCREENSTATE_H
00003 
00004 #include "stdafx.h"
00005 #include "Point.h"
00006 
00007 // Determines the detail of point storage. If VSCREEN_POINTSIZE = 50, there are 50 document points for each pixel.
00008 const int VSCREEN_POINTSIZE = 50;
00009 
00011 class ScreenState
00012 {
00013 public:
00015         CRect screen;   
00017         CRect doc; 
00018 
00020         CRect window;
00021 
00022 public:
00023         ScreenState() : screen(0, 0, 220, 280), doc(0, 0, 220, 280), window(0, 0, 220, 280)
00024         {
00025         }
00026 
00027         int ScreenToDoc_x( int x )
00028         {
00029                 return (int) (ScreenToDocRatio_x() * (VSCREEN_POINTSIZE * x - screen.left) + doc.left);
00030         }
00031         
00032         int ScreenToDoc_x( float x )
00033         {
00034                 return (int) (ScreenToDocRatio_x() * (float) (VSCREEN_POINTSIZE * x - screen.left) + doc.left);
00035         }
00036 
00037         int ScreenToDoc_y( int y )
00038         {
00039                 return (int) (ScreenToDocRatio_y() * (VSCREEN_POINTSIZE * y - screen.top) + doc.top);
00040         }
00041 
00042         int ScreenToDoc_y( float y )
00043         {
00044                 return (int) (ScreenToDocRatio_y() * (float) (VSCREEN_POINTSIZE * y - screen.top) + doc.top);
00045         }
00046 
00047         VPoint ScreenToDoc( VPoint pt)
00048         {
00049                 return VPoint( ScreenToDoc_x(pt.x), ScreenToDoc_y(pt.y) );
00050         }
00051 
00052         float ScreenToDocRatio_x()
00053         {
00054                 if (screen.Width != 0)
00055                         return (float) doc.Width() / screen.Width();
00056                 else
00057                         return 1;
00058         }
00059 
00060         float ScreenToDocRatio_y()
00061         {
00062                 if (screen.Height != 0)
00063                         return (float) doc.Height() / screen.Height();
00064                 else
00065                         return 1;
00066         }
00067 
00068 
00069 
00070         int DocToScreen_x( int x )
00071         {
00072                 return (int) (DocToScreenRatio_x() * (x - doc.left) + screen.left)/VSCREEN_POINTSIZE;
00073         }
00074 
00075         int DocToScreen_y( int y )
00076         {
00077                 return (int) (DocToScreenRatio_y() * (y - doc.top) + screen.top)/VSCREEN_POINTSIZE;
00078         }
00079 
00080         VPoint DocToScreen( VPoint pt )
00081         {
00082                 return VPoint( DocToScreen_x(pt.x), DocToScreen_y(pt.y) );
00083         }
00084 
00085 
00086 
00087 
00088         float DocToScreenRatio_x()
00089         {
00090                 if (doc.Width != 0)
00091                         return (float) screen.Width() / doc.Width();
00092                 else
00093                         return 1;
00094         }
00095 
00096         float DocToScreenRatio_y()
00097         {
00098                 if (doc.Height != 0)
00099                         return (float) screen.Height() / doc.Height();
00100                 else
00101                         return 1;
00102         }
00103 
00104         static int PointMultiplier()
00105         {
00106                 return VSCREEN_POINTSIZE;
00107         }
00108 };
00109 
00110 
00111 #endif

Generated at Wed Aug 29 19:58:55 2001 for Pocket Animator by doxygen1.2.5 written by Dimitri van Heesch, © 1997-2001