Update git submodules
[LibreOffice.git] / include / vcl / toolkit / floatwin.hxx
blobe0e218c6176e866cae0e3b2b167de22386509425
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 #pragma once
22 #if !defined(VCL_DLLIMPLEMENTATION) && !defined(TOOLKIT_DLLIMPLEMENTATION) && !defined(VCL_INTERNALS)
23 #error "don't use this in new code"
24 #endif
26 #include <vcl/dllapi.h>
27 #include <vcl/syswin.hxx>
28 #include <memory>
29 #include <o3tl/typed_flags_set.hxx>
31 class ToolBox;
33 enum class FloatWinPopupEndFlags
35 NONE = 0x00,
36 Cancel = 0x01,
37 TearOff = 0x02,
38 DontCallHdl = 0x04,
39 CloseAll = 0x08,
40 NoCloseChildren = 0x10,
42 namespace o3tl
44 template<> struct typed_flags<FloatWinPopupEndFlags> : is_typed_flags<FloatWinPopupEndFlags, 0x1f> {};
47 enum class FloatWinTitleType
49 Unknown = 0,
50 Normal = 1,
51 TearOff = 2,
52 Popup = 3,
53 NONE = 4,
56 class VCL_DLLPUBLIC FloatingWindow : public SystemWindow
58 class SAL_DLLPRIVATE ImplData;
59 private:
60 VclPtr<FloatingWindow> mpNextFloat;
61 VclPtr<vcl::Window> mpFirstPopupModeWin;
62 VclPtr<vcl::Window> mxPrevFocusWin;
63 std::unique_ptr<ImplData> mpImplData;
64 AbsoluteScreenPixelRectangle maFloatRect;
65 ImplSVEvent * mnPostId;
66 FloatWinPopupFlags mnPopupModeFlags;
67 FloatWinTitleType mnTitle;
68 FloatWinTitleType mnOldTitle;
69 bool mbInPopupMode;
70 bool mbPopupMode;
71 bool mbPopupModeCanceled;
72 bool mbPopupModeTearOff;
73 bool mbMouseDown;
74 bool mbGrabFocus; // act as key input window, although focus is not set
75 bool mbInCleanUp;
76 Link<FloatingWindow*,void> maPopupModeEndHdl;
78 SAL_DLLPRIVATE void ImplCallPopupModeEnd();
79 DECL_DLLPRIVATE_LINK( ImplEndPopupModeHdl, void*, void );
81 FloatingWindow (const FloatingWindow &) = delete;
82 FloatingWindow & operator= (const FloatingWindow &) = delete;
84 protected:
85 SAL_DLLPRIVATE void ImplInitFloating( vcl::Window* pParent, WinBits nStyle );
86 virtual void ImplDeferredInit(vcl::Window* pParent, WinBits nBits) override;
87 SAL_DLLPRIVATE void ImplInitSettings();
89 virtual void ApplySettings(vcl::RenderContext& rRenderContext) override;
91 public:
92 SAL_DLLPRIVATE FloatingWindow* ImplFloatHitTest( vcl::Window* pReference, const Point& rPos, bool& rbHitTestInsideRect );
93 SAL_DLLPRIVATE FloatingWindow* ImplFindLastLevelFloat();
94 SAL_DLLPRIVATE bool ImplIsFloatPopupModeWindow( const vcl::Window* pWindow );
95 SAL_DLLPRIVATE void ImplSetMouseDown() { mbMouseDown = true; }
96 SAL_DLLPRIVATE bool ImplIsMouseDown() const { return mbMouseDown; }
97 static Point ImplCalcPos(vcl::Window* pWindow,
98 const tools::Rectangle& rRect, FloatWinPopupFlags nFlags,
99 sal_uInt16& rArrangeIndex, Point* pLOKTwipsPos = nullptr);
100 static AbsoluteScreenPixelPoint ImplConvertToAbsPos(vcl::Window* pReference, const Point& rPos);
101 static AbsoluteScreenPixelRectangle ImplConvertToAbsPos(vcl::Window* pReference, const tools::Rectangle& rRect);
102 SAL_DLLPRIVATE static tools::Rectangle ImplConvertToRelPos(vcl::Window* pReference, const AbsoluteScreenPixelRectangle& rRect);
103 SAL_DLLPRIVATE void ImplEndPopupMode( FloatWinPopupEndFlags nFlags, const VclPtr<vcl::Window>& xFocusId );
104 SAL_DLLPRIVATE const AbsoluteScreenPixelRectangle & ImplGetItemEdgeClipRect();
105 SAL_DLLPRIVATE bool ImplIsInPrivatePopupMode() const { return mbInPopupMode; }
106 void PixelInvalidate(const tools::Rectangle* pRectangle) override;
108 public:
109 explicit FloatingWindow(vcl::Window* pParent, WinBits nStyle);
110 SAL_DLLPRIVATE explicit FloatingWindow(vcl::Window* pParent, const OUString& rID, const OUString& rUIXMLDescription,
111 const css::uno::Reference<css::frame::XFrame> &rFrame = css::uno::Reference<css::frame::XFrame>());
112 virtual ~FloatingWindow() override;
113 virtual void dispose() override;
115 virtual bool EventNotify( NotifyEvent& rNEvt ) override;
116 virtual void StateChanged( StateChangedType nType ) override;
117 virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
119 virtual void PopupModeEnd();
121 SAL_DLLPRIVATE void SetTitleType( FloatWinTitleType nTitle );
122 FloatWinTitleType GetTitleType() const { return mnTitle; }
124 SAL_DLLPRIVATE void StartPopupMode( const tools::Rectangle& rRect, FloatWinPopupFlags nFlags );
125 SAL_DLLPRIVATE void StartPopupMode( ToolBox* pBox, FloatWinPopupFlags nFlags );
126 void EndPopupMode( FloatWinPopupEndFlags nFlags = FloatWinPopupEndFlags::NONE );
127 SAL_DLLPRIVATE void AddPopupModeWindow( vcl::Window* pWindow );
128 FloatWinPopupFlags GetPopupModeFlags() const { return mnPopupModeFlags; }
129 void SetPopupModeFlags( FloatWinPopupFlags nFlags ) { mnPopupModeFlags = nFlags; }
130 bool IsInPopupMode() const { return mbPopupMode; }
131 bool IsInCleanUp() const { return mbInCleanUp; }
132 bool IsPopupModeCanceled() const { return mbPopupModeCanceled; }
133 bool IsPopupModeTearOff() const { return mbPopupModeTearOff; }
135 void SetPopupModeEndHdl( const Link<FloatingWindow*,void>& rLink ) { maPopupModeEndHdl = rLink; }
137 bool GrabsFocus() const { return mbGrabFocus; }
140 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */