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 <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");
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
45 GetQtInstance().RunInMainThread([&] {
46 if (QScrollBar
* pScrollBar
= m_pScrollArea
->horizontalScrollBar())
47 nValue
= pScrollBar
->value();
53 void QtInstanceScrolledWindow::hadjustment_set_value(int nValue
)
57 GetQtInstance().RunInMainThread([&] {
58 if (QScrollBar
* pScrollBar
= m_pScrollArea
->horizontalScrollBar())
59 pScrollBar
->setValue(nValue
);
63 int QtInstanceScrolledWindow::hadjustment_get_upper() const
68 GetQtInstance().RunInMainThread([&] {
69 if (QScrollBar
* pScrollBar
= m_pScrollArea
->horizontalScrollBar())
70 nMax
= pScrollBar
->maximum();
76 void QtInstanceScrolledWindow::hadjustment_set_upper(int nUpper
)
80 GetQtInstance().RunInMainThread([&] {
81 if (QScrollBar
* pScrollBar
= m_pScrollArea
->horizontalScrollBar())
82 pScrollBar
->setMaximum(nUpper
);
86 int QtInstanceScrolledWindow::hadjustment_get_page_size() const
88 assert(false && "Not implemented yet");
92 void QtInstanceScrolledWindow::hadjustment_set_page_size(int)
94 assert(false && "Not implemented yet");
97 void QtInstanceScrolledWindow::hadjustment_set_page_increment(int nSize
)
101 GetQtInstance().RunInMainThread([&] {
102 if (QScrollBar
* pScrollBar
= m_pScrollArea
->horizontalScrollBar())
103 pScrollBar
->setPageStep(nSize
);
107 void QtInstanceScrolledWindow::hadjustment_set_step_increment(int nSize
)
111 GetQtInstance().RunInMainThread([&] {
112 if (QScrollBar
* pScrollBar
= m_pScrollArea
->horizontalScrollBar())
113 pScrollBar
->setSingleStep(nSize
);
117 void QtInstanceScrolledWindow::set_hpolicy(VclPolicyType eHPolicy
)
121 GetQtInstance().RunInMainThread(
122 [&] { m_pScrollArea
->setHorizontalScrollBarPolicy(toQtPolicy(eHPolicy
)); });
125 VclPolicyType
QtInstanceScrolledWindow::get_hpolicy() const
129 VclPolicyType ePolicy
= VclPolicyType::AUTOMATIC
;
130 GetQtInstance().RunInMainThread(
131 [&] { ePolicy
= toVclPolicy(m_pScrollArea
->horizontalScrollBarPolicy()); });
136 void QtInstanceScrolledWindow::vadjustment_configure(int, int, int, int, int, int)
138 assert(false && "Not implemented yet");
141 int QtInstanceScrolledWindow::vadjustment_get_value() const
146 GetQtInstance().RunInMainThread([&] {
147 if (QScrollBar
* pScrollBar
= m_pScrollArea
->verticalScrollBar())
148 nValue
= pScrollBar
->value();
154 void QtInstanceScrolledWindow::vadjustment_set_value(int nValue
)
158 GetQtInstance().RunInMainThread([&] {
159 if (QScrollBar
* pScrollBar
= m_pScrollArea
->verticalScrollBar())
160 pScrollBar
->setValue(nValue
);
164 int QtInstanceScrolledWindow::vadjustment_get_upper() const
169 GetQtInstance().RunInMainThread([&] {
170 if (QScrollBar
* pScrollBar
= m_pScrollArea
->verticalScrollBar())
171 nMax
= pScrollBar
->maximum();
177 void QtInstanceScrolledWindow::vadjustment_set_upper(int nUpper
)
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");
193 void QtInstanceScrolledWindow::vadjustment_set_page_size(int)
195 assert(false && "Not implemented yet");
198 void QtInstanceScrolledWindow::vadjustment_set_page_increment(int nSize
)
202 GetQtInstance().RunInMainThread([&] {
203 if (QScrollBar
* pScrollBar
= m_pScrollArea
->verticalScrollBar())
204 pScrollBar
->setPageStep(nSize
);
208 void QtInstanceScrolledWindow::vadjustment_set_step_increment(int nSize
)
212 GetQtInstance().RunInMainThread([&] {
213 if (QScrollBar
* pScrollBar
= m_pScrollArea
->verticalScrollBar())
214 pScrollBar
->setSingleStep(nSize
);
218 int QtInstanceScrolledWindow::vadjustment_get_lower() const
223 GetQtInstance().RunInMainThread([&] {
224 if (QScrollBar
* pScrollBar
= m_pScrollArea
->verticalScrollBar())
225 nMin
= pScrollBar
->minimum();
231 void QtInstanceScrolledWindow::vadjustment_set_lower(int nLower
)
235 GetQtInstance().RunInMainThread([&] {
236 if (QScrollBar
* pScrollBar
= m_pScrollArea
->verticalScrollBar())
237 pScrollBar
->setMinimum(nLower
);
241 void QtInstanceScrolledWindow::set_vpolicy(VclPolicyType eVPolicy
)
245 GetQtInstance().RunInMainThread(
246 [&] { m_pScrollArea
->setVerticalScrollBarPolicy(toQtPolicy(eVPolicy
)); });
249 VclPolicyType
QtInstanceScrolledWindow::get_vpolicy() const
253 VclPolicyType ePolicy
= VclPolicyType::AUTOMATIC
;
254 GetQtInstance().RunInMainThread(
255 [&] { ePolicy
= toVclPolicy(m_pScrollArea
->verticalScrollBarPolicy()); });
260 int QtInstanceScrolledWindow::get_scroll_thickness() const
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();
275 void QtInstanceScrolledWindow::set_scroll_thickness(int nThickness
)
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
)
296 case VclPolicyType::ALWAYS
:
297 return Qt::ScrollBarAlwaysOn
;
298 case VclPolicyType::AUTOMATIC
:
299 return Qt::ScrollBarAsNeeded
;
300 case VclPolicyType::NEVER
:
301 return Qt::ScrollBarAlwaysOff
;
303 assert(false && "Unhandled scroll bar policy");
304 return Qt::ScrollBarAsNeeded
;
308 VclPolicyType
QtInstanceScrolledWindow::toVclPolicy(Qt::ScrollBarPolicy 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
;
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: */