1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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>
30 enum class WindowState
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
39 MaximizedHorz
= 0x0010,
40 MaximizedVert
= 0x0020,
45 enum class WindowDataMask
56 MaximizedWidth
= 0x0400,
57 MaximizedHeight
= 0x0800,
59 Size
= Width
| Height
,
61 PosSizeState
= Pos
| Size
| State
,
62 All
= X
| Y
| Width
| Height
| MaximizedX
| MaximizedY
| MaximizedWidth
| MaximizedHeight
66 class VCL_PLUGIN_PUBLIC WindowData final
: public WindowPosSize
69 WindowDataMask m_nMask
;
73 unsigned int mnMaximizedWidth
;
74 unsigned int mnMaximizedHeight
;
78 : m_nState(WindowState::NONE
)
79 , m_nMask(WindowDataMask::NONE
)
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
; }
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>
123 inline std::ostream
& operator<<(std::ostream
& s
, const WindowData
& rData
)
125 if (rData
.mask() & WindowDataMask::Width
)
126 s
<< rData
.width() << "x";
129 if (rData
.mask() & WindowDataMask::Height
)
130 s
<< rData
.height() << "@(";
133 if (rData
.mask() & WindowDataMask::X
)
134 s
<< rData
.x() << ",";
137 if (rData
.mask() & WindowDataMask::Y
)
138 s
<< rData
.y() << ")^";
141 if (rData
.mask() & WindowDataMask::State
)
142 s
<< "0x" << std::hex
<< static_cast<unsigned>(rData
.state()) << std::dec
;
150 #endif // INCLUDED_VCL_WINDOWSTATE_HXX
152 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */