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>
31 // - FloatingWindow-Types -
34 enum class FloatWinPopupFlags
37 AllowTearOff
= 0x000001,
38 AnimationSlide
= 0x000002,
39 NoAutoArrange
= 0x000004,
40 NoAnimation
= 0x000008,
45 NoFocusClose
= 0x000100,
46 NoKeyClose
= 0x000200,
47 NoMouseClose
= 0x000400,
48 NoMouseRectClose
= 0x000800,
49 AllMouseButtonClose
= 0x001000,
50 NoAppFocusClose
= 0x002000,
52 NoMouseUpClose
= 0x008000,
54 NoHorzPlacement
= 0x020000,
58 template<> struct typed_flags
<FloatWinPopupFlags
> : is_typed_flags
<FloatWinPopupFlags
, 0x03ffff> {};
61 enum class FloatWinPopupEndFlags
71 template<> struct typed_flags
<FloatWinPopupEndFlags
> : is_typed_flags
<FloatWinPopupEndFlags
, 0x0f> {};
74 enum class FloatWinTitleType
92 class VCL_DLLPUBLIC FloatingWindow
: public SystemWindow
96 VclPtr
<FloatingWindow
> mpNextFloat
;
97 VclPtr
<vcl::Window
> mpFirstPopupModeWin
;
99 Rectangle maFloatRect
;
100 ImplSVEvent
* mnPostId
;
101 FloatWinPopupFlags mnPopupModeFlags
;
102 FloatWinTitleType mnTitle
;
103 FloatWinTitleType mnOldTitle
;
106 bool mbPopupModeCanceled
;
107 bool mbPopupModeTearOff
;
109 bool mbOldSaveBackMode
;
110 bool mbGrabFocus
; // act as key input window, although focus is not set
112 Link
<> maPopupModeEndHdl
;
114 SAL_DLLPRIVATE
void ImplCallPopupModeEnd();
115 DECL_DLLPRIVATE_LINK( ImplEndPopupModeHdl
, void* );
116 virtual void setPosSizeOnContainee(Size aSize
, Window
&rBox
) SAL_OVERRIDE
;
118 FloatingWindow (const FloatingWindow
&) SAL_DELETED_FUNCTION
;
119 FloatingWindow
& operator= (const FloatingWindow
&) SAL_DELETED_FUNCTION
;
122 using Window::ImplInit
;
123 SAL_DLLPRIVATE
void ImplInit( vcl::Window
* pParent
, WinBits nStyle
);
124 SAL_DLLPRIVATE
void ImplInitSettings();
126 virtual void ApplySettings(vcl::RenderContext
& rRenderContext
) SAL_OVERRIDE
;
129 SAL_DLLPRIVATE FloatingWindow
* ImplFloatHitTest( vcl::Window
* pReference
, const Point
& rPos
, HitTest
& rHitTest
);
130 SAL_DLLPRIVATE FloatingWindow
* ImplFindLastLevelFloat();
131 SAL_DLLPRIVATE
bool ImplIsFloatPopupModeWindow( const vcl::Window
* pWindow
);
132 SAL_DLLPRIVATE
void ImplSetMouseDown() { mbMouseDown
= true; }
133 SAL_DLLPRIVATE
bool ImplIsMouseDown() const { return mbMouseDown
; }
134 SAL_DLLPRIVATE
static Point
ImplCalcPos( vcl::Window
* pWindow
,
135 const Rectangle
& rRect
, FloatWinPopupFlags nFlags
,
136 sal_uInt16
& rArrangeIndex
);
137 SAL_DLLPRIVATE
void ImplEndPopupMode( FloatWinPopupEndFlags nFlags
= FloatWinPopupEndFlags::NONE
, sal_uLong nFocusId
= 0 );
138 SAL_DLLPRIVATE Rectangle
& ImplGetItemEdgeClipRect();
139 SAL_DLLPRIVATE
bool ImplIsInPrivatePopupMode() const { return mbInPopupMode
; }
140 virtual void doDeferredInit(WinBits nBits
) SAL_OVERRIDE
;
143 explicit FloatingWindow(vcl::Window
* pParent
, WinBits nStyle
= WB_STDFLOATWIN
);
144 explicit FloatingWindow(vcl::Window
* pParent
, const OString
& rID
, const OUString
& rUIXMLDescription
,
145 const css::uno::Reference
<css::frame::XFrame
> &rFrame
= css::uno::Reference
<css::frame::XFrame
>());
146 virtual ~FloatingWindow();
147 virtual void dispose() SAL_OVERRIDE
;
149 virtual bool Notify( NotifyEvent
& rNEvt
) SAL_OVERRIDE
;
150 virtual void StateChanged( StateChangedType nType
) SAL_OVERRIDE
;
151 virtual void DataChanged( const DataChangedEvent
& rDCEvt
) SAL_OVERRIDE
;
153 virtual void PopupModeEnd();
155 void SetTitleType( FloatWinTitleType nTitle
);
156 FloatWinTitleType
GetTitleType() const { return mnTitle
; }
158 void StartPopupMode( const Rectangle
& rRect
, FloatWinPopupFlags nFlags
= FloatWinPopupFlags::NONE
);
159 void StartPopupMode( ToolBox
* pBox
, FloatWinPopupFlags nFlags
= FloatWinPopupFlags::NONE
);
160 void EndPopupMode( FloatWinPopupEndFlags nFlags
= FloatWinPopupEndFlags::NONE
);
161 void AddPopupModeWindow( vcl::Window
* pWindow
);
162 FloatWinPopupFlags
GetPopupModeFlags() const { return mnPopupModeFlags
; }
163 void SetPopupModeFlags( FloatWinPopupFlags nFlags
) { mnPopupModeFlags
= nFlags
; }
164 bool IsInPopupMode() const { return mbPopupMode
; }
165 bool IsInCleanUp() const { return mbInCleanUp
; }
166 bool IsPopupModeCanceled() const { return mbPopupModeCanceled
; }
167 bool IsPopupModeTearOff() const { return mbPopupModeTearOff
; }
169 void SetPopupModeEndHdl( const Link
<>& rLink
) { maPopupModeEndHdl
= rLink
; }
170 const Link
<>& GetPopupModeEndHdl() const { return maPopupModeEndHdl
; }
172 bool GrabsFocus() const { return mbGrabFocus
; }
174 static Point
CalcFloatingPosition( vcl::Window
* pWindow
, const Rectangle
& rRect
, FloatWinPopupFlags nFlags
, sal_uInt16
& rArrangeIndex
);
177 #endif // INCLUDED_VCL_FLOATWIN_HXX
179 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */