Mark some Calc slots as inactive in readonly mode
[LibreOffice.git] / vcl / qt5 / QtInstanceScrolledWindow.cxx
blobd799555d94cf93987db79c83a42db5a901c7f88c
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 <QtInstanceScrolledWindow.hxx>
11 #include <QtInstanceScrolledWindow.moc>
13 #include <QtWidgets/QScrollBar>
15 QtInstanceScrolledWindow::QtInstanceScrolledWindow(QScrollArea* pScrollArea)
16 : QtInstanceWidget(pScrollArea)
17 , m_pScrollArea(pScrollArea)
19 assert(m_pScrollArea);
22 void QtInstanceScrolledWindow::move(weld::Widget*, weld::Container*)
24 assert(false && "Not implemented yet");
27 css::uno::Reference<css::awt::XWindow> QtInstanceScrolledWindow::CreateChildFrame()
29 assert(false && "Not implemented yet");
30 return nullptr;
33 void QtInstanceScrolledWindow::child_grab_focus() { assert(false && "Not implemented yet"); }
35 void QtInstanceScrolledWindow::hadjustment_configure(int, int, int, int, int, int)
37 assert(false && "Not implemented yet");
40 int QtInstanceScrolledWindow::hadjustment_get_value() const
42 SolarMutexGuard g;
44 int nValue = 0;
45 GetQtInstance().RunInMainThread([&] {
46 if (QScrollBar* pScrollBar = m_pScrollArea->horizontalScrollBar())
47 nValue = pScrollBar->value();
48 });
50 return nValue;
53 void QtInstanceScrolledWindow::hadjustment_set_value(int nValue)
55 SolarMutexGuard g;
57 GetQtInstance().RunInMainThread([&] {
58 if (QScrollBar* pScrollBar = m_pScrollArea->horizontalScrollBar())
59 pScrollBar->setValue(nValue);
60 });
63 int QtInstanceScrolledWindow::hadjustment_get_upper() const
65 SolarMutexGuard g;
67 int nMax = 0;
68 GetQtInstance().RunInMainThread([&] {
69 if (QScrollBar* pScrollBar = m_pScrollArea->horizontalScrollBar())
70 nMax = pScrollBar->maximum();
71 });
73 return nMax;
76 void QtInstanceScrolledWindow::hadjustment_set_upper(int nUpper)
78 SolarMutexGuard g;
80 GetQtInstance().RunInMainThread([&] {
81 if (QScrollBar* pScrollBar = m_pScrollArea->horizontalScrollBar())
82 pScrollBar->setMaximum(nUpper);
83 });
86 int QtInstanceScrolledWindow::hadjustment_get_page_size() const
88 assert(false && "Not implemented yet");
89 return 0;
92 void QtInstanceScrolledWindow::hadjustment_set_page_size(int)
94 assert(false && "Not implemented yet");
97 void QtInstanceScrolledWindow::hadjustment_set_page_increment(int nSize)
99 SolarMutexGuard g;
101 GetQtInstance().RunInMainThread([&] {
102 if (QScrollBar* pScrollBar = m_pScrollArea->horizontalScrollBar())
103 pScrollBar->setPageStep(nSize);
107 void QtInstanceScrolledWindow::hadjustment_set_step_increment(int nSize)
109 SolarMutexGuard g;
111 GetQtInstance().RunInMainThread([&] {
112 if (QScrollBar* pScrollBar = m_pScrollArea->horizontalScrollBar())
113 pScrollBar->setSingleStep(nSize);
117 void QtInstanceScrolledWindow::set_hpolicy(VclPolicyType eHPolicy)
119 SolarMutexGuard g;
121 GetQtInstance().RunInMainThread(
122 [&] { m_pScrollArea->setHorizontalScrollBarPolicy(toQtPolicy(eHPolicy)); });
125 VclPolicyType QtInstanceScrolledWindow::get_hpolicy() const
127 SolarMutexGuard g;
129 VclPolicyType ePolicy = VclPolicyType::AUTOMATIC;
130 GetQtInstance().RunInMainThread(
131 [&] { ePolicy = toVclPolicy(m_pScrollArea->horizontalScrollBarPolicy()); });
133 return ePolicy;
136 void QtInstanceScrolledWindow::vadjustment_configure(int, int, int, int, int, int)
138 assert(false && "Not implemented yet");
141 int QtInstanceScrolledWindow::vadjustment_get_value() const
143 SolarMutexGuard g;
145 int nValue = 0;
146 GetQtInstance().RunInMainThread([&] {
147 if (QScrollBar* pScrollBar = m_pScrollArea->verticalScrollBar())
148 nValue = pScrollBar->value();
151 return nValue;
154 void QtInstanceScrolledWindow::vadjustment_set_value(int nValue)
156 SolarMutexGuard g;
158 GetQtInstance().RunInMainThread([&] {
159 if (QScrollBar* pScrollBar = m_pScrollArea->verticalScrollBar())
160 pScrollBar->setValue(nValue);
164 int QtInstanceScrolledWindow::vadjustment_get_upper() const
166 SolarMutexGuard g;
168 int nMax = 0;
169 GetQtInstance().RunInMainThread([&] {
170 if (QScrollBar* pScrollBar = m_pScrollArea->verticalScrollBar())
171 nMax = pScrollBar->maximum();
174 return nMax;
177 void QtInstanceScrolledWindow::vadjustment_set_upper(int nUpper)
179 SolarMutexGuard g;
181 GetQtInstance().RunInMainThread([&] {
182 if (QScrollBar* pScrollBar = m_pScrollArea->verticalScrollBar())
183 pScrollBar->setMaximum(nUpper);
187 int QtInstanceScrolledWindow::vadjustment_get_page_size() const
189 assert(false && "Not implemented yet");
190 return 0;
193 void QtInstanceScrolledWindow::vadjustment_set_page_size(int)
195 assert(false && "Not implemented yet");
198 void QtInstanceScrolledWindow::vadjustment_set_page_increment(int nSize)
200 SolarMutexGuard g;
202 GetQtInstance().RunInMainThread([&] {
203 if (QScrollBar* pScrollBar = m_pScrollArea->verticalScrollBar())
204 pScrollBar->setPageStep(nSize);
208 void QtInstanceScrolledWindow::vadjustment_set_step_increment(int nSize)
210 SolarMutexGuard g;
212 GetQtInstance().RunInMainThread([&] {
213 if (QScrollBar* pScrollBar = m_pScrollArea->verticalScrollBar())
214 pScrollBar->setSingleStep(nSize);
218 int QtInstanceScrolledWindow::vadjustment_get_lower() const
220 SolarMutexGuard g;
222 int nMin = 0;
223 GetQtInstance().RunInMainThread([&] {
224 if (QScrollBar* pScrollBar = m_pScrollArea->verticalScrollBar())
225 nMin = pScrollBar->minimum();
228 return nMin;
231 void QtInstanceScrolledWindow::vadjustment_set_lower(int nLower)
233 SolarMutexGuard g;
235 GetQtInstance().RunInMainThread([&] {
236 if (QScrollBar* pScrollBar = m_pScrollArea->verticalScrollBar())
237 pScrollBar->setMinimum(nLower);
241 void QtInstanceScrolledWindow::set_vpolicy(VclPolicyType eVPolicy)
243 SolarMutexGuard g;
245 GetQtInstance().RunInMainThread(
246 [&] { m_pScrollArea->setVerticalScrollBarPolicy(toQtPolicy(eVPolicy)); });
249 VclPolicyType QtInstanceScrolledWindow::get_vpolicy() const
251 SolarMutexGuard g;
253 VclPolicyType ePolicy = VclPolicyType::AUTOMATIC;
254 GetQtInstance().RunInMainThread(
255 [&] { ePolicy = toVclPolicy(m_pScrollArea->verticalScrollBarPolicy()); });
257 return ePolicy;
260 int QtInstanceScrolledWindow::get_scroll_thickness() const
262 SolarMutexGuard g;
264 int nThickness = 0;
265 GetQtInstance().RunInMainThread([&] {
266 if (QScrollBar* pVerticalScrollBar = m_pScrollArea->verticalScrollBar())
267 nThickness = pVerticalScrollBar->width();
268 else if (QScrollBar* pHorizontalScrollBar = m_pScrollArea->horizontalScrollBar())
269 nThickness = pHorizontalScrollBar->height();
272 return nThickness;
275 void QtInstanceScrolledWindow::set_scroll_thickness(int nThickness)
277 SolarMutexGuard g;
279 GetQtInstance().RunInMainThread([&] {
280 if (QScrollBar* pVerticalScrollBar = m_pScrollArea->verticalScrollBar())
281 pVerticalScrollBar->resize(nThickness, pVerticalScrollBar->height());
282 else if (QScrollBar* pHorizontalScrollBar = m_pScrollArea->horizontalScrollBar())
283 pHorizontalScrollBar->resize(pHorizontalScrollBar->width(), nThickness);
287 void QtInstanceScrolledWindow::customize_scrollbars(const Color&, const Color&, const Color&)
289 assert(false && "Not implemented yet");
292 Qt::ScrollBarPolicy QtInstanceScrolledWindow::toQtPolicy(VclPolicyType eVclPolicy)
294 switch (eVclPolicy)
296 case VclPolicyType::ALWAYS:
297 return Qt::ScrollBarAlwaysOn;
298 case VclPolicyType::AUTOMATIC:
299 return Qt::ScrollBarAsNeeded;
300 case VclPolicyType::NEVER:
301 return Qt::ScrollBarAlwaysOff;
302 default:
303 assert(false && "Unhandled scroll bar policy");
304 return Qt::ScrollBarAsNeeded;
308 VclPolicyType QtInstanceScrolledWindow::toVclPolicy(Qt::ScrollBarPolicy eQtPolicy)
310 switch (eQtPolicy)
312 case Qt::ScrollBarAlwaysOn:
313 return VclPolicyType::ALWAYS;
314 case Qt::ScrollBarAsNeeded:
315 return VclPolicyType::AUTOMATIC;
316 case Qt::ScrollBarAlwaysOff:
317 return VclPolicyType::NEVER;
318 default:
319 assert(false && "Unhandled scroll bar policy");
320 return VclPolicyType::AUTOMATIC;
324 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */