Mark some Calc slots as inactive in readonly mode
[LibreOffice.git] / vcl / qt5 / QtInstanceDrawingArea.cxx
blob9a6368d350246292a695fb9da00ef4b0bf7a7b3b
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
2 /*
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/.
8 */
10 #include <QtInstanceDrawingArea.hxx>
11 #include <QtInstanceDrawingArea.moc>
13 #include <vcl/qt/QtUtils.hxx>
15 QtInstanceDrawingArea::QtInstanceDrawingArea(QLabel* pLabel)
16 : QtInstanceWidget(pLabel)
17 , m_pLabel(pLabel)
18 , m_xDevice(DeviceFormat::WITHOUT_ALPHA)
20 assert(m_pLabel);
22 // install event filter, so eventFilter() can handle widget events
23 m_pLabel->installEventFilter(this);
26 void QtInstanceDrawingArea::queue_draw()
28 SolarMutexGuard g;
29 GetQtInstance().RunInMainThread([&] { getQWidget()->update(); });
32 void QtInstanceDrawingArea::queue_draw_area(int, int, int, int)
34 assert(false && "Not implemented yet");
37 void QtInstanceDrawingArea::enable_drag_source(rtl::Reference<TransferDataContainer>&, sal_uInt8)
39 assert(false && "Not implemented yet");
42 void QtInstanceDrawingArea::set_cursor(PointerStyle) { assert(false && "Not implemented yet"); }
44 Point QtInstanceDrawingArea::get_pointer_position() const
46 assert(false && "Not implemented yet");
47 return Point();
50 void QtInstanceDrawingArea::set_input_context(const InputContext&)
52 assert(false && "Not implemented yet");
55 void QtInstanceDrawingArea::im_context_set_cursor_location(const tools::Rectangle&, int)
57 assert(false && "Not implemented yet");
60 OutputDevice& QtInstanceDrawingArea::get_ref_device() { return *m_xDevice; }
62 a11yref QtInstanceDrawingArea::get_accessible_parent()
64 assert(false && "Not implemented yet");
65 return nullptr;
68 a11yrelationset QtInstanceDrawingArea::get_accessible_relation_set()
70 assert(false && "Not implemented yet");
71 return nullptr;
74 AbsoluteScreenPixelPoint QtInstanceDrawingArea::get_accessible_location_on_screen()
76 assert(false && "Not implemented yet");
77 return AbsoluteScreenPixelPoint(0, 0);
80 void QtInstanceDrawingArea::click(const Point&) { assert(false && "Not implemented yet"); }
82 bool QtInstanceDrawingArea::eventFilter(QObject* pObject, QEvent* pEvent)
84 if (pObject != m_pLabel)
85 return false;
87 SolarMutexGuard g;
88 assert(GetQtInstance().IsMainThread());
90 switch (pEvent->type())
92 case QEvent::Paint:
93 handlePaintEvent();
94 return false;
95 case QEvent::Resize:
96 handleResizeEvent();
97 return false;
98 default:
99 return false;
103 void QtInstanceDrawingArea::handlePaintEvent()
105 tools::Rectangle aRect(0, 0, m_pLabel->width(), m_pLabel->height());
106 aRect = m_xDevice->PixelToLogic(aRect);
107 m_xDevice->Erase(aRect);
108 m_aDrawHdl.Call(std::pair<vcl::RenderContext&, const tools::Rectangle&>(*m_xDevice, aRect));
109 QPixmap aPixmap = toQPixmap(*m_xDevice);
111 // set new pixmap if it changed
112 #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
113 if (aPixmap.toImage() != m_pLabel->pixmap().toImage())
114 #else
115 if (aPixmap.toImage() != m_pLabel->pixmap(Qt::ReturnByValue).toImage())
116 #endif
117 m_pLabel->setPixmap(aPixmap);
120 void QtInstanceDrawingArea::handleResizeEvent()
122 const Size aSize = toSize(m_pLabel->size());
123 m_xDevice->SetOutputSizePixel(aSize);
124 m_aSizeAllocateHdl.Call(aSize);
127 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */