Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / vcl / inc / brdwin.hxx
blobab9c965202a9e165b03c5c89e39c3c70c364ea91
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.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 {
33 NONE = 0x0000,
34 Overlap = 0x0001,
35 Border = 0x0002,
36 Float = 0x0004,
37 Frame = 0x0008,
38 App = 0x0010
40 namespace o3tl {
41 template<> struct typed_flags<BorderWindowStyle> : is_typed_flags<BorderWindowStyle, 0x001f> {};
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 Roll = 0x0800,
58 Dock = 0x1000,
59 Hide = 0x2000,
60 Help = 0x4000,
62 namespace o3tl {
63 template<> struct typed_flags<BorderWindowHitTest> : is_typed_flags<BorderWindowHitTest, 0xffff> {};
66 enum class BorderWindowTitleType {
67 Normal = 0x0001,
68 Small = 0x0002,
69 Tearoff = 0x0004,
70 Popup = 0x0008,
71 NONE = 0x0010
73 namespace o3tl {
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;
84 private:
85 ImplBorderWindowView* mpBorderView;
86 VclPtr<vcl::Window> mpMenuBarWindow;
87 VclPtr<NotebookBar> mpNotebookBar;
88 long mnMinWidth;
89 long mnMinHeight;
90 long mnMaxWidth;
91 long mnMaxHeight;
92 long mnRollHeight;
93 long mnOrgMenuHeight;
94 BorderWindowTitleType mnTitleType;
95 WindowBorderStyle mnBorderStyle;
96 bool mbFloatWindow;
97 bool mbSmallOutBorder;
98 bool mbFrameBorder;
99 bool mbRollUp;
100 bool mbMenuHide;
101 bool mbDockBtn;
102 bool mbHideBtn;
103 bool mbMenuBtn;
104 bool mbDisplayActive;
106 using Window::ImplInit;
107 void ImplInit( vcl::Window* pParent,
108 WinBits nStyle, BorderWindowStyle nTypeStyle,
109 SystemParentData* pParentData );
111 ImplBorderWindow (const ImplBorderWindow &) = delete;
112 ImplBorderWindow& operator= (const ImplBorderWindow &) = delete;
114 public:
115 ImplBorderWindow( vcl::Window* pParent,
116 SystemParentData* pParentData,
117 WinBits nStyle,
118 BorderWindowStyle nTypeStyle );
119 ImplBorderWindow( vcl::Window* pParent, WinBits nStyle,
120 BorderWindowStyle nTypeStyle );
121 virtual ~ImplBorderWindow() override;
122 virtual void dispose() override;
124 virtual void MouseMove( const MouseEvent& rMEvt ) override;
125 virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
126 virtual void Tracking( const TrackingEvent& rTEvt ) override;
127 virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
128 virtual void Activate() override;
129 virtual void Deactivate() override;
130 virtual void Resize() override;
131 virtual void RequestHelp( const HelpEvent& rHEvt ) override;
132 virtual void StateChanged( StateChangedType nType ) override;
133 virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
134 virtual void queue_resize(StateChangedType eReason = StateChangedType::Layout) override;
136 void InitView();
137 void UpdateView( bool bNewView, const Size& rNewOutSize );
138 void InvalidateBorder();
140 using Window::Draw;
141 void Draw( OutputDevice* pDev, const Point& rPos );
143 void SetDisplayActive( bool bActive );
144 void SetTitleType( BorderWindowTitleType nTitleType, const Size& rSize );
145 void SetBorderStyle( WindowBorderStyle nStyle );
146 WindowBorderStyle GetBorderStyle() const { return mnBorderStyle; }
147 void SetRollUp( bool bRollUp, const Size& rSize );
148 void SetCloseButton();
149 void SetDockButton( bool bDockButton );
150 void SetHideButton( bool bHideButton );
151 void SetMenuButton( bool bMenuButton );
153 void UpdateMenuHeight();
154 void SetMenuBarWindow( vcl::Window* pWindow );
155 void SetMenuBarMode( bool bHide );
157 void SetNotebookBar(const OUString& rUIXMLDescription, const css::uno::Reference<css::frame::XFrame>& rFrame);
158 void CloseNotebookBar();
159 const VclPtr<NotebookBar>& GetNotebookBar() const { return mpNotebookBar; }
161 void SetMinOutputSize( long nWidth, long nHeight )
162 { mnMinWidth = nWidth; mnMinHeight = nHeight; }
163 void SetMaxOutputSize( long nWidth, long nHeight )
164 { mnMaxWidth = nWidth; mnMaxHeight = nHeight; }
166 void GetBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder,
167 sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const;
168 long CalcTitleWidth() const;
170 tools::Rectangle GetMenuRect() const;
172 virtual Size GetOptimalSize() const override;
175 struct ImplBorderFrameData
177 VclPtr<ImplBorderWindow> mpBorderWindow;
178 VclPtr<OutputDevice> mpOutDev;
179 tools::Rectangle maTitleRect;
180 tools::Rectangle maCloseRect;
181 tools::Rectangle maRollRect;
182 tools::Rectangle maDockRect;
183 tools::Rectangle maMenuRect;
184 tools::Rectangle maHideRect;
185 tools::Rectangle maHelpRect;
186 Point maMouseOff;
187 long mnWidth;
188 long mnHeight;
189 long mnTrackX;
190 long mnTrackY;
191 long mnTrackWidth;
192 long mnTrackHeight;
193 sal_Int32 mnLeftBorder;
194 sal_Int32 mnTopBorder;
195 sal_Int32 mnRightBorder;
196 sal_Int32 mnBottomBorder;
197 long mnNoTitleTop;
198 long mnBorderSize;
199 long mnTitleHeight;
200 BorderWindowHitTest mnHitTest;
201 DrawButtonFlags mnCloseState;
202 DrawButtonFlags mnRollState;
203 DrawButtonFlags mnDockState;
204 DrawButtonFlags mnMenuState;
205 DrawButtonFlags mnHideState;
206 DrawButtonFlags mnHelpState;
207 BorderWindowTitleType mnTitleType;
208 bool mbFloatWindow;
209 bool mbDragFull;
210 bool mbTitleClipped;
213 class ImplBorderWindowView
215 public:
216 virtual ~ImplBorderWindowView();
218 virtual bool MouseMove( const MouseEvent& rMEvt );
219 virtual bool MouseButtonDown( const MouseEvent& rMEvt );
220 virtual bool Tracking( const TrackingEvent& rTEvt );
221 virtual OUString RequestHelp( const Point& rPos, tools::Rectangle& rHelpRect );
223 virtual void Init( OutputDevice* pDev, long nWidth, long nHeight ) = 0;
224 virtual void GetBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder,
225 sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const = 0;
226 virtual long CalcTitleWidth() const = 0;
227 virtual void DrawWindow(vcl::RenderContext& rRenderContext, const Point* pOffset = nullptr) = 0;
228 virtual tools::Rectangle GetMenuRect() const;
230 static void ImplInitTitle( ImplBorderFrameData* pData );
231 static BorderWindowHitTest ImplHitTest( ImplBorderFrameData* pData, const Point& rPos );
232 static bool ImplMouseMove( ImplBorderFrameData* pData, const MouseEvent& rMEvt );
233 static OUString ImplRequestHelp( ImplBorderFrameData* pData, const Point& rPos, tools::Rectangle& rHelpRect );
234 static long ImplCalcTitleWidth( const ImplBorderFrameData* pData );
237 class ImplNoBorderWindowView : public ImplBorderWindowView
239 public:
240 ImplNoBorderWindowView();
242 virtual void Init( OutputDevice* pDev, long nWidth, long nHeight ) override;
243 virtual void GetBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder,
244 sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const override;
245 virtual long CalcTitleWidth() const override;
246 virtual void DrawWindow(vcl::RenderContext& rRenderContext, const Point* pOffset = nullptr) override;
249 class ImplSmallBorderWindowView : public ImplBorderWindowView
251 VclPtr<ImplBorderWindow> mpBorderWindow;
252 VclPtr<OutputDevice> mpOutDev;
253 long mnWidth;
254 long mnHeight;
255 sal_Int32 mnLeftBorder;
256 sal_Int32 mnTopBorder;
257 sal_Int32 mnRightBorder;
258 sal_Int32 mnBottomBorder;
259 bool mbNWFBorder;
261 public:
262 ImplSmallBorderWindowView( ImplBorderWindow* pBorderWindow );
264 virtual void Init( OutputDevice* pOutDev, long nWidth, long nHeight ) override;
265 virtual void GetBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder,
266 sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const override;
267 virtual long CalcTitleWidth() const override;
268 virtual void DrawWindow(vcl::RenderContext& rRenderContext, const Point* pOffset = nullptr) override;
271 class ImplStdBorderWindowView : public ImplBorderWindowView
273 ImplBorderFrameData maFrameData;
274 VclPtr<VirtualDevice> mpATitleVirDev;
275 VclPtr<VirtualDevice> mpDTitleVirDev;
277 public:
278 ImplStdBorderWindowView( ImplBorderWindow* pBorderWindow );
279 virtual ~ImplStdBorderWindowView() override;
281 virtual bool MouseMove( const MouseEvent& rMEvt ) override;
282 virtual bool MouseButtonDown( const MouseEvent& rMEvt ) override;
283 virtual bool Tracking( const TrackingEvent& rTEvt ) override;
284 virtual OUString RequestHelp( const Point& rPos, tools::Rectangle& rHelpRect ) override;
285 virtual tools::Rectangle GetMenuRect() const override;
287 virtual void Init( OutputDevice* pDev, long nWidth, long nHeight ) override;
288 virtual void GetBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder,
289 sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const override;
290 virtual long CalcTitleWidth() const override;
291 virtual void DrawWindow(vcl::RenderContext& rRenderContext, const Point* pOffset = nullptr) override;
294 #endif // INCLUDED_VCL_INC_BRDWIN_HXX
296 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */