LibreOffice Module vcl (master) 1
windowstate.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_WINDOWSTATE_HXX
21#define INCLUDED_VCL_WINDOWSTATE_HXX
22
23#include <vcl/WindowPosSize.hxx>
24
25namespace vcl
26{
27enum class WindowState
28{
29 NONE = 0x0000,
30 Normal = 0x0001,
31 Minimized = 0x0002,
32 Maximized = 0x0004,
33 // Rollup is no longer used, but the bit is retained because WindowData is serialized
34 // from/to strings describing window state that are stored in a users config
35 // Rollup = 0x0008,
36 MaximizedHorz = 0x0010,
37 MaximizedVert = 0x0020,
38 FullScreen = 0x0040,
39 SystemMask = 0xffff
40};
41
43{
44 NONE = 0x0000,
45 X = 0x0001,
46 Y = 0x0002,
47 Width = 0x0004,
48 Height = 0x0008,
49 State = 0x0010,
50 Minimized = 0x0020,
51 MaximizedX = 0x0100,
52 MaximizedY = 0x0200,
53 MaximizedWidth = 0x0400,
54 MaximizedHeight = 0x0800,
55 Pos = X | Y,
56 Size = Width | Height,
57 PosSize = Pos | Size,
61};
62
64{
67
70 unsigned int mnMaximizedWidth;
71 unsigned int mnMaximizedHeight;
72
73public:
75 : m_nState(WindowState::NONE)
76 , m_nMask(WindowDataMask::NONE)
77 , mnMaximizedX(0)
78 , mnMaximizedY(0)
79 , mnMaximizedWidth(0)
80 , mnMaximizedHeight(0)
81 {
82 }
83 WindowData(std::u16string_view rStr);
84
85 // serialize values to a string (the original WindowState representation)
86 OUString toStr() const;
87
88 void setState(WindowState nState) { m_nState = nState; }
89 WindowState state() const { return m_nState; }
90 WindowState& rState() { return m_nState; }
91
92 void setMask(WindowDataMask nMask) { m_nMask = nMask; }
93 WindowDataMask mask() const { return m_nMask; }
94 WindowDataMask& rMask() { return m_nMask; }
95
96 void SetMaximizedX(int nRX) { mnMaximizedX = nRX; }
97 int GetMaximizedX() const { return mnMaximizedX; }
98 void SetMaximizedY(int nRY) { mnMaximizedY = nRY; }
99 int GetMaximizedY() const { return mnMaximizedY; }
100 void SetMaximizedWidth(unsigned int nRWidth) { mnMaximizedWidth = nRWidth; }
101 unsigned int GetMaximizedWidth() const { return mnMaximizedWidth; }
102 void SetMaximizedHeight(unsigned int nRHeight) { mnMaximizedHeight = nRHeight; }
103 unsigned int GetMaximizedHeight() const { return mnMaximizedHeight; }
104};
105
106} // namespace vcl
107
108namespace o3tl
109{
110template <> struct typed_flags<vcl::WindowState> : is_typed_flags<vcl::WindowState, 0xffff>
111{
112};
113template <> struct typed_flags<vcl::WindowDataMask> : is_typed_flags<vcl::WindowDataMask, 0x0f3f>
114{
115};
116}
117
118namespace vcl
119{
120inline std::ostream& operator<<(std::ostream& s, const WindowData& rData)
121{
122 if (rData.mask() & WindowDataMask::Width)
123 s << rData.width() << "x";
124 else
125 s << "?x";
126 if (rData.mask() & WindowDataMask::Height)
127 s << rData.height() << "@(";
128 else
129 s << "?@(";
130 if (rData.mask() & WindowDataMask::X)
131 s << rData.x() << ",";
132 else
133 s << "?,";
134 if (rData.mask() & WindowDataMask::Y)
135 s << rData.y() << ")^";
136 else
137 s << "?)^";
138 if (rData.mask() & WindowDataMask::State)
139 s << "0x" << std::hex << static_cast<unsigned>(rData.state()) << std::dec;
140 else
141 s << "?";
142 return s;
143}
144
145} // namespace vcl
146
147#endif // INCLUDED_VCL_WINDOWSTATE_HXX
148
149/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void SetMaximizedX(int nRX)
Definition: windowstate.hxx:96
int GetMaximizedX() const
Definition: windowstate.hxx:97
WindowState m_nState
Definition: windowstate.hxx:65
int GetMaximizedY() const
Definition: windowstate.hxx:99
unsigned int GetMaximizedWidth() const
WindowDataMask m_nMask
Definition: windowstate.hxx:66
WindowDataMask & rMask()
Definition: windowstate.hxx:94
WindowState & rState()
Definition: windowstate.hxx:90
WindowState state() const
Definition: windowstate.hxx:89
void SetMaximizedY(int nRY)
Definition: windowstate.hxx:98
void SetMaximizedHeight(unsigned int nRHeight)
void setMask(WindowDataMask nMask)
Definition: windowstate.hxx:92
WindowDataMask mask() const
Definition: windowstate.hxx:93
unsigned int mnMaximizedHeight
Definition: windowstate.hxx:71
void SetMaximizedWidth(unsigned int nRWidth)
unsigned int mnMaximizedWidth
Definition: windowstate.hxx:70
unsigned int GetMaximizedHeight() const
void setState(WindowState nState)
Definition: windowstate.hxx:88
There are multiple ways to store the two different areas of a vcl::Window.
constexpr sal_Int32 height() const
constexpr sal_Int32 y() const
constexpr sal_Int32 x() const
constexpr sal_Int32 width() const
#define VCL_PLUGIN_PUBLIC
Definition: dllapi.h:40
sal_Int32 nState
NONE
std::basic_ostream< charT, traits > & operator<<(std::basic_ostream< charT, traits > &stream, const Region &rRegion)
Definition: region.hxx:136
WindowDataMask
Definition: windowstate.hxx:43
WindowState
Definition: windowstate.hxx:28
#define Y