LibreOffice Module vcl (master)  1
salgeom.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_INC_SALGEOM_HXX
21 #define INCLUDED_VCL_INC_SALGEOM_HXX
22 
23 #include <iostream>
24 
25 #include <vcl/dllapi.h>
26 #include <vcl/WindowPosSize.hxx>
27 #include <tools/long.hxx>
28 
29 // There are some unused functions, which I would keep to ease understanding.
31 {
32  // non-drawable area / margins / frame / decorations around the client area
34  unsigned int m_nDisplayScreenNumber;
35 
36 public:
38  : m_nLeftDecoration(0)
39  , m_nTopDecoration(0)
40  , m_nRightDecoration(0)
41  , m_nBottomDecoration(0)
42  , m_nDisplayScreenNumber(0)
43  {
44  }
45 
46  constexpr tools::Rectangle clientArea() const
47  {
48  tools::Long nX(x() + m_nLeftDecoration), nY(y() + m_nTopDecoration);
49  return { { nX, nY }, size() };
50  }
51  void setClientArea(const tools::Rectangle& rRect)
52  {
53  setX(rRect.getX() - m_nLeftDecoration);
54  setY(rRect.getY() - m_nTopDecoration);
55  setSize(rRect.GetSize());
56  }
57  constexpr tools::Rectangle clientRect() const { return { { 0, 0 }, size() }; }
58 
59  // returns the position and size of the window, including all margins
60  constexpr tools::Rectangle frameArea() const
61  {
62  tools::Long nWidth(width() + m_nLeftDecoration + m_nRightDecoration);
63  tools::Long nHeight(height() + m_nTopDecoration + m_nBottomDecoration);
64  return { pos(), Size(nWidth, nHeight) };
65  }
66  // no setFrameArea, as it can't really be implemented, e.g. what happens, if size() > frameArea.size() etc.
67 
68  constexpr sal_uInt32 leftDecoration() const { return m_nLeftDecoration; }
69  void setLeftDecoration(sal_uInt32 nLeftDecoration) { m_nLeftDecoration = nLeftDecoration; }
70  constexpr sal_uInt32 topDecoration() const { return m_nTopDecoration; }
71  void setTopDecoration(sal_uInt32 nTopDecoration) { m_nTopDecoration = nTopDecoration; }
72  constexpr sal_uInt32 rightDecoration() const { return m_nRightDecoration; }
73  void setRightDecoration(sal_uInt32 nRightDecoration) { m_nRightDecoration = nRightDecoration; }
74  constexpr sal_uInt32 bottomDecoration() const { return m_nBottomDecoration; }
75  void setBottomDecoration(sal_uInt32 nBottomDecoration)
76  {
77  m_nBottomDecoration = nBottomDecoration;
78  }
79  void decorations(sal_uInt32& nLeft, sal_uInt32& nTop, sal_uInt32& nRight,
80  sal_uInt32& nBottom) const
81  {
82  nLeft = m_nLeftDecoration;
83  nTop = m_nTopDecoration;
84  nRight = m_nRightDecoration;
85  nBottom = m_nBottomDecoration;
86  }
87  void setDecorations(sal_uInt32 nLeft, sal_uInt32 nTop, sal_uInt32 nRight, sal_uInt32 nBottom)
88  {
89  m_nLeftDecoration = nLeft;
90  m_nTopDecoration = nTop;
91  m_nRightDecoration = nRight;
92  m_nBottomDecoration = nBottom;
93  }
94 
95  unsigned int screen() const { return m_nDisplayScreenNumber; }
96  void setScreen(unsigned int nScreen) { m_nDisplayScreenNumber = nScreen; }
97 };
98 
99 inline std::ostream& operator<<(std::ostream& s, const SalFrameGeometry& rGeom)
100 {
101  s << *static_cast<const vcl::WindowPosSize*>(&rGeom) << ":{" << rGeom.leftDecoration() << ","
102  << rGeom.topDecoration() << "," << rGeom.rightDecoration() << "," << rGeom.bottomDecoration()
103  << "}s" << rGeom.screen();
104  return s;
105 }
106 
110 {
111 public:
112  virtual ~SalGeometryProvider() {}
113  virtual tools::Long GetWidth() const = 0;
114  virtual tools::Long GetHeight() const = 0;
115  virtual bool IsOffScreen() const = 0;
116 };
117 
118 #endif // INCLUDED_VCL_INC_SALGEOM_HXX
119 
120 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Interface used to share logic on sizing between SalVirtualDevices and SalFrames.
Definition: salgeom.hxx:109
void setX(sal_Int32 nX)
constexpr Size size() const
constexpr sal_uInt32 bottomDecoration() const
Definition: salgeom.hxx:74
sal_uInt32 m_nLeftDecoration
Definition: salgeom.hxx:33
sal_uInt32 m_nTopDecoration
Definition: salgeom.hxx:33
void setRightDecoration(sal_uInt32 nRightDecoration)
Definition: salgeom.hxx:73
long Long
tools::Long getY() const
sal_uInt32 m_nRightDecoration
Definition: salgeom.hxx:33
void setLeftDecoration(sal_uInt32 nLeftDecoration)
Definition: salgeom.hxx:69
unsigned int screen() const
Definition: salgeom.hxx:95
constexpr sal_Int32 x() const
constexpr tools::Rectangle clientRect() const
Definition: salgeom.hxx:57
There are multiple ways to store the two different areas of a vcl::Window.
tools::Long getX() const
void decorations(sal_uInt32 &nLeft, sal_uInt32 &nTop, sal_uInt32 &nRight, sal_uInt32 &nBottom) const
Definition: salgeom.hxx:79
constexpr tools::Rectangle frameArea() const
Definition: salgeom.hxx:60
void setBottomDecoration(sal_uInt32 nBottomDecoration)
Definition: salgeom.hxx:75
constexpr tools::Rectangle clientArea() const
Definition: salgeom.hxx:46
void setTopDecoration(sal_uInt32 nTopDecoration)
Definition: salgeom.hxx:71
std::ostream & operator<<(std::ostream &s, const SalFrameGeometry &rGeom)
Definition: salgeom.hxx:99
constexpr sal_uInt32 rightDecoration() const
Definition: salgeom.hxx:72
void setSize(const Size &rSize)
constexpr sal_uInt32 topDecoration() const
Definition: salgeom.hxx:70
virtual ~SalGeometryProvider()
Definition: salgeom.hxx:112
#define VCL_PLUGIN_PUBLIC
Definition: dllapi.h:40
constexpr Size GetSize() const
void setY(sal_Int32 nY)
constexpr sal_uInt32 leftDecoration() const
Definition: salgeom.hxx:68
void setDecorations(sal_uInt32 nLeft, sal_uInt32 nTop, sal_uInt32 nRight, sal_uInt32 nBottom)
Definition: salgeom.hxx:87
constexpr sal_Int32 width() const
unsigned int m_nDisplayScreenNumber
Definition: salgeom.hxx:34
sal_uInt32 m_nBottomDecoration
Definition: salgeom.hxx:33
constexpr Point pos() const
constexpr sal_Int32 y() const
constexpr sal_Int32 height() const
void setScreen(unsigned int nScreen)
Definition: salgeom.hxx:96
void setClientArea(const tools::Rectangle &rRect)
Definition: salgeom.hxx:51