Branch data Line data Source code
1 : : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : : /*
3 : : * This file is part of the LibreOffice project.
4 : : *
5 : : * This Source Code Form is subject to the terms of the Mozilla Public
6 : : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : : *
9 : : * This file incorporates work covered by the following license notice:
10 : : *
11 : : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : : * contributor license agreements. See the NOTICE file distributed
13 : : * with this work for additional information regarding copyright
14 : : * ownership. The ASF licenses this file to you under the Apache
15 : : * License, Version 2.0 (the "License"); you may not use this file
16 : : * except in compliance with the License. You may obtain a copy of
17 : : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : : */
19 : :
20 : : #ifndef _SVBORDER_HXX
21 : : #define _SVBORDER_HXX
22 : :
23 : : #include "tools/toolsdllapi.h"
24 : : #include <tools/gen.hxx>
25 : :
26 : : class TOOLS_DLLPUBLIC SvBorder
27 : : {
28 : : long nTop, nRight, nBottom, nLeft;
29 : :
30 : : public:
31 : : SvBorder()
32 : : { nTop = nRight = nBottom = nLeft = 0; }
33 : : SvBorder( const Size & rSz )
34 : : { nTop = nBottom = rSz.Height(); nRight = nLeft = rSz.Width(); }
35 : : SvBorder( long nLeftP, long nTopP, long nRightP, long nBottomP )
36 : : { nLeft = nLeftP; nTop = nTopP; nRight = nRightP; nBottom = nBottomP; }
37 : : sal_Bool operator == ( const SvBorder & rObj ) const
38 : : {
39 : : return nTop == rObj.nTop && nRight == rObj.nRight &&
40 : : nBottom == rObj.nBottom && nLeft == rObj.nLeft;
41 : : }
42 : : sal_Bool operator != ( const SvBorder & rObj ) const
43 : : { return !(*this == rObj); }
44 : : SvBorder & operator = ( const SvBorder & rBorder )
45 : : {
46 : : Left() = rBorder.Left();
47 : : Top() = rBorder.Top();
48 : : Right() = rBorder.Right();
49 : : Bottom() = rBorder.Bottom();
50 : : return *this;
51 : : }
52 : : SvBorder & operator += ( const SvBorder & rBorder )
53 : : {
54 : : Left() += rBorder.Left();
55 : : Top() += rBorder.Top();
56 : : Right() += rBorder.Right();
57 : : Bottom() += rBorder.Bottom();
58 : : return *this;
59 : : }
60 : : SvBorder & operator -= ( const SvBorder & rBorder )
61 : : {
62 : : Left() -= rBorder.Left();
63 : : Top() -= rBorder.Top();
64 : : Right() -= rBorder.Right();
65 : : Bottom() -= rBorder.Bottom();
66 : : return *this;
67 : : }
68 : : sal_Bool IsInside( const SvBorder & rInside )
69 : : {
70 : : return nTop >= rInside.nTop && nRight >= rInside.nRight &&
71 : : nBottom >= rInside.nBottom && nLeft >= rInside.nLeft;
72 : : }
73 : : long & Top() { return nTop; }
74 : : long & Right() { return nRight; }
75 : : long & Bottom() { return nBottom; }
76 : : long & Left() { return nLeft; }
77 : 0 : long Top() const { return nTop; }
78 : 0 : long Right() const { return nRight; }
79 : 0 : long Bottom() const { return nBottom; }
80 : 0 : long Left() const { return nLeft; }
81 : : };
82 : :
83 : : TOOLS_DLLPUBLIC Rectangle & operator += ( Rectangle & rRect, const SvBorder & rBorder );
84 : : TOOLS_DLLPUBLIC Rectangle & operator -= ( Rectangle & rRect, const SvBorder & rBorder );
85 : :
86 : : #endif
87 : :
88 : : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|