]> git.sesse.net Git - vlc/blob - modules/gui/skins2/utils/position.cpp
Copyright fixes
[vlc] / modules / gui / skins2 / utils / position.cpp
1 /*****************************************************************************
2  * position.cpp
3  *****************************************************************************
4  * Copyright (C) 2003 VideoLAN (Centrale Réseaux) and its contributors
5  * $Id$
6  *
7  * Authors: Cyril Deguet     <asmax@via.ecp.fr>
8  *          Olivier Teulière <ipkiss@via.ecp.fr>
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
23  *****************************************************************************/
24
25 #include "position.hpp"
26
27
28 Rect::Rect( int left, int top, int right, int bottom ):
29     m_left( left ), m_top( top ), m_right( right ), m_bottom( bottom )
30 {
31 }
32
33
34 Position::Position( int left, int top, int right, int bottom, const Box &rBox,
35                     Ref_t refLeftTop, Ref_t refRightBottom ):
36     m_left( left ), m_top( top ), m_right( right ), m_bottom( bottom ),
37     m_rBox( rBox ), m_refLeftTop( refLeftTop ),
38     m_refRighBottom( refRightBottom )
39 {
40 }
41
42
43 int Position::getLeft() const
44 {
45     switch( m_refLeftTop )
46     {
47         case kLeftTop:
48         case kLeftBottom:
49             return m_left;
50             break;
51         case kRightTop:
52         case kRightBottom:
53             return m_rBox.getWidth() + m_left - 1;
54             break;
55     }
56     // Avoid a warning
57     return 0;
58 }
59
60
61 int Position::getTop() const
62 {
63     switch( m_refLeftTop )
64     {
65         case kLeftTop:
66         case kRightTop:
67             return m_top;
68             break;
69         case kRightBottom:
70         case kLeftBottom:
71             return m_rBox.getHeight() + m_top - 1;
72             break;
73     }
74     // Avoid a warning
75     return 0;
76 }
77
78
79 int Position::getRight() const
80 {
81     switch( m_refRighBottom )
82     {
83         case kLeftTop:
84         case kLeftBottom:
85             return m_right;
86             break;
87         case kRightTop:
88         case kRightBottom:
89             return m_rBox.getWidth() + m_right - 1;
90             break;
91     }
92     // Avoid a warning
93     return 0;
94 }
95
96
97 int Position::getBottom() const
98 {
99     switch( m_refRighBottom )
100     {
101         case kLeftTop:
102         case kRightTop:
103             return m_bottom;
104             break;
105         case kLeftBottom:
106         case kRightBottom:
107             return m_rBox.getHeight() + m_bottom - 1;
108             break;
109     }
110     // Avoid a warning
111     return 0;
112 }
113
114
115 int Position::getWidth() const
116 {
117     return getRight() - getLeft() + 1;
118 }
119
120
121 int Position::getHeight() const
122 {
123     return getBottom() - getTop() + 1;
124 }
125