Version 5.4.3.2, tag libreoffice-5.4.3.2
[LibreOffice.git] / include / svx / dlgctrl.hxx
blobfd96b1ce247a46a10f3da2b3ed2ef51b0104e423
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 .
19 #ifndef INCLUDED_SVX_DLGCTRL_HXX
20 #define INCLUDED_SVX_DLGCTRL_HXX
22 #include <svtools/ctrlbox.hxx>
23 #include <sfx2/tabdlg.hxx>
24 #include <svx/svxdllapi.h>
25 #include <svx/rectenum.hxx>
26 #include <vcl/graph.hxx>
27 #include <svx/xtable.hxx>
28 #include <rtl/ref.hxx>
29 #include <o3tl/typed_flags_set.hxx>
31 class XOBitmap;
32 class XOutdevItemPool;
34 namespace com { namespace sun { namespace star { namespace awt {
35 struct Point;
36 } } } }
38 /*************************************************************************
39 |* Derived from SfxTabPage for being able to get notified through the
40 |* virtual method from the control.
41 \************************************************************************/
43 class SAL_WARN_UNUSED SvxTabPage : public SfxTabPage
46 public:
47 SvxTabPage(vcl::Window *pParent, const OString& rID, const OUString& rUIXMLDescription, const SfxItemSet &rAttrSet)
48 : SfxTabPage(pParent, rID, rUIXMLDescription, &rAttrSet)
51 virtual void PointChanged( vcl::Window* pWindow, RectPoint eRP ) = 0;
54 /*************************************************************************
55 |* Control for display and selection of the corner and center points of
56 |* an object
57 \************************************************************************/
59 enum class CTL_STATE
61 NONE = 0,
62 NOHORZ = 1, // no horizontal input information is used
63 NOVERT = 2, // no vertical input information is used
65 namespace o3tl
67 template<> struct typed_flags<CTL_STATE> : is_typed_flags<CTL_STATE, 0x03> {};
70 class SvxRectCtlAccessibleContext;
71 class SvxPixelCtlAccessible;
73 class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxRectCtl : public Control
75 private:
76 SVX_DLLPRIVATE void InitSettings(vcl::RenderContext& rRenderContext);
77 SVX_DLLPRIVATE void InitRectBitmap();
78 SVX_DLLPRIVATE BitmapEx& GetRectBitmap();
79 SVX_DLLPRIVATE void Resize_Impl();
81 protected:
82 rtl::Reference<SvxRectCtlAccessibleContext> pAccContext;
83 sal_uInt16 nBorderWidth;
84 sal_uInt16 nRadius;
85 Size aSize;
86 Point aPtLT, aPtMT, aPtRT;
87 Point aPtLM, aPtMM, aPtRM;
88 Point aPtLB, aPtMB, aPtRB;
89 Point aPtNew;
90 RectPoint eRP, eDefRP;
91 BitmapEx* pBitmap;
92 CTL_STATE m_nState;
94 bool mbCompleteDisable : 1;
95 bool mbUpdateForeground : 1;
96 bool mbUpdateBackground : 1;
98 void MarkToResetSettings(bool bUpdateForeground, bool bUpdateBackground);
100 RectPoint GetRPFromPoint( Point, bool bRTL = false ) const;
101 const Point& GetPointFromRP( RectPoint ) const;
102 void SetFocusRect();
103 Point SetActualRPWithoutInvalidate( RectPoint eNewRP ); // returns the last point
105 virtual void GetFocus() override;
106 virtual void LoseFocus() override;
108 Point GetApproxLogPtFromPixPt( const Point& rRoughPixelPoint ) const;
109 public:
110 SvxRectCtl( vcl::Window* pParent, RectPoint eRpt = RectPoint::MM,
111 sal_uInt16 nBorder = 200, sal_uInt16 nCircle = 80 );
112 void SetControlSettings(RectPoint eRpt, sal_uInt16 nBorder, sal_uInt16 nCircl);
113 virtual ~SvxRectCtl() override;
114 virtual void dispose() override;
116 virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
117 virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
118 virtual void KeyInput( const KeyEvent& rKeyEvt ) override;
119 virtual void StateChanged( StateChangedType nStateChange ) override;
120 virtual void DataChanged( const DataChangedEvent& rDCEvt ) override;
121 virtual void Resize() override;
122 virtual Size GetOptimalSize() const override;
124 void Reset();
125 RectPoint GetActualRP() const { return eRP;}
126 void SetActualRP( RectPoint eNewRP );
128 void SetState( CTL_STATE nState );
130 static const sal_uInt8 NO_CHILDREN = 9; // returns number of usable radio buttons
132 tools::Rectangle CalculateFocusRectangle() const;
133 tools::Rectangle CalculateFocusRectangle( RectPoint eRectPoint ) const;
135 virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override;
137 RectPoint GetApproxRPFromPixPt( const css::awt::Point& rPixelPoint ) const;
139 bool IsCompletelyDisabled() const { return mbCompleteDisable; }
140 void DoCompletelyDisable(bool bNew);
143 /*************************************************************************
144 |* Control for editing bitmaps
145 \************************************************************************/
147 class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxPixelCtl : public Control
149 private:
150 using OutputDevice::SetLineColor;
152 protected:
153 sal_uInt16 nLines, nSquares;
154 Color aPixelColor;
155 Color aBackgroundColor;
156 Color aLineColor;
157 Size aRectSize;
158 sal_uInt16* pPixel;
159 bool bPaintable;
160 //Add member identifying position
161 Point aFocusPosition;
162 rtl::Reference<SvxPixelCtlAccessible> m_xAccess;
164 tools::Rectangle implCalFocusRect( const Point& aPosition );
165 void ChangePixel( sal_uInt16 nPixel );
167 public:
168 SvxPixelCtl( vcl::Window* pParent, sal_uInt16 nNumber = 8 );
170 virtual ~SvxPixelCtl() override;
171 virtual void dispose() override;
173 virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
174 virtual void MouseButtonDown( const MouseEvent& rMEvt ) override;
175 virtual void Resize() override;
176 virtual Size GetOptimalSize() const override;
178 void SetXBitmap( const BitmapEx& rBitmapEx );
180 void SetPixelColor( const Color& rCol ) { aPixelColor = rCol; }
181 void SetBackgroundColor( const Color& rCol ) { aBackgroundColor = rCol; }
183 sal_uInt16 GetLineCount() const { return nLines; }
185 sal_uInt16 GetBitmapPixel( const sal_uInt16 nPixelNumber );
186 sal_uInt16* GetBitmapPixelPtr() { return pPixel; }
188 void SetPaintable( bool bTmp ) { bPaintable = bTmp; }
189 void Reset();
190 virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override;
191 long GetSquares() const { return nSquares ; }
192 long GetWidth() const { return aRectSize.getWidth() ; }
193 long GetHeight() const { return aRectSize.getHeight() ; }
195 //Device Pixel .
196 long ShowPosition( const Point &pt);
198 long PointToIndex(const Point &pt) const;
199 Point IndexToPoint(long nIndex) const ;
200 long GetFocusPosIndex() const ;
201 //Keyboard function for key input and focus handling function
202 virtual void KeyInput( const KeyEvent& rKEvt ) override;
203 virtual void GetFocus() override;
204 virtual void LoseFocus() override;
207 /************************************************************************/
209 class SAL_WARN_UNUSED SVX_DLLPUBLIC HatchingLB : public ListBox
211 public:
212 explicit HatchingLB(vcl::Window* pParent, WinBits aWB);
215 /************************************************************************/
217 class SAL_WARN_UNUSED SVX_DLLPUBLIC GradientLB : public ListBox
219 public:
220 explicit GradientLB(vcl::Window* pParent, WinBits aWB);
223 /************************************************************************/
225 class SAL_WARN_UNUSED SVX_DLLPUBLIC BitmapLB : public ListBox
227 public:
228 explicit BitmapLB(vcl::Window* pParent, WinBits aWB);
231 /************************************************************************/
233 class SAL_WARN_UNUSED SVX_DLLPUBLIC FillAttrLB : public ListBox
235 private:
236 BitmapEx maBitmapEx;
238 public:
239 FillAttrLB( vcl::Window* pParent, WinBits aWB );
241 void Fill( const XHatchListRef &pList );
242 void Fill( const XGradientListRef &pList );
243 void Fill( const XBitmapListRef &pList );
244 void Fill( const XPatternListRef &pList );
247 /************************************************************************/
249 class SAL_WARN_UNUSED SVX_DLLPUBLIC FillTypeLB : public ListBox
252 public:
253 FillTypeLB( vcl::Window* pParent, WinBits aWB ) : ListBox( pParent, aWB ) {}
255 void Fill();
258 /************************************************************************/
260 class SAL_WARN_UNUSED SVX_DLLPUBLIC LineLB : public ListBox
262 private:
263 /// defines if standard fields (none, solid) are added, default is true
264 bool mbAddStandardFields : 1;
266 public:
267 LineLB(vcl::Window* pParent, WinBits aWB);
269 void Fill(const XDashListRef &pList);
270 bool getAddStandardFields() const { return mbAddStandardFields; }
271 void setAddStandardFields(bool bNew);
273 void Append(const XDashEntry& rEntry, const Bitmap& rBitmap );
274 void Modify(const XDashEntry& rEntry, sal_Int32 nPos, const Bitmap& rBitmap );
278 /************************************************************************/
280 class SAL_WARN_UNUSED SVX_DLLPUBLIC LineEndLB : public ListBox
283 public:
284 LineEndLB( vcl::Window* pParent, WinBits aWB );
286 void Fill( const XLineEndListRef &pList, bool bStart = true );
288 void Append( const XLineEndEntry& rEntry, const Bitmap& rBitmap );
289 void Modify( const XLineEndEntry& rEntry, sal_Int32 nPos, const Bitmap& rBitmap );
293 class SdrObject;
294 class SdrPathObj;
295 class SdrModel;
297 class SAL_WARN_UNUSED SvxPreviewBase : public Control
299 private:
300 SdrModel* mpModel;
301 VclPtr<VirtualDevice> mpBufferDevice;
303 protected:
304 void InitSettings(bool bForeground, bool bBackground);
306 // prepare buffered paint
307 void LocalPrePaint(vcl::RenderContext& rRenderContext);
309 // end and output buffered paint
310 void LocalPostPaint(vcl::RenderContext& rRenderContext);
312 public:
313 SvxPreviewBase(vcl::Window* pParent);
314 virtual ~SvxPreviewBase() override;
315 virtual void dispose() override;
317 // change support
318 virtual void StateChanged(StateChangedType nStateChange) override;
319 virtual void DataChanged(const DataChangedEvent& rDCEvt) override;
321 // dada read access
322 SdrModel& getModel() const
324 return *mpModel;
326 OutputDevice& getBufferDevice() const
328 return *mpBufferDevice;
332 /*************************************************************************
334 |* SvxLinePreview
336 \************************************************************************/
338 class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxXLinePreview : public SvxPreviewBase
340 private:
341 SdrPathObj* mpLineObjA;
342 SdrPathObj* mpLineObjB;
343 SdrPathObj* mpLineObjC;
345 Graphic* mpGraphic;
346 bool mbWithSymbol;
347 Size maSymbolSize;
349 public:
350 SvxXLinePreview( vcl::Window* pParent );
351 virtual ~SvxXLinePreview() override;
352 virtual void dispose() override;
354 void SetLineAttributes(const SfxItemSet& rItemSet);
356 void ShowSymbol( bool b ) { mbWithSymbol = b; };
357 void SetSymbol( Graphic* p, const Size& s );
358 void ResizeSymbol( const Size& s );
360 virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
361 virtual void Resize() override;
362 virtual Size GetOptimalSize() const override;
365 /*************************************************************************
367 |* SvxXRectPreview
369 \************************************************************************/
371 class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxXRectPreview : public SvxPreviewBase
373 private:
374 SdrObject* mpRectangleObject;
376 public:
377 SvxXRectPreview(vcl::Window* pParent);
378 virtual ~SvxXRectPreview() override;
379 virtual void dispose() override;
381 void SetAttributes(const SfxItemSet& rItemSet);
383 virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
384 virtual void Resize() override;
387 /*************************************************************************
389 |* SvxXShadowPreview
391 \************************************************************************/
393 class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxXShadowPreview : public SvxPreviewBase
395 private:
396 Point maShadowOffset;
398 SdrObject* mpRectangleObject;
399 SdrObject* mpRectangleShadow;
401 public:
402 SvxXShadowPreview(vcl::Window *pParent);
404 virtual ~SvxXShadowPreview() override;
405 virtual void dispose() override;
407 void SetRectangleAttributes(const SfxItemSet& rItemSet);
408 void SetShadowAttributes(const SfxItemSet& rItemSet);
409 void SetShadowPosition(const Point& rPos);
411 virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
414 #endif // INCLUDED_SVX_DLGCTRL_HXX
416 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */