lok: calc - send other views our selection in their co-ordinates.
[LibreOffice.git] / include / svx / dlgctrl.hxx
blobe68f881f8bceae2bda6b374f433c5e0bded4683f
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/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>
32 #include <memory>
33 #include <array>
35 namespace com { namespace sun { namespace star { namespace awt {
36 struct Point;
37 } } } }
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
47 public:
48 SvxTabPage(weld::Container* pPage, weld::DialogController* pController, const OUString& rUIXMLDescription, const OString& rID, const SfxItemSet &rAttrSet)
49 : SfxTabPage(pPage, pController, 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
57 |* an object
58 \************************************************************************/
60 enum class CTL_STATE
62 NONE = 0,
63 NOHORZ = 1, // no horizontal input information is used
64 NOVERT = 2, // no vertical input information is used
66 namespace o3tl
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
76 private:
77 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;
87 protected:
88 rtl::Reference<SvxRectCtlAccessibleContext> pAccContext;
89 sal_uInt16 nBorderWidth;
90 Point aPtLT, aPtMT, aPtRT;
91 Point aPtLM, aPtMM, aPtRM;
92 Point aPtLB, aPtMB, aPtRB;
93 Point aPtNew;
94 RectPoint eRP, eDefRP;
95 std::unique_ptr<BitmapEx> pBitmap;
96 CTL_STATE m_nState;
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;
105 public:
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;
120 void Reset();
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() const { return GetDrawingArea()->get_accessible_parent(); }
132 virtual css::uno::Reference<css::accessibility::XAccessible> CreateAccessible() override;
133 a11yrelationset get_accessible_relation_set() const { 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
147 private:
148 static sal_uInt16 constexpr nLines = 8;
149 static sal_uInt16 constexpr nSquares = nLines * nLines;
151 SvxTabPage* m_pPage;
153 Color aPixelColor;
154 Color aBackgroundColor;
155 Size aRectSize;
156 std::array<sal_uInt8,nSquares> maPixelData;
157 bool bPaintable;
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;
170 public:
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; }
192 void Reset();
194 css::uno::Reference<css::accessibility::XAccessible> getAccessibleParent() const { return GetDrawingArea()->get_accessible_parent(); }
195 virtual css::uno::Reference<css::accessibility::XAccessible> CreateAccessible() override;
196 a11yrelationset get_accessible_relation_set() const { 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() ; }
202 //Device Pixel .
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
219 public:
220 FillTypeLB( vcl::Window* pParent, WinBits aWB ) : ListBox( pParent, aWB ) {}
222 void Fill();
225 /************************************************************************/
227 class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxLineLB
229 private:
230 std::unique_ptr<weld::ComboBox> m_xControl;
232 /// defines if standard fields (none, solid) are added, default is true
233 bool mbAddStandardFields : 1;
235 public:
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
264 private:
265 std::unique_ptr<weld::ComboBox> m_xControl;
267 public:
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(); }
290 class SdrObject;
291 class SdrPathObj;
292 class SdrModel;
294 class SAL_WARN_UNUSED SAL_DLLPUBLIC_RTTI SvxPreviewBase : public weld::CustomWidgetController
296 private:
297 std::unique_ptr<SdrModel> mpModel;
298 VclPtr<VirtualDevice> mpBufferDevice;
300 protected:
301 void InitSettings();
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);
311 public:
312 SvxPreviewBase();
313 virtual void SetDrawingArea(weld::DrawingArea*) override;
314 virtual ~SvxPreviewBase() override;
316 // change support
317 virtual void StyleUpdated() override;
319 void SetDrawMode(DrawModeFlags nDrawMode)
321 mpBufferDevice->SetDrawMode(nDrawMode);
324 Size GetOutputSize() const
326 return mpBufferDevice->PixelToLogic(GetOutputSizePixel());
329 // dada read access
330 SdrModel& getModel() const
332 return *mpModel;
334 OutputDevice& getBufferDevice() const
336 return *mpBufferDevice;
341 /*************************************************************************
343 |* SvxLinePreview
345 \************************************************************************/
347 class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxXLinePreview final : public SvxPreviewBase
349 private:
350 SdrPathObj* mpLineObjA;
351 SdrPathObj* mpLineObjB;
352 SdrPathObj* mpLineObjC;
354 Graphic* mpGraphic;
355 bool mbWithSymbol;
356 Size maSymbolSize;
358 public:
359 SvxXLinePreview();
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 final : public SvxPreviewBase
375 private:
376 SdrObject* mpRectangleObject;
378 public:
379 SvxXRectPreview();
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 /*************************************************************************
391 |* SvxXShadowPreview
393 \************************************************************************/
395 class SAL_WARN_UNUSED SVX_DLLPUBLIC SvxXShadowPreview final : public SvxPreviewBase
397 private:
398 Point maShadowOffset;
400 SdrObject* mpRectangleObject;
401 SdrObject* mpRectangleShadow;
403 public:
404 SvxXShadowPreview();
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: */