xref: /trunk/main/cui/source/inc/cuigrfflt.hxx (revision 1ecadb572e7010ff3b3382ad9bf179dbc6efadbb)
1 /*************************************************************************
2  *
3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4  *
5  * Copyright 2000, 2010 Oracle and/or its affiliates.
6  *
7  * OpenOffice.org - a multi-platform office productivity suite
8  *
9  * This file is part of OpenOffice.org.
10  *
11  * OpenOffice.org is free software: you can redistribute it and/or modify
12  * it under the terms of the GNU Lesser General Public License version 3
13  * only, as published by the Free Software Foundation.
14  *
15  * OpenOffice.org is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU Lesser General Public License version 3 for more details
19  * (a copy is included in the LICENSE file that accompanied this code).
20  *
21  * You should have received a copy of the GNU Lesser General Public License
22  * version 3 along with OpenOffice.org.  If not, see
23  * <http://www.openoffice.org/license.html>
24  * for a copy of the LGPLv3 License.
25  *
26  ************************************************************************/
27 
28 #ifndef _CUI_GRFFLT_HXX
29 #define _CUI_GRFFLT_HXX
30 
31 #include <vcl/fixed.hxx>
32 #include <vcl/field.hxx>
33 #ifndef _SV_BUTTON_HXX
34 #include <vcl/button.hxx>
35 #endif
36 #include <vcl/timer.hxx>
37 #include <vcl/dialog.hxx>
38 #include <vcl/group.hxx>
39 #include <vcl/salbtype.hxx>
40 #include <svtools/grfmgr.hxx>
41 #include <svx/graphctl.hxx>
42 #include <svx/dlgctrl.hxx>
43 #include <svx/rectenum.hxx>
44 /*
45 // ---------------
46 // - Error codes -
47 // ---------------
48 
49 #define SVX_GRAPHICFILTER_ERRCODE_NONE              0x00000000
50 #define SVX_GRAPHICFILTER_UNSUPPORTED_GRAPHICTYPE   0x00000001
51 #define SVX_GRAPHICFILTER_UNSUPPORTED_SLOT          0x00000002
52 
53 // --------------------
54 // - SvxGraphicFilter -
55 // --------------------
56 
57 class SfxRequest;
58 class SfxItemSet;
59 
60 class SvxGraphicFilter
61 {
62 public:
63 
64     static sal_uLong    ExecuteGrfFilterSlot( SfxRequest& rReq, GraphicObject& rFilterObject );
65     static void     DisableGraphicFilterSlots( SfxItemSet& rSet );
66 };
67 */
68 // -----------------------
69 // - GraphicFilterDialog -
70 // -----------------------
71 
72 class GraphicFilterDialog : public ModalDialog
73 {
74 private:
75 
76     class PreviewWindow : public Control
77     {
78     private:
79 
80         GraphicObject   maGraphic;
81 
82         virtual void    Paint( const Rectangle& rRect );
83 
84     public:
85 
86                         PreviewWindow( Window* pParent, const ResId& rResId );
87                         ~PreviewWindow();
88 
89         void            SetGraphic( const Graphic& rGraphic );
90     };
91 
92 private:
93 
94     Timer           maTimer;
95     Link            maModifyHdl;
96     Graphic         maGraphic;
97     double          mfScaleX;
98     double          mfScaleY;
99     Size            maSizePixel;
100 
101                     DECL_LINK( ImplPreviewTimeoutHdl, Timer* pTimer );
102                     DECL_LINK( ImplModifyHdl, void* p );
103 
104 protected:
105     PreviewWindow   maPreview;
106     OKButton        maBtnOK;
107     CancelButton    maBtnCancel;
108     HelpButton      maBtnHelp;
109     FixedLine       maFlParameter;
110 
111     const Link&     GetModifyHdl() const { return maModifyHdl; }
112     const Size&     GetGraphicSizePixel() const { return maSizePixel; }
113 
114 public:
115 
116                     GraphicFilterDialog( Window* pParent, const ResId& rResId, const Graphic& rGraphic );
117                     ~GraphicFilterDialog();
118 
119     virtual Graphic GetFilteredGraphic( const Graphic& rGraphic, double fScaleX, double fScaleY ) = 0;
120 };
121 
122 // -----------------------
123 // - GraphicFilterMosaic -
124 // -----------------------
125 
126 class GraphicFilterMosaic : public GraphicFilterDialog
127 {
128 private:
129 
130     FixedText       maFtWidth;
131     MetricField     maMtrWidth;
132     FixedText       maFtHeight;
133     MetricField     maMtrHeight;
134     CheckBox        maCbxEdges;
135 
136 public:
137 
138                     GraphicFilterMosaic( Window* pParent, const Graphic& rGraphic,
139                                          sal_uInt16 nTileWidth, sal_uInt16 nTileHeight, sal_Bool bEnhanceEdges );
140                     ~GraphicFilterMosaic();
141 
142     virtual Graphic GetFilteredGraphic( const Graphic& rGraphic, double fScaleX, double fScaleY );
143     long            GetTileWidth() const { return static_cast<long>(maMtrWidth.GetValue()); }
144     long            GetTileHeight() const { return static_cast<long>(maMtrHeight.GetValue()); }
145     sal_Bool            IsEnhanceEdges() const { return maCbxEdges.IsChecked(); }
146 };
147 
148 // -------------------------
149 // - GraphicFilterSolarize -
150 // -------------------------
151 
152 class GraphicFilterSolarize : public GraphicFilterDialog
153 {
154 private:
155 
156     FixedText       maFtThreshold;
157     MetricField     maMtrThreshold;
158     CheckBox        maCbxInvert;
159 
160 public:
161 
162                     GraphicFilterSolarize( Window* pParent, const Graphic& rGraphic,
163                                            sal_uInt8 nGreyThreshold, sal_Bool bInvert );
164                     ~GraphicFilterSolarize();
165 
166     virtual Graphic GetFilteredGraphic( const Graphic& rGraphic, double fScaleX, double fScaleY );
167     sal_uInt8           GetGreyThreshold() const { return( (sal_uInt8) FRound( maMtrThreshold.GetValue() * 2.55 ) ); }
168     sal_Bool            IsInvert() const { return maCbxInvert.IsChecked(); }
169 };
170 
171 // ----------------------
172 // - GraphicFilterSepia -
173 // ----------------------
174 
175 class GraphicFilterSepia : public GraphicFilterDialog
176 {
177 private:
178 
179     FixedText       maFtSepia;
180     MetricField     maMtrSepia;
181 
182 public:
183 
184                     GraphicFilterSepia( Window* pParent, const Graphic& rGraphic,
185                                         sal_uInt16 nSepiaPercent );
186                     ~GraphicFilterSepia();
187 
188     virtual Graphic GetFilteredGraphic( const Graphic& rGraphic, double fScaleX, double fScaleY );
189     sal_uInt16          GetSepiaPercent() const
190     { return sal::static_int_cast< sal_uInt16 >(maMtrSepia.GetValue()); }
191 };
192 
193 // -----------------------
194 // - GraphicFilterPoster -
195 // -----------------------
196 
197 class GraphicFilterPoster : public GraphicFilterDialog
198 {
199 private:
200 
201     FixedText       maFtPoster;
202     NumericField    maNumPoster;
203 
204 public:
205 
206                     GraphicFilterPoster( Window* pParent, const Graphic& rGraphic,
207                                          sal_uInt16 nPosterColorCount );
208                     ~GraphicFilterPoster();
209 
210     virtual Graphic GetFilteredGraphic( const Graphic& rGraphic, double fScaleX, double fScaleY );
211     sal_uInt16          GetPosterColorCount() const { return( (sal_uInt16) maNumPoster.GetValue() ); }
212 };
213 
214 // -----------------------
215 // - GraphicFilterEmboss -
216 // -----------------------
217 
218 class GraphicFilterEmboss : public GraphicFilterDialog
219 {
220 private:
221 
222     class EmbossControl : public SvxRectCtl
223     {
224     private:
225 
226         Link            maModifyHdl;
227 
228         virtual void    MouseButtonDown( const MouseEvent& rEvt );
229 
230     public:
231 
232                         EmbossControl( Window* pParent, const ResId& rResId, RECT_POINT eRectPoint ) :
233                             SvxRectCtl( pParent, rResId ) { SetActualRP( eRectPoint ); }
234 
235         void            SetModifyHdl( const Link& rHdl ) { maModifyHdl = rHdl; }
236     };
237 
238 private:
239 
240     FixedText       maFtLight;
241     EmbossControl   maCtlLight;
242 
243 public:
244 
245                     GraphicFilterEmboss( Window* pParent, const Graphic& rGraphic,
246                                          RECT_POINT eLightSource );
247                     ~GraphicFilterEmboss();
248 
249     virtual Graphic GetFilteredGraphic( const Graphic& rGraphic, double fScaleX, double fScaleY );
250     RECT_POINT      GetLightSource() const { return maCtlLight.GetActualRP(); }
251 };
252 
253 #endif
254