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 .
20 #ifndef INCLUDED_CUI_SOURCE_INC_CUIGRFFLT_HXX
21 #define INCLUDED_CUI_SOURCE_INC_CUIGRFFLT_HXX
23 #include <vcl/timer.hxx>
24 #include <svx/dlgctrl.hxx>
25 #include <svx/rectenum.hxx>
27 class CuiGraphicPreviewWindow
: public weld::CustomWidgetController
30 const Graphic
* mpOrigGraphic
;
31 Size maOrigGraphicSizePixel
;
32 Size maOutputSizePixel
;
33 Link
<LinkParamNone
*,void> maModifyHdl
;
39 virtual void Paint(vcl::RenderContext
& rRenderContext
, const ::tools::Rectangle
& rRect
) override
;
40 virtual void Resize() override
;
42 void ScaleImageToFit();
45 CuiGraphicPreviewWindow();
46 virtual void SetDrawingArea(weld::DrawingArea
* pDrawingArea
) override
;
47 void init(const Graphic
* pOrigGraphic
, const Link
<LinkParamNone
*,void>& rLink
)
49 mpOrigGraphic
= pOrigGraphic
;
51 maOrigGraphicSizePixel
= GetDrawingArea()->get_ref_device().LogicToPixel(mpOrigGraphic
->GetPrefSize(),
52 mpOrigGraphic
->GetPrefMapMode());
56 void SetPreview(const Graphic
& rGraphic
);
57 const Graphic
& GetScaledOriginal() const { return maScaledOrig
; }
58 double GetScaleX() const { return mfScaleX
; }
59 double GetScaleY() const { return mfScaleY
; }
60 const Size
& GetGraphicSizePixel() const { return maOrigGraphicSizePixel
; }
63 class GraphicFilterDialog
: public weld::GenericDialogController
68 Link
<LinkParamNone
*,void> maModifyHdl
;
71 DECL_LINK( ImplPreviewTimeoutHdl
, Timer
*, void );
72 DECL_LINK( ImplModifyHdl
, LinkParamNone
*, void);
74 CuiGraphicPreviewWindow maPreview
;
75 std::unique_ptr
<weld::CustomWeld
> mxPreview
;
78 const Link
<LinkParamNone
*,void>& GetModifyHdl() const { return maModifyHdl
; }
79 const Size
& GetGraphicSizePixel() const { return maPreview
.GetGraphicSizePixel(); }
83 GraphicFilterDialog(weld::Window
* pParent
, const OUString
& rUIXMLDescription
, const OString
& rID
, const Graphic
& rGraphic
);
84 virtual Graphic
GetFilteredGraphic(const Graphic
& rGraphic
, double fScaleX
, double fScaleY
) = 0;
87 class GraphicFilterSmooth
: public GraphicFilterDialog
90 std::unique_ptr
<weld::SpinButton
> mxMtrRadius
;
91 DECL_LINK(EditModifyHdl
, weld::SpinButton
&, void);
95 GraphicFilterSmooth(weld::Window
* pParent
, const Graphic
& rGraphic
, double nRadius
);
96 virtual Graphic
GetFilteredGraphic( const Graphic
& rGraphic
, double fScaleX
, double fScaleY
) override
;
99 class GraphicFilterMosaic
: public GraphicFilterDialog
102 std::unique_ptr
<weld::MetricSpinButton
> mxMtrWidth
;
103 std::unique_ptr
<weld::MetricSpinButton
> mxMtrHeight
;
104 std::unique_ptr
<weld::CheckButton
> mxCbxEdges
;
105 DECL_LINK(CheckBoxModifyHdl
, weld::ToggleButton
&, void);
106 DECL_LINK(EditModifyHdl
, weld::MetricSpinButton
&, void);
109 GraphicFilterMosaic(weld::Window
* pParent
, const Graphic
& rGraphic
,
110 sal_uInt16 nTileWidth
, sal_uInt16 nTileHeight
, bool bEnhanceEdges
);
112 virtual Graphic
GetFilteredGraphic( const Graphic
& rGraphic
, double fScaleX
, double fScaleY
) override
;
113 bool IsEnhanceEdges() const { return mxCbxEdges
->get_active(); }
116 class GraphicFilterSolarize
: public GraphicFilterDialog
119 std::unique_ptr
<weld::MetricSpinButton
> mxMtrThreshold
;
120 std::unique_ptr
<weld::CheckButton
> mxCbxInvert
;
121 DECL_LINK(CheckBoxModifyHdl
, weld::ToggleButton
&, void);
122 DECL_LINK(EditModifyHdl
, weld::MetricSpinButton
&, void);
125 GraphicFilterSolarize(weld::Window
* pParent
, const Graphic
& rGraphic
,
126 sal_uInt8 nGreyThreshold
, bool bInvert
);
127 virtual Graphic
GetFilteredGraphic( const Graphic
& rGraphic
, double fScaleX
, double fScaleY
) override
;
128 bool IsInvert() const { return mxCbxInvert
->get_active(); }
131 class GraphicFilterSepia
: public GraphicFilterDialog
134 std::unique_ptr
<weld::MetricSpinButton
> mxMtrSepia
;
135 DECL_LINK(EditModifyHdl
, weld::MetricSpinButton
&, void);
137 GraphicFilterSepia(weld::Window
* pParent
, const Graphic
& rGraphic
,
138 sal_uInt16 nSepiaPercent
);
139 virtual Graphic
GetFilteredGraphic( const Graphic
& rGraphic
, double fScaleX
, double fScaleY
) override
;
142 class GraphicFilterPoster
: public GraphicFilterDialog
145 std::unique_ptr
<weld::SpinButton
> mxNumPoster
;
146 DECL_LINK(EditModifyHdl
, weld::SpinButton
&, void);
148 GraphicFilterPoster(weld::Window
* pParent
, const Graphic
& rGraphic
,
149 sal_uInt16 nPosterColorCount
);
150 virtual Graphic
GetFilteredGraphic( const Graphic
& rGraphic
, double fScaleX
, double fScaleY
) override
;
153 class EmbossControl
: public SvxRectCtl
156 Link
<LinkParamNone
*, void> maModifyHdl
;
157 virtual bool MouseButtonDown( const MouseEvent
& rEvt
) override
;
158 virtual void SetDrawingArea(weld::DrawingArea
* pDrawingArea
) override
;
161 : SvxRectCtl(nullptr)
165 void SetModifyHdl( const Link
<LinkParamNone
*,void>& rHdl
) { maModifyHdl
= rHdl
; }
168 class GraphicFilterEmboss
: public GraphicFilterDialog
171 EmbossControl maCtlLight
;
172 std::unique_ptr
<weld::CustomWeld
> mxCtlLight
;
174 GraphicFilterEmboss(weld::Window
* pParent
, const Graphic
& rGraphic
,
175 RectPoint eLightSource
);
176 virtual ~GraphicFilterEmboss() override
;
178 virtual Graphic
GetFilteredGraphic(const Graphic
& rGraphic
, double fScaleX
, double fScaleY
) override
;
183 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */