LibreOffice Module cui (master)  1
cuigrfflt.hxx
Go to the documentation of this file.
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 
20 #ifndef INCLUDED_CUI_SOURCE_INC_CUIGRFFLT_HXX
21 #define INCLUDED_CUI_SOURCE_INC_CUIGRFFLT_HXX
22 
23 #include <vcl/timer.hxx>
24 #include <svx/dlgctrl.hxx>
25 #include <svx/rectenum.hxx>
26 
28 {
29 private:
36  double mfScaleX;
37  double mfScaleY;
38 
39  virtual void Paint(vcl::RenderContext& rRenderContext, const ::tools::Rectangle& rRect) override;
40  virtual void Resize() override;
41 
42  void ScaleImageToFit();
43 
44 public:
46  virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
47  void init(const Graphic* pOrigGraphic, const Link<LinkParamNone*,void>& rLink)
48  {
49  mpOrigGraphic = pOrigGraphic;
50  maModifyHdl = rLink;
51  maOrigGraphicSizePixel = GetDrawingArea()->get_ref_device().LogicToPixel(mpOrigGraphic->GetPrefSize(),
52  mpOrigGraphic->GetPrefMapMode());
54  }
55 
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; }
61 };
62 
64 {
65 private:
66 
69  bool bIsBitmap;
70 
71  DECL_LINK( ImplPreviewTimeoutHdl, Timer *, void );
72  DECL_LINK( ImplModifyHdl, LinkParamNone*, void);
73 
75  std::unique_ptr<weld::CustomWeld> mxPreview;
76 
77 protected:
79  const Size& GetGraphicSizePixel() const { return maPreview.GetGraphicSizePixel(); }
80 
81 public:
82 
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;
85 };
86 
88 {
89 private:
90  std::unique_ptr<weld::SpinButton> mxMtrRadius;
91  DECL_LINK(EditModifyHdl, weld::SpinButton&, void);
92 
93 public:
94 
95  GraphicFilterSmooth(weld::Window* pParent, const Graphic& rGraphic, double nRadius);
96  virtual Graphic GetFilteredGraphic( const Graphic& rGraphic, double fScaleX, double fScaleY ) override;
97 };
98 
100 {
101 private:
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);
107 public:
108 
109  GraphicFilterMosaic(weld::Window* pParent, const Graphic& rGraphic,
110  sal_uInt16 nTileWidth, sal_uInt16 nTileHeight, bool bEnhanceEdges);
111 
112  virtual Graphic GetFilteredGraphic( const Graphic& rGraphic, double fScaleX, double fScaleY ) override;
113  bool IsEnhanceEdges() const { return mxCbxEdges->get_active(); }
114 };
115 
117 {
118 private:
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);
123 
124 public:
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(); }
129 };
130 
132 {
133 private:
134  std::unique_ptr<weld::MetricSpinButton> mxMtrSepia;
135  DECL_LINK(EditModifyHdl, weld::MetricSpinButton&, void);
136 public:
137  GraphicFilterSepia(weld::Window* pParent, const Graphic& rGraphic,
138  sal_uInt16 nSepiaPercent);
139  virtual Graphic GetFilteredGraphic( const Graphic& rGraphic, double fScaleX, double fScaleY ) override;
140 };
141 
143 {
144 private:
145  std::unique_ptr<weld::SpinButton> mxNumPoster;
146  DECL_LINK(EditModifyHdl, weld::SpinButton&, void);
147 public:
148  GraphicFilterPoster(weld::Window* pParent, const Graphic& rGraphic,
149  sal_uInt16 nPosterColorCount);
150  virtual Graphic GetFilteredGraphic( const Graphic& rGraphic, double fScaleX, double fScaleY ) override;
151 };
152 
153 class EmbossControl : public SvxRectCtl
154 {
155 private:
157  virtual bool MouseButtonDown( const MouseEvent& rEvt ) override;
158  virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
159 public:
161  : SvxRectCtl(nullptr)
162  {
163  }
164 
165  void SetModifyHdl( const Link<LinkParamNone*,void>& rHdl ) { maModifyHdl = rHdl; }
166 };
167 
169 {
170 private:
172  std::unique_ptr<weld::CustomWeld> mxCtlLight;
173 public:
174  GraphicFilterEmboss(weld::Window* pParent, const Graphic& rGraphic,
175  RectPoint eLightSource);
176  virtual ~GraphicFilterEmboss() override;
177 
178  virtual Graphic GetFilteredGraphic(const Graphic& rGraphic, double fScaleX, double fScaleY) override;
179 };
180 
181 #endif
182 
183 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual Graphic GetFilteredGraphic(const Graphic &rGraphic, double fScaleX, double fScaleY) override
Definition: cuigrfflt.cxx:239
const Link< LinkParamNone *, void > & GetModifyHdl() const
Definition: cuigrfflt.hxx:78
GraphicFilterEmboss(weld::Window *pParent, const Graphic &rGraphic, RectPoint eLightSource)
Definition: cuigrfflt.cxx:416
GraphicFilterPoster(weld::Window *pParent, const Graphic &rGraphic, sal_uInt16 nPosterColorCount)
Definition: cuigrfflt.cxx:359
void SetModifyHdl(const Link< LinkParamNone *, void > &rHdl)
Definition: cuigrfflt.hxx:165
void init(const Graphic *pOrigGraphic, const Link< LinkParamNone *, void > &rLink)
Definition: cuigrfflt.hxx:47
std::unique_ptr< weld::CustomWeld > mxCtlLight
Definition: cuigrfflt.hxx:172
EmbossControl maCtlLight
Definition: cuigrfflt.hxx:171
GraphicFilterSolarize(weld::Window *pParent, const Graphic &rGraphic, sal_uInt8 nGreyThreshold, bool bInvert)
Definition: cuigrfflt.cxx:266
Link< LinkParamNone *, void > maModifyHdl
Definition: cuigrfflt.hxx:156
double GetScaleY() const
Definition: cuigrfflt.hxx:59
std::unique_ptr< weld::CustomWeld > mxPreview
Definition: cuigrfflt.hxx:75
virtual Graphic GetFilteredGraphic(const Graphic &rGraphic, double fScaleX, double fScaleY) override
Definition: cuigrfflt.cxx:374
std::unique_ptr< weld::MetricSpinButton > mxMtrHeight
Definition: cuigrfflt.hxx:103
virtual Graphic GetFilteredGraphic(const Graphic &rGraphic, double fScaleX, double fScaleY)=0
virtual void Paint(vcl::RenderContext &rRenderContext, const ::tools::Rectangle &rRect) override
Definition: cuigrfflt.cxx:48
GraphicFilterSmooth(weld::Window *pParent, const Graphic &rGraphic, double nRadius)
Definition: cuigrfflt.cxx:225
DECL_LINK(CheckBoxModifyHdl, weld::ToggleButton &, void)
double GetScaleX() const
Definition: cuigrfflt.hxx:58
DECL_LINK(CheckBoxModifyHdl, weld::ToggleButton &, void)
std::unique_ptr< weld::MetricSpinButton > mxMtrWidth
Definition: cuigrfflt.hxx:102
const Graphic & GetScaledOriginal() const
Definition: cuigrfflt.hxx:57
GraphicFilterSepia(weld::Window *pParent, const Graphic &rGraphic, sal_uInt16 nSepiaPercent)
Definition: cuigrfflt.cxx:322
virtual Graphic GetFilteredGraphic(const Graphic &rGraphic, double fScaleX, double fScaleY) override
Definition: cuigrfflt.cxx:336
std::unique_ptr< weld::CheckButton > mxCbxEdges
Definition: cuigrfflt.hxx:104
virtual ~GraphicFilterEmboss() override
Definition: cuigrfflt.cxx:426
virtual OutputDevice & get_ref_device()=0
Link< LinkParamNone *, void > maModifyHdl
Definition: cuigrfflt.hxx:33
DECL_LINK(EditModifyHdl, weld::SpinButton &, void)
RectPoint
DECL_LINK(ImplPreviewTimeoutHdl, Timer *, void)
virtual void SetDrawingArea(weld::DrawingArea *pDrawingArea) override
Definition: cuigrfflt.cxx:40
const Graphic * mpOrigGraphic
Definition: cuigrfflt.hxx:30
virtual Graphic GetFilteredGraphic(const Graphic &rGraphic, double fScaleX, double fScaleY) override
Definition: cuigrfflt.cxx:289
Link< LinkParamNone *, void > maModifyHdl
Definition: cuigrfflt.hxx:68
void SetPreview(const Graphic &rGraphic)
Definition: cuigrfflt.cxx:71
DECL_LINK(EditModifyHdl, weld::MetricSpinButton &, void)
std::unique_ptr< weld::CheckButton > mxCbxInvert
Definition: cuigrfflt.hxx:120
Point LogicToPixel(const Point &rLogicPt) const
Size GetPrefSize() const
std::unique_ptr< weld::MetricSpinButton > mxMtrSepia
Definition: cuigrfflt.hxx:134
virtual Graphic GetFilteredGraphic(const Graphic &rGraphic, double fScaleX, double fScaleY) override
Definition: cuigrfflt.cxx:430
DECL_LINK(EditModifyHdl, weld::SpinButton &, void)
std::unique_ptr< weld::SpinButton > mxMtrRadius
Definition: cuigrfflt.hxx:90
weld::DrawingArea * GetDrawingArea() const
bool IsInvert() const
Definition: cuigrfflt.hxx:128
MapMode GetPrefMapMode() const
unsigned char sal_uInt8
CuiGraphicPreviewWindow maPreview
Definition: cuigrfflt.hxx:74
virtual void SetDrawingArea(weld::DrawingArea *pDrawingArea) override
Definition: cuigrfflt.cxx:409
GraphicFilterDialog(weld::Window *pParent, const OUString &rUIXMLDescription, const OString &rID, const Graphic &rGraphic)
Definition: cuigrfflt.cxx:126
const Size & GetGraphicSizePixel() const
Definition: cuigrfflt.hxx:79
virtual Graphic GetFilteredGraphic(const Graphic &rGraphic, double fScaleX, double fScaleY) override
Definition: cuigrfflt.cxx:188
virtual bool MouseButtonDown(const MouseEvent &rEvt) override
Definition: cuigrfflt.cxx:397
const Size & GetGraphicSizePixel() const
Definition: cuigrfflt.hxx:60
std::unique_ptr< weld::SpinButton > mxNumPoster
Definition: cuigrfflt.hxx:145
virtual void Resize() override
Definition: cuigrfflt.cxx:120
bool IsEnhanceEdges() const
Definition: cuigrfflt.hxx:113
GraphicFilterMosaic(weld::Window *pParent, const Graphic &rGraphic, sal_uInt16 nTileWidth, sal_uInt16 nTileHeight, bool bEnhanceEdges)
Definition: cuigrfflt.cxx:157
std::unique_ptr< weld::MetricSpinButton > mxMtrThreshold
Definition: cuigrfflt.hxx:119