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 #ifndef INCLUDED_VCL_FLOATWIN_HXX
21 #define INCLUDED_VCL_FLOATWIN_HXX
22 
23 #include <vcl/dllapi.h>
24 #include <vcl/syswin.hxx>
25 #include <memory>
26 #include <o3tl/typed_flags_set.hxx>
27 
28 class ToolBox;
29 
30 
32 {
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,
46 };
47 namespace o3tl
48 {
49  template<> struct typed_flags<FloatWinPopupFlags> : is_typed_flags<FloatWinPopupFlags, 0x0fff> {};
50 }
51 
53 {
54  NONE = 0x00,
55  Cancel = 0x01,
56  TearOff = 0x02,
57  DontCallHdl = 0x04,
58  CloseAll = 0x08,
59 };
60 namespace o3tl
61 {
62  template<> struct typed_flags<FloatWinPopupEndFlags> : is_typed_flags<FloatWinPopupEndFlags, 0x0f> {};
63 }
64 
66 {
67  Unknown = 0,
68  Normal = 1,
69  TearOff = 2,
70  Popup = 3,
71  NONE = 4,
72 };
73 
75 {
76  class ImplData;
77 private:
81  std::unique_ptr<ImplData> mpImplData;
92  bool mbGrabFocus; // act as key input window, although focus is not set
95 
96  SAL_DLLPRIVATE void ImplCallPopupModeEnd();
97  DECL_DLLPRIVATE_LINK( ImplEndPopupModeHdl, void*, void );
98 
99  FloatingWindow (const FloatingWindow &) = delete;
100  FloatingWindow & operator= (const FloatingWindow &) = delete;
101 
102 protected:
103  using Window::ImplInit;
104  SAL_DLLPRIVATE void ImplInit( vcl::Window* pParent, WinBits nStyle );
105  SAL_DLLPRIVATE void ImplInitSettings();
106 
107  virtual void ApplySettings(vcl::RenderContext& rRenderContext) override;
108 
109 public:
110  SAL_DLLPRIVATE FloatingWindow* ImplFloatHitTest( vcl::Window* pReference, const Point& rPos, bool& rbHitTestInsideRect );
111  SAL_DLLPRIVATE FloatingWindow* ImplFindLastLevelFloat();
112  SAL_DLLPRIVATE bool ImplIsFloatPopupModeWindow( const vcl::Window* pWindow );
113  SAL_DLLPRIVATE void ImplSetMouseDown() { mbMouseDown = true; }
114  SAL_DLLPRIVATE bool ImplIsMouseDown() const { return mbMouseDown; }
115  static Point ImplCalcPos(vcl::Window* pWindow,
116  const tools::Rectangle& rRect, FloatWinPopupFlags nFlags,
117  sal_uInt16& rArrangeIndex, Point* pLOKTwipsPos = nullptr);
118  static Point ImplConvertToAbsPos(vcl::Window* pReference, const Point& rPos);
119  static tools::Rectangle ImplConvertToAbsPos(vcl::Window* pReference, const tools::Rectangle& rRect);
120  SAL_DLLPRIVATE void ImplEndPopupMode( FloatWinPopupEndFlags nFlags, const VclPtr<vcl::Window>& xFocusId );
121  SAL_DLLPRIVATE tools::Rectangle& ImplGetItemEdgeClipRect();
122  SAL_DLLPRIVATE bool ImplIsInPrivatePopupMode() const { return mbInPopupMode; }
123  virtual void doDeferredInit(WinBits nBits) override;
124  void PixelInvalidate(const tools::Rectangle* pRectangle) override;
125 
126 public:
127  explicit FloatingWindow(vcl::Window* pParent, WinBits nStyle);
128  explicit FloatingWindow(vcl::Window* pParent, const OString& rID, const OUString& rUIXMLDescription,
129  const css::uno::Reference<css::frame::XFrame> &rFrame = css::uno::Reference<css::frame::XFrame>());
130  virtual ~FloatingWindow() override;
131  virtual void dispose() override;
132 
133  virtual bool EventNotify( NotifyEvent& rNEvt ) override;
134  virtual void StateChanged( StateChangedType nType ) override;
135  virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
136 
137  virtual void PopupModeEnd();
138 
139  void SetTitleType( FloatWinTitleType nTitle );
140  FloatWinTitleType GetTitleType() const { return mnTitle; }
141 
142  void StartPopupMode( const tools::Rectangle& rRect, FloatWinPopupFlags nFlags );
143  void StartPopupMode( ToolBox* pBox, FloatWinPopupFlags nFlags );
144  void EndPopupMode( FloatWinPopupEndFlags nFlags = FloatWinPopupEndFlags::NONE );
145  void AddPopupModeWindow( vcl::Window* pWindow );
146  FloatWinPopupFlags GetPopupModeFlags() const { return mnPopupModeFlags; }
147  void SetPopupModeFlags( FloatWinPopupFlags nFlags ) { mnPopupModeFlags = nFlags; }
148  bool IsInPopupMode() const { return mbPopupMode; }
149  bool IsInCleanUp() const { return mbInCleanUp; }
150  bool IsPopupModeCanceled() const { return mbPopupModeCanceled; }
151  bool IsPopupModeTearOff() const { return mbPopupModeTearOff; }
152 
153  void SetPopupModeEndHdl( const Link<FloatingWindow*,void>& rLink ) { maPopupModeEndHdl = rLink; }
154 
155  bool GrabsFocus() const { return mbGrabFocus; }
156  bool UpdatePositionData();
157 
158  static Point CalcFloatingPosition( vcl::Window* pWindow, const tools::Rectangle& rRect, FloatWinPopupFlags nFlags, sal_uInt16& rArrangeIndex );
159 };
160 
161 #endif // INCLUDED_VCL_FLOATWIN_HXX
162 
163 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
FloatWinTitleType mnOldTitle
Definition: floatwin.hxx:86
void SetPopupModeFlags(FloatWinPopupFlags nFlags)
Definition: floatwin.hxx:147
bool IsInPopupMode() const
Definition: floatwin.hxx:148
bool mbPopupMode
Definition: floatwin.hxx:88
SAL_DLLPRIVATE bool ImplIsInPrivatePopupMode() const
Definition: floatwin.hxx:122
void SetPopupModeEndHdl(const Link< FloatingWindow *, void > &rLink)
Definition: floatwin.hxx:153
virtual bool EventNotify(NotifyEvent &rNEvt) override
Definition: syswin.cxx:167
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
Link< FloatingWindow *, void > maPopupModeEndHdl
Definition: floatwin.hxx:94
bool mbGrabFocus
Definition: floatwin.hxx:92
bool mbInCleanUp
Definition: floatwin.hxx:93
FloatWinTitleType GetTitleType() const
Definition: floatwin.hxx:140
tools::Rectangle maFloatRect
Definition: floatwin.hxx:82
StateChangedType
Definition: window.hxx:309
FloatWinPopupEndFlags
Definition: floatwin.hxx:52
sal_Int64 WinBits
bool mbPopupModeTearOff
Definition: floatwin.hxx:90
FloatWinPopupFlags GetPopupModeFlags() const
Definition: floatwin.hxx:146
bool IsPopupModeTearOff() const
Definition: floatwin.hxx:151
std::unique_ptr< ImplData > mpImplData
Definition: floatwin.hxx:81
VclPtr< vcl::Window > mxPrevFocusWin
Definition: floatwin.hxx:80
virtual void doDeferredInit(WinBits nBits)
Definition: syswin.cxx:1150
SAL_DLLPRIVATE void ImplSetMouseDown()
Definition: floatwin.hxx:113
virtual void ApplySettings(vcl::RenderContext &rRenderContext)
Definition: window.cxx:3670
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:304
SAL_DLLPRIVATE bool ImplIsMouseDown() const
Definition: floatwin.hxx:114
virtual void PixelInvalidate(const tools::Rectangle *pRectangle)
Notification about some rectangle of the output device got invalidated.
Definition: paint.cxx:1211
VclPtr< FloatingWindow > mpNextFloat
Definition: floatwin.hxx:76
DECL_DLLPRIVATE_LINK(ImplHandleLayoutTimerHdl, Timer *, void)
FloatWinPopupFlags mnPopupModeFlags
Definition: floatwin.hxx:84
FloatWinPopupFlags
Definition: floatwin.hxx:31
FloatWinTitleType
Definition: floatwin.hxx:65
bool GrabsFocus() const
Definition: floatwin.hxx:155
SAL_DLLPRIVATE void ImplInit(vcl::Window *pParent, WinBits nStyle, SystemParentData *pSystemParentData)
Definition: window.cxx:930
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects...
Definition: syswin.cxx:97
ImplSVEvent * mnPostId
Definition: floatwin.hxx:83
bool mbPopupModeCanceled
Definition: floatwin.hxx:89
bool IsPopupModeCanceled() const
Definition: floatwin.hxx:150
FloatWinTitleType mnTitle
Definition: floatwin.hxx:85
static Point ImplCalcPos(WinBits nStyle, const Point &rPos, const Size &rObjSize, const Size &rWinSize)
Definition: fixed.cxx:46
VclPtr< vcl::Window > mpFirstPopupModeWin
Definition: floatwin.hxx:79
virtual void StateChanged(StateChangedType nStateChange)
Definition: window.cxx:1903
OutputDevice & operator=(const OutputDevice &)=delete
bool mbInPopupMode
Definition: floatwin.hxx:87
bool IsInCleanUp() const
Definition: floatwin.hxx:149
virtual void DataChanged(const DataChangedEvent &rDCEvt)
Definition: event.cxx:35
bool mbMouseDown
Definition: floatwin.hxx:91