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 #pragma once
21 
22 #include <vcl/timer.hxx>
23 #include <svx/dlgctrl.hxx>
24 #include <svx/rectenum.hxx>
25 
27 {
28 private:
35  double mfScaleX;
36  double mfScaleY;
37 
38  virtual void Paint(vcl::RenderContext& rRenderContext, const ::tools::Rectangle& rRect) override;
39  virtual void Resize() override;
40 
41  void ScaleImageToFit();
42 
43 public:
45  virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
46  void init(const Graphic* pOrigGraphic, const Link<LinkParamNone*,void>& rLink)
47  {
48  mpOrigGraphic = pOrigGraphic;
49  maModifyHdl = rLink;
50  maOrigGraphicSizePixel = GetDrawingArea()->get_ref_device().LogicToPixel(mpOrigGraphic->GetPrefSize(),
51  mpOrigGraphic->GetPrefMapMode());
53  }
54 
55  void SetPreview(const Graphic& rGraphic);
56  const Graphic& GetScaledOriginal() const { return maScaledOrig; }
57  double GetScaleX() const { return mfScaleX; }
58  double GetScaleY() const { return mfScaleY; }
59  const Size& GetGraphicSizePixel() const { return maOrigGraphicSizePixel; }
60 };
61 
63 {
64 private:
65 
68  bool bIsBitmap;
69 
70  DECL_LINK( ImplPreviewTimeoutHdl, Timer *, void );
71  DECL_LINK( ImplModifyHdl, LinkParamNone*, void);
72 
74  std::unique_ptr<weld::CustomWeld> mxPreview;
75 
76 protected:
78  const Size& GetGraphicSizePixel() const { return maPreview.GetGraphicSizePixel(); }
79 
80 public:
81 
82  GraphicFilterDialog(weld::Window* pParent, const OUString& rUIXMLDescription, const OString& rID, const Graphic& rGraphic);
83  virtual Graphic GetFilteredGraphic(const Graphic& rGraphic, double fScaleX, double fScaleY) = 0;
84 };
85 
87 {
88 private:
89  std::unique_ptr<weld::SpinButton> mxMtrRadius;
90  DECL_LINK(EditModifyHdl, weld::SpinButton&, void);
91 
92 public:
93 
94  GraphicFilterSmooth(weld::Window* pParent, const Graphic& rGraphic, double nRadius);
95  virtual Graphic GetFilteredGraphic( const Graphic& rGraphic, double fScaleX, double fScaleY ) override;
96 };
97 
99 {
100 private:
101  std::unique_ptr<weld::MetricSpinButton> mxMtrWidth;
102  std::unique_ptr<weld::MetricSpinButton> mxMtrHeight;
103  std::unique_ptr<weld::CheckButton> mxCbxEdges;
104  DECL_LINK(CheckBoxModifyHdl, weld::ToggleButton&, void);
105  DECL_LINK(EditModifyHdl, weld::MetricSpinButton&, void);
106 public:
107 
108  GraphicFilterMosaic(weld::Window* pParent, const Graphic& rGraphic,
109  sal_uInt16 nTileWidth, sal_uInt16 nTileHeight, bool bEnhanceEdges);
110 
111  virtual Graphic GetFilteredGraphic( const Graphic& rGraphic, double fScaleX, double fScaleY ) override;
112  bool IsEnhanceEdges() const { return mxCbxEdges->get_active(); }
113 };
114 
116 {
117 private:
118  std::unique_ptr<weld::MetricSpinButton> mxMtrThreshold;
119  std::unique_ptr<weld::CheckButton> mxCbxInvert;
120  DECL_LINK(CheckBoxModifyHdl, weld::ToggleButton&, void);
121  DECL_LINK(EditModifyHdl, weld::MetricSpinButton&, void);
122 
123 public:
124  GraphicFilterSolarize(weld::Window* pParent, const Graphic& rGraphic,
125  sal_uInt8 nGreyThreshold, bool bInvert);
126  virtual Graphic GetFilteredGraphic( const Graphic& rGraphic, double fScaleX, double fScaleY ) override;
127  bool IsInvert() const { return mxCbxInvert->get_active(); }
128 };
129 
131 {
132 private:
133  std::unique_ptr<weld::MetricSpinButton> mxMtrSepia;
134  DECL_LINK(EditModifyHdl, weld::MetricSpinButton&, void);
135 public:
136  GraphicFilterSepia(weld::Window* pParent, const Graphic& rGraphic,
137  sal_uInt16 nSepiaPercent);
138  virtual Graphic GetFilteredGraphic( const Graphic& rGraphic, double fScaleX, double fScaleY ) override;
139 };
140 
142 {
143 private:
144  std::unique_ptr<weld::SpinButton> mxNumPoster;
145  DECL_LINK(EditModifyHdl, weld::SpinButton&, void);
146 public:
147  GraphicFilterPoster(weld::Window* pParent, const Graphic& rGraphic,
148  sal_uInt16 nPosterColorCount);
149  virtual Graphic GetFilteredGraphic( const Graphic& rGraphic, double fScaleX, double fScaleY ) override;
150 };
151 
152 class EmbossControl : public SvxRectCtl
153 {
154 private:
156  virtual bool MouseButtonDown( const MouseEvent& rEvt ) override;
157  virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
158 public:
160  : SvxRectCtl(nullptr)
161  {
162  }
163 
164  void SetModifyHdl( const Link<LinkParamNone*,void>& rHdl ) { maModifyHdl = rHdl; }
165 };
166 
168 {
169 private:
171  std::unique_ptr<weld::CustomWeld> mxCtlLight;
172 public:
173  GraphicFilterEmboss(weld::Window* pParent, const Graphic& rGraphic,
174  RectPoint eLightSource);
175  virtual ~GraphicFilterEmboss() override;
176 
177  virtual Graphic GetFilteredGraphic(const Graphic& rGraphic, double fScaleX, double fScaleY) override;
178 };
179 
180 /* 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:77
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:164
void init(const Graphic *pOrigGraphic, const Link< LinkParamNone *, void > &rLink)
Definition: cuigrfflt.hxx:46
std::unique_ptr< weld::CustomWeld > mxCtlLight
Definition: cuigrfflt.hxx:171
EmbossControl maCtlLight
Definition: cuigrfflt.hxx:170
GraphicFilterSolarize(weld::Window *pParent, const Graphic &rGraphic, sal_uInt8 nGreyThreshold, bool bInvert)
Definition: cuigrfflt.cxx:266
Link< LinkParamNone *, void > maModifyHdl
Definition: cuigrfflt.hxx:155
double GetScaleY() const
Definition: cuigrfflt.hxx:58
std::unique_ptr< weld::CustomWeld > mxPreview
Definition: cuigrfflt.hxx:74
virtual Graphic GetFilteredGraphic(const Graphic &rGraphic, double fScaleX, double fScaleY) override
Definition: cuigrfflt.cxx:374
std::unique_ptr< weld::MetricSpinButton > mxMtrHeight
Definition: cuigrfflt.hxx:102
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:57
DECL_LINK(CheckBoxModifyHdl, weld::ToggleButton &, void)
std::unique_ptr< weld::MetricSpinButton > mxMtrWidth
Definition: cuigrfflt.hxx:101
const Graphic & GetScaledOriginal() const
Definition: cuigrfflt.hxx:56
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:103
virtual ~GraphicFilterEmboss() override
Definition: cuigrfflt.cxx:426
virtual OutputDevice & get_ref_device()=0
Link< LinkParamNone *, void > maModifyHdl
Definition: cuigrfflt.hxx:32
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:29
virtual Graphic GetFilteredGraphic(const Graphic &rGraphic, double fScaleX, double fScaleY) override
Definition: cuigrfflt.cxx:289
Link< LinkParamNone *, void > maModifyHdl
Definition: cuigrfflt.hxx:67
void SetPreview(const Graphic &rGraphic)
Definition: cuigrfflt.cxx:71
DECL_LINK(EditModifyHdl, weld::MetricSpinButton &, void)
std::unique_ptr< weld::CheckButton > mxCbxInvert
Definition: cuigrfflt.hxx:119
Point LogicToPixel(const Point &rLogicPt) const
Size GetPrefSize() const
std::unique_ptr< weld::MetricSpinButton > mxMtrSepia
Definition: cuigrfflt.hxx:133
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:89
weld::DrawingArea * GetDrawingArea() const
bool IsInvert() const
Definition: cuigrfflt.hxx:127
MapMode GetPrefMapMode() const
unsigned char sal_uInt8
CuiGraphicPreviewWindow maPreview
Definition: cuigrfflt.hxx:73
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:78
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:59
std::unique_ptr< weld::SpinButton > mxNumPoster
Definition: cuigrfflt.hxx:144
virtual void Resize() override
Definition: cuigrfflt.cxx:120
bool IsEnhanceEdges() const
Definition: cuigrfflt.hxx:112
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:118