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  {
125  nTextStyle |= DrawTextFlags::WordBreak;
126  if ( (nWinStyle & WB_HYPHENATION ) == WB_HYPHENATION )
128  }
129  if ( nWinStyle & WB_NOLABEL )
130  nTextStyle &= ~DrawTextFlags::Mnemonic;
131 
132  return nTextStyle;
133 }
134 
136  const Point& rPos, const Size& rSize,
137  bool bFillLayout) const
138 {
139  const StyleSettings& rStyleSettings = pDev->GetSettings().GetStyleSettings();
140  WinBits nWinStyle = GetStyle();
141  OUString aText(GetText());
142  DrawTextFlags nTextStyle = FixedText::ImplGetTextStyle( nWinStyle );
143  Point aPos = rPos;
144 
145  if ( nWinStyle & WB_EXTRAOFFSET )
146  aPos.AdjustX(2 );
147 
148  if ( nWinStyle & WB_PATHELLIPSIS )
149  {
151  nTextStyle |= DrawTextFlags::PathEllipsis;
152  }
153  if ( !IsEnabled() )
154  nTextStyle |= DrawTextFlags::Disable;
155  if ( (nDrawFlags & DrawFlags::Mono) ||
156  (rStyleSettings.GetOptions() & StyleSettingsOptions::Mono) )
157  nTextStyle |= DrawTextFlags::Mono;
158 
159  if( bFillLayout )
160  mpControlData->mpLayoutData->m_aDisplayText.clear();
161 
162  const tools::Rectangle aRect(aPos, rSize);
163  DrawControlText(*pDev, aRect, aText, nTextStyle,
164  bFillLayout ? &mpControlData->mpLayoutData->m_aUnicodeBoundRects : nullptr,
165  bFillLayout ? &mpControlData->mpLayoutData->m_aDisplayText : nullptr);
166 }
167 
169 {
170  Control::ApplySettings(rRenderContext);
171 
172  vcl::Window* pParent = GetParent();
173  bool bEnableTransparent = true;
175  {
178  SetPaintTransparent(false);
179 
180  if (IsControlBackground())
181  rRenderContext.SetBackground(GetControlBackground());
182  else
183  rRenderContext.SetBackground(pParent->GetBackground());
184 
185  if (rRenderContext.IsBackground())
186  bEnableTransparent = false;
187  }
188 
189  if (bEnableTransparent)
190  {
193  SetPaintTransparent(true);
194  rRenderContext.SetBackground();
195  }
196 }
197 
198 void FixedText::Paint( vcl::RenderContext& rRenderContext, const tools::Rectangle& )
199 {
200  ImplDraw(&rRenderContext, DrawFlags::NONE, Point(), GetOutputSizePixel());
201 }
202 
203 void FixedText::Draw( OutputDevice* pDev, const Point& rPos,
204  DrawFlags nFlags )
205 {
206  ApplySettings(*pDev);
207 
208  Point aPos = pDev->LogicToPixel( rPos );
209  Size aSize = GetSizePixel();
210  vcl::Font aFont = GetDrawPixelFont( pDev );
211 
212  pDev->Push();
213  pDev->SetMapMode();
214  pDev->SetFont( aFont );
215  if ( nFlags & DrawFlags::Mono )
216  pDev->SetTextColor( COL_BLACK );
217  else
218  pDev->SetTextColor( GetTextColor() );
219  pDev->SetTextFillColor();
220 
221  bool bBorder = (GetStyle() & WB_BORDER);
222  bool bBackground = IsControlBackground();
223  if ( bBorder || bBackground )
224  {
225  tools::Rectangle aRect( aPos, aSize );
226  if ( bBorder )
227  {
228  ImplDrawFrame( pDev, aRect );
229  }
230  if ( bBackground )
231  {
233  pDev->DrawRect( aRect );
234  }
235  }
236 
237  ImplDraw( pDev, nFlags, aPos, aSize );
238  pDev->Pop();
239 }
240 
242 {
243  Control::Resize();
244  Invalidate();
245 }
246 
248 {
249  Control::StateChanged( nType );
250 
251  if ( (nType == StateChangedType::Enable) ||
252  (nType == StateChangedType::Text) ||
253  (nType == StateChangedType::UpdateMode) )
254  {
255  if ( IsReallyVisible() && IsUpdateMode() )
256  Invalidate();
257  }
258  else if ( nType == StateChangedType::Style )
259  {
261  if ( (GetPrevStyle() & FIXEDTEXT_VIEW_STYLE) !=
263  {
264  ApplySettings(*this);
265  Invalidate();
266  }
267  }
268  else if ( (nType == StateChangedType::Zoom) ||
269  (nType == StateChangedType::ControlFont) )
270  {
271  ApplySettings(*this);
272  Invalidate();
273  }
274  else if ( nType == StateChangedType::ControlForeground )
275  {
276  ApplySettings(*this);
277  Invalidate();
278  }
279  else if ( nType == StateChangedType::ControlBackground )
280  {
281  ApplySettings(*this);
282  Invalidate();
283  }
284 }
285 
287 {
288  Control::DataChanged( rDCEvt );
289 
290  if ( (rDCEvt.GetType() == DataChangedEventType::FONTS) ||
292  ((rDCEvt.GetType() == DataChangedEventType::SETTINGS) &&
293  (rDCEvt.GetFlags() & AllSettingsFlags::STYLE)) )
294  {
295  ApplySettings(*this);
296  Invalidate();
297  }
298 }
299 
300 Size FixedText::getTextDimensions(Control const *pControl, const OUString &rTxt, tools::Long nMaxWidth)
301 {
302  DrawTextFlags nStyle = ImplGetTextStyle( pControl->GetStyle() );
303  if ( !( pControl->GetStyle() & WB_NOLABEL ) )
304  nStyle |= DrawTextFlags::Mnemonic;
305 
306  return pControl->GetTextRect(tools::Rectangle( Point(), Size(nMaxWidth, 0x7fffffff)),
307  rTxt, nStyle).GetSize();
308 }
309 
311 {
312  Size aSize = getTextDimensions(pControl, pControl->GetText(), nMaxWidth);
313 
314  if ( pControl->GetStyle() & WB_EXTRAOFFSET )
315  aSize.AdjustWidth(2 );
316 
317  // GetTextRect cannot take an empty string
318  if ( aSize.Width() < 0 )
319  aSize.setWidth( 0 );
320  if ( aSize.Height() <= 0 )
321  aSize.setHeight( pControl->GetTextHeight() );
322 
323  return aSize;
324 }
325 
327 {
328  return CalcWindowSize( CalcMinimumTextSize ( this, nMaxWidth ) );
329 }
330 
332 {
333  sal_Int32 nMaxAvailWidth = 0x7fffffff;
334  if (m_nMaxWidthChars != -1)
335  {
336  OUStringBuffer aBuf;
338  nMaxAvailWidth = getTextDimensions(this,
339  aBuf.makeStringAndClear(), 0x7fffffff).Width();
340  }
341  Size aRet = CalcMinimumSize(nMaxAvailWidth);
342  if (m_nMinWidthChars != -1)
343  {
344  OUStringBuffer aBuf;
346  Size aMinAllowed = getTextDimensions(this,
347  aBuf.makeStringAndClear(), 0x7fffffff);
348  aRet.setWidth(std::max(aMinAllowed.Width(), aRet.Width()));
349  }
350  return aRet;
351 }
352 
354 {
355  mpControlData->mpLayoutData.reset( new vcl::ControlLayoutData );
356  ImplDraw(const_cast<FixedText*>(this), DrawFlags::NONE, Point(), GetOutputSizePixel(), true);
357  //const_cast<FixedText*>(this)->Invalidate();
358 }
359 
360 void FixedText::setMaxWidthChars(sal_Int32 nWidth)
361 {
362  if (nWidth != m_nMaxWidthChars)
363  {
364  m_nMaxWidthChars = nWidth;
365  queue_resize();
366  }
367 }
368 
369 void FixedText::setMinWidthChars(sal_Int32 nWidth)
370 {
371  if (nWidth != m_nMinWidthChars)
372  {
373  m_nMinWidthChars = nWidth;
374  queue_resize();
375  }
376 }
377 
378 bool FixedText::set_property(const OString &rKey, const OUString &rValue)
379 {
380  if (rKey == "max-width-chars")
381  setMaxWidthChars(rValue.toInt32());
382  else if (rKey == "width-chars")
383  setMinWidthChars(rValue.toInt32());
384  else if (rKey == "ellipsize")
385  {
386  WinBits nBits = GetStyle();
387  nBits &= ~WB_PATHELLIPSIS;
388  if (rValue != "none")
389  {
390  SAL_WARN_IF(rValue != "end", "vcl.layout", "Only endellipsis support for now");
391  nBits |= WB_PATHELLIPSIS;
392  }
393  SetStyle(nBits);
394  }
395  else
396  return Control::set_property(rKey, rValue);
397  return true;
398 }
399 
401 {
403  if (pWindow)
404  return pWindow;
405  return get_mnemonic_widget();
406 }
407 
409 {
410  if (pWindow == m_pMnemonicWindow)
411  return;
412  if (m_pMnemonicWindow)
413  {
414  vcl::Window *pTempReEntryGuard = m_pMnemonicWindow;
415  m_pMnemonicWindow = nullptr;
416  pTempReEntryGuard->remove_mnemonic_label(this);
417  }
418  m_pMnemonicWindow = pWindow;
419  if (m_pMnemonicWindow)
421 }
422 
424 {
425  disposeOnce();
426 }
427 
429 {
430  set_mnemonic_widget(nullptr);
433 }
434 
436  : Edit(pParent, nStyle)
437 {
438  // no border
440  // read-only
441  SetReadOnly();
442  // make it transparent
443  SetPaintTransparent(true);
445 }
446 
448 {
449  rRenderContext.SetBackground();
450 }
451 
453 {
454  Edit::LoseFocus();
455  // clear cursor
456  Invalidate();
457 }
458 
459 void FixedLine::ImplInit( vcl::Window* pParent, WinBits nStyle )
460 {
461  nStyle = ImplInitStyle( nStyle );
462  Control::ImplInit( pParent, nStyle, nullptr );
463  ApplySettings(*this);
464 }
465 
467 {
468  if ( !(nStyle & WB_NOGROUP) )
469  nStyle |= WB_GROUP;
470  return nStyle;
471 }
472 
474 {
475  return _rStyle.GetGroupFont();
476 }
477 
479 {
480  return _rStyle.GetGroupTextColor();
481 }
482 
484 {
485  // we need to measure according to the window, not according to the
486  // RenderContext we paint to
487  Size aOutSize = GetOutputSizePixel();
488 
489  OUString aText = GetText();
490  WinBits nWinStyle = GetStyle();
491 
492  DecorationView aDecoView(&rRenderContext);
493  if (aText.isEmpty())
494  {
495  if (nWinStyle & WB_VERT)
496  {
497  tools::Long nX = (aOutSize.Width() - 1) / 2;
498  aDecoView.DrawSeparator(Point(nX, 0), Point(nX, aOutSize.Height() - 1));
499  }
500  else
501  {
502  tools::Long nY = (aOutSize.Height() - 1) / 2;
503  aDecoView.DrawSeparator(Point(0, nY), Point(aOutSize.Width() - 1, nY), false);
504  }
505  }
506  else if (nWinStyle & WB_VERT)
507  {
508  tools::Long nWidth = rRenderContext.GetTextWidth(aText);
509  rRenderContext.Push(PushFlags::FONT);
510  vcl::Font aFont(rRenderContext.GetFont());
511  aFont.SetOrientation(900_deg10);
512  SetFont(aFont);
513  Point aStartPt(aOutSize.Width() / 2, aOutSize.Height() - 1);
514  if (nWinStyle & WB_VCENTER)
515  aStartPt.AdjustY( -((aOutSize.Height() - nWidth) / 2) );
516  Point aTextPt(aStartPt);
517  aTextPt.AdjustX( -(GetTextHeight() / 2) );
518  rRenderContext.DrawText(aTextPt, aText, 0, aText.getLength());
519  rRenderContext.Pop();
520  if (aOutSize.Height() - aStartPt.Y() > FIXEDLINE_TEXT_BORDER)
521  aDecoView.DrawSeparator(Point(aStartPt.X(), aStartPt.Y() + FIXEDLINE_TEXT_BORDER),
522  Point(aStartPt.X(), aOutSize.Height() - 1));
523  if (aStartPt.Y() - nWidth - FIXEDLINE_TEXT_BORDER > 0)
524  aDecoView.DrawSeparator(Point(aStartPt.X(), 0),
525  Point(aStartPt.X(), aStartPt.Y() - nWidth - FIXEDLINE_TEXT_BORDER));
526  }
527  else
528  {
530  tools::Rectangle aRect(0, 0, aOutSize.Width(), aOutSize.Height());
531  const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
532  if (nWinStyle & WB_CENTER)
533  nStyle |= DrawTextFlags::Center;
534 
535  if (!IsEnabled())
536  nStyle |= DrawTextFlags::Disable;
537  if (GetStyle() & WB_NOLABEL)
538  nStyle &= ~DrawTextFlags::Mnemonic;
539  if (rStyleSettings.GetOptions() & StyleSettingsOptions::Mono)
540  nStyle |= DrawTextFlags::Mono;
541 
542  aRect = DrawControlText(*this, aRect, aText, nStyle, nullptr, nullptr);
543 
544  tools::Long nTop = aRect.Top() + ((aRect.GetHeight() - 1) / 2);
545  aDecoView.DrawSeparator(Point(aRect.Right() + FIXEDLINE_TEXT_BORDER, nTop), Point(aOutSize.Width() - 1, nTop), false);
546  if (aRect.Left() > FIXEDLINE_TEXT_BORDER)
547  aDecoView.DrawSeparator(Point(0, nTop), Point(aRect.Left() - FIXEDLINE_TEXT_BORDER, nTop), false);
548  }
549 }
550 
553 {
554  ImplInit( pParent, nStyle );
555  SetSizePixel( Size( 2, 2 ) );
556 }
557 
559 {
560  mpControlData->mpLayoutData.reset( new vcl::ControlLayoutData );
561  const_cast<FixedLine*>(this)->Invalidate();
562 }
563 
565 {
566  Control::ApplySettings(rRenderContext);
567 
568  vcl::Window* pParent = GetParent();
570  {
573  SetPaintTransparent(true);
574  rRenderContext.SetBackground();
575  }
576  else
577  {
580  SetPaintTransparent(false);
581 
582  if (IsControlBackground())
583  rRenderContext.SetBackground(GetControlBackground());
584  else
585  rRenderContext.SetBackground(pParent->GetBackground());
586  }
587 }
588 
590 {
591  ImplDraw(rRenderContext);
592 }
593 
594 void FixedLine::Draw( OutputDevice*, const Point&, DrawFlags )
595 {
596 }
597 
599 {
600  Control::Resize();
601  Invalidate();
602 }
603 
605 {
606  Control::StateChanged( nType );
607 
608  if ( (nType == StateChangedType::Enable) ||
609  (nType == StateChangedType::Text) ||
610  (nType == StateChangedType::UpdateMode) )
611  {
612  if ( IsReallyVisible() && IsUpdateMode() )
613  Invalidate();
614  }
615  else if ( nType == StateChangedType::Style )
616  {
618  if ( (GetPrevStyle() & FIXEDLINE_VIEW_STYLE) !=
620  Invalidate();
621  }
622  else if ( (nType == StateChangedType::Zoom) ||
623  (nType == StateChangedType::Style) ||
624  (nType == StateChangedType::ControlFont) )
625  {
626  ApplySettings(*this);
627  Invalidate();
628  }
629  else if ( nType == StateChangedType::ControlForeground )
630  {
631  ApplySettings(*this);
632  Invalidate();
633  }
634  else if ( nType == StateChangedType::ControlBackground )
635  {
636  ApplySettings(*this);
637  Invalidate();
638  }
639 }
640 
642 {
643  Control::DataChanged( rDCEvt );
644 
645  if ( (rDCEvt.GetType() == DataChangedEventType::FONTS) ||
647  ((rDCEvt.GetType() == DataChangedEventType::SETTINGS) &&
648  (rDCEvt.GetFlags() & AllSettingsFlags::STYLE)) )
649  {
650  ApplySettings(*this);
651  Invalidate();
652  }
653 }
654 
656 {
658 }
659 
661 {
662  Control::DumpAsPropertyTree(rJsonWriter);
663  rJsonWriter.put("type", "separator");
664  rJsonWriter.put("orientation", (GetStyle() & WB_VERT) ? "vertical" : "horizontal");
665 }
666 
667 void FixedBitmap::ImplInit( vcl::Window* pParent, WinBits nStyle )
668 {
669  nStyle = ImplInitStyle( nStyle );
670  Control::ImplInit( pParent, nStyle, nullptr );
671  ApplySettings(*this);
672 }
673 
675 {
676  if ( !(nStyle & WB_NOGROUP) )
677  nStyle |= WB_GROUP;
678  return nStyle;
679 }
680 
683 {
684  ImplInit( pParent, nStyle );
685 }
686 
687 void FixedBitmap::ImplDraw( OutputDevice* pDev, const Point& rPos, const Size& rSize )
688 {
689  // do we have a Bitmap?
690  if ( !!maBitmap )
691  {
692  if ( GetStyle() & WB_SCALE )
693  pDev->DrawBitmapEx( rPos, rSize, maBitmap );
694  else
695  {
696  Point aPos = ImplCalcPos( GetStyle(), rPos, maBitmap.GetSizePixel(), rSize );
697  pDev->DrawBitmapEx( aPos, maBitmap );
698  }
699  }
700 }
701 
703 {
704  vcl::Window* pParent = GetParent();
706  {
709  SetPaintTransparent(true);
710  rRenderContext.SetBackground();
711  }
712  else
713  {
716  SetPaintTransparent(false);
717 
718  if (IsControlBackground())
719  rRenderContext.SetBackground(GetControlBackground());
720  else
721  rRenderContext.SetBackground(pParent->GetBackground());
722  }
723 }
724 
726 {
727  ImplDraw(&rRenderContext, Point(), GetOutputSizePixel());
728 }
729 
730 void FixedBitmap::Draw( OutputDevice* pDev, const Point& rPos,
731  DrawFlags )
732 {
733  Point aPos = pDev->LogicToPixel( rPos );
734  Size aSize = GetSizePixel();
735  tools::Rectangle aRect( aPos, aSize );
736 
737  pDev->Push();
738  pDev->SetMapMode();
739 
740  // Border
741  if ( GetStyle() & WB_BORDER )
742  {
743  DecorationView aDecoView( pDev );
744  aRect = aDecoView.DrawFrame( aRect, DrawFrameStyle::DoubleIn );
745  }
746  pDev->IntersectClipRegion( aRect );
747  ImplDraw( pDev, aRect.TopLeft(), aRect.GetSize() );
748 
749  pDev->Pop();
750 }
751 
753 {
754  Control::Resize();
755  Invalidate();
756 }
757 
759 {
760  Control::StateChanged( nType );
761 
762  if ( (nType == StateChangedType::Data) ||
763  (nType == StateChangedType::UpdateMode) )
764  {
765  if ( IsReallyVisible() && IsUpdateMode() )
766  Invalidate();
767  }
768  else if ( nType == StateChangedType::Style )
769  {
773  Invalidate();
774  }
775  else if ( nType == StateChangedType::ControlBackground )
776  {
777  ApplySettings(*this);
778  Invalidate();
779  }
780 }
781 
783 {
784  Control::DataChanged( rDCEvt );
785 
786  if ( (rDCEvt.GetType() == DataChangedEventType::SETTINGS) &&
787  (rDCEvt.GetFlags() & AllSettingsFlags::STYLE) )
788  {
789  ApplySettings(*this);
790  Invalidate();
791  }
792 }
793 
794 void FixedBitmap::SetBitmap( const BitmapEx& rBitmap )
795 {
796  maBitmap = rBitmap;
798  queue_resize();
799 }
800 
801 void FixedImage::ImplInit( vcl::Window* pParent, WinBits nStyle )
802 {
803  nStyle = ImplInitStyle( nStyle );
804  Control::ImplInit( pParent, nStyle, nullptr );
805  ApplySettings(*this);
806 }
807 
809 {
810  if ( !(nStyle & WB_NOGROUP) )
811  nStyle |= WB_GROUP;
812  return nStyle;
813 }
814 
817 {
818  ImplInit( pParent, nStyle );
819 }
820 
822  const Point& rPos, const Size& rSize )
823 {
825  if ( !IsEnabled() )
826  nStyle |= DrawImageFlags::Disable;
827 
828  Image *pImage = &maImage;
829 
830  // do we have an image?
831  if ( !(!(*pImage)) )
832  {
833  if ( GetStyle() & WB_SCALE )
834  pDev->DrawImage( rPos, rSize, *pImage, nStyle );
835  else
836  {
837  Point aPos = ImplCalcPos( GetStyle(), rPos, pImage->GetSizePixel(), rSize );
838  pDev->DrawImage( aPos, *pImage, nStyle );
839  }
840  }
841 }
842 
844 {
845  vcl::Window* pParent = GetParent();
846  if (pParent && pParent->IsChildTransparentModeEnabled() && !IsControlBackground())
847  {
850  SetPaintTransparent(true);
851  rRenderContext.SetBackground();
852  }
853  else
854  {
857  SetPaintTransparent(false);
858 
859  if (IsControlBackground())
860  rRenderContext.SetBackground(GetControlBackground());
861  else if (pParent)
862  rRenderContext.SetBackground(pParent->GetBackground());
863  }
864 }
865 
866 
868 {
869  ImplDraw(&rRenderContext, Point(), GetOutputSizePixel());
870 }
871 
873 {
874  return maImage.GetSizePixel();
875 }
876 
877 void FixedImage::Draw( OutputDevice* pDev, const Point& rPos,
878  DrawFlags )
879 {
880  Point aPos = pDev->LogicToPixel( rPos );
881  Size aSize = GetSizePixel();
882  tools::Rectangle aRect( aPos, aSize );
883 
884  pDev->Push();
885  pDev->SetMapMode();
886 
887  // Border
888  if ( GetStyle() & WB_BORDER )
889  {
890  ImplDrawFrame( pDev, aRect );
891  }
892  pDev->IntersectClipRegion( aRect );
893  ImplDraw( pDev, aRect.TopLeft(), aRect.GetSize() );
894 
895  pDev->Pop();
896 }
897 
899 {
900  Control::Resize();
901  Invalidate();
902 }
903 
905 {
906  Control::StateChanged( nType );
907 
908  if ( (nType == StateChangedType::Enable) ||
909  (nType == StateChangedType::Data) ||
910  (nType == StateChangedType::UpdateMode) )
911  {
912  if ( IsReallyVisible() && IsUpdateMode() )
913  Invalidate();
914  }
915  else if ( nType == StateChangedType::Style )
916  {
918  if ( (GetPrevStyle() & FIXEDIMAGE_VIEW_STYLE) !=
920  Invalidate();
921  }
922  else if ( nType == StateChangedType::ControlBackground )
923  {
924  ApplySettings(*this);
925  Invalidate();
926  }
927 }
928 
930 {
931  Control::DataChanged( rDCEvt );
932 
933  if ( (rDCEvt.GetType() == DataChangedEventType::SETTINGS) &&
934  (rDCEvt.GetFlags() & AllSettingsFlags::STYLE) )
935  {
936  ApplySettings(*this);
937  Invalidate();
938  }
939 }
940 
941 void FixedImage::SetImage( const Image& rImage )
942 {
943  if ( rImage != maImage )
944  {
945  maImage = rImage;
947  queue_resize();
948  }
949 }
950 
951 void FixedImage::SetModeImage( const Image& rImage )
952 {
953  SetImage( rImage );
954 }
955 
956 Image FixedImage::loadThemeImage(const OUString &rFileName)
957 {
958  return Image(StockImage::Yes, rFileName);
959 }
960 
961 bool FixedImage::set_property(const OString &rKey, const OUString &rValue)
962 {
963  if (rKey == "icon-size")
964  {
965  WinBits nBits = GetStyle();
966  nBits &= ~WB_SMALLSTYLE;
967  if (rValue == "2")
968  nBits |= WB_SMALLSTYLE;
969  SetStyle(nBits);
970  }
971  else
972  return Control::set_property(rKey, rValue);
973  return true;
974 }
975 
976 /* 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:1085
SAL_DLLPRIVATE void ImplDraw(OutputDevice *pDev, DrawFlags nDrawFlags, const Point &rPos, const Size &rSize, bool bFillLayout=false) const
Definition: fixed.cxx:135
void set_mnemonic_widget(vcl::Window *pWindow)
Definition: fixed.cxx:408
const Wallpaper & GetBackground() const
Definition: outdev.hxx:647
void remove_mnemonic_label(FixedText *pLabel)
Definition: window2.cxx:1976
static Image loadThemeImage(const OUString &rFileName)
Definition: fixed.cxx:956
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:594
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:466
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:551
const StyleSettings & GetStyleSettings() const
virtual void ApplySettings(vcl::RenderContext &) override
Definition: fixed.cxx:564
virtual void Resize() override
Definition: fixed.cxx:752
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:837
SAL_DLLPRIVATE void ImplDraw(OutputDevice *pDev, const Point &rPos, const Size &rSize)
Definition: fixed.cxx:687
const Color & GetGroupTextColor() const
virtual Size GetSizePixel() const
Definition: window.cxx:2394
virtual void SetSizePixel(const Size &rNewSize)
Definition: window2.cxx:1260
WinBits const WB_RIGHT
virtual void DataChanged(const DataChangedEvent &rDCEvt) override
Definition: fixed.cxx:641
aBuf
void CompatStateChanged(StateChangedType nStateChange)
Definition: window.cxx:3897
void SetBitmap(const BitmapEx &rBitmap)
Definition: fixed.cxx:794
void SetTextFillColor()
Definition: text.cxx:697
void SetParentClipMode(ParentClipMode nMode=ParentClipMode::NONE)
WinBits GetPrevStyle() const
Definition: window2.cxx:956
virtual bool set_property(const OString &rKey, const OUString &rValue) override
Definition: fixed.cxx:961
DataChangedEventType GetType() const
Definition: event.hxx:356
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:758
const Color & GetControlBackground() const
Definition: window2.cxx:1080
virtual void StateChanged(StateChangedType nType) override
Definition: fixed.cxx:604
virtual void ApplySettings(vcl::RenderContext &rRenderContext) override
Definition: ctrl.cxx:418
void SetMapMode()
Definition: map.cxx:546
StateChangedType
Definition: window.hxx:317
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:1796
WinBits const WB_SCALE
sal_Int64 WinBits
virtual Size GetOptimalSize() const override
Definition: fixed.cxx:872
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:904
virtual Size GetOptimalSize() const override
Definition: fixed.cxx:331
AllSettingsFlags GetFlags() const
Definition: event.hxx:357
static SAL_DLLPRIVATE WinBits ImplInitStyle(WinBits nStyle)
Definition: fixed.cxx:808
virtual const Color & GetCanonicalTextColor(const StyleSettings &_rStyle) const override
Definition: fixed.cxx:478
virtual void queue_resize(StateChangedType eReason=StateChangedType::Layout)
Definition: window2.cxx:1325
BitmapEx maBitmap
void SetBorderStyle(WindowBorderStyle nBorderStyle)
Definition: window.cxx:1987
const sal_Int16 FIXEDLINE
void SetModeImage(const Image &rImage)
Definition: fixed.cxx:951
virtual OUString GetText() const
Definition: window.cxx:3047
virtual const vcl::Font & GetCanonicalFont(const StyleSettings &_rStyle) const override
Definition: fixed.cxx:473
SAL_DLLPRIVATE void ImplDraw(OutputDevice *pDev, const Point &rPos, const Size &rSize)
Definition: fixed.cxx:821
virtual void ApplySettings(vcl::RenderContext &rRenderContext) override
Definition: fixed.cxx:168
WinBits const WB_HYPHENATION
Definition: edit.hxx:55
virtual void StateChanged(StateChangedType nType) override
Definition: fixed.cxx:247
virtual void DataChanged(const DataChangedEvent &rDCEvt) override
Definition: fixed.cxx:782
SAL_DLLPRIVATE void ImplInit(vcl::Window *pParent, WinBits nStyle)
Definition: fixed.cxx:71
bool IsChildTransparentModeEnabled() const
Definition: window2.cxx:1025
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:31
virtual void Resize() override
Definition: fixed.cxx:598
static Size getTextDimensions(Control const *pControl, const OUString &rTxt, tools::Long nMaxWidth)
Definition: fixed.cxx:300
Size CalcWindowSize(const Size &rOutSz) const
Definition: window2.cxx:535
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:286
constexpr auto FIXEDBITMAP_VIEW_STYLE
Definition: fixed.cxx:38
const vcl::Font & GetGroupFont() const
DrawFlags
Definition: window.hxx:360
void add_mnemonic_label(FixedText *pLabel)
Definition: window2.cxx:1967
virtual vcl::Window * getAccessibleRelationLabelFor() const
void setMaxWidthChars(sal_Int32 nWidth)
Definition: fixed.cxx:360
void SetControlBackground()
Definition: window2.cxx:495
void SetOrientation(Degree10 nLineOrientation)
Definition: font/font.cxx:193
virtual void SetReadOnly(bool bReadOnly=true)
Definition: edit.cxx:2360
virtual void ApplySettings(vcl::RenderContext &) override
Definition: fixed.cxx:702
WinBits const WB_VCENTER
virtual void Invalidate(InvalidateFlags nFlags=InvalidateFlags::NONE)
Definition: paint.cxx:1158
bool IsUpdateMode() const
Definition: window2.cxx:1171
void SetFillColor()
tools::Long Width() const
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:447
void SetTextColor(const Color &rColor)
Definition: text.cxx:662
WinBits const WB_SMALLSTYLE
VclPtr< vcl::Window > m_pMnemonicWindow
Definition: fixed.hxx:32
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:941
DrawTextFlags
Definition: outdev.hxx:143
virtual bool set_property(const OString &rKey, const OUString &rValue)
Definition: window2.cxx:1443
vcl::Window * GetParent() const
Definition: window2.cxx:1095
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:1010
Size GetSize() const
void put(const char *pPropName, const OUString &rPropValue)
static Size CalcMinimumTextSize(Control const *pControl, tools::Long nMaxWidth=0x7fffffff)
Definition: fixed.cxx:310
StyleSettingsOptions GetOptions() const
SAL_DLLPRIVATE void ImplInit(vcl::Window *pParent, WinBits nStyle)
Definition: fixed.cxx:801
Point LogicToPixel(const Point &rLogicPt) const
Definition: map.cxx:828
SelectableFixedText(vcl::Window *pParent, WinBits nStyle)
Definition: fixed.cxx:435
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:681
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:30
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:660
#define SAL_WARN_IF(condition, area, stream)
SAL_DLLPRIVATE void ImplInit(vcl::Window *pParent, WinBits nStyle)
Definition: fixed.cxx:667
WinBits const WB_BORDER
void SetFont(const vcl::Font &rNewFont)
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
Definition: fixed.cxx:867
virtual vcl::Window * getAccessibleRelationLabelFor() const override
Definition: fixed.cxx:400
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:452
vcl::Font GetDrawPixelFont(::OutputDevice const *pDev) const
Definition: window2.cxx:551
void EnableChildTransparentMode(bool bEnable=true)
Definition: window2.cxx:1020
SAL_DLLPRIVATE void ImplInit(vcl::Window *pParent, WinBits nStyle)
Definition: fixed.cxx:459
tools::Long AdjustWidth(tools::Long n)
Definition: image.hxx:39
virtual void Draw(OutputDevice *pDev, const Point &rPos, DrawFlags nFlags) override
Definition: fixed.cxx:877
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
tools::Long Height() const
vcl::Window * get_mnemonic_widget() const
Definition: fixed.hxx:72
const ::std::vector< Color > ImpSvNumberformatScan::StandardColor COL_BLACK
virtual Size GetOptimalSize() const override
Definition: fixed.cxx:655
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:1120
virtual void FillLayoutData() const override
Definition: fixed.cxx:558
virtual void ApplySettings(vcl::RenderContext &) override
Definition: fixed.cxx:843
virtual void DataChanged(const DataChangedEvent &rDCEvt) override
Definition: fixed.cxx:929
WinBits GetStyle() const
Definition: window2.cxx:951
SAL_DLLPRIVATE void ImplDraw(vcl::RenderContext &rRenderContext)
Definition: fixed.cxx:483
static SAL_DLLPRIVATE WinBits ImplInitStyle(WinBits nStyle)
Definition: fixed.cxx:674
virtual void Resize() override
Definition: fixed.cxx:241
virtual void LoseFocus() override
Definition: edit.cxx:1901
virtual void Draw(OutputDevice *pDev, const Point &rPos, DrawFlags nFlags) override
Definition: fixed.cxx:203
WinBits const WB_GROUP
Size CalcMinimumSize(tools::Long nMaxWidth=0x7fffffff) const
Definition: fixed.cxx:326
bool IsReallyVisible() const
Definition: window2.cxx:1105
const Size & GetSizePixel() const
Definition: bitmapex.hxx:84
void setMinWidthChars(sal_Int32 nWidth)
Definition: fixed.cxx:369
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
Definition: fixed.cxx:725
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:428
virtual bool set_property(const OString &rKey, const OUString &rValue) override
Definition: fixed.cxx:378
WinBits const WB_EXTRAOFFSET
void Push(PushFlags nFlags=PushFlags::ALL)
Definition: outdevstate.cxx:59
WinBits const WB_WORDBREAK
virtual ~FixedText() override
Definition: fixed.cxx:423
virtual void Resize() override
Definition: fixed.cxx:898
DrawImageFlags
Definition: outdev.hxx:171
virtual void Draw(OutputDevice *pDev, const Point &rPos, DrawFlags nFlags) override
Definition: fixed.cxx:730
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
Definition: fixed.cxx:589
FixedImage(vcl::Window *pParent, WinBits nStyle=0)
Definition: fixed.cxx:815
virtual void DataChanged(const DataChangedEvent &rDCEvt)
Definition: event.cxx:34
Image maImage
Definition: fixed.hxx:78
virtual void FillLayoutData() const override
Definition: fixed.cxx:353
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
Definition: fixed.cxx:198
OStringBuffer & padToLength(OStringBuffer &rBuffer, sal_Int32 nLength, char cFill= '\0')