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 .
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>
30 class XOutdevItemPool
;
32 namespace com
{ namespace sun
{ namespace star
{ namespace awt
{
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
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
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
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();
76 SvxRectCtlAccessibleContext
* pAccContext
;
77 sal_uInt16 nBorderWidth
;
80 Point aPtLT
, aPtMT
, aPtRT
;
81 Point aPtLM
, aPtMM
, aPtRM
;
82 Point aPtLB
, aPtMB
, aPtRB
;
84 RECT_POINT eRP
, eDefRP
;
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;
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;
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
146 Color aPixelColor
, aBackgroundColor
;
147 const sal_uInt16
* pBmpArray
;
150 SvxBitmapCtl( Window
* pParent
, const Size
& rSize
);
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
168 using OutputDevice::SetLineColor
;
171 sal_uInt16 nLines
, nSquares
;
173 Color aBackgroundColor
;
179 void ChangePixel( sal_uInt16 nPixel
);
182 SvxPixelCtl( Window
* pParent
, sal_uInt16 nNumber
= 8 );
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
; }
207 /************************************************************************/
209 class SVX_DLLPUBLIC ColorLB
: public ColorListBox
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
;
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
;
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
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
);
268 XBitmapListRef mpList
;
271 /************************************************************************/
273 class FillAttrLB
: public ColorListBox
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
293 FillTypeLB( Window
* pParent
, ResId Id
) : ListBox( pParent
, Id
) {}
294 FillTypeLB( Window
* pParent
, WinBits aWB
) : ListBox( pParent
, aWB
) {}
299 /************************************************************************/
301 class SVX_DLLPUBLIC LineLB
: public ListBox
305 /// defines if standard fields (none, solid) are added, default is true
306 bool mbAddStandardFields
: 1;
309 LineLB(Window
* pParent
, WinBits aWB
);
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
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 //////////////////////////////////////////////////////////////////////////////
343 class SvxPreviewBase
: public Control
347 VirtualDevice
* mpBufferDevice
;
350 void InitSettings(bool bForeground
, bool bBackground
);
352 // prepare buffered paint
353 void LocalPrePaint();
355 // end and output buffered paint
356 void LocalPostPaint();
359 SvxPreviewBase(Window
* pParent
);
360 virtual ~SvxPreviewBase();
363 virtual void StateChanged(StateChangedType nStateChange
);
364 virtual void DataChanged(const DataChangedEvent
& rDCEvt
);
367 SdrModel
& getModel() const { return *mpModel
; }
368 OutputDevice
& getBufferDevice() const { return *mpBufferDevice
; }
371 /*************************************************************************
375 \************************************************************************/
377 class SVX_DLLPUBLIC SvxXLinePreview
: public SvxPreviewBase
380 SdrPathObj
* mpLineObjA
;
381 SdrPathObj
* mpLineObjB
;
382 SdrPathObj
* mpLineObjC
;
385 sal_Bool mbWithSymbol
;
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 /*************************************************************************
407 \************************************************************************/
409 class SVX_DLLPUBLIC SvxXRectPreview
: public SvxPreviewBase
412 SdrObject
* mpRectangleObject
;
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 /*************************************************************************
428 \************************************************************************/
430 class SVX_DLLPUBLIC SvxXShadowPreview
: public SvxPreviewBase
433 Point maShadowOffset
;
435 SdrObject
* mpRectangleObject
;
436 SdrObject
* mpRectangleShadow
;
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: */