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 _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
43 class PreviewWindow
: public Control
49 virtual void Paint( const Rectangle
& rRect
);
53 PreviewWindow( Window
* pParent
, const ResId
& rResId
);
56 void SetGraphic( const Graphic
& rGraphic
);
68 DECL_LINK(ImplPreviewTimeoutHdl
, void *);
69 DECL_LINK( ImplModifyHdl
, void* p
);
72 PreviewWindow maPreview
;
74 CancelButton maBtnCancel
;
76 FixedLine maFlParameter
;
78 const Link
& GetModifyHdl() const { return maModifyHdl
; }
79 const Size
& GetGraphicSizePixel() const { return maSizePixel
; }
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
98 NumericField maMtrRadius
;
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
118 MetricField maMtrWidth
;
119 FixedText maFtHeight
;
120 MetricField maMtrHeight
;
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
143 FixedText maFtThreshold
;
144 MetricField maMtrThreshold
;
145 CheckBox maCbxInvert
;
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
167 MetricField maMtrSepia
;
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
188 FixedText maFtPoster
;
189 NumericField maNumPoster
;
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
209 class EmbossControl
: public SvxRectCtl
215 virtual void MouseButtonDown( const MouseEvent
& rEvt
);
219 EmbossControl( Window
* pParent
, const ResId
& rResId
, RECT_POINT eRectPoint
) :
220 SvxRectCtl( pParent
, rResId
) { SetActualRP( eRectPoint
); }
222 void SetModifyHdl( const Link
& rHdl
) { maModifyHdl
= rHdl
; }
228 EmbossControl maCtlLight
;
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(); }
242 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */