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