bump product version to 6.3.0.0.beta1
[LibreOffice.git] / cui / source / inc / cuigrfflt.hxx
blob31b51ca47a443d4598b6dc0f0819b5c46b350eb9
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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/.
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 <tools/helpers.hxx>
24 #include <vcl/GraphicObject.hxx>
25 #include <vcl/timer.hxx>
26 #include <svx/graphctl.hxx>
27 #include <svx/dlgctrl.hxx>
28 #include <svx/rectenum.hxx>
30 class CuiGraphicPreviewWindow : public weld::CustomWidgetController
32 private:
33 const Graphic* mpOrigGraphic;
34 Size maOrigGraphicSizePixel;
35 Size maOutputSizePixel;
36 Link<LinkParamNone*,void> maModifyHdl;
37 Graphic maScaledOrig;
38 Graphic maPreview;
39 double mfScaleX;
40 double mfScaleY;
42 virtual void Paint(vcl::RenderContext& rRenderContext, const ::tools::Rectangle& rRect) override;
43 virtual void Resize() override;
45 void ScaleImageToFit();
47 public:
48 CuiGraphicPreviewWindow();
49 virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
50 void init(const Graphic* pOrigGraphic, const Link<LinkParamNone*,void>& rLink)
52 mpOrigGraphic = pOrigGraphic;
53 maModifyHdl = rLink;
54 maOrigGraphicSizePixel = GetDrawingArea()->get_ref_device().LogicToPixel(mpOrigGraphic->GetPrefSize(),
55 mpOrigGraphic->GetPrefMapMode());
56 ScaleImageToFit();
59 void SetPreview(const Graphic& rGraphic);
60 const Graphic& GetScaledOriginal() const { return maScaledOrig; }
61 double GetScaleX() const { return mfScaleX; }
62 double GetScaleY() const { return mfScaleY; }
63 const Size& GetGraphicSizePixel() const { return maOrigGraphicSizePixel; }
66 class GraphicFilterDialog : public weld::GenericDialogController
68 private:
70 Timer maTimer;
71 Link<LinkParamNone*,void> maModifyHdl;
72 bool bIsBitmap;
74 DECL_LINK( ImplPreviewTimeoutHdl, Timer *, void );
75 DECL_LINK( ImplModifyHdl, LinkParamNone*, void);
77 CuiGraphicPreviewWindow maPreview;
78 std::unique_ptr<weld::CustomWeld> mxPreview;
80 protected:
81 const Link<LinkParamNone*,void>& GetModifyHdl() const { return maModifyHdl; }
82 const Size& GetGraphicSizePixel() const { return maPreview.GetGraphicSizePixel(); }
84 public:
86 GraphicFilterDialog(weld::Window* pParent, const OUString& rUIXMLDescription, const OString& rID, const Graphic& rGraphic);
87 virtual Graphic GetFilteredGraphic(const Graphic& rGraphic, double fScaleX, double fScaleY) = 0;
90 class GraphicFilterSmooth : public GraphicFilterDialog
92 private:
93 std::unique_ptr<weld::SpinButton> mxMtrRadius;
94 DECL_LINK(EditModifyHdl, weld::SpinButton&, void);
96 public:
98 GraphicFilterSmooth(weld::Window* pParent, const Graphic& rGraphic, double nRadius);
99 virtual Graphic GetFilteredGraphic( const Graphic& rGraphic, double fScaleX, double fScaleY ) override;
102 class GraphicFilterMosaic : public GraphicFilterDialog
104 private:
105 std::unique_ptr<weld::MetricSpinButton> mxMtrWidth;
106 std::unique_ptr<weld::MetricSpinButton> mxMtrHeight;
107 std::unique_ptr<weld::CheckButton> mxCbxEdges;
108 DECL_LINK(CheckBoxModifyHdl, weld::ToggleButton&, void);
109 DECL_LINK(EditModifyHdl, weld::MetricSpinButton&, void);
110 public:
112 GraphicFilterMosaic(weld::Window* pParent, const Graphic& rGraphic,
113 sal_uInt16 nTileWidth, sal_uInt16 nTileHeight, bool bEnhanceEdges);
115 virtual Graphic GetFilteredGraphic( const Graphic& rGraphic, double fScaleX, double fScaleY ) override;
116 bool IsEnhanceEdges() const { return mxCbxEdges->get_active(); }
119 class GraphicFilterSolarize : public GraphicFilterDialog
121 private:
122 std::unique_ptr<weld::MetricSpinButton> mxMtrThreshold;
123 std::unique_ptr<weld::CheckButton> mxCbxInvert;
124 DECL_LINK(CheckBoxModifyHdl, weld::ToggleButton&, void);
125 DECL_LINK(EditModifyHdl, weld::MetricSpinButton&, void);
127 public:
128 GraphicFilterSolarize(weld::Window* pParent, const Graphic& rGraphic,
129 sal_uInt8 nGreyThreshold, bool bInvert);
130 virtual Graphic GetFilteredGraphic( const Graphic& rGraphic, double fScaleX, double fScaleY ) override;
131 bool IsInvert() const { return mxCbxInvert->get_active(); }
134 class GraphicFilterSepia : public GraphicFilterDialog
136 private:
137 std::unique_ptr<weld::MetricSpinButton> mxMtrSepia;
138 DECL_LINK(EditModifyHdl, weld::MetricSpinButton&, void);
139 public:
140 GraphicFilterSepia(weld::Window* pParent, const Graphic& rGraphic,
141 sal_uInt16 nSepiaPercent);
142 virtual Graphic GetFilteredGraphic( const Graphic& rGraphic, double fScaleX, double fScaleY ) override;
145 class GraphicFilterPoster : public GraphicFilterDialog
147 private:
148 std::unique_ptr<weld::SpinButton> mxNumPoster;
149 DECL_LINK(EditModifyHdl, weld::SpinButton&, void);
150 public:
151 GraphicFilterPoster(weld::Window* pParent, const Graphic& rGraphic,
152 sal_uInt16 nPosterColorCount);
153 virtual Graphic GetFilteredGraphic( const Graphic& rGraphic, double fScaleX, double fScaleY ) override;
156 class EmbossControl : public SvxRectCtl
158 private:
159 Link<LinkParamNone*, void> maModifyHdl;
160 virtual bool MouseButtonDown( const MouseEvent& rEvt ) override;
161 virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
162 public:
163 EmbossControl()
164 : SvxRectCtl(nullptr)
168 void SetModifyHdl( const Link<LinkParamNone*,void>& rHdl ) { maModifyHdl = rHdl; }
171 class GraphicFilterEmboss : public GraphicFilterDialog
173 private:
174 EmbossControl maCtlLight;
175 std::unique_ptr<weld::CustomWeld> mxCtlLight;
176 public:
177 GraphicFilterEmboss(weld::Window* pParent, const Graphic& rGraphic,
178 RectPoint eLightSource);
179 virtual ~GraphicFilterEmboss() override;
181 virtual Graphic GetFilteredGraphic(const Graphic& rGraphic, double fScaleX, double fScaleY) override;
184 #endif
186 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */