Main Page | Modules | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

position.cpp

00001 /*****************************************************************************
00002  * position.cpp
00003  *****************************************************************************
00004  * Copyright (C) 2003 the VideoLAN team
00005  * $Id: position.cpp 11664 2005-07-09 06:17:09Z courmisch $
00006  *
00007  * Authors: Cyril Deguet     <[email protected]>
00008  *          Olivier Teulière <[email protected]>
00009  *
00010  * This program is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2 of the License, or
00013  * (at your option) any later version.
00014  *
00015  * This program is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  * GNU General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU General Public License
00021  * along with this program; if not, write to the Free Software
00022  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
00023  *****************************************************************************/
00024 
00025 #include "position.hpp"
00026 
00027 
00028 Rect::Rect( int left, int top, int right, int bottom ):
00029     m_left( left ), m_top( top ), m_right( right ), m_bottom( bottom )
00030 {
00031 }
00032 
00033 
00034 Position::Position( int left, int top, int right, int bottom, const Box &rBox,
00035                     Ref_t refLeftTop, Ref_t refRightBottom ):
00036     m_left( left ), m_top( top ), m_right( right ), m_bottom( bottom ),
00037     m_rBox( rBox ), m_refLeftTop( refLeftTop ),
00038     m_refRighBottom( refRightBottom )
00039 {
00040 }
00041 
00042 
00043 int Position::getLeft() const
00044 {
00045     switch( m_refLeftTop )
00046     {
00047         case kLeftTop:
00048         case kLeftBottom:
00049             return m_left;
00050             break;
00051         case kRightTop:
00052         case kRightBottom:
00053             return m_rBox.getWidth() + m_left - 1;
00054             break;
00055     }
00056     // Avoid a warning
00057     return 0;
00058 }
00059 
00060 
00061 int Position::getTop() const
00062 {
00063     switch( m_refLeftTop )
00064     {
00065         case kLeftTop:
00066         case kRightTop:
00067             return m_top;
00068             break;
00069         case kRightBottom:
00070         case kLeftBottom:
00071             return m_rBox.getHeight() + m_top - 1;
00072             break;
00073     }
00074     // Avoid a warning
00075     return 0;
00076 }
00077 
00078 
00079 int Position::getRight() const
00080 {
00081     switch( m_refRighBottom )
00082     {
00083         case kLeftTop:
00084         case kLeftBottom:
00085             return m_right;
00086             break;
00087         case kRightTop:
00088         case kRightBottom:
00089             return m_rBox.getWidth() + m_right - 1;
00090             break;
00091     }
00092     // Avoid a warning
00093     return 0;
00094 }
00095 
00096 
00097 int Position::getBottom() const
00098 {
00099     switch( m_refRighBottom )
00100     {
00101         case kLeftTop:
00102         case kRightTop:
00103             return m_bottom;
00104             break;
00105         case kLeftBottom:
00106         case kRightBottom:
00107             return m_rBox.getHeight() + m_bottom - 1;
00108             break;
00109     }
00110     // Avoid a warning
00111     return 0;
00112 }
00113 
00114 
00115 int Position::getWidth() const
00116 {
00117     return getRight() - getLeft() + 1;
00118 }
00119 
00120 
00121 int Position::getHeight() const
00122 {
00123     return getBottom() - getTop() + 1;
00124 }
00125 

Generated on Tue Dec 20 10:14:43 2005 for vlc-0.8.4a by  doxygen 1.4.2