LibreOffice Module vcl (master)  1
floatwin.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #pragma once
21 
22 #if !defined(VCL_DLLIMPLEMENTATION) && !defined(TOOLKIT_DLLIMPLEMENTATION) && !defined(VCL_INTERNALS)
23 #error "don't use this in new code"
24 #endif
25 
26 #include <vcl/dllapi.h>
27 #include <vcl/syswin.hxx>
28 #include <memory>
29 #include <o3tl/typed_flags_set.hxx>
30 
31 class ToolBox;
32 
34 {
35  NONE = 0x00,
36  Cancel = 0x01,
37  TearOff = 0x02,
38  DontCallHdl = 0x04,
39  CloseAll = 0x08,
40  NoCloseChildren = 0x10,
41 };
42 namespace o3tl
43 {
44  template<> struct typed_flags<FloatWinPopupEndFlags> : is_typed_flags<FloatWinPopupEndFlags, 0x1f> {};
45 }
46 
48 {
49  Unknown = 0,
50  Normal = 1,
51  TearOff = 2,
52  Popup = 3,
53  NONE = 4,
54 };
55 
57 {
58  class SAL_DLLPRIVATE ImplData;
59 private:
63  std::unique_ptr<ImplData> mpImplData;
74  bool mbGrabFocus; // act as key input window, although focus is not set
77 
78  SAL_DLLPRIVATE void ImplCallPopupModeEnd();
79  DECL_DLLPRIVATE_LINK( ImplEndPopupModeHdl, void*, void );
80 
81  FloatingWindow (const FloatingWindow &) = delete;
82  FloatingWindow & operator= (const FloatingWindow &) = delete;
83 
84 protected:
85  SAL_DLLPRIVATE void ImplInitFloating( vcl::Window* pParent, WinBits nStyle );
86  SAL_DLLPRIVATE void ImplInitSettings();
87 
88  virtual void ApplySettings(vcl::RenderContext& rRenderContext) override;
89 
90 public:
91  SAL_DLLPRIVATE FloatingWindow* ImplFloatHitTest( vcl::Window* pReference, const Point& rPos, bool& rbHitTestInsideRect );
92  SAL_DLLPRIVATE FloatingWindow* ImplFindLastLevelFloat();
93  SAL_DLLPRIVATE bool ImplIsFloatPopupModeWindow( const vcl::Window* pWindow );
94  SAL_DLLPRIVATE void ImplSetMouseDown() { mbMouseDown = true; }
95  SAL_DLLPRIVATE bool ImplIsMouseDown() const { return mbMouseDown; }
96  static Point ImplCalcPos(vcl::Window* pWindow,
97  const tools::Rectangle& rRect, FloatWinPopupFlags nFlags,
98  sal_uInt16& rArrangeIndex, Point* pLOKTwipsPos = nullptr);
99  static Point ImplConvertToAbsPos(vcl::Window* pReference, const Point& rPos);
100  static tools::Rectangle ImplConvertToAbsPos(vcl::Window* pReference, const tools::Rectangle& rRect);
101  static tools::Rectangle ImplConvertToRelPos(vcl::Window* pReference, const tools::Rectangle& rRect);
102  SAL_DLLPRIVATE void ImplEndPopupMode( FloatWinPopupEndFlags nFlags, const VclPtr<vcl::Window>& xFocusId );
103  SAL_DLLPRIVATE tools::Rectangle& ImplGetItemEdgeClipRect();
104  SAL_DLLPRIVATE bool ImplIsInPrivatePopupMode() const { return mbInPopupMode; }
105  virtual void doDeferredInit(WinBits nBits) override;
106  void PixelInvalidate(const tools::Rectangle* pRectangle) override;
107 
108 public:
109  explicit FloatingWindow(vcl::Window* pParent, WinBits nStyle);
110  explicit FloatingWindow(vcl::Window* pParent, const OString& 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;
114 
115  virtual bool EventNotify( NotifyEvent& rNEvt ) override;
116  virtual void StateChanged( StateChangedType nType ) override;
117  virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
118 
119  virtual void PopupModeEnd();
120 
121  void SetTitleType( FloatWinTitleType nTitle );
122  FloatWinTitleType GetTitleType() const { return mnTitle; }
123 
124  void StartPopupMode( const tools::Rectangle& rRect, FloatWinPopupFlags nFlags );
125  void StartPopupMode( ToolBox* pBox, FloatWinPopupFlags nFlags );
126  void EndPopupMode( FloatWinPopupEndFlags nFlags = FloatWinPopupEndFlags::NONE );
127  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; }
134 
135  void SetPopupModeEndHdl( const Link<FloatingWindow*,void>& rLink ) { maPopupModeEndHdl = rLink; }
136 
137  bool GrabsFocus() const { return mbGrabFocus; }
138 };
139 
140 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
VclReferenceBase & operator=(const VclReferenceBase &)=delete
FloatWinTitleType mnOldTitle
Definition: floatwin.hxx:68
void SetPopupModeFlags(FloatWinPopupFlags nFlags)
Definition: floatwin.hxx:129
bool IsInPopupMode() const
Definition: floatwin.hxx:130
bool mbPopupMode
Definition: floatwin.hxx:70
SAL_DLLPRIVATE bool ImplIsInPrivatePopupMode() const
Definition: floatwin.hxx:104
void SetPopupModeEndHdl(const Link< FloatingWindow *, void > &rLink)
Definition: floatwin.hxx:135
virtual bool EventNotify(NotifyEvent &rNEvt) override
Definition: syswin.cxx:174
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
Link< FloatingWindow *, void > maPopupModeEndHdl
Definition: floatwin.hxx:76
bool mbGrabFocus
Definition: floatwin.hxx:74
bool mbInCleanUp
Definition: floatwin.hxx:75
FloatWinPopupFlags
Definition: vclenum.hxx:367
FloatWinTitleType GetTitleType() const
Definition: floatwin.hxx:122
tools::Rectangle maFloatRect
Definition: floatwin.hxx:64
StateChangedType
Definition: window.hxx:289
FloatWinPopupEndFlags
Definition: floatwin.hxx:33
sal_Int64 WinBits
bool mbPopupModeTearOff
Definition: floatwin.hxx:72
FloatWinPopupFlags GetPopupModeFlags() const
Definition: floatwin.hxx:128
bool IsPopupModeTearOff() const
Definition: floatwin.hxx:133
std::unique_ptr< ImplData > mpImplData
Definition: floatwin.hxx:63
VclPtr< vcl::Window > mxPrevFocusWin
Definition: floatwin.hxx:62
virtual void doDeferredInit(WinBits nBits)
Definition: syswin.cxx:1102
SAL_DLLPRIVATE void ImplSetMouseDown()
Definition: floatwin.hxx:94
virtual void ApplySettings(vcl::RenderContext &rRenderContext)
Definition: window.cxx:3843
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:168
SAL_DLLPRIVATE bool ImplIsMouseDown() const
Definition: floatwin.hxx:95
virtual void PixelInvalidate(const tools::Rectangle *pRectangle)
Notification about some rectangle of the output device got invalidated.
Definition: paint.cxx:1226
VclPtr< FloatingWindow > mpNextFloat
Definition: floatwin.hxx:60
DECL_DLLPRIVATE_LINK(ImplHandleLayoutTimerHdl, Timer *, void)
FloatWinPopupFlags mnPopupModeFlags
Definition: floatwin.hxx:66
FloatWinTitleType
Definition: floatwin.hxx:47
bool GrabsFocus() const
Definition: floatwin.hxx:137
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects...
Definition: syswin.cxx:101
ImplSVEvent * mnPostId
Definition: floatwin.hxx:65
bool mbPopupModeCanceled
Definition: floatwin.hxx:71
bool IsPopupModeCanceled() const
Definition: floatwin.hxx:132
FloatWinTitleType mnTitle
Definition: floatwin.hxx:67
static Point ImplCalcPos(WinBits nStyle, const Point &rPos, const Size &rObjSize, const Size &rWinSize)
Definition: fixed.cxx:49
VclPtr< vcl::Window > mpFirstPopupModeWin
Definition: floatwin.hxx:61
virtual void StateChanged(StateChangedType nStateChange)
Definition: window.cxx:1940
bool mbInPopupMode
Definition: floatwin.hxx:69
bool IsInCleanUp() const
Definition: floatwin.hxx:131
virtual void DataChanged(const DataChangedEvent &rDCEvt)
Definition: event.cxx:36
bool mbMouseDown
Definition: floatwin.hxx:73