LibreOffice Module vcl (master) 1
WindowPosSize.hxx
Go to the documentation of this file.
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 INCLUDED_VCL_FRAMEPOSSIZE_HXX
21#define INCLUDED_VCL_FRAMEPOSSIZE_HXX
22
23#include <vcl/dllapi.h>
25#include <rtl/string.hxx>
26#include <sal/types.h>
27#include <tools/gen.hxx>
28
29namespace vcl
30{
52{
53 // position of the window frames left-top corner
54 sal_Int32 m_nX;
55 sal_Int32 m_nY;
56 // size of the client / drawable area, i.e. without decorations / borders
57 sal_Int32 m_nWidth;
58 sal_Int32 m_nHeight;
59
60protected:
62 : m_nX(0)
63 , m_nY(0)
64 , m_nWidth(1)
65 , m_nHeight(1)
66 {
67 }
68
69public:
70 constexpr sal_Int32 x() const { return m_nX; }
71 void setX(sal_Int32 nX) { m_nX = nX; }
72 constexpr sal_Int32 y() const { return m_nY; }
73 void setY(sal_Int32 nY) { m_nY = nY; }
74
75 constexpr Point pos() const { return { m_nX, m_nY }; }
76 void setPos(const Point& aPos)
77 {
78 setX(aPos.getX());
79 setY(aPos.getY());
80 }
81 void move(sal_Int32 nDX, sal_Int32 nDY)
82 {
83 m_nX += nDX;
84 m_nY += nDY;
85 }
86
87 constexpr sal_Int32 width() const { return m_nWidth; }
88 void setWidth(sal_Int32 nWidth)
89 {
90 assert(nWidth >= 0);
91 if (nWidth >= 0)
92 m_nWidth = nWidth;
93 else
94 m_nWidth = 0;
95 }
96
97 constexpr sal_Int32 height() const { return m_nHeight; }
98 void setHeight(sal_Int32 nHeight)
99 {
100 assert(nHeight >= 0);
101 if (nHeight >= 0)
102 m_nHeight = nHeight;
103 else
104 m_nHeight = 0;
105 }
106
107 constexpr Size size() const
108 {
109 return { static_cast<tools::Long>(m_nWidth), static_cast<tools::Long>(m_nHeight) };
110 }
111 void setSize(const Size& rSize)
112 {
113 setWidth(rSize.Width());
114 setHeight(rSize.Height());
115 }
116
117 constexpr tools::Rectangle posSize() const { return { pos(), size() }; }
118 void setPosSize(const tools::Rectangle& rRect)
119 {
120 setPos(rRect.GetPos());
121 setSize(rRect.GetSize());
122 }
123 // because tools::Rectangle has the ambiguous (Point&, Point&) constructor, which we don't want here
124 void setPosSize(const Point& rPos, const Size& rSize) { setPosSize({ rPos, rSize }); }
125};
126
127inline std::ostream& operator<<(std::ostream& s, const WindowPosSize& rPosSize)
128{
129 s << rPosSize.width() << "x" << rPosSize.height() << "@(" << rPosSize.x() << "," << rPosSize.y()
130 << ")";
131 return s;
132}
133
134} // namespace vcl
135
136#endif // INCLUDED_VCL_FRAMEPOSSIZE_HXX
137
138/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
constexpr tools::Long getX() const
constexpr tools::Long getY() const
constexpr tools::Long Height() const
constexpr tools::Long Width() const
constexpr Size GetSize() const
constexpr Point GetPos() const
There are multiple ways to store the two different areas of a vcl::Window.
constexpr Point pos() const
constexpr sal_Int32 height() const
constexpr sal_Int32 y() const
constexpr Size size() const
void setX(sal_Int32 nX)
void setPos(const Point &aPos)
void setWidth(sal_Int32 nWidth)
void setPosSize(const tools::Rectangle &rRect)
constexpr sal_Int32 x() const
void setPosSize(const Point &rPos, const Size &rSize)
constexpr sal_Int32 width() const
void setY(sal_Int32 nY)
constexpr tools::Rectangle posSize() const
void setSize(const Size &rSize)
void move(sal_Int32 nDX, sal_Int32 nDY)
void setHeight(sal_Int32 nHeight)
#define VCL_PLUGIN_PUBLIC
Definition: dllapi.h:40
size
long Long
std::basic_ostream< charT, traits > & operator<<(std::basic_ostream< charT, traits > &stream, const Region &rRegion)
Definition: region.hxx:136
size_t pos