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.hxx>
24 #include <vcl/window.hxx>
25 #include <o3tl/typed_flags_set.hxx>
27 #include <com/sun/star/frame/XFrame.hpp>
29 class ImplBorderWindowView
;
30 enum class DrawButtonFlags
;
32 enum class BorderWindowStyle
{
41 template<> struct typed_flags
<BorderWindowStyle
> : is_typed_flags
<BorderWindowStyle
, 0x001f> {};
44 enum class BorderWindowHitTest
{
64 template<> struct typed_flags
<BorderWindowHitTest
> : is_typed_flags
<BorderWindowHitTest
, 0xffff> {};
67 enum class BorderWindowTitleType
{
75 template<> struct typed_flags
<BorderWindowTitleType
> : is_typed_flags
<BorderWindowTitleType
, 0x001f> {};
78 class ImplBorderWindow
: public vcl::Window
80 friend class vcl::Window
;
81 friend class ImplBorderWindowView
;
82 friend class ImplSmallBorderWindowView
;
83 friend class ImplStdBorderWindowView
;
86 ImplBorderWindowView
* mpBorderView
;
87 VclPtr
<vcl::Window
> mpMenuBarWindow
;
88 VclPtr
<NotebookBar
> mpNotebookBar
;
95 BorderWindowTitleType mnTitleType
;
96 WindowBorderStyle mnBorderStyle
;
98 bool mbSmallOutBorder
;
106 bool mbDisplayActive
;
108 using Window::ImplInit
;
109 void ImplInit( vcl::Window
* pParent
,
110 WinBits nStyle
, BorderWindowStyle nTypeStyle
,
111 SystemParentData
* pParentData
);
113 ImplBorderWindow (const ImplBorderWindow
&) = delete;
114 ImplBorderWindow
& operator= (const ImplBorderWindow
&) = delete;
117 ImplBorderWindow( vcl::Window
* pParent
,
118 SystemParentData
* pParentData
,
120 BorderWindowStyle nTypeStyle
);
121 ImplBorderWindow( vcl::Window
* pParent
, WinBits nStyle
,
122 BorderWindowStyle nTypeStyle
);
123 virtual ~ImplBorderWindow() override
;
124 virtual void dispose() override
;
126 virtual void MouseMove( const MouseEvent
& rMEvt
) override
;
127 virtual void MouseButtonDown( const MouseEvent
& rMEvt
) override
;
128 virtual void Tracking( const TrackingEvent
& rTEvt
) override
;
129 virtual void Paint( vcl::RenderContext
& rRenderContext
, const Rectangle
& rRect
) override
;
130 virtual void Activate() override
;
131 virtual void Deactivate() override
;
132 virtual void Resize() override
;
133 virtual void RequestHelp( const HelpEvent
& rHEvt
) override
;
134 virtual void StateChanged( StateChangedType nType
) override
;
135 virtual void DataChanged( const DataChangedEvent
& rDCEvt
) override
;
136 virtual void queue_resize(StateChangedType eReason
= StateChangedType::Layout
) override
;
139 void UpdateView( bool bNewView
, const Size
& rNewOutSize
);
140 void InvalidateBorder();
143 void Draw( const Rectangle
& rRect
, OutputDevice
* pDev
, const Point
& rPos
);
145 void SetDisplayActive( bool bActive
);
146 void SetTitleType( BorderWindowTitleType nTitleType
, const Size
& rSize
);
147 void SetBorderStyle( WindowBorderStyle nStyle
);
148 WindowBorderStyle
GetBorderStyle() const { return mnBorderStyle
; }
149 void SetPin( bool bPin
);
150 void SetRollUp( bool bRollUp
, const Size
& rSize
);
151 void SetCloseButton();
152 void SetDockButton( bool bDockButton
);
153 void SetHideButton( bool bHideButton
);
154 void SetMenuButton( bool bMenuButton
);
156 void UpdateMenuHeight();
157 void SetMenuBarWindow( vcl::Window
* pWindow
);
158 void SetMenuBarMode( bool bHide
);
160 void SetNotebookBar(const OUString
& rUIXMLDescription
, const css::uno::Reference
<css::frame::XFrame
>& rFrame
);
161 void CloseNotebookBar();
162 const VclPtr
<NotebookBar
>& GetNotebookBar() const { return mpNotebookBar
; }
164 void SetMinOutputSize( long nWidth
, long nHeight
)
165 { mnMinWidth
= nWidth
; mnMinHeight
= nHeight
; }
166 void SetMaxOutputSize( long nWidth
, long nHeight
)
167 { mnMaxWidth
= nWidth
; mnMaxHeight
= nHeight
; }
169 void GetBorder( sal_Int32
& rLeftBorder
, sal_Int32
& rTopBorder
,
170 sal_Int32
& rRightBorder
, sal_Int32
& rBottomBorder
) const;
171 long CalcTitleWidth() const;
173 Rectangle
GetMenuRect() const;
175 virtual Size
GetOptimalSize() const override
;
178 struct ImplBorderFrameData
180 VclPtr
<ImplBorderWindow
> mpBorderWindow
;
181 VclPtr
<OutputDevice
> mpOutDev
;
182 Rectangle maTitleRect
;
184 Rectangle maCloseRect
;
185 Rectangle maRollRect
;
186 Rectangle maDockRect
;
187 Rectangle maMenuRect
;
188 Rectangle maHideRect
;
189 Rectangle maHelpRect
;
197 sal_Int32 mnLeftBorder
;
198 sal_Int32 mnTopBorder
;
199 sal_Int32 mnRightBorder
;
200 sal_Int32 mnBottomBorder
;
204 BorderWindowHitTest mnHitTest
;
205 DrawButtonFlags mnPinState
;
206 DrawButtonFlags mnCloseState
;
207 DrawButtonFlags mnRollState
;
208 DrawButtonFlags mnDockState
;
209 DrawButtonFlags mnMenuState
;
210 DrawButtonFlags mnHideState
;
211 DrawButtonFlags mnHelpState
;
212 BorderWindowTitleType mnTitleType
;
218 class ImplBorderWindowView
221 virtual ~ImplBorderWindowView();
223 virtual bool MouseMove( const MouseEvent
& rMEvt
);
224 virtual bool MouseButtonDown( const MouseEvent
& rMEvt
);
225 virtual bool Tracking( const TrackingEvent
& rTEvt
);
226 virtual OUString
RequestHelp( const Point
& rPos
, Rectangle
& rHelpRect
);
228 virtual void Init( OutputDevice
* pDev
, long nWidth
, long nHeight
) = 0;
229 virtual void GetBorder( sal_Int32
& rLeftBorder
, sal_Int32
& rTopBorder
,
230 sal_Int32
& rRightBorder
, sal_Int32
& rBottomBorder
) const = 0;
231 virtual long CalcTitleWidth() const = 0;
232 virtual void DrawWindow(vcl::RenderContext
& rRenderContext
, const Point
* pOffset
= nullptr) = 0;
233 virtual Rectangle
GetMenuRect() const;
235 static void ImplInitTitle( ImplBorderFrameData
* pData
);
236 static BorderWindowHitTest
ImplHitTest( ImplBorderFrameData
* pData
, const Point
& rPos
);
237 static bool ImplMouseMove( ImplBorderFrameData
* pData
, const MouseEvent
& rMEvt
);
238 static OUString
ImplRequestHelp( ImplBorderFrameData
* pData
, const Point
& rPos
, Rectangle
& rHelpRect
);
239 static long ImplCalcTitleWidth( const ImplBorderFrameData
* pData
);
242 class ImplNoBorderWindowView
: public ImplBorderWindowView
245 ImplNoBorderWindowView( ImplBorderWindow
* pBorderWindow
);
247 virtual void Init( OutputDevice
* pDev
, long nWidth
, long nHeight
) override
;
248 virtual void GetBorder( sal_Int32
& rLeftBorder
, sal_Int32
& rTopBorder
,
249 sal_Int32
& rRightBorder
, sal_Int32
& rBottomBorder
) const override
;
250 virtual long CalcTitleWidth() const override
;
251 virtual void DrawWindow(vcl::RenderContext
& rRenderContext
, const Point
* pOffset
= nullptr) override
;
254 class ImplSmallBorderWindowView
: public ImplBorderWindowView
256 VclPtr
<ImplBorderWindow
> mpBorderWindow
;
257 VclPtr
<OutputDevice
> mpOutDev
;
260 sal_Int32 mnLeftBorder
;
261 sal_Int32 mnTopBorder
;
262 sal_Int32 mnRightBorder
;
263 sal_Int32 mnBottomBorder
;
267 ImplSmallBorderWindowView( ImplBorderWindow
* pBorderWindow
);
269 virtual void Init( OutputDevice
* pOutDev
, long nWidth
, long nHeight
) override
;
270 virtual void GetBorder( sal_Int32
& rLeftBorder
, sal_Int32
& rTopBorder
,
271 sal_Int32
& rRightBorder
, sal_Int32
& rBottomBorder
) const override
;
272 virtual long CalcTitleWidth() const override
;
273 virtual void DrawWindow(vcl::RenderContext
& rRenderContext
, const Point
* pOffset
= nullptr) override
;
276 class ImplStdBorderWindowView
: public ImplBorderWindowView
278 ImplBorderFrameData maFrameData
;
279 VclPtr
<VirtualDevice
> mpATitleVirDev
;
280 VclPtr
<VirtualDevice
> mpDTitleVirDev
;
283 ImplStdBorderWindowView( ImplBorderWindow
* pBorderWindow
);
284 virtual ~ImplStdBorderWindowView() override
;
286 virtual bool MouseMove( const MouseEvent
& rMEvt
) override
;
287 virtual bool MouseButtonDown( const MouseEvent
& rMEvt
) override
;
288 virtual bool Tracking( const TrackingEvent
& rTEvt
) override
;
289 virtual OUString
RequestHelp( const Point
& rPos
, Rectangle
& rHelpRect
) override
;
290 virtual Rectangle
GetMenuRect() const override
;
292 virtual void Init( OutputDevice
* pDev
, long nWidth
, long nHeight
) override
;
293 virtual void GetBorder( sal_Int32
& rLeftBorder
, sal_Int32
& rTopBorder
,
294 sal_Int32
& rRightBorder
, sal_Int32
& rBottomBorder
) const override
;
295 virtual long CalcTitleWidth() const override
;
296 virtual void DrawWindow(vcl::RenderContext
& rRenderContext
, const Point
* pOffset
= nullptr) override
;
299 #endif // INCLUDED_VCL_INC_BRDWIN_HXX
301 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */