Branch libreoffice-5-0-4
[LibreOffice.git] / include / svx / dlgctrl.hxx
blob20d79a5058f0dafa1025056ecf655cf16b1d4292
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 <o3tl/typed_flags_set.hxx>
30 class XOBitmap;
31 class XOutdevItemPool;
33 namespace com { namespace sun { namespace star { namespace awt {
34 struct Point;
35 } } } }
37 /*************************************************************************
38 |* Derived from SfxTabPage for being able to get notified through the
39 |* virtual method from the control.
40 \************************************************************************/
42 class SAL_WARN_UNUSED SvxTabPage : public SfxTabPage
45 public:
46 SvxTabPage(vcl::Window *pParent, const OString& rID, const OUString& rUIXMLDescription, const SfxItemSet &rAttrSet)
47 : SfxTabPage(pParent, rID, rUIXMLDescription, &rAttrSet)
50 virtual void PointChanged( vcl::Window* pWindow, RECT_POINT eRP ) = 0;
53 /*************************************************************************
54 |* Control for display and selection of the corner and center points of
55 |* an object
56 \************************************************************************/
58 enum class CTL_STATE
60 NONE = 0,
61 NOHORZ = 1, // no horizontal input information is used
62 NOVERT = 2, // no vertical input information is used
64 namespace o3tl
66 template<> struct typed_flags<CTL_STATE> : is_typed_flags<CTL_STATE, 0x03> {};
69 class SvxRectCtlAccessibleContext;
70 class SvxPixelCtlAccessible;
72 class SVX_DLLPUBLIC SAL_WARN_UNUSED SvxRectCtl : public Control
74 private:
75 SVX_DLLPRIVATE void InitSettings(vcl::RenderContext& rRenderContext);
76 SVX_DLLPRIVATE void InitRectBitmap();
77 SVX_DLLPRIVATE Bitmap& GetRectBitmap();
78 SVX_DLLPRIVATE void Resize_Impl();
80 protected:
81 SvxRectCtlAccessibleContext* pAccContext;
82 sal_uInt16 nBorderWidth;
83 sal_uInt16 nRadius;
84 Size aSize;
85 Point aPtLT, aPtMT, aPtRT;
86 Point aPtLM, aPtMM, aPtRM;
87 Point aPtLB, aPtMB, aPtRB;
88 Point aPtNew;
89 RECT_POINT eRP, eDefRP;
90 CTL_STYLE eCS;
91 Bitmap* 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 RECT_POINT GetRPFromPoint( Point, bool bRTL = false ) const;
101 Point GetPointFromRP( RECT_POINT ) const;
102 void SetFocusRect( const Rectangle* pRect = NULL ); // pRect == NULL -> calculate rectangle in method
103 Point SetActualRPWithoutInvalidate( RECT_POINT eNewRP ); // returns the last point
105 virtual void GetFocus() SAL_OVERRIDE;
106 virtual void LoseFocus() SAL_OVERRIDE;
108 Point GetApproxLogPtFromPixPt( const Point& rRoughPixelPoint ) const;
109 public:
110 SvxRectCtl( vcl::Window* pParent, RECT_POINT eRpt = RP_MM,
111 sal_uInt16 nBorder = 200, sal_uInt16 nCircle = 80, CTL_STYLE eStyle = CS_RECT );
112 void SetControlSettings(RECT_POINT eRpt = RP_MM, sal_uInt16 nBorder = 200,
113 sal_uInt16 nCircle = 80, CTL_STYLE eStyle = CS_RECT);
114 virtual ~SvxRectCtl();
115 virtual void dispose() SAL_OVERRIDE;
117 virtual void Paint( vcl::RenderContext& rRenderContext, const Rectangle& rRect ) SAL_OVERRIDE;
118 virtual void MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
119 virtual void KeyInput( const KeyEvent& rKeyEvt ) SAL_OVERRIDE;
120 virtual void StateChanged( StateChangedType nStateChange ) SAL_OVERRIDE;
121 virtual void DataChanged( const DataChangedEvent& rDCEvt ) SAL_OVERRIDE;
122 virtual void Resize() SAL_OVERRIDE;
123 virtual Size GetOptimalSize() const SAL_OVERRIDE;
125 void Reset();
126 RECT_POINT GetActualRP() const { return eRP;}
127 void SetActualRP( RECT_POINT eNewRP );
129 void SetState( CTL_STATE nState );
131 sal_uInt8 GetNumOfChildren() const; // returns number of usable radio buttons
133 Rectangle CalculateFocusRectangle() const;
134 Rectangle CalculateFocusRectangle( RECT_POINT eRectPoint ) const;
136 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible() SAL_OVERRIDE;
138 RECT_POINT GetApproxRPFromPixPt( const ::com::sun::star::awt::Point& rPixelPoint ) const;
140 bool IsCompletelyDisabled() const { return mbCompleteDisable; }
141 void DoCompletelyDisable(bool bNew);
142 void SetCS(CTL_STYLE eNew);
145 /*************************************************************************
146 |* Preview control for the display of bitmaps
147 \************************************************************************/
149 class SVX_DLLPUBLIC SAL_WARN_UNUSED SvxBitmapCtl
151 protected:
152 Size aSize;
153 sal_uInt16 nLines;
154 Color aPixelColor, aBackgroundColor;
155 const sal_uInt16* pBmpArray;
157 public:
158 SvxBitmapCtl( vcl::Window* pParent, const Size& rSize );
159 ~SvxBitmapCtl();
161 BitmapEx GetBitmapEx();
163 void SetBmpArray( const sal_uInt16* pPixel ) { pBmpArray = pPixel; }
164 void SetLines( sal_uInt16 nLns ) { nLines = nLns; }
165 void SetPixelColor( Color aColor ) { aPixelColor = aColor; }
166 void SetBackgroundColor( Color aColor ) { aBackgroundColor = aColor; }
169 /*************************************************************************
170 |* Control for editing bitmaps
171 \************************************************************************/
173 class SVX_DLLPUBLIC SAL_WARN_UNUSED SvxPixelCtl : public Control
175 private:
176 using OutputDevice::SetLineColor;
178 protected:
179 sal_uInt16 nLines, nSquares;
180 Color aPixelColor;
181 Color aBackgroundColor;
182 Color aLineColor;
183 Size aRectSize;
184 sal_uInt16* pPixel;
185 bool bPaintable;
186 //Add member identifying position
187 Point aFocusPosition;
188 Rectangle implCalFocusRect( const Point& aPosition );
189 void ChangePixel( sal_uInt16 nPixel );
191 public:
192 SvxPixelCtl( vcl::Window* pParent, sal_uInt16 nNumber = 8 );
194 virtual ~SvxPixelCtl();
195 virtual void dispose() SAL_OVERRIDE;
197 virtual void Paint( vcl::RenderContext& rRenderContext, const Rectangle& rRect ) SAL_OVERRIDE;
198 virtual void MouseButtonDown( const MouseEvent& rMEvt ) SAL_OVERRIDE;
199 virtual void Resize() SAL_OVERRIDE;
200 virtual Size GetOptimalSize() const SAL_OVERRIDE;
202 void SetXBitmap( const BitmapEx& rBitmapEx );
204 void SetPixelColor( const Color& rCol ) { aPixelColor = rCol; }
205 void SetBackgroundColor( const Color& rCol ) { aBackgroundColor = rCol; }
206 void SetLineColor( const Color& rCol ) { aLineColor = rCol; }
208 sal_uInt16 GetLineCount() const { return nLines; }
209 Color GetPixelColor() const { return aPixelColor; }
210 Color GetBackgroundColor() const { return aBackgroundColor; }
212 sal_uInt16 GetBitmapPixel( const sal_uInt16 nPixelNumber );
213 sal_uInt16* GetBitmapPixelPtr() { return pPixel; }
215 void SetPaintable( bool bTmp ) { bPaintable = bTmp; }
216 void Reset();
217 SvxPixelCtlAccessible* m_pAccess;
218 ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > m_xAccess;
219 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible() SAL_OVERRIDE;
220 long GetSquares() const { return nSquares ; }
221 long GetWidth() const { return aRectSize.getWidth() ; }
222 long GetHeight() const { return aRectSize.getHeight() ; }
224 //Device Pixel .
225 long ShowPosition( const Point &pt);
227 long PointToIndex(const Point &pt) const;
228 Point IndexToPoint(long nIndex) const ;
229 long GetFoucsPosIndex() const ;
230 //Keyboard function for key input and focus handling function
231 virtual void KeyInput( const KeyEvent& rKEvt ) SAL_OVERRIDE;
232 virtual void GetFocus() SAL_OVERRIDE;
233 virtual void LoseFocus() SAL_OVERRIDE;
236 /************************************************************************/
238 class SVX_DLLPUBLIC SAL_WARN_UNUSED ColorLB : public ColorListBox
241 public:
242 ColorLB( vcl::Window* pParent, ResId Id ) : ColorListBox( pParent, Id ) {}
243 ColorLB( vcl::Window* pParent, WinBits aWB ) : ColorListBox( pParent, aWB ) {}
245 void Fill( const XColorListRef &pTab );
247 void Append( const XColorEntry& rEntry );
248 void Modify( const XColorEntry& rEntry, sal_Int32 nPos );
251 /************************************************************************/
253 class SVX_DLLPUBLIC SAL_WARN_UNUSED HatchingLB : public ListBox
255 XHatchListRef mpList;
256 public:
257 explicit HatchingLB(vcl::Window* pParent, WinBits aWB);
259 void Fill( const XHatchListRef &pList );
261 void Append( const XHatchEntry& rEntry, const Bitmap& rBitmap );
262 void Modify( const XHatchEntry& rEntry, sal_Int32 nPos, const Bitmap& rBitmap );
265 /************************************************************************/
267 class SVX_DLLPUBLIC SAL_WARN_UNUSED GradientLB : public ListBox
269 XGradientListRef mpList;
270 public:
271 explicit GradientLB(vcl::Window* pParent, WinBits aWB);
273 void Fill( const XGradientListRef &pList );
275 void Append( const XGradientEntry& rEntry, const Bitmap& rBitmap );
276 void Modify( const XGradientEntry& rEntry, sal_Int32 nPos, const Bitmap& rBitmap );
277 void SelectEntryByList( const XGradientListRef &pList, const OUString& rStr,
278 const XGradient& rXGradient, sal_uInt16 nDist = 0 );
281 /************************************************************************/
283 class SVX_DLLPUBLIC SAL_WARN_UNUSED BitmapLB : public ListBox
285 public:
286 explicit BitmapLB(vcl::Window* pParent, WinBits aWB);
288 void Fill(const XBitmapListRef &pList);
290 void Append(const Size& rSize, const XBitmapEntry& rEntry);
291 void Modify(const Size& rSize, const XBitmapEntry& rEntry, sal_Int32 nPos);
292 void SelectEntryByList(const XBitmapList* pList, const OUString& rStr);
294 private:
295 BitmapEx maBitmapEx;
297 XBitmapListRef mpList;
300 /************************************************************************/
302 class SVX_DLLPUBLIC SAL_WARN_UNUSED FillAttrLB : public ColorListBox
304 private:
305 BitmapEx maBitmapEx;
307 public:
308 FillAttrLB( vcl::Window* pParent, WinBits aWB );
310 void Fill( const XHatchListRef &pList );
311 void Fill( const XGradientListRef &pList );
312 void Fill( const XBitmapListRef &pList );
315 /************************************************************************/
317 class SVX_DLLPUBLIC SAL_WARN_UNUSED FillTypeLB : public ListBox
320 public:
321 FillTypeLB( vcl::Window* pParent, ResId Id ) : ListBox( pParent, Id ) {}
322 FillTypeLB( vcl::Window* pParent, WinBits aWB ) : ListBox( pParent, aWB ) {}
324 void Fill();
327 /************************************************************************/
329 class SVX_DLLPUBLIC SAL_WARN_UNUSED LineLB : public ListBox
331 private:
332 /// bitfield
333 /// defines if standard fields (none, solid) are added, default is true
334 bool mbAddStandardFields : 1;
336 public:
337 LineLB(vcl::Window* pParent, WinBits aWB);
339 void Fill(const XDashListRef &pList);
340 bool getAddStandardFields() const { return mbAddStandardFields; }
341 void setAddStandardFields(bool bNew);
343 void Append(const XDashEntry& rEntry, const Bitmap& rBitmap );
344 void Modify(const XDashEntry& rEntry, sal_Int32 nPos, const Bitmap& rBitmap );
345 void SelectEntryByList(const XDashList* pList, const OUString& rStr, const XDash& rDash, sal_uInt16 nDist = 0);
349 /************************************************************************/
351 class SVX_DLLPUBLIC SAL_WARN_UNUSED LineEndLB : public ListBox
354 public:
355 LineEndLB( vcl::Window* pParent, WinBits aWB );
357 void Fill( const XLineEndListRef &pList, bool bStart = true );
359 void Append( const XLineEndEntry& rEntry, const Bitmap& rBitmap, bool bStart = true );
360 void Modify( const XLineEndEntry& rEntry, sal_Int32 nPos, const Bitmap& rBitmap, bool bStart = true );
364 class SdrObject;
365 class SdrPathObj;
366 class SdrModel;
368 class SAL_WARN_UNUSED SvxPreviewBase : public Control
370 private:
371 SdrModel* mpModel;
372 VclPtr<VirtualDevice> mpBufferDevice;
374 protected:
375 void InitSettings(bool bForeground, bool bBackground);
377 // prepare buffered paint
378 void LocalPrePaint(vcl::RenderContext& rRenderContext);
380 // end and output buffered paint
381 void LocalPostPaint(vcl::RenderContext& rRenderContext);
383 public:
384 SvxPreviewBase(vcl::Window* pParent);
385 virtual ~SvxPreviewBase();
386 virtual void dispose() SAL_OVERRIDE;
388 // change support
389 virtual void StateChanged(StateChangedType nStateChange) SAL_OVERRIDE;
390 virtual void DataChanged(const DataChangedEvent& rDCEvt) SAL_OVERRIDE;
392 // dada read access
393 SdrModel& getModel() const
395 return *mpModel;
397 OutputDevice& getBufferDevice() const
399 return *mpBufferDevice;
403 /*************************************************************************
405 |* SvxLinePreview
407 \************************************************************************/
409 class SVX_DLLPUBLIC SAL_WARN_UNUSED SvxXLinePreview : public SvxPreviewBase
411 private:
412 SdrPathObj* mpLineObjA;
413 SdrPathObj* mpLineObjB;
414 SdrPathObj* mpLineObjC;
416 Graphic* mpGraphic;
417 bool mbWithSymbol;
418 Size maSymbolSize;
420 public:
421 SvxXLinePreview( vcl::Window* pParent );
422 virtual ~SvxXLinePreview();
423 virtual void dispose() SAL_OVERRIDE;
425 void SetLineAttributes(const SfxItemSet& rItemSet);
427 void ShowSymbol( bool b ) { mbWithSymbol = b; };
428 void SetSymbol( Graphic* p, const Size& s );
429 void ResizeSymbol( const Size& s );
431 virtual void Paint( vcl::RenderContext& rRenderContext, const Rectangle& rRect ) SAL_OVERRIDE;
432 virtual void Resize() SAL_OVERRIDE;
433 virtual Size GetOptimalSize() const SAL_OVERRIDE;
436 /*************************************************************************
438 |* SvxXRectPreview
440 \************************************************************************/
442 class SVX_DLLPUBLIC SAL_WARN_UNUSED SvxXRectPreview : public SvxPreviewBase
444 private:
445 SdrObject* mpRectangleObject;
447 public:
448 SvxXRectPreview(vcl::Window* pParent);
449 virtual ~SvxXRectPreview();
450 virtual void dispose() SAL_OVERRIDE;
452 void SetAttributes(const SfxItemSet& rItemSet);
454 virtual void Paint( vcl::RenderContext& rRenderContext, const Rectangle& rRect ) SAL_OVERRIDE;
455 virtual void Resize() SAL_OVERRIDE;
458 /*************************************************************************
460 |* SvxXShadowPreview
462 \************************************************************************/
464 class SVX_DLLPUBLIC SAL_WARN_UNUSED SvxXShadowPreview : public SvxPreviewBase
466 private:
467 Point maShadowOffset;
469 SdrObject* mpRectangleObject;
470 SdrObject* mpRectangleShadow;
472 public:
473 SvxXShadowPreview(vcl::Window *pParent);
475 virtual ~SvxXShadowPreview();
476 virtual void dispose() SAL_OVERRIDE;
478 void SetRectangleAttributes(const SfxItemSet& rItemSet);
479 void SetShadowAttributes(const SfxItemSet& rItemSet);
480 void SetShadowPosition(const Point& rPos);
482 virtual void Paint( vcl::RenderContext& rRenderContext, const Rectangle& rRect ) SAL_OVERRIDE;
485 #endif // INCLUDED_SVX_DLGCTRL_HXX
487 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */