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_pOurSvpGraphics;
81  // in base class, this ptr is the same as m_pOurSvpGraphic
82  // in derived class, it can point to a derivative
83  // of Qt5SvpGraphics (which the derived class then owns)
86  QRegion m_aRegion;
88 
94 
96 
98 
101  bool m_bInDrag;
102 
107  sal_uInt32 m_nRestoreScreen;
109 
110 #if QT5_USING_X11
111  ScreenSaverInhibitor m_ScreenSaverInhibitor;
112 #endif
113 
114  void SetDefaultPos();
115  Size CalcDefaultSize();
116  void SetDefaultSize();
117 
118  bool isChild(bool bPlug = true, bool bSysChild = true) const
119  {
121  if (bPlug)
122  nMask |= SalFrameStyleFlags::PLUG;
123  if (bSysChild)
125  return bool(m_nStyle & nMask);
126  }
127 
128  bool isWindow() const;
129  QWindow* windowHandle() const;
130  QScreen* screen() const;
131  bool isMinimized() const;
132  bool isMaximized() const;
133  void SetWindowStateImpl(Qt::WindowStates eState);
134 
135  void TriggerPaintEvent();
136  void TriggerPaintEvent(QRect aRect);
137 
138 public:
139  Qt5Frame(Qt5Frame* pParent, SalFrameStyleFlags nSalFrameStyle, bool bUseCairo);
140  virtual ~Qt5Frame() override;
141 
142  QWidget* GetQWidget() const { return m_pQWidget; }
143  Qt5MainWindow* GetTopLevelWindow() const { return m_pTopLevel; }
144  QWidget* asChild() const;
145 
146  void Damage(sal_Int32 nExtentsX, sal_Int32 nExtentsY, sal_Int32 nExtentsWidth,
147  sal_Int32 nExtentsHeight) const;
148 
149  void InitQt5SvpGraphics(Qt5SvpGraphics* pQt5SvpGraphics);
150  virtual SalGraphics* AcquireGraphics() override;
151  virtual void ReleaseGraphics(SalGraphics* pGraphics) override;
152 
153  virtual bool PostEvent(std::unique_ptr<ImplSVEvent> pData) override;
154 
155  virtual void SetTitle(const OUString& rTitle) override;
156  virtual void SetIcon(sal_uInt16 nIcon) override;
157  virtual void SetMenu(SalMenu* pMenu) override;
158  virtual void DrawMenuBar() override;
159 
160  virtual void registerDragSource(Qt5DragSource* pDragSource);
161  virtual void deregisterDragSource(Qt5DragSource const* pDragSource);
162  virtual void registerDropTarget(Qt5DropTarget* pDropTarget);
163  virtual void deregisterDropTarget(Qt5DropTarget const* pDropTarget);
164 
165  void handleDragLeave();
166  void handleDragMove(QDragMoveEvent* pEvent);
167  void handleDrop(QDropEvent* pEvent);
168 
169  virtual void SetExtendedFrameStyle(SalExtStyle nExtStyle) override;
170  virtual void Show(bool bVisible, bool bNoActivate = false) override;
171  virtual void SetMinClientSize(long nWidth, long nHeight) override;
172  virtual void SetMaxClientSize(long nWidth, long nHeight) override;
173  virtual void SetPosSize(long nX, long nY, long nWidth, long nHeight,
174  sal_uInt16 nFlags) override;
175  virtual void GetClientSize(long& rWidth, long& rHeight) override;
176  virtual void GetWorkArea(tools::Rectangle& rRect) override;
177  virtual SalFrame* GetParent() const override;
178  virtual void SetModal(bool bModal) override;
179  virtual bool GetModal() const override;
180  virtual void SetWindowState(const SalFrameState* pState) override;
181  virtual bool GetWindowState(SalFrameState* pState) override;
182  virtual void ShowFullScreen(bool bFullScreen, sal_Int32 nDisplay) override;
183  virtual void StartPresentation(bool bStart) override;
184  virtual void SetAlwaysOnTop(bool bOnTop) override;
185  virtual void ToTop(SalFrameToTop nFlags) override;
186  virtual void SetPointer(PointerStyle ePointerStyle) override;
187  virtual void CaptureMouse(bool bMouse) override;
188  virtual void SetPointerPos(long nX, long nY) override;
189  virtual bool ShowTooltip(const OUString& rText, const tools::Rectangle& rHelpArea) override;
190  using SalFrame::Flush;
191  virtual void Flush() override;
192  virtual void SetInputContext(SalInputContext* pContext) override;
193  virtual void EndExtTextInput(EndExtTextInputFlags nFlags) override;
194  virtual OUString GetKeyName(sal_uInt16 nKeyCode) override;
195  virtual bool MapUnicodeToKeyCode(sal_Unicode aUnicode, LanguageType aLangType,
196  vcl::KeyCode& rKeyCode) override;
197  virtual LanguageType GetInputLanguage() override;
198  virtual void UpdateSettings(AllSettings& rSettings) override;
199  virtual void Beep() override;
200  virtual const SystemEnvData* GetSystemData() const override { return &m_aSystemData; }
201  virtual SalPointerState GetPointerState() override;
202  virtual KeyIndicatorState GetIndicatorState() override;
203  virtual void SimulateKeyPress(sal_uInt16 nKeyCode) override;
204  virtual void SetParent(SalFrame* pNewParent) override;
205  virtual bool SetPluginParent(SystemParentData* pNewParent) override;
206  virtual void ResetClipRegion() override;
207  virtual void BeginSetClipRegion(sal_uInt32 nRects) override;
208  virtual void UnionClipRegion(long nX, long nY, long nWidth, long nHeight) override;
209  virtual void EndSetClipRegion() override;
210 
211  virtual void SetScreenNumber(unsigned int) override;
212  virtual void SetApplicationID(const OUString&) override;
213 
214  inline bool CallCallback(SalEvent nEvent, const void* pEvent) const;
215 
216  cairo_t* getCairoContext() const;
217 };
218 
219 inline bool Qt5Frame::CallCallback(SalEvent nEvent, const void* pEvent) const
220 {
221  SolarMutexGuard aGuard;
222  return SalFrame::CallCallback(nEvent, pEvent);
223 }
224 
225 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
QWidget * GetQWidget() const
Definition: Qt5Frame.hxx:142
virtual SalFrame * GetParent() const =0
bool CallCallback(SalEvent nEvent, const void *pEvent) const
Definition: salframe.hxx:298
bool m_bGraphicsInUse
Definition: Qt5Frame.hxx:89
virtual void ReleaseGraphics(SalGraphics *pGraphics)=0
virtual void DrawMenuBar()=0
bool m_bDefaultSize
Definition: Qt5Frame.hxx:103
Qt5DropTarget * m_pDropTarget
Definition: Qt5Frame.hxx:100
virtual void ToTop(SalFrameToTop nFlags)=0
virtual void SetPosSize(long nX, long nY, long nWidth, long nHeight, sal_uInt16 nFlags)=0
virtual void SetMinClientSize(long nWidth, long nHeight)=0
virtual const SystemEnvData * GetSystemData() const override
Definition: Qt5Frame.hxx:200
virtual void SetTitle(const OUString &rTitle)=0
Qt5SvpGraphics * m_pSvpGraphics
Definition: Qt5Frame.hxx:84
bool isChild(bool bPlug=true, bool bSysChild=true) const
Definition: Qt5Frame.hxx:118
#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:135
bool m_bDefaultPos
Definition: Qt5Frame.hxx:104
SystemEnvData m_aSystemData
Definition: Qt5Frame.hxx:95
virtual void Beep()=0
virtual void GetWorkArea(tools::Rectangle &rRect)=0
sal_uInt32 m_nRestoreScreen
Definition: Qt5Frame.hxx:107
virtual void SetIcon(sal_uInt16 nIcon)=0
virtual void EndExtTextInput(EndExtTextInputFlags nFlags)=0
sal_uInt64 SalExtStyle
Definition: salframe.hxx:95
bool CallCallback(SalEvent nEvent, const void *pEvent) const
Definition: Qt5Frame.hxx:219
virtual SalPointerState GetPointerState()=0
virtual void SetPointerPos(long nX, long nY)=0
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 SetPointer(PointerStyle ePointerStyle)=0
virtual void SetParent(SalFrame *pNewParent)=0
virtual void SetExtendedFrameStyle(SalExtStyle nExtStyle)=0
PointerStyle m_ePointerStyle
Definition: Qt5Frame.hxx:93
virtual bool PostEvent(std::unique_ptr< ImplSVEvent > pData)=0
virtual void EndSetClipRegion()=0
KeyIndicatorState
Definition: keycodes.hxx:180
virtual void GetClientSize(long &rWidth, long &rHeight)=0
bool m_bFullScreen
Definition: Qt5Frame.hxx:105
virtual bool SetPluginParent(SystemParentData *pNewParent)=0
virtual LanguageType GetInputLanguage()=0
EndExtTextInputFlags
Definition: window.hxx:379
bool m_bNullRegion
Definition: Qt5Frame.hxx:87
Qt5MainWindow * m_pTopLevel
Definition: Qt5Frame.hxx:74
virtual void UpdateSettings(AllSettings &rSettings)=0
struct _cairo cairo_t
Definition: svpgdi.hxx:69
virtual void Flush()=0
virtual void ShowFullScreen(bool bFullScreen, sal_Int32 nDisplay)=0
virtual void SetWindowState(const SalFrameState *pState)=0
SalEvent
Definition: salwtype.hxx:40
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:106
virtual void SetModal(bool)
Definition: salframe.hxx:250
std::unique_ptr< Qt5SvpGraphics > m_pOurSvpGraphics
Definition: Qt5Frame.hxx:80
virtual KeyIndicatorState GetIndicatorState()=0
SalFrameStyleFlags
Definition: salframe.hxx:64
virtual void SimulateKeyPress(sal_uInt16 nKeyCode)=0
virtual void StartPresentation(bool bStart)=0
virtual SalGraphics * AcquireGraphics()=0
PointerStyle
Definition: ptrstyle.hxx:25
SalFrameStyleFlags m_nStyle
Definition: Qt5Frame.hxx:91
bool m_bGraphicsInvalid
Definition: Qt5Frame.hxx:90
virtual bool ShowTooltip(const OUString &, const tools::Rectangle &)
Definition: salframe.hxx:260
bool m_bInDrag
Definition: Qt5Frame.hxx:101
virtual void UnionClipRegion(long nX, long nY, long nWidth, long nHeight)=0
virtual void ResetClipRegion()=0
Qt5DragSource * m_pDragSource
Definition: Qt5Frame.hxx:99
Qt5MainWindow * GetTopLevelWindow() const
Definition: Qt5Frame.hxx:143
Qt5Frame * m_pParent
Definition: Qt5Frame.hxx:92
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:86
const bool m_bUseCairo
Definition: Qt5Frame.hxx:76
virtual void SetMaxClientSize(long nWidth, long nHeight)=0
QRect m_aRestoreGeometry
Definition: Qt5Frame.hxx:108
virtual void SetMenu(SalMenu *pSalMenu)=0
QWidget * m_pQWidget
Definition: Qt5Frame.hxx:73
DamageHandler m_aDamageHandler
Definition: Qt5Frame.hxx:85
Qt5Menu * m_pSalMenu
Definition: Qt5Frame.hxx:97
virtual bool GetModal() const
Definition: salframe.hxx:254