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
{
63 template<> struct typed_flags
<BorderWindowHitTest
> : is_typed_flags
<BorderWindowHitTest
, 0xffff> {};
66 enum class BorderWindowTitleType
{
74 template<> struct typed_flags
<BorderWindowTitleType
> : is_typed_flags
<BorderWindowTitleType
, 0x001f> {};
77 class ImplBorderWindow
: public vcl::Window
79 friend class vcl::Window
;
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
;
93 BorderWindowTitleType mnTitleType
;
94 WindowBorderStyle mnBorderStyle
;
96 bool mbSmallOutBorder
;
103 bool mbDisplayActive
;
105 using Window::ImplInit
;
106 void ImplInit( vcl::Window
* pParent
,
107 WinBits nStyle
, BorderWindowStyle nTypeStyle
,
108 SystemParentData
* pParentData
);
110 ImplBorderWindow (const ImplBorderWindow
&) = delete;
111 ImplBorderWindow
& operator= (const ImplBorderWindow
&) = delete;
114 ImplBorderWindow( vcl::Window
* pParent
,
115 SystemParentData
* pParentData
,
117 BorderWindowStyle nTypeStyle
);
118 ImplBorderWindow( vcl::Window
* pParent
, WinBits nStyle
,
119 BorderWindowStyle nTypeStyle
);
120 virtual ~ImplBorderWindow() override
;
121 virtual void dispose() override
;
123 virtual void MouseMove( const MouseEvent
& rMEvt
) override
;
124 virtual void MouseButtonDown( const MouseEvent
& rMEvt
) override
;
125 virtual void Tracking( const TrackingEvent
& rTEvt
) override
;
126 virtual void Paint( vcl::RenderContext
& rRenderContext
, const tools::Rectangle
& rRect
) override
;
127 virtual void Activate() override
;
128 virtual void Deactivate() override
;
129 virtual void Resize() override
;
130 virtual void RequestHelp( const HelpEvent
& rHEvt
) override
;
131 virtual void StateChanged( StateChangedType nType
) override
;
132 virtual void DataChanged( const DataChangedEvent
& rDCEvt
) override
;
133 virtual void queue_resize(StateChangedType eReason
= StateChangedType::Layout
) override
;
136 void UpdateView( bool bNewView
, const Size
& rNewOutSize
);
137 void InvalidateBorder();
140 void Draw( OutputDevice
* pDev
, const Point
& rPos
);
142 void SetDisplayActive( bool bActive
);
143 void SetTitleType( BorderWindowTitleType nTitleType
, const Size
& rSize
);
144 void SetBorderStyle( WindowBorderStyle nStyle
);
145 WindowBorderStyle
GetBorderStyle() const { return mnBorderStyle
; }
146 void SetRollUp( bool bRollUp
, const Size
& rSize
);
147 void SetCloseButton();
148 void SetDockButton( bool bDockButton
);
149 void SetHideButton( bool bHideButton
);
150 void SetMenuButton( bool bMenuButton
);
152 void UpdateMenuHeight();
153 void SetMenuBarWindow( vcl::Window
* pWindow
);
154 void SetMenuBarMode( bool bHide
);
156 void SetNotebookBar(const OUString
& rUIXMLDescription
, const css::uno::Reference
<css::frame::XFrame
>& rFrame
);
157 void CloseNotebookBar();
158 const VclPtr
<NotebookBar
>& GetNotebookBar() const { return mpNotebookBar
; }
160 void SetMinOutputSize( long nWidth
, long nHeight
)
161 { mnMinWidth
= nWidth
; mnMinHeight
= nHeight
; }
162 void SetMaxOutputSize( long nWidth
, 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 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 maRollRect
;
181 tools::Rectangle maDockRect
;
182 tools::Rectangle maMenuRect
;
183 tools::Rectangle maHideRect
;
184 tools::Rectangle maHelpRect
;
192 sal_Int32 mnLeftBorder
;
193 sal_Int32 mnTopBorder
;
194 sal_Int32 mnRightBorder
;
195 sal_Int32 mnBottomBorder
;
199 BorderWindowHitTest mnHitTest
;
200 DrawButtonFlags mnCloseState
;
201 DrawButtonFlags mnRollState
;
202 DrawButtonFlags mnDockState
;
203 DrawButtonFlags mnMenuState
;
204 DrawButtonFlags mnHideState
;
205 DrawButtonFlags mnHelpState
;
206 BorderWindowTitleType mnTitleType
;
211 class ImplBorderWindowView
214 virtual ~ImplBorderWindowView();
216 virtual bool MouseMove( const MouseEvent
& rMEvt
);
217 virtual bool MouseButtonDown( const MouseEvent
& rMEvt
);
218 virtual bool Tracking( const TrackingEvent
& rTEvt
);
219 virtual OUString
RequestHelp( const Point
& rPos
, tools::Rectangle
& rHelpRect
);
221 virtual void Init( OutputDevice
* pDev
, long nWidth
, long nHeight
) = 0;
222 virtual void GetBorder( sal_Int32
& rLeftBorder
, sal_Int32
& rTopBorder
,
223 sal_Int32
& rRightBorder
, sal_Int32
& rBottomBorder
) const = 0;
224 virtual long CalcTitleWidth() const = 0;
225 virtual void DrawWindow(vcl::RenderContext
& rRenderContext
, const Point
* pOffset
= nullptr) = 0;
226 virtual tools::Rectangle
GetMenuRect() const;
228 static void ImplInitTitle( ImplBorderFrameData
* pData
);
229 static BorderWindowHitTest
ImplHitTest( ImplBorderFrameData
const * pData
, const Point
& rPos
);
230 static void ImplMouseMove( ImplBorderFrameData
* pData
, const MouseEvent
& rMEvt
);
231 static OUString
ImplRequestHelp( ImplBorderFrameData
const * pData
, const Point
& rPos
, tools::Rectangle
& rHelpRect
);
232 static long ImplCalcTitleWidth( const ImplBorderFrameData
* pData
);
235 class ImplNoBorderWindowView
: public ImplBorderWindowView
238 ImplNoBorderWindowView();
240 virtual void Init( OutputDevice
* pDev
, long nWidth
, long nHeight
) override
;
241 virtual void GetBorder( sal_Int32
& rLeftBorder
, sal_Int32
& rTopBorder
,
242 sal_Int32
& rRightBorder
, sal_Int32
& rBottomBorder
) const override
;
243 virtual long CalcTitleWidth() const override
;
244 virtual void DrawWindow(vcl::RenderContext
& rRenderContext
, const Point
* pOffset
= nullptr) override
;
247 class ImplSmallBorderWindowView
: public ImplBorderWindowView
249 VclPtr
<ImplBorderWindow
> mpBorderWindow
;
250 VclPtr
<OutputDevice
> mpOutDev
;
253 sal_Int32 mnLeftBorder
;
254 sal_Int32 mnTopBorder
;
255 sal_Int32 mnRightBorder
;
256 sal_Int32 mnBottomBorder
;
260 ImplSmallBorderWindowView( ImplBorderWindow
* pBorderWindow
);
262 virtual void Init( OutputDevice
* pOutDev
, long nWidth
, long nHeight
) override
;
263 virtual void GetBorder( sal_Int32
& rLeftBorder
, sal_Int32
& rTopBorder
,
264 sal_Int32
& rRightBorder
, sal_Int32
& rBottomBorder
) const override
;
265 virtual long CalcTitleWidth() const override
;
266 virtual void DrawWindow(vcl::RenderContext
& rRenderContext
, const Point
* pOffset
= nullptr) override
;
269 class ImplStdBorderWindowView
: public ImplBorderWindowView
271 ImplBorderFrameData maFrameData
;
274 ImplStdBorderWindowView( ImplBorderWindow
* pBorderWindow
);
275 virtual ~ImplStdBorderWindowView() override
;
277 virtual bool MouseMove( const MouseEvent
& rMEvt
) override
;
278 virtual bool MouseButtonDown( const MouseEvent
& rMEvt
) override
;
279 virtual bool Tracking( const TrackingEvent
& rTEvt
) override
;
280 virtual OUString
RequestHelp( const Point
& rPos
, tools::Rectangle
& rHelpRect
) override
;
281 virtual tools::Rectangle
GetMenuRect() const override
;
283 virtual void Init( OutputDevice
* pDev
, long nWidth
, long nHeight
) override
;
284 virtual void GetBorder( sal_Int32
& rLeftBorder
, sal_Int32
& rTopBorder
,
285 sal_Int32
& rRightBorder
, sal_Int32
& rBottomBorder
) const override
;
286 virtual long CalcTitleWidth() const override
;
287 virtual void DrawWindow(vcl::RenderContext
& rRenderContext
, const Point
* pOffset
= nullptr) override
;
290 #endif // INCLUDED_VCL_INC_BRDWIN_HXX
292 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */