LibreOffice Module svx (master)  1
dlgctrl.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 #ifndef INCLUDED_SVX_DLGCTRL_HXX
20 #define INCLUDED_SVX_DLGCTRL_HXX
21 
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>
33 
34 namespace com::sun::star::awt {
35  struct Point;
36 }
37 
38 /*************************************************************************
39 |* Derived from SfxTabPage for being able to get notified through the
40 |* virtual method from the control.
41 \************************************************************************/
42 
44 {
45 
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)
49  {
50  }
51  virtual void PointChanged(weld::DrawingArea* pArea, RectPoint eRP) = 0;
52 };
53 
54 /*************************************************************************
55 |* Control for display and selection of the corner and center points of
56 |* an object
57 \************************************************************************/
58 
59 enum class CTL_STATE
60 {
61  NONE = 0,
62  NOHORZ = 1, // no horizontal input information is used
63  NOVERT = 2, // no vertical input information is used
64 };
65 namespace o3tl
66 {
67  template<> struct typed_flags<CTL_STATE> : is_typed_flags<CTL_STATE, 0x03> {};
68 }
69 
72 
74 {
75 private:
77 
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);
82 
83  SvxRectCtl(const SvxRectCtl&) = delete;
84  SvxRectCtl& operator=(const SvxRectCtl&) = delete;
85 
86 protected:
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;
96 
97  bool mbCompleteDisable : 1;
98 
99  RectPoint GetRPFromPoint( Point, bool bRTL = false ) const;
100  const Point& GetPointFromRP( RectPoint ) const;
101  Point SetActualRPWithoutInvalidate( RectPoint eNewRP ); // returns the last point
102 
103  Point GetApproxLogPtFromPixPt( const Point& rRoughPixelPoint ) const;
104 public:
105  SvxRectCtl(SvxTabPage* pPage, RectPoint eRpt = RectPoint::MM, sal_uInt16 nBorder = 200);
106  void SetControlSettings(RectPoint eRpt, sal_uInt16 nBorder);
107  virtual ~SvxRectCtl() override;
108 
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;
118 
119  void Reset();
120  RectPoint GetActualRP() const { return eRP;}
121  void SetActualRP( RectPoint eNewRP );
122 
123  void SetState( CTL_STATE nState );
124 
125  static const sal_uInt8 NO_CHILDREN = 9; // returns number of usable radio buttons
126 
127  tools::Rectangle CalculateFocusRectangle() const;
128  tools::Rectangle CalculateFocusRectangle( RectPoint eRectPoint ) const;
129 
130  css::uno::Reference<css::accessibility::XAccessible> getAccessibleParent() const { return GetDrawingArea()->get_accessible_parent(); }
131  virtual css::uno::Reference<css::accessibility::XAccessible> CreateAccessible() override;
133 
134  RectPoint GetApproxRPFromPixPt( const css::awt::Point& rPixelPoint ) const;
135 
136  bool IsCompletelyDisabled() const { return mbCompleteDisable; }
137  void DoCompletelyDisable(bool bNew);
138 };
139 
140 /*************************************************************************
141 |* Control for editing bitmaps
142 \************************************************************************/
143 
145 {
146 private:
147  static sal_uInt16 constexpr nLines = 8;
148  static sal_uInt16 constexpr nSquares = nLines * nLines;
149 
151 
155  std::array<sal_uInt8,nSquares> maPixelData;
157  //Add member identifying position
160 
161  tools::Rectangle implCalFocusRect( const Point& aPosition );
162  void ChangePixel( sal_uInt16 nPixel );
163 
164  SvxPixelCtl(SvxPixelCtl const&) = delete;
165  SvxPixelCtl(SvxPixelCtl&&) = delete;
166  SvxPixelCtl& operator=(SvxPixelCtl const&) = delete;
167  SvxPixelCtl& operator=(SvxPixelCtl&&) = delete;
168 
169 public:
170  SvxPixelCtl(SvxTabPage* pPage);
171 
172  virtual ~SvxPixelCtl() override;
173 
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;
179 
180  void SetXBitmap( const BitmapEx& rBitmapEx );
181 
182  void SetPixelColor( const Color& rCol ) { aPixelColor = rCol; }
183  void SetBackgroundColor( const Color& rCol ) { aBackgroundColor = rCol; }
184 
185  static sal_uInt16 GetLineCount() { return nLines; }
186 
187  sal_uInt8 GetBitmapPixel( const sal_uInt16 nPixelNumber ) const;
188  std::array<sal_uInt8,64> const & GetBitmapPixelPtr() const { return maPixelData; }
189 
190  void SetPaintable( bool bTmp ) { bPaintable = bTmp; }
191  void Reset();
192 
193  css::uno::Reference<css::accessibility::XAccessible> getAccessibleParent() const { return GetDrawingArea()->get_accessible_parent(); }
194  virtual css::uno::Reference<css::accessibility::XAccessible> CreateAccessible() override;
196 
197  static long GetSquares() { return nSquares ; }
198  long GetWidth() const { return aRectSize.getWidth() ; }
199  long GetHeight() const { return aRectSize.getHeight() ; }
200 
201  //Device Pixel .
202  long ShowPosition( const Point &pt);
203 
204  long PointToIndex(const Point &pt) const;
205  Point IndexToPoint(long nIndex) const ;
206  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;
211 };
212 
213 /************************************************************************/
214 
216 {
217 private:
218  std::unique_ptr<weld::ComboBox> m_xControl;
219 
221  bool mbAddStandardFields : 1;
222 
223 public:
224  SvxLineLB(std::unique_ptr<weld::ComboBox> pControl);
225 
226  void Fill(const XDashListRef &pList);
227  bool getAddStandardFields() const { return mbAddStandardFields; }
228  void setAddStandardFields(bool bNew);
229 
230  void Append(const XDashEntry& rEntry, const BitmapEx& rBitmap );
231  void Modify(const XDashEntry& rEntry, sal_Int32 nPos, const BitmapEx& rBitmap );
232 
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(); }
244  void set_sensitive(bool bSensitive) { m_xControl->set_sensitive(bSensitive); }
245  bool get_sensitive() const { return m_xControl->get_sensitive(); }
246 };
247 
248 /************************************************************************/
249 
251 {
252 private:
253  std::unique_ptr<weld::ComboBox> m_xControl;
254 
255 public:
256  SvxLineEndLB(std::unique_ptr<weld::ComboBox> pControl);
257 
258  void Fill( const XLineEndListRef &pList, bool bStart = true );
259 
260  void Append( const XLineEndEntry& rEntry, const BitmapEx& rBitmap );
261  void Modify( const XLineEndEntry& rEntry, sal_Int32 nPos, const BitmapEx& rBitmap );
262 
263  void clear() { m_xControl->clear(); }
264  void remove(int nPos) { m_xControl->remove(nPos); }
265  int get_active() const { return m_xControl->get_active(); }
266  void set_active(int nPos) { m_xControl->set_active(nPos); }
267  void set_active_text(const OUString& rStr) { m_xControl->set_active_text(rStr); }
268  OUString get_active_text() const { return m_xControl->get_active_text(); }
269  void connect_changed(const Link<weld::ComboBox&, void>& rLink) { m_xControl->connect_changed(rLink); }
270  int get_count() const { return m_xControl->get_count(); }
271  void append_text(const OUString& rStr) { m_xControl->append_text(rStr); }
272  bool get_value_changed_from_saved() const { return m_xControl->get_value_changed_from_saved(); }
273  void save_value() { m_xControl->save_value(); }
274  void set_sensitive(bool bSensitive) { m_xControl->set_sensitive(bSensitive); }
275  bool get_sensitive() const { return m_xControl->get_sensitive(); }
276 };
277 
278 class SdrObject;
279 class SdrPathObj;
280 class SdrModel;
281 
283 {
284 private:
285  std::unique_ptr<SdrModel> mpModel;
287 
288 protected:
289  void InitSettings();
290 
291  tools::Rectangle GetPreviewSize() const;
292 
293  // prepare buffered paint
294  void LocalPrePaint(vcl::RenderContext const & rRenderContext);
295 
296  // end and output buffered paint
297  void LocalPostPaint(vcl::RenderContext& rRenderContext);
298 
299 public:
300  SvxPreviewBase();
301  virtual void SetDrawingArea(weld::DrawingArea*) override;
302  virtual ~SvxPreviewBase() override;
303 
304  // change support
305  virtual void StyleUpdated() override;
306 
307  void SetDrawMode(DrawModeFlags nDrawMode)
308  {
309  mpBufferDevice->SetDrawMode(nDrawMode);
310  }
311 
313  {
314  return mpBufferDevice->PixelToLogic(GetOutputSizePixel());
315  }
316 
317  // dada read access
319  {
320  return *mpModel;
321  }
323  {
324  return *mpBufferDevice;
325  }
326 };
327 
328 
329 /*************************************************************************
330 |*
331 |* SvxLinePreview
332 |*
333 \************************************************************************/
334 
336 {
337 private:
341 
345 
346 public:
347  SvxXLinePreview();
348  virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
349  virtual ~SvxXLinePreview() override;
350 
351  void SetLineAttributes(const SfxItemSet& rItemSet);
352 
353  void ShowSymbol( bool b ) { mbWithSymbol = b; };
354  void SetSymbol( Graphic* p, const Size& s );
355  void ResizeSymbol( const Size& s );
356 
357  virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
358  virtual void Resize() override;
359 };
360 
362 {
363 private:
365 
366 public:
367  SvxXRectPreview();
368  virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
369  virtual ~SvxXRectPreview() override;
370 
371  void SetAttributes(const SfxItemSet& rItemSet);
372 
373  virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
374  virtual void Resize() override;
375 };
376 
377 /*************************************************************************
378 |*
379 |* SvxXShadowPreview
380 |*
381 \************************************************************************/
382 
384 {
385 private:
387 
390 
391 public:
393  virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
394  virtual ~SvxXShadowPreview() override;
395 
396  void SetRectangleAttributes(const SfxItemSet& rItemSet);
397  void SetShadowAttributes(const SfxItemSet& rItemSet);
398  void SetShadowPosition(const Point& rPos);
399 
400  virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
401 };
402 
403 class SvxRelativeField;
404 
405 void limitWidthForSidebar(weld::SpinButton& rSpinButton);
406 SVX_DLLPUBLIC void limitWidthForSidebar(SvxRelativeField& rMetricSpinButton);
407 //tdf#130197 Give this toolbar a width as if it had 5 standard toolbutton entries
408 SVX_DLLPUBLIC void padWidthForSidebar(weld::Toolbar& rToolbar, const css::uno::Reference<css::frame::XFrame>& rFrame);
409 
410 #endif // INCLUDED_SVX_DLGCTRL_HXX
411 
412 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
void clear()
Definition: dlgctrl.hxx:263
CTL_STATE m_nState
Definition: dlgctrl.hxx:95
void SetBackgroundColor(const Color &rCol)
Definition: dlgctrl.hxx:183
OutputDevice & getBufferDevice() const
Definition: dlgctrl.hxx:322
SvxTabPage * m_pPage
Definition: dlgctrl.hxx:150
int get_count() const
Definition: dlgctrl.hxx:270
Color aPixelColor
Definition: dlgctrl.hxx:152
bool get_sensitive() const
Definition: dlgctrl.hxx:245
css::uno::Reference< css::accessibility::XAccessibleRelationSet > a11yrelationset
virtual a11yref get_accessible_parent()=0
DrawModeFlags
SdrPathObj * mpLineObjB
Definition: dlgctrl.hxx:339
void append_text(const OUString &rStr)
Definition: dlgctrl.hxx:241
bool bPaintable
Definition: dlgctrl.hxx:156
int get_count() const
Definition: dlgctrl.hxx:240
void set_sensitive(bool bSensitive)
Definition: dlgctrl.hxx:244
bool get_sensitive() const
Definition: dlgctrl.hxx:275
Size GetOutputSize() const
Definition: dlgctrl.hxx:312
void set_sensitive(bool bSensitive)
Definition: dlgctrl.hxx:274
SdrPathObj * mpLineObjA
Definition: dlgctrl.hxx:338
Point aPtRT
Definition: dlgctrl.hxx:89
long GetHeight() const
Definition: dlgctrl.hxx:199
RectPoint GetActualRP() const
Definition: dlgctrl.hxx:120
RectPoint eRP
Definition: dlgctrl.hxx:93
static long PointToIndex(RectPoint ePoint)
SdrModel & getModel() const
Definition: dlgctrl.hxx:318
SvxTabPage * m_pPage
Definition: dlgctrl.hxx:76
Color aBackgroundColor
Definition: dlgctrl.hxx:153
Point maShadowOffset
Definition: dlgctrl.hxx:386
a11yrelationset get_accessible_relation_set() const
Definition: dlgctrl.hxx:195
#define SVX_DLLPUBLIC
Definition: svxdllapi.h:28
virtual a11yrelationset get_accessible_relation_set()=0
a11yrelationset get_accessible_relation_set() const
Definition: dlgctrl.hxx:132
Size const & GetOutputSizePixel() const
Point aFocusPosition
Definition: dlgctrl.hxx:158
SdrObject * mpRectangleShadow
Definition: dlgctrl.hxx:389
void SetDrawMode(DrawModeFlags nDrawMode)
void limitWidthForSidebar(weld::SpinButton &rSpinButton)
Definition: dlgctrl.cxx:1425
SdrPathObj * mpLineObjC
Definition: dlgctrl.hxx:340
CustomWidgetController & operator=(CustomWidgetController const &)=default
Size aRectSize
Definition: dlgctrl.hxx:154
bool getAddStandardFields() const
Definition: dlgctrl.hxx:227
static const ChildIndexToPointData * IndexToPoint(long nIndex)
std::unique_ptr< SdrModel > mpModel
Definition: dlgctrl.hxx:285
void ShowSymbol(bool b)
Definition: dlgctrl.hxx:353
std::array< sal_uInt8, nSquares > maPixelData
Definition: dlgctrl.hxx:155
void set_active_text(const OUString &rStr)
Definition: dlgctrl.hxx:267
void clear()
Definition: dlgctrl.hxx:233
SvxTabPage(weld::Container *pPage, weld::DialogController *pController, const OUString &rUIXMLDescription, const OString &rID, const SfxItemSet &rAttrSet)
Definition: dlgctrl.hxx:47
void SetPixelColor(const Color &rCol)
Definition: dlgctrl.hxx:182
RectPoint
Definition: rectenum.hxx:22
sal_uInt16 nBorderWidth
Definition: dlgctrl.hxx:88
bool get_value_changed_from_saved() const
Definition: dlgctrl.hxx:272
void save_value()
Definition: dlgctrl.hxx:273
VclPtr< VirtualDevice > mpBufferDevice
Definition: dlgctrl.hxx:286
Point aPtRB
Definition: dlgctrl.hxx:91
bool IsCompletelyDisabled() const
Definition: dlgctrl.hxx:136
SVX_DLLPUBLIC void padWidthForSidebar(weld::Toolbar &rToolbar, const css::uno::Reference< css::frame::XFrame > &rFrame)
Definition: dlgctrl.cxx:1438
std::unique_ptr< weld::ComboBox > m_xControl
Definition: dlgctrl.hxx:253
static sal_uInt16 GetLineCount()
Definition: dlgctrl.hxx:185
virtual tools::Rectangle GetFocusRect()
Point aPtNew
Definition: dlgctrl.hxx:92
SdrObject * mpRectangleObject
Definition: dlgctrl.hxx:364
rtl::Reference< SvxRectCtlAccessibleContext > pAccContext
Definition: dlgctrl.hxx:87
std::unique_ptr< weld::ComboBox > m_xControl
Definition: dlgctrl.hxx:218
virtual bool KeyInput(const KeyEvent &)
css::uno::Reference< css::accessibility::XAccessible > getAccessibleParent() const
Definition: dlgctrl.hxx:130
std::unique_ptr< BitmapEx > pBitmap
Definition: dlgctrl.hxx:94
void SetPaintable(bool bTmp)
Definition: dlgctrl.hxx:190
Abstract DrawObject.
Definition: svdobj.hxx:312
void save_value()
Definition: dlgctrl.hxx:243
Point PixelToLogic(const Point &rDevicePt) const
#define SAL_WARN_UNUSED
int get_active() const
Definition: dlgctrl.hxx:235
Fill
void append_text(const OUString &rStr)
Definition: dlgctrl.hxx:271
weld::DrawingArea * GetDrawingArea() const
OUString get_active_text() const
Definition: dlgctrl.hxx:238
Graphic * mpGraphic
Definition: dlgctrl.hxx:342
unsigned char sal_uInt8
int get_active() const
Definition: dlgctrl.hxx:265
OUString get_active_text() const
Definition: dlgctrl.hxx:268
void connect_changed(const Link< weld::ComboBox &, void > &rLink)
Definition: dlgctrl.hxx:239
virtual bool MouseButtonDown(const MouseEvent &)
void set_active_text(const OUString &rStr)
Definition: dlgctrl.hxx:237
virtual void SetDrawingArea(weld::DrawingArea *pDrawingArea)
virtual void SetDrawingArea(weld::DrawingArea *) override
Definition: dlgctrl.cxx:1295
rtl::Reference< SvxPixelCtlAccessible > m_xAccess
Definition: dlgctrl.hxx:159
css::uno::Reference< css::accessibility::XAccessible > getAccessibleParent() const
Definition: dlgctrl.hxx:193
static long GetSquares()
Definition: dlgctrl.hxx:197
SdrObject * mpRectangleObject
Definition: dlgctrl.hxx:388
void SetDrawMode(DrawModeFlags nDrawMode)
Definition: dlgctrl.hxx:307
void set_active(int nPos)
Definition: dlgctrl.hxx:266
std::array< sal_uInt8, 64 > const & GetBitmapPixelPtr() const
Definition: dlgctrl.hxx:188
long getHeight() const
bool get_value_changed_from_saved() const
Definition: dlgctrl.hxx:242
long getWidth() const
#define SVX_DLLPRIVATE
Definition: svxdllapi.h:30
void connect_changed(const Link< weld::ComboBox &, void > &rLink)
Definition: dlgctrl.hxx:269
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect)=0
virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible()
Point aPtRM
Definition: dlgctrl.hxx:90
void set_active(int nPos)
Definition: dlgctrl.hxx:236
long GetWidth() const
Definition: dlgctrl.hxx:198
sal_uInt16 nPos
CTL_STATE
Definition: dlgctrl.hxx:59