Main Page | Class Hierarchy | Class List | File List | Class Members

aedRect.h

00001 
00002 /*
00003  * The aedRect class
00004  * This class controls every widget position
00005  * Initial design by Eduardo B. Fonseca <ebf@aedsolucoes.com.br>
00006  *
00007  * This library is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU Library General Public
00009  * License as published by the Free Software Foundation; either
00010  * version 2 of the License, or (at your option) any later version.
00011  *
00012  * This library 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 GNU
00015  * Library General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU Library General Public
00018  * License along with this library; if not, write to the Free
00019  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020  *
00021  */
00022 #ifndef AEDRECT_H
00023 #define AEDRECT_H
00024 
00025 #include <iostream>
00026 #include "dllmacros.h"
00027 #include "SDL.h"
00028 
00029 #define aedDEFAULTPOSITION aedRect(0,0,0,0)
00030 
00031 class DLLEXPORT aedRect
00032 {
00033   public:
00034     aedRect()
00035     {
00036         m_X = 0;
00037         m_Y = 0;
00038         m_W = 0;
00039         m_H = 0;
00040     }
00041     aedRect(Sint32 x, Sint32 y, Sint32 w, Sint32 h)
00042     {
00043         m_X = x;
00044         m_Y = y;
00045         m_W = w;
00046         m_H = h;
00047     }
00048     aedRect(SDL_Rect & rect)
00049     {
00050         m_X = rect.x;
00051         m_Y = rect.y;
00052         m_W = rect.w;
00053         m_H = rect.h;
00054     }
00055 
00056     Sint32 getWidth(void)
00057     {
00058         return m_W;
00059     }
00060     Sint32 getHeight(void)
00061     {
00062         return m_H;
00063     }
00064     Sint32 getX(void)
00065     {
00066         return m_X;
00067     }
00068     Sint32 getY(void)
00069     {
00070         return m_Y;
00071     }
00072     Sint32 getX2(void)
00073     {
00074         return m_X + m_W;
00075     }
00076     Sint32 getY2(void)
00077     {
00078         return m_Y + m_H;
00079     }
00080 
00081     void setX(Sint32 X)
00082     {
00083         m_X = X;
00084     }
00085     void setY(Sint32 Y)
00086     {
00087         m_Y = Y;
00088     }
00089     void setWidth(Sint32 W)
00090     {
00091         m_W = W;
00092     }
00093     void setHeight(Sint32 H)
00094     {
00095         m_H = H;
00096     }
00097     void setRect(Sint32 X, Sint32 Y, Sint32 W, Sint32 H)
00098     {
00099         setX(X);
00100         setY(Y);
00101         setWidth(W);
00102         setHeight(H);
00103     }
00104     bool isPointIn(Sint32 x, Sint32 y)
00105     {
00106         if((x >= getX()) && (x <= getX2()) && (y >= getY()) && (y <= getY2()))
00107         {
00108             return true;
00109         }
00110 
00111         return false;
00112     }
00113     void dumpAll(void)
00114     {
00115         std::cout << "X: " << getX() << std::endl;
00116         std::cout << "Y: " << getY() << std::endl;
00117         std::cout << "W: " << getWidth() << std::endl;
00118         std::cout << "H: " << getHeight() << std::endl;
00119         std::cout << "--" << std::endl;
00120     }
00121 
00122     SDL_Rect getSDLRect(void)
00123     {
00124         SDL_Rect rect;
00125 
00126         rect.x = getX();
00127         rect.y = getY();
00128         rect.w = getWidth();
00129         rect.h = getHeight();
00130         return rect;
00131     }
00132     bool operator==(aedRect op2)
00133     {
00134         if((getX() == op2.getX()) && (getY() == op2.getY()) &&
00135            (getWidth() == op2.getWidth()) && (getHeight() == op2.getHeight()))
00136             return true;
00137 
00138         return false;
00139     }
00140     bool operator!=(aedRect op2)
00141     {
00142         if((getX() == op2.getX()) && (getY() == op2.getY()) &&
00143            (getWidth() == op2.getWidth()) && (getHeight() == op2.getHeight()))
00144             return false;
00145 
00146         return true;
00147     }
00148 
00149   private:
00150     Sint32 m_X, m_Y, m_W, m_H;
00151 };
00152 
00153 #endif /* AEDRECT_H */

Generated on Mon Mar 1 19:56:18 2004 for aedGUI by doxygen 1.3.6