LibreOffice Module svx (master)  1
dlgctrl.cxx
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 
20 #include <vcl/svapp.hxx>
21 #include <vcl/settings.hxx>
22 #include <vcl/virdev.hxx>
23 #include <vcl/event.hxx>
24 #include <sfx2/dialoghelper.hxx>
25 #include <sfx2/weldutils.hxx>
26 #include <svx/relfld.hxx>
27 #include <svx/xlineit0.hxx>
28 #include <svx/xtable.hxx>
29 #include <svx/strings.hrc>
30 #include <bitmaps.hlst>
31 #include <svx/dlgctrl.hxx>
32 #include <svx/dialmgr.hxx>
33 #include <tools/debug.hxx>
35 #include <svtools/colorcfg.hxx>
39 #include <svx/svdorect.hxx>
40 #include <svx/svdmodel.hxx>
41 #include <svx/svdopath.hxx>
44 #include <vcl/BitmapTools.hxx>
45 
46 #define OUTPUT_DRAWMODE_COLOR (DrawModeFlags::Default)
47 #define OUTPUT_DRAWMODE_CONTRAST (DrawModeFlags::SettingsLine | DrawModeFlags::SettingsFill | DrawModeFlags::SettingsText | DrawModeFlags::SettingsGradient)
48 
49 using namespace ::com::sun::star;
50 using namespace ::com::sun::star::uno;
51 using namespace ::com::sun::star::lang;
52 using namespace ::com::sun::star::accessibility;
53 
54 // Control for display and selection of the corner points and
55 // mid point of an object
56 
58 {
59  if( !pBitmap )
61 
62  return *pBitmap;
63 }
64 
65 SvxRectCtl::SvxRectCtl(SvxTabPage* pPage, RectPoint eRpt, sal_uInt16 nBorder)
66  : m_pPage(pPage)
67  , nBorderWidth(Application::GetDefaultDevice()->LogicToPixel(Size(nBorder, 0), MapMode(MapUnit::Map100thMM)).Width())
68  , eRP(eRpt)
69  , eDefRP(eRpt)
70  , m_nState(CTL_STATE::NONE)
71  , mbCompleteDisable(false)
72 {
73 }
74 
76 {
77  CustomWidgetController::SetDrawingArea(pDrawingArea);
78  Size aSize(pDrawingArea->get_approximate_digit_width() * 25,
79  pDrawingArea->get_text_height() * 5);
80  pDrawingArea->set_size_request(aSize.Width(), aSize.Height());
81  Resize_Impl(aSize);
82 }
83 
84 void SvxRectCtl::SetControlSettings(RectPoint eRpt, sal_uInt16 nBorder)
85 {
86  nBorderWidth = Application::GetDefaultDevice()->LogicToPixel(Size(nBorder, 0), MapMode(MapUnit::Map100thMM)).Width();
87  eDefRP = eRpt;
88  Resize();
89 }
90 
92 {
93  pBitmap.reset();
94  pAccContext.clear();
95 }
96 
98 {
100 }
101 
102 void SvxRectCtl::Resize_Impl(const Size &rSize)
103 {
104  aPtLT = Point( 0 + nBorderWidth, 0 + nBorderWidth );
105  aPtMT = Point( rSize.Width() / 2, 0 + nBorderWidth );
106  aPtRT = Point( rSize.Width() - nBorderWidth, 0 + nBorderWidth );
107 
108  aPtLM = Point( 0 + nBorderWidth, rSize.Height() / 2 );
109  aPtMM = Point( rSize.Width() / 2, rSize.Height() / 2 );
110  aPtRM = Point( rSize.Width() - nBorderWidth, rSize.Height() / 2 );
111 
112  aPtLB = Point( 0 + nBorderWidth, rSize.Height() - nBorderWidth );
113  aPtMB = Point( rSize.Width() / 2, rSize.Height() - nBorderWidth );
114  aPtRB = Point( rSize.Width() - nBorderWidth, rSize.Height() - nBorderWidth );
115 
116  Reset();
117  StyleUpdated();
118 }
119 
121 {
122  pBitmap.reset();
123 
125  svtools::ColorConfig aColorConfig;
126 
127  pBitmap.reset(new BitmapEx(RID_SVXCTRL_RECTBTNS));
128 
129  // set bitmap-colors
130  Color aColorAry1[7];
131  Color aColorAry2[7];
132  aColorAry1[0] = Color( 0xC0, 0xC0, 0xC0 ); // light-gray
133  aColorAry1[1] = Color( 0xFF, 0xFF, 0x00 ); // yellow
134  aColorAry1[2] = Color( 0xFF, 0xFF, 0xFF ); // white
135  aColorAry1[3] = Color( 0x80, 0x80, 0x80 ); // dark-gray
136  aColorAry1[4] = Color( 0x00, 0x00, 0x00 ); // black
137  aColorAry1[5] = Color( 0x00, 0xFF, 0x00 ); // green
138  aColorAry1[6] = Color( 0x00, 0x00, 0xFF ); // blue
139  aColorAry2[0] = rStyles.GetDialogColor(); // background
140  aColorAry2[1] = rStyles.GetWindowColor();
141  aColorAry2[2] = rStyles.GetLightColor();
142  aColorAry2[3] = rStyles.GetShadowColor();
143  aColorAry2[4] = rStyles.GetDarkShadowColor();
144  aColorAry2[5] = aColorConfig.GetColorValue( svtools::FONTCOLOR ).nColor;
145  aColorAry2[6] = rStyles.GetDialogColor();
146 
147 #ifdef DBG_UTIL
148  static bool bModify = false;
149  bool& rModify = bModify;
150  if( rModify )
151  {
152  static int n = 0;
153  static sal_uInt8 r = 0xFF;
154  static sal_uInt8 g = 0x00;
155  static sal_uInt8 b = 0xFF;
156  int& rn = n;
157  sal_uInt8& rr = r;
158  sal_uInt8& rg = g;
159  sal_uInt8& rb = b;
160  aColorAry2[ rn ] = Color( rr, rg, rb );
161  }
162 #endif
163 
164  pBitmap->Replace( aColorAry1, aColorAry2, 7 );
165 }
166 
168 {
169  pBitmap.reset(); // forces new creating of bitmap
170  CustomWidgetController::StyleUpdated();
171 }
172 
174 {
175  svtools::ColorConfig aColorConfig;
176  Color aTextColor(aColorConfig.GetColorValue(svtools::FONTCOLOR).nColor);
177  rRenderContext.SetTextColor(aTextColor);
178  const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
179  rRenderContext.SetBackground(rStyleSettings.GetWindowColor());
180 }
181 
182 // The clicked rectangle (3 x 3) is determined and the parent (dialog)
183 // is notified that the item was changed
185 {
186  // CompletelyDisabled() added to have a disabled state for SvxRectCtl
187  if(!IsCompletelyDisabled())
188  {
191  SetActualRP( eRP );
192 
193  if (m_pPage)
195  }
196  return true;
197 }
198 
199 bool SvxRectCtl::KeyInput(const KeyEvent& rKeyEvt)
200 {
201  // CompletelyDisabled() added to have a disabled state for SvxRectCtl
202  if (IsCompletelyDisabled())
203  return false;
204 
205  RectPoint eNewRP = eRP;
206 
207  switch( rKeyEvt.GetKeyCode().GetCode() )
208  {
209  case KEY_DOWN:
210  {
211  if( !(m_nState & CTL_STATE::NOVERT) )
212  switch( eNewRP )
213  {
214  case RectPoint::LT: eNewRP = RectPoint::LM; break;
215  case RectPoint::MT: eNewRP = RectPoint::MM; break;
216  case RectPoint::RT: eNewRP = RectPoint::RM; break;
217  case RectPoint::LM: eNewRP = RectPoint::LB; break;
218  case RectPoint::MM: eNewRP = RectPoint::MB; break;
219  case RectPoint::RM: eNewRP = RectPoint::RB; break;
220  default: ; //prevent warning
221  }
222  }
223  break;
224  case KEY_UP:
225  {
226  if( !(m_nState & CTL_STATE::NOVERT) )
227  switch( eNewRP )
228  {
229  case RectPoint::LM: eNewRP = RectPoint::LT; break;
230  case RectPoint::MM: eNewRP = RectPoint::MT; break;
231  case RectPoint::RM: eNewRP = RectPoint::RT; break;
232  case RectPoint::LB: eNewRP = RectPoint::LM; break;
233  case RectPoint::MB: eNewRP = RectPoint::MM; break;
234  case RectPoint::RB: eNewRP = RectPoint::RM; break;
235  default: ; //prevent warning
236  }
237  }
238  break;
239  case KEY_LEFT:
240  {
241  if( !(m_nState & CTL_STATE::NOHORZ) )
242  switch( eNewRP )
243  {
244  case RectPoint::MT: eNewRP = RectPoint::LT; break;
245  case RectPoint::RT: eNewRP = RectPoint::MT; break;
246  case RectPoint::MM: eNewRP = RectPoint::LM; break;
247  case RectPoint::RM: eNewRP = RectPoint::MM; break;
248  case RectPoint::MB: eNewRP = RectPoint::LB; break;
249  case RectPoint::RB: eNewRP = RectPoint::MB; break;
250  default: ; //prevent warning
251  }
252  }
253  break;
254  case KEY_RIGHT:
255  {
256  if( !(m_nState & CTL_STATE::NOHORZ) )
257  switch( eNewRP )
258  {
259  case RectPoint::LT: eNewRP = RectPoint::MT; break;
260  case RectPoint::MT: eNewRP = RectPoint::RT; break;
261  case RectPoint::LM: eNewRP = RectPoint::MM; break;
262  case RectPoint::MM: eNewRP = RectPoint::RM; break;
263  case RectPoint::LB: eNewRP = RectPoint::MB; break;
264  case RectPoint::MB: eNewRP = RectPoint::RB; break;
265  default: ; //prevent warning
266  }
267  }
268  break;
269  default:
270  return false;
271  }
272  if( eNewRP != eRP )
273  {
274  SetActualRP( eNewRP );
275 
276  if (m_pPage)
278  }
279  return true;
280 }
281 
282 // the control (rectangle with 9 circles)
284 {
285  InitSettings(rRenderContext);
286 
287  Point aPtDiff(1, 1);
288 
290 
291  rRenderContext.SetLineColor(rStyles.GetDialogColor());
292  rRenderContext.SetFillColor(rStyles.GetDialogColor());
293  rRenderContext.DrawRect(tools::Rectangle(Point(0,0), rRenderContext.GetOutputSize()));
294 
295  if (IsEnabled())
296  rRenderContext.SetLineColor(rStyles.GetLabelTextColor());
297  else
298  rRenderContext.SetLineColor(rStyles.GetShadowColor());
299 
300  rRenderContext.SetFillColor();
301 
302  if (!IsEnabled())
303  {
304  Color aOldCol = rRenderContext.GetLineColor();
305  rRenderContext.SetLineColor(rStyles.GetLightColor());
306  rRenderContext.DrawRect(tools::Rectangle(aPtLT + aPtDiff, aPtRB + aPtDiff));
307  rRenderContext.SetLineColor(aOldCol);
308  }
309  rRenderContext.DrawRect(tools::Rectangle(aPtLT, aPtRB));
310 
311  rRenderContext.SetFillColor(rRenderContext.GetBackground().GetColor());
312 
313  Size aBtnSize(11, 11);
314  Size aDstBtnSize(aBtnSize);
315  Point aToCenter(aDstBtnSize.Width() >> 1, aDstBtnSize.Height() >> 1);
316  Point aBtnPnt1(IsEnabled() ? 0 : 22, 0);
317  Point aBtnPnt2(11, 0);
318  Point aBtnPnt3(22, 0);
319 
320  bool bNoHorz = bool(m_nState & CTL_STATE::NOHORZ);
321  bool bNoVert = bool(m_nState & CTL_STATE::NOVERT);
322 
323  BitmapEx& rBitmap = GetRectBitmap();
324 
325  // CompletelyDisabled() added to have a disabled state for SvxRectCtl
326  if (IsCompletelyDisabled())
327  {
328  rRenderContext.DrawBitmapEx(aPtLT - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap);
329  rRenderContext.DrawBitmapEx(aPtMT - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap);
330  rRenderContext.DrawBitmapEx(aPtRT - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap);
331  rRenderContext.DrawBitmapEx(aPtLM - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap);
332  rRenderContext.DrawBitmapEx(aPtMM - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap);
333  rRenderContext.DrawBitmapEx(aPtRM - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap);
334  rRenderContext.DrawBitmapEx(aPtLB - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap);
335  rRenderContext.DrawBitmapEx(aPtMB - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap);
336  rRenderContext.DrawBitmapEx(aPtRB - aToCenter, aDstBtnSize, aBtnPnt3, aBtnSize, rBitmap);
337  }
338  else
339  {
340  rRenderContext.DrawBitmapEx(aPtLT - aToCenter, aDstBtnSize, (bNoHorz || bNoVert)?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap);
341  rRenderContext.DrawBitmapEx(aPtMT - aToCenter, aDstBtnSize, bNoVert?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap);
342  rRenderContext.DrawBitmapEx(aPtRT - aToCenter, aDstBtnSize, (bNoHorz || bNoVert)?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap);
343  rRenderContext.DrawBitmapEx(aPtLM - aToCenter, aDstBtnSize, bNoHorz?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap);
344 
345  // Center for rectangle and line
346  rRenderContext.DrawBitmapEx(aPtMM - aToCenter, aDstBtnSize, aBtnPnt1, aBtnSize, rBitmap);
347 
348  rRenderContext.DrawBitmapEx(aPtRM - aToCenter, aDstBtnSize, bNoHorz?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap);
349  rRenderContext.DrawBitmapEx(aPtLB - aToCenter, aDstBtnSize, (bNoHorz || bNoVert)?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap);
350  rRenderContext.DrawBitmapEx(aPtMB - aToCenter, aDstBtnSize, bNoVert?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap);
351  rRenderContext.DrawBitmapEx(aPtRB - aToCenter, aDstBtnSize, (bNoHorz || bNoVert)?aBtnPnt3:aBtnPnt1, aBtnSize, rBitmap);
352  }
353 
354  // draw active button, avoid center pos for angle
355  // CompletelyDisabled() added to have a disabled state for SvxRectCtl
356  if (!IsCompletelyDisabled())
357  {
358  if (IsEnabled())
359  {
360  Point aCenterPt(aPtNew);
361  aCenterPt -= aToCenter;
362 
363  rRenderContext.DrawBitmapEx(aCenterPt, aDstBtnSize, aBtnPnt2, aBtnSize, rBitmap);
364  }
365  }
366 }
367 
369 {
370  tools::Rectangle aRet;
371  if (HasFocus())
372  aRet = CalculateFocusRectangle();
373  return aRet;
374 }
375 
376 // Convert RectPoint Point
377 
379 {
380  switch( _eRP )
381  {
382  case RectPoint::LT: return aPtLT;
383  case RectPoint::MT: return aPtMT;
384  case RectPoint::RT: return aPtRT;
385  case RectPoint::LM: return aPtLM;
386  case RectPoint::MM: return aPtMM;
387  case RectPoint::RM: return aPtRM;
388  case RectPoint::LB: return aPtLB;
389  case RectPoint::MB: return aPtMB;
390  case RectPoint::RB: return aPtRB;
391  }
392  return aPtMM; // default
393 }
394 
396 {
397  Point aPtLast = aPtNew;
398  aPtNew = GetPointFromRP( eNewRP );
399 
401  aPtNew.setX( aPtMM.X() );
402 
404  aPtNew.setY( aPtMM.Y() );
405 
406  // fdo#74751 this fix reverse base point on RTL UI.
407  bool bRTL = AllSettings::GetLayoutRTL();
408  eNewRP = GetRPFromPoint( aPtNew, bRTL );
409 
410  eDefRP = eNewRP;
411  eRP = eNewRP;
412 
413  return aPtLast;
414 }
415 
417 {
418  Invalidate();
419 
420  // Send accessibility event.
421  if (pAccContext.is())
422  {
423  pAccContext->FireChildFocus(GetActualRP());
424  }
425 }
426 
428 {
429  Invalidate();
430 }
431 
433 {
434  Point aPt = rPt;
435  long x;
436  long y;
437 
438  Size aSize(GetOutputSizePixel());
439 
440  if( !( m_nState & CTL_STATE::NOHORZ ) )
441  {
442  if( aPt.X() < aSize.Width() / 3 )
443  x = aPtLT.X();
444  else if( aPt.X() < aSize.Width() * 2 / 3 )
445  x = aPtMM.X();
446  else
447  x = aPtRB.X();
448  }
449  else
450  x = aPtMM.X();
451 
452  if( !( m_nState & CTL_STATE::NOVERT ) )
453  {
454  if( aPt.Y() < aSize.Height() / 3 )
455  y = aPtLT.Y();
456  else if( aPt.Y() < aSize.Height() * 2 / 3 )
457  y = aPtMM.Y();
458  else
459  y = aPtRB.Y();
460  }
461  else
462  y = aPtMM.Y();
463 
464  return Point( x, y );
465 }
466 
467 
468 // Converts Point in RectPoint
469 
470 RectPoint SvxRectCtl::GetRPFromPoint( Point aPt, bool bRTL ) const
471 {
472  RectPoint rPoint = RectPoint::MM; // default
473 
474  if (aPt == aPtLT) rPoint = bRTL ? RectPoint::RT : RectPoint::LT;
475  else if( aPt == aPtMT) rPoint = RectPoint::MT;
476  else if( aPt == aPtRT) rPoint = bRTL ? RectPoint::LT : RectPoint::RT;
477  else if( aPt == aPtLM) rPoint = bRTL ? RectPoint::RM : RectPoint::LM;
478  else if( aPt == aPtRM) rPoint = bRTL ? RectPoint::LM : RectPoint::RM;
479  else if( aPt == aPtLB) rPoint = bRTL ? RectPoint::RB : RectPoint::LB;
480  else if( aPt == aPtMB) rPoint = RectPoint::MB;
481  else if( aPt == aPtRB) rPoint = bRTL ? RectPoint::LB : RectPoint::RB;
482 
483  return rPoint;
484 }
485 
486 // Resets to the original state of the control
487 
489 {
491  eRP = eDefRP;
492  Invalidate();
493 }
494 
495 // Returns the currently selected RectPoint
496 
497 
499 {
501 
502  Invalidate();
503 
504  // notify accessibility object about change
505  if (pAccContext.is())
506  pAccContext->selectChild( eNewRP /* MT, bFireFocus */ );
507 }
508 
510 {
511  m_nState = nState;
512 
513  Point aPtLast( GetPointFromRP( eRP ) );
514  Point _aPtNew( aPtLast );
515 
517  _aPtNew.setX( aPtMM.X() );
518 
520  _aPtNew.setY( aPtMM.Y() );
521 
522  eRP = GetRPFromPoint( _aPtNew );
523  Invalidate();
524 
525  if (m_pPage)
527 }
528 
530 {
531  Size aDstBtnSize(15, 15);
532  return tools::Rectangle( aPtNew - Point( aDstBtnSize.Width() >> 1, aDstBtnSize.Height() >> 1 ), aDstBtnSize );
533 }
534 
536 {
537  tools::Rectangle aRet;
538  RectPoint eOldRectPoint = GetActualRP();
539 
540  if( eOldRectPoint == eRectPoint )
541  aRet = CalculateFocusRectangle();
542  else
543  {
544  SvxRectCtl* pThis = const_cast<SvxRectCtl*>(this);
545 
546  pThis->SetActualRPWithoutInvalidate( eRectPoint ); // no invalidation because it's only temporary!
547  aRet = CalculateFocusRectangle();
548 
549  pThis->SetActualRPWithoutInvalidate( eOldRectPoint ); // no invalidation because nothing has changed!
550  }
551 
552  return aRet;
553 }
554 
555 Reference< XAccessible > SvxRectCtl::CreateAccessible()
556 {
558  return pAccContext.get();
559 }
560 
561 RectPoint SvxRectCtl::GetApproxRPFromPixPt( const css::awt::Point& r ) const
562 {
563  return GetRPFromPoint( GetApproxLogPtFromPixPt( Point( r.X, r.Y ) ) );
564 }
565 
566 // CompletelyDisabled() added to have a disabled state for SvxRectCtl
568 {
569  mbCompleteDisable = bNew;
570  Invalidate();
571 }
572 
573 // Control for editing bitmaps
574 
575 css::uno::Reference< css::accessibility::XAccessible > SvxPixelCtl::CreateAccessible()
576 {
577  if (!m_xAccess.is())
578  m_xAccess = new SvxPixelCtlAccessible(this);
579  return m_xAccess.get();
580 }
581 
582 long SvxPixelCtl::PointToIndex(const Point &aPt) const
583 {
584  long nX = aPt.X() * nLines / aRectSize.Width();
585  long nY = aPt.Y() * nLines / aRectSize.Height();
586 
587  return nX + nY * nLines ;
588 }
589 
591 {
592  DBG_ASSERT(nIndex >= 0 && nIndex < nSquares ," Check Index");
593 
594  sal_Int32 nXIndex = nIndex % nLines;
595  sal_Int32 nYIndex = nIndex / nLines;
596 
597  Point aPtTl;
598  aPtTl.setY( aRectSize.Height() * nYIndex / nLines + 1 );
599  aPtTl.setX( aRectSize.Width() * nXIndex / nLines + 1 );
600 
601  return aPtTl;
602 }
603 
605 {
606  return aFocusPosition.getX() + aFocusPosition.getY() * nLines ;
607 }
608 
609 long SvxPixelCtl::ShowPosition( const Point &rPt)
610 {
611  sal_Int32 nX = rPt.X() * nLines / aRectSize.Width();
612  sal_Int32 nY = rPt.Y() * nLines / aRectSize.Height();
613 
614  ChangePixel( nX + nY * nLines );
615 
616  //Solution:Set new focus position and repaint
617  aFocusPosition.setX(nX);
618  aFocusPosition.setY(nY);
620 
621  if (m_pPage)
622  m_pPage->PointChanged(GetDrawingArea(), RectPoint::MM ); // RectPoint is dummy
623 
624  return GetFocusPosIndex();
625 
626 }
627 
629  : m_pPage(pPage)
630  , bPaintable(true)
631  , aFocusPosition(0,0)
632 {
633  maPixelData.fill(0);
634 }
635 
637 {
638  CustomWidgetController::Resize();
640 }
641 
643 {
644  CustomWidgetController::SetDrawingArea(pDrawingArea);
645  pDrawingArea->set_size_request(pDrawingArea->get_approximate_digit_width() * 25,
646  pDrawingArea->get_text_height() * 10);
647 }
648 
650 {
651 }
652 
653 // Changes the foreground or Background color
654 
655 void SvxPixelCtl::ChangePixel( sal_uInt16 nPixel )
656 {
657  if( maPixelData[nPixel] == 0 )
658  maPixelData[nPixel] = 1; // could be extended to more colors
659  else
660  maPixelData[nPixel] = 0;
661 }
662 
663 // The clicked rectangle is identified, to change its color
664 
666 {
667  if (!aRectSize.Width() || !aRectSize.Height())
668  return true;
669 
670  //Grab focus when click in window
671  if (!HasFocus())
672  {
673  GrabFocus();
674  }
675 
676  long nIndex = ShowPosition(rMEvt.GetPosPixel());
677 
678  if(m_xAccess.is())
679  {
680  m_xAccess->NotifyChild(nIndex,true, true);
681  }
682 
683  return true;
684 }
685 
687 {
688  tools::Rectangle aRet;
689  //Draw visual focus when has focus
690  if (HasFocus())
692  return aRet;
693 }
694 
695 // Draws the Control (Rectangle with nine circles)
697 {
698  if (!aRectSize.Width() || !aRectSize.Height())
699  return;
700 
701  sal_uInt16 i, j, nTmp;
702  Point aPtTl, aPtBr;
703 
704  if (bPaintable)
705  {
706  // Draw lines
707  rRenderContext.SetLineColor(Color());
708  for (i = 1; i < nLines; i++)
709  {
710  // horizontal
711  nTmp = static_cast<sal_uInt16>(aRectSize.Height() * i / nLines);
712  rRenderContext.DrawLine(Point(0, nTmp), Point(aRectSize.Width(), nTmp));
713  // vertically
714  nTmp = static_cast<sal_uInt16>( aRectSize.Width() * i / nLines );
715  rRenderContext.DrawLine(Point(nTmp, 0), Point(nTmp, aRectSize.Height()));
716  }
717 
718  //Draw Rectangles (squares)
719  rRenderContext.SetLineColor();
720  sal_uInt16 nLastPixel = maPixelData[0] ? 0 : 1;
721 
722  for (i = 0; i < nLines; i++)
723  {
724  aPtTl.setY( aRectSize.Height() * i / nLines + 1 );
725  aPtBr.setY( aRectSize.Height() * (i + 1) / nLines - 1 );
726 
727  for (j = 0; j < nLines; j++)
728  {
729  aPtTl.setX( aRectSize.Width() * j / nLines + 1 );
730  aPtBr.setX( aRectSize.Width() * (j + 1) / nLines - 1 );
731 
732  if (maPixelData[i * nLines + j] != nLastPixel)
733  {
734  nLastPixel = maPixelData[i * nLines + j];
735  // Change color: 0 -> Background color
736  rRenderContext.SetFillColor(nLastPixel ? aPixelColor : aBackgroundColor);
737  }
738  rRenderContext.DrawRect(tools::Rectangle(aPtTl, aPtBr));
739  }
740  }
741  }
742  else
743  {
744  rRenderContext.SetBackground(Wallpaper(COL_LIGHTGRAY));
745  rRenderContext.SetLineColor(COL_LIGHTRED);
746  rRenderContext.DrawLine(Point(0, 0), Point(aRectSize.Width(), aRectSize.Height()));
747  rRenderContext.DrawLine(Point(0, aRectSize.Height()), Point(aRectSize.Width(), 0));
748  }
749 }
750 
751 //Calculate visual focus rectangle via focus position
753 {
754  long nLeft,nTop,nRight,nBottom;
755  long i,j;
756  i = aPosition.Y();
757  j = aPosition.X();
758  nLeft = aRectSize.Width() * j / nLines + 1;
759  nRight = aRectSize.Width() * (j + 1) / nLines - 1;
760  nTop = aRectSize.Height() * i / nLines + 1;
761  nBottom = aRectSize.Height() * (i + 1) / nLines - 1;
762  return tools::Rectangle(nLeft,nTop,nRight,nBottom);
763 }
764 
765 //Solution:Keyboard function
766 bool SvxPixelCtl::KeyInput( const KeyEvent& rKEvt )
767 {
768  vcl::KeyCode aKeyCode = rKEvt.GetKeyCode();
769  sal_uInt16 nCode = aKeyCode.GetCode();
770  bool bIsMod = aKeyCode.IsShift() || aKeyCode.IsMod1() || aKeyCode.IsMod2();
771 
772  if( !bIsMod )
773  {
774  Point aRepaintPoint( aRectSize.Width() *( aFocusPosition.getX() - 1)/ nLines - 1,
775  aRectSize.Height() *( aFocusPosition.getY() - 1)/ nLines -1
776  );
777  Size aRepaintSize( aRectSize.Width() *3/ nLines + 2,aRectSize.Height() *3/ nLines + 2);
778  tools::Rectangle aRepaintRect( aRepaintPoint, aRepaintSize );
779  bool bFocusPosChanged=false;
780  switch(nCode)
781  {
782  case KEY_LEFT:
783  if(aFocusPosition.getX() >= 1)
784  {
785  aFocusPosition.setX( aFocusPosition.getX() - 1 );
786  Invalidate(aRepaintRect);
787  bFocusPosChanged=true;
788  }
789  break;
790  case KEY_RIGHT:
791  if( aFocusPosition.getX() < (nLines - 1) )
792  {
793  aFocusPosition.setX( aFocusPosition.getX() + 1 );
794  Invalidate(aRepaintRect);
795  bFocusPosChanged=true;
796  }
797  break;
798  case KEY_UP:
799  if(aFocusPosition.getY() >= 1)
800  {
801  aFocusPosition.setY( aFocusPosition.getY() - 1 );
802  Invalidate(aRepaintRect);
803  bFocusPosChanged=true;
804  }
805  break;
806  case KEY_DOWN:
807  if( aFocusPosition.getY() < ( nLines - 1 ) )
808  {
809  aFocusPosition.setY( aFocusPosition.getY() + 1 );
810  Invalidate(aRepaintRect);
811  bFocusPosChanged=true;
812  }
813  break;
814  case KEY_SPACE:
815  ChangePixel( sal_uInt16(aFocusPosition.getX() + aFocusPosition.getY() * nLines) );
817  break;
818  default:
819  return CustomWidgetController::KeyInput( rKEvt );
820  }
821  if(m_xAccess.is())
822  {
823  long nIndex = GetFocusPosIndex();
824  switch(nCode)
825  {
826  case KEY_LEFT:
827  case KEY_RIGHT:
828  case KEY_UP:
829  case KEY_DOWN:
830  if (bFocusPosChanged)
831  {
832  m_xAccess->NotifyChild(nIndex,false,false);
833  }
834  break;
835  case KEY_SPACE:
836  m_xAccess->NotifyChild(nIndex,false,true);
837  break;
838  default:
839  break;
840  }
841  }
842  return true;
843  }
844  else
845  {
846  return CustomWidgetController::KeyInput( rKEvt );
847  }
848 }
849 
850 //Draw focus when get focus
852 {
854 
855  if (m_xAccess.is())
856  {
857  m_xAccess->NotifyChild(GetFocusPosIndex(),true,false);
858  }
859 }
860 
862 {
863  Invalidate();
864 }
865 
866 void SvxPixelCtl::SetXBitmap(const BitmapEx& rBitmapEx)
867 {
869  {
870  for (sal_uInt16 i = 0; i < nSquares; i++)
871  {
872  Color aColor = rBitmapEx.GetPixelColor(i%8, i/8);
873  maPixelData[i] = (aColor == aBackgroundColor) ? 0 : 1;
874  }
875  }
876 }
877 
878 // Returns a specific pixel
879 
880 sal_uInt8 SvxPixelCtl::GetBitmapPixel( const sal_uInt16 nPixel ) const
881 {
882  return maPixelData[nPixel];
883 }
884 
885 // Resets to the original state of the control
886 
888 {
889  // clear pixel area
890  maPixelData.fill(0);
891  Invalidate();
892 }
893 
894 SvxLineLB::SvxLineLB(std::unique_ptr<weld::ComboBox> pControl)
895  : m_xControl(std::move(pControl))
896  , mbAddStandardFields(true)
897 {
898 }
899 
901 {
902  if(getAddStandardFields() != bNew)
903  {
904  mbAddStandardFields = bNew;
905  }
906 }
907 
908 // Fills the listbox (provisional) with strings
909 
910 void SvxLineLB::Fill( const XDashListRef &pList )
911 {
912  m_xControl->clear();
913 
914  if( !pList.is() )
915  return;
916 
918 
920  {
921  // entry for 'none'
922  m_xControl->append_text(pList->GetStringForUiNoLine());
923 
924  // entry for solid line
925  const BitmapEx aBitmap = pList->GetBitmapForUISolidLine();
926  const Size aBmpSize(aBitmap.GetSizePixel());
927  pVD->SetOutputSizePixel(aBmpSize, false);
928  pVD->DrawBitmapEx(Point(), aBitmap);
929  m_xControl->append("", pList->GetStringForUiSolidLine(), *pVD);
930  }
931 
932  // entries for dashed lines
933 
934  long nCount = pList->Count();
935  m_xControl->freeze();
936 
937  for( long i = 0; i < nCount; i++ )
938  {
939  const XDashEntry* pEntry = pList->GetDash(i);
940  const BitmapEx aBitmap = pList->GetUiBitmap( i );
941  if( !aBitmap.IsEmpty() )
942  {
943  const Size aBmpSize(aBitmap.GetSizePixel());
944  pVD->SetOutputSizePixel(aBmpSize, false);
945  pVD->DrawBitmapEx(Point(), aBitmap);
946  m_xControl->append("", pEntry->GetName(), *pVD);
947  }
948  else
949  {
950  m_xControl->append_text(pEntry->GetName());
951  }
952  }
953 
954  m_xControl->thaw();
955 }
956 
957 void SvxLineLB::Append( const XDashEntry& rEntry, const BitmapEx& rBitmap )
958 {
959  if (!rBitmap.IsEmpty())
960  {
962 
963  const Size aBmpSize(rBitmap.GetSizePixel());
964  pVD->SetOutputSizePixel(aBmpSize, false);
965  pVD->DrawBitmapEx(Point(), rBitmap);
966  m_xControl->append("", rEntry.GetName(), *pVD);
967  }
968  else
969  {
970  m_xControl->append_text(rEntry.GetName());
971  }
972 }
973 
974 void SvxLineLB::Modify(const XDashEntry& rEntry, sal_Int32 nPos, const BitmapEx& rBitmap)
975 {
976  m_xControl->remove(nPos);
977 
978  if (!rBitmap.IsEmpty())
979  {
981 
982  const Size aBmpSize(rBitmap.GetSizePixel());
983  pVD->SetOutputSizePixel(aBmpSize, false);
984  pVD->DrawBitmapEx(Point(), rBitmap);
985  m_xControl->insert(nPos, rEntry.GetName(), nullptr, nullptr, pVD);
986  }
987  else
988  {
989  m_xControl->insert_text(nPos, rEntry.GetName());
990  }
991 }
992 
993 SvxLineEndLB::SvxLineEndLB(std::unique_ptr<weld::ComboBox> pControl)
994  : m_xControl(std::move(pControl))
995 {
996 }
997 
998 void SvxLineEndLB::Fill( const XLineEndListRef &pList, bool bStart )
999 {
1000  if( !pList.is() )
1001  return;
1002 
1003  long nCount = pList->Count();
1005  m_xControl->freeze();
1006 
1007  for( long i = 0; i < nCount; i++ )
1008  {
1009  const XLineEndEntry* pEntry = pList->GetLineEnd(i);
1010  const BitmapEx aBitmap = pList->GetUiBitmap( i );
1011  if( !aBitmap.IsEmpty() )
1012  {
1013  const Size aBmpSize(aBitmap.GetSizePixel());
1014  pVD->SetOutputSizePixel(Size(aBmpSize.Width() / 2, aBmpSize.Height()), false);
1015  pVD->DrawBitmapEx(bStart ? Point() : Point(-aBmpSize.Width() / 2, 0), aBitmap);
1016  m_xControl->append("", pEntry->GetName(), *pVD);
1017  }
1018  else
1019  m_xControl->append_text(pEntry->GetName());
1020  }
1021 
1022  m_xControl->thaw();
1023 }
1024 
1025 void SvxLineEndLB::Append( const XLineEndEntry& rEntry, const BitmapEx& rBitmap )
1026 {
1027  if(!rBitmap.IsEmpty())
1028  {
1030 
1031  const Size aBmpSize(rBitmap.GetSizePixel());
1032  pVD->SetOutputSizePixel(Size(aBmpSize.Width() / 2, aBmpSize.Height()), false);
1033  pVD->DrawBitmapEx(Point(-aBmpSize.Width() / 2, 0), rBitmap);
1034  m_xControl->append("", rEntry.GetName(), *pVD);
1035  }
1036  else
1037  {
1038  m_xControl->append_text(rEntry.GetName());
1039  }
1040 }
1041 
1042 void SvxLineEndLB::Modify( const XLineEndEntry& rEntry, sal_Int32 nPos, const BitmapEx& rBitmap )
1043 {
1044  m_xControl->remove(nPos);
1045 
1046  if(!rBitmap.IsEmpty())
1047  {
1049 
1050  const Size aBmpSize(rBitmap.GetSizePixel());
1051  pVD->SetOutputSizePixel(Size(aBmpSize.Width() / 2, aBmpSize.Height()), false);
1052  pVD->DrawBitmapEx(Point(-aBmpSize.Width() / 2, 0), rBitmap);
1053  m_xControl->insert(nPos, rEntry.GetName(), nullptr, nullptr, pVD);
1054  }
1055  else
1056  {
1057  m_xControl->insert_text(nPos, rEntry.GetName());
1058  }
1059 }
1060 
1062 {
1064 
1065  const Size aOutputSize(GetOutputSize());
1066  const sal_Int32 nDistance(500);
1067  const sal_Int32 nAvailableLength(aOutputSize.Width() - (4 * nDistance));
1068 
1069  // create DrawObectA
1070  const sal_Int32 aYPosA(aOutputSize.Height() / 2);
1071  const basegfx::B2DPoint aPointA1( nDistance, aYPosA);
1072  const basegfx::B2DPoint aPointA2( aPointA1.getX() + ((nAvailableLength * 14) / 20), aYPosA );
1073  basegfx::B2DPolygon aPolygonA;
1074  aPolygonA.append(aPointA1);
1075  aPolygonA.append(aPointA2);
1077 
1078  // create DrawObectB
1079  const sal_Int32 aYPosB1((aOutputSize.Height() * 3) / 4);
1080  const sal_Int32 aYPosB2((aOutputSize.Height() * 1) / 4);
1081  const basegfx::B2DPoint aPointB1( aPointA2.getX() + nDistance, aYPosB1);
1082  const basegfx::B2DPoint aPointB2( aPointB1.getX() + ((nAvailableLength * 2) / 20), aYPosB2 );
1083  const basegfx::B2DPoint aPointB3( aPointB2.getX() + ((nAvailableLength * 2) / 20), aYPosB1 );
1084  basegfx::B2DPolygon aPolygonB;
1085  aPolygonB.append(aPointB1);
1086  aPolygonB.append(aPointB2);
1087  aPolygonB.append(aPointB3);
1089 
1090  // create DrawObectC
1091  basegfx::B2DPolygon aPolygonC;
1092  const basegfx::B2DPoint aPointC1( aPointB3.getX() + nDistance, aYPosB1);
1093  const basegfx::B2DPoint aPointC2( aPointC1.getX() + ((nAvailableLength * 1) / 20), aYPosB2 );
1094  const basegfx::B2DPoint aPointC3( aPointC2.getX() + ((nAvailableLength * 1) / 20), aYPosB1 );
1095  aPolygonC.append(aPointC1);
1096  aPolygonC.append(aPointC2);
1097  aPolygonC.append(aPointC3);
1099 }
1100 
1102  : mpLineObjA(nullptr)
1103  , mpLineObjB(nullptr)
1104  , mpLineObjC(nullptr)
1105  , mpGraphic(nullptr)
1106  , mbWithSymbol(false)
1107 {
1108 }
1109 
1111 {
1112  SvxPreviewBase::SetDrawingArea(pDrawingArea);
1113 
1117 
1118  Resize();
1119  Invalidate();
1120 }
1121 
1123 {
1124  SdrObject *pFoo = mpLineObjA;
1125  SdrObject::Free( pFoo );
1126  pFoo = mpLineObjB;
1127  SdrObject::Free( pFoo );
1128  pFoo = mpLineObjC;
1129  SdrObject::Free( pFoo );
1130 }
1131 
1133 {
1134  mpGraphic = p;
1135  maSymbolSize = s;
1136 }
1137 
1139 {
1140  if ( s != maSymbolSize )
1141  {
1142  maSymbolSize = s;
1143  Invalidate();
1144  }
1145 }
1146 
1148 {
1149  // Set ItemSet at objects
1150  mpLineObjA->SetMergedItemSet(rItemSet);
1151 
1152  // At line joints, do not use arrows
1153  SfxItemSet aTempSet(rItemSet);
1154  aTempSet.ClearItem(XATTR_LINESTART);
1155  aTempSet.ClearItem(XATTR_LINEEND);
1156 
1157  mpLineObjB->SetMergedItemSet(aTempSet);
1158  mpLineObjC->SetMergedItemSet(aTempSet);
1159 }
1160 
1162 {
1163  LocalPrePaint(rRenderContext);
1164 
1165  // paint objects to buffer device
1166  sdr::contact::SdrObjectVector aObjectVector;
1167  aObjectVector.push_back(mpLineObjA);
1168  aObjectVector.push_back(mpLineObjB);
1169  aObjectVector.push_back(mpLineObjC);
1170 
1171  sdr::contact::ObjectContactOfObjListPainter aPainter(getBufferDevice(), aObjectVector, nullptr);
1172  sdr::contact::DisplayInfo aDisplayInfo;
1173 
1174  // do processing
1175  aPainter.ProcessDisplay(aDisplayInfo);
1176 
1177  if ( mbWithSymbol && mpGraphic )
1178  {
1179  const Size aOutputSize(GetOutputSize());
1180  Point aPos( aOutputSize.Width() / 3, aOutputSize.Height() / 2 );
1181  aPos.AdjustX( -(maSymbolSize.Width() / 2) );
1182  aPos.AdjustY( -(maSymbolSize.Height() / 2) );
1184  }
1185 
1186  LocalPostPaint(rRenderContext);
1187 }
1188 
1190  : mpRectangleObject(nullptr)
1191  , mpRectangleShadow(nullptr)
1192 {
1193 }
1194 
1196 {
1197  SvxPreviewBase::SetDrawingArea(pDrawingArea);
1198  InitSettings();
1199 
1200  // prepare size
1201  Size aSize = GetPreviewSize().GetSize();
1202  aSize.setWidth( aSize.Width() / 3 );
1203  aSize.setHeight( aSize.Height() / 3 );
1204 
1205  // create RectangleObject
1206  const tools::Rectangle aObjectSize( Point( aSize.Width(), aSize.Height() ), aSize );
1208  getModel(),
1209  aObjectSize);
1210 
1211  // create ShadowObject
1212  const tools::Rectangle aShadowSize( Point( aSize.Width(), aSize.Height() ), aSize );
1214  getModel(),
1215  aShadowSize);
1216 }
1217 
1219 {
1222 }
1223 
1225 {
1226  mpRectangleObject->SetMergedItemSet(rItemSet, true);
1227  mpRectangleObject->SetMergedItem(XLineStyleItem(drawing::LineStyle_NONE));
1228 }
1229 
1231 {
1232  mpRectangleShadow->SetMergedItemSet(rItemSet, true);
1233  mpRectangleShadow->SetMergedItem(XLineStyleItem(drawing::LineStyle_NONE));
1234 }
1235 
1237 {
1238  maShadowOffset = rPos;
1239 }
1240 
1242 {
1243  rRenderContext.Push(PushFlags::MAPMODE);
1244  rRenderContext.SetMapMode(MapMode(MapUnit::Map100thMM));
1245 
1246  LocalPrePaint(rRenderContext);
1247 
1248  // prepare size
1249  Size aSize = rRenderContext.GetOutputSize();
1250  aSize.setWidth( aSize.Width() / 3 );
1251  aSize.setHeight( aSize.Height() / 3 );
1252 
1253  tools::Rectangle aObjectRect(Point(aSize.Width(), aSize.Height()), aSize);
1254  mpRectangleObject->SetSnapRect(aObjectRect);
1255  aObjectRect.Move(maShadowOffset.X(), maShadowOffset.Y());
1256  mpRectangleShadow->SetSnapRect(aObjectRect);
1257 
1258  sdr::contact::SdrObjectVector aObjectVector;
1259 
1260  aObjectVector.push_back(mpRectangleShadow);
1261  aObjectVector.push_back(mpRectangleObject);
1262 
1263  sdr::contact::ObjectContactOfObjListPainter aPainter(getBufferDevice(), aObjectVector, nullptr);
1264  sdr::contact::DisplayInfo aDisplayInfo;
1265 
1266  aPainter.ProcessDisplay(aDisplayInfo);
1267 
1268  LocalPostPaint(rRenderContext);
1269 
1270  rRenderContext.Pop();
1271 }
1272 
1274 {
1275  const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
1276 
1277  svtools::ColorConfig aColorConfig;
1278  Color aTextColor(aColorConfig.GetColorValue(svtools::FONTCOLOR).nColor);
1279  getBufferDevice().SetTextColor(aTextColor);
1280 
1281  getBufferDevice().SetBackground(rStyleSettings.GetWindowColor());
1282 
1284 
1285  Invalidate();
1286 }
1287 
1289  : mpModel(new SdrModel(nullptr, nullptr, true))
1290 {
1291  // init model
1292  mpModel->GetItemPool().FreezeIdRanges();
1293 }
1294 
1296 {
1297  CustomWidgetController::SetDrawingArea(pDrawingArea);
1298  Size aSize(getPreviewStripSize(pDrawingArea->get_ref_device()));
1299  pDrawingArea->set_size_request(aSize.Width(), aSize.Height());
1300  SetOutputSizePixel(aSize);
1301 
1303  mpBufferDevice->SetMapMode(MapMode(MapUnit::Map100thMM));
1304 }
1305 
1307 {
1308  mpModel.reset();
1310 }
1311 
1313 {
1314  // init BufferDevice
1317  mpBufferDevice->SetAntialiasing(rRenderContext.GetAntialiasing());
1318 
1319  const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
1320 
1321  if (rStyleSettings.GetPreviewUsesCheckeredBackground())
1322  {
1323  const Point aNull(0, 0);
1324  static const sal_uInt32 nLen(8);
1325  static const Color aW(COL_WHITE);
1326  static const Color aG(0xef, 0xef, 0xef);
1327  const bool bWasEnabled(mpBufferDevice->IsMapModeEnabled());
1328 
1329  mpBufferDevice->EnableMapMode(false);
1331  mpBufferDevice->EnableMapMode(bWasEnabled);
1332  }
1333  else
1334  {
1335  mpBufferDevice->Erase();
1336  }
1337 }
1338 
1340 {
1341  // copy to front (in pixel mode)
1342  const bool bWasEnabledSrc(mpBufferDevice->IsMapModeEnabled());
1343  const bool bWasEnabledDst(rRenderContext.IsMapModeEnabled());
1344  const Point aEmptyPoint;
1345 
1346  mpBufferDevice->EnableMapMode(false);
1347  rRenderContext.EnableMapMode(false);
1348 
1349  rRenderContext.DrawOutDev(aEmptyPoint, GetOutputSizePixel(),
1350  aEmptyPoint, GetOutputSizePixel(),
1351  *mpBufferDevice);
1352 
1353  mpBufferDevice->EnableMapMode(bWasEnabledSrc);
1354  rRenderContext.EnableMapMode(bWasEnabledDst);
1355 }
1356 
1358 {
1359  InitSettings();
1360  CustomWidgetController::StyleUpdated();
1361 }
1362 
1364  : mpRectangleObject(nullptr)
1365 {
1366 }
1367 
1369 {
1370  tools::Rectangle aObjectSize(Point(), getBufferDevice().PixelToLogic(GetOutputSizePixel()));
1371  return aObjectSize;
1372 }
1373 
1375 {
1376  SvxPreviewBase::SetDrawingArea(pDrawingArea);
1377  InitSettings();
1378 
1379  // create RectangleObject
1381 }
1382 
1384 {
1385  SdrObject *pOrigObject = mpRectangleObject;
1386  if (pOrigObject)
1387  {
1389  SetAttributes(pOrigObject->GetMergedItemSet());
1390  SdrObject::Free(pOrigObject);
1391  }
1393 }
1394 
1396 {
1398 }
1399 
1401 {
1402  mpRectangleObject->SetMergedItemSet(rItemSet, true);
1403  mpRectangleObject->SetMergedItem(XLineStyleItem(drawing::LineStyle_NONE));
1404 }
1405 
1407 {
1408  rRenderContext.Push(PushFlags::MAPMODE);
1409  rRenderContext.SetMapMode(MapMode(MapUnit::Map100thMM));
1410  LocalPrePaint(rRenderContext);
1411 
1412  sdr::contact::SdrObjectVector aObjectVector;
1413 
1414  aObjectVector.push_back(mpRectangleObject);
1415 
1416  sdr::contact::ObjectContactOfObjListPainter aPainter(getBufferDevice(), aObjectVector, nullptr);
1417  sdr::contact::DisplayInfo aDisplayInfo;
1418 
1419  aPainter.ProcessDisplay(aDisplayInfo);
1420 
1421  LocalPostPaint(rRenderContext);
1422  rRenderContext.Pop();
1423 }
1424 
1426 {
1427  // space is limited in the sidebar, so limit MetricSpinButtons to a width of 4 digits
1428  const int nMaxDigits = 4;
1429  rSpinButton.set_width_chars(std::min(rSpinButton.get_width_chars(), nMaxDigits));
1430 }
1431 
1432 void limitWidthForSidebar(SvxRelativeField& rMetricSpinButton)
1433 {
1434  weld::SpinButton& rSpinButton = rMetricSpinButton.get_widget();
1435  limitWidthForSidebar(rSpinButton);
1436 }
1437 
1438 void padWidthForSidebar(weld::Toolbar& rToolbar, const css::uno::Reference<css::frame::XFrame>& rFrame)
1439 {
1440  static int nColumnWidth = -1;
1441  static vcl::ImageType eSize;
1442  if (nColumnWidth != -1 && eSize != rToolbar.get_icon_size())
1443  nColumnWidth = -1;
1444  if (nColumnWidth == -1)
1445  {
1446  // use the, filled-in by dispatcher, width of measurewidth as the width
1447  // of a "standard" column in a two column panel
1448  std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(&rToolbar, "svx/ui/measurewidthbar.ui"));
1449  std::unique_ptr<weld::Toolbar> xToolbar(xBuilder->weld_toolbar("measurewidth"));
1450  std::unique_ptr<ToolbarUnoDispatcher> xDispatcher(new ToolbarUnoDispatcher(*xToolbar, *xBuilder, rFrame));
1451  nColumnWidth = xToolbar->get_preferred_size().Width();
1452  eSize = rToolbar.get_icon_size();
1453  }
1454  rToolbar.set_size_request(nColumnWidth, -1);
1455 }
1456 
1457 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
CTL_STATE m_nState
Definition: dlgctrl.hxx:95
long Width() const
const Color & GetShadowColor() const
void setAddStandardFields(bool bNew)
Definition: dlgctrl.cxx:900
#define OUTPUT_DRAWMODE_CONTRAST
Definition: dlgctrl.cxx:47
virtual ~SvxPixelCtl() override
Definition: dlgctrl.cxx:649
const Wallpaper & GetBackground() const
void Modify(const XLineEndEntry &rEntry, sal_Int32 nPos, const BitmapEx &rBitmap)
Definition: dlgctrl.cxx:1042
void SetActualRP(RectPoint eNewRP)
Definition: dlgctrl.cxx:498
OutputDevice & getBufferDevice() const
Definition: dlgctrl.hxx:322
SvxTabPage * m_pPage
Definition: dlgctrl.hxx:150
sal_Int32 nIndex
void append(const basegfx::B2DPoint &rPoint, sal_uInt32 nCount)
const Color & GetDialogColor() const
constexpr TypedWhichId< XLineEndItem > XATTR_LINEEND(XATTR_LINE_FIRST+5)
void SetAntialiasing(AntialiasingFlags nMode)
void padWidthForSidebar(weld::Toolbar &rToolbar, const css::uno::Reference< css::frame::XFrame > &rFrame)
Definition: dlgctrl.cxx:1438
Color aPixelColor
Definition: dlgctrl.hxx:152
constexpr TypedWhichId< XLineStartItem > XATTR_LINESTART(XATTR_LINE_FIRST+4)
void limitWidthForSidebar(weld::SpinButton &rSpinButton)
Definition: dlgctrl.cxx:1425
virtual void Resize() override
Definition: dlgctrl.cxx:1061
virtual void SetDrawingArea(weld::DrawingArea *pDrawingArea) override
Definition: dlgctrl.cxx:642
SdrPathObj * mpLineObjB
Definition: dlgctrl.hxx:339
tools::Rectangle implCalFocusRect(const Point &aPosition)
Definition: dlgctrl.cxx:752
void SetXBitmap(const BitmapEx &rBitmapEx)
Definition: dlgctrl.cxx:866
Point aPtLT
Definition: dlgctrl.hxx:89
bool bPaintable
Definition: dlgctrl.hxx:156
Point aPtLM
Definition: dlgctrl.hxx:90
Reference< XControl > m_xControl
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
Definition: dlgctrl.cxx:1406
long Height() const
Size GetOutputSize() const
Definition: dlgctrl.hxx:312
void DrawBitmapEx(const Point &rDestPt, const BitmapEx &rBitmapEx)
void SetControlSettings(RectPoint eRpt, sal_uInt16 nBorder)
Definition: dlgctrl.cxx:84
virtual void SetDrawingArea(weld::DrawingArea *pDrawingArea) override
Definition: dlgctrl.cxx:1374
virtual void GetFocus() override
Definition: dlgctrl.cxx:851
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
Definition: dlgctrl.cxx:696
weld::SpinButton & get_widget()
Definition: relfld.hxx:64
void Reset()
Definition: dlgctrl.cxx:488
void DoCompletelyDisable(bool bNew)
Definition: dlgctrl.cxx:567
SVX_DLLPRIVATE BitmapEx & GetRectBitmap()
Definition: dlgctrl.cxx:57
virtual void SetDrawingArea(weld::DrawingArea *pDrawingArea) override
Definition: dlgctrl.cxx:75
const StyleSettings & GetStyleSettings() const
static const AllSettings & GetSettings()
class UNLESS_MERGELIBS(SVXCORE_DLLPUBLIC) ObjectContactPainter typedef::std::vector< SdrObject * > SdrObjectVector
SdrPathObj * mpLineObjA
Definition: dlgctrl.hxx:338
bool IsMapModeEnabled() const
sal_Int64 n
Point aPtRT
Definition: dlgctrl.hxx:89
virtual void SetDrawingArea(weld::DrawingArea *pDrawingArea) override
Definition: dlgctrl.cxx:1195
virtual ~SvxXRectPreview() override
Definition: dlgctrl.cxx:1395
sal_uInt16 GetCode() const
bool GetPreviewUsesCheckeredBackground() const
RectPoint GetActualRP() const
Definition: dlgctrl.hxx:120
RectPoint eRP
Definition: dlgctrl.hxx:93
long ShowPosition(const Point &pt)
Definition: dlgctrl.cxx:609
SdrModel & getModel() const
Definition: dlgctrl.hxx:318
SvxTabPage * m_pPage
Definition: dlgctrl.hxx:76
constexpr::Color COL_LIGHTRED(0xFF, 0x00, 0x00)
Color aBackgroundColor
Definition: dlgctrl.hxx:153
const Color & GetLabelTextColor() const
Point maShadowOffset
Definition: dlgctrl.hxx:386
virtual int get_width_chars() const =0
constexpr::Color COL_LIGHTGRAY(0xC0, 0xC0, 0xC0)
void EnableMapMode(bool bEnable=true)
virtual void set_width_chars(int nChars)=0
#define OUTPUT_DRAWMODE_COLOR
Definition: dlgctrl.cxx:46
static void Free(SdrObject *&_rpObject)
Definition: svdobj.cxx:396
void SetLineAttributes(const SfxItemSet &rItemSet)
Definition: dlgctrl.cxx:1147
constexpr sal_uInt16 KEY_SPACE
SVX_DLLPRIVATE void InitRectBitmap()
Definition: dlgctrl.cxx:120
virtual bool KeyInput(const KeyEvent &) override
Definition: dlgctrl.cxx:199
float x
virtual void SetDrawingArea(weld::DrawingArea *pDrawingArea) override
Definition: dlgctrl.cxx:1110
void SetRectangleAttributes(const SfxItemSet &rItemSet)
Definition: dlgctrl.cxx:1224
void SetMapMode()
AntialiasingFlags GetAntialiasing() const
virtual void LoseFocus() override
Definition: dlgctrl.cxx:861
polygon, PolyPolygon
Definition: svdobj.hxx:126
long GetFocusPosIndex() const
Definition: dlgctrl.cxx:604
constexpr sal_uInt16 KEY_UP
Size const & GetOutputSizePixel() const
Point IndexToPoint(long nIndex) const
Definition: dlgctrl.cxx:590
Point aFocusPosition
Definition: dlgctrl.hxx:158
SdrObject * mpRectangleShadow
Definition: dlgctrl.hxx:389
NONE
void Move(long nHorzMoveDelta, long nVertMoveDelta)
void SetDrawMode(DrawModeFlags nDrawMode)
Rectangle objects (rectangle, circle, ...)
Definition: svdorect.hxx:39
static OutputDevice * GetDefaultDevice()
void SetShadowAttributes(const SfxItemSet &rItemSet)
Definition: dlgctrl.cxx:1230
SdrPathObj * mpLineObjC
Definition: dlgctrl.hxx:340
virtual tools::Rectangle GetFocusRect() override
Definition: dlgctrl.cxx:686
void SetBackground()
SvxRectCtl(const SvxRectCtl &)=delete
bool mbAddStandardFields
defines if standard fields (none, solid) are added, default is true
Definition: dlgctrl.hxx:221
virtual void GetFocus() override
Definition: dlgctrl.cxx:416
virtual void PointChanged(weld::DrawingArea *pArea, RectPoint eRP)=0
Size aRectSize
Definition: dlgctrl.hxx:154
int nCount
bool getAddStandardFields() const
Definition: dlgctrl.hxx:227
Size getPreviewStripSize(const OutputDevice &rReference)
const Color & GetLightColor() const
bool GetHighContrastMode() const
void SetMergedItemSet(const SfxItemSet &rSet, bool bClearAllItems=false)
Definition: svdobj.cxx:1909
std::unique_ptr< SdrModel > mpModel
Definition: dlgctrl.hxx:285
virtual OutputDevice & get_ref_device()=0
std::array< sal_uInt8, nSquares > maPixelData
Definition: dlgctrl.hxx:155
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
Definition: dlgctrl.cxx:1161
void DrawLine(const Point &rStartPt, const Point &rEndPt)
void SetState(CTL_STATE nState)
Definition: dlgctrl.cxx:509
sal_uInt16 nCode
void Append(const XLineEndEntry &rEntry, const BitmapEx &rBitmap)
Definition: dlgctrl.cxx:1025
void DrawRect(const tools::Rectangle &rRect)
virtual void LoseFocus() override
Definition: dlgctrl.cxx:427
float y
virtual void ProcessDisplay(DisplayInfo &rDisplayInfo) override
const OUString & GetName() const
constexpr sal_uInt16 KEY_DOWN
const Color & GetDarkShadowColor() const
bool IsEmpty() const
RectPoint
Definition: rectenum.hxx:22
void SetLineColor()
virtual void Resize() override
Definition: dlgctrl.cxx:1383
object group
Definition: svdobj.hxx:119
sal_uInt16 ClearItem(sal_uInt16 nWhich=0)
virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override
Definition: dlgctrl.cxx:575
Point aPtMB
Definition: dlgctrl.hxx:91
void Draw(OutputDevice *pOutDev, const Point &rDestPt) const
#define DBG_ASSERT(sCon, aError)
static sal_uInt16 constexpr nSquares
Definition: dlgctrl.hxx:148
int i
void SetPathPoly(const basegfx::B2DPolyPolygon &rPathPoly)
Definition: svdopath.cxx:2738
sal_uInt16 nBorderWidth
Definition: dlgctrl.hxx:88
sal_uInt8 GetBitmapPixel(const sal_uInt16 nPixelNumber) const
Definition: dlgctrl.cxx:880
RectPoint eDefRP
Definition: dlgctrl.hxx:93
VclPtr< VirtualDevice > mpBufferDevice
Definition: dlgctrl.hxx:286
Point aPtRB
Definition: dlgctrl.hxx:91
bool SetOutputSizePixel(const Size &rNewSize, bool bErase=true)
const Color & GetColor() const
Size GetOutputSize() const
bool IsCompletelyDisabled() const
Definition: dlgctrl.hxx:136
std::unique_ptr< weld::ComboBox > m_xControl
Definition: dlgctrl.hxx:253
void SetFillColor()
const Color & GetLineColor() const
Point aPtNew
Definition: dlgctrl.hxx:92
void SetTextColor(const Color &rColor)
static bool GetLayoutRTL()
SdrObject * mpRectangleObject
Definition: dlgctrl.hxx:364
bool isHistorical8x8(const BitmapEx &rBitmapEx, Color &o_rBack, Color &o_rFront)
void LocalPrePaint(vcl::RenderContext const &rRenderContext)
Definition: dlgctrl.cxx:1312
rtl::Reference< SvxRectCtlAccessibleContext > pAccContext
Definition: dlgctrl.hxx:87
void SetAttributes(const SfxItemSet &rItemSet)
Definition: dlgctrl.cxx:1400
std::unique_ptr< weld::ComboBox > m_xControl
Definition: dlgctrl.hxx:218
void SetMergedItem(const SfxPoolItem &rItem)
Definition: svdobj.cxx:1894
::Color GetPixelColor(sal_Int32 nX, sal_Int32 nY) const
virtual bool MouseButtonDown(const MouseEvent &rMEvt) override
Definition: dlgctrl.cxx:665
Size GetOutputSizePixel() const
static SVX_DLLPRIVATE void InitSettings(vcl::RenderContext &rRenderContext)
Definition: dlgctrl.cxx:173
std::unique_ptr< BitmapEx > pBitmap
Definition: dlgctrl.hxx:94
SVX_DLLPRIVATE void Resize_Impl(const Size &rSize)
Definition: dlgctrl.cxx:102
virtual ~SvxPreviewBase() override
Definition: dlgctrl.cxx:1306
Point aPtLB
Definition: dlgctrl.hxx:91
Abstract DrawObject.
Definition: svdobj.hxx:312
RectPoint GetApproxRPFromPixPt(const css::awt::Point &rPixelPoint) const
Definition: dlgctrl.cxx:561
tools::Rectangle GetPreviewSize() const
Definition: dlgctrl.cxx:1368
Point SetActualRPWithoutInvalidate(RectPoint eNewRP)
Definition: dlgctrl.cxx:395
void SetOutputSizePixel(const Size &rSize)
void Append(const XDashEntry &rEntry, const BitmapEx &rBitmap)
Definition: dlgctrl.cxx:957
Size GetSize() const
constexpr sal_uInt16 KEY_RIGHT
void SetShadowPosition(const Point &rPos)
Definition: dlgctrl.cxx:1236
Point LogicToPixel(const Point &rLogicPt) const
void LocalPostPaint(vcl::RenderContext &rRenderContext)
Definition: dlgctrl.cxx:1339
static sal_uInt16 constexpr nLines
Definition: dlgctrl.hxx:147
const vcl::KeyCode & GetKeyCode() const
virtual void StyleUpdated() override
Definition: dlgctrl.cxx:1357
virtual ~SvxXLinePreview() override
Definition: dlgctrl.cxx:1122
Point GetApproxLogPtFromPixPt(const Point &rRoughPixelPoint) const
Definition: dlgctrl.cxx:432
bool mbCompleteDisable
Definition: dlgctrl.hxx:97
bool IsShift() const
weld::DrawingArea * GetDrawingArea() const
Graphic * mpGraphic
Definition: dlgctrl.hxx:342
void SetSymbol(Graphic *p, const Size &s)
Definition: dlgctrl.cxx:1132
ColorConfigValue GetColorValue(ColorConfigEntry eEntry, bool bSmart=true) const
virtual void Resize() override
Definition: dlgctrl.cxx:636
unsigned char sal_uInt8
virtual bool KeyInput(const KeyEvent &rKEvt) override
Definition: dlgctrl.cxx:766
void Fill(const XDashListRef &pList)
Definition: dlgctrl.cxx:910
void Reset()
Definition: dlgctrl.cxx:887
tools::Rectangle CalculateFocusRectangle() const
Definition: dlgctrl.cxx:529
const SfxItemSet & GetMergedItemSet() const
Definition: svdobj.cxx:1884
virtual int get_text_height() const =0
bool IsMod1() const
static VclPtr< reference_type > Create(Arg &&...arg)
virtual bool MouseButtonDown(const MouseEvent &) override
Definition: dlgctrl.cxx:184
virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override
Definition: dlgctrl.cxx:555
virtual void SetDrawingArea(weld::DrawingArea *) override
Definition: dlgctrl.cxx:1295
const Color & GetWindowColor() const
const Point & GetPosPixel() const
constexpr::Color COL_WHITE(0xFF, 0xFF, 0xFF)
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &) override
Definition: dlgctrl.cxx:283
virtual vcl::ImageType get_icon_size() const =0
rtl::Reference< SvxPixelCtlAccessible > m_xAccess
Definition: dlgctrl.hxx:159
void DrawCheckered(const Point &rPos, const Size &rSize, sal_uInt32 nLen=8, Color aStart=COL_WHITE, Color aEnd=COL_BLACK)
void Modify(const XDashEntry &rEntry, sal_Int32 nPos, const BitmapEx &rBitmap)
Definition: dlgctrl.cxx:974
virtual ~SvxXShadowPreview() override
Definition: dlgctrl.cxx:1218
virtual void Resize() override
Definition: dlgctrl.cxx:97
RectPoint GetRPFromPoint(Point, bool bRTL=false) const
Definition: dlgctrl.cxx:470
virtual void SetSnapRect(const tools::Rectangle &rRect)
Definition: svdobj.cxx:1622
void Fill(const XLineEndListRef &pList, bool bStart=true)
Definition: dlgctrl.cxx:998
static weld::Builder * CreateBuilder(weld::Widget *pParent, const OUString &rUIFile)
MapUnit
virtual tools::Rectangle GetFocusRect() override
Definition: dlgctrl.cxx:368
void ChangePixel(sal_uInt16 nPixel)
Definition: dlgctrl.cxx:655
SdrObject * mpRectangleObject
Definition: dlgctrl.hxx:388
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
Definition: dlgctrl.cxx:1241
constexpr sal_uInt16 KEY_LEFT
long PointToIndex(const Point &pt) const
Definition: dlgctrl.cxx:582
void ResizeSymbol(const Size &s)
Definition: dlgctrl.cxx:1138
const Size & GetSizePixel() const
const Point & GetPointFromRP(RectPoint) const
Definition: dlgctrl.cxx:378
virtual void StyleUpdated() override
Definition: dlgctrl.cxx:167
virtual void set_size_request(int nWidth, int nHeight)=0
SvxPixelCtl(SvxPixelCtl const &)=delete
void Push(PushFlags nFlags=PushFlags::ALL)
void setWidth(long nWidth)
virtual ~SvxRectCtl() override
Definition: dlgctrl.cxx:91
Point aPtRM
Definition: dlgctrl.hxx:90
SvxLineEndLB(std::unique_ptr< weld::ComboBox > pControl)
Definition: dlgctrl.cxx:993
virtual float get_approximate_digit_width() const =0
SAL_DLLPRIVATE void DrawOutDev(const Point &, const Size &, const Point &, const Size &, const Printer &)=delete
SvxLineLB(std::unique_ptr< weld::ComboBox > pControl)
Definition: dlgctrl.cxx:894
Point aPtMT
Definition: dlgctrl.hxx:89
CTL_STATE
Definition: dlgctrl.hxx:59
void InitSettings()
Definition: dlgctrl.cxx:1273
bool IsMod2() const
Point aPtMM
Definition: dlgctrl.hxx:90
void setHeight(long nHeight)