build fix
[LibreOffice.git] / vcl / inc / brdwin.hxx
blob3e02d049bf5f84747a971dbdc00f323222babc47
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,
61 Pin = 0x8000
63 namespace o3tl {
64 template<> struct typed_flags<BorderWindowHitTest> : is_typed_flags<BorderWindowHitTest, 0xffff> {};
67 enum class BorderWindowTitleType {
68 Normal = 0x0001,
69 Small = 0x0002,
70 Tearoff = 0x0004,
71 Popup = 0x0008,
72 NONE = 0x0010
74 namespace o3tl {
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;
85 private:
86 ImplBorderWindowView* mpBorderView;
87 VclPtr<vcl::Window> mpMenuBarWindow;
88 VclPtr<NotebookBar> mpNotebookBar;
89 long mnMinWidth;
90 long mnMinHeight;
91 long mnMaxWidth;
92 long mnMaxHeight;
93 long mnRollHeight;
94 long mnOrgMenuHeight;
95 BorderWindowTitleType mnTitleType;
96 WindowBorderStyle mnBorderStyle;
97 bool mbFloatWindow;
98 bool mbSmallOutBorder;
99 bool mbFrameBorder;
100 bool mbPinned;
101 bool mbRollUp;
102 bool mbMenuHide;
103 bool mbDockBtn;
104 bool mbHideBtn;
105 bool mbMenuBtn;
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;
116 public:
117 ImplBorderWindow( vcl::Window* pParent,
118 SystemParentData* pParentData,
119 WinBits nStyle,
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;
138 void InitView();
139 void UpdateView( bool bNewView, const Size& rNewOutSize );
140 void InvalidateBorder();
142 using Window::Draw;
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;
183 Rectangle maPinRect;
184 Rectangle maCloseRect;
185 Rectangle maRollRect;
186 Rectangle maDockRect;
187 Rectangle maMenuRect;
188 Rectangle maHideRect;
189 Rectangle maHelpRect;
190 Point maMouseOff;
191 long mnWidth;
192 long mnHeight;
193 long mnTrackX;
194 long mnTrackY;
195 long mnTrackWidth;
196 long mnTrackHeight;
197 sal_Int32 mnLeftBorder;
198 sal_Int32 mnTopBorder;
199 sal_Int32 mnRightBorder;
200 sal_Int32 mnBottomBorder;
201 long mnNoTitleTop;
202 long mnBorderSize;
203 long mnTitleHeight;
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;
213 bool mbFloatWindow;
214 bool mbDragFull;
215 bool mbTitleClipped;
218 class ImplBorderWindowView
220 public:
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
244 public:
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;
258 long mnWidth;
259 long mnHeight;
260 sal_Int32 mnLeftBorder;
261 sal_Int32 mnTopBorder;
262 sal_Int32 mnRightBorder;
263 sal_Int32 mnBottomBorder;
264 bool mbNWFBorder;
266 public:
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;
282 public:
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: */