Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

layout.h

Go to the documentation of this file.
00001 /* ***********************************************************************************
00002         Writer:         Sebastien Bloc
00003         Copyright:      2003-2004
00004         eMail:          sebastien.bloc@free.fr
00005         URL:            http://mignonsoft.free.fr
00006 
00007         This program is free software; you can redistribute it and/or
00008         modify it under the terms of the GNU General Public License
00009         as published by the Free Software Foundation; either version 2
00010         of the License, or (at your option) any later version.
00011 
00012         This program is distributed in the hope that it will be useful,
00013         but WITHOUT ANY WARRANTY; without even the implied warranty of
00014         MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015         GNU General Public License for more details.
00016         http://www.gnu.org/copyleft/gpl.html
00017 *********************************************************************************** */
00018 
00023 #ifndef INCLUDE_LAYOUT_H
00024 #define INCLUDE_LAYOUT_H
00025 
00040 template <class T> class Layout // T peut etre de preferance float ou double
00041 {
00042 public:
00043         T constValue;
00044         double percentValue;
00045         T *baseValue;
00046 
00047 public:
00048         Layout()
00049         {
00050                 Zero();
00051         }
00052 
00053         void Zero()
00054         {
00055                 constValue=0;
00056                 percentValue=0;
00057                 baseValue=NULL;
00058         }
00059 
00067         void operator=(int value)
00068         {
00069                 constValue = value;
00070         }
00071 
00072         void operator=(GLdouble value)
00073         {
00074                 constValue = value;
00075         }
00076 
00077         void operator=(Layout &source)
00078         {
00079                 constValue = source.constValue;
00080                 percentValue = source.percentValue;
00081                 baseValue = source.baseValue;
00082         }
00083 
00084         void Set(T _constValue,double _percentValue=0,T *_baseValue=NULL) 
00085         {
00086                 constValue = _constValue;
00087                 SetPercent(_percentValue,_baseValue);
00088         }
00089 
00090         void SetPercent(double _percentValue=0,T *_baseValue=NULL)
00091         {
00092                 percentValue = _percentValue;
00093                 baseValue = _baseValue;
00094         }
00095 
00096         BOOL IsDynamic()
00097         {
00098                 return baseValue?TRUE:FALSE;
00099         }
00100 
00117         T Compute()
00118         {
00119                 if (!percentValue || !baseValue) return constValue;
00120                 return constValue+*baseValue*percentValue;
00121         }
00122 };
00123 
00124 #endif

Generated on Fri Aug 20 19:19:46 2004 for 3d Controls by doxygen 1.3.6