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 OUString& 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:
78 sal_uInt16 nBorderWidth;
79 Point aPtLT, aPtMT, aPtRT;
80 Point aPtLM, aPtMM, aPtRM;
81 Point aPtLB, aPtMB, aPtRB;
84 std::unique_ptr<BitmapEx> pBitmap;
87
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);
92
93 SvxRectCtl(const SvxRectCtl&) = delete;
94 SvxRectCtl& operator=(const SvxRectCtl&) = delete;
95
96protected:
97 RectPoint GetRPFromPoint( Point, bool bRTL = false ) const;
98 const Point& GetPointFromRP( RectPoint ) const;
99 Point SetActualRPWithoutInvalidate( RectPoint eNewRP ); // returns the last point
100
101 Point GetApproxLogPtFromPixPt( const Point& rRoughPixelPoint ) const;
102public:
103 SvxRectCtl(SvxTabPage* pPage);
104 void SetControlSettings(RectPoint eRpt, sal_uInt16 nBorder);
105 virtual ~SvxRectCtl() override;
106
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;
116
117 void Reset();
118 RectPoint GetActualRP() const { return eRP;}
119 void SetActualRP( RectPoint eNewRP );
120
121 void SetState( CTL_STATE nState );
122
123 static const sal_uInt8 NO_CHILDREN = 9; // returns number of usable radio buttons
124
125 tools::Rectangle CalculateFocusRectangle() const;
126 tools::Rectangle CalculateFocusRectangle( RectPoint eRectPoint ) const;
127
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(); }
131
132 RectPoint GetApproxRPFromPixPt( const css::awt::Point& rPixelPoint ) const;
133
134 bool IsCompletelyDisabled() const { return mbCompleteDisable; }
135 void DoCompletelyDisable(bool bNew);
136};
137
138/*************************************************************************
139|* Control for editing bitmaps
140\************************************************************************/
141
143{
144private:
145 static sal_uInt16 constexpr nLines = 8;
146 static sal_uInt16 constexpr nSquares = nLines * nLines;
147
149
153 std::array<sal_uInt8,nSquares> maPixelData;
155 //Add member identifying position
158
159 tools::Rectangle implCalFocusRect( const Point& aPosition );
160 void ChangePixel( sal_uInt16 nPixel );
161
162 SvxPixelCtl(SvxPixelCtl const&) = delete;
166
167public:
168 SvxPixelCtl(SvxTabPage* pPage);
169
170 virtual ~SvxPixelCtl() override;
171
172 virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
173 virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
174 virtual bool MouseButtonDown( const MouseEvent& rMEvt ) override;
175 virtual void Resize() override;
176 virtual tools::Rectangle GetFocusRect() override;
177
178 void SetXBitmap( const BitmapEx& rBitmapEx );
179
180 void SetPixelColor( const Color& rCol ) { aPixelColor = rCol; }
181 void SetBackgroundColor( const Color& rCol ) { aBackgroundColor = rCol; }
182
183 static sal_uInt16 GetLineCount() { return nLines; }
184
185 sal_uInt8 GetBitmapPixel( const sal_uInt16 nPixelNumber ) const;
186 std::array<sal_uInt8,64> const & GetBitmapPixelPtr() const { return maPixelData; }
187
188 void SetPaintable( bool bTmp ) { bPaintable = bTmp; }
189 void Reset();
190
191 css::uno::Reference<css::accessibility::XAccessible> getAccessibleParent() const { return GetDrawingArea()->get_accessible_parent(); }
192 virtual css::uno::Reference<css::accessibility::XAccessible> CreateAccessible() override;
193 a11yrelationset get_accessible_relation_set() const { return GetDrawingArea()->get_accessible_relation_set(); }
194
195 static tools::Long GetSquares() { return nSquares ; }
196 tools::Long GetWidth() const { return aRectSize.getWidth() ; }
197 tools::Long GetHeight() const { return aRectSize.getHeight() ; }
198
199 //Device Pixel .
200 tools::Long ShowPosition( const Point &pt);
201
202 tools::Long PointToIndex(const Point &pt) const;
203 Point IndexToPoint(tools::Long nIndex) const ;
204 tools::Long GetFocusPosIndex() const ;
205 //Keyboard function for key input and focus handling function
206 virtual bool KeyInput( const KeyEvent& rKEvt ) override;
207 virtual void GetFocus() override;
208 virtual void LoseFocus() override;
209};
210
211/************************************************************************/
212
214{
215private:
216 std::unique_ptr<weld::ComboBox> m_xControl;
217
220
221public:
222 SvxLineLB(std::unique_ptr<weld::ComboBox> pControl);
223
224 void Fill(const XDashListRef &pList);
225 bool getAddStandardFields() const { return mbAddStandardFields; }
226 void setAddStandardFields(bool bNew);
227
228 void Append(const XDashEntry& rEntry, const BitmapEx& rBitmap );
229 void Modify(const XDashEntry& rEntry, sal_Int32 nPos, const BitmapEx& rBitmap );
230
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(); }
242};
243
244/************************************************************************/
245
247{
248private:
249 std::unique_ptr<weld::ComboBox> m_xControl;
250
251public:
252 SvxLineEndLB(std::unique_ptr<weld::ComboBox> pControl);
253
254 void Fill( const XLineEndListRef &pList, bool bStart = true );
255
256 void Append( const XLineEndEntry& rEntry, const BitmapEx& rBitmap );
257 void Modify( const XLineEndEntry& rEntry, sal_Int32 nPos, const BitmapEx& rBitmap );
258
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(); }
272};
273
274class SdrObject;
275class SdrPathObj;
276class SdrModel;
277
279{
280private:
281 std::unique_ptr<SdrModel> mpModel;
283
284protected:
285 void InitSettings();
286
287 tools::Rectangle GetPreviewSize() const;
288
289 // prepare buffered paint
290 void LocalPrePaint(vcl::RenderContext const & rRenderContext);
291
292 // end and output buffered paint
293 void LocalPostPaint(vcl::RenderContext& rRenderContext);
294
295public:
297 virtual void SetDrawingArea(weld::DrawingArea*) override;
298 virtual ~SvxPreviewBase() override;
299
300 // change support
301 virtual void StyleUpdated() override;
302
304 {
305 mpBufferDevice->SetDrawMode(nDrawMode);
306 }
307
309 {
310 return mpBufferDevice->PixelToLogic(GetOutputSizePixel());
311 }
312
313 // dada read access
315 {
316 return *mpModel;
317 }
319 {
320 return *mpBufferDevice;
321 }
322};
323
324
325/*************************************************************************
326|*
327|* SvxLinePreview
328|*
329\************************************************************************/
330
332{
333private:
337
341
342public:
344 virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
345 virtual ~SvxXLinePreview() override;
346
347 void SetLineAttributes(const SfxItemSet& rItemSet);
348
349 void ShowSymbol( bool b ) { mbWithSymbol = b; };
350 void SetSymbol( Graphic* p, const Size& s );
351 void ResizeSymbol( const Size& s );
352
353 virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
354 virtual void Resize() override;
355};
356
358{
359private:
361
362public:
364 virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
365 virtual ~SvxXRectPreview() override;
366
367 void SetAttributes(const SfxItemSet& rItemSet);
368
369 virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
370 virtual void Resize() override;
371};
372
373/*************************************************************************
374|*
375|* SvxXShadowPreview
376|*
377\************************************************************************/
378
380{
381private:
383
386
387public:
389 virtual void SetDrawingArea(weld::DrawingArea* pDrawingArea) override;
390 virtual ~SvxXShadowPreview() override;
391
392 void SetRectangleAttributes(const SfxItemSet& rItemSet);
393 void SetShadowAttributes(const SfxItemSet& rItemSet);
394 void SetShadowPosition(const Point& rPos);
395
396 virtual void Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& rRect ) override;
397};
398
399class SvxRelativeField;
400
401void limitWidthForSidebar(weld::SpinButton& rSpinButton);
403//tdf#130197 Give this toolbar a width as if it had 5 standard toolbutton entries
404SVX_DLLPUBLIC void padWidthForSidebar(weld::Toolbar& rToolbar, const css::uno::Reference<css::frame::XFrame>& rFrame);
405
406#endif // INCLUDED_SVX_DLGCTRL_HXX
407
408/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
DrawModeFlags
Abstract DrawObject.
Definition: svdobj.hxx:260
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:265
void set_active_text(const OUString &rStr)
Definition: dlgctrl.hxx:263
void set_active(int nPos)
Definition: dlgctrl.hxx:262
int get_active() const
Definition: dlgctrl.hxx:261
void clear()
Definition: dlgctrl.hxx:259
void remove(int nPos)
Definition: dlgctrl.hxx:260
bool get_sensitive() const
Definition: dlgctrl.hxx:271
std::unique_ptr< weld::ComboBox > m_xControl
Definition: dlgctrl.hxx:249
int get_count() const
Definition: dlgctrl.hxx:266
bool get_value_changed_from_saved() const
Definition: dlgctrl.hxx:268
void append_text(const OUString &rStr)
Definition: dlgctrl.hxx:267
void save_value()
Definition: dlgctrl.hxx:269
void set_sensitive(bool bSensitive)
Definition: dlgctrl.hxx:270
OUString get_active_text() const
Definition: dlgctrl.hxx:264
void set_active(int nPos)
Definition: dlgctrl.hxx:234
OUString get_active_text() const
Definition: dlgctrl.hxx:236
void append_text(const OUString &rStr)
Definition: dlgctrl.hxx:239
void set_active_text(const OUString &rStr)
Definition: dlgctrl.hxx:235
std::unique_ptr< weld::ComboBox > m_xControl
Definition: dlgctrl.hxx:216
int get_count() const
Definition: dlgctrl.hxx:238
bool getAddStandardFields() const
Definition: dlgctrl.hxx:225
int get_active() const
Definition: dlgctrl.hxx:233
bool mbAddStandardFields
defines if standard fields (none, solid) are added, default is true
Definition: dlgctrl.hxx:219
bool get_value_changed_from_saved() const
Definition: dlgctrl.hxx:240
void connect_changed(const Link< weld::ComboBox &, void > &rLink)
Definition: dlgctrl.hxx:237
void clear()
Definition: dlgctrl.hxx:231
void remove(int nPos)
Definition: dlgctrl.hxx:232
void save_value()
Definition: dlgctrl.hxx:241
bool bPaintable
Definition: dlgctrl.hxx:154
void SetPaintable(bool bTmp)
Definition: dlgctrl.hxx:188
css::uno::Reference< css::accessibility::XAccessible > getAccessibleParent() const
Definition: dlgctrl.hxx:191
SvxPixelCtl & operator=(SvxPixelCtl const &)=delete
SvxPixelCtl(SvxPixelCtl const &)=delete
a11yrelationset get_accessible_relation_set() const
Definition: dlgctrl.hxx:193
Color aPixelColor
Definition: dlgctrl.hxx:150
Size aRectSize
Definition: dlgctrl.hxx:152
std::array< sal_uInt8, nSquares > maPixelData
Definition: dlgctrl.hxx:153
std::array< sal_uInt8, 64 > const & GetBitmapPixelPtr() const
Definition: dlgctrl.hxx:186
SvxPixelCtl(SvxPixelCtl &&)=delete
void SetPixelColor(const Color &rCol)
Definition: dlgctrl.hxx:180
void SetBackgroundColor(const Color &rCol)
Definition: dlgctrl.hxx:181
Point aFocusPosition
Definition: dlgctrl.hxx:156
rtl::Reference< SvxPixelCtlAccessible > m_xAccess
Definition: dlgctrl.hxx:157
tools::Long GetWidth() const
Definition: dlgctrl.hxx:196
static sal_uInt16 GetLineCount()
Definition: dlgctrl.hxx:183
SvxPixelCtl & operator=(SvxPixelCtl &&)=delete
tools::Long GetHeight() const
Definition: dlgctrl.hxx:197
SvxTabPage * m_pPage
Definition: dlgctrl.hxx:148
Color aBackgroundColor
Definition: dlgctrl.hxx:151
static tools::Long GetSquares()
Definition: dlgctrl.hxx:195
OutputDevice & getBufferDevice() const
Definition: dlgctrl.hxx:318
void SetDrawMode(DrawModeFlags nDrawMode)
Definition: dlgctrl.hxx:303
std::unique_ptr< SdrModel > mpModel
Definition: dlgctrl.hxx:281
VclPtr< VirtualDevice > mpBufferDevice
Definition: dlgctrl.hxx:282
SdrModel & getModel() const
Definition: dlgctrl.hxx:314
Size GetOutputSize() const
Definition: dlgctrl.hxx:308
a11yrelationset get_accessible_relation_set() const
Definition: dlgctrl.hxx:130
SvxRectCtl(const SvxRectCtl &)=delete
std::unique_ptr< BitmapEx > pBitmap
Definition: dlgctrl.hxx:84
Point aPtNew
Definition: dlgctrl.hxx:82
rtl::Reference< SvxRectCtlAccessibleContext > pAccContext
Definition: dlgctrl.hxx:77
SvxRectCtl & operator=(const SvxRectCtl &)=delete
css::uno::Reference< css::accessibility::XAccessible > getAccessibleParent() const
Definition: dlgctrl.hxx:128
CTL_STATE m_nState
Definition: dlgctrl.hxx:85
bool mbCompleteDisable
Definition: dlgctrl.hxx:86
SvxTabPage * m_pPage
Definition: dlgctrl.hxx:76
Point aPtLB
Definition: dlgctrl.hxx:81
Point aPtLT
Definition: dlgctrl.hxx:79
bool IsCompletelyDisabled() const
Definition: dlgctrl.hxx:134
sal_uInt16 nBorderWidth
Definition: dlgctrl.hxx:78
Point aPtLM
Definition: dlgctrl.hxx:80
RectPoint GetActualRP() const
Definition: dlgctrl.hxx:118
RectPoint eDefRP
Definition: dlgctrl.hxx:83
virtual void PointChanged(weld::DrawingArea *pArea, RectPoint eRP)=0
SvxTabPage(weld::Container *pPage, weld::DialogController *pController, const OUString &rUIXMLDescription, const OUString &rID, const SfxItemSet &rAttrSet)
Definition: dlgctrl.hxx:47
rtl::Reference< SdrPathObj > mpLineObjC
Definition: dlgctrl.hxx:336
void ShowSymbol(bool b)
Definition: dlgctrl.hxx:349
rtl::Reference< SdrPathObj > mpLineObjA
Definition: dlgctrl.hxx:334
Graphic * mpGraphic
Definition: dlgctrl.hxx:338
rtl::Reference< SdrPathObj > mpLineObjB
Definition: dlgctrl.hxx:335
rtl::Reference< SdrObject > mpRectangleObject
Definition: dlgctrl.hxx:360
rtl::Reference< SdrObject > mpRectangleShadow
Definition: dlgctrl.hxx:385
rtl::Reference< SdrObject > mpRectangleObject
Definition: dlgctrl.hxx:384
Point maShadowOffset
Definition: dlgctrl.hxx:382
void limitWidthForSidebar(weld::SpinButton &rSpinButton)
Definition: dlgctrl.cxx:1430
SVX_DLLPUBLIC void padWidthForSidebar(weld::Toolbar &rToolbar, const css::uno::Reference< css::frame::XFrame > &rFrame)
Definition: dlgctrl.cxx:1443
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