bump product version to 4.2.0.1
[LibreOffice.git] / include / svx / dlgctrl.hxx
blob6cca020c3e1959b49711a8ae55115f9b8a367de1
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>
29 class XOBitmap;
30 class XOutdevItemPool;
32 namespace com { namespace sun { namespace star { namespace awt {
33 struct Point;
34 } } } }
36 /*************************************************************************
37 |* Derived from SfxTabPage for being able to get notified through the
38 |* virtual method from the control.
39 \************************************************************************/
41 class SvxTabPage : public SfxTabPage
44 public:
45 SvxTabPage(Window* pParent, ResId Id, const SfxItemSet& rInAttrs)
46 : SfxTabPage(pParent, Id, rInAttrs)
49 SvxTabPage(Window *pParent, const OString& rID, const OUString& rUIXMLDescription, const SfxItemSet &rAttrSet)
50 : SfxTabPage(pParent, rID, rUIXMLDescription, rAttrSet)
53 virtual void PointChanged( Window* pWindow, RECT_POINT eRP ) = 0;
56 /*************************************************************************
57 |* Control for display and selection of the corner and center points of
58 |* an object
59 \************************************************************************/
61 typedef sal_uInt16 CTL_STATE;
62 #define CS_NOHORZ 1 // no horizontal input information is used
63 #define CS_NOVERT 2 // no vertikal input information is used
65 class SvxRectCtlAccessibleContext;
67 class SVX_DLLPUBLIC SvxRectCtl : public Control
69 private:
70 SVX_DLLPRIVATE void InitSettings( sal_Bool bForeground, sal_Bool bBackground );
71 SVX_DLLPRIVATE void InitRectBitmap( void );
72 SVX_DLLPRIVATE Bitmap& GetRectBitmap( void );
73 SVX_DLLPRIVATE void Resize_Impl();
75 protected:
76 SvxRectCtlAccessibleContext* pAccContext;
77 sal_uInt16 nBorderWidth;
78 sal_uInt16 nRadius;
79 Size aSize;
80 Point aPtLT, aPtMT, aPtRT;
81 Point aPtLM, aPtMM, aPtRM;
82 Point aPtLB, aPtMB, aPtRB;
83 Point aPtNew;
84 RECT_POINT eRP, eDefRP;
85 CTL_STYLE eCS;
86 Bitmap* pBitmap;
87 CTL_STATE m_nState;
89 sal_Bool mbCompleteDisable;
91 RECT_POINT GetRPFromPoint( Point ) const;
92 Point GetPointFromRP( RECT_POINT ) const;
93 void SetFocusRect( const Rectangle* pRect = NULL ); // pRect == NULL -> calculate rectangle in method
94 Point SetActualRPWithoutInvalidate( RECT_POINT eNewRP ); // returns the last point
96 virtual void GetFocus();
97 virtual void LoseFocus();
99 Point GetApproxLogPtFromPixPt( const Point& rRoughPixelPoint ) const;
100 public:
101 SvxRectCtl( Window* pParent, const ResId& rResId, RECT_POINT eRpt = RP_MM,
102 sal_uInt16 nBorder = 200, sal_uInt16 nCircle = 80, CTL_STYLE eStyle = CS_RECT );
103 SvxRectCtl( Window* pParent, RECT_POINT eRpt = RP_MM,
104 sal_uInt16 nBorder = 200, sal_uInt16 nCircle = 80, CTL_STYLE eStyle = CS_RECT );
105 void SetControlSettings(RECT_POINT eRpt = RP_MM, sal_uInt16 nBorder = 200,
106 sal_uInt16 nCircle = 80, CTL_STYLE eStyle = CS_RECT);
107 virtual ~SvxRectCtl();
109 virtual void Paint( const Rectangle& rRect );
110 virtual void MouseButtonDown( const MouseEvent& rMEvt );
111 virtual void KeyInput( const KeyEvent& rKeyEvt );
112 virtual void StateChanged( StateChangedType nStateChange );
113 virtual void DataChanged( const DataChangedEvent& rDCEvt );
114 virtual void Resize();
115 virtual Size GetOptimalSize() const;
117 void Reset();
118 RECT_POINT GetActualRP() const;
119 void SetActualRP( RECT_POINT eNewRP );
121 void SetState( CTL_STATE nState );
123 sal_uInt8 GetNumOfChildren( void ) const; // returns number of usable radio buttons
125 Rectangle CalculateFocusRectangle( void ) const;
126 Rectangle CalculateFocusRectangle( RECT_POINT eRectPoint ) const;
128 virtual ::com::sun::star::uno::Reference< ::com::sun::star::accessibility::XAccessible > CreateAccessible();
130 RECT_POINT GetApproxRPFromPixPt( const ::com::sun::star::awt::Point& rPixelPoint ) const;
132 sal_Bool IsCompletelyDisabled() const { return mbCompleteDisable; }
133 void DoCompletelyDisable(sal_Bool bNew);
134 void SetCS(CTL_STYLE eNew);
137 /*************************************************************************
138 |* Preview control for the display of bitmaps
139 \************************************************************************/
141 class SVX_DLLPUBLIC SvxBitmapCtl
143 protected:
144 Size aSize;
145 sal_uInt16 nLines;
146 Color aPixelColor, aBackgroundColor;
147 const sal_uInt16* pBmpArray;
149 public:
150 SvxBitmapCtl( Window* pParent, const Size& rSize );
151 ~SvxBitmapCtl();
153 BitmapEx GetBitmapEx();
155 void SetBmpArray( const sal_uInt16* pPixel ) { pBmpArray = pPixel; }
156 void SetLines( sal_uInt16 nLns ) { nLines = nLns; }
157 void SetPixelColor( Color aColor ) { aPixelColor = aColor; }
158 void SetBackgroundColor( Color aColor ) { aBackgroundColor = aColor; }
161 /*************************************************************************
162 |* Control for editing bitmaps
163 \************************************************************************/
165 class SVX_DLLPUBLIC SvxPixelCtl : public Control
167 private:
168 using OutputDevice::SetLineColor;
170 protected:
171 sal_uInt16 nLines, nSquares;
172 Color aPixelColor;
173 Color aBackgroundColor;
174 Color aLineColor;
175 Size aRectSize;
176 sal_uInt16* pPixel;
177 sal_Bool bPaintable;
179 void ChangePixel( sal_uInt16 nPixel );
181 public:
182 SvxPixelCtl( Window* pParent, sal_uInt16 nNumber = 8 );
184 ~SvxPixelCtl();
186 virtual void Paint( const Rectangle& rRect );
187 virtual void MouseButtonDown( const MouseEvent& rMEvt );
188 virtual void Resize();
189 virtual Size GetOptimalSize() const;
191 void SetXBitmap( const BitmapEx& rBitmapEx );
193 void SetPixelColor( const Color& rCol ) { aPixelColor = rCol; }
194 void SetBackgroundColor( const Color& rCol ) { aBackgroundColor = rCol; }
195 void SetLineColor( const Color& rCol ) { aLineColor = rCol; }
197 sal_uInt16 GetLineCount() const { return nLines; }
198 Color GetPixelColor() const { return aPixelColor; }
199 Color GetBackgroundColor() const { return aBackgroundColor; }
201 sal_uInt16* GetBitmapPixelPtr() { return pPixel; }
203 void SetPaintable( sal_Bool bTmp ) { bPaintable = bTmp; }
204 void Reset();
207 /************************************************************************/
209 class SVX_DLLPUBLIC ColorLB : public ColorListBox
212 public:
213 ColorLB( Window* pParent, ResId Id ) : ColorListBox( pParent, Id ) {}
214 ColorLB( Window* pParent, WinBits aWB ) : ColorListBox( pParent, aWB ) {}
216 virtual void Fill( const XColorListRef &pTab );
218 void Append( const XColorEntry& rEntry );
219 void Modify( const XColorEntry& rEntry, sal_uInt16 nPos );
222 /************************************************************************/
224 class SVX_DLLPUBLIC HatchingLB : public ListBox
226 XHatchListRef mpList;
227 public:
228 explicit HatchingLB(Window* pParent, WinBits aWB);
230 virtual void Fill( const XHatchListRef &pList );
232 void Append( const XHatchEntry& rEntry, const Bitmap& rBitmap );
233 void Modify( const XHatchEntry& rEntry, sal_uInt16 nPos, const Bitmap& rBitmap );
236 /************************************************************************/
238 class SVX_DLLPUBLIC GradientLB : public ListBox
240 XGradientListRef mpList;
241 public:
242 explicit GradientLB(Window* pParent, WinBits aWB);
244 virtual void Fill( const XGradientListRef &pList );
246 void Append( const XGradientEntry& rEntry, const Bitmap& rBitmap );
247 void Modify( const XGradientEntry& rEntry, sal_uInt16 nPos, const Bitmap& rBitmap );
248 void SelectEntryByList( const XGradientListRef &pList, const OUString& rStr,
249 const XGradient& rXGradient, sal_uInt16 nDist = 0 );
252 /************************************************************************/
254 class SVX_DLLPUBLIC BitmapLB : public ListBox
256 public:
257 explicit BitmapLB(Window* pParent, WinBits aWB);
259 virtual void Fill(const XBitmapListRef &pList);
261 void Append(const Size& rSize, const XBitmapEntry& rEntry);
262 void Modify(const Size& rSize, const XBitmapEntry& rEntry, sal_uInt16 nPos);
263 void SelectEntryByList(const XBitmapList* pList, const OUString& rStr);
265 private:
266 BitmapEx maBitmapEx;
268 XBitmapListRef mpList;
271 /************************************************************************/
273 class FillAttrLB : public ColorListBox
275 private:
276 BitmapEx maBitmapEx;
278 public:
279 FillAttrLB( Window* pParent, WinBits aWB );
281 virtual void Fill( const XColorListRef &pList );
282 virtual void Fill( const XHatchListRef &pList );
283 virtual void Fill( const XGradientListRef &pList );
284 virtual void Fill( const XBitmapListRef &pList );
287 /************************************************************************/
289 class FillTypeLB : public ListBox
292 public:
293 FillTypeLB( Window* pParent, ResId Id ) : ListBox( pParent, Id ) {}
294 FillTypeLB( Window* pParent, WinBits aWB ) : ListBox( pParent, aWB ) {}
296 virtual void Fill();
299 /************************************************************************/
301 class SVX_DLLPUBLIC LineLB : public ListBox
303 private:
304 /// bitfield
305 /// defines if standard fields (none, solid) are added, default is true
306 bool mbAddStandardFields : 1;
308 public:
309 LineLB(Window* pParent, WinBits aWB);
310 virtual ~LineLB();
312 virtual void Fill(const XDashListRef &pList);
313 bool getAddStandardFields() const { return mbAddStandardFields; }
314 void setAddStandardFields(bool bNew);
316 void Append(const XDashEntry& rEntry, const Bitmap& rBitmap );
317 void Modify(const XDashEntry& rEntry, sal_uInt16 nPos, const Bitmap& rBitmap );
318 void SelectEntryByList(const XDashList* pList, const OUString& rStr, const XDash& rDash, sal_uInt16 nDist = 0);
322 /************************************************************************/
324 class SVX_DLLPUBLIC LineEndLB : public ListBox
327 public:
328 LineEndLB( Window* pParent, WinBits aWB );
329 virtual ~LineEndLB (void);
331 virtual void Fill( const XLineEndListRef &pList, bool bStart = true );
333 void Append( const XLineEndEntry& rEntry, const Bitmap& rBitmap, bool bStart = true );
334 void Modify( const XLineEndEntry& rEntry, sal_uInt16 nPos, const Bitmap& rBitmap, bool bStart = true );
337 //////////////////////////////////////////////////////////////////////////////
339 class SdrObject;
340 class SdrPathObj;
341 class SdrModel;
343 class SvxPreviewBase : public Control
345 private:
346 SdrModel* mpModel;
347 VirtualDevice* mpBufferDevice;
349 protected:
350 void InitSettings(bool bForeground, bool bBackground);
352 // prepare buffered paint
353 void LocalPrePaint();
355 // end and output buffered paint
356 void LocalPostPaint();
358 public:
359 SvxPreviewBase(Window* pParent);
360 virtual ~SvxPreviewBase();
362 // change support
363 virtual void StateChanged(StateChangedType nStateChange);
364 virtual void DataChanged(const DataChangedEvent& rDCEvt);
366 // dada read access
367 SdrModel& getModel() const { return *mpModel; }
368 OutputDevice& getBufferDevice() const { return *mpBufferDevice; }
371 /*************************************************************************
373 |* SvxLinePreview
375 \************************************************************************/
377 class SVX_DLLPUBLIC SvxXLinePreview : public SvxPreviewBase
379 private:
380 SdrPathObj* mpLineObjA;
381 SdrPathObj* mpLineObjB;
382 SdrPathObj* mpLineObjC;
384 Graphic* mpGraphic;
385 sal_Bool mbWithSymbol;
386 Size maSymbolSize;
388 public:
389 SvxXLinePreview( Window* pParent );
390 virtual ~SvxXLinePreview();
392 void SetLineAttributes(const SfxItemSet& rItemSet);
394 void ShowSymbol( sal_Bool b ) { mbWithSymbol = b; };
395 void SetSymbol( Graphic* p, const Size& s );
396 void ResizeSymbol( const Size& s );
398 virtual void Paint( const Rectangle& rRect );
399 virtual void Resize();
400 virtual Size GetOptimalSize() const;
403 /*************************************************************************
405 |* SvxXRectPreview
407 \************************************************************************/
409 class SVX_DLLPUBLIC SvxXRectPreview : public SvxPreviewBase
411 private:
412 SdrObject* mpRectangleObject;
414 public:
415 SvxXRectPreview(Window* pParent);
416 virtual ~SvxXRectPreview();
418 void SetAttributes(const SfxItemSet& rItemSet);
420 virtual void Paint( const Rectangle& rRect );
421 virtual void Resize();
424 /*************************************************************************
426 |* SvxXShadowPreview
428 \************************************************************************/
430 class SVX_DLLPUBLIC SvxXShadowPreview : public SvxPreviewBase
432 private:
433 Point maShadowOffset;
435 SdrObject* mpRectangleObject;
436 SdrObject* mpRectangleShadow;
438 public:
439 SvxXShadowPreview(Window *pParent);
441 virtual ~SvxXShadowPreview();
443 void SetRectangleAttributes(const SfxItemSet& rItemSet);
444 void SetShadowAttributes(const SfxItemSet& rItemSet);
445 void SetShadowPosition(const Point& rPos);
447 virtual void Paint( const Rectangle& rRect );
450 #endif // INCLUDED_SVX_DLGCTRL_HXX
452 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */