Home || Architecture || Video Search || Visual Search || Scripts || Applications || Important Messages || OGL || Src

LayoutScale.h

Go to the documentation of this file.
00001 #ifndef OglGui_LayoutScale_h
00002 #define OglGui_LayoutScale_h
00003 
00004 #ifndef OglGui_LayoutComponent_h
00005 #include "OglGui/LayoutComponent.h"
00006 #endif
00007 
00008 #ifndef OglGui_LayoutListener_h
00009 #include "OglGui/LayoutListener.h"
00010 #endif
00011 
00012 namespace OglGui
00013 {
00014 
00015 class LayoutScale : public LayoutListener
00016 {
00017 public:
00018 
00019     LayoutScale(LayoutComponent* leader, LayoutComponent* follower, int mode) :
00020         LayoutListener(leader, follower)
00021     {
00022         mMode = mode;
00023 
00024         int lx, ly, lw, lh;
00025         int fx, fy, fw, fh;
00026         mLeader->GetDimensions(lx, ly, lw, lh);
00027         mFollower->GetDimensions(fx, fy, fw, fh);
00028         
00029         mScaleX = (float)fx / lw;
00030         mScaleW = (float)fw / lw;
00031         mScaleY = (float)fy / lh;
00032         mScaleH = (float)fh / lh;
00033     }
00034 
00035     virtual void
00036     OnLayoutChange()
00037     {
00038         int lx, ly, lw, lh;
00039         int fx, fy, fw, fh;
00040         mLeader->GetDimensions(lx, ly, lw, lh);
00041         mFollower->GetDimensions(fx, fy, fw, fh);
00042         
00043         if(!(mMode & NoHorizontal))
00044         {
00045             fx = (int)(lw * mScaleX);
00046             if(!(mMode & NoWidth))
00047                 fw = (int)(lw * mScaleW);
00048         }
00049         if(!(mMode & NoVertical))
00050         {
00051             fy = (int)(lh * mScaleY);
00052             if(!(mMode & NoHeight))
00053                 fh = (int)(lh * mScaleH);
00054         }
00055 
00056         mFollower->SetDimensions(fx, fy, fw, fh);
00057     }
00058 
00059 protected:
00060     int     mMode;
00061     float   mScaleX;
00062     float   mScaleY;
00063     float   mScaleW;
00064     float   mScaleH;
00065 };
00066 
00067 } // namespace OglGui
00068 
00069 #endif // LayoutScale_h

Generated on Fri Mar 19 09:31:36 2010 for ImpalaSrc by  doxygen 1.5.1