tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / include / svx / dlgctrl.hxx
blobfa8ee330e13eb0939e42db776df045277f8eea2d
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 OUString& 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;
77 rtl::Reference<SvxRectCtlAccessibleContext> pAccContext;
78 sal_uInt16 nBorderWidth;
79 Point aPtLT, aPtMT, aPtRT;
80 Point aPtLM, aPtMM, aPtRM;
81 Point aPtLB, aPtMB, aPtRB;
82 Point aPtNew;
83 RectPoint eRP, eDefRP;
84 std::unique_ptr<BitmapEx> pBitmap;
85 CTL_STATE m_nState;
86 bool mbCompleteDisable : 1;
88 SVX_DLLPRIVATE static void InitSettings(vcl::RenderContext& rRenderContext);
89 SVX_DLLPRIVATE void InitRectBitmap();
90 SVX_DLLPRIVATE BitmapEx& GetRectBitmap();
91 SVX_DLLPRIVATE void Resize_Impl(const Size& rSize);
93 SvxRectCtl(const SvxRectCtl&) = delete;
94 SvxRectCtl& operator=(const SvxRectCtl&) = delete;
96 protected:
97 RectPoint GetRPFromPoint( Point, bool bRTL = false ) const;
98 const Point& GetPointFromRP( RectPoint ) const;
99 Point SetActualRPWithoutInvalidate( RectPoint eNewRP ); // returns the last point
101 Point GetApproxLogPtFromPixPt( const Point& rRoughPixelPoint ) const;
102 public:
103 SvxRectCtl(SvxTabPage* pPage);
104 void SetControlSettings(RectPoint eRpt, sal_uInt16 nBorder);
105 virtual ~SvxRectCtl() override;
107 virtual void Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) override;
108 virtual void Resize() override;
109 virtual bool MouseButtonDown(const MouseEvent&) override;
110 virtual bool KeyInput(const KeyEvent&) override;
111 virtual void GetFocus() override;
112 virtual void LoseFocus() override;
113 virtual tools::Rectangle GetFocusRect() override;
114 virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
115 virtual void StyleUpdated() override;
117 void Reset();
118 RectPoint GetActualRP() const { return eRP;}
119 void SetActualRP( RectPoint eNewRP );
121 void SetState( CTL_STATE nState );
123 static const sal_uInt8 NO_CHILDREN = 9; // returns number of usable radio buttons
125 tools::Rectangle CalculateFocusRectangle() const;
126 tools::Rectangle CalculateFocusRectangle( RectPoint eRectPoint ) const;
128 css::uno::Reference<css::accessibility::XAccessible> getAccessibleParent() const { return GetDrawingArea()->get_accessible_parent(); }
129 virtual css::uno::Reference<css::accessibility::XAccessible> CreateAccessible() override;
130 a11yrelationset get_accessible_relation_set() const { return GetDrawingArea()->get_accessible_relation_set(); }
132 RectPoint GetApproxRPFromPixPt( const css::awt::Point& rPixelPoint ) const;
134 bool IsCompletelyDisabled() const { return mbCompleteDisable; }
135 void DoCompletelyDisable(bool bNew);
138 /*************************************************************************
139 |* Control for editing bitmaps
140 \************************************************************************/
142 class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxPixelCtl final : public weld::CustomWidgetController
144 private:
145 static sal_uInt16 constexpr nLines = 8;
146 static sal_uInt16 constexpr nSquares = nLines * nLines;
148 SvxTabPage* m_pPage;
150 Color aPixelColor;
151 Color aBackgroundColor;
152 Size aRectSize;
153 std::array<sal_uInt8,nSquares> maPixelData;
154 bool bPaintable;
155 //Add member identifying position
156 Point aFocusPosition;
157 rtl::Reference<SvxPixelCtlAccessible> m_xAccess;
159 SAL_DLLPRIVATE tools::Rectangle implCalFocusRect( const Point& aPosition );
160 SAL_DLLPRIVATE void ChangePixel( sal_uInt16 nPixel );
162 SvxPixelCtl(SvxPixelCtl const&) = delete;
163 SvxPixelCtl(SvxPixelCtl&&) = delete;
164 SvxPixelCtl& operator=(SvxPixelCtl const&) = delete;
165 SvxPixelCtl& operator=(SvxPixelCtl&&) = delete;
167 public:
168 SvxPixelCtl(SvxTabPage* pPage);
170 virtual ~SvxPixelCtl() override;
172 SAL_DLLPRIVATE virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
173 SAL_DLLPRIVATE virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
174 SAL_DLLPRIVATE virtual bool MouseButtonDown( const MouseEvent& rMEvt ) override;
175 SAL_DLLPRIVATE virtual void Resize() override;
176 SAL_DLLPRIVATE virtual tools::Rectangle GetFocusRect() override;
178 void SetXBitmap( const BitmapEx& rBitmapEx );
180 void SetPixelColor( const Color& rCol ) { aPixelColor = rCol; }
181 void SetBackgroundColor( const Color& rCol ) { aBackgroundColor = rCol; }
183 static sal_uInt16 GetLineCount() { return nLines; }
185 SAL_DLLPRIVATE sal_uInt8 GetBitmapPixel( const sal_uInt16 nPixelNumber ) const;
186 std::array<sal_uInt8,64> const & GetBitmapPixelPtr() const { return maPixelData; }
188 void SetPaintable( bool bTmp ) { bPaintable = bTmp; }
189 void Reset();
191 css::uno::Reference<css::accessibility::XAccessible> getAccessibleParent() const { return GetDrawingArea()->get_accessible_parent(); }
192 SAL_DLLPRIVATE virtual css::uno::Reference<css::accessibility::XAccessible> CreateAccessible() override;
193 a11yrelationset get_accessible_relation_set() const { return GetDrawingArea()->get_accessible_relation_set(); }
195 static tools::Long GetSquares() { return nSquares ; }
196 tools::Long GetWidth() const { return aRectSize.getWidth() ; }
197 tools::Long GetHeight() const { return aRectSize.getHeight() ; }
199 //Device Pixel .
200 SAL_DLLPRIVATE tools::Long ShowPosition( const Point &pt);
202 SAL_DLLPRIVATE tools::Long PointToIndex(const Point &pt) const;
203 SAL_DLLPRIVATE Point IndexToPoint(tools::Long nIndex) const ;
204 SAL_DLLPRIVATE tools::Long GetFocusPosIndex() const ;
205 //Keyboard function for key input and focus handling function
206 SAL_DLLPRIVATE virtual bool KeyInput( const KeyEvent& rKEvt ) override;
207 SAL_DLLPRIVATE virtual void GetFocus() override;
208 SAL_DLLPRIVATE virtual void LoseFocus() override;
211 /************************************************************************/
213 class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxLineLB
215 private:
216 std::unique_ptr<weld::ComboBox> m_xControl;
218 /// defines if standard fields (none, solid) are added, default is true
219 bool mbAddStandardFields : 1;
221 public:
222 SvxLineLB(std::unique_ptr<weld::ComboBox> pControl);
224 void Fill(const XDashListRef &pList);
225 bool getAddStandardFields() const { return mbAddStandardFields; }
226 void setAddStandardFields(bool bNew);
228 void Append(const XDashEntry& rEntry, const BitmapEx& rBitmap );
229 void Modify(const XDashEntry& rEntry, sal_Int32 nPos, const BitmapEx& rBitmap );
231 void clear() { m_xControl->clear(); }
232 void remove(int nPos) { m_xControl->remove(nPos); }
233 int get_active() const { return m_xControl->get_active(); }
234 void set_active(int nPos) { m_xControl->set_active(nPos); }
235 void set_active_text(const OUString& rStr) { m_xControl->set_active_text(rStr); }
236 OUString get_active_text() const { return m_xControl->get_active_text(); }
237 void connect_changed(const Link<weld::ComboBox&, void>& rLink) { m_xControl->connect_changed(rLink); }
238 int get_count() const { return m_xControl->get_count(); }
239 void append_text(const OUString& rStr) { m_xControl->append_text(rStr); }
240 bool get_value_changed_from_saved() const { return m_xControl->get_value_changed_from_saved(); }
241 void save_value() { m_xControl->save_value(); }
244 /************************************************************************/
246 class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxLineEndLB
248 private:
249 std::unique_ptr<weld::ComboBox> m_xControl;
251 public:
252 SvxLineEndLB(std::unique_ptr<weld::ComboBox> pControl);
254 void Fill( const XLineEndListRef &pList, bool bStart = true );
256 void Append( const XLineEndEntry& rEntry, const BitmapEx& rBitmap );
257 void Modify( const XLineEndEntry& rEntry, sal_Int32 nPos, const BitmapEx& rBitmap );
259 void clear() { m_xControl->clear(); }
260 void remove(int nPos) { m_xControl->remove(nPos); }
261 int get_active() const { return m_xControl->get_active(); }
262 void set_active(int nPos) { m_xControl->set_active(nPos); }
263 void set_active_text(const OUString& rStr) { m_xControl->set_active_text(rStr); }
264 OUString get_active_text() const { return m_xControl->get_active_text(); }
265 void connect_changed(const Link<weld::ComboBox&, void>& rLink) { m_xControl->connect_changed(rLink); }
266 int get_count() const { return m_xControl->get_count(); }
267 void append_text(const OUString& rStr) { m_xControl->append_text(rStr); }
268 bool get_value_changed_from_saved() const { return m_xControl->get_value_changed_from_saved(); }
269 void save_value() { m_xControl->save_value(); }
270 void set_sensitive(bool bSensitive) { m_xControl->set_sensitive(bSensitive); }
271 bool get_sensitive() const { return m_xControl->get_sensitive(); }
274 class SdrObject;
275 class SdrPathObj;
276 class SdrModel;
278 class SAL_WARN_UNUSED SAL_DLLPUBLIC_RTTI SvxPreviewBase : public weld::CustomWidgetController
280 private:
281 std::unique_ptr<SdrModel> mpModel;
282 VclPtr<VirtualDevice> mpBufferDevice;
284 protected:
285 void InitSettings();
287 tools::Rectangle GetPreviewSize() const;
289 // prepare buffered paint
290 void LocalPrePaint(vcl::RenderContext const & rRenderContext);
292 // end and output buffered paint
293 void LocalPostPaint(vcl::RenderContext& rRenderContext);
295 public:
296 SvxPreviewBase();
297 virtual void SetDrawingArea(weld::DrawingArea*) override;
298 virtual ~SvxPreviewBase() override;
300 // change support
301 virtual void StyleUpdated() override;
303 void SetDrawMode(DrawModeFlags nDrawMode)
305 mpBufferDevice->SetDrawMode(nDrawMode);
308 Size GetOutputSize() const
310 return mpBufferDevice->PixelToLogic(GetOutputSizePixel());
313 // dada read access
314 SdrModel& getModel() const
316 return *mpModel;
318 OutputDevice& getBufferDevice() const
320 return *mpBufferDevice;
325 /*************************************************************************
327 |* SvxLinePreview
329 \************************************************************************/
331 class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxXLinePreview final : public SvxPreviewBase
333 private:
334 rtl::Reference<SdrPathObj> mpLineObjA;
335 rtl::Reference<SdrPathObj> mpLineObjB;
336 rtl::Reference<SdrPathObj> mpLineObjC;
338 Graphic* mpGraphic;
339 bool mbWithSymbol;
340 Size maSymbolSize;
342 public:
343 SvxXLinePreview();
344 virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
345 virtual ~SvxXLinePreview() override;
347 void SetLineAttributes(const SfxItemSet& rItemSet);
349 void ShowSymbol( bool b ) { mbWithSymbol = b; };
350 void SetSymbol( Graphic* p, const Size& s );
351 void ResizeSymbol( const Size& s );
353 virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
354 virtual void Resize() override;
357 class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxXRectPreview final : public SvxPreviewBase
359 private:
360 rtl::Reference<SdrObject> mpRectangleObject;
362 public:
363 SvxXRectPreview();
364 virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
365 virtual ~SvxXRectPreview() override;
367 void SetAttributes(const SfxItemSet& rItemSet);
369 virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
370 virtual void Resize() override;
373 /*************************************************************************
375 |* SvxXShadowPreview
377 \************************************************************************/
379 class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxXShadowPreview final : public SvxPreviewBase
381 private:
382 Point maShadowOffset;
384 rtl::Reference<SdrObject> mpRectangleObject;
385 rtl::Reference<SdrObject> mpRectangleShadow;
387 public:
388 SvxXShadowPreview();
389 virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
390 virtual ~SvxXShadowPreview() override;
392 void SetRectangleAttributes(const SfxItemSet& rItemSet);
393 void SetShadowAttributes(const SfxItemSet& rItemSet);
394 void SetShadowPosition(const Point& rPos);
396 virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
399 class SvxRelativeField;
401 void limitWidthForSidebar(weld::SpinButton& rSpinButton);
402 SVX_DLLPUBLIC void limitWidthForSidebar(SvxRelativeField& rMetricSpinButton);
403 //tdf#130197 Give this toolbar a width as if it had 5 standard toolbutton entries
404 SVX_DLLPUBLIC void padWidthForSidebar(weld::Toolbar& rToolbar, const css::uno::Reference<css::frame::XFrame>& rFrame);
406 #endif // INCLUDED_SVX_DLGCTRL_HXX
408 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */