Version 4.0.0.1, tag libreoffice-4.0.0.1
[LibreOffice.git] / cui / source / inc / cuigrfflt.hxx
blob66fdba231ce7244690c7d97f7b9a3e6a94366e56
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 _CUI_GRFFLT_HXX
21 #define _CUI_GRFFLT_HXX
23 #include <vcl/fixed.hxx>
24 #include <vcl/field.hxx>
25 #include <vcl/button.hxx>
26 #include <vcl/timer.hxx>
27 #include <vcl/dialog.hxx>
28 #include <vcl/group.hxx>
29 #include <tools/helpers.hxx>
30 #include <svtools/grfmgr.hxx>
31 #include <svx/graphctl.hxx>
32 #include <svx/dlgctrl.hxx>
33 #include <svx/rectenum.hxx>
35 // -----------------------
36 // - GraphicFilterDialog -
37 // -----------------------
39 class GraphicFilterDialog : public ModalDialog
41 private:
43 class PreviewWindow : public Control
45 private:
47 Graphic maGraphic;
49 virtual void Paint( const Rectangle& rRect );
51 public:
53 PreviewWindow( Window* pParent, const ResId& rResId );
54 ~PreviewWindow();
56 void SetGraphic( const Graphic& rGraphic );
59 private:
61 Timer maTimer;
62 Link maModifyHdl;
63 Graphic maGraphic;
64 double mfScaleX;
65 double mfScaleY;
66 Size maSizePixel;
68 DECL_LINK(ImplPreviewTimeoutHdl, void *);
69 DECL_LINK( ImplModifyHdl, void* p );
71 protected:
72 PreviewWindow maPreview;
73 OKButton maBtnOK;
74 CancelButton maBtnCancel;
75 HelpButton maBtnHelp;
76 FixedLine maFlParameter;
78 const Link& GetModifyHdl() const { return maModifyHdl; }
79 const Size& GetGraphicSizePixel() const { return maSizePixel; }
81 public:
83 GraphicFilterDialog( Window* pParent, const ResId& rResId, const Graphic& rGraphic );
84 ~GraphicFilterDialog();
86 virtual Graphic GetFilteredGraphic( const Graphic& rGraphic, double fScaleX, double fScaleY ) = 0;
89 // -------------------------
90 // - GraphicFilterSmooth -
91 // -------------------------
93 class GraphicFilterSmooth : public GraphicFilterDialog
95 private:
97 FixedText maFtRadius;
98 NumericField maMtrRadius;
100 public:
102 GraphicFilterSmooth( Window* pParent, const Graphic& rGraphic, double nRadius);
103 ~GraphicFilterSmooth();
105 virtual Graphic GetFilteredGraphic( const Graphic& rGraphic, double fScaleX, double fScaleY );
106 double GetRadius() const { return maMtrRadius.GetValue() / 10.0; }
109 // -----------------------
110 // - GraphicFilterMosaic -
111 // -----------------------
113 class GraphicFilterMosaic : public GraphicFilterDialog
115 private:
117 FixedText maFtWidth;
118 MetricField maMtrWidth;
119 FixedText maFtHeight;
120 MetricField maMtrHeight;
121 CheckBox maCbxEdges;
123 public:
125 GraphicFilterMosaic( Window* pParent, const Graphic& rGraphic,
126 sal_uInt16 nTileWidth, sal_uInt16 nTileHeight, sal_Bool bEnhanceEdges );
127 ~GraphicFilterMosaic();
129 virtual Graphic GetFilteredGraphic( const Graphic& rGraphic, double fScaleX, double fScaleY );
130 long GetTileWidth() const { return static_cast<long>(maMtrWidth.GetValue()); }
131 long GetTileHeight() const { return static_cast<long>(maMtrHeight.GetValue()); }
132 sal_Bool IsEnhanceEdges() const { return maCbxEdges.IsChecked(); }
135 // -------------------------
136 // - GraphicFilterSolarize -
137 // -------------------------
139 class GraphicFilterSolarize : public GraphicFilterDialog
141 private:
143 FixedText maFtThreshold;
144 MetricField maMtrThreshold;
145 CheckBox maCbxInvert;
147 public:
149 GraphicFilterSolarize( Window* pParent, const Graphic& rGraphic,
150 sal_uInt8 nGreyThreshold, sal_Bool bInvert );
151 ~GraphicFilterSolarize();
153 virtual Graphic GetFilteredGraphic( const Graphic& rGraphic, double fScaleX, double fScaleY );
154 sal_uInt8 GetGreyThreshold() const { return( (sal_uInt8) FRound( maMtrThreshold.GetValue() * 2.55 ) ); }
155 sal_Bool IsInvert() const { return maCbxInvert.IsChecked(); }
158 // ----------------------
159 // - GraphicFilterSepia -
160 // ----------------------
162 class GraphicFilterSepia : public GraphicFilterDialog
164 private:
166 FixedText maFtSepia;
167 MetricField maMtrSepia;
169 public:
171 GraphicFilterSepia( Window* pParent, const Graphic& rGraphic,
172 sal_uInt16 nSepiaPercent );
173 ~GraphicFilterSepia();
175 virtual Graphic GetFilteredGraphic( const Graphic& rGraphic, double fScaleX, double fScaleY );
176 sal_uInt16 GetSepiaPercent() const
177 { return sal::static_int_cast< sal_uInt16 >(maMtrSepia.GetValue()); }
180 // -----------------------
181 // - GraphicFilterPoster -
182 // -----------------------
184 class GraphicFilterPoster : public GraphicFilterDialog
186 private:
188 FixedText maFtPoster;
189 NumericField maNumPoster;
191 public:
193 GraphicFilterPoster( Window* pParent, const Graphic& rGraphic,
194 sal_uInt16 nPosterColorCount );
195 ~GraphicFilterPoster();
197 virtual Graphic GetFilteredGraphic( const Graphic& rGraphic, double fScaleX, double fScaleY );
198 sal_uInt16 GetPosterColorCount() const { return( (sal_uInt16) maNumPoster.GetValue() ); }
201 // -----------------------
202 // - GraphicFilterEmboss -
203 // -----------------------
205 class GraphicFilterEmboss : public GraphicFilterDialog
207 private:
209 class EmbossControl : public SvxRectCtl
211 private:
213 Link maModifyHdl;
215 virtual void MouseButtonDown( const MouseEvent& rEvt );
217 public:
219 EmbossControl( Window* pParent, const ResId& rResId, RECT_POINT eRectPoint ) :
220 SvxRectCtl( pParent, rResId ) { SetActualRP( eRectPoint ); }
222 void SetModifyHdl( const Link& rHdl ) { maModifyHdl = rHdl; }
225 private:
227 FixedText maFtLight;
228 EmbossControl maCtlLight;
230 public:
232 GraphicFilterEmboss( Window* pParent, const Graphic& rGraphic,
233 RECT_POINT eLightSource );
234 ~GraphicFilterEmboss();
236 virtual Graphic GetFilteredGraphic( const Graphic& rGraphic, double fScaleX, double fScaleY );
237 RECT_POINT GetLightSource() const { return maCtlLight.GetActualRP(); }
240 #endif
242 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */