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