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/weld.hxx>
27 #include <vcl/virdev.hxx>
28 #include <svx/xtable.hxx>
29 #include <rtl/ref.hxx>
30 #include <o3tl/typed_flags_set.hxx>
34 namespace com::sun::star::awt
{
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
47 SvxTabPage(weld::Container
* pPage
, weld::DialogController
* pController
, const OUString
& rUIXMLDescription
, const OString
& rID
, const SfxItemSet
&rAttrSet
)
48 : SfxTabPage(pPage
, pController
, rUIXMLDescription
, rID
, &rAttrSet
)
51 virtual void PointChanged(weld::DrawingArea
* pArea
, RectPoint eRP
) = 0;
54 /*************************************************************************
55 |* Control for display and selection of the corner and center points of
57 \************************************************************************/
62 NOHORZ
= 1, // no horizontal input information is used
63 NOVERT
= 2, // no vertical input information is used
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 weld::CustomWidgetController
78 SVX_DLLPRIVATE
static void InitSettings(vcl::RenderContext
& rRenderContext
);
79 SVX_DLLPRIVATE
void InitRectBitmap();
80 SVX_DLLPRIVATE BitmapEx
& GetRectBitmap();
81 SVX_DLLPRIVATE
void Resize_Impl(const Size
& rSize
);
83 SvxRectCtl(const SvxRectCtl
&) = delete;
84 SvxRectCtl
& operator=(const SvxRectCtl
&) = delete;
87 rtl::Reference
<SvxRectCtlAccessibleContext
> pAccContext
;
88 sal_uInt16 nBorderWidth
;
89 Point aPtLT
, aPtMT
, aPtRT
;
90 Point aPtLM
, aPtMM
, aPtRM
;
91 Point aPtLB
, aPtMB
, aPtRB
;
93 RectPoint eRP
, eDefRP
;
94 std::unique_ptr
<BitmapEx
> pBitmap
;
97 bool mbCompleteDisable
: 1;
99 RectPoint
GetRPFromPoint( Point
, bool bRTL
= false ) const;
100 const Point
& GetPointFromRP( RectPoint
) const;
101 Point
SetActualRPWithoutInvalidate( RectPoint eNewRP
); // returns the last point
103 Point
GetApproxLogPtFromPixPt( const Point
& rRoughPixelPoint
) const;
105 SvxRectCtl(SvxTabPage
* pPage
);
106 void SetControlSettings(RectPoint eRpt
, sal_uInt16 nBorder
);
107 virtual ~SvxRectCtl() override
;
109 virtual void Paint(vcl::RenderContext
& rRenderContext
, const tools::Rectangle
&) override
;
110 virtual void Resize() override
;
111 virtual bool MouseButtonDown(const MouseEvent
&) override
;
112 virtual bool KeyInput(const KeyEvent
&) override
;
113 virtual void GetFocus() override
;
114 virtual void LoseFocus() override
;
115 virtual tools::Rectangle
GetFocusRect() override
;
116 virtual void SetDrawingArea(weld::DrawingArea
* pDrawingArea
) override
;
117 virtual void StyleUpdated() override
;
120 RectPoint
GetActualRP() const { return eRP
;}
121 void SetActualRP( RectPoint eNewRP
);
123 void SetState( CTL_STATE nState
);
125 static const sal_uInt8 NO_CHILDREN
= 9; // returns number of usable radio buttons
127 tools::Rectangle
CalculateFocusRectangle() const;
128 tools::Rectangle
CalculateFocusRectangle( RectPoint eRectPoint
) const;
130 css::uno::Reference
<css::accessibility::XAccessible
> getAccessibleParent() const { return GetDrawingArea()->get_accessible_parent(); }
131 virtual css::uno::Reference
<css::accessibility::XAccessible
> CreateAccessible() override
;
132 a11yrelationset
get_accessible_relation_set() const { return GetDrawingArea()->get_accessible_relation_set(); }
134 RectPoint
GetApproxRPFromPixPt( const css::awt::Point
& rPixelPoint
) const;
136 bool IsCompletelyDisabled() const { return mbCompleteDisable
; }
137 void DoCompletelyDisable(bool bNew
);
140 /*************************************************************************
141 |* Control for editing bitmaps
142 \************************************************************************/
144 class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxPixelCtl final
: public weld::CustomWidgetController
147 static sal_uInt16
constexpr nLines
= 8;
148 static sal_uInt16
constexpr nSquares
= nLines
* nLines
;
153 Color aBackgroundColor
;
155 std::array
<sal_uInt8
,nSquares
> maPixelData
;
157 //Add member identifying position
158 Point aFocusPosition
;
159 rtl::Reference
<SvxPixelCtlAccessible
> m_xAccess
;
161 tools::Rectangle
implCalFocusRect( const Point
& aPosition
);
162 void ChangePixel( sal_uInt16 nPixel
);
164 SvxPixelCtl(SvxPixelCtl
const&) = delete;
165 SvxPixelCtl(SvxPixelCtl
&&) = delete;
166 SvxPixelCtl
& operator=(SvxPixelCtl
const&) = delete;
167 SvxPixelCtl
& operator=(SvxPixelCtl
&&) = delete;
170 SvxPixelCtl(SvxTabPage
* pPage
);
172 virtual ~SvxPixelCtl() override
;
174 virtual void SetDrawingArea(weld::DrawingArea
* pDrawingArea
) override
;
175 virtual void Paint( vcl::RenderContext
& rRenderContext
, const tools::Rectangle
& rRect
) override
;
176 virtual bool MouseButtonDown( const MouseEvent
& rMEvt
) override
;
177 virtual void Resize() override
;
178 virtual tools::Rectangle
GetFocusRect() override
;
180 void SetXBitmap( const BitmapEx
& rBitmapEx
);
182 void SetPixelColor( const Color
& rCol
) { aPixelColor
= rCol
; }
183 void SetBackgroundColor( const Color
& rCol
) { aBackgroundColor
= rCol
; }
185 static sal_uInt16
GetLineCount() { return nLines
; }
187 sal_uInt8
GetBitmapPixel( const sal_uInt16 nPixelNumber
) const;
188 std::array
<sal_uInt8
,64> const & GetBitmapPixelPtr() const { return maPixelData
; }
190 void SetPaintable( bool bTmp
) { bPaintable
= bTmp
; }
193 css::uno::Reference
<css::accessibility::XAccessible
> getAccessibleParent() const { return GetDrawingArea()->get_accessible_parent(); }
194 virtual css::uno::Reference
<css::accessibility::XAccessible
> CreateAccessible() override
;
195 a11yrelationset
get_accessible_relation_set() const { return GetDrawingArea()->get_accessible_relation_set(); }
197 static tools::Long
GetSquares() { return nSquares
; }
198 tools::Long
GetWidth() const { return aRectSize
.getWidth() ; }
199 tools::Long
GetHeight() const { return aRectSize
.getHeight() ; }
202 tools::Long
ShowPosition( const Point
&pt
);
204 tools::Long
PointToIndex(const Point
&pt
) const;
205 Point
IndexToPoint(tools::Long nIndex
) const ;
206 tools::Long
GetFocusPosIndex() const ;
207 //Keyboard function for key input and focus handling function
208 virtual bool KeyInput( const KeyEvent
& rKEvt
) override
;
209 virtual void GetFocus() override
;
210 virtual void LoseFocus() override
;
213 /************************************************************************/
215 class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxLineLB
218 std::unique_ptr
<weld::ComboBox
> m_xControl
;
220 /// defines if standard fields (none, solid) are added, default is true
221 bool mbAddStandardFields
: 1;
224 SvxLineLB(std::unique_ptr
<weld::ComboBox
> pControl
);
226 void Fill(const XDashListRef
&pList
);
227 bool getAddStandardFields() const { return mbAddStandardFields
; }
228 void setAddStandardFields(bool bNew
);
230 void Append(const XDashEntry
& rEntry
, const BitmapEx
& rBitmap
);
231 void Modify(const XDashEntry
& rEntry
, sal_Int32 nPos
, const BitmapEx
& rBitmap
);
233 void clear() { m_xControl
->clear(); }
234 void remove(int nPos
) { m_xControl
->remove(nPos
); }
235 int get_active() const { return m_xControl
->get_active(); }
236 void set_active(int nPos
) { m_xControl
->set_active(nPos
); }
237 void set_active_text(const OUString
& rStr
) { m_xControl
->set_active_text(rStr
); }
238 OUString
get_active_text() const { return m_xControl
->get_active_text(); }
239 void connect_changed(const Link
<weld::ComboBox
&, void>& rLink
) { m_xControl
->connect_changed(rLink
); }
240 int get_count() const { return m_xControl
->get_count(); }
241 void append_text(const OUString
& rStr
) { m_xControl
->append_text(rStr
); }
242 bool get_value_changed_from_saved() const { return m_xControl
->get_value_changed_from_saved(); }
243 void save_value() { m_xControl
->save_value(); }
246 /************************************************************************/
248 class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxLineEndLB
251 std::unique_ptr
<weld::ComboBox
> m_xControl
;
254 SvxLineEndLB(std::unique_ptr
<weld::ComboBox
> pControl
);
256 void Fill( const XLineEndListRef
&pList
, bool bStart
= true );
258 void Append( const XLineEndEntry
& rEntry
, const BitmapEx
& rBitmap
);
259 void Modify( const XLineEndEntry
& rEntry
, sal_Int32 nPos
, const BitmapEx
& rBitmap
);
261 void clear() { m_xControl
->clear(); }
262 void remove(int nPos
) { m_xControl
->remove(nPos
); }
263 int get_active() const { return m_xControl
->get_active(); }
264 void set_active(int nPos
) { m_xControl
->set_active(nPos
); }
265 void set_active_text(const OUString
& rStr
) { m_xControl
->set_active_text(rStr
); }
266 OUString
get_active_text() const { return m_xControl
->get_active_text(); }
267 void connect_changed(const Link
<weld::ComboBox
&, void>& rLink
) { m_xControl
->connect_changed(rLink
); }
268 int get_count() const { return m_xControl
->get_count(); }
269 void append_text(const OUString
& rStr
) { m_xControl
->append_text(rStr
); }
270 bool get_value_changed_from_saved() const { return m_xControl
->get_value_changed_from_saved(); }
271 void save_value() { m_xControl
->save_value(); }
272 void set_sensitive(bool bSensitive
) { m_xControl
->set_sensitive(bSensitive
); }
273 bool get_sensitive() const { return m_xControl
->get_sensitive(); }
280 class SAL_WARN_UNUSED SAL_DLLPUBLIC_RTTI SvxPreviewBase
: public weld::CustomWidgetController
283 std::unique_ptr
<SdrModel
> mpModel
;
284 VclPtr
<VirtualDevice
> mpBufferDevice
;
289 tools::Rectangle
GetPreviewSize() const;
291 // prepare buffered paint
292 void LocalPrePaint(vcl::RenderContext
const & rRenderContext
);
294 // end and output buffered paint
295 void LocalPostPaint(vcl::RenderContext
& rRenderContext
);
299 virtual void SetDrawingArea(weld::DrawingArea
*) override
;
300 virtual ~SvxPreviewBase() override
;
303 virtual void StyleUpdated() override
;
305 void SetDrawMode(DrawModeFlags nDrawMode
)
307 mpBufferDevice
->SetDrawMode(nDrawMode
);
310 Size
GetOutputSize() const
312 return mpBufferDevice
->PixelToLogic(GetOutputSizePixel());
316 SdrModel
& getModel() const
320 OutputDevice
& getBufferDevice() const
322 return *mpBufferDevice
;
327 /*************************************************************************
331 \************************************************************************/
333 class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxXLinePreview final
: public SvxPreviewBase
336 SdrPathObj
* mpLineObjA
;
337 SdrPathObj
* mpLineObjB
;
338 SdrPathObj
* mpLineObjC
;
346 virtual void SetDrawingArea(weld::DrawingArea
* pDrawingArea
) override
;
347 virtual ~SvxXLinePreview() override
;
349 void SetLineAttributes(const SfxItemSet
& rItemSet
);
351 void ShowSymbol( bool b
) { mbWithSymbol
= b
; };
352 void SetSymbol( Graphic
* p
, const Size
& s
);
353 void ResizeSymbol( const Size
& s
);
355 virtual void Paint( vcl::RenderContext
& rRenderContext
, const tools::Rectangle
& rRect
) override
;
356 virtual void Resize() override
;
359 class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxXRectPreview final
: public SvxPreviewBase
362 SdrObject
* mpRectangleObject
;
366 virtual void SetDrawingArea(weld::DrawingArea
* pDrawingArea
) override
;
367 virtual ~SvxXRectPreview() override
;
369 void SetAttributes(const SfxItemSet
& rItemSet
);
371 virtual void Paint( vcl::RenderContext
& rRenderContext
, const tools::Rectangle
& rRect
) override
;
372 virtual void Resize() override
;
375 /*************************************************************************
379 \************************************************************************/
381 class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxXShadowPreview final
: public SvxPreviewBase
384 Point maShadowOffset
;
386 SdrObject
* mpRectangleObject
;
387 SdrObject
* mpRectangleShadow
;
391 virtual void SetDrawingArea(weld::DrawingArea
* pDrawingArea
) override
;
392 virtual ~SvxXShadowPreview() override
;
394 void SetRectangleAttributes(const SfxItemSet
& rItemSet
);
395 void SetShadowAttributes(const SfxItemSet
& rItemSet
);
396 void SetShadowPosition(const Point
& rPos
);
398 virtual void Paint( vcl::RenderContext
& rRenderContext
, const tools::Rectangle
& rRect
) override
;
401 class SvxRelativeField
;
403 void limitWidthForSidebar(weld::SpinButton
& rSpinButton
);
404 SVX_DLLPUBLIC
void limitWidthForSidebar(SvxRelativeField
& rMetricSpinButton
);
405 //tdf#130197 Give this toolbar a width as if it had 5 standard toolbutton entries
406 SVX_DLLPUBLIC
void padWidthForSidebar(weld::Toolbar
& rToolbar
, const css::uno::Reference
<css::frame::XFrame
>& rFrame
);
408 #endif // INCLUDED_SVX_DLGCTRL_HXX
410 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */