1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
9 * This file incorporates work covered by the following license notice:
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 .
22 #include <vcl/customweld.hxx>
23 #include <vcl/graph.hxx>
24 #include <sfx2/tabdlg.hxx>
26 class SvxCropExample
: public weld::CustomWidgetController
30 Point m_aTopLeft
, m_aBottomRight
;
36 virtual void Paint(vcl::RenderContext
& rRenderContext
, const ::tools::Rectangle
& rRect
) override
;
37 virtual void Resize() override
;
38 virtual void SetDrawingArea(weld::DrawingArea
* pDrawingArea
) override
;
40 void SetTop( tools::Long nVal
) { m_aTopLeft
.setX(nVal
); }
41 void SetBottom( tools::Long nVal
) { m_aBottomRight
.setX(nVal
); }
42 void SetLeft( tools::Long nVal
) { m_aTopLeft
.setY(nVal
); }
43 void SetRight( tools::Long nVal
) { m_aBottomRight
.setY(nVal
); }
44 void SetFrameSize( const Size
& rSz
);
45 void SetGraphic( const Graphic
& rGrf
) { m_aGrf
= rGrf
; }
48 class SvxGrfCropPage
: public SfxTabPage
50 friend class VclPtr
<SvxGrfCropPage
>;
52 OUString m_aGraphicName
;
54 Size m_aOrigPixelSize
;
56 tools::Long m_nOldWidth
;
57 tools::Long m_nOldHeight
;
59 sal_Int32 m_aPreferredDPI
;
61 SvxCropExample m_aExampleWN
;
63 std::unique_ptr
<weld::Widget
> m_xCropFrame
;
64 std::unique_ptr
<weld::RadioButton
> m_xZoomConstRB
;
65 std::unique_ptr
<weld::RadioButton
> m_xSizeConstRB
;
66 std::unique_ptr
<weld::MetricSpinButton
> m_xLeftMF
;
67 std::unique_ptr
<weld::MetricSpinButton
> m_xRightMF
;
68 std::unique_ptr
<weld::MetricSpinButton
> m_xTopMF
;
69 std::unique_ptr
<weld::MetricSpinButton
> m_xBottomMF
;
71 std::unique_ptr
<weld::Widget
> m_xScaleFrame
;
72 std::unique_ptr
<weld::MetricSpinButton
> m_xWidthZoomMF
;
73 std::unique_ptr
<weld::MetricSpinButton
> m_xHeightZoomMF
;
75 std::unique_ptr
<weld::Widget
> m_xSizeFrame
;
76 std::unique_ptr
<weld::MetricSpinButton
> m_xWidthMF
;
77 std::unique_ptr
<weld::MetricSpinButton
> m_xHeightMF
;
79 std::unique_ptr
<weld::Widget
> m_xOrigSizeGrid
;
80 std::unique_ptr
<weld::Label
> m_xOrigSizeFT
;
81 std::unique_ptr
<weld::Button
> m_xOrigSizePB
;
83 std::unique_ptr
<weld::Button
> m_xUncropPB
;
86 std::unique_ptr
<weld::CustomWeld
> m_xExampleWN
;
88 DECL_LINK(ZoomHdl
, weld::MetricSpinButton
&, void);
89 DECL_LINK(SizeHdl
, weld::MetricSpinButton
&, void);
90 DECL_LINK(CropModifyHdl
, weld::MetricSpinButton
&, void);
91 DECL_LINK(OrigSizeHdl
, weld::Button
&, void);
92 DECL_LINK(UncropHdl
, weld::Button
&, void);
95 void CalcMinMaxBorder();
96 void GraphicHasChanged(bool bFound
);
97 virtual void ActivatePage(const SfxItemSet
& rSet
) override
;
99 Size
GetGrfOrigSize(const Graphic
& rGraphic
);
101 SvxGrfCropPage(weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
&rSet
);
102 static std::unique_ptr
<SfxTabPage
> Create( weld::Container
* pPage
, weld::DialogController
* pController
, const SfxItemSet
*rSet
);
103 virtual ~SvxGrfCropPage() override
;
105 virtual bool FillItemSet( SfxItemSet
*rSet
) override
;
106 virtual void Reset( const SfxItemSet
*rSet
) override
;
107 virtual DeactivateRC
DeactivatePage( SfxItemSet
*pSet
) override
;
110 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */