Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / include / vcl / floatwin.hxx
blobfc7df3ada4248dfb0448dd9dea2e72fe3ee3c94d
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_FLOATWIN_HXX
21 #define INCLUDED_VCL_FLOATWIN_HXX
23 #include <tools/solar.h>
24 #include <vcl/dllapi.h>
25 #include <vcl/syswin.hxx>
26 #include <o3tl/typed_flags_set.hxx>
28 class ToolBox;
31 enum class FloatWinPopupFlags
33 NONE = 0x000000,
34 AllowTearOff = 0x000001,
35 Down = 0x000002,
36 Up = 0x000004,
37 Left = 0x000008,
38 Right = 0x000010,
39 NoKeyClose = 0x000020,
40 AllMouseButtonClose = 0x000040,
41 NoAppFocusClose = 0x000080,
42 NewLevel = 0x000100,
43 NoMouseUpClose = 0x000200,
44 GrabFocus = 0x000400,
45 NoHorzPlacement = 0x000800,
47 namespace o3tl
49 template<> struct typed_flags<FloatWinPopupFlags> : is_typed_flags<FloatWinPopupFlags, 0x0fff> {};
52 enum class FloatWinPopupEndFlags
54 NONE = 0x00,
55 Cancel = 0x01,
56 TearOff = 0x02,
57 DontCallHdl = 0x04,
58 CloseAll = 0x08,
60 namespace o3tl
62 template<> struct typed_flags<FloatWinPopupEndFlags> : is_typed_flags<FloatWinPopupEndFlags, 0x0f> {};
65 enum class FloatWinTitleType
67 Unknown = 0,
68 Normal = 1,
69 TearOff = 2,
70 Popup = 3,
71 NONE = 4,
74 enum HitTest
76 HITTEST_OUTSIDE,
77 HITTEST_WINDOW,
78 HITTEST_RECT
82 class VCL_DLLPUBLIC FloatingWindow : public SystemWindow
84 class ImplData;
85 private:
86 VclPtr<FloatingWindow> mpNextFloat;
87 VclPtr<vcl::Window> mpFirstPopupModeWin;
88 VclPtr<vcl::Window> mxPrevFocusWin;
89 ImplData* mpImplData;
90 tools::Rectangle maFloatRect;
91 ImplSVEvent * mnPostId;
92 FloatWinPopupFlags mnPopupModeFlags;
93 FloatWinTitleType mnTitle;
94 FloatWinTitleType mnOldTitle;
95 bool mbInPopupMode;
96 bool mbPopupMode;
97 bool mbPopupModeCanceled;
98 bool mbPopupModeTearOff;
99 bool mbMouseDown;
100 bool mbGrabFocus; // act as key input window, although focus is not set
101 bool mbInCleanUp;
102 Link<FloatingWindow*,void> maPopupModeEndHdl;
104 SAL_DLLPRIVATE void ImplCallPopupModeEnd();
105 DECL_DLLPRIVATE_LINK( ImplEndPopupModeHdl, void*, void );
107 FloatingWindow (const FloatingWindow &) = delete;
108 FloatingWindow & operator= (const FloatingWindow &) = delete;
110 protected:
111 using Window::ImplInit;
112 SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle );
113 SAL_DLLPRIVATE void ImplInitSettings();
115 virtual void ApplySettings(vcl::RenderContext& rRenderContext) override;
117 public:
118 SAL_DLLPRIVATE FloatingWindow* ImplFloatHitTest( vcl::Window* pReference, const Point& rPos, HitTest& rHitTest );
119 SAL_DLLPRIVATE FloatingWindow* ImplFindLastLevelFloat();
120 SAL_DLLPRIVATE bool ImplIsFloatPopupModeWindow( const vcl::Window* pWindow );
121 SAL_DLLPRIVATE void ImplSetMouseDown() { mbMouseDown = true; }
122 SAL_DLLPRIVATE bool ImplIsMouseDown() const { return mbMouseDown; }
123 static Point ImplCalcPos( vcl::Window* pWindow,
124 const tools::Rectangle& rRect, FloatWinPopupFlags nFlags,
125 sal_uInt16& rArrangeIndex );
126 static Point ImplConvertToAbsPos(vcl::Window* pReference, const Point& rPos);
127 static tools::Rectangle ImplConvertToAbsPos(vcl::Window* pReference, const tools::Rectangle& rRect);
128 SAL_DLLPRIVATE void ImplEndPopupMode( FloatWinPopupEndFlags nFlags, const VclPtr<vcl::Window>& xFocusId );
129 SAL_DLLPRIVATE tools::Rectangle& ImplGetItemEdgeClipRect();
130 SAL_DLLPRIVATE bool ImplIsInPrivatePopupMode() const { return mbInPopupMode; }
131 virtual void doDeferredInit(WinBits nBits) override;
133 public:
134 explicit FloatingWindow(vcl::Window* pParent, WinBits nStyle);
135 explicit FloatingWindow(vcl::Window* pParent, const OString& rID, const OUString& rUIXMLDescription,
136 const css::uno::Reference<css::frame::XFrame> &rFrame = css::uno::Reference<css::frame::XFrame>());
137 virtual ~FloatingWindow() override;
138 virtual void dispose() override;
140 virtual bool EventNotify( NotifyEvent& rNEvt ) override;
141 virtual void StateChanged( StateChangedType nType ) override;
142 virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
144 virtual void PopupModeEnd();
146 void SetTitleType( FloatWinTitleType nTitle );
147 FloatWinTitleType GetTitleType() const { return mnTitle; }
149 void StartPopupMode( const tools::Rectangle& rRect, FloatWinPopupFlags nFlags );
150 void StartPopupMode( ToolBox* pBox, FloatWinPopupFlags nFlags = FloatWinPopupFlags::NONE );
151 void EndPopupMode( FloatWinPopupEndFlags nFlags = FloatWinPopupEndFlags::NONE );
152 void AddPopupModeWindow( vcl::Window* pWindow );
153 FloatWinPopupFlags GetPopupModeFlags() const { return mnPopupModeFlags; }
154 void SetPopupModeFlags( FloatWinPopupFlags nFlags ) { mnPopupModeFlags = nFlags; }
155 bool IsInPopupMode() const { return mbPopupMode; }
156 bool IsInCleanUp() const { return mbInCleanUp; }
157 bool IsPopupModeCanceled() const { return mbPopupModeCanceled; }
158 bool IsPopupModeTearOff() const { return mbPopupModeTearOff; }
160 void SetPopupModeEndHdl( const Link<FloatingWindow*,void>& rLink ) { maPopupModeEndHdl = rLink; }
162 bool GrabsFocus() const { return mbGrabFocus; }
164 static Point CalcFloatingPosition( vcl::Window* pWindow, const tools::Rectangle& rRect, FloatWinPopupFlags nFlags, sal_uInt16& rArrangeIndex );
167 #endif // INCLUDED_VCL_FLOATWIN_HXX
169 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */