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 INCLUDED_CUI_SOURCE_INC_CUIGRFFLT_HXX
21 #define INCLUDED_CUI_SOURCE_INC_CUIGRFFLT_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 class GraphicPreviewWindow
: public Control
38 const Graphic
* mpOrigGraphic
;
45 virtual void Paint(vcl::RenderContext
& rRenderContext
, const Rectangle
& rRect
) SAL_OVERRIDE
;
46 virtual void Resize() SAL_OVERRIDE
;
47 virtual Size
GetOptimalSize() const SAL_OVERRIDE
;
49 void ScaleImageToFit();
53 GraphicPreviewWindow(vcl::Window
* pParent
, WinBits nStyle
);
54 void init(const Graphic
* pOrigGraphic
, const Link
<>& rLink
)
56 mpOrigGraphic
= pOrigGraphic
;
61 void SetPreview(const Graphic
& rGraphic
);
62 const Graphic
& GetScaledOriginal() const { return maScaledOrig
; }
63 double GetScaleX() const { return mfScaleX
; }
64 double GetScaleY() const { return mfScaleY
; }
67 class GraphicFilterDialog
: public ModalDialog
76 DECL_LINK_TYPED(ImplPreviewTimeoutHdl
, Timer
*, void);
77 DECL_LINK( ImplModifyHdl
, void* p
);
80 VclPtr
<GraphicPreviewWindow
> mpPreview
;
82 const Link
<>& GetModifyHdl() const { return maModifyHdl
; }
83 const Size
& GetGraphicSizePixel() const { return maSizePixel
; }
87 GraphicFilterDialog(vcl::Window
* pParent
, const OUString
& rID
, const OUString
& rUIXMLDescription
, const Graphic
& rGraphic
);
88 virtual ~GraphicFilterDialog();
89 virtual void dispose() SAL_OVERRIDE
;
91 virtual Graphic
GetFilteredGraphic( const Graphic
& rGraphic
, double fScaleX
, double fScaleY
) = 0;
94 class GraphicFilterSmooth
: public GraphicFilterDialog
97 VclPtr
<NumericField
> mpMtrRadius
;
101 GraphicFilterSmooth( vcl::Window
* pParent
, const Graphic
& rGraphic
, double nRadius
);
102 virtual ~GraphicFilterSmooth();
103 virtual void dispose() SAL_OVERRIDE
;
105 virtual Graphic
GetFilteredGraphic( const Graphic
& rGraphic
, double fScaleX
, double fScaleY
) SAL_OVERRIDE
;
106 double GetRadius() const { return mpMtrRadius
->GetValue() / 10.0; }
109 class GraphicFilterMosaic
: public GraphicFilterDialog
112 VclPtr
<MetricField
> mpMtrWidth
;
113 VclPtr
<MetricField
> mpMtrHeight
;
114 VclPtr
<CheckBox
> mpCbxEdges
;
118 GraphicFilterMosaic(vcl::Window
* pParent
, const Graphic
& rGraphic
,
119 sal_uInt16 nTileWidth
, sal_uInt16 nTileHeight
, bool bEnhanceEdges
);
120 virtual ~GraphicFilterMosaic();
121 virtual void dispose() SAL_OVERRIDE
;
123 virtual Graphic
GetFilteredGraphic( const Graphic
& rGraphic
, double fScaleX
, double fScaleY
) SAL_OVERRIDE
;
124 long GetTileWidth() const { return static_cast<long>(mpMtrWidth
->GetValue()); }
125 long GetTileHeight() const { return static_cast<long>(mpMtrHeight
->GetValue()); }
126 bool IsEnhanceEdges() const { return mpCbxEdges
->IsChecked(); }
129 class GraphicFilterSolarize
: public GraphicFilterDialog
132 VclPtr
<MetricField
> mpMtrThreshold
;
133 VclPtr
<CheckBox
> mpCbxInvert
;
137 GraphicFilterSolarize( vcl::Window
* pParent
, const Graphic
& rGraphic
,
138 sal_uInt8 nGreyThreshold
, bool bInvert
);
139 virtual ~GraphicFilterSolarize();
140 virtual void dispose() SAL_OVERRIDE
;
142 virtual Graphic
GetFilteredGraphic( const Graphic
& rGraphic
, double fScaleX
, double fScaleY
) SAL_OVERRIDE
;
143 sal_uInt8
GetGreyThreshold() const { return( (sal_uInt8
) FRound( mpMtrThreshold
->GetValue() * 2.55 ) ); }
144 bool IsInvert() const { return mpCbxInvert
->IsChecked(); }
147 class GraphicFilterSepia
: public GraphicFilterDialog
150 VclPtr
<MetricField
> mpMtrSepia
;
152 GraphicFilterSepia( vcl::Window
* pParent
, const Graphic
& rGraphic
,
153 sal_uInt16 nSepiaPercent
);
154 virtual ~GraphicFilterSepia();
155 virtual void dispose() SAL_OVERRIDE
;
156 virtual Graphic
GetFilteredGraphic( const Graphic
& rGraphic
, double fScaleX
, double fScaleY
) SAL_OVERRIDE
;
157 sal_uInt16
GetSepiaPercent() const
159 return sal::static_int_cast
< sal_uInt16
>(mpMtrSepia
->GetValue());
163 class GraphicFilterPoster
: public GraphicFilterDialog
166 VclPtr
<NumericField
> mpNumPoster
;
168 GraphicFilterPoster( vcl::Window
* pParent
, const Graphic
& rGraphic
,
169 sal_uInt16 nPosterColorCount
);
170 virtual ~GraphicFilterPoster();
171 virtual void dispose() SAL_OVERRIDE
;
173 virtual Graphic
GetFilteredGraphic( const Graphic
& rGraphic
, double fScaleX
, double fScaleY
) SAL_OVERRIDE
;
174 sal_uInt16
GetPosterColorCount() const { return( (sal_uInt16
) mpNumPoster
->GetValue() ); }
177 class EmbossControl
: public SvxRectCtl
181 virtual void MouseButtonDown( const MouseEvent
& rEvt
) SAL_OVERRIDE
;
182 virtual Size
GetOptimalSize() const SAL_OVERRIDE
;
184 EmbossControl(vcl::Window
* pParent
)
185 : SvxRectCtl(pParent
) {}
187 void SetModifyHdl( const Link
<>& rHdl
) { maModifyHdl
= rHdl
; }
190 class GraphicFilterEmboss
: public GraphicFilterDialog
193 VclPtr
<EmbossControl
> mpCtlLight
;
195 GraphicFilterEmboss( vcl::Window
* pParent
, const Graphic
& rGraphic
,
196 RECT_POINT eLightSource
);
197 virtual ~GraphicFilterEmboss();
198 virtual void dispose() SAL_OVERRIDE
;
200 virtual Graphic
GetFilteredGraphic( const Graphic
& rGraphic
, double fScaleX
, double fScaleY
) SAL_OVERRIDE
;
201 RECT_POINT
GetLightSource() const { return mpCtlLight
->GetActualRP(); }
206 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */