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_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
{
41 template<> struct typed_flags
<BorderWindowStyle
> : is_typed_flags
<BorderWindowStyle
, 0x001d> {};
44 enum class BorderWindowHitTest
{
62 template<> struct typed_flags
<BorderWindowHitTest
> : is_typed_flags
<BorderWindowHitTest
, 0x3fff> {};
65 enum class BorderWindowTitleType
{
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
;
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
;
96 bool mbSmallOutBorder
;
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;
113 ImplBorderWindow( vcl::Window
* pParent
,
114 SystemParentData
* pParentData
,
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
;
135 void UpdateView( bool bNewView
, const Size
& rNewOutSize
);
136 void InvalidateBorder();
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
;
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
;
209 class ImplBorderWindowView
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
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
;
250 tools::Long mnHeight
;
251 sal_Int32 mnLeftBorder
;
252 sal_Int32 mnTopBorder
;
253 sal_Int32 mnRightBorder
;
254 sal_Int32 mnBottomBorder
;
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
;
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: */