LibreOffice Module vcl (master)  1
Qt5Frame.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 #include <config_vclplug.h>
23 
24 #include <salframe.hxx>
25 #include <vclpluginapi.h>
26 
27 #include "Qt5Tools.hxx"
28 
29 #include <headless/svpgdi.hxx>
30 #include <vcl/svapp.hxx>
31 #include <vcl/sysdata.hxx>
32 
33 #include <QtCore/QObject>
34 
35 #if QT5_USING_X11
37 // any better way to get rid of the X11 / Qt type clashes?
38 #undef Bool
39 #undef CursorShape
40 #undef Expose
41 #undef KeyPress
42 #undef KeyRelease
43 #undef FocusIn
44 #undef FocusOut
45 #undef FontChange
46 #undef None
47 #undef Status
48 #undef Unsorted
49 #endif
50 
51 class Qt5DragSource;
52 class Qt5DropTarget;
53 class Qt5Graphics;
54 class Qt5Instance;
55 class Qt5MainWindow;
56 class Qt5Menu;
57 class Qt5SvpGraphics;
58 
59 class QDragMoveEvent;
60 class QDropEvent;
61 class QImage;
62 class QMimeData;
63 class QPaintDevice;
64 class QScreen;
65 class QWidget;
66 
67 class VCLPLUG_QT5_PUBLIC Qt5Frame : public QObject, public SalFrame
68 {
69  Q_OBJECT
70 
71  friend class Qt5Widget;
72 
73  QWidget* m_pQWidget;
75 
76  const bool m_bUseCairo;
77  std::unique_ptr<QImage> m_pQImage;
78  std::unique_ptr<Qt5Graphics> m_pQt5Graphics;
80  std::unique_ptr<Qt5SvpGraphics> m_pSvpGraphics;
82  QRegion m_aRegion;
84 
90 
92 
95  bool m_bInDrag;
96 
101  sal_uInt32 m_nRestoreScreen;
103 
104 #if QT5_USING_X11
105  ScreenSaverInhibitor m_ScreenSaverInhibitor;
106 #endif
107 
109 
110  void SetDefaultPos();
111  Size CalcDefaultSize();
112  void SetDefaultSize();
113 
114  bool isChild(bool bPlug = true, bool bSysChild = true) const
115  {
117  if (bPlug)
118  nMask |= SalFrameStyleFlags::PLUG;
119  if (bSysChild)
121  return bool(m_nStyle & nMask);
122  }
123 
124  bool isWindow() const;
125  QWindow* windowHandle() const;
126  QScreen* screen() const;
127  bool isMinimized() const;
128  bool isMaximized() const;
129  void SetWindowStateImpl(Qt::WindowStates eState);
130 
131  void fixICCCMwindowGroup();
132 
133 public:
134  Qt5Frame(Qt5Frame* pParent, SalFrameStyleFlags nSalFrameStyle, bool bUseCairo);
135  virtual ~Qt5Frame() override;
136 
137  QWidget* GetQWidget() const { return m_pQWidget; }
138  Qt5MainWindow* GetTopLevelWindow() const { return m_pTopLevel; }
139  QWidget* asChild() const;
140  qreal devicePixelRatioF() const;
141 
142  void Damage(sal_Int32 nExtentsX, sal_Int32 nExtentsY, sal_Int32 nExtentsWidth,
143  sal_Int32 nExtentsHeight) const;
144 
145  virtual SalGraphics* AcquireGraphics() override;
146  virtual void ReleaseGraphics(SalGraphics* pGraphics) override;
147 
148  virtual bool PostEvent(std::unique_ptr<ImplSVEvent> pData) override;
149 
150  virtual void SetTitle(const OUString& rTitle) override;
151  virtual void SetIcon(sal_uInt16 nIcon) override;
152  virtual void SetMenu(SalMenu* pMenu) override;
153  virtual void DrawMenuBar() override;
154 
155  virtual void registerDragSource(Qt5DragSource* pDragSource);
156  virtual void deregisterDragSource(Qt5DragSource const* pDragSource);
157  virtual void registerDropTarget(Qt5DropTarget* pDropTarget);
158  virtual void deregisterDropTarget(Qt5DropTarget const* pDropTarget);
159 
160  void handleDragLeave();
161  void handleDragMove(QDragMoveEvent* pEvent);
162  void handleDrop(QDropEvent* pEvent);
163 
164  virtual void SetExtendedFrameStyle(SalExtStyle nExtStyle) override;
165  virtual void Show(bool bVisible, bool bNoActivate = false) override;
166  virtual void SetMinClientSize(tools::Long nWidth, tools::Long nHeight) override;
167  virtual void SetMaxClientSize(tools::Long nWidth, tools::Long nHeight) override;
168  virtual void SetPosSize(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight,
169  sal_uInt16 nFlags) override;
170  virtual void GetClientSize(tools::Long& rWidth, tools::Long& rHeight) override;
171  virtual void GetWorkArea(tools::Rectangle& rRect) override;
172  virtual SalFrame* GetParent() const override;
173  virtual void SetModal(bool bModal) override;
174  virtual bool GetModal() const override;
175  virtual void SetWindowState(const SalFrameState* pState) override;
176  virtual bool GetWindowState(SalFrameState* pState) override;
177  virtual void ShowFullScreen(bool bFullScreen, sal_Int32 nDisplay) override;
178  virtual void StartPresentation(bool bStart) override;
179  virtual void SetAlwaysOnTop(bool bOnTop) override;
180  virtual void ToTop(SalFrameToTop nFlags) override;
181  virtual void SetPointer(PointerStyle ePointerStyle) override;
182  virtual void CaptureMouse(bool bMouse) override;
183  virtual void SetPointerPos(tools::Long nX, tools::Long nY) override;
184  virtual bool ShowTooltip(const OUString& rText, const tools::Rectangle& rHelpArea) override;
185  using SalFrame::Flush;
186  virtual void Flush() override;
187  virtual void SetInputContext(SalInputContext* pContext) override;
188  virtual void EndExtTextInput(EndExtTextInputFlags nFlags) override;
189  virtual OUString GetKeyName(sal_uInt16 nKeyCode) override;
190  virtual bool MapUnicodeToKeyCode(sal_Unicode aUnicode, LanguageType aLangType,
191  vcl::KeyCode& rKeyCode) override;
192  virtual LanguageType GetInputLanguage() override;
193  virtual void UpdateSettings(AllSettings& rSettings) override;
194  virtual void Beep() override;
195  virtual const SystemEnvData* GetSystemData() const override { return &m_aSystemData; }
196  virtual SalPointerState GetPointerState() override;
197  virtual KeyIndicatorState GetIndicatorState() override;
198  virtual void SimulateKeyPress(sal_uInt16 nKeyCode) override;
199  virtual void SetParent(SalFrame* pNewParent) override;
200  virtual void SetPluginParent(SystemParentData* pNewParent) override;
201  virtual void ResetClipRegion() override;
202  virtual void BeginSetClipRegion(sal_uInt32 nRects) override;
203  virtual void UnionClipRegion(tools::Long nX, tools::Long nY, tools::Long nWidth,
204  tools::Long nHeight) override;
205  virtual void EndSetClipRegion() override;
206 
207  virtual void SetScreenNumber(unsigned int) override;
208  virtual void SetApplicationID(const OUString&) override;
209 
210  inline bool CallCallback(SalEvent nEvent, const void* pEvent) const;
211 
212  void setInputLanguage(LanguageType);
213 };
214 
215 inline bool Qt5Frame::CallCallback(SalEvent nEvent, const void* pEvent) const
216 {
217  SolarMutexGuard aGuard;
218  return SalFrame::CallCallback(nEvent, pEvent);
219 }
220 
221 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
QWidget * GetQWidget() const
Definition: Qt5Frame.hxx:137
virtual SalFrame * GetParent() const =0
bool CallCallback(SalEvent nEvent, const void *pEvent) const
Definition: salframe.hxx:305
bool m_bGraphicsInUse
Definition: Qt5Frame.hxx:85
virtual void ReleaseGraphics(SalGraphics *pGraphics)=0
virtual void DrawMenuBar()=0
bool m_bDefaultSize
Definition: Qt5Frame.hxx:97
Qt5DropTarget * m_pDropTarget
Definition: Qt5Frame.hxx:94
virtual void ToTop(SalFrameToTop nFlags)=0
virtual void SetMaxClientSize(tools::Long nWidth, tools::Long nHeight)=0
virtual const SystemEnvData * GetSystemData() const override
Definition: Qt5Frame.hxx:195
long Long
virtual void SetTitle(const OUString &rTitle)=0
bool isChild(bool bPlug=true, bool bSysChild=true) const
Definition: Qt5Frame.hxx:114
#define VCLPLUG_QT5_PUBLIC
Definition: vclpluginapi.h:53
virtual void BeginSetClipRegion(sal_uInt32 nRects)=0
virtual void Show(bool bVisible, bool bNoActivate=false)=0
virtual bool GetWindowState(SalFrameState *pState)=0
sal_uInt16 sal_Unicode
std::unique_ptr< cairo_surface_t, CairoDeleter > UniqueCairoSurface
Definition: Qt5Tools.hxx:147
bool m_bDefaultPos
Definition: Qt5Frame.hxx:98
SystemEnvData m_aSystemData
Definition: Qt5Frame.hxx:91
virtual void Beep()=0
virtual void GetWorkArea(tools::Rectangle &rRect)=0
sal_uInt32 m_nRestoreScreen
Definition: Qt5Frame.hxx:101
virtual void SetIcon(sal_uInt16 nIcon)=0
virtual void EndExtTextInput(EndExtTextInputFlags nFlags)=0
sal_uInt64 SalExtStyle
Definition: salframe.hxx:95
virtual void SetPointerPos(tools::Long nX, tools::Long nY)=0
bool CallCallback(SalEvent nEvent, const void *pEvent) const
Definition: Qt5Frame.hxx:215
virtual SalPointerState GetPointerState()=0
std::unique_ptr< Qt5SvpGraphics > m_pSvpGraphics
Definition: Qt5Frame.hxx:80
virtual void CaptureMouse(bool bMouse)=0
std::unique_ptr< QImage > m_pQImage
Definition: Qt5Frame.hxx:77
SalFrameToTop
Definition: salframe.hxx:43
virtual void SetInputContext(SalInputContext *pContext)=0
virtual void GetClientSize(tools::Long &rWidth, tools::Long &rHeight)=0
virtual void SetPointer(PointerStyle ePointerStyle)=0
virtual void SetParent(SalFrame *pNewParent)=0
virtual void SetPosSize(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, sal_uInt16 nFlags)=0
virtual void SetExtendedFrameStyle(SalExtStyle nExtStyle)=0
PointerStyle m_ePointerStyle
Definition: Qt5Frame.hxx:89
virtual bool PostEvent(std::unique_ptr< ImplSVEvent > pData)=0
virtual void EndSetClipRegion()=0
KeyIndicatorState
Definition: keycodes.hxx:184
bool m_bFullScreen
Definition: Qt5Frame.hxx:99
virtual LanguageType GetInputLanguage()=0
EndExtTextInputFlags
Definition: window.hxx:357
bool m_bNullRegion
Definition: Qt5Frame.hxx:83
virtual void SetMinClientSize(tools::Long nWidth, tools::Long nHeight)=0
Qt5MainWindow * m_pTopLevel
Definition: Qt5Frame.hxx:74
virtual void UpdateSettings(AllSettings &rSettings)=0
virtual void Flush()=0
virtual void ShowFullScreen(bool bFullScreen, sal_Int32 nDisplay)=0
virtual void SetWindowState(const SalFrameState *pState)=0
SalEvent
Definition: salwtype.hxx:41
virtual void SetScreenNumber(unsigned int nScreen)=0
A SalFrame is a system window (e.g. an X11 window).
Definition: salframe.hxx:112
std::unique_ptr< Qt5Graphics > m_pQt5Graphics
Definition: Qt5Frame.hxx:78
virtual void SetApplicationID(const OUString &rApplicationID)=0
bool m_bFullScreenSpanAll
Definition: Qt5Frame.hxx:100
virtual void SetModal(bool)
Definition: salframe.hxx:257
virtual void SetPluginParent(SystemParentData *pNewParent)=0
virtual KeyIndicatorState GetIndicatorState()=0
SalFrameStyleFlags
Definition: salframe.hxx:64
virtual void SimulateKeyPress(sal_uInt16 nKeyCode)=0
virtual void StartPresentation(bool bStart)=0
virtual void UnionClipRegion(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight)=0
virtual SalGraphics * AcquireGraphics()=0
PointerStyle
Definition: ptrstyle.hxx:25
SalFrameStyleFlags m_nStyle
Definition: Qt5Frame.hxx:87
bool m_bGraphicsInvalid
Definition: Qt5Frame.hxx:86
virtual bool ShowTooltip(const OUString &, const tools::Rectangle &)
Definition: salframe.hxx:267
bool m_bInDrag
Definition: Qt5Frame.hxx:95
virtual void ResetClipRegion()=0
Qt5DragSource * m_pDragSource
Definition: Qt5Frame.hxx:93
Qt5MainWindow * GetTopLevelWindow() const
Definition: Qt5Frame.hxx:138
Qt5Frame * m_pParent
Definition: Qt5Frame.hxx:88
virtual OUString GetKeyName(sal_uInt16 nKeyCode)=0
virtual bool MapUnicodeToKeyCode(sal_Unicode aUnicode, LanguageType aLangType, vcl::KeyCode &rKeyCode)=0
virtual void SetAlwaysOnTop(bool bOnTop)=0
UniqueCairoSurface m_pSurface
Definition: Qt5Frame.hxx:79
QRegion m_aRegion
Definition: Qt5Frame.hxx:82
const bool m_bUseCairo
Definition: Qt5Frame.hxx:76
QRect m_aRestoreGeometry
Definition: Qt5Frame.hxx:102
LanguageType m_nInputLanguage
Definition: Qt5Frame.hxx:108
virtual void SetMenu(SalMenu *pSalMenu)=0
QWidget * m_pQWidget
Definition: Qt5Frame.hxx:73
DamageHandler m_aDamageHandler
Definition: Qt5Frame.hxx:81
virtual bool GetModal() const
Definition: salframe.hxx:261