/src/libreoffice/sc/source/ui/cctrl/tbzoomsliderctrl.cxx
Line | Count | Source |
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 | | #include <tbzoomsliderctrl.hxx> |
20 | | #include <i18nutil/unicode.hxx> |
21 | | #include <vcl/svapp.hxx> |
22 | | |
23 | | #include <comphelper/propertyvalue.hxx> |
24 | | #include <utility> |
25 | | #include <vcl/InterimItemWindow.hxx> |
26 | | #include <vcl/event.hxx> |
27 | | #include <vcl/image.hxx> |
28 | | #include <vcl/toolbox.hxx> |
29 | | #include <vcl/virdev.hxx> |
30 | | #include <svx/zoomslideritem.hxx> |
31 | | #include <iterator> |
32 | | #include <set> |
33 | | #include <bitmaps.hlst> |
34 | | |
35 | | #include <com/sun/star/frame/XFrame.hpp> |
36 | | #include <com/sun/star/frame/XDispatchProvider.hpp> |
37 | | |
38 | | // class ScZoomSliderControl --------------------------------------- |
39 | | |
40 | | SFX_IMPL_TOOLBOX_CONTROL( ScZoomSliderControl, SvxZoomSliderItem ); |
41 | | |
42 | | ScZoomSliderControl::ScZoomSliderControl( |
43 | | sal_uInt16 nSlotId, |
44 | | ToolBoxItemId nId, |
45 | | ToolBox& rTbx ) |
46 | 0 | :SfxToolBoxControl( nSlotId, nId, rTbx ) |
47 | 0 | { |
48 | 0 | rTbx.Invalidate(); |
49 | 0 | } |
50 | | |
51 | | ScZoomSliderControl::~ScZoomSliderControl() |
52 | 0 | { |
53 | |
|
54 | 0 | } |
55 | | |
56 | | void ScZoomSliderControl::StateChangedAtToolBoxControl( sal_uInt16 /*nSID*/, SfxItemState eState, |
57 | | const SfxPoolItem* pState ) |
58 | 0 | { |
59 | 0 | ToolBoxItemId nId = GetId(); |
60 | 0 | ToolBox& rTbx = GetToolBox(); |
61 | 0 | ScZoomSliderWnd* pBox = static_cast<ScZoomSliderWnd*>(rTbx.GetItemWindow( nId )); |
62 | 0 | OSL_ENSURE( pBox ,"Control not found!" ); |
63 | |
|
64 | 0 | if (SfxItemState::DEFAULT != eState || SfxItemState::DISABLED == eState) |
65 | 0 | { |
66 | 0 | SvxZoomSliderItem aZoomSliderItem( 100 ); |
67 | 0 | pBox->Disable(); |
68 | 0 | pBox->UpdateFromItem( &aZoomSliderItem ); |
69 | 0 | } |
70 | 0 | else |
71 | 0 | { |
72 | 0 | pBox->Enable(); |
73 | 0 | OSL_ENSURE( dynamic_cast<const SvxZoomSliderItem*>( pState) != nullptr, "invalid item type" ); |
74 | 0 | const SvxZoomSliderItem* pZoomSliderItem = dynamic_cast< const SvxZoomSliderItem* >( pState ); |
75 | |
|
76 | 0 | OSL_ENSURE( pZoomSliderItem, "Sc::ScZoomSliderControl::StateChanged(), wrong item type!" ); |
77 | 0 | if( pZoomSliderItem ) |
78 | 0 | pBox->UpdateFromItem( pZoomSliderItem ); |
79 | 0 | } |
80 | 0 | } |
81 | | |
82 | | VclPtr<InterimItemWindow> ScZoomSliderControl::CreateItemWindow( vcl::Window *pParent ) |
83 | 0 | { |
84 | | // #i98000# Don't try to get a value via SfxViewFrame::Current here. |
85 | | // The view's value is always notified via StateChanged later. |
86 | 0 | VclPtrInstance<ScZoomSliderWnd> xSlider( pParent, |
87 | 0 | css::uno::Reference< css::frame::XDispatchProvider >( m_xFrame->getController(), |
88 | 0 | css::uno::UNO_QUERY ), 100 ); |
89 | 0 | return xSlider; |
90 | 0 | } |
91 | | |
92 | | constexpr sal_uInt16 gnSliderCenter(100); |
93 | | |
94 | | const tools::Long nButtonWidth = 10; |
95 | | const tools::Long nButtonHeight = 10; |
96 | | const tools::Long nIncDecWidth = 11; |
97 | | const tools::Long nIncDecHeight = 11; |
98 | | const tools::Long nSliderHeight = 2; |
99 | | const tools::Long nSliderWidth = 4; |
100 | | const tools::Long nSnappingHeight = 4; |
101 | | const tools::Long nSliderXOffset = 20; |
102 | | const tools::Long nSnappingEpsilon = 5; // snapping epsilon in pixels |
103 | | const tools::Long nSnappingPointsMinDist = nSnappingEpsilon; // minimum distance of two adjacent snapping points |
104 | | |
105 | | sal_uInt16 ScZoomSlider::Offset2Zoom( tools::Long nOffset ) const |
106 | 0 | { |
107 | 0 | const tools::Long nControlWidth = GetSliderLength(); |
108 | 0 | sal_uInt16 nRet = 0; |
109 | |
|
110 | 0 | if( nOffset < nSliderXOffset ) |
111 | 0 | return mnMinZoom; |
112 | 0 | if( nOffset > nControlWidth - nSliderXOffset ) |
113 | 0 | return mnMaxZoom; |
114 | | |
115 | | // check for snapping points: |
116 | 0 | auto aSnappingPointIter = std::find_if(maSnappingPointOffsets.begin(), maSnappingPointOffsets.end(), |
117 | 0 | [nOffset](const tools::Long nCurrent) { return std::abs(nCurrent - nOffset) < nSnappingEpsilon; }); |
118 | 0 | if (aSnappingPointIter != maSnappingPointOffsets.end()) |
119 | 0 | { |
120 | 0 | nOffset = *aSnappingPointIter; |
121 | 0 | auto nCount = static_cast<sal_uInt16>(std::distance(maSnappingPointOffsets.begin(), aSnappingPointIter)); |
122 | 0 | nRet = maSnappingPointZooms[ nCount ]; |
123 | 0 | } |
124 | |
|
125 | 0 | if( 0 == nRet ) |
126 | 0 | { |
127 | 0 | if( nOffset < nControlWidth / 2 ) |
128 | 0 | { |
129 | | // first half of slider |
130 | 0 | const tools::Long nFirstHalfRange = gnSliderCenter - mnMinZoom; |
131 | 0 | const tools::Long nHalfSliderWidth = nControlWidth/2 - nSliderXOffset; |
132 | 0 | const tools::Long nZoomPerSliderPixel = (1000 * nFirstHalfRange) / nHalfSliderWidth; |
133 | 0 | const tools::Long nOffsetToSliderLeft = nOffset - nSliderXOffset; |
134 | 0 | nRet = mnMinZoom + sal_uInt16( nOffsetToSliderLeft * nZoomPerSliderPixel / 1000 ); |
135 | 0 | } |
136 | 0 | else |
137 | 0 | { |
138 | | // second half of slider |
139 | 0 | const tools::Long nSecondHalfRange = mnMaxZoom - gnSliderCenter; |
140 | 0 | const tools::Long nHalfSliderWidth = nControlWidth/2 - nSliderXOffset; |
141 | 0 | const tools::Long nZoomPerSliderPixel = 1000 * nSecondHalfRange / nHalfSliderWidth; |
142 | 0 | const tools::Long nOffsetToSliderCenter = nOffset - nControlWidth/2; |
143 | 0 | nRet = gnSliderCenter + sal_uInt16( nOffsetToSliderCenter * nZoomPerSliderPixel / 1000 ); |
144 | 0 | } |
145 | 0 | } |
146 | |
|
147 | 0 | if( nRet < mnMinZoom ) |
148 | 0 | return mnMinZoom; |
149 | | |
150 | 0 | else if( nRet > mnMaxZoom ) |
151 | 0 | return mnMaxZoom; |
152 | | |
153 | 0 | return nRet; |
154 | 0 | } |
155 | | |
156 | | tools::Long ScZoomSlider::Zoom2Offset( sal_uInt16 nCurrentZoom ) const |
157 | 0 | { |
158 | 0 | const tools::Long nControlWidth = GetSliderLength(); |
159 | 0 | tools::Long nRect = nSliderXOffset; |
160 | |
|
161 | 0 | const tools::Long nHalfSliderWidth = nControlWidth/2 - nSliderXOffset; |
162 | 0 | if( nCurrentZoom <= gnSliderCenter ) |
163 | 0 | { |
164 | 0 | nCurrentZoom = nCurrentZoom - mnMinZoom; |
165 | 0 | const tools::Long nFirstHalfRange = gnSliderCenter - mnMinZoom; |
166 | 0 | const tools::Long nSliderPixelPerZoomPercent = 1000 * nHalfSliderWidth / nFirstHalfRange; |
167 | 0 | const tools::Long nOffset = (nSliderPixelPerZoomPercent * nCurrentZoom) / 1000; |
168 | 0 | nRect += nOffset; |
169 | 0 | } |
170 | 0 | else |
171 | 0 | { |
172 | 0 | nCurrentZoom = nCurrentZoom - gnSliderCenter; |
173 | 0 | const tools::Long nSecondHalfRange = mnMaxZoom - gnSliderCenter; |
174 | 0 | const tools::Long nSliderPixelPerZoomPercent = 1000 * nHalfSliderWidth / nSecondHalfRange; |
175 | 0 | const tools::Long nOffset = (nSliderPixelPerZoomPercent * nCurrentZoom) / 1000; |
176 | 0 | nRect += nHalfSliderWidth + nOffset; |
177 | 0 | } |
178 | 0 | return nRect; |
179 | 0 | } |
180 | | |
181 | | ScZoomSliderWnd::ScZoomSliderWnd( vcl::Window* pParent, |
182 | | const css::uno::Reference< css::frame::XDispatchProvider >& rDispatchProvider, |
183 | | sal_uInt16 nCurrentZoom ): |
184 | 0 | InterimItemWindow(pParent, u"modules/scalc/ui/zoombox.ui"_ustr, u"ZoomBox"_ustr), |
185 | 0 | mxWidget(new ScZoomSlider(rDispatchProvider, nCurrentZoom)), |
186 | 0 | mxPercentage(m_xBuilder->weld_label(u"current_zoom"_ustr)), |
187 | 0 | mxLabel(m_xBuilder->weld_label(u"zoom_label"_ustr)), |
188 | 0 | mxWeld(new weld::CustomWeld(*m_xBuilder, u"zoom"_ustr, *mxWidget)) |
189 | 0 | { |
190 | 0 | Size aLogicalSize( 115, 40 ); |
191 | 0 | Size aSliderSize = LogicToPixel(aLogicalSize, MapMode(MapUnit::Map10thMM)); |
192 | 0 | Size aPreferredSize(aSliderSize.Width() * nSliderWidth-1, aSliderSize.Height() + nSliderHeight); |
193 | 0 | mxWidget->GetDrawingArea()->set_size_request(aPreferredSize.Width(), aPreferredSize.Height()); |
194 | 0 | mxWidget->SetOutputSizePixel(aPreferredSize); |
195 | 0 | mxWidget->SetSliderLength(aPreferredSize.Width() + nIncDecWidth); |
196 | |
|
197 | 0 | aPreferredSize.setWidth(aPreferredSize.Width() + mxLabel->get_pixel_size(mxLabel->get_label()).Width() |
198 | 0 | + mxPercentage->get_pixel_size(mxPercentage->get_label()).Width()); |
199 | |
|
200 | 0 | SetSizePixel(aPreferredSize); |
201 | 0 | OUString sCurrentZoom(unicode::formatPercent(nCurrentZoom, Application::GetSettings().GetUILanguageTag())); |
202 | 0 | mxPercentage->set_label(sCurrentZoom); |
203 | 0 | } Unexecuted instantiation: ScZoomSliderWnd::ScZoomSliderWnd(vcl::Window*, com::sun::star::uno::Reference<com::sun::star::frame::XDispatchProvider> const&, unsigned short) Unexecuted instantiation: ScZoomSliderWnd::ScZoomSliderWnd(vcl::Window*, com::sun::star::uno::Reference<com::sun::star::frame::XDispatchProvider> const&, unsigned short) |
204 | | |
205 | | ScZoomSliderWnd::~ScZoomSliderWnd() |
206 | 0 | { |
207 | 0 | disposeOnce(); |
208 | 0 | } |
209 | | |
210 | | void ScZoomSliderWnd::dispose() |
211 | 0 | { |
212 | 0 | mxWeld.reset(); |
213 | 0 | mxWidget.reset(); |
214 | 0 | InterimItemWindow::dispose(); |
215 | 0 | } |
216 | | |
217 | | ScZoomSlider::ScZoomSlider(css::uno::Reference< css::frame::XDispatchProvider> xDispatchProvider, |
218 | | sal_uInt16 nCurrentZoom) |
219 | 0 | : mnSliderLength(0) |
220 | 0 | , mnCurrentZoom(nCurrentZoom) |
221 | 0 | , mnMinZoom(10) |
222 | 0 | , mnMaxZoom(400) |
223 | 0 | , mbOmitPaint(false) |
224 | 0 | , m_xDispatchProvider(std::move(xDispatchProvider)) |
225 | 0 | { |
226 | 0 | maSliderButton = Image(StockImage::Yes, RID_SVXBMP_SLIDERBUTTON); |
227 | 0 | maIncreaseButton = Image(StockImage::Yes, RID_SVXBMP_SLIDERINCREASE); |
228 | 0 | maDecreaseButton = Image(StockImage::Yes, RID_SVXBMP_SLIDERDECREASE); |
229 | 0 | } |
230 | | |
231 | | |
232 | | bool ScZoomSlider::MouseButtonDown( const MouseEvent& rMEvt ) |
233 | 0 | { |
234 | 0 | Size aSliderWindowSize = GetOutputSizePixel(); |
235 | |
|
236 | 0 | const Point aPoint = rMEvt.GetPosPixel(); |
237 | |
|
238 | 0 | const tools::Long nButtonLeftOffset = ( nSliderXOffset - nIncDecWidth )/2; |
239 | 0 | const tools::Long nButtonRightOffset = ( nSliderXOffset + nIncDecWidth )/2; |
240 | |
|
241 | 0 | const tools::Long nOldZoom = mnCurrentZoom; |
242 | | |
243 | | // click to - button |
244 | 0 | if ( aPoint.X() >= nButtonLeftOffset && aPoint.X() <= nButtonRightOffset ) |
245 | 0 | { |
246 | 0 | mnCurrentZoom = mnCurrentZoom - 5; |
247 | 0 | } |
248 | | // click to + button |
249 | 0 | else if ( aPoint.X() >= GetSliderLength() - nSliderXOffset + nButtonLeftOffset && |
250 | 0 | aPoint.X() <= GetSliderLength() - nSliderXOffset + nButtonRightOffset ) |
251 | 0 | { |
252 | 0 | mnCurrentZoom = mnCurrentZoom + 5; |
253 | 0 | } |
254 | 0 | else if( aPoint.X() >= nSliderXOffset && aPoint.X() <= GetSliderLength() - nSliderXOffset ) |
255 | 0 | { |
256 | 0 | mnCurrentZoom = Offset2Zoom( aPoint.X() ); |
257 | 0 | } |
258 | |
|
259 | 0 | if( mnCurrentZoom < mnMinZoom ) |
260 | 0 | mnCurrentZoom = mnMinZoom; |
261 | 0 | else if( mnCurrentZoom > mnMaxZoom ) |
262 | 0 | mnCurrentZoom = mnMaxZoom; |
263 | |
|
264 | 0 | if( nOldZoom == mnCurrentZoom ) |
265 | 0 | return true; |
266 | | |
267 | 0 | tools::Rectangle aRect( Point( 0, 0 ), aSliderWindowSize ); |
268 | |
|
269 | 0 | Invalidate(aRect); |
270 | 0 | mbOmitPaint = true; |
271 | |
|
272 | 0 | SvxZoomSliderItem aZoomSliderItem( mnCurrentZoom ); |
273 | |
|
274 | 0 | css::uno::Any a; |
275 | 0 | aZoomSliderItem.QueryValue( a ); |
276 | |
|
277 | 0 | css::uno::Sequence aArgs{ comphelper::makePropertyValue(u"ScalingFactor"_ustr, a) }; |
278 | |
|
279 | 0 | SfxToolBoxControl::Dispatch( m_xDispatchProvider, u".uno:ScalingFactor"_ustr, aArgs ); |
280 | |
|
281 | 0 | mbOmitPaint = false; |
282 | |
|
283 | 0 | return true; |
284 | 0 | } |
285 | | |
286 | | bool ScZoomSlider::MouseMove( const MouseEvent& rMEvt ) |
287 | 0 | { |
288 | 0 | Size aSliderWindowSize = GetOutputSizePixel(); |
289 | 0 | const tools::Long nControlWidth = GetSliderLength(); |
290 | 0 | const short nButtons = rMEvt.GetButtons(); |
291 | | |
292 | | // check mouse move with button pressed |
293 | 0 | if ( 1 == nButtons ) |
294 | 0 | { |
295 | 0 | const Point aPoint = rMEvt.GetPosPixel(); |
296 | |
|
297 | 0 | if ( aPoint.X() >= nSliderXOffset && aPoint.X() <= nControlWidth - nSliderXOffset ) |
298 | 0 | { |
299 | 0 | mnCurrentZoom = Offset2Zoom( aPoint.X() ); |
300 | |
|
301 | 0 | tools::Rectangle aRect(Point(0, 0), aSliderWindowSize); |
302 | 0 | Invalidate(aRect); |
303 | |
|
304 | 0 | mbOmitPaint = true; // optimization: paint before executing command, |
305 | | |
306 | | // commit state change |
307 | 0 | SvxZoomSliderItem aZoomSliderItem( mnCurrentZoom ); |
308 | |
|
309 | 0 | css::uno::Any a; |
310 | 0 | aZoomSliderItem.QueryValue( a ); |
311 | |
|
312 | 0 | css::uno::Sequence aArgs{ comphelper::makePropertyValue(u"ScalingFactor"_ustr, a) }; |
313 | |
|
314 | 0 | SfxToolBoxControl::Dispatch( m_xDispatchProvider, u".uno:ScalingFactor"_ustr, aArgs ); |
315 | |
|
316 | 0 | mbOmitPaint = false; |
317 | 0 | } |
318 | 0 | } |
319 | |
|
320 | 0 | return false; |
321 | 0 | } |
322 | | |
323 | | void ScZoomSliderWnd::UpdateFromItem( const SvxZoomSliderItem* pZoomSliderItem ) |
324 | 0 | { |
325 | 0 | OUString sCurrentZoom(unicode::formatPercent(pZoomSliderItem->GetValue(), Application::GetSettings().GetUILanguageTag())); |
326 | 0 | mxPercentage->set_label(sCurrentZoom); |
327 | 0 | mxWidget->UpdateFromItem(pZoomSliderItem); |
328 | 0 | } |
329 | | |
330 | | void ScZoomSlider::UpdateFromItem(const SvxZoomSliderItem* pZoomSliderItem) |
331 | 0 | { |
332 | 0 | if( pZoomSliderItem ) |
333 | 0 | { |
334 | 0 | mnCurrentZoom = pZoomSliderItem->GetValue(); |
335 | 0 | mnMinZoom = pZoomSliderItem->GetMinZoom(); |
336 | 0 | mnMaxZoom = pZoomSliderItem->GetMaxZoom(); |
337 | |
|
338 | 0 | OSL_ENSURE( mnMinZoom <= mnCurrentZoom && |
339 | 0 | mnMinZoom < gnSliderCenter && |
340 | 0 | mnMaxZoom >= mnCurrentZoom && |
341 | 0 | mnMaxZoom > gnSliderCenter, |
342 | 0 | "Looks like the zoom slider item is corrupted" ); |
343 | 0 | const css::uno::Sequence < sal_Int32 >& rSnappingPoints = pZoomSliderItem->GetSnappingPoints(); |
344 | 0 | maSnappingPointOffsets.clear(); |
345 | 0 | maSnappingPointZooms.clear(); |
346 | | |
347 | | // get all snapping points: |
348 | 0 | std::set< sal_uInt16 > aTmpSnappingPoints; |
349 | 0 | std::transform(rSnappingPoints.begin(), rSnappingPoints.end(), std::inserter(aTmpSnappingPoints, aTmpSnappingPoints.end()), |
350 | 0 | [](const sal_Int32 nSnappingPoint) -> sal_uInt16 { return static_cast<sal_uInt16>(nSnappingPoint); }); |
351 | | |
352 | | // remove snapping points that are too close to each other: |
353 | 0 | tools::Long nLastOffset = 0; |
354 | |
|
355 | 0 | for ( const sal_uInt16 nCurrent : aTmpSnappingPoints ) |
356 | 0 | { |
357 | 0 | const tools::Long nCurrentOffset = Zoom2Offset( nCurrent ); |
358 | |
|
359 | 0 | if ( nCurrentOffset - nLastOffset >= nSnappingPointsMinDist ) |
360 | 0 | { |
361 | 0 | maSnappingPointOffsets.push_back( nCurrentOffset ); |
362 | 0 | maSnappingPointZooms.push_back( nCurrent ); |
363 | 0 | nLastOffset = nCurrentOffset; |
364 | 0 | } |
365 | 0 | } |
366 | 0 | } |
367 | |
|
368 | 0 | Size aSliderWindowSize = GetOutputSizePixel(); |
369 | 0 | tools::Rectangle aRect(Point(0, 0), aSliderWindowSize); |
370 | |
|
371 | 0 | if ( !mbOmitPaint ) |
372 | 0 | Invalidate(aRect); |
373 | 0 | } |
374 | | |
375 | | void ScZoomSlider::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle& /*rRect*/) |
376 | 0 | { |
377 | 0 | DoPaint(rRenderContext); |
378 | 0 | } |
379 | | |
380 | | void ScZoomSlider::DoPaint(vcl::RenderContext& rRenderContext) |
381 | 0 | { |
382 | 0 | if (mbOmitPaint) |
383 | 0 | return; |
384 | | |
385 | 0 | Size aSliderWindowSize(GetOutputSizePixel()); |
386 | 0 | tools::Rectangle aRect(Point(0, 0), aSliderWindowSize); |
387 | |
|
388 | 0 | ScopedVclPtrInstance< VirtualDevice > pVDev(rRenderContext); |
389 | 0 | pVDev->SetOutputSizePixel(aSliderWindowSize); |
390 | |
|
391 | 0 | tools::Rectangle aSlider = aRect; |
392 | 0 | aSlider.setWidth(GetSliderLength()); |
393 | |
|
394 | 0 | aSlider.AdjustTop((aSliderWindowSize.Height() - nSliderHeight) / 2 - 1 ); |
395 | 0 | aSlider.SetBottom( aSlider.Top() + nSliderHeight ); |
396 | 0 | aSlider.AdjustLeft(nSliderXOffset ); |
397 | 0 | aSlider.AdjustRight( -nSliderXOffset ); |
398 | |
|
399 | 0 | tools::Rectangle aFirstLine(aSlider); |
400 | 0 | aFirstLine.SetBottom( aFirstLine.Top() ); |
401 | |
|
402 | 0 | tools::Rectangle aSecondLine(aSlider); |
403 | 0 | aSecondLine.SetTop( aSecondLine.Bottom() ); |
404 | |
|
405 | 0 | tools::Rectangle aLeft(aSlider); |
406 | 0 | aLeft.SetRight( aLeft.Left() ); |
407 | |
|
408 | 0 | tools::Rectangle aRight(aSlider); |
409 | 0 | aRight.SetLeft( aRight.Right() ); |
410 | | |
411 | | // draw VirtualDevice's background color |
412 | 0 | Color aStartColor = rRenderContext.GetSettings().GetStyleSettings().GetFaceColor(); |
413 | 0 | Color aEndColor = rRenderContext.GetSettings().GetStyleSettings().GetFaceColor(); |
414 | |
|
415 | 0 | if (aEndColor.IsDark()) |
416 | 0 | aStartColor = aEndColor; |
417 | |
|
418 | 0 | Gradient aGradient; |
419 | 0 | aGradient.SetAngle(0_deg10); |
420 | 0 | aGradient.SetStyle(css::awt::GradientStyle_LINEAR); |
421 | |
|
422 | 0 | aGradient.SetStartColor(aStartColor); |
423 | 0 | aGradient.SetEndColor(aEndColor); |
424 | 0 | pVDev->DrawGradient(aRect, aGradient); |
425 | | |
426 | | // draw slider |
427 | 0 | pVDev->SetLineColor(COL_WHITE); |
428 | 0 | pVDev->DrawRect(aSecondLine); |
429 | 0 | pVDev->DrawRect(aRight); |
430 | |
|
431 | 0 | pVDev->SetLineColor(COL_GRAY); |
432 | 0 | pVDev->DrawRect(aFirstLine); |
433 | 0 | pVDev->DrawRect(aLeft); |
434 | | |
435 | | // draw snapping points: |
436 | 0 | for (const auto& rSnappingPointOffset : maSnappingPointOffsets) |
437 | 0 | { |
438 | 0 | pVDev->SetLineColor(COL_GRAY); |
439 | 0 | tools::Rectangle aSnapping(aRect); |
440 | 0 | aSnapping.SetBottom( aSlider.Top() ); |
441 | 0 | aSnapping.SetTop( aSnapping.Bottom() - nSnappingHeight ); |
442 | 0 | aSnapping.AdjustLeft(rSnappingPointOffset ); |
443 | 0 | aSnapping.SetRight( aSnapping.Left() ); |
444 | 0 | pVDev->DrawRect(aSnapping); |
445 | |
|
446 | 0 | aSnapping.AdjustTop(nSnappingHeight + nSliderHeight ); |
447 | 0 | aSnapping.AdjustBottom(nSnappingHeight + nSliderHeight ); |
448 | 0 | pVDev->DrawRect(aSnapping); |
449 | 0 | } |
450 | | |
451 | | // draw slider button |
452 | 0 | Point aImagePoint = aRect.TopLeft(); |
453 | 0 | aImagePoint.AdjustX(Zoom2Offset(mnCurrentZoom) ); |
454 | 0 | aImagePoint.AdjustX( -(nButtonWidth / 2) ); |
455 | 0 | aImagePoint.AdjustY( (aSliderWindowSize.Height() - nButtonHeight) / 2 ); |
456 | 0 | pVDev->DrawImage(aImagePoint, maSliderButton); |
457 | | |
458 | | // draw decrease button |
459 | 0 | aImagePoint = aRect.TopLeft(); |
460 | 0 | aImagePoint.AdjustX((nSliderXOffset - nIncDecWidth) / 2 ); |
461 | 0 | aImagePoint.AdjustY((aSliderWindowSize.Height() - nIncDecHeight) / 2 ); |
462 | 0 | pVDev->DrawImage(aImagePoint, maDecreaseButton); |
463 | | |
464 | | // draw increase button |
465 | 0 | aImagePoint.setX( aRect.Left() + GetSliderLength() - nIncDecWidth - (nSliderXOffset - nIncDecWidth) / 2 ); |
466 | 0 | pVDev->DrawImage(aImagePoint, maIncreaseButton); |
467 | |
|
468 | 0 | rRenderContext.DrawOutDev(Point(0, 0), aSliderWindowSize, Point(0, 0), aSliderWindowSize, *pVDev); |
469 | 0 | } |
470 | | |
471 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |