1 : /* -*- Mode: c++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2 : * ***** BEGIN LICENSE BLOCK *****
3 : * Version: MPL 1.1/GPL 2.0/LGPL 2.1
4 : *
5 : * The contents of this file are subject to the Mozilla Public License Version
6 : * 1.1 (the "License"); you may not use this file except in compliance with
7 : * the License. You may obtain a copy of the License at
8 : * http://www.mozilla.org/MPL/
9 : *
10 : * Software distributed under the License is distributed on an "AS IS" basis,
11 : * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 : * for the specific language governing rights and limitations under the
13 : * License.
14 : *
15 : * The Original Code is Mozilla Corporation code.
16 : *
17 : * The Initial Developer of the Original Code is Mozilla Foundation.
18 : * Portions created by the Initial Developer are Copyright (Sub) 2011
19 : * the Initial Developer. All Rights Reserved.
20 : *
21 : * Contributor(s):
22 : * Robert O'Callahan <robert@ocallahan.org>
23 : *
24 : * Alternatively, the contents of this file may be used under the terms of
25 : * either the GNU General Public License Version 2 or later (the "GPL"), or
26 : * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 : * in which case the provisions of the GPL or the LGPL are applicable instead
28 : * of those above. If you wish to allow use of your version of this file only
29 : * under the terms of either the GPL or the LGPL, and not to allow others to
30 : * use your version of this file under the terms of the MPL, indicate your
31 : * decision by deleting the provisions above and replace them with the notice
32 : * and other provisions required by the GPL or the LGPL. If you do not delete
33 : * the provisions above, a recipient may use your version of this file under
34 : * the terms of any one of the MPL, the GPL or the LGPL.
35 : *
36 : * ***** END LICENSE BLOCK ***** */
37 :
38 : #ifndef MOZILLA_GFX_RECT_H_
39 : #define MOZILLA_GFX_RECT_H_
40 :
41 : #include "BaseRect.h"
42 : #include "BaseMargin.h"
43 : #include "Point.h"
44 :
45 : namespace mozilla {
46 : namespace gfx {
47 :
48 : struct Margin :
49 : public BaseMargin<Float, Margin> {
50 : typedef BaseMargin<Float, Margin> Super;
51 :
52 : // Constructors
53 : Margin(const Margin& aMargin) : Super(aMargin) {}
54 : Margin(Float aLeft, Float aTop, Float aRight, Float aBottom)
55 : : Super(aLeft, aTop, aRight, aBottom) {}
56 : };
57 :
58 : struct IntRect :
59 : public BaseRect<int32_t, IntRect, IntPoint, IntSize, Margin> {
60 : typedef BaseRect<int32_t, IntRect, IntPoint, mozilla::gfx::IntSize, Margin> Super;
61 :
62 : IntRect() : Super() {}
63 : IntRect(IntPoint aPos, mozilla::gfx::IntSize aSize) :
64 : Super(aPos, aSize) {}
65 0 : IntRect(int32_t _x, int32_t _y, int32_t _width, int32_t _height) :
66 0 : Super(_x, _y, _width, _height) {}
67 :
68 : // Rounding isn't meaningful on an integer rectangle.
69 : void Round() {}
70 : void RoundIn() {}
71 : void RoundOut() {}
72 : };
73 :
74 : struct Rect :
75 : public BaseRect<Float, Rect, Point, Size, Margin> {
76 : typedef BaseRect<Float, Rect, Point, mozilla::gfx::Size, Margin> Super;
77 :
78 : Rect() : Super() {}
79 : Rect(Point aPos, mozilla::gfx::Size aSize) :
80 : Super(aPos, aSize) {}
81 0 : Rect(Float _x, Float _y, Float _width, Float _height) :
82 0 : Super(_x, _y, _width, _height) {}
83 : explicit Rect(const IntRect& rect) :
84 : Super(float(rect.x), float(rect.y),
85 : float(rect.width), float(rect.height)) {}
86 : };
87 :
88 : }
89 : }
90 :
91 : #endif /* MOZILLA_GFX_RECT_H_ */
|