xref: /aoo42x/main/cui/source/inc/cuigrfflt.hxx (revision c4eee24d)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 #ifndef _CUI_GRFFLT_HXX
25 #define _CUI_GRFFLT_HXX
26 
27 #include <vcl/fixed.hxx>
28 #include <vcl/field.hxx>
29 #ifndef _SV_BUTTON_HXX
30 #include <vcl/button.hxx>
31 #endif
32 #include <vcl/timer.hxx>
33 #include <vcl/dialog.hxx>
34 #include <vcl/group.hxx>
35 #include <vcl/salbtype.hxx>
36 #include <svtools/grfmgr.hxx>
37 #include <svx/graphctl.hxx>
38 #include <svx/dlgctrl.hxx>
39 #include <svx/rectenum.hxx>
40 /*
41 // ---------------
42 // - Error codes -
43 // ---------------
44 
45 #define SVX_GRAPHICFILTER_ERRCODE_NONE				0x00000000
46 #define SVX_GRAPHICFILTER_UNSUPPORTED_GRAPHICTYPE	0x00000001
47 #define SVX_GRAPHICFILTER_UNSUPPORTED_SLOT			0x00000002
48 
49 // --------------------
50 // - SvxGraphicFilter -
51 // --------------------
52 
53 class SfxRequest;
54 class SfxItemSet;
55 
56 class SvxGraphicFilter
57 {
58 public:
59 
60 	static sal_uLong	ExecuteGrfFilterSlot( SfxRequest& rReq, GraphicObject& rFilterObject );
61 	static void		DisableGraphicFilterSlots( SfxItemSet& rSet );
62 };
63 */
64 // -----------------------
65 // - GraphicFilterDialog -
66 // -----------------------
67 
68 class GraphicFilterDialog : public ModalDialog
69 {
70 private:
71 
72 	class PreviewWindow : public Control
73 	{
74 	private:
75 
76 		GraphicObject	maGraphic;
77 
78 		virtual void	Paint( const Rectangle& rRect );
79 
80 	public:
81 
82 						PreviewWindow( Window* pParent, const ResId& rResId );
83 						~PreviewWindow();
84 
85 		void			SetGraphic( const Graphic& rGraphic );
86 	};
87 
88 private:
89 
90 	Timer			maTimer;
91 	Link			maModifyHdl;
92 	Graphic			maGraphic;
93 	double			mfScaleX;
94 	double			mfScaleY;
95 	Size			maSizePixel;
96 
97 					DECL_LINK( ImplPreviewTimeoutHdl, Timer* pTimer );
98 					DECL_LINK( ImplModifyHdl, void* p );
99 
100 protected:
101 	PreviewWindow	maPreview;
102 	OKButton		maBtnOK;
103 	CancelButton	maBtnCancel;
104 	HelpButton		maBtnHelp;
105 	FixedLine		maFlParameter;
106 
GetModifyHdl() const107 	const Link&		GetModifyHdl() const { return maModifyHdl; }
GetGraphicSizePixel() const108 	const Size&		GetGraphicSizePixel() const { return maSizePixel; }
109 
110 public:
111 
112 					GraphicFilterDialog( Window* pParent, const ResId& rResId, const Graphic& rGraphic );
113 					~GraphicFilterDialog();
114 
115 	virtual Graphic	GetFilteredGraphic( const Graphic& rGraphic, double fScaleX, double fScaleY ) = 0;
116 };
117 
118 // -----------------------
119 // - GraphicFilterMosaic -
120 // -----------------------
121 
122 class GraphicFilterMosaic : public GraphicFilterDialog
123 {
124 private:
125 
126 	FixedText		maFtWidth;
127 	MetricField		maMtrWidth;
128 	FixedText		maFtHeight;
129 	MetricField		maMtrHeight;
130 	CheckBox		maCbxEdges;
131 
132 public:
133 
134 					GraphicFilterMosaic( Window* pParent, const Graphic& rGraphic,
135 										 sal_uInt16 nTileWidth, sal_uInt16 nTileHeight, sal_Bool bEnhanceEdges );
136 					~GraphicFilterMosaic();
137 
138 	virtual Graphic	GetFilteredGraphic( const Graphic& rGraphic, double fScaleX, double fScaleY );
GetTileWidth() const139 	long			GetTileWidth() const { return static_cast<long>(maMtrWidth.GetValue()); }
GetTileHeight() const140 	long			GetTileHeight() const { return static_cast<long>(maMtrHeight.GetValue()); }
IsEnhanceEdges() const141 	sal_Bool			IsEnhanceEdges() const { return maCbxEdges.IsChecked(); }
142 };
143 
144 // -------------------------
145 // - GraphicFilterSolarize -
146 // -------------------------
147 
148 class GraphicFilterSolarize : public GraphicFilterDialog
149 {
150 private:
151 
152 	FixedText		maFtThreshold;
153 	MetricField		maMtrThreshold;
154 	CheckBox		maCbxInvert;
155 
156 public:
157 
158 					GraphicFilterSolarize( Window* pParent, const Graphic& rGraphic,
159 										   sal_uInt8 nGreyThreshold, sal_Bool bInvert );
160 					~GraphicFilterSolarize();
161 
162 	virtual Graphic	GetFilteredGraphic( const Graphic& rGraphic, double fScaleX, double fScaleY );
GetGreyThreshold() const163 	sal_uInt8			GetGreyThreshold() const { return( (sal_uInt8) FRound( maMtrThreshold.GetValue() * 2.55 ) ); }
IsInvert() const164 	sal_Bool			IsInvert() const { return maCbxInvert.IsChecked(); }
165 };
166 
167 // ----------------------
168 // - GraphicFilterSepia -
169 // ----------------------
170 
171 class GraphicFilterSepia : public GraphicFilterDialog
172 {
173 private:
174 
175 	FixedText		maFtSepia;
176 	MetricField		maMtrSepia;
177 
178 public:
179 
180 					GraphicFilterSepia( Window* pParent, const Graphic& rGraphic,
181 										sal_uInt16 nSepiaPercent );
182 					~GraphicFilterSepia();
183 
184 	virtual Graphic	GetFilteredGraphic( const Graphic& rGraphic, double fScaleX, double fScaleY );
GetSepiaPercent() const185 	sal_uInt16			GetSepiaPercent() const
186     { return sal::static_int_cast< sal_uInt16 >(maMtrSepia.GetValue()); }
187 };
188 
189 // -----------------------
190 // - GraphicFilterPoster -
191 // -----------------------
192 
193 class GraphicFilterPoster : public GraphicFilterDialog
194 {
195 private:
196 
197 	FixedText		maFtPoster;
198 	NumericField	maNumPoster;
199 
200 public:
201 
202 					GraphicFilterPoster( Window* pParent, const Graphic& rGraphic,
203 										 sal_uInt16 nPosterColorCount );
204 					~GraphicFilterPoster();
205 
206 	virtual Graphic	GetFilteredGraphic( const Graphic& rGraphic, double fScaleX, double fScaleY );
GetPosterColorCount() const207 	sal_uInt16			GetPosterColorCount() const { return( (sal_uInt16) maNumPoster.GetValue() ); }
208 };
209 
210 // -----------------------
211 // - GraphicFilterEmboss -
212 // -----------------------
213 
214 class GraphicFilterEmboss : public GraphicFilterDialog
215 {
216 private:
217 
218 	class EmbossControl : public SvxRectCtl
219 	{
220 	private:
221 
222 		Link			maModifyHdl;
223 
224 		virtual void	MouseButtonDown( const MouseEvent& rEvt );
225 
226 	public:
227 
EmbossControl(Window * pParent,const ResId & rResId,RECT_POINT eRectPoint)228 						EmbossControl( Window* pParent, const ResId& rResId, RECT_POINT eRectPoint ) :
229 							SvxRectCtl( pParent, rResId ) { SetActualRP( eRectPoint ); }
230 
SetModifyHdl(const Link & rHdl)231 		void			SetModifyHdl( const Link& rHdl ) { maModifyHdl = rHdl; }
232 	};
233 
234 private:
235 
236 	FixedText		maFtLight;
237 	EmbossControl	maCtlLight;
238 
239 public:
240 
241 					GraphicFilterEmboss( Window* pParent, const Graphic& rGraphic,
242 										 RECT_POINT eLightSource );
243 					~GraphicFilterEmboss();
244 
245 	virtual Graphic	GetFilteredGraphic( const Graphic& rGraphic, double fScaleX, double fScaleY );
GetLightSource() const246 	RECT_POINT		GetLightSource() const { return maCtlLight.GetActualRP(); }
247 };
248 
249 #endif
250