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>
31#include <memory>
32#include <array>
33
34namespace 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
46public:
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
59enum 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};
65namespace o3tl
66{
67 template<> struct typed_flags<CTL_STATE> : is_typed_flags<CTL_STATE, 0x03> {};
68}
69
72
74{
75private:
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
86protected:
88 sal_uInt16 nBorderWidth;
89 Point aPtLT, aPtMT, aPtRT;
90 Point aPtLM, aPtMM, aPtRM;
91 Point aPtLB, aPtMB, aPtRB;
94 std::unique_ptr<BitmapEx> pBitmap;
96
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;
104public:
105 SvxRectCtl(SvxTabPage* pPage);
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;
132 a11yrelationset get_accessible_relation_set() const { return GetDrawingArea()->get_accessible_relation_set(); }
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{
146private:
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;
168
169public:
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;
195 a11yrelationset get_accessible_relation_set() const { return GetDrawingArea()->get_accessible_relation_set(); }
196
197 static tools::Long GetSquares() { return nSquares ; }
198 tools::Long GetWidth() const { return aRectSize.getWidth() ; }
199 tools::Long GetHeight() const { return aRectSize.getHeight() ; }
200
201 //Device Pixel .
202 tools::Long ShowPosition( const Point &pt);
203
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;
211};
212
213/************************************************************************/
214
216{
217private:
218 std::unique_ptr<weld::ComboBox> m_xControl;
219
222
223public:
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};
245
246/************************************************************************/
247
249{
250private:
251 std::unique_ptr<weld::ComboBox> m_xControl;
252
253public:
254 SvxLineEndLB(std::unique_ptr<weld::ComboBox> pControl);
255
256 void Fill( const XLineEndListRef &pList, bool bStart = true );
257
258 void Append( const XLineEndEntry& rEntry, const BitmapEx& rBitmap );
259 void Modify( const XLineEndEntry& rEntry, sal_Int32 nPos, const BitmapEx& rBitmap );
260
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(); }
274};
275
276class SdrObject;
277class SdrPathObj;
278class SdrModel;
279
281{
282private:
283 std::unique_ptr<SdrModel> mpModel;
285
286protected:
287 void InitSettings();
288
289 tools::Rectangle GetPreviewSize() const;
290
291 // prepare buffered paint
292 void LocalPrePaint(vcl::RenderContext const & rRenderContext);
293
294 // end and output buffered paint
295 void LocalPostPaint(vcl::RenderContext& rRenderContext);
296
297public:
299 virtual void SetDrawingArea(weld::DrawingArea*) override;
300 virtual ~SvxPreviewBase() override;
301
302 // change support
303 virtual void StyleUpdated() override;
304
306 {
307 mpBufferDevice->SetDrawMode(nDrawMode);
308 }
309
311 {
312 return mpBufferDevice->PixelToLogic(GetOutputSizePixel());
313 }
314
315 // dada read access
317 {
318 return *mpModel;
319 }
321 {
322 return *mpBufferDevice;
323 }
324};
325
326
327/*************************************************************************
328|*
329|* SvxLinePreview
330|*
331\************************************************************************/
332
334{
335private:
339
343
344public:
346 virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
347 virtual ~SvxXLinePreview() override;
348
349 void SetLineAttributes(const SfxItemSet& rItemSet);
350
351 void ShowSymbol( bool b ) { mbWithSymbol = b; };
352 void SetSymbol( Graphic* p, const Size& s );
353 void ResizeSymbol( const Size& s );
354
355 virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
356 virtual void Resize() override;
357};
358
360{
361private:
363
364public:
366 virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
367 virtual ~SvxXRectPreview() override;
368
369 void SetAttributes(const SfxItemSet& rItemSet);
370
371 virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
372 virtual void Resize() override;
373};
374
375/*************************************************************************
376|*
377|* SvxXShadowPreview
378|*
379\************************************************************************/
380
382{
383private:
385
388
389public:
391 virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
392 virtual ~SvxXShadowPreview() override;
393
394 void SetRectangleAttributes(const SfxItemSet& rItemSet);
395 void SetShadowAttributes(const SfxItemSet& rItemSet);
396 void SetShadowPosition(const Point& rPos);
397
398 virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
399};
400
401class SvxRelativeField;
402
403void limitWidthForSidebar(weld::SpinButton& rSpinButton);
405//tdf#130197 Give this toolbar a width as if it had 5 standard toolbutton entries
406SVX_DLLPUBLIC void padWidthForSidebar(weld::Toolbar& rToolbar, const css::uno::Reference<css::frame::XFrame>& rFrame);
407
408#endif // INCLUDED_SVX_DLGCTRL_HXX
409
410/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
DrawModeFlags
Abstract DrawObject.
Definition: svdobj.hxx:261
virtual void Reset(const SfxItemSet *)
constexpr tools::Long getHeight() const
constexpr tools::Long getWidth() const
void connect_changed(const Link< weld::ComboBox &, void > &rLink)
Definition: dlgctrl.hxx:267
void set_active_text(const OUString &rStr)
Definition: dlgctrl.hxx:265
void set_active(int nPos)
Definition: dlgctrl.hxx:264
int get_active() const
Definition: dlgctrl.hxx:263
void clear()
Definition: dlgctrl.hxx:261
void remove(int nPos)
Definition: dlgctrl.hxx:262
bool get_sensitive() const
Definition: dlgctrl.hxx:273
std::unique_ptr< weld::ComboBox > m_xControl
Definition: dlgctrl.hxx:251
int get_count() const
Definition: dlgctrl.hxx:268
bool get_value_changed_from_saved() const
Definition: dlgctrl.hxx:270
void append_text(const OUString &rStr)
Definition: dlgctrl.hxx:269
void save_value()
Definition: dlgctrl.hxx:271
void set_sensitive(bool bSensitive)
Definition: dlgctrl.hxx:272
OUString get_active_text() const
Definition: dlgctrl.hxx:266
void set_active(int nPos)
Definition: dlgctrl.hxx:236
OUString get_active_text() const
Definition: dlgctrl.hxx:238
void append_text(const OUString &rStr)
Definition: dlgctrl.hxx:241
void set_active_text(const OUString &rStr)
Definition: dlgctrl.hxx:237
std::unique_ptr< weld::ComboBox > m_xControl
Definition: dlgctrl.hxx:218
int get_count() const
Definition: dlgctrl.hxx:240
bool getAddStandardFields() const
Definition: dlgctrl.hxx:227
int get_active() const
Definition: dlgctrl.hxx:235
bool mbAddStandardFields
defines if standard fields (none, solid) are added, default is true
Definition: dlgctrl.hxx:221
bool get_value_changed_from_saved() const
Definition: dlgctrl.hxx:242
void connect_changed(const Link< weld::ComboBox &, void > &rLink)
Definition: dlgctrl.hxx:239
void clear()
Definition: dlgctrl.hxx:233
void remove(int nPos)
Definition: dlgctrl.hxx:234
void save_value()
Definition: dlgctrl.hxx:243
bool bPaintable
Definition: dlgctrl.hxx:156
void SetPaintable(bool bTmp)
Definition: dlgctrl.hxx:190
css::uno::Reference< css::accessibility::XAccessible > getAccessibleParent() const
Definition: dlgctrl.hxx:193
SvxPixelCtl & operator=(SvxPixelCtl const &)=delete
SvxPixelCtl(SvxPixelCtl const &)=delete
a11yrelationset get_accessible_relation_set() const
Definition: dlgctrl.hxx:195
Color aPixelColor
Definition: dlgctrl.hxx:152
Size aRectSize
Definition: dlgctrl.hxx:154
std::array< sal_uInt8, nSquares > maPixelData
Definition: dlgctrl.hxx:155
std::array< sal_uInt8, 64 > const & GetBitmapPixelPtr() const
Definition: dlgctrl.hxx:188
SvxPixelCtl(SvxPixelCtl &&)=delete
void SetPixelColor(const Color &rCol)
Definition: dlgctrl.hxx:182
void SetBackgroundColor(const Color &rCol)
Definition: dlgctrl.hxx:183
Point aFocusPosition
Definition: dlgctrl.hxx:158
rtl::Reference< SvxPixelCtlAccessible > m_xAccess
Definition: dlgctrl.hxx:159
tools::Long GetWidth() const
Definition: dlgctrl.hxx:198
static sal_uInt16 GetLineCount()
Definition: dlgctrl.hxx:185
SvxPixelCtl & operator=(SvxPixelCtl &&)=delete
tools::Long GetHeight() const
Definition: dlgctrl.hxx:199
SvxTabPage * m_pPage
Definition: dlgctrl.hxx:150
Color aBackgroundColor
Definition: dlgctrl.hxx:153
static tools::Long GetSquares()
Definition: dlgctrl.hxx:197
OutputDevice & getBufferDevice() const
Definition: dlgctrl.hxx:320
void SetDrawMode(DrawModeFlags nDrawMode)
Definition: dlgctrl.hxx:305
std::unique_ptr< SdrModel > mpModel
Definition: dlgctrl.hxx:283
VclPtr< VirtualDevice > mpBufferDevice
Definition: dlgctrl.hxx:284
SdrModel & getModel() const
Definition: dlgctrl.hxx:316
Size GetOutputSize() const
Definition: dlgctrl.hxx:310
a11yrelationset get_accessible_relation_set() const
Definition: dlgctrl.hxx:132
SvxRectCtl(const SvxRectCtl &)=delete
std::unique_ptr< BitmapEx > pBitmap
Definition: dlgctrl.hxx:94
Point aPtNew
Definition: dlgctrl.hxx:92
rtl::Reference< SvxRectCtlAccessibleContext > pAccContext
Definition: dlgctrl.hxx:87
SvxRectCtl & operator=(const SvxRectCtl &)=delete
css::uno::Reference< css::accessibility::XAccessible > getAccessibleParent() const
Definition: dlgctrl.hxx:130
CTL_STATE m_nState
Definition: dlgctrl.hxx:95
bool mbCompleteDisable
Definition: dlgctrl.hxx:97
SvxTabPage * m_pPage
Definition: dlgctrl.hxx:76
Point aPtLB
Definition: dlgctrl.hxx:91
Point aPtLT
Definition: dlgctrl.hxx:89
bool IsCompletelyDisabled() const
Definition: dlgctrl.hxx:136
sal_uInt16 nBorderWidth
Definition: dlgctrl.hxx:88
Point aPtLM
Definition: dlgctrl.hxx:90
RectPoint GetActualRP() const
Definition: dlgctrl.hxx:120
RectPoint eDefRP
Definition: dlgctrl.hxx:93
virtual void PointChanged(weld::DrawingArea *pArea, RectPoint eRP)=0
SvxTabPage(weld::Container *pPage, weld::DialogController *pController, const OUString &rUIXMLDescription, const OString &rID, const SfxItemSet &rAttrSet)
Definition: dlgctrl.hxx:47
SdrPathObj * mpLineObjA
Definition: dlgctrl.hxx:336
void ShowSymbol(bool b)
Definition: dlgctrl.hxx:351
Graphic * mpGraphic
Definition: dlgctrl.hxx:340
SdrPathObj * mpLineObjC
Definition: dlgctrl.hxx:338
SdrPathObj * mpLineObjB
Definition: dlgctrl.hxx:337
SdrObject * mpRectangleObject
Definition: dlgctrl.hxx:362
SdrObject * mpRectangleShadow
Definition: dlgctrl.hxx:387
SdrObject * mpRectangleObject
Definition: dlgctrl.hxx:386
Point maShadowOffset
Definition: dlgctrl.hxx:384
void limitWidthForSidebar(weld::SpinButton &rSpinButton)
Definition: dlgctrl.cxx:1445
SVX_DLLPUBLIC void padWidthForSidebar(weld::Toolbar &rToolbar, const css::uno::Reference< css::frame::XFrame > &rFrame)
Definition: dlgctrl.cxx:1458
CTL_STATE
Definition: dlgctrl.hxx:60
sal_uInt16 nPos
NONE
Fill
long Long
RectPoint
Definition: rectenum.hxx:23
@ MouseButtonDown
#define SVX_DLLPUBLIC
Definition: svxdllapi.h:28
#define SVX_DLLPRIVATE
Definition: svxdllapi.h:30
static const ChildIndexToPointData * IndexToPoint(tools::Long nIndex)
static tools::Long PointToIndex(RectPoint ePoint)
unsigned char sal_uInt8
#define SAL_WARN_UNUSED
Reference< XControl > m_xControl
css::uno::Reference< css::accessibility::XAccessibleRelationSet > a11yrelationset