1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
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/.
10 #include <QtInstanceDrawingArea.hxx>
11 #include <QtInstanceDrawingArea.moc>
13 #include <vcl/qt/QtUtils.hxx>
15 QtInstanceDrawingArea::QtInstanceDrawingArea(QLabel
* pLabel
)
16 : QtInstanceWidget(pLabel
)
18 , m_xDevice(DeviceFormat::WITHOUT_ALPHA
)
22 // install event filter, so eventFilter() can handle widget events
23 m_pLabel
->installEventFilter(this);
26 void QtInstanceDrawingArea::queue_draw()
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");
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");
68 a11yrelationset
QtInstanceDrawingArea::get_accessible_relation_set()
70 assert(false && "Not implemented yet");
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
)
88 assert(GetQtInstance().IsMainThread());
90 switch (pEvent
->type())
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())
115 if (aPixmap
.toImage() != m_pLabel
->pixmap(Qt::ReturnByValue
).toImage())
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: */