]> git.sesse.net Git - vlc/blob - modules/gui/skins2/utils/position.hpp
Make Zorglub less unhappy
[vlc] / modules / gui / skins2 / utils / position.hpp
1 /*****************************************************************************
2  * position.hpp
3  *****************************************************************************
4  * Copyright (C) 2003 the VideoLAN team
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 #ifndef POSITION_HPP
26 #define POSITION_HPP
27
28
29 /// Interface for rectangular objects
30 class Box
31 {
32     public:
33         /// Get the size of the box
34         virtual int getWidth() const = 0;
35         virtual int getHeight() const = 0;
36 };
37
38
39 /// Characterization of a rectangle
40 class Rect: public Box
41 {
42     public:
43         Rect( int left, int top, int right, int bottom );
44
45         virtual int getLeft() const { return m_left; }
46         virtual int getTop() const { return m_top; }
47         virtual int getRight() const { return m_right; }
48         virtual int getBottom() const { return m_bottom; }
49
50         virtual int getWidth() const { return m_right - m_left; }
51         virtual int getHeight() const { return m_bottom - m_top; }
52
53     private:
54         int m_left;
55         int m_top;
56         int m_right;
57         int m_bottom;
58 };
59
60
61 /// Relative position of a rectangle in a box
62 class Position
63 {
64     public:
65         /// Type for reference edge/corner
66         typedef enum
67         {
68             /// Coordinates are relative to the upper left corner
69             kLeftTop,
70             /// Coordinates are relative to the upper right corner
71             kRightTop,
72             /// Coordinates are relative to the lower left corner
73             kLeftBottom,
74             /// Coordinates are relative to the lower right corner
75             kRightBottom
76         } Ref_t;
77
78         /// Create a new position relative to the given box
79         Position( int left, int top, int right, int bottom, const Box &rBox,
80                   Ref_t refLeftTop = kLeftTop,
81                   Ref_t refRightBottom = kLeftTop );
82
83         ~Position() {}
84
85         /// Get the position relative to the left top corner of the box
86         int getLeft() const;
87         int getTop() const;
88         int getRight() const;
89         int getBottom() const;
90         /// Get the size of the rectangle
91         int getWidth() const;
92         int getHeight() const;
93
94     private:
95         /// Position and reference edge/corner
96         int m_left;
97         int m_top;
98         int m_right;
99         int m_bottom;
100         const Box &m_rBox;
101         Ref_t m_refLeftTop;
102         Ref_t m_refRighBottom;
103 };
104
105
106 #endif