cid#1606940 Check of thread-shared field evades lock acquisition
[LibreOffice.git] / vcl / inc / brdwin.hxx
blobf9c8a8edb894f3b3b6679bb706be72acb42ba889
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_INC_BRDWIN_HXX
21 #define INCLUDED_VCL_INC_BRDWIN_HXX
23 #include <vcl/notebookbar/notebookbar.hxx>
24 #include <vcl/window.hxx>
25 #include <o3tl/typed_flags_set.hxx>
26 #include <vcl/notebookbar/NotebookBarAddonsMerger.hxx>
28 #include <com/sun/star/frame/XFrame.hpp>
30 class ImplBorderWindowView;
31 enum class DrawButtonFlags;
33 enum class BorderWindowStyle {
34 NONE = 0x0000,
35 Overlap = 0x0001,
36 Float = 0x0004,
37 Frame = 0x0008,
38 App = 0x0010
40 namespace o3tl {
41 template<> struct typed_flags<BorderWindowStyle> : is_typed_flags<BorderWindowStyle, 0x001d> {};
44 enum class BorderWindowHitTest {
45 NONE = 0x0000,
46 Title = 0x0001,
47 Left = 0x0002,
48 Menu = 0x0004,
49 Top = 0x0008,
50 Right = 0x0010,
51 Bottom = 0x0020,
52 TopLeft = 0x0040,
53 TopRight = 0x0080,
54 BottomLeft = 0x0100,
55 BottomRight = 0x0200,
56 Close = 0x0400,
57 Dock = 0x0800,
58 Hide = 0x1000,
59 Help = 0x2000,
61 namespace o3tl {
62 template<> struct typed_flags<BorderWindowHitTest> : is_typed_flags<BorderWindowHitTest, 0x3fff> {};
65 enum class BorderWindowTitleType {
66 Normal = 0x0001,
67 Small = 0x0002,
68 Tearoff = 0x0004,
69 Popup = 0x0008,
70 NONE = 0x0010
72 namespace o3tl {
73 template<> struct typed_flags<BorderWindowTitleType> : is_typed_flags<BorderWindowTitleType, 0x001f> {};
76 class ImplBorderWindow final : public vcl::Window
78 friend class vcl::Window;
79 friend class vcl::WindowOutputDevice;
80 friend class ImplBorderWindowView;
81 friend class ImplSmallBorderWindowView;
82 friend class ImplStdBorderWindowView;
84 private:
85 std::unique_ptr<ImplBorderWindowView> mpBorderView;
86 VclPtr<vcl::Window> mpMenuBarWindow;
87 VclPtr<NotebookBar> mpNotebookBar;
88 tools::Long mnMinWidth;
89 tools::Long mnMinHeight;
90 tools::Long mnMaxWidth;
91 tools::Long mnMaxHeight;
92 tools::Long mnOrgMenuHeight;
93 BorderWindowTitleType mnTitleType;
94 WindowBorderStyle mnBorderStyle;
95 bool mbFloatWindow;
96 bool mbSmallOutBorder;
97 bool mbFrameBorder;
98 bool mbMenuHide;
99 bool mbDockBtn;
100 bool mbHideBtn;
101 bool mbMenuBtn;
102 bool mbDisplayActive;
104 using Window::ImplInit;
105 void ImplInit( vcl::Window* pParent,
106 WinBits nStyle, BorderWindowStyle nTypeStyle,
107 SystemParentData* pParentData );
109 ImplBorderWindow (const ImplBorderWindow &) = delete;
110 ImplBorderWindow& operator= (const ImplBorderWindow &) = delete;
112 public:
113 ImplBorderWindow( vcl::Window* pParent,
114 SystemParentData* pParentData,
115 WinBits nStyle,
116 BorderWindowStyle nTypeStyle );
117 ImplBorderWindow( vcl::Window* pParent, WinBits nStyle,
118 BorderWindowStyle nTypeStyle );
119 virtual ~ImplBorderWindow() override;
120 virtual void dispose() override;
122 virtual void MouseMove( const MouseEvent& rMEvt ) override;
123 virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
124 virtual void Tracking( const TrackingEvent& rTEvt ) override;
125 virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
126 virtual void Activate() override;
127 virtual void Deactivate() override;
128 virtual void Resize() override;
129 virtual void RequestHelp( const HelpEvent& rHEvt ) override;
130 virtual void StateChanged( StateChangedType nType ) override;
131 virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
132 virtual void queue_resize(StateChangedType eReason = StateChangedType::Layout) override;
134 void InitView();
135 void UpdateView( bool bNewView, const Size& rNewOutSize );
136 void InvalidateBorder();
138 using Window::Draw;
139 void Draw( OutputDevice* pDev, const Point& rPos );
141 void SetDisplayActive( bool bActive );
142 void SetTitleType( BorderWindowTitleType nTitleType, const Size& rSize );
143 void SetBorderStyle( WindowBorderStyle nStyle );
144 WindowBorderStyle GetBorderStyle() const { return mnBorderStyle; }
145 void SetCloseButton();
146 void SetDockButton( bool bDockButton );
147 void SetHideButton( bool bHideButton );
148 void SetMenuButton( bool bMenuButton );
150 void UpdateMenuHeight();
151 void SetMenuBarWindow( vcl::Window* pWindow );
152 void SetMenuBarMode( bool bHide );
154 void SetNotebookBar(const OUString& rUIXMLDescription,
155 const css::uno::Reference<css::frame::XFrame>& rFrame,
156 const NotebookBarAddonsItem &aNotebookBarAddonsItem);
157 void CloseNotebookBar();
158 const VclPtr<NotebookBar>& GetNotebookBar() const { return mpNotebookBar; }
160 void SetMinOutputSize( tools::Long nWidth, tools::Long nHeight )
161 { mnMinWidth = nWidth; mnMinHeight = nHeight; }
162 void SetMaxOutputSize( tools::Long nWidth, tools::Long nHeight )
163 { mnMaxWidth = nWidth; mnMaxHeight = nHeight; }
165 void GetBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder,
166 sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const;
167 tools::Long CalcTitleWidth() const;
169 tools::Rectangle GetMenuRect() const;
171 virtual Size GetOptimalSize() const override;
174 struct ImplBorderFrameData
176 VclPtr<ImplBorderWindow> mpBorderWindow;
177 VclPtr<OutputDevice> mpOutDev;
178 tools::Rectangle maTitleRect;
179 tools::Rectangle maCloseRect;
180 tools::Rectangle maDockRect;
181 tools::Rectangle maMenuRect;
182 tools::Rectangle maHideRect;
183 tools::Rectangle maHelpRect;
184 Point maMouseOff;
185 tools::Long mnWidth;
186 tools::Long mnHeight;
187 tools::Long mnTrackX;
188 tools::Long mnTrackY;
189 tools::Long mnTrackWidth;
190 tools::Long mnTrackHeight;
191 sal_Int32 mnLeftBorder;
192 sal_Int32 mnTopBorder;
193 sal_Int32 mnRightBorder;
194 sal_Int32 mnBottomBorder;
195 tools::Long mnNoTitleTop;
196 tools::Long mnBorderSize;
197 tools::Long mnTitleHeight;
198 BorderWindowHitTest mnHitTest;
199 DrawButtonFlags mnCloseState;
200 DrawButtonFlags mnDockState;
201 DrawButtonFlags mnMenuState;
202 DrawButtonFlags mnHideState;
203 DrawButtonFlags mnHelpState;
204 BorderWindowTitleType mnTitleType;
205 bool mbDragFull;
206 bool mbTitleClipped;
209 class ImplBorderWindowView
211 public:
212 virtual ~ImplBorderWindowView();
214 virtual bool MouseMove( const MouseEvent& rMEvt );
215 virtual bool MouseButtonDown( const MouseEvent& rMEvt );
216 virtual bool Tracking( const TrackingEvent& rTEvt );
217 virtual OUString RequestHelp( const Point& rPos, tools::Rectangle& rHelpRect );
219 virtual void Init( OutputDevice* pDev, tools::Long nWidth, tools::Long nHeight ) = 0;
220 virtual void GetBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder,
221 sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const = 0;
222 virtual tools::Long CalcTitleWidth() const = 0;
223 virtual void DrawWindow(vcl::RenderContext& rRenderContext, const Point* pOffset = nullptr) = 0;
224 virtual tools::Rectangle GetMenuRect() const;
226 static void ImplInitTitle( ImplBorderFrameData* pData );
227 static BorderWindowHitTest ImplHitTest( ImplBorderFrameData const * pData, const Point& rPos );
228 static void ImplMouseMove( ImplBorderFrameData* pData, const MouseEvent& rMEvt );
229 static OUString ImplRequestHelp( ImplBorderFrameData const * pData, const Point& rPos, tools::Rectangle& rHelpRect );
230 static tools::Long ImplCalcTitleWidth( const ImplBorderFrameData* pData );
233 class ImplNoBorderWindowView final : public ImplBorderWindowView
235 public:
236 ImplNoBorderWindowView();
238 virtual void Init( OutputDevice* pDev, tools::Long nWidth, tools::Long nHeight ) override;
239 virtual void GetBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder,
240 sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const override;
241 virtual tools::Long CalcTitleWidth() const override;
242 virtual void DrawWindow(vcl::RenderContext& rRenderContext, const Point* pOffset = nullptr) override;
245 class ImplSmallBorderWindowView final : public ImplBorderWindowView
247 VclPtr<ImplBorderWindow> mpBorderWindow;
248 VclPtr<OutputDevice> mpOutDev;
249 tools::Long mnWidth;
250 tools::Long mnHeight;
251 sal_Int32 mnLeftBorder;
252 sal_Int32 mnTopBorder;
253 sal_Int32 mnRightBorder;
254 sal_Int32 mnBottomBorder;
255 bool mbNWFBorder;
257 public:
258 ImplSmallBorderWindowView( ImplBorderWindow* pBorderWindow );
260 virtual void Init( OutputDevice* pOutDev, tools::Long nWidth, tools::Long nHeight ) override;
261 virtual void GetBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder,
262 sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const override;
263 virtual tools::Long CalcTitleWidth() const override;
264 virtual void DrawWindow(vcl::RenderContext& rRenderContext, const Point* pOffset = nullptr) override;
267 class ImplStdBorderWindowView final : public ImplBorderWindowView
269 ImplBorderFrameData maFrameData;
271 public:
272 ImplStdBorderWindowView( ImplBorderWindow* pBorderWindow );
273 virtual ~ImplStdBorderWindowView() override;
275 virtual bool MouseMove( const MouseEvent& rMEvt ) override;
276 virtual bool MouseButtonDown( const MouseEvent& rMEvt ) override;
277 virtual bool Tracking( const TrackingEvent& rTEvt ) override;
278 virtual OUString RequestHelp( const Point& rPos, tools::Rectangle& rHelpRect ) override;
279 virtual tools::Rectangle GetMenuRect() const override;
281 virtual void Init( OutputDevice* pDev, tools::Long nWidth, tools::Long nHeight ) override;
282 virtual void GetBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder,
283 sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const override;
284 virtual tools::Long CalcTitleWidth() const override;
285 virtual void DrawWindow(vcl::RenderContext& rRenderContext, const Point* pOffset = nullptr) override;
288 #endif // INCLUDED_VCL_INC_BRDWIN_HXX
290 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */