LibreOffice Module vcl (master)  1
fixed.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/cvtgrf.hxx>
21 #include <vcl/decoview.hxx>
22 #include <vcl/event.hxx>
23 #include <vcl/toolkit/fixed.hxx>
24 #include <vcl/settings.hxx>
25 
26 #include <comphelper/base64.hxx>
27 #include <comphelper/string.hxx>
28 #include <sal/log.hxx>
29 #include <tools/json_writer.hxx>
30 #include <tools/stream.hxx>
31 
32 #define FIXEDLINE_TEXT_BORDER 4
33 
34 constexpr auto FIXEDTEXT_VIEW_STYLE = WB_3DLOOK |
43  WB_SCALE;
44 constexpr auto FIXEDIMAGE_VIEW_STYLE = WB_3DLOOK |
47  WB_SCALE;
48 
49 static Point ImplCalcPos( WinBits nStyle, const Point& rPos,
50  const Size& rObjSize, const Size& rWinSize )
51 {
52  tools::Long nX;
53  tools::Long nY;
54 
55  if ( nStyle & WB_LEFT )
56  nX = 0;
57  else if ( nStyle & WB_RIGHT )
58  nX = rWinSize.Width()-rObjSize.Width();
59  else
60  nX = (rWinSize.Width()-rObjSize.Width())/2;
61 
62  if ( nStyle & WB_TOP )
63  nY = 0;
64  else if ( nStyle & WB_BOTTOM )
65  nY = rWinSize.Height()-rObjSize.Height();
66  else
67  nY = (rWinSize.Height()-rObjSize.Height())/2;
68 
69  Point aPos( nX+rPos.X(), nY+rPos.Y() );
70  return aPos;
71 }
72 
73 void FixedText::ImplInit( vcl::Window* pParent, WinBits nStyle )
74 {
75  nStyle = ImplInitStyle( nStyle );
76  Control::ImplInit( pParent, nStyle, nullptr );
78 }
79 
81 {
82  if ( !(nStyle & WB_NOGROUP) )
83  nStyle |= WB_GROUP;
84  return nStyle;
85 }
86 
87 const vcl::Font& FixedText::GetCanonicalFont( const StyleSettings& _rStyle ) const
88 {
89  return _rStyle.GetLabelFont();
90 }
91 
93 {
94  return _rStyle.GetLabelTextColor();
95 }
96 
99  , m_nMaxWidthChars(-1)
100  , m_nMinWidthChars(-1)
101  , m_pMnemonicWindow(nullptr)
102 {
103  ImplInit( pParent, nStyle );
104 }
105 
107 {
109 
110  if( ! (nWinStyle & WB_NOMULTILINE) )
111  nTextStyle |= DrawTextFlags::MultiLine;
112 
113  if ( nWinStyle & WB_RIGHT )
114  nTextStyle |= DrawTextFlags::Right;
115  else if ( nWinStyle & WB_CENTER )
116  nTextStyle |= DrawTextFlags::Center;
117  else
118  nTextStyle |= DrawTextFlags::Left;
119  if ( nWinStyle & WB_BOTTOM )
120  nTextStyle |= DrawTextFlags::Bottom;
121  else if ( nWinStyle & WB_VCENTER )
122  nTextStyle |= DrawTextFlags::VCenter;
123  else
124  nTextStyle |= DrawTextFlags::Top;
125  if ( nWinStyle & WB_WORDBREAK )
126  nTextStyle |= DrawTextFlags::WordBreak;
127  if ( nWinStyle & WB_NOLABEL )
128  nTextStyle &= ~DrawTextFlags::Mnemonic;
129 
130  return nTextStyle;
131 }
132 
133 void FixedText::ImplDraw(OutputDevice* pDev, SystemTextColorFlags nSystemTextColorFlags,
134  const Point& rPos, const Size& rSize,
135  bool bFillLayout) const
136 {
137  const StyleSettings& rStyleSettings = pDev->GetSettings().GetStyleSettings();
138  WinBits nWinStyle = GetStyle();
139  OUString aText(GetText());
140  DrawTextFlags nTextStyle = FixedText::ImplGetTextStyle( nWinStyle );
141  Point aPos = rPos;
142 
143  if ( nWinStyle & WB_EXTRAOFFSET )
144  aPos.AdjustX(2 );
145 
146  if ( nWinStyle & WB_PATHELLIPSIS )
147  {
149  nTextStyle |= DrawTextFlags::PathEllipsis;
150  }
151  if ( !IsEnabled() )
152  nTextStyle |= DrawTextFlags::Disable;
153  if ( (nSystemTextColorFlags & SystemTextColorFlags::Mono) ||
154  (rStyleSettings.GetOptions() & StyleSettingsOptions::Mono) )
155  nTextStyle |= DrawTextFlags::Mono;
156 
157  if( bFillLayout )
158  mxLayoutData->m_aDisplayText.clear();
159 
160  const tools::Rectangle aRect(aPos, rSize);
161  DrawControlText(*pDev, aRect, aText, nTextStyle,
162  bFillLayout ? &mxLayoutData->m_aUnicodeBoundRects : nullptr,
163  bFillLayout ? &mxLayoutData->m_aDisplayText : nullptr);
164 }
165 
167 {
168  Control::ApplySettings(rRenderContext);
169 
170  vcl::Window* pParent = GetParent();
171  bool bEnableTransparent = true;
173  {
176  SetPaintTransparent(false);
177 
178  if (IsControlBackground())
179  rRenderContext.SetBackground(GetControlBackground());
180  else
181  rRenderContext.SetBackground(pParent->GetBackground());
182 
183  if (rRenderContext.IsBackground())
184  bEnableTransparent = false;
185  }
186 
187  if (bEnableTransparent)
188  {
191  SetPaintTransparent(true);
192  rRenderContext.SetBackground();
193  }
194 }
195 
196 void FixedText::Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& )
197 {
199 }
200 
201 void FixedText::Draw( OutputDevice* pDev, const Point& rPos,
202  SystemTextColorFlags nFlags )
203 {
204  ApplySettings(*pDev);
205 
206  Point aPos = pDev->LogicToPixel( rPos );
207  Size aSize = GetSizePixel();
208  vcl::Font aFont = GetDrawPixelFont( pDev );
209 
210  pDev->Push();
211  pDev->SetMapMode();
212  pDev->SetFont( aFont );
213  if ( nFlags & SystemTextColorFlags::Mono )
214  pDev->SetTextColor( COL_BLACK );
215  else
216  pDev->SetTextColor( GetTextColor() );
217  pDev->SetTextFillColor();
218 
219  bool bBorder = (GetStyle() & WB_BORDER);
220  bool bBackground = IsControlBackground();
221  if ( bBorder || bBackground )
222  {
223  tools::Rectangle aRect( aPos, aSize );
224  if ( bBorder )
225  {
226  ImplDrawFrame( pDev, aRect );
227  }
228  if ( bBackground )
229  {
231  pDev->DrawRect( aRect );
232  }
233  }
234 
235  ImplDraw( pDev, nFlags, aPos, aSize );
236  pDev->Pop();
237 }
238 
240 {
241  Control::Resize();
242  Invalidate();
243 }
244 
246 {
247  Control::StateChanged( nType );
248 
249  if ( (nType == StateChangedType::Enable) ||
250  (nType == StateChangedType::Text) ||
251  (nType == StateChangedType::UpdateMode) )
252  {
253  if ( IsReallyVisible() && IsUpdateMode() )
254  Invalidate();
255  }
256  else if ( nType == StateChangedType::Style )
257  {
259  if ( (GetPrevStyle() & FIXEDTEXT_VIEW_STYLE) !=
261  {
263  Invalidate();
264  }
265  }
266  else if ( (nType == StateChangedType::Zoom) ||
267  (nType == StateChangedType::ControlFont) )
268  {
270  Invalidate();
271  }
272  else if ( nType == StateChangedType::ControlForeground )
273  {
275  Invalidate();
276  }
277  else if ( nType == StateChangedType::ControlBackground )
278  {
280  Invalidate();
281  }
282 }
283 
285 {
286  Control::DataChanged( rDCEvt );
287 
288  if ( (rDCEvt.GetType() == DataChangedEventType::FONTS) ||
290  ((rDCEvt.GetType() == DataChangedEventType::SETTINGS) &&
291  (rDCEvt.GetFlags() & AllSettingsFlags::STYLE)) )
292  {
294  Invalidate();
295  }
296 }
297 
298 Size FixedText::getTextDimensions(Control const *pControl, const OUString &rTxt, tools::Long nMaxWidth)
299 {
300  DrawTextFlags nStyle = ImplGetTextStyle( pControl->GetStyle() );
301  if ( !( pControl->GetStyle() & WB_NOLABEL ) )
302  nStyle |= DrawTextFlags::Mnemonic;
303 
304  return pControl->GetTextRect(tools::Rectangle( Point(), Size(nMaxWidth, 0x7fffffff)),
305  rTxt, nStyle).GetSize();
306 }
307 
309 {
310  Size aSize = getTextDimensions(pControl, pControl->GetText(), nMaxWidth);
311 
312  if ( pControl->GetStyle() & WB_EXTRAOFFSET )
313  aSize.AdjustWidth(2 );
314 
315  // GetTextRect cannot take an empty string
316  if ( aSize.Width() < 0 )
317  aSize.setWidth( 0 );
318  if ( aSize.Height() <= 0 )
319  aSize.setHeight( pControl->GetTextHeight() );
320 
321  return aSize;
322 }
323 
325 {
326  return CalcWindowSize( CalcMinimumTextSize ( this, nMaxWidth ) );
327 }
328 
330 {
331  sal_Int32 nMaxAvailWidth = 0x7fffffff;
332  if (m_nMaxWidthChars != -1)
333  {
334  OUStringBuffer aBuf;
336  nMaxAvailWidth = getTextDimensions(this,
337  aBuf.makeStringAndClear(), 0x7fffffff).Width();
338  }
339  Size aRet = CalcMinimumSize(nMaxAvailWidth);
340  if (m_nMinWidthChars != -1)
341  {
342  OUStringBuffer aBuf;
344  Size aMinAllowed = getTextDimensions(this,
345  aBuf.makeStringAndClear(), 0x7fffffff);
346  aRet.setWidth(std::max(aMinAllowed.Width(), aRet.Width()));
347  }
348  return aRet;
349 }
350 
352 {
353  mxLayoutData.emplace();
354  ImplDraw(const_cast<FixedText*>(this)->GetOutDev(), SystemTextColorFlags::NONE, Point(), GetOutputSizePixel(), true);
355  //const_cast<FixedText*>(this)->Invalidate();
356 }
357 
358 void FixedText::setMaxWidthChars(sal_Int32 nWidth)
359 {
360  if (nWidth != m_nMaxWidthChars)
361  {
362  m_nMaxWidthChars = nWidth;
363  queue_resize();
364  }
365 }
366 
367 void FixedText::setMinWidthChars(sal_Int32 nWidth)
368 {
369  if (nWidth != m_nMinWidthChars)
370  {
371  m_nMinWidthChars = nWidth;
372  queue_resize();
373  }
374 }
375 
376 bool FixedText::set_property(const OString &rKey, const OUString &rValue)
377 {
378  if (rKey == "max-width-chars")
379  setMaxWidthChars(rValue.toInt32());
380  else if (rKey == "width-chars")
381  setMinWidthChars(rValue.toInt32());
382  else if (rKey == "ellipsize")
383  {
384  WinBits nBits = GetStyle();
385  nBits &= ~WB_PATHELLIPSIS;
386  if (rValue != "none")
387  {
388  SAL_WARN_IF(rValue != "end", "vcl.layout", "Only endellipsis support for now");
389  nBits |= WB_PATHELLIPSIS;
390  }
391  SetStyle(nBits);
392  }
393  else
394  return Control::set_property(rKey, rValue);
395  return true;
396 }
397 
399 {
401  if (pWindow)
402  return pWindow;
403  return get_mnemonic_widget();
404 }
405 
407 {
408  if (pWindow == m_pMnemonicWindow)
409  return;
410  if (m_pMnemonicWindow)
411  {
412  vcl::Window *pTempReEntryGuard = m_pMnemonicWindow;
413  m_pMnemonicWindow = nullptr;
414  pTempReEntryGuard->remove_mnemonic_label(this);
415  }
416  m_pMnemonicWindow = pWindow;
417  if (m_pMnemonicWindow)
419 }
420 
422 {
423  disposeOnce();
424 }
425 
427 {
428  set_mnemonic_widget(nullptr);
431 }
432 
434  : Edit(pParent, nStyle)
435 {
436  // no border
438  // read-only
439  SetReadOnly();
440  // make it transparent
441  SetPaintTransparent(true);
443 }
444 
446 {
447  rRenderContext.SetBackground();
448 }
449 
451 {
452  Edit::LoseFocus();
453  // clear cursor
454  Invalidate();
455 }
456 
457 void FixedLine::ImplInit( vcl::Window* pParent, WinBits nStyle )
458 {
459  nStyle = ImplInitStyle( nStyle );
460  Control::ImplInit( pParent, nStyle, nullptr );
462 }
463 
465 {
466  if ( !(nStyle & WB_NOGROUP) )
467  nStyle |= WB_GROUP;
468  return nStyle;
469 }
470 
472 {
473  return _rStyle.GetGroupFont();
474 }
475 
477 {
478  return _rStyle.GetGroupTextColor();
479 }
480 
482 {
483  // we need to measure according to the window, not according to the
484  // RenderContext we paint to
485  Size aOutSize = GetOutputSizePixel();
486 
487  OUString aText = GetText();
488  WinBits nWinStyle = GetStyle();
489 
490  DecorationView aDecoView(&rRenderContext);
491  if (aText.isEmpty())
492  {
493  if (nWinStyle & WB_VERT)
494  {
495  tools::Long nX = (aOutSize.Width() - 1) / 2;
496  aDecoView.DrawSeparator(Point(nX, 0), Point(nX, aOutSize.Height() - 1));
497  }
498  else
499  {
500  tools::Long nY = (aOutSize.Height() - 1) / 2;
501  aDecoView.DrawSeparator(Point(0, nY), Point(aOutSize.Width() - 1, nY), false);
502  }
503  }
504  else if (nWinStyle & WB_VERT)
505  {
506  tools::Long nWidth = rRenderContext.GetTextWidth(aText);
507  rRenderContext.Push(PushFlags::FONT);
508  vcl::Font aFont(rRenderContext.GetFont());
509  aFont.SetOrientation(900_deg10);
510  SetFont(aFont);
511  Point aStartPt(aOutSize.Width() / 2, aOutSize.Height() - 1);
512  if (nWinStyle & WB_VCENTER)
513  aStartPt.AdjustY( -((aOutSize.Height() - nWidth) / 2) );
514  Point aTextPt(aStartPt);
515  aTextPt.AdjustX( -(GetTextHeight() / 2) );
516  rRenderContext.DrawText(aTextPt, aText, 0, aText.getLength());
517  rRenderContext.Pop();
518  if (aOutSize.Height() - aStartPt.Y() > FIXEDLINE_TEXT_BORDER)
519  aDecoView.DrawSeparator(Point(aStartPt.X(), aStartPt.Y() + FIXEDLINE_TEXT_BORDER),
520  Point(aStartPt.X(), aOutSize.Height() - 1));
521  if (aStartPt.Y() - nWidth - FIXEDLINE_TEXT_BORDER > 0)
522  aDecoView.DrawSeparator(Point(aStartPt.X(), 0),
523  Point(aStartPt.X(), aStartPt.Y() - nWidth - FIXEDLINE_TEXT_BORDER));
524  }
525  else
526  {
528  tools::Rectangle aRect(0, 0, aOutSize.Width(), aOutSize.Height());
529  const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
530  if (nWinStyle & WB_CENTER)
531  nStyle |= DrawTextFlags::Center;
532 
533  if (!IsEnabled())
534  nStyle |= DrawTextFlags::Disable;
535  if (GetStyle() & WB_NOLABEL)
536  nStyle &= ~DrawTextFlags::Mnemonic;
537  if (rStyleSettings.GetOptions() & StyleSettingsOptions::Mono)
538  nStyle |= DrawTextFlags::Mono;
539 
540  aRect = DrawControlText(*GetOutDev(), aRect, aText, nStyle, nullptr, nullptr);
541 
542  tools::Long nTop = aRect.Top() + ((aRect.GetHeight() - 1) / 2);
543  aDecoView.DrawSeparator(Point(aRect.Right() + FIXEDLINE_TEXT_BORDER, nTop), Point(aOutSize.Width() - 1, nTop), false);
544  if (aRect.Left() > FIXEDLINE_TEXT_BORDER)
545  aDecoView.DrawSeparator(Point(0, nTop), Point(aRect.Left() - FIXEDLINE_TEXT_BORDER, nTop), false);
546  }
547 }
548 
551 {
552  ImplInit( pParent, nStyle );
553  SetSizePixel( Size( 2, 2 ) );
554 }
555 
557 {
558  mxLayoutData.emplace();
559  const_cast<FixedLine*>(this)->Invalidate();
560 }
561 
563 {
564  Control::ApplySettings(rRenderContext);
565 
566  vcl::Window* pParent = GetParent();
568  {
571  SetPaintTransparent(true);
572  rRenderContext.SetBackground();
573  }
574  else
575  {
578  SetPaintTransparent(false);
579 
580  if (IsControlBackground())
581  rRenderContext.SetBackground(GetControlBackground());
582  else
583  rRenderContext.SetBackground(pParent->GetBackground());
584  }
585 }
586 
588 {
589  ImplDraw(rRenderContext);
590 }
591 
593 {
594 }
595 
597 {
598  Control::Resize();
599  Invalidate();
600 }
601 
603 {
604  Control::StateChanged( nType );
605 
606  if ( (nType == StateChangedType::Enable) ||
607  (nType == StateChangedType::Text) ||
608  (nType == StateChangedType::UpdateMode) )
609  {
610  if ( IsReallyVisible() && IsUpdateMode() )
611  Invalidate();
612  }
613  else if ( nType == StateChangedType::Style )
614  {
616  if ( (GetPrevStyle() & FIXEDLINE_VIEW_STYLE) !=
618  Invalidate();
619  }
620  else if ( (nType == StateChangedType::Zoom) ||
621  (nType == StateChangedType::Style) ||
622  (nType == StateChangedType::ControlFont) )
623  {
625  Invalidate();
626  }
627  else if ( nType == StateChangedType::ControlForeground )
628  {
630  Invalidate();
631  }
632  else if ( nType == StateChangedType::ControlBackground )
633  {
635  Invalidate();
636  }
637 }
638 
640 {
641  Control::DataChanged( rDCEvt );
642 
643  if ( (rDCEvt.GetType() == DataChangedEventType::FONTS) ||
645  ((rDCEvt.GetType() == DataChangedEventType::SETTINGS) &&
646  (rDCEvt.GetFlags() & AllSettingsFlags::STYLE)) )
647  {
649  Invalidate();
650  }
651 }
652 
654 {
656 }
657 
659 {
660  Control::DumpAsPropertyTree(rJsonWriter);
661  rJsonWriter.put("type", "separator");
662  rJsonWriter.put("orientation", (GetStyle() & WB_VERT) ? "vertical" : "horizontal");
663 }
664 
665 void FixedBitmap::ImplInit( vcl::Window* pParent, WinBits nStyle )
666 {
667  nStyle = ImplInitStyle( nStyle );
668  Control::ImplInit( pParent, nStyle, nullptr );
670 }
671 
673 {
674  if ( !(nStyle & WB_NOGROUP) )
675  nStyle |= WB_GROUP;
676  return nStyle;
677 }
678 
681 {
682  ImplInit( pParent, nStyle );
683 }
684 
685 void FixedBitmap::ImplDraw( OutputDevice* pDev, const Point& rPos, const Size& rSize )
686 {
687  // do we have a Bitmap?
688  if ( !maBitmap.IsEmpty() )
689  {
690  if ( GetStyle() & WB_SCALE )
691  pDev->DrawBitmapEx( rPos, rSize, maBitmap );
692  else
693  {
694  Point aPos = ImplCalcPos( GetStyle(), rPos, maBitmap.GetSizePixel(), rSize );
695  pDev->DrawBitmapEx( aPos, maBitmap );
696  }
697  }
698 }
699 
701 {
702  vcl::Window* pParent = GetParent();
704  {
707  SetPaintTransparent(true);
708  rRenderContext.SetBackground();
709  }
710  else
711  {
714  SetPaintTransparent(false);
715 
716  if (IsControlBackground())
717  rRenderContext.SetBackground(GetControlBackground());
718  else
719  rRenderContext.SetBackground(pParent->GetBackground());
720  }
721 }
722 
724 {
725  ImplDraw(&rRenderContext, Point(), GetOutputSizePixel());
726 }
727 
728 void FixedBitmap::Draw( OutputDevice* pDev, const Point& rPos,
730 {
731  Point aPos = pDev->LogicToPixel( rPos );
732  Size aSize = GetSizePixel();
733  tools::Rectangle aRect( aPos, aSize );
734 
735  pDev->Push();
736  pDev->SetMapMode();
737 
738  // Border
739  if ( GetStyle() & WB_BORDER )
740  {
741  DecorationView aDecoView( pDev );
742  aRect = aDecoView.DrawFrame( aRect, DrawFrameStyle::DoubleIn );
743  }
744  pDev->IntersectClipRegion( aRect );
745  ImplDraw( pDev, aRect.TopLeft(), aRect.GetSize() );
746 
747  pDev->Pop();
748 }
749 
751 {
752  Control::Resize();
753  Invalidate();
754 }
755 
757 {
758  Control::StateChanged( nType );
759 
760  if ( (nType == StateChangedType::Data) ||
761  (nType == StateChangedType::UpdateMode) )
762  {
763  if ( IsReallyVisible() && IsUpdateMode() )
764  Invalidate();
765  }
766  else if ( nType == StateChangedType::Style )
767  {
771  Invalidate();
772  }
773  else if ( nType == StateChangedType::ControlBackground )
774  {
776  Invalidate();
777  }
778 }
779 
781 {
782  Control::DataChanged( rDCEvt );
783 
784  if ( (rDCEvt.GetType() == DataChangedEventType::SETTINGS) &&
785  (rDCEvt.GetFlags() & AllSettingsFlags::STYLE) )
786  {
788  Invalidate();
789  }
790 }
791 
792 void FixedBitmap::SetBitmap( const BitmapEx& rBitmap )
793 {
794  maBitmap = rBitmap;
796  queue_resize();
797 }
798 
799 void FixedImage::ImplInit( vcl::Window* pParent, WinBits nStyle )
800 {
801  nStyle = ImplInitStyle( nStyle );
802  Control::ImplInit( pParent, nStyle, nullptr );
804 }
805 
807 {
808  if ( !(nStyle & WB_NOGROUP) )
809  nStyle |= WB_GROUP;
810  return nStyle;
811 }
812 
815 {
816  ImplInit( pParent, nStyle );
817 }
818 
820  const Point& rPos, const Size& rSize )
821 {
823  if ( !IsEnabled() )
824  nStyle |= DrawImageFlags::Disable;
825 
826  Image *pImage = &maImage;
827 
828  // do we have an image?
829  if ( !(!(*pImage)) )
830  {
831  if ( GetStyle() & WB_SCALE )
832  pDev->DrawImage( rPos, rSize, *pImage, nStyle );
833  else
834  {
835  Point aPos = ImplCalcPos( GetStyle(), rPos, pImage->GetSizePixel(), rSize );
836  pDev->DrawImage( aPos, *pImage, nStyle );
837  }
838  }
839 }
840 
842 {
843  vcl::Window* pParent = GetParent();
844  if (pParent && pParent->IsChildTransparentModeEnabled() && !IsControlBackground())
845  {
848  SetPaintTransparent(true);
849  rRenderContext.SetBackground();
850  }
851  else
852  {
855  SetPaintTransparent(false);
856 
857  if (IsControlBackground())
858  rRenderContext.SetBackground(GetControlBackground());
859  else if (pParent)
860  rRenderContext.SetBackground(pParent->GetBackground());
861  }
862 }
863 
864 
866 {
867  ImplDraw(&rRenderContext, Point(), GetOutputSizePixel());
868 }
869 
871 {
872  return maImage.GetSizePixel();
873 }
874 
875 void FixedImage::Draw( OutputDevice* pDev, const Point& rPos,
877 {
878  Point aPos = pDev->LogicToPixel( rPos );
879  Size aSize = GetSizePixel();
880  tools::Rectangle aRect( aPos, aSize );
881 
882  pDev->Push();
883  pDev->SetMapMode();
884 
885  // Border
886  if ( GetStyle() & WB_BORDER )
887  {
888  ImplDrawFrame( pDev, aRect );
889  }
890  pDev->IntersectClipRegion( aRect );
891  ImplDraw( pDev, aRect.TopLeft(), aRect.GetSize() );
892 
893  pDev->Pop();
894 }
895 
897 {
898  Control::Resize();
899  Invalidate();
900 }
901 
903 {
904  Control::StateChanged( nType );
905 
906  if ( (nType == StateChangedType::Enable) ||
907  (nType == StateChangedType::Data) ||
908  (nType == StateChangedType::UpdateMode) )
909  {
910  if ( IsReallyVisible() && IsUpdateMode() )
911  Invalidate();
912  }
913  else if ( nType == StateChangedType::Style )
914  {
916  if ( (GetPrevStyle() & FIXEDIMAGE_VIEW_STYLE) !=
918  Invalidate();
919  }
920  else if ( nType == StateChangedType::ControlBackground )
921  {
923  Invalidate();
924  }
925 }
926 
928 {
929  Control::DataChanged( rDCEvt );
930 
931  if ( (rDCEvt.GetType() == DataChangedEventType::SETTINGS) &&
932  (rDCEvt.GetFlags() & AllSettingsFlags::STYLE) )
933  {
935  Invalidate();
936  }
937 }
938 
939 void FixedImage::SetImage( const Image& rImage )
940 {
941  if ( rImage != maImage )
942  {
943  maImage = rImage;
945  queue_resize();
946  }
947 }
948 
949 Image FixedImage::loadThemeImage(const OUString &rFileName)
950 {
951  return Image(StockImage::Yes, rFileName);
952 }
953 
954 bool FixedImage::set_property(const OString &rKey, const OUString &rValue)
955 {
956  if (rKey == "icon-size")
957  {
958  WinBits nBits = GetStyle();
959  nBits &= ~WB_SMALLSTYLE;
960  if (rValue == "2")
961  nBits |= WB_SMALLSTYLE;
962  SetStyle(nBits);
963  }
964  else
965  return Control::set_property(rKey, rValue);
966  return true;
967 }
968 
970 {
971  rJsonWriter.put("id", get_id());
972  rJsonWriter.put("type", "image");
973  if (!!maImage)
974  {
975  SvMemoryStream aOStm(6535, 6535);
977  {
978  css::uno::Sequence<sal_Int8> aSeq( static_cast<sal_Int8 const *>(aOStm.GetData()), aOStm.Tell());
979  OUStringBuffer aBuffer("data:image/png;base64,");
981  rJsonWriter.put("image", aBuffer.makeStringAndClear());
982  }
983  }
984 }
985 
986 
987 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual const Color & GetCanonicalTextColor(const StyleSettings &_rStyle) const override
Definition: fixed.cxx:92
tools::Long GetTextHeight() const
Height where any character of the current font fits; in logic coordinates.
Definition: window3.cxx:65
Size GetSizePixel() const
Definition: Image.cxx:86
bool IsControlBackground() const
Definition: window2.cxx:1081
void set_mnemonic_widget(vcl::Window *pWindow)
Definition: fixed.cxx:406
void remove_mnemonic_label(FixedText *pLabel)
Definition: window2.cxx:1974
static Image loadThemeImage(const OUString &rFileName)
Definition: fixed.cxx:949
WinBits const WB_NOLABEL
void DrawImage(const Point &rPos, const Image &rImage, DrawImageFlags nStyle=DrawImageFlags::NONE)
This is an overloaded member function, provided for convenience. It differs from the above function o...
virtual void Draw(OutputDevice *pDev, const Point &rPos, SystemTextColorFlags nFlags) override
Definition: fixed.cxx:592
void setWidth(tools::Long nWidth)
std::optional< vcl::ControlLayoutData > mxLayoutData
Definition: ctrl.hxx:84
SAL_DLLPRIVATE void ImplDrawFrame(OutputDevice *pDev, tools::Rectangle &rRect)
draws a frame around the give rectangle, onto the given device
Definition: ctrl.cxx:330
void DumpAsPropertyTree(tools::JsonWriter &rJsonWriter) override
Dumps itself and potentially its children to a property tree, to be written easily to JSON...
Definition: fixed.cxx:969
void DrawBitmapEx(const Point &rDestPt, const BitmapEx &rBitmapEx)
This is an overloaded member function, provided for convenience. It differs from the above function o...
Definition: bitmapex.cxx:33
static SAL_DLLPRIVATE WinBits ImplInitStyle(WinBits nStyle)
Definition: fixed.cxx:464
WinBits const WB_NOGROUP
bool IsBackground() const
Definition: outdev.hxx:523
constexpr auto FIXEDIMAGE_VIEW_STYLE
Definition: fixed.cxx:44
long Long
FixedLine(vcl::Window *pParent, WinBits nStyle=WB_HORZ)
Definition: fixed.cxx:549
const StyleSettings & GetStyleSettings() const
virtual void ApplySettings(vcl::RenderContext &) override
Definition: fixed.cxx:562
virtual void Resize() override
Definition: fixed.cxx:750
virtual void StateChanged(StateChangedType nStateChange) override
Definition: ctrl.cxx:255
void DrawFrame(const tools::Rectangle &rRect, const Color &rLeftTopColor, const Color &rRightBottomColor)
Definition: decoview.cxx:824
SAL_DLLPRIVATE void ImplDraw(OutputDevice *pDev, const Point &rPos, const Size &rSize)
Definition: fixed.cxx:685
const Color & GetGroupTextColor() const
virtual Size GetSizePixel() const
Definition: window.cxx:2392
virtual void SetSizePixel(const Size &rNewSize)
Definition: window2.cxx:1256
WinBits const WB_RIGHT
virtual void DataChanged(const DataChangedEvent &rDCEvt) override
Definition: fixed.cxx:639
aBuf
SAL_DLLPRIVATE void CompatStateChanged(StateChangedType nStateChange)
Definition: window.cxx:3881
void SetBitmap(const BitmapEx &rBitmap)
Definition: fixed.cxx:792
void SetTextFillColor()
Definition: text.cxx:704
void SetParentClipMode(ParentClipMode nMode=ParentClipMode::NONE)
WinBits GetPrevStyle() const
Definition: window2.cxx:952
virtual bool set_property(const OString &rKey, const OUString &rValue) override
Definition: fixed.cxx:954
DataChangedEventType GetType() const
Definition: event.hxx:362
static SAL_DLLPRIVATE WinBits ImplInitStyle(WinBits nStyle)
Definition: fixed.cxx:80
void IntersectClipRegion(const tools::Rectangle &rRect)
FixedText(vcl::Window *pParent, WinBits nStyle=0)
Definition: fixed.cxx:97
const Color & GetLabelTextColor() const
virtual void StateChanged(StateChangedType nType) override
Definition: fixed.cxx:756
tools::Rectangle DrawControlText(OutputDevice &_rTargetDevice, const tools::Rectangle &_rRect, const OUString &_rStr, DrawTextFlags _nStyle, std::vector< tools::Rectangle > *_pVector, OUString *_pDisplayText, const Size *i_pDeviceSize=nullptr) const
draws the given text onto the given device
Definition: ctrl.cxx:427
const Color & GetControlBackground() const
Definition: window2.cxx:1076
virtual void StateChanged(StateChangedType nType) override
Definition: fixed.cxx:602
virtual void ApplySettings(vcl::RenderContext &rRenderContext) override
Definition: ctrl.cxx:412
void SetMapMode()
Definition: map.cxx:592
DrawTextFlags
StateChangedType
Definition: window.hxx:289
constexpr tools::Long Width() const
WinBits const WB_SCALE
sal_Int64 WinBits
virtual Size GetOptimalSize() const override
Definition: fixed.cxx:870
void SetBackground()
Definition: background.cxx:27
const OUString & get_id() const
Get the ID of the window.
Definition: window.cxx:3918
WinBits const WB_BOTTOM
WinBits const WB_TOP
virtual void DumpAsPropertyTree(tools::JsonWriter &)
Dumps itself and potentially its children to a property tree, to be written easily to JSON...
Definition: window.cxx:3348
const vcl::Font & GetLabelFont() const
const vcl::Font & GetFont() const
Definition: outdev.hxx:526
WinBits const WB_VERT
virtual void StateChanged(StateChangedType nType) override
Definition: fixed.cxx:902
DrawImageFlags
virtual Size GetOptimalSize() const override
Definition: fixed.cxx:329
AllSettingsFlags GetFlags() const
Definition: event.hxx:363
static SAL_DLLPRIVATE WinBits ImplInitStyle(WinBits nStyle)
Definition: fixed.cxx:806
virtual void Draw(OutputDevice *pDev, const Point &rPos, SystemTextColorFlags nFlags) override
Definition: fixed.cxx:875
virtual const Color & GetCanonicalTextColor(const StyleSettings &_rStyle) const override
Definition: fixed.cxx:476
SystemTextColorFlags
virtual void queue_resize(StateChangedType eReason=StateChangedType::Layout)
Definition: window2.cxx:1321
void Pop()
Definition: stack.cxx:93
BitmapEx maBitmap
Definition: fixed.hxx:121
void SetBorderStyle(WindowBorderStyle nBorderStyle)
Definition: window.cxx:1984
const sal_Int16 FIXEDLINE
virtual OUString GetText() const
Definition: window.cxx:3045
virtual const vcl::Font & GetCanonicalFont(const StyleSettings &_rStyle) const override
Definition: fixed.cxx:471
SAL_DLLPRIVATE void ImplDraw(OutputDevice *pDev, const Point &rPos, const Size &rSize)
Definition: fixed.cxx:819
static void encode(OUStringBuffer &aStrBuffer, const css::uno::Sequence< sal_Int8 > &aPass)
virtual void ApplySettings(vcl::RenderContext &rRenderContext) override
Definition: fixed.cxx:166
Definition: edit.hxx:55
virtual void StateChanged(StateChangedType nType) override
Definition: fixed.cxx:245
virtual void DataChanged(const DataChangedEvent &rDCEvt) override
Definition: fixed.cxx:780
SAL_DLLPRIVATE void ImplInit(vcl::Window *pParent, WinBits nStyle)
Definition: fixed.cxx:73
bool IsChildTransparentModeEnabled() const
Definition: window2.cxx:1021
void DrawRect(const tools::Rectangle &rRect)
Definition: rect.cxx:51
#define FIXEDLINE_TEXT_BORDER
Definition: fixed.cxx:32
sal_Int32 m_nMinWidthChars
Definition: fixed.hxx:35
virtual void Resize() override
Definition: fixed.cxx:596
static Size getTextDimensions(Control const *pControl, const OUString &rTxt, tools::Long nMaxWidth)
Definition: fixed.cxx:298
bool IsEmpty() const
Definition: BitmapEx.cxx:177
Size CalcWindowSize(const Size &rOutSz) const
Definition: window2.cxx:531
constexpr auto FIXEDTEXT_VIEW_STYLE
Definition: fixed.cxx:34
void clear()
Definition: vclptr.hxx:190
virtual void DataChanged(const DataChangedEvent &rDCEvt) override
Definition: fixed.cxx:284
constexpr auto FIXEDBITMAP_VIEW_STYLE
Definition: fixed.cxx:40
const vcl::Font & GetGroupFont() const
tools::Long GetTextWidth(const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, vcl::text::TextLayoutCache const *=nullptr, SalLayoutGlyphs const *const pLayoutCache=nullptr) const
Width of the text.
Definition: text.cxx:861
void add_mnemonic_label(FixedText *pLabel)
Definition: window2.cxx:1965
virtual vcl::Window * getAccessibleRelationLabelFor() const
void setMaxWidthChars(sal_Int32 nWidth)
Definition: fixed.cxx:358
void SetControlBackground()
Definition: window2.cxx:491
void SetOrientation(Degree10 nLineOrientation)
Definition: font/font.cxx:202
virtual void SetReadOnly(bool bReadOnly=true)
Definition: edit.cxx:2349
virtual void ApplySettings(vcl::RenderContext &) override
Definition: fixed.cxx:700
WinBits const WB_VCENTER
virtual void Invalidate(InvalidateFlags nFlags=InvalidateFlags::NONE)
Definition: paint.cxx:1164
bool IsUpdateMode() const
Definition: window2.cxx:1167
void SetFillColor()
Definition: fill.cxx:29
Some things multiple-inherit from VclAbstractDialog and OutputDevice, so we need to use virtual inher...
Definition: outdev.hxx:168
virtual void ApplySettings(vcl::RenderContext &) override
Definition: fixed.cxx:445
void SetTextColor(const Color &rColor)
Definition: text.cxx:686
WinBits const WB_SMALLSTYLE
VclPtr< vcl::Window > m_pMnemonicWindow
Definition: fixed.hxx:36
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects...
Definition: ctrl.cxx:57
virtual void Draw(OutputDevice *pDev, const Point &rPos, SystemTextColorFlags nFlags) override
Definition: fixed.cxx:728
const AllSettings & GetSettings() const
Definition: outdev.hxx:288
void SetPaintTransparent(bool bTransparent)
Definition: paint.cxx:1046
void SetImage(const Image &rImage)
Definition: fixed.cxx:939
virtual bool set_property(const OString &rKey, const OUString &rValue)
Definition: window2.cxx:1439
vcl::Window * GetParent() const
Definition: window2.cxx:1091
WinBits const WB_PATHELLIPSIS
WinBits const WB_LEFT
void SetStyle(WinBits nStyle)
Definition: window.cxx:1952
void DrawSeparator(const Point &rStart, const Point &rStop, bool bVertical=true)
Definition: decoview.cxx:997
void put(const char *pPropName, const OUString &rPropValue)
static Size CalcMinimumTextSize(Control const *pControl, tools::Long nMaxWidth=0x7fffffff)
Definition: fixed.cxx:308
constexpr Point TopLeft() const
StyleSettingsOptions GetOptions() const
SAL_DLLPRIVATE void ImplInit(vcl::Window *pParent, WinBits nStyle)
Definition: fixed.cxx:799
SAL_WARN_UNUSED_RESULT Point LogicToPixel(const Point &rLogicPt) const
Definition: map.cxx:876
SAL_DLLPRIVATE void ImplDraw(OutputDevice *pDev, SystemTextColorFlags nSystemTextColorFlags, const Point &rPos, const Size &rSize, bool bFillLayout=false) const
Definition: fixed.cxx:133
SelectableFixedText(vcl::Window *pParent, WinBits nStyle)
Definition: fixed.cxx:433
SAL_DLLPRIVATE void ImplInit(vcl::Window *pParent, WinBits nStyle, SystemParentData *pSystemParentData)
Definition: window.cxx:935
WinBits const WB_3DLOOK
constexpr auto FIXEDLINE_VIEW_STYLE
Definition: fixed.cxx:39
static ErrCode Export(SvStream &rOStm, const Graphic &rGraphic, ConvertDataFormat nFormat)
Definition: cvtgrf.cxx:55
constexpr Size GetSize() const
std::unique_ptr< char[]> aBuffer
FixedBitmap(vcl::Window *pParent, WinBits nStyle=0)
Definition: fixed.cxx:679
static SAL_DLLPRIVATE DrawTextFlags ImplGetTextStyle(WinBits nWinBits)
Definition: fixed.cxx:106
virtual void Resize() override
Definition: ctrl.cxx:73
sal_Int32 m_nMaxWidthChars
Definition: fixed.hxx:34
WindowType
Definition: ctrl.hxx:81
virtual void DumpAsPropertyTree(tools::JsonWriter &rJsonWriter) override
Dumps itself and potentially its children to a property tree, to be written easily to JSON...
Definition: fixed.cxx:658
#define SAL_WARN_IF(condition, area, stream)
#define ERRCODE_NONE
Definition: errcode.hxx:196
constexpr tools::Long Height() const
SAL_DLLPRIVATE void ImplInit(vcl::Window *pParent, WinBits nStyle)
Definition: fixed.cxx:665
WinBits const WB_BORDER
void SetFont(const vcl::Font &rNewFont)
Definition: outdev/font.cxx:52
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
Definition: fixed.cxx:865
virtual vcl::Window * getAccessibleRelationLabelFor() const override
Definition: fixed.cxx:398
virtual void LoseFocus() override
Definition: fixed.cxx:450
vcl::Font GetDrawPixelFont(::OutputDevice const *pDev) const
Definition: window2.cxx:547
::OutputDevice const * GetOutDev() const
Definition: window.cxx:565
void EnableChildTransparentMode(bool bEnable=true)
Definition: window2.cxx:1016
SAL_DLLPRIVATE void ImplInit(vcl::Window *pParent, WinBits nStyle)
Definition: fixed.cxx:457
tools::Long AdjustWidth(tools::Long n)
Definition: image.hxx:39
tools::Rectangle GetTextRect(const tools::Rectangle &rRect, const OUString &rStr, DrawTextFlags nStyle=DrawTextFlags::WordBreak, TextRectInfo *pInfo=nullptr, const vcl::ITextLayout *_pTextLayout=nullptr) const
Definition: window3.cxx:201
const Color & GetTextColor() const
Definition: window3.cxx:109
sal_uInt64 Tell() const
vcl::Window * get_mnemonic_widget() const
Definition: fixed.hxx:76
const ::std::vector< Color > ImpSvNumberformatScan::StandardColor COL_BLACK
Sequence< sal_Int8 > aSeq
virtual Size GetOptimalSize() const override
Definition: fixed.cxx:653
WinBits const WB_NOMULTILINE
static Point ImplCalcPos(WinBits nStyle, const Point &rPos, const Size &rObjSize, const Size &rWinSize)
Definition: fixed.cxx:49
BitmapEx GetBitmapEx() const
Definition: Image.cxx:94
Size GetOutputSizePixel() const
Definition: window3.cxx:89
void setHeight(tools::Long nHeight)
WinBits const WB_CENTER
bool IsEnabled() const
Definition: window2.cxx:1116
virtual void FillLayoutData() const override
Definition: fixed.cxx:556
virtual void ApplySettings(vcl::RenderContext &) override
Definition: fixed.cxx:841
virtual void DataChanged(const DataChangedEvent &rDCEvt) override
Definition: fixed.cxx:927
WinBits GetStyle() const
Definition: window2.cxx:947
SAL_DLLPRIVATE void ImplDraw(vcl::RenderContext &rRenderContext)
Definition: fixed.cxx:481
static SAL_DLLPRIVATE WinBits ImplInitStyle(WinBits nStyle)
Definition: fixed.cxx:672
void SetFont(const vcl::Font &rNewFont)
Definition: window3.cxx:59
virtual void Resize() override
Definition: fixed.cxx:239
virtual void LoseFocus() override
Definition: edit.cxx:1900
WinBits const WB_GROUP
virtual void Draw(OutputDevice *pDev, const Point &rPos, SystemTextColorFlags nFlags) override
Definition: fixed.cxx:201
Size CalcMinimumSize(tools::Long nMaxWidth=0x7fffffff) const
Definition: fixed.cxx:324
bool IsReallyVisible() const
Definition: window2.cxx:1101
const Size & GetSizePixel() const
Definition: bitmapex.hxx:73
void setMinWidthChars(sal_Int32 nWidth)
Definition: fixed.cxx:367
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
Definition: fixed.cxx:723
virtual const vcl::Font & GetCanonicalFont(const StyleSettings &_rStyle) const override
Definition: fixed.cxx:87
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects...
Definition: fixed.cxx:426
const Wallpaper & GetBackground() const
Definition: window3.cxx:63
virtual bool set_property(const OString &rKey, const OUString &rValue) override
Definition: fixed.cxx:376
WinBits const WB_EXTRAOFFSET
void Push(PushFlags nFlags=PushFlags::ALL)
Definition: stack.cxx:34
WinBits const WB_WORDBREAK
void DrawText(const Point &rStartPt, const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, std::vector< tools::Rectangle > *pVector=nullptr, OUString *pDisplayText=nullptr, const SalLayoutGlyphs *pLayoutCache=nullptr)
Definition: text.cxx:772
virtual ~FixedText() override
Definition: fixed.cxx:421
virtual void Resize() override
Definition: fixed.cxx:896
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
Definition: fixed.cxx:587
FixedImage(vcl::Window *pParent, WinBits nStyle=0)
Definition: fixed.cxx:813
virtual void DataChanged(const DataChangedEvent &rDCEvt)
Definition: event.cxx:36
const void * GetData()
Image maImage
Definition: fixed.hxx:146
virtual void FillLayoutData() const override
Definition: fixed.cxx:351
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
Definition: fixed.cxx:196
OStringBuffer & padToLength(OStringBuffer &rBuffer, sal_Int32 nLength, char cFill= '\0')