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_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>
32 enum class FloatWinPopupFlags
35 AllowTearOff
= 0x000001,
40 NoKeyClose
= 0x000020,
41 AllMouseButtonClose
= 0x000040,
42 NoAppFocusClose
= 0x000080,
44 NoMouseUpClose
= 0x000200,
46 NoHorzPlacement
= 0x000800,
50 template<> struct typed_flags
<FloatWinPopupFlags
> : is_typed_flags
<FloatWinPopupFlags
, 0x0fff> {};
53 enum class FloatWinPopupEndFlags
60 NoCloseChildren
= 0x10,
64 template<> struct typed_flags
<FloatWinPopupEndFlags
> : is_typed_flags
<FloatWinPopupEndFlags
, 0x1f> {};
67 enum class FloatWinTitleType
84 class VCL_DLLPUBLIC FloatingWindow
: public SystemWindow
88 VclPtr
<FloatingWindow
> mpNextFloat
;
89 VclPtr
<vcl::Window
> mpFirstPopupModeWin
;
90 VclPtr
<vcl::Window
> mxPrevFocusWin
;
91 std::unique_ptr
<ImplData
> mpImplData
;
92 tools::Rectangle maFloatRect
;
93 ImplSVEvent
* mnPostId
;
94 FloatWinPopupFlags mnPopupModeFlags
;
95 FloatWinTitleType mnTitle
;
96 FloatWinTitleType mnOldTitle
;
99 bool mbPopupModeCanceled
;
100 bool mbPopupModeTearOff
;
102 bool mbGrabFocus
; // act as key input window, although focus is not set
104 Link
<FloatingWindow
*,void> maPopupModeEndHdl
;
106 SAL_DLLPRIVATE
void ImplCallPopupModeEnd();
107 DECL_DLLPRIVATE_LINK( ImplEndPopupModeHdl
, void*, void );
109 FloatingWindow (const FloatingWindow
&) = delete;
110 FloatingWindow
& operator= (const FloatingWindow
&) = delete;
113 using Window::ImplInit
;
114 SAL_DLLPRIVATE
void ImplInit( vcl::Window
* pParent
, WinBits nStyle
);
115 SAL_DLLPRIVATE
void ImplInitSettings();
117 virtual void ApplySettings(vcl::RenderContext
& rRenderContext
) override
;
120 SAL_DLLPRIVATE FloatingWindow
* ImplFloatHitTest( vcl::Window
* pReference
, const Point
& rPos
, HitTest
& rHitTest
);
121 SAL_DLLPRIVATE FloatingWindow
* ImplFindLastLevelFloat();
122 SAL_DLLPRIVATE
bool ImplIsFloatPopupModeWindow( const vcl::Window
* pWindow
);
123 SAL_DLLPRIVATE
void ImplSetMouseDown() { mbMouseDown
= true; }
124 SAL_DLLPRIVATE
bool ImplIsMouseDown() const { return mbMouseDown
; }
125 static Point
ImplCalcPos(vcl::Window
* pWindow
,
126 const tools::Rectangle
& rRect
, FloatWinPopupFlags nFlags
,
127 sal_uInt16
& rArrangeIndex
, Point
* pLOKTwipsPos
= nullptr);
128 static Point
ImplConvertToAbsPos(vcl::Window
* pReference
, const Point
& rPos
);
129 static tools::Rectangle
ImplConvertToAbsPos(vcl::Window
* pReference
, const tools::Rectangle
& rRect
);
130 SAL_DLLPRIVATE
void ImplEndPopupMode( FloatWinPopupEndFlags nFlags
, const VclPtr
<vcl::Window
>& xFocusId
);
131 SAL_DLLPRIVATE
tools::Rectangle
& ImplGetItemEdgeClipRect();
132 SAL_DLLPRIVATE
bool ImplIsInPrivatePopupMode() const { return mbInPopupMode
; }
133 virtual void doDeferredInit(WinBits nBits
) override
;
134 void PixelInvalidate(const tools::Rectangle
* pRectangle
) override
;
137 explicit FloatingWindow(vcl::Window
* pParent
, WinBits nStyle
);
138 explicit FloatingWindow(vcl::Window
* pParent
, const OString
& rID
, const OUString
& rUIXMLDescription
,
139 const css::uno::Reference
<css::frame::XFrame
> &rFrame
= css::uno::Reference
<css::frame::XFrame
>());
140 virtual ~FloatingWindow() override
;
141 virtual void dispose() override
;
143 virtual bool EventNotify( NotifyEvent
& rNEvt
) override
;
144 virtual void StateChanged( StateChangedType nType
) override
;
145 virtual void DataChanged( const DataChangedEvent
& rDCEvt
) override
;
147 virtual void PopupModeEnd();
149 void SetTitleType( FloatWinTitleType nTitle
);
150 FloatWinTitleType
GetTitleType() const { return mnTitle
; }
152 void StartPopupMode( const tools::Rectangle
& rRect
, FloatWinPopupFlags nFlags
);
153 void StartPopupMode( ToolBox
* pBox
, FloatWinPopupFlags nFlags
);
154 void EndPopupMode( FloatWinPopupEndFlags nFlags
= FloatWinPopupEndFlags::NONE
);
155 void AddPopupModeWindow( vcl::Window
* pWindow
);
156 FloatWinPopupFlags
GetPopupModeFlags() const { return mnPopupModeFlags
; }
157 void SetPopupModeFlags( FloatWinPopupFlags nFlags
) { mnPopupModeFlags
= nFlags
; }
158 bool IsInPopupMode() const { return mbPopupMode
; }
159 bool IsInCleanUp() const { return mbInCleanUp
; }
160 bool IsPopupModeCanceled() const { return mbPopupModeCanceled
; }
161 bool IsPopupModeTearOff() const { return mbPopupModeTearOff
; }
163 void SetPopupModeEndHdl( const Link
<FloatingWindow
*,void>& rLink
) { maPopupModeEndHdl
= rLink
; }
165 bool GrabsFocus() const { return mbGrabFocus
; }
167 static Point
CalcFloatingPosition( vcl::Window
* pWindow
, const tools::Rectangle
& rRect
, FloatWinPopupFlags nFlags
, sal_uInt16
& rArrangeIndex
);
170 #endif // INCLUDED_VCL_FLOATWIN_HXX
172 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */