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