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 <sfx2/tabdlg.hxx>
23 #include <svx/svxdllapi.h>
24 #include <svx/rectenum.hxx>
25 #include <vcl/customweld.hxx>
26 #include <vcl/lstbox.hxx>
27 #include <vcl/weld.hxx>
28 #include <vcl/virdev.hxx>
29 #include <svx/xtable.hxx>
30 #include <rtl/ref.hxx>
31 #include <o3tl/typed_flags_set.hxx>
35 namespace com
{ namespace sun
{ namespace star
{ namespace awt
{
39 /*************************************************************************
40 |* Derived from SfxTabPage for being able to get notified through the
41 |* virtual method from the control.
42 \************************************************************************/
44 class SAL_WARN_UNUSED SvxTabPage
: public SfxTabPage
48 SvxTabPage(TabPageParent pParent
, const OUString
& rUIXMLDescription
, const OString
& rID
, const SfxItemSet
&rAttrSet
)
49 : SfxTabPage(pParent
, rUIXMLDescription
, rID
, &rAttrSet
)
52 virtual void PointChanged(weld::DrawingArea
* pArea
, RectPoint eRP
) = 0;
55 /*************************************************************************
56 |* Control for display and selection of the corner and center points of
58 \************************************************************************/
63 NOHORZ
= 1, // no horizontal input information is used
64 NOVERT
= 2, // no vertical input information is used
68 template<> struct typed_flags
<CTL_STATE
> : is_typed_flags
<CTL_STATE
, 0x03> {};
71 class SvxRectCtlAccessibleContext
;
72 class SvxPixelCtlAccessible
;
74 class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxRectCtl
: public weld::CustomWidgetController
77 VclPtr
<SvxTabPage
> m_pPage
;
79 SVX_DLLPRIVATE
static void InitSettings(vcl::RenderContext
& rRenderContext
);
80 SVX_DLLPRIVATE
void InitRectBitmap();
81 SVX_DLLPRIVATE BitmapEx
& GetRectBitmap();
82 SVX_DLLPRIVATE
void Resize_Impl(const Size
& rSize
);
84 SvxRectCtl(const SvxRectCtl
&) = delete;
85 SvxRectCtl
& operator=(const SvxRectCtl
&) = delete;
88 rtl::Reference
<SvxRectCtlAccessibleContext
> pAccContext
;
89 sal_uInt16 nBorderWidth
;
90 Point aPtLT
, aPtMT
, aPtRT
;
91 Point aPtLM
, aPtMM
, aPtRM
;
92 Point aPtLB
, aPtMB
, aPtRB
;
94 RectPoint eRP
, eDefRP
;
95 std::unique_ptr
<BitmapEx
> pBitmap
;
98 bool mbCompleteDisable
: 1;
100 RectPoint
GetRPFromPoint( Point
, bool bRTL
= false ) const;
101 const Point
& GetPointFromRP( RectPoint
) const;
102 Point
SetActualRPWithoutInvalidate( RectPoint eNewRP
); // returns the last point
104 Point
GetApproxLogPtFromPixPt( const Point
& rRoughPixelPoint
) const;
106 SvxRectCtl(SvxTabPage
* pPage
, RectPoint eRpt
= RectPoint::MM
, sal_uInt16 nBorder
= 200);
107 void SetControlSettings(RectPoint eRpt
, sal_uInt16 nBorder
);
108 virtual ~SvxRectCtl() override
;
110 virtual void Paint(vcl::RenderContext
& rRenderContext
, const tools::Rectangle
&) override
;
111 virtual void Resize() override
;
112 virtual bool MouseButtonDown(const MouseEvent
&) override
;
113 virtual bool KeyInput(const KeyEvent
&) override
;
114 virtual void GetFocus() override
;
115 virtual void LoseFocus() override
;
116 virtual tools::Rectangle
GetFocusRect() override
;
117 virtual void SetDrawingArea(weld::DrawingArea
* pDrawingArea
) override
;
118 virtual void StyleUpdated() override
;
121 RectPoint
GetActualRP() const { return eRP
;}
122 void SetActualRP( RectPoint eNewRP
);
124 void SetState( CTL_STATE nState
);
126 static const sal_uInt8 NO_CHILDREN
= 9; // returns number of usable radio buttons
128 tools::Rectangle
CalculateFocusRectangle() const;
129 tools::Rectangle
CalculateFocusRectangle( RectPoint eRectPoint
) const;
131 css::uno::Reference
<css::accessibility::XAccessible
> getAccessibleParent() { return GetDrawingArea()->get_accessible_parent(); }
132 virtual css::uno::Reference
<css::accessibility::XAccessible
> CreateAccessible() override
;
133 a11yrelationset
get_accessible_relation_set() { return GetDrawingArea()->get_accessible_relation_set(); }
135 RectPoint
GetApproxRPFromPixPt( const css::awt::Point
& rPixelPoint
) const;
137 bool IsCompletelyDisabled() const { return mbCompleteDisable
; }
138 void DoCompletelyDisable(bool bNew
);
141 /*************************************************************************
142 |* Control for editing bitmaps
143 \************************************************************************/
145 class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxPixelCtl final
: public weld::CustomWidgetController
148 static sal_uInt16
constexpr nLines
= 8;
149 static sal_uInt16
constexpr nSquares
= nLines
* nLines
;
151 VclPtr
<SvxTabPage
> m_pPage
;
154 Color aBackgroundColor
;
156 std::array
<sal_uInt8
,nSquares
> maPixelData
;
158 //Add member identifying position
159 Point aFocusPosition
;
160 rtl::Reference
<SvxPixelCtlAccessible
> m_xAccess
;
162 tools::Rectangle
implCalFocusRect( const Point
& aPosition
);
163 void ChangePixel( sal_uInt16 nPixel
);
165 SvxPixelCtl(SvxPixelCtl
const&) = delete;
166 SvxPixelCtl(SvxPixelCtl
&&) = delete;
167 SvxPixelCtl
& operator=(SvxPixelCtl
const&) = delete;
168 SvxPixelCtl
& operator=(SvxPixelCtl
&&) = delete;
171 SvxPixelCtl(SvxTabPage
* pPage
);
173 virtual ~SvxPixelCtl() override
;
175 virtual void SetDrawingArea(weld::DrawingArea
* pDrawingArea
) override
;
176 virtual void Paint( vcl::RenderContext
& rRenderContext
, const tools::Rectangle
& rRect
) override
;
177 virtual bool MouseButtonDown( const MouseEvent
& rMEvt
) override
;
178 virtual void Resize() override
;
179 virtual tools::Rectangle
GetFocusRect() override
;
181 void SetXBitmap( const BitmapEx
& rBitmapEx
);
183 void SetPixelColor( const Color
& rCol
) { aPixelColor
= rCol
; }
184 void SetBackgroundColor( const Color
& rCol
) { aBackgroundColor
= rCol
; }
186 static sal_uInt16
GetLineCount() { return nLines
; }
188 sal_uInt8
GetBitmapPixel( const sal_uInt16 nPixelNumber
) const;
189 std::array
<sal_uInt8
,64> const & GetBitmapPixelPtr() const { return maPixelData
; }
191 void SetPaintable( bool bTmp
) { bPaintable
= bTmp
; }
194 css::uno::Reference
<css::accessibility::XAccessible
> getAccessibleParent() { return GetDrawingArea()->get_accessible_parent(); }
195 virtual css::uno::Reference
<css::accessibility::XAccessible
> CreateAccessible() override
;
196 a11yrelationset
get_accessible_relation_set() { return GetDrawingArea()->get_accessible_relation_set(); }
198 static long GetSquares() { return nSquares
; }
199 long GetWidth() const { return aRectSize
.getWidth() ; }
200 long GetHeight() const { return aRectSize
.getHeight() ; }
203 long ShowPosition( const Point
&pt
);
205 long PointToIndex(const Point
&pt
) const;
206 Point
IndexToPoint(long nIndex
) const ;
207 long GetFocusPosIndex() const ;
208 //Keyboard function for key input and focus handling function
209 virtual bool KeyInput( const KeyEvent
& rKEvt
) override
;
210 virtual void GetFocus() override
;
211 virtual void LoseFocus() override
;
214 /************************************************************************/
216 class SAL_WARN_UNUSED SVX_DLLPUBLIC FillTypeLB
: public ListBox
220 FillTypeLB( vcl::Window
* pParent
, WinBits aWB
) : ListBox( pParent
, aWB
) {}
225 /************************************************************************/
227 class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxLineLB
230 std::unique_ptr
<weld::ComboBox
> m_xControl
;
232 /// defines if standard fields (none, solid) are added, default is true
233 bool mbAddStandardFields
: 1;
236 SvxLineLB(std::unique_ptr
<weld::ComboBox
> pControl
);
238 void Fill(const XDashListRef
&pList
);
239 bool getAddStandardFields() const { return mbAddStandardFields
; }
240 void setAddStandardFields(bool bNew
);
242 void Append(const XDashEntry
& rEntry
, const BitmapEx
& rBitmap
);
243 void Modify(const XDashEntry
& rEntry
, sal_Int32 nPos
, const BitmapEx
& rBitmap
);
245 void clear() { m_xControl
->clear(); }
246 void remove(int nPos
) { m_xControl
->remove(nPos
); }
247 int get_active() const { return m_xControl
->get_active(); }
248 void set_active(int nPos
) { m_xControl
->set_active(nPos
); }
249 void set_active_text(const OUString
& rStr
) { m_xControl
->set_active_text(rStr
); }
250 OUString
get_active_text() const { return m_xControl
->get_active_text(); }
251 void connect_changed(const Link
<weld::ComboBox
&, void>& rLink
) { m_xControl
->connect_changed(rLink
); }
252 int get_count() const { return m_xControl
->get_count(); }
253 void append_text(const OUString
& rStr
) { m_xControl
->append_text(rStr
); }
254 bool get_value_changed_from_saved() const { return m_xControl
->get_value_changed_from_saved(); }
255 void save_value() { m_xControl
->save_value(); }
256 void set_sensitive(bool bSensitive
) { m_xControl
->set_sensitive(bSensitive
); }
257 bool get_sensitive() const { return m_xControl
->get_sensitive(); }
260 /************************************************************************/
262 class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxLineEndLB
265 std::unique_ptr
<weld::ComboBox
> m_xControl
;
268 SvxLineEndLB(std::unique_ptr
<weld::ComboBox
> pControl
);
270 void Fill( const XLineEndListRef
&pList
, bool bStart
= true );
272 void Append( const XLineEndEntry
& rEntry
, const BitmapEx
& rBitmap
);
273 void Modify( const XLineEndEntry
& rEntry
, sal_Int32 nPos
, const BitmapEx
& rBitmap
);
275 void clear() { m_xControl
->clear(); }
276 void remove(int nPos
) { m_xControl
->remove(nPos
); }
277 int get_active() const { return m_xControl
->get_active(); }
278 void set_active(int nPos
) { m_xControl
->set_active(nPos
); }
279 void set_active_text(const OUString
& rStr
) { m_xControl
->set_active_text(rStr
); }
280 OUString
get_active_text() const { return m_xControl
->get_active_text(); }
281 void connect_changed(const Link
<weld::ComboBox
&, void>& rLink
) { m_xControl
->connect_changed(rLink
); }
282 int get_count() const { return m_xControl
->get_count(); }
283 void append_text(const OUString
& rStr
) { m_xControl
->append_text(rStr
); }
284 bool get_value_changed_from_saved() const { return m_xControl
->get_value_changed_from_saved(); }
285 void save_value() { m_xControl
->save_value(); }
286 void set_sensitive(bool bSensitive
) { m_xControl
->set_sensitive(bSensitive
); }
287 bool get_sensitive() const { return m_xControl
->get_sensitive(); }
294 class SAL_WARN_UNUSED SAL_DLLPUBLIC_RTTI SvxPreviewBase
: public weld::CustomWidgetController
297 std::unique_ptr
<SdrModel
> mpModel
;
298 VclPtr
<VirtualDevice
> mpBufferDevice
;
303 tools::Rectangle
GetPreviewSize() const;
305 // prepare buffered paint
306 void LocalPrePaint(vcl::RenderContext
const & rRenderContext
);
308 // end and output buffered paint
309 void LocalPostPaint(vcl::RenderContext
& rRenderContext
);
313 virtual void SetDrawingArea(weld::DrawingArea
*) override
;
314 virtual ~SvxPreviewBase() override
;
317 virtual void StyleUpdated() override
;
319 void SetDrawMode(DrawModeFlags nDrawMode
)
321 mpBufferDevice
->SetDrawMode(nDrawMode
);
324 Size
GetOutputSize() const
326 return mpBufferDevice
->PixelToLogic(GetOutputSizePixel());
330 SdrModel
& getModel() const
334 OutputDevice
& getBufferDevice() const
336 return *mpBufferDevice
;
341 /*************************************************************************
345 \************************************************************************/
347 class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxXLinePreview
: public SvxPreviewBase
350 SdrPathObj
* mpLineObjA
;
351 SdrPathObj
* mpLineObjB
;
352 SdrPathObj
* mpLineObjC
;
360 virtual void SetDrawingArea(weld::DrawingArea
* pDrawingArea
) override
;
361 virtual ~SvxXLinePreview() override
;
363 void SetLineAttributes(const SfxItemSet
& rItemSet
);
365 void ShowSymbol( bool b
) { mbWithSymbol
= b
; };
366 void SetSymbol( Graphic
* p
, const Size
& s
);
367 void ResizeSymbol( const Size
& s
);
369 virtual void Paint( vcl::RenderContext
& rRenderContext
, const tools::Rectangle
& rRect
) override
;
370 virtual void Resize() override
;
373 class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxXRectPreview
: public SvxPreviewBase
376 SdrObject
* mpRectangleObject
;
380 virtual void SetDrawingArea(weld::DrawingArea
* pDrawingArea
) override
;
381 virtual ~SvxXRectPreview() override
;
383 void SetAttributes(const SfxItemSet
& rItemSet
);
385 virtual void Paint( vcl::RenderContext
& rRenderContext
, const tools::Rectangle
& rRect
) override
;
386 virtual void Resize() override
;
389 /*************************************************************************
393 \************************************************************************/
395 class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxXShadowPreview
: public SvxPreviewBase
398 Point maShadowOffset
;
400 SdrObject
* mpRectangleObject
;
401 SdrObject
* mpRectangleShadow
;
405 virtual void SetDrawingArea(weld::DrawingArea
* pDrawingArea
) override
;
406 virtual ~SvxXShadowPreview() override
;
408 void SetRectangleAttributes(const SfxItemSet
& rItemSet
);
409 void SetShadowAttributes(const SfxItemSet
& rItemSet
);
410 void SetShadowPosition(const Point
& rPos
);
412 virtual void Paint( vcl::RenderContext
& rRenderContext
, const tools::Rectangle
& rRect
) override
;
415 #endif // INCLUDED_SVX_DLGCTRL_HXX
417 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */