tdf#151073 - enable firebird for appstore build w/o experimental mode
[LibreOffice.git] / include / svx / dlgctrl.hxx
blob26371185c7f0f2941f3557f7fea4d6bf4ae39ac6
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 <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>
31 #include <memory>
32 #include <array>
34 namespace com::sun::star::awt {
35 struct Point;
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
46 public:
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
56 |* an object
57 \************************************************************************/
59 enum class CTL_STATE
61 NONE = 0,
62 NOHORZ = 1, // no horizontal input information is used
63 NOVERT = 2, // no vertical input information is used
65 namespace o3tl
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
75 private:
76 SvxTabPage* m_pPage;
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;
86 protected:
87 rtl::Reference<SvxRectCtlAccessibleContext> pAccContext;
88 sal_uInt16 nBorderWidth;
89 Point aPtLT, aPtMT, aPtRT;
90 Point aPtLM, aPtMM, aPtRM;
91 Point aPtLB, aPtMB, aPtRB;
92 Point aPtNew;
93 RectPoint eRP, eDefRP;
94 std::unique_ptr<BitmapEx> pBitmap;
95 CTL_STATE m_nState;
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;
104 public:
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;
119 void Reset();
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
146 private:
147 static sal_uInt16 constexpr nLines = 8;
148 static sal_uInt16 constexpr nSquares = nLines * nLines;
150 SvxTabPage* m_pPage;
152 Color aPixelColor;
153 Color aBackgroundColor;
154 Size aRectSize;
155 std::array<sal_uInt8,nSquares> maPixelData;
156 bool bPaintable;
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;
169 public:
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; }
191 void Reset();
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() ; }
201 //Device Pixel .
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
217 private:
218 std::unique_ptr<weld::ComboBox> m_xControl;
220 /// defines if standard fields (none, solid) are added, default is true
221 bool mbAddStandardFields : 1;
223 public:
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
250 private:
251 std::unique_ptr<weld::ComboBox> m_xControl;
253 public:
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(); }
276 class SdrObject;
277 class SdrPathObj;
278 class SdrModel;
280 class SAL_WARN_UNUSED SAL_DLLPUBLIC_RTTI SvxPreviewBase : public weld::CustomWidgetController
282 private:
283 std::unique_ptr<SdrModel> mpModel;
284 VclPtr<VirtualDevice> mpBufferDevice;
286 protected:
287 void InitSettings();
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);
297 public:
298 SvxPreviewBase();
299 virtual void SetDrawingArea(weld::DrawingArea*) override;
300 virtual ~SvxPreviewBase() override;
302 // change support
303 virtual void StyleUpdated() override;
305 void SetDrawMode(DrawModeFlags nDrawMode)
307 mpBufferDevice->SetDrawMode(nDrawMode);
310 Size GetOutputSize() const
312 return mpBufferDevice->PixelToLogic(GetOutputSizePixel());
315 // dada read access
316 SdrModel& getModel() const
318 return *mpModel;
320 OutputDevice& getBufferDevice() const
322 return *mpBufferDevice;
327 /*************************************************************************
329 |* SvxLinePreview
331 \************************************************************************/
333 class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxXLinePreview final : public SvxPreviewBase
335 private:
336 rtl::Reference<SdrPathObj> mpLineObjA;
337 rtl::Reference<SdrPathObj> mpLineObjB;
338 rtl::Reference<SdrPathObj> mpLineObjC;
340 Graphic* mpGraphic;
341 bool mbWithSymbol;
342 Size maSymbolSize;
344 public:
345 SvxXLinePreview();
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
361 private:
362 rtl::Reference<SdrObject> mpRectangleObject;
364 public:
365 SvxXRectPreview();
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 /*************************************************************************
377 |* SvxXShadowPreview
379 \************************************************************************/
381 class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxXShadowPreview final : public SvxPreviewBase
383 private:
384 Point maShadowOffset;
386 rtl::Reference<SdrObject> mpRectangleObject;
387 rtl::Reference<SdrObject> mpRectangleShadow;
389 public:
390 SvxXShadowPreview();
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: */