tdf#154285 Check upper bound of arguments in SbRtl_Minute function
[LibreOffice.git] / include / vcl / windowstate.hxx
blobfdae315f93249fafd08e705bd8275efb2b1ee205
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_VCL_WINDOWSTATE_HXX
21 #define INCLUDED_VCL_WINDOWSTATE_HXX
23 #include <o3tl/typed_flags_set.hxx>
24 #include <rtl/ustring.hxx>
25 #include <vcl/dllapi.h>
26 #include <vcl/WindowPosSize.hxx>
28 namespace vcl
30 enum class WindowState
32 NONE = 0x0000,
33 Normal = 0x0001,
34 Minimized = 0x0002,
35 Maximized = 0x0004,
36 // Rollup is no longer used, but the bit is retained because WindowData is serialized
37 // from/to strings describing window state that are stored in a users config
38 // Rollup = 0x0008,
39 MaximizedHorz = 0x0010,
40 MaximizedVert = 0x0020,
41 FullScreen = 0x0040,
42 SystemMask = 0xffff
45 enum class WindowDataMask
47 NONE = 0x0000,
48 X = 0x0001,
49 Y = 0x0002,
50 Width = 0x0004,
51 Height = 0x0008,
52 State = 0x0010,
53 Minimized = 0x0020,
54 MaximizedX = 0x0100,
55 MaximizedY = 0x0200,
56 MaximizedWidth = 0x0400,
57 MaximizedHeight = 0x0800,
58 Pos = X | Y,
59 Size = Width | Height,
60 PosSize = Pos | Size,
61 PosSizeState = Pos | Size | State,
62 All = X | Y | Width | Height | MaximizedX | MaximizedY | MaximizedWidth | MaximizedHeight
63 | State | Minimized
66 class VCL_PLUGIN_PUBLIC WindowData final : public WindowPosSize
68 WindowState m_nState;
69 WindowDataMask m_nMask;
71 int mnMaximizedX;
72 int mnMaximizedY;
73 unsigned int mnMaximizedWidth;
74 unsigned int mnMaximizedHeight;
76 public:
77 WindowData()
78 : m_nState(WindowState::NONE)
79 , m_nMask(WindowDataMask::NONE)
80 , mnMaximizedX(0)
81 , mnMaximizedY(0)
82 , mnMaximizedWidth(0)
83 , mnMaximizedHeight(0)
86 WindowData(std::u16string_view rStr);
88 // serialize values to a string (the original WindowState representation)
89 OUString toStr() const;
91 void setState(WindowState nState) { m_nState = nState; }
92 WindowState state() const { return m_nState; }
93 WindowState& rState() { return m_nState; }
95 void setMask(WindowDataMask nMask) { m_nMask = nMask; }
96 WindowDataMask mask() const { return m_nMask; }
97 WindowDataMask& rMask() { return m_nMask; }
99 void SetMaximizedX(int nRX) { mnMaximizedX = nRX; }
100 int GetMaximizedX() const { return mnMaximizedX; }
101 void SetMaximizedY(int nRY) { mnMaximizedY = nRY; }
102 int GetMaximizedY() const { return mnMaximizedY; }
103 void SetMaximizedWidth(unsigned int nRWidth) { mnMaximizedWidth = nRWidth; }
104 unsigned int GetMaximizedWidth() const { return mnMaximizedWidth; }
105 void SetMaximizedHeight(unsigned int nRHeight) { mnMaximizedHeight = nRHeight; }
106 unsigned int GetMaximizedHeight() const { return mnMaximizedHeight; }
109 } // namespace vcl
111 namespace o3tl
113 template <> struct typed_flags<vcl::WindowState> : is_typed_flags<vcl::WindowState, 0xffff>
116 template <> struct typed_flags<vcl::WindowDataMask> : is_typed_flags<vcl::WindowDataMask, 0x0f3f>
121 namespace vcl
123 inline std::ostream& operator<<(std::ostream& s, const WindowData& rData)
125 if (rData.mask() & WindowDataMask::Width)
126 s << rData.width() << "x";
127 else
128 s << "?x";
129 if (rData.mask() & WindowDataMask::Height)
130 s << rData.height() << "@(";
131 else
132 s << "?@(";
133 if (rData.mask() & WindowDataMask::X)
134 s << rData.x() << ",";
135 else
136 s << "?,";
137 if (rData.mask() & WindowDataMask::Y)
138 s << rData.y() << ")^";
139 else
140 s << "?)^";
141 if (rData.mask() & WindowDataMask::State)
142 s << "0x" << std::hex << static_cast<unsigned>(rData.state()) << std::dec;
143 else
144 s << "?";
145 return s;
148 } // namespace vcl
150 #endif // INCLUDED_VCL_WINDOWSTATE_HXX
152 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */