Update ooo320-m1
[ooovba.git] / svx / source / cui / cuigrfflt.hxx
blobadf9519993324509c3d85551f7e7ce56f329c127
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: cuigrfflt.hxx,v $
10 * $Revision: 1.7 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef _CUI_GRFFLT_HXX
32 #define _CUI_GRFFLT_HXX
34 #include <vcl/fixed.hxx>
35 #include <vcl/field.hxx>
36 #ifndef _SV_BUTTON_HXX
37 #include <vcl/button.hxx>
38 #endif
39 #include <vcl/timer.hxx>
40 #include <vcl/dialog.hxx>
41 #include <vcl/group.hxx>
42 #include <vcl/salbtype.hxx>
43 #include <goodies/grfmgr.hxx>
44 #include <svx/graphctl.hxx>
45 #include <svx/dlgctrl.hxx>
46 #include <svx/rectenum.hxx>
48 // ---------------
49 // - Error codes -
50 // ---------------
52 #define SVX_GRAPHICFILTER_ERRCODE_NONE 0x00000000
53 #define SVX_GRAPHICFILTER_UNSUPPORTED_GRAPHICTYPE 0x00000001
54 #define SVX_GRAPHICFILTER_UNSUPPORTED_SLOT 0x00000002
56 // --------------------
57 // - SvxGraphicFilter -
58 // --------------------
60 class SfxRequest;
61 class SfxItemSet;
63 class SvxGraphicFilter
65 public:
67 static ULONG ExecuteGrfFilterSlot( SfxRequest& rReq, GraphicObject& rFilterObject );
68 static void DisableGraphicFilterSlots( SfxItemSet& rSet );
71 // -----------------------
72 // - GraphicFilterDialog -
73 // -----------------------
75 class GraphicFilterDialog : public ModalDialog
77 private:
79 class PreviewWindow : public Control
81 private:
83 GraphicObject maGraphic;
85 virtual void Paint( const Rectangle& rRect );
87 public:
89 PreviewWindow( Window* pParent, const ResId& rResId );
90 ~PreviewWindow();
92 void SetGraphic( const Graphic& rGraphic );
95 private:
97 Timer maTimer;
98 Link maModifyHdl;
99 Graphic maGraphic;
100 double mfScaleX;
101 double mfScaleY;
102 Size maSizePixel;
103 PreviewWindow maPreview;
104 FixedLine maFlParameter;
105 OKButton maBtnOK;
106 CancelButton maBtnCancel;
107 HelpButton maBtnHelp;
109 DECL_LINK( ImplPreviewTimeoutHdl, Timer* pTimer );
110 DECL_LINK( ImplModifyHdl, void* p );
112 protected:
114 const Link& GetModifyHdl() const { return maModifyHdl; }
115 const Size& GetGraphicSizePixel() const { return maSizePixel; }
117 public:
119 GraphicFilterDialog( Window* pParent, const ResId& rResId, const Graphic& rGraphic );
120 ~GraphicFilterDialog();
122 virtual Graphic GetFilteredGraphic( const Graphic& rGraphic, double fScaleX, double fScaleY ) = 0;
125 // -----------------------
126 // - GraphicFilterMosaic -
127 // -----------------------
129 class GraphicFilterMosaic : public GraphicFilterDialog
131 private:
133 FixedText maFtWidth;
134 MetricField maMtrWidth;
135 FixedText maFtHeight;
136 MetricField maMtrHeight;
137 CheckBox maCbxEdges;
139 public:
141 GraphicFilterMosaic( Window* pParent, const Graphic& rGraphic,
142 USHORT nTileWidth, USHORT nTileHeight, BOOL bEnhanceEdges );
143 ~GraphicFilterMosaic();
145 virtual Graphic GetFilteredGraphic( const Graphic& rGraphic, double fScaleX, double fScaleY );
146 long GetTileWidth() const { return static_cast<long>(maMtrWidth.GetValue()); }
147 long GetTileHeight() const { return static_cast<long>(maMtrHeight.GetValue()); }
148 BOOL IsEnhanceEdges() const { return maCbxEdges.IsChecked(); }
151 // -------------------------
152 // - GraphicFilterSolarize -
153 // -------------------------
155 class GraphicFilterSolarize : public GraphicFilterDialog
157 private:
159 FixedText maFtThreshold;
160 MetricField maMtrThreshold;
161 CheckBox maCbxInvert;
163 public:
165 GraphicFilterSolarize( Window* pParent, const Graphic& rGraphic,
166 BYTE nGreyThreshold, BOOL bInvert );
167 ~GraphicFilterSolarize();
169 virtual Graphic GetFilteredGraphic( const Graphic& rGraphic, double fScaleX, double fScaleY );
170 BYTE GetGreyThreshold() const { return( (BYTE) FRound( maMtrThreshold.GetValue() * 2.55 ) ); }
171 BOOL IsInvert() const { return maCbxInvert.IsChecked(); }
174 // ----------------------
175 // - GraphicFilterSepia -
176 // ----------------------
178 class GraphicFilterSepia : public GraphicFilterDialog
180 private:
182 FixedText maFtSepia;
183 MetricField maMtrSepia;
185 public:
187 GraphicFilterSepia( Window* pParent, const Graphic& rGraphic,
188 USHORT nSepiaPercent );
189 ~GraphicFilterSepia();
191 virtual Graphic GetFilteredGraphic( const Graphic& rGraphic, double fScaleX, double fScaleY );
192 USHORT GetSepiaPercent() const
193 { return sal::static_int_cast< USHORT >(maMtrSepia.GetValue()); }
196 // -----------------------
197 // - GraphicFilterPoster -
198 // -----------------------
200 class GraphicFilterPoster : public GraphicFilterDialog
202 private:
204 FixedText maFtPoster;
205 NumericField maNumPoster;
207 public:
209 GraphicFilterPoster( Window* pParent, const Graphic& rGraphic,
210 USHORT nPosterColorCount );
211 ~GraphicFilterPoster();
213 virtual Graphic GetFilteredGraphic( const Graphic& rGraphic, double fScaleX, double fScaleY );
214 USHORT GetPosterColorCount() const { return( (USHORT) maNumPoster.GetValue() ); }
217 // -----------------------
218 // - GraphicFilterEmboss -
219 // -----------------------
221 class GraphicFilterEmboss : public GraphicFilterDialog
223 private:
225 class EmbossControl : public SvxRectCtl
227 private:
229 Link maModifyHdl;
231 virtual void MouseButtonDown( const MouseEvent& rEvt );
233 public:
235 EmbossControl( Window* pParent, const ResId& rResId, RECT_POINT eRectPoint ) :
236 SvxRectCtl( pParent, rResId ) { SetActualRP( eRectPoint ); }
238 void SetModifyHdl( const Link& rHdl ) { maModifyHdl = rHdl; }
241 private:
243 FixedText maFtLight;
244 EmbossControl maCtlLight;
246 public:
248 GraphicFilterEmboss( Window* pParent, const Graphic& rGraphic,
249 RECT_POINT eLightSource );
250 ~GraphicFilterEmboss();
252 virtual Graphic GetFilteredGraphic( const Graphic& rGraphic, double fScaleX, double fScaleY );
253 RECT_POINT GetLightSource() const { return maCtlLight.GetActualRP(); }
256 #endif