LibreOffice Module vcl (master)  1
button.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 <tools/poly.hxx>
21 
22 #include <vcl/image.hxx>
23 #include <vcl/bitmapex.hxx>
24 #include <vcl/decoview.hxx>
25 #include <vcl/event.hxx>
26 #include <vcl/svapp.hxx>
27 #include <vcl/settings.hxx>
28 #include <vcl/toolkit/dialog.hxx>
29 #include <vcl/toolkit/fixed.hxx>
30 #include <vcl/toolkit/button.hxx>
31 #include <vcl/salnativewidgets.hxx>
32 #include <vcl/toolkit/edit.hxx>
33 #include <vcl/layout.hxx>
34 #include <vcl/stdtext.hxx>
35 #include <vcl/uitest/uiobject.hxx>
36 
37 #include <bitmaps.hlst>
38 #include <svdata.hxx>
39 #include <window.h>
40 #include <controldata.hxx>
41 #include <vclstatuslistener.hxx>
42 #include <osl/diagnose.h>
43 
45 #include <comphelper/lok.hxx>
46 #include <officecfg/Office/Common.hxx>
47 #include <boost/property_tree/ptree.hpp>
48 #include <tools/json_writer.hxx>
49 
50 
51 using namespace css;
52 
53 constexpr auto PUSHBUTTON_VIEW_STYLE = WB_3DLOOK |
59  WB_TOGGLE;
64 constexpr auto CHECKBOX_VIEW_STYLE = WB_3DLOOK |
68 
69 #define STYLE_RADIOBUTTON_MONO (sal_uInt16(0x0001)) // legacy
70 #define STYLE_CHECKBOX_MONO (sal_uInt16(0x0001)) // legacy
71 
73 {
74 public:
76 
81 
85 
87 
90 };
91 
92 ImplCommonButtonData::ImplCommonButtonData() : maFocusRect(), mnSeparatorX(0), mnButtonState(DrawButtonFlags::NONE),
93 mbSmallSymbol(false), maImage(), meImageAlign(ImageAlign::Top), meSymbolAlign(SymbolAlign::LEFT), maCustomContentImage()
94 {
95 }
96 
98  Control( nType ),
99  mpButtonData( std::make_unique<ImplCommonButtonData>() )
100 {
101 }
102 
104 {
105  disposeOnce();
106 }
107 
109 {
110  if (mpButtonData->mpStatusListener.is())
111  mpButtonData->mpStatusListener->dispose();
113 }
114 
115 void Button::SetCommandHandler(const OUString& aCommand)
116 {
117  maCommand = aCommand;
118  SetClickHdl( LINK( this, Button, dispatchCommandHandler) );
119 
120  mpButtonData->mpStatusListener = new VclStatusListener<Button>(this, aCommand);
121  mpButtonData->mpStatusListener->startListening();
122 }
123 
125 {
127 }
128 
129 void Button::SetModeImage( const Image& rImage )
130 {
131  if ( rImage != mpButtonData->maImage )
132  {
133  mpButtonData->maImage = rImage;
135  queue_resize();
136  }
137 }
138 
139 Image const & Button::GetModeImage( ) const
140 {
141  return mpButtonData->maImage;
142 }
143 
144 bool Button::HasImage() const
145 {
146  return !!(mpButtonData->maImage);
147 }
148 
150 {
151  if ( mpButtonData->meImageAlign != eAlign )
152  {
153  mpButtonData->meImageAlign = eAlign;
155  }
156 }
157 
159 {
160  return mpButtonData->meImageAlign;
161 }
162 
164 {
165  if (rImage != mpButtonData->maCustomContentImage)
166  {
167  mpButtonData->maCustomContentImage = rImage;
169  }
170 }
171 
173 {
174  return mpButtonData->maCustomContentImage;
175 }
176 
178 {
179  return mpButtonData->mnSeparatorX;
180 }
181 
183 {
184  mpButtonData->mnSeparatorX = nX;
185 }
186 
188 {
189  const StyleSettings& rStyleSettings = Application::GetSettings().GetStyleSettings();
190  DrawTextFlags nTextStyle = FixedText::ImplGetTextStyle(nWinStyle & ~WB_DEFBUTTON);
191 
192  if (!IsEnabled())
193  nTextStyle |= DrawTextFlags::Disable;
194 
195  if ((nDrawFlags & DrawFlags::Mono) ||
196  (rStyleSettings.GetOptions() & StyleSettingsOptions::Mono))
197  {
198  nTextStyle |= DrawTextFlags::Mono;
199  }
200 
201  return nTextStyle;
202 }
203 
205  Size& rSize,
206  sal_uLong nImageSep,
207  DrawTextFlags nTextStyle, tools::Rectangle *pSymbolRect,
208  bool bAddImageSep)
209 {
210  OUString aText(GetText());
211  bool bDrawImage = HasImage();
212  bool bDrawText = !aText.isEmpty();
213  bool bHasSymbol = pSymbolRect != nullptr;
214 
215  // No text and no image => nothing to do => return
216  if (!bDrawImage && !bDrawText && !bHasSymbol)
217  return;
218 
219  WinBits nWinStyle = GetStyle();
220  tools::Rectangle aOutRect( rPos, rSize );
221  ImageAlign eImageAlign = mpButtonData->meImageAlign;
222  Size aImageSize = mpButtonData->maImage.GetSizePixel();
223 
224  aImageSize.setWidth( CalcZoom( aImageSize.Width() ) );
225  aImageSize.setHeight( CalcZoom( aImageSize.Height() ) );
226 
227  // Drawing text or symbol only is simple, use style and output rectangle
228  if (bHasSymbol && !bDrawImage && !bDrawText)
229  {
230  *pSymbolRect = aOutRect;
231  return;
232  }
233  else if (bDrawText && !bDrawImage && !bHasSymbol)
234  {
235  aOutRect = DrawControlText(*pDev, aOutRect, aText, nTextStyle, nullptr, nullptr);
236  tools::Rectangle textRect = GetTextRect(
237  tools::Rectangle(Point(), Size(0x7fffffff, 0x7fffffff)), aText, nTextStyle);
238  // If the button text doesn't fit into it, put it into a tooltip (might happen in sidebar)
239  if (GetQuickHelpText().isEmpty() && textRect.getWidth() > rSize.getWidth())
240  SetQuickHelpText(aText);
241 
242  ImplSetFocusRect(aOutRect);
243  rSize = aOutRect.GetSize();
244  rPos = aOutRect.TopLeft();
245 
246  return;
247  }
248 
249  // check for HC mode ( image only! )
250  Image* pImage = &(mpButtonData->maImage);
251 
252  Size aTextSize;
253  Size aSymbolSize;
254  Size aDeviceTextSize;
255  Point aImagePos = rPos;
256  Point aTextPos = rPos;
257  tools::Rectangle aUnion(aImagePos, aImageSize);
258  tools::Long nSymbolHeight = 0;
259 
260  if (bDrawText || bHasSymbol)
261  {
262  // Get the size of the text output area ( the symbol will be drawn in
263  // this area as well, so the symbol rectangle will be calculated here, too )
264 
265  tools::Rectangle aRect(Point(), rSize);
266  Size aTSSize;
267 
268  if (bHasSymbol)
269  {
270  tools::Rectangle aSymbol;
271  if (bDrawText)
272  {
273  nSymbolHeight = pDev->GetTextHeight();
274  if (mpButtonData->mbSmallSymbol)
275  nSymbolHeight = nSymbolHeight * 3 / 4;
276 
277  aSymbol = tools::Rectangle(Point(), Size(nSymbolHeight, nSymbolHeight));
278  ImplCalcSymbolRect(aSymbol);
279  aRect.AdjustLeft(3 * nSymbolHeight / 2 );
280  aTSSize.setWidth( 3 * nSymbolHeight / 2 );
281  }
282  else
283  {
284  aSymbol = tools::Rectangle(Point(), rSize);
285  ImplCalcSymbolRect(aSymbol);
286  aTSSize.setWidth( aSymbol.GetWidth() );
287  }
288  aTSSize.setHeight( aSymbol.GetHeight() );
289  aSymbolSize = aSymbol.GetSize();
290  }
291 
292  if (bDrawText)
293  {
294  if ((eImageAlign == ImageAlign::LeftTop) ||
295  (eImageAlign == ImageAlign::Left ) ||
296  (eImageAlign == ImageAlign::LeftBottom) ||
297  (eImageAlign == ImageAlign::RightTop) ||
298  (eImageAlign == ImageAlign::Right) ||
299  (eImageAlign == ImageAlign::RightBottom))
300  {
301  aRect.AdjustRight( -sal_Int32(aImageSize.Width() + nImageSep) );
302  }
303  else if ((eImageAlign == ImageAlign::TopLeft) ||
304  (eImageAlign == ImageAlign::Top) ||
305  (eImageAlign == ImageAlign::TopRight) ||
306  (eImageAlign == ImageAlign::BottomLeft) ||
307  (eImageAlign == ImageAlign::Bottom) ||
308  (eImageAlign == ImageAlign::BottomRight))
309  {
310  aRect.AdjustBottom( -sal_Int32(aImageSize.Height() + nImageSep) );
311  }
312 
313  aRect = GetControlTextRect(*pDev, aRect, aText, nTextStyle, &aDeviceTextSize);
314  aTextSize = aRect.GetSize();
315 
316  aTSSize.AdjustWidth(aTextSize.Width() );
317 
318  if (aTSSize.Height() < aTextSize.Height())
319  aTSSize.setHeight( aTextSize.Height() );
320 
321  if (bAddImageSep && bDrawImage)
322  {
323  tools::Long nDiff = (aImageSize.Height() - aTextSize.Height()) / 3;
324  if (nDiff > 0)
325  nImageSep += nDiff;
326  }
327  }
328 
329  Size aMax;
330  aMax.setWidth( std::max(aTSSize.Width(), aImageSize.Width()) );
331  aMax.setHeight( std::max(aTSSize.Height(), aImageSize.Height()) );
332 
333  // Now calculate the output area for the image and the text according to the image align flags
334 
335  if ((eImageAlign == ImageAlign::Left) ||
336  (eImageAlign == ImageAlign::Right))
337  {
338  aImagePos.setY( rPos.Y() + (aMax.Height() - aImageSize.Height()) / 2 );
339  aTextPos.setY( rPos.Y() + (aMax.Height() - aTSSize.Height()) / 2 );
340  }
341  else if ((eImageAlign == ImageAlign::LeftBottom) ||
342  (eImageAlign == ImageAlign::RightBottom))
343  {
344  aImagePos.setY( rPos.Y() + aMax.Height() - aImageSize.Height() );
345  aTextPos.setY( rPos.Y() + aMax.Height() - aTSSize.Height() );
346  }
347  else if ((eImageAlign == ImageAlign::Top) ||
348  (eImageAlign == ImageAlign::Bottom))
349  {
350  aImagePos.setX( rPos.X() + (aMax.Width() - aImageSize.Width()) / 2 );
351  aTextPos.setX( rPos.X() + (aMax.Width() - aTSSize.Width()) / 2 );
352  }
353  else if ((eImageAlign == ImageAlign::TopRight) ||
354  (eImageAlign == ImageAlign::BottomRight))
355  {
356  aImagePos.setX( rPos.X() + aMax.Width() - aImageSize.Width() );
357  aTextPos.setX( rPos.X() + aMax.Width() - aTSSize.Width() );
358  }
359 
360  if ((eImageAlign == ImageAlign::LeftTop) ||
361  (eImageAlign == ImageAlign::Left) ||
362  (eImageAlign == ImageAlign::LeftBottom))
363  {
364  aTextPos.setX( rPos.X() + aImageSize.Width() + nImageSep );
365  }
366  else if ((eImageAlign == ImageAlign::RightTop) ||
367  (eImageAlign == ImageAlign::Right) ||
368  (eImageAlign == ImageAlign::RightBottom))
369  {
370  aImagePos.setX( rPos.X() + aTSSize.Width() + nImageSep );
371  }
372  else if ((eImageAlign == ImageAlign::TopLeft) ||
373  (eImageAlign == ImageAlign::Top) ||
374  (eImageAlign == ImageAlign::TopRight))
375  {
376  aTextPos.setY( rPos.Y() + aImageSize.Height() + nImageSep );
377  }
378  else if ((eImageAlign == ImageAlign::BottomLeft) ||
379  (eImageAlign == ImageAlign::Bottom) ||
380  (eImageAlign == ImageAlign::BottomRight))
381  {
382  aImagePos.setY( rPos.Y() + aTSSize.Height() + nImageSep );
383  }
384  else if (eImageAlign == ImageAlign::Center)
385  {
386  aImagePos.setX( rPos.X() + (aMax.Width() - aImageSize.Width()) / 2 );
387  aImagePos.setY( rPos.Y() + (aMax.Height() - aImageSize.Height()) / 2 );
388  aTextPos.setX( rPos.X() + (aMax.Width() - aTSSize.Width()) / 2 );
389  aTextPos.setY( rPos.Y() + (aMax.Height() - aTSSize.Height()) / 2 );
390  }
391  aUnion = tools::Rectangle(aImagePos, aImageSize);
392  aUnion.Union(tools::Rectangle(aTextPos, aTSSize));
393  }
394 
395  // Now place the combination of text and image in the output area of the button
396  // according to the window style (WinBits)
397  tools::Long nXOffset = 0;
398  tools::Long nYOffset = 0;
399 
400  if (nWinStyle & WB_CENTER)
401  {
402  nXOffset = (rSize.Width() - aUnion.GetWidth()) / 2;
403  }
404  else if (nWinStyle & WB_RIGHT)
405  {
406  nXOffset = rSize.Width() - aUnion.GetWidth();
407  }
408 
409  if (nWinStyle & WB_VCENTER)
410  {
411  nYOffset = (rSize.Height() - aUnion.GetHeight()) / 2;
412  }
413  else if (nWinStyle & WB_BOTTOM)
414  {
415  nYOffset = rSize.Height() - aUnion.GetHeight();
416  }
417 
418  // the top left corner should always be visible, so we don't allow negative offsets
419  if (nXOffset < 0) nXOffset = 0;
420  if (nYOffset < 0) nYOffset = 0;
421 
422  aImagePos.AdjustX(nXOffset );
423  aImagePos.AdjustY(nYOffset );
424  aTextPos.AdjustX(nXOffset );
425  aTextPos.AdjustY(nYOffset );
426 
427  // set rPos and rSize to the union
428  rSize = aUnion.GetSize();
429  rPos.AdjustX(nXOffset );
430  rPos.AdjustY(nYOffset );
431 
432  if (bHasSymbol)
433  {
434  if (mpButtonData->meSymbolAlign == SymbolAlign::RIGHT)
435  {
436  Point aRightPos(aTextPos.X() + aTextSize.Width() + aSymbolSize.Width() / 2, aTextPos.Y());
437  *pSymbolRect = tools::Rectangle(aRightPos, aSymbolSize);
438  }
439  else
440  {
441  *pSymbolRect = tools::Rectangle(aTextPos, aSymbolSize);
442  aTextPos.AdjustX(3 * nSymbolHeight / 2 );
443  }
444  if (mpButtonData->mbSmallSymbol)
445  {
446  nYOffset = (aUnion.GetHeight() - aSymbolSize.Height()) / 2;
447  pSymbolRect->setY(aTextPos.Y() + nYOffset);
448  }
449  }
450 
452 
453  if (!IsEnabled())
454  {
455  nStyle |= DrawImageFlags::Disable;
456  }
457 
458  if (IsZoom())
459  pDev->DrawImage(aImagePos, aImageSize, *pImage, nStyle);
460  else
461  pDev->DrawImage(aImagePos, *pImage, nStyle);
462 
463  if (bDrawText)
464  {
465  const tools::Rectangle aTOutRect(aTextPos, aTextSize);
466  ImplSetFocusRect(aTOutRect);
467  DrawControlText(*pDev, aTOutRect, aText, nTextStyle, nullptr, nullptr, &aDeviceTextSize);
468  }
469  else
470  {
471  ImplSetFocusRect(tools::Rectangle(aImagePos, aImageSize));
472  }
473 }
474 
476 {
477  tools::Rectangle aFocusRect = rFocusRect;
478  tools::Rectangle aOutputRect(Point(), GetOutputSizePixel());
479 
480  if (!aFocusRect.IsEmpty())
481  {
482  aFocusRect.AdjustLeft( -1 );
483  aFocusRect.AdjustTop( -1 );
484  aFocusRect.AdjustRight( 1 );
485  aFocusRect.AdjustBottom( 1 );
486  }
487 
488  if (aFocusRect.Left() < aOutputRect.Left())
489  aFocusRect.SetLeft( aOutputRect.Left() );
490  if (aFocusRect.Top() < aOutputRect.Top())
491  aFocusRect.SetTop( aOutputRect.Top() );
492  if (aFocusRect.Right() > aOutputRect.Right())
493  aFocusRect.SetRight( aOutputRect.Right() );
494  if (aFocusRect.Bottom() > aOutputRect.Bottom())
495  aFocusRect.SetBottom( aOutputRect.Bottom() );
496 
497  mpButtonData->maFocusRect = aFocusRect;
498 }
499 
501 {
502  return mpButtonData->maFocusRect;
503 }
504 
506 {
507  return mpButtonData->mnButtonState;
508 }
509 
511 {
512  return mpButtonData->mnButtonState;
513 }
514 
516 {
517  if ( mpButtonData->meSymbolAlign != eAlign )
518  {
519  mpButtonData->meSymbolAlign = eAlign;
521  }
522 }
523 
525 {
526  mpButtonData->mbSmallSymbol = true;
527 }
528 
530 {
531  return mpButtonData->mbSmallSymbol;
532 }
533 
534 bool Button::set_property(const OString &rKey, const OUString &rValue)
535 {
536  if (rKey == "image-position")
537  {
538  ImageAlign eAlign = ImageAlign::Left;
539  if (rValue == "left")
540  eAlign = ImageAlign::Left;
541  else if (rValue == "right")
542  eAlign = ImageAlign::Right;
543  else if (rValue == "top")
544  eAlign = ImageAlign::Top;
545  else if (rValue == "bottom")
546  eAlign = ImageAlign::Bottom;
547  SetImageAlign(eAlign);
548  }
549  else if (rKey == "focus-on-click")
550  {
551  WinBits nBits = GetStyle();
552  nBits &= ~WB_NOPOINTERFOCUS;
553  if (!toBool(rValue))
554  nBits |= WB_NOPOINTERFOCUS;
555  SetStyle(nBits);
556  }
557  else
558  return Control::set_property(rKey, rValue);
559  return true;
560 }
561 
562 void Button::statusChanged(const css::frame::FeatureStateEvent& rEvent)
563 {
564  Enable(rEvent.IsEnabled);
565 }
566 
568 {
569  return ButtonUIObject::create;
570 }
571 
573 {
574  Control::DumpAsPropertyTree(rJsonWriter);
575  rJsonWriter.put("text", GetText());
576 }
577 
578 IMPL_STATIC_LINK( Button, dispatchCommandHandler, Button*, pButton, void )
579 {
580  if (pButton == nullptr)
581  return;
582 
583  comphelper::dispatchCommand(pButton->maCommand, uno::Sequence<beans::PropertyValue>());
584 }
585 
587 {
588  mpWindowImpl->mbPushButton = true;
589 
593  mbIsActive = false;
594  mbPressed = false;
595  mbIsAction = false;
596 }
597 
598 namespace
599 {
600  vcl::Window* getPreviousSibling(vcl::Window const *pParent)
601  {
602  return pParent ? pParent->GetWindow(GetWindowType::LastChild) : nullptr;
603  }
604 }
605 
606 void PushButton::ImplInit( vcl::Window* pParent, WinBits nStyle )
607 {
608  nStyle = ImplInitStyle(getPreviousSibling(pParent), nStyle);
609  Button::ImplInit( pParent, nStyle, nullptr );
610 
611  if ( nStyle & WB_NOLIGHTBORDER )
613 
614  ImplInitSettings( true );
615 }
616 
618 {
619  if ( !(nStyle & WB_NOTABSTOP) )
620  nStyle |= WB_TABSTOP;
621 
622  // if no alignment is given, default to "vertically centered". This is because since
623  // #i26046#, we respect the vertical alignment flags (previously we didn't completely),
624  // but we of course want to look as before when no vertical alignment is specified
625  if ( ( nStyle & ( WB_TOP | WB_VCENTER | WB_BOTTOM ) ) == 0 )
626  nStyle |= WB_VCENTER;
627 
628  if ( !(nStyle & WB_NOGROUP) &&
629  (!pPrevWindow ||
630  ((pPrevWindow->GetType() != WindowType::PUSHBUTTON ) &&
631  (pPrevWindow->GetType() != WindowType::OKBUTTON ) &&
632  (pPrevWindow->GetType() != WindowType::CANCELBUTTON) &&
633  (pPrevWindow->GetType() != WindowType::HELPBUTTON )) ) )
634  nStyle |= WB_GROUP;
635  return nStyle;
636 }
637 
639 {
640  return _rStyle.GetPushButtonFont();
641 }
642 
644 {
645  return _rStyle.GetButtonTextColor();
646 }
647 
648 void PushButton::ImplInitSettings( bool bBackground )
649 {
651 
652  if ( !bBackground )
653  return;
654 
655  SetBackground();
656  // #i38498#: do not check for GetParent()->IsChildTransparentModeEnabled()
657  // otherwise the formcontrol button will be overdrawn due to ParentClipMode::NoClip
658  // for radio and checkbox this is ok as they should appear transparent in documents
660  (GetStyle() & WB_FLATBUTTON) != 0 )
661  {
664  SetPaintTransparent( true );
665 
666  if ((GetStyle() & WB_FLATBUTTON) == 0)
667  mpWindowImpl->mbUseNativeFocus = ImplGetSVData()->maNWFData.mbNoFocusRects;
668  else
670  }
671  else
672  {
675  SetPaintTransparent( false );
676  }
677 }
678 
680  tools::Rectangle& rRect, DrawButtonFlags nStyle)
681 {
682  if (!(GetStyle() & (WB_RECTSTYLE | WB_SMALLSTYLE)))
683  {
684  StyleSettings aStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
685  if (IsControlBackground())
686  aStyleSettings.Set3DColors(GetControlBackground());
687  }
688 
689  DecorationView aDecoView(&rRenderContext);
690  if (IsControlBackground())
691  {
692  AllSettings aSettings = rRenderContext.GetSettings();
693  AllSettings aOldSettings = aSettings;
694  StyleSettings aStyleSettings = aSettings.GetStyleSettings();
695  aStyleSettings.Set3DColors(GetControlBackground());
696  aSettings.SetStyleSettings(aStyleSettings);
697 
698  // Call OutputDevice::SetSettings() explicitly, as rRenderContext may
699  // be a vcl::Window in fact, and vcl::Window::SetSettings() will call
700  // Invalidate(), which is a problem, since we're in Paint().
701  rRenderContext.OutputDevice::SetSettings(aSettings);
702  rRect = aDecoView.DrawButton(rRect, nStyle);
703  rRenderContext.OutputDevice::SetSettings(aOldSettings);
704  }
705  else
706  rRect = aDecoView.DrawButton(rRect, nStyle);
707 }
708 
710  const Point& rPos )
711 {
712  tools::Rectangle aTestRect( Point(), pDev->GetOutputSizePixel() );
713 
714  return aTestRect.IsInside( rPos );
715 }
716 
718 {
719  const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
720 
722 
723  if ( ( rStyleSettings.GetOptions() & StyleSettingsOptions::Mono ) ||
724  ( nDrawFlags & DrawFlags::Mono ) )
725  nTextStyle |= DrawTextFlags::Mono;
726 
727  if ( GetStyle() & WB_WORDBREAK )
728  nTextStyle |= DrawTextFlags::WordBreak;
729  if ( GetStyle() & WB_NOLABEL )
730  nTextStyle &= ~DrawTextFlags::Mnemonic;
731 
732  if ( GetStyle() & WB_LEFT )
733  nTextStyle |= DrawTextFlags::Left;
734  else if ( GetStyle() & WB_RIGHT )
735  nTextStyle |= DrawTextFlags::Right;
736  else
737  nTextStyle |= DrawTextFlags::Center;
738 
739  if ( GetStyle() & WB_TOP )
740  nTextStyle |= DrawTextFlags::Top;
741  else if ( GetStyle() & WB_BOTTOM )
742  nTextStyle |= DrawTextFlags::Bottom;
743  else
744  nTextStyle |= DrawTextFlags::VCenter;
745 
746  if ( !IsEnabled() )
747  nTextStyle |= DrawTextFlags::Disable;
748 
749  return nTextStyle;
750 }
751 
753  const tools::Rectangle &rRect, bool bMenuBtnSep,
754  DrawButtonFlags nButtonFlags)
755 {
756  const StyleSettings &rStyleSettings = GetSettings().GetStyleSettings();
757  tools::Rectangle aInRect = rRect;
758  Color aColor;
759  DrawTextFlags nTextStyle = ImplGetTextStyle(nDrawFlags);
760  DrawSymbolFlags nStyle;
761 
762  if (aInRect.Right() < aInRect.Left() || aInRect.Bottom() < aInRect.Top())
763  return;
764 
766  pDev->IntersectClipRegion(aInRect);
767 
768  if (nDrawFlags & DrawFlags::Mono)
769  aColor = COL_BLACK;
770 
771  // Custom foreground color is reasonable on stock controls only. Stock controls are used if a custom background has been set
772  // (and thus no native controls are able to be used) or no native controls are available.
773 
774  else if (IsControlForeground()
776  aColor = GetControlForeground();
777 
778  // Button types with possibly different text coloring are flat buttons and regular buttons. Regular buttons may be action
779  // buttons and may have an additional default status. Moreover all buttons may have an additional pressed and rollover
780  // (highlight) status. Pressed buttons are always in rollover status.
781 
782  else if (GetStyle() & WB_FLATBUTTON)
783  if (nButtonFlags & DrawButtonFlags::Pressed)
784  aColor = rStyleSettings.GetFlatButtonPressedRolloverTextColor();
785  else if (nButtonFlags & DrawButtonFlags::Highlight)
786  aColor = rStyleSettings.GetFlatButtonRolloverTextColor();
787  else
788  aColor = rStyleSettings.GetFlatButtonTextColor();
789  else
790  if (isAction() && (nButtonFlags & DrawButtonFlags::Default))
791  if (nButtonFlags & DrawButtonFlags::Pressed)
792  aColor = rStyleSettings.GetDefaultActionButtonPressedRolloverTextColor();
793  else if (nButtonFlags & DrawButtonFlags::Highlight)
794  aColor = rStyleSettings.GetDefaultActionButtonRolloverTextColor();
795  else
796  aColor = rStyleSettings.GetDefaultActionButtonTextColor();
797  else if (isAction())
798  if (nButtonFlags & DrawButtonFlags::Pressed)
799  aColor = rStyleSettings.GetActionButtonPressedRolloverTextColor();
800  else if (nButtonFlags & DrawButtonFlags::Highlight)
801  aColor = rStyleSettings.GetActionButtonRolloverTextColor();
802  else
803  aColor = rStyleSettings.GetActionButtonTextColor();
804  else if (nButtonFlags & DrawButtonFlags::Default)
805  if (nButtonFlags & DrawButtonFlags::Pressed)
806  aColor = rStyleSettings.GetDefaultButtonPressedRolloverTextColor();
807  else if (nButtonFlags & DrawButtonFlags::Highlight)
808  aColor = rStyleSettings.GetDefaultButtonRolloverTextColor();
809  else
810  aColor = rStyleSettings.GetDefaultButtonTextColor();
811  else
812  if (nButtonFlags & DrawButtonFlags::Pressed)
813  aColor = rStyleSettings.GetButtonPressedRolloverTextColor();
814  else if (nButtonFlags & DrawButtonFlags::Highlight)
815  aColor = rStyleSettings.GetButtonRolloverTextColor();
816  else
817  aColor = rStyleSettings.GetButtonTextColor();
818 
819  pDev->SetTextColor(aColor);
820 
821  if ( IsEnabled() )
822  nStyle = DrawSymbolFlags::NONE;
823  else
824  nStyle = DrawSymbolFlags::Disable;
825 
826  Size aSize = rRect.GetSize();
827  Point aPos = rRect.TopLeft();
828 
829  sal_uLong nImageSep = 1 + (pDev->GetTextHeight()-10)/2;
830  if( nImageSep < 1 )
831  nImageSep = 1;
834  {
835  tools::Long nSeparatorX = 0;
836  tools::Rectangle aSymbolRect = aInRect;
837 
838  // calculate symbol size
839  tools::Long nSymbolSize = pDev->GetTextHeight() / 2 + 1;
840 
841  nSeparatorX = aInRect.Right() - 2*nSymbolSize;
842  aSize.AdjustWidth( -(2*nSymbolSize) );
843 
844  // center symbol rectangle in the separated area
845  aSymbolRect.AdjustRight( -(nSymbolSize/2) );
846  aSymbolRect.SetLeft( aSymbolRect.Right() - nSymbolSize );
847 
848  ImplDrawAlignedImage( pDev, aPos, aSize, nImageSep,
849  nTextStyle, nullptr, true );
850 
851  tools::Long nDistance = (aSymbolRect.GetHeight() > 10) ? 2 : 1;
852  DecorationView aDecoView( pDev );
853  if( bMenuBtnSep && nSeparatorX > 0 )
854  {
855  Point aStartPt( nSeparatorX, aSymbolRect.Top()+nDistance );
856  Point aEndPt( nSeparatorX, aSymbolRect.Bottom()-nDistance );
857  aDecoView.DrawSeparator( aStartPt, aEndPt );
858  }
859  ImplSetSeparatorX( nSeparatorX );
860 
861  aDecoView.DrawSymbol( aSymbolRect, SymbolType::SPIN_DOWN, aColor, nStyle );
862 
863  }
864  else
865  {
866  tools::Rectangle aSymbolRect;
867  ImplDrawAlignedImage( pDev, aPos, aSize, nImageSep,
868  nTextStyle, IsSymbol() ? &aSymbolRect : nullptr, true );
869 
870  if ( IsSymbol() )
871  {
872  DecorationView aDecoView( pDev );
873  aDecoView.DrawSymbol( aSymbolRect, meSymbol, aColor, nStyle );
874  }
875  }
876 
877  pDev->Pop(); // restore clipregion
878 }
879 
881 {
882  HideFocus();
883 
884  DrawButtonFlags nButtonStyle = GetButtonState();
885  Size aOutSz(GetOutputSizePixel());
886  tools::Rectangle aRect(Point(), aOutSz);
887  tools::Rectangle aInRect = aRect;
888  bool bNativeOK = false;
889 
890  // adjust style if button should be rendered 'pressed'
891  if (mbPressed || mbIsActive)
892  nButtonStyle |= DrawButtonFlags::Pressed;
893 
894  // TODO: move this to Window class or make it a member !!!
895  ControlType aCtrlType = ControlType::Generic;
896  switch(GetParent()->GetType())
897  {
898  case WindowType::LISTBOX:
899  case WindowType::MULTILISTBOX:
900  case WindowType::TREELISTBOX:
901  aCtrlType = ControlType::Listbox;
902  break;
903 
904  case WindowType::COMBOBOX:
905  case WindowType::PATTERNBOX:
906  case WindowType::NUMERICBOX:
907  case WindowType::METRICBOX:
908  case WindowType::CURRENCYBOX:
909  case WindowType::DATEBOX:
910  case WindowType::TIMEBOX:
911  case WindowType::LONGCURRENCYBOX:
912  aCtrlType = ControlType::Combobox;
913  break;
914  default:
915  break;
916  }
917 
918  bool bDropDown = (IsSymbol() && (GetSymbol() == SymbolType::SPIN_DOWN) && GetText().isEmpty());
919 
920  if( bDropDown && (aCtrlType == ControlType::Combobox || aCtrlType == ControlType::Listbox))
921  {
923  {
924  // skip painting if the button was already drawn by the theme
925  if (aCtrlType == ControlType::Combobox)
926  {
927  Edit* pEdit = static_cast<Edit*>(GetParent());
928  if (pEdit->ImplUseNativeBorder(rRenderContext, pEdit->GetStyle()))
929  bNativeOK = true;
930  }
932  {
933  bNativeOK = true;
934  }
935 
936  if (!bNativeOK && GetParent()->IsNativeControlSupported(aCtrlType, ControlPart::ButtonDown))
937  {
938  // let the theme draw it, note we then need support
939  // for ControlType::Listbox/ControlPart::ButtonDown and ControlType::Combobox/ControlPart::ButtonDown
940 
941  ImplControlValue aControlValue;
943 
944  if (mbPressed || mbIsActive)
945  nState |= ControlState::PRESSED;
947  nState |= ControlState::PRESSED;
948  if (HasFocus())
949  nState |= ControlState::FOCUSED;
951  nState |= ControlState::DEFAULT;
952  if (Window::IsEnabled())
953  nState |= ControlState::ENABLED;
954 
955  if (IsMouseOver() && aInRect.IsInside(GetPointerPosPixel()))
956  nState |= ControlState::ROLLOVER;
957 
958  if ( IsMouseOver() && aInRect.IsInside(GetPointerPosPixel()) && mbIsActive)
959  {
960  nState |= ControlState::ROLLOVER;
961  nButtonStyle &= ~DrawButtonFlags::Pressed;
962  }
963 
964  bNativeOK = rRenderContext.DrawNativeControl(aCtrlType, ControlPart::ButtonDown, aInRect, nState,
965  aControlValue, OUString());
966  }
967  }
968  }
969 
970  if (bNativeOK)
971  return;
972 
973  bool bRollOver = (IsMouseOver() && aInRect.IsInside(GetPointerPosPixel()));
974  if (bRollOver)
975  nButtonStyle |= DrawButtonFlags::Highlight;
977  if (GetStyle() & WB_FLATBUTTON)
978  {
979  if (!bRollOver && !HasFocus())
980  bDrawMenuSep = false;
981  }
982  // tdf#123175 if there is a custom control bg set, draw the button without outsourcing to the NWF
984  if (bNativeOK)
985  {
986  PushButtonValue aControlValue;
987  aControlValue.mbIsAction = isAction();
988 
989  tools::Rectangle aCtrlRegion(aInRect);
991 
992  if (mbPressed || IsChecked() || mbIsActive)
993  {
994  nState |= ControlState::PRESSED;
995  nButtonStyle |= DrawButtonFlags::Pressed;
996  }
998  nState |= ControlState::PRESSED;
999  if (HasFocus())
1000  nState |= ControlState::FOCUSED;
1002  nState |= ControlState::DEFAULT;
1003  if (Window::IsEnabled())
1004  nState |= ControlState::ENABLED;
1005 
1006  if (bRollOver || mbIsActive)
1007  {
1008  nButtonStyle |= DrawButtonFlags::Highlight;
1009  nState |= ControlState::ROLLOVER;
1010  }
1011 
1012  if (mbIsActive && bRollOver)
1013  {
1014  nState &= ~ControlState::PRESSED;
1015  nButtonStyle &= ~DrawButtonFlags::Pressed;
1016  }
1017 
1018  if (GetStyle() & WB_FLATBUTTON)
1019  aControlValue.m_bFlatButton = true;
1020  if (GetStyle() & WB_BEVELBUTTON)
1021  aControlValue.mbBevelButton = true;
1022 
1023  // draw frame into invisible window to have aInRect modified correctly
1024  // but do not shift the inner rect for pressed buttons (ie remove DrawButtonFlags::Pressed)
1025  // this assumes the theme has enough visual cues to signalize the button was pressed
1026  //Window aWin( this );
1027  //ImplDrawPushButtonFrame( &aWin, aInRect, nButtonStyle & ~DrawButtonFlags::Pressed );
1028 
1029  // looks better this way as symbols were displaced slightly using the above approach
1030  aInRect.AdjustTop(4 );
1031  aInRect.AdjustBottom( -4 );
1032  aInRect.AdjustLeft(4 );
1033  aInRect.AdjustRight( -4 );
1034 
1035  // prepare single line hint (needed on mac to decide between normal push button and
1036  // rectangular bevel button look)
1037  Size aFontSize(Application::GetSettings().GetStyleSettings().GetPushButtonFont().GetFontSize());
1038  aFontSize = rRenderContext.LogicToPixel(aFontSize, MapMode(MapUnit::MapPoint));
1039  Size aInRectSize(rRenderContext.LogicToPixel(Size(aInRect.GetWidth(), aInRect.GetHeight())));
1040  aControlValue.mbSingleLine = (aInRectSize.Height() < 2 * aFontSize.Height());
1041 
1042  if ((nState & ControlState::ROLLOVER) || !(GetStyle() & WB_FLATBUTTON)
1043  || (HasFocus() && mpWindowImpl->mbUseNativeFocus
1045  {
1046  bNativeOK = rRenderContext.DrawNativeControl(ControlType::Pushbutton, ControlPart::Entire, aCtrlRegion, nState,
1047  aControlValue, OUString() /*PushButton::GetText()*/);
1048  }
1049  else
1050  {
1051  bNativeOK = true;
1052  }
1053 
1054  // draw content using the same aInRect as non-native VCL would do
1055  ImplDrawPushButtonContent(&rRenderContext, DrawFlags::NONE,
1056  aInRect, bDrawMenuSep, nButtonStyle);
1057 
1058  if (HasFocus())
1060  }
1061 
1062  if (bNativeOK)
1063  return;
1064 
1065  // draw PushButtonFrame, aInRect has content size afterwards
1066  if (GetStyle() & WB_FLATBUTTON)
1067  {
1068  tools::Rectangle aTempRect(aInRect);
1069  if (bRollOver)
1070  ImplDrawPushButtonFrame(rRenderContext, aTempRect, nButtonStyle);
1071  aInRect.AdjustLeft(2 );
1072  aInRect.AdjustTop(2 );
1073  aInRect.AdjustRight( -2 );
1074  aInRect.AdjustBottom( -2 );
1075  }
1076  else
1077  {
1078  ImplDrawPushButtonFrame(rRenderContext, aInRect, nButtonStyle);
1079  }
1080 
1081  // draw content
1082  ImplDrawPushButtonContent(&rRenderContext, DrawFlags::NONE, aInRect, bDrawMenuSep, nButtonStyle);
1083 
1084  if (HasFocus())
1085  {
1087  }
1088 }
1089 
1091 {
1092  Size aSize( GetSizePixel() );
1093  Point aPos( GetPosPixel() );
1094  int dLeft(0), dRight(0), dTop(0), dBottom(0);
1095  bool bSetPos = false;
1096 
1098  {
1099  tools::Rectangle aBound, aCont;
1100  tools::Rectangle aCtrlRegion( 0, 0, 80, 20 ); // use a constant size to avoid accumulating
1101  // will not work if the theme has dynamic adornment sizes
1102  ImplControlValue aControlValue;
1103 
1104  // get native size of a 'default' button
1105  // and adjust the VCL button if more space for adornment is required
1108  aControlValue,
1109  aBound, aCont ) )
1110  {
1111  dLeft = aCont.Left() - aBound.Left();
1112  dTop = aCont.Top() - aBound.Top();
1113  dRight = aBound.Right() - aCont.Right();
1114  dBottom = aBound.Bottom() - aCont.Bottom();
1115  bSetPos = dLeft || dTop || dRight || dBottom;
1116  }
1117  }
1118 
1119  if ( bSet )
1120  {
1121  if( !(GetButtonState() & DrawButtonFlags::Default) && bSetPos )
1122  {
1123  // adjust pos/size when toggling from non-default to default
1124  aPos.Move(-dLeft, -dTop);
1125  aSize.AdjustWidth(dLeft + dRight );
1126  aSize.AdjustHeight(dTop + dBottom );
1127  }
1129  }
1130  else
1131  {
1132  if( (GetButtonState() & DrawButtonFlags::Default) && bSetPos )
1133  {
1134  // adjust pos/size when toggling from default to non-default
1135  aPos.Move(dLeft, dTop);
1136  aSize.AdjustWidth( -(dLeft + dRight) );
1137  aSize.AdjustHeight( -(dTop + dBottom) );
1138  }
1139  GetButtonState() &= ~DrawButtonFlags::Default;
1140  }
1141  if( bSetPos )
1142  setPosSizePixel( aPos.X(), aPos.Y(), aSize.Width(), aSize.Height() );
1143 
1144  Invalidate();
1145 }
1146 
1148 {
1149  return bool(GetButtonState() & DrawButtonFlags::Default);
1150 }
1151 
1153  Button( nType )
1154 {
1156 }
1157 
1160 {
1162  ImplInit( pParent, nStyle );
1163 }
1164 
1166 {
1167  if ( !(rMEvt.IsLeft() &&
1168  ImplHitTestPushButton( this, rMEvt.GetPosPixel() )) )
1169  return;
1170 
1172 
1173  if ( ( GetStyle() & WB_REPEAT ) &&
1174  ! ( GetStyle() & WB_TOGGLE ) )
1175  nTrackFlags |= StartTrackingFlags::ButtonRepeat;
1176 
1178  Invalidate();
1179  StartTracking( nTrackFlags );
1180 
1181  if ( nTrackFlags & StartTrackingFlags::ButtonRepeat )
1182  Click();
1183 }
1184 
1186 {
1187  if ( rTEvt.IsTrackingEnded() )
1188  {
1190  {
1191  if ( !(GetStyle() & WB_NOPOINTERFOCUS) && !rTEvt.IsTrackingCanceled() )
1192  GrabFocus();
1193 
1194  if ( GetStyle() & WB_TOGGLE )
1195  {
1196  // Don't toggle, when aborted
1197  if ( !rTEvt.IsTrackingCanceled() )
1198  {
1199  if ( IsChecked() )
1200  {
1201  Check( false );
1203  }
1204  else
1205  Check();
1206  }
1207  }
1208  else
1210 
1211  Invalidate();
1212 
1213  // do not call Click handler if aborted
1214  if ( !rTEvt.IsTrackingCanceled() )
1215  {
1216  if ( ! ( GetStyle() & WB_REPEAT ) || ( GetStyle() & WB_TOGGLE ) )
1217  Click();
1218  }
1219  }
1220  }
1221  else
1222  {
1223  if ( ImplHitTestPushButton( this, rTEvt.GetMouseEvent().GetPosPixel() ) )
1224  {
1226  {
1227  if ( rTEvt.IsTrackingRepeat() && (GetStyle() & WB_REPEAT) &&
1228  ! ( GetStyle() & WB_TOGGLE ) )
1229  Click();
1230  }
1231  else
1232  {
1234  Invalidate();
1235  }
1236  }
1237  else
1238  {
1240  {
1242  Invalidate();
1243  }
1244  }
1245  }
1246 }
1247 
1248 void PushButton::KeyInput( const KeyEvent& rKEvt )
1249 {
1250  vcl::KeyCode aKeyCode = rKEvt.GetKeyCode();
1251 
1252  if ( !aKeyCode.GetModifier() &&
1253  ((aKeyCode.GetCode() == KEY_RETURN) || (aKeyCode.GetCode() == KEY_SPACE)) )
1254  {
1256  {
1258  Invalidate();
1259  }
1260 
1261  if ( ( GetStyle() & WB_REPEAT ) &&
1262  ! ( GetStyle() & WB_TOGGLE ) )
1263  Click();
1264  }
1265  else if ( (GetButtonState() & DrawButtonFlags::Pressed) && (aKeyCode.GetCode() == KEY_ESCAPE) )
1266  {
1268  Invalidate();
1269  }
1270  else
1271  Button::KeyInput( rKEvt );
1272 }
1273 
1274 void PushButton::KeyUp( const KeyEvent& rKEvt )
1275 {
1276  vcl::KeyCode aKeyCode = rKEvt.GetKeyCode();
1277 
1279  ((aKeyCode.GetCode() == KEY_RETURN) || (aKeyCode.GetCode() == KEY_SPACE)) )
1280  {
1281  if ( GetStyle() & WB_TOGGLE )
1282  {
1283  if ( IsChecked() )
1284  {
1285  Check( false );
1287  }
1288  else
1289  Check();
1290 
1291  Toggle();
1292  }
1293  else
1295 
1296  Invalidate();
1297 
1298  if ( !( GetStyle() & WB_REPEAT ) || ( GetStyle() & WB_TOGGLE ) )
1299  Click();
1300  }
1301  else
1302  Button::KeyUp( rKEvt );
1303 }
1304 
1306 {
1307  mpControlData->mpLayoutData.reset( new vcl::ControlLayoutData );
1308  const_cast<PushButton*>(this)->Invalidate();
1309 }
1310 
1312 {
1313  const Image& rCustomButtonImage = GetCustomButtonImage();
1314  if (!!rCustomButtonImage)
1315  {
1316  rRenderContext.DrawImage(Point(0, 0), rCustomButtonImage);
1317  return;
1318  }
1319  ImplDrawPushButton(rRenderContext);
1320 }
1321 
1322 void PushButton::Draw( OutputDevice* pDev, const Point& rPos,
1323  DrawFlags nFlags )
1324 {
1325  Point aPos = pDev->LogicToPixel( rPos );
1326  Size aSize = GetSizePixel();
1327  tools::Rectangle aRect( aPos, aSize );
1328  vcl::Font aFont = GetDrawPixelFont( pDev );
1329 
1330  pDev->Push();
1331  pDev->SetMapMode();
1332  pDev->SetFont( aFont );
1333  if ( nFlags & DrawFlags::Mono )
1334  {
1335  pDev->SetTextColor( COL_BLACK );
1336  }
1337  else
1338  {
1339  pDev->SetTextColor( GetTextColor() );
1340 
1341  // DecoView uses the FaceColor...
1342  AllSettings aSettings = pDev->GetSettings();
1343  StyleSettings aStyleSettings = aSettings.GetStyleSettings();
1344  if ( IsControlBackground() )
1345  aStyleSettings.SetFaceColor( GetControlBackground() );
1346  else
1347  aStyleSettings.SetFaceColor( GetSettings().GetStyleSettings().GetFaceColor() );
1348  aSettings.SetStyleSettings( aStyleSettings );
1349  pDev->OutputDevice::SetSettings( aSettings );
1350  }
1351  pDev->SetTextFillColor();
1352 
1353  DecorationView aDecoView( pDev );
1354  DrawButtonFlags nButtonStyle = DrawButtonFlags::NONE;
1355  if ( nFlags & DrawFlags::Mono )
1356  nButtonStyle |= DrawButtonFlags::Mono;
1357  if ( IsChecked() )
1358  nButtonStyle |= DrawButtonFlags::Checked;
1359  aRect = aDecoView.DrawButton( aRect, nButtonStyle );
1360 
1361  ImplDrawPushButtonContent( pDev, nFlags, aRect, true, nButtonStyle );
1362  pDev->Pop();
1363 }
1364 
1366 {
1367  Control::Resize();
1368  Invalidate();
1369 }
1370 
1372 {
1375  Button::GetFocus();
1376 }
1377 
1379 {
1380  EndSelection();
1381  HideFocus();
1383 }
1384 
1386 {
1387  Button::StateChanged( nType );
1388 
1389  if ( (nType == StateChangedType::Enable) ||
1390  (nType == StateChangedType::Text) ||
1391  (nType == StateChangedType::Data) ||
1392  (nType == StateChangedType::State) ||
1393  (nType == StateChangedType::UpdateMode) )
1394  {
1395  if ( IsReallyVisible() && IsUpdateMode() )
1396  Invalidate();
1397  }
1398  else if ( nType == StateChangedType::Style )
1399  {
1401 
1402  bool bIsDefButton = ( GetStyle() & WB_DEFBUTTON ) != 0;
1403  bool bWasDefButton = ( GetPrevStyle() & WB_DEFBUTTON ) != 0;
1404  if ( bIsDefButton != bWasDefButton )
1405  ImplSetDefButton( bIsDefButton );
1406 
1407  if ( IsReallyVisible() && IsUpdateMode() )
1408  {
1409  if ( (GetPrevStyle() & PUSHBUTTON_VIEW_STYLE) !=
1411  Invalidate();
1412  }
1413  }
1414  else if ( (nType == StateChangedType::Zoom) ||
1415  (nType == StateChangedType::ControlFont) )
1416  {
1417  ImplInitSettings( false );
1418  Invalidate();
1419  }
1420  else if ( nType == StateChangedType::ControlForeground )
1421  {
1422  ImplInitSettings( false );
1423  Invalidate();
1424  }
1425  else if ( nType == StateChangedType::ControlBackground )
1426  {
1427  ImplInitSettings( true );
1428  Invalidate();
1429  }
1430 }
1431 
1433 {
1434  Button::DataChanged( rDCEvt );
1435 
1436  if ( (rDCEvt.GetType() == DataChangedEventType::FONTS) ||
1438  ((rDCEvt.GetType() == DataChangedEventType::SETTINGS) &&
1439  (rDCEvt.GetFlags() & AllSettingsFlags::STYLE)) )
1440  {
1441  ImplInitSettings( true );
1442  Invalidate();
1443  }
1444 }
1445 
1447 {
1448  if( rNEvt.GetType() == MouseNotifyEvent::MOUSEMOVE )
1449  {
1450  const MouseEvent* pMouseEvt = rNEvt.GetMouseEvent();
1451  if( pMouseEvt && (pMouseEvt->IsEnterWindow() || pMouseEvt->IsLeaveWindow()) )
1452  {
1453  // trigger redraw as mouse over state has changed
1454 
1455  // TODO: move this to Window class or make it a member !!!
1456  ControlType aCtrlType = ControlType::Generic;
1457  switch( GetParent()->GetType() )
1458  {
1459  case WindowType::LISTBOX:
1460  case WindowType::MULTILISTBOX:
1461  case WindowType::TREELISTBOX:
1462  aCtrlType = ControlType::Listbox;
1463  break;
1464 
1465  case WindowType::COMBOBOX:
1466  case WindowType::PATTERNBOX:
1467  case WindowType::NUMERICBOX:
1468  case WindowType::METRICBOX:
1469  case WindowType::CURRENCYBOX:
1470  case WindowType::DATEBOX:
1471  case WindowType::TIMEBOX:
1472  case WindowType::LONGCURRENCYBOX:
1473  aCtrlType = ControlType::Combobox;
1474  break;
1475  default:
1476  break;
1477  }
1478 
1479  bool bDropDown = ( IsSymbol() && (GetSymbol()==SymbolType::SPIN_DOWN) && GetText().isEmpty() );
1480 
1481  if( bDropDown && GetParent()->IsNativeControlSupported( aCtrlType, ControlPart::Entire) &&
1483  {
1485  if(aCtrlType == ControlType::Combobox)
1486  {
1487  // only paint the button part to avoid flickering of the combobox text
1488  tools::Rectangle aClipRect( Point(), GetOutputSizePixel() );
1489  aClipRect.SetPos(pBorder->ScreenToOutputPixel(OutputToScreenPixel(aClipRect.TopLeft())));
1490  pBorder->Invalidate( aClipRect );
1491  }
1492  else
1493  {
1495  }
1496  }
1497  else if( (GetStyle() & WB_FLATBUTTON) ||
1499  {
1500  Invalidate();
1501  }
1502  }
1503  }
1504 
1505  return Button::PreNotify(rNEvt);
1506 }
1507 
1509 {
1511 }
1512 
1514 {
1515  if ( meSymbol != eSymbol )
1516  {
1517  meSymbol = eSymbol;
1519  }
1520 }
1521 
1523 {
1524  ImplSetSymbolAlign( eAlign );
1525 }
1526 
1528 {
1529  if ( mnDDStyle != nStyle )
1530  {
1531  mnDDStyle = nStyle;
1533  }
1534 }
1535 
1537 {
1538  if ( meState == eState )
1539  return;
1540 
1541  meState = eState;
1542  if ( meState == TRISTATE_FALSE )
1544  else if ( meState == TRISTATE_TRUE )
1545  {
1546  GetButtonState() &= ~DrawButtonFlags::DontKnow;
1548  }
1549  else // TRISTATE_INDET
1550  {
1551  GetButtonState() &= ~DrawButtonFlags::Checked;
1553  }
1554 
1556  Toggle();
1557 }
1558 
1559 void PushButton::statusChanged(const css::frame::FeatureStateEvent& rEvent)
1560 {
1561  Button::statusChanged(rEvent);
1562  if (rEvent.State.has<bool>())
1563  SetPressed(rEvent.State.get<bool>());
1564 }
1565 
1566 void PushButton::SetPressed( bool bPressed )
1567 {
1568  if ( mbPressed != bPressed )
1569  {
1570  mbPressed = bPressed;
1572  }
1573 }
1574 
1576 {
1578  if ( !IsDisposed() &&
1580  {
1582  if ( !mbPressed )
1583  Invalidate();
1584  }
1585 }
1586 
1588 {
1589  Size aSize;
1590 
1591  if ( IsSymbol() )
1592  {
1593  if ( IsSmallSymbol ())
1594  aSize = Size( 16, 12 );
1595  else
1596  aSize = Size( 26, 24 );
1597  }
1598  else if ( Button::HasImage() )
1599  aSize = GetModeImage().GetSizePixel();
1602  {
1603  tools::Long nSymbolSize = GetTextHeight() / 2 + 1;
1604  aSize.AdjustWidth(2*nSymbolSize );
1605  }
1606  if (!PushButton::GetText().isEmpty())
1607  {
1608  Size textSize = GetTextRect( tools::Rectangle( Point(), Size( 0x7fffffff, 0x7fffffff ) ),
1610  aSize.AdjustWidth(textSize.Width() );
1611  aSize.setHeight( std::max( aSize.Height(), tools::Long( textSize.Height() * 1.15 ) ) );
1612  }
1613 
1614  // cf. ImplDrawPushButton ...
1615  if( (GetStyle() & WB_SMALLSTYLE) == 0 )
1616  {
1617  aSize.AdjustWidth(24 );
1618  aSize.AdjustHeight(12 );
1619  }
1620 
1621  return CalcWindowSize( aSize );
1622 }
1623 
1625 {
1626  return CalcMinimumSize();
1627 }
1628 
1629 bool PushButton::set_property(const OString &rKey, const OUString &rValue)
1630 {
1631  if (rKey == "has-default")
1632  {
1633  WinBits nBits = GetStyle();
1634  nBits &= ~WB_DEFBUTTON;
1635  if (toBool(rValue))
1636  nBits |= WB_DEFBUTTON;
1637  SetStyle(nBits);
1638  }
1639  else
1640  return Button::set_property(rKey, rValue);
1641  return true;
1642 }
1643 
1645 {
1647  {
1648  PushButtonValue aControlValue;
1649  aControlValue.mbIsAction = isAction();
1652  ControlState::FOCUSED, aControlValue, OUString());
1653  }
1654  Button::ShowFocus(rRect);
1655 }
1656 
1657 void OKButton::ImplInit( vcl::Window* pParent, WinBits nStyle )
1658 {
1659  set_id("ok");
1660  PushButton::ImplInit( pParent, nStyle );
1661 
1662  SetText( GetStandardText( StandardButtonType::OK ) );
1663 }
1664 
1667 {
1668  ImplInit( pParent, nStyle );
1669 }
1670 
1672 {
1673  // close parent if no link set
1674  if ( !GetClickHdl() )
1675  {
1676  vcl::Window* pParent = getNonLayoutParent(this);
1677  if ( pParent->IsSystemWindow() )
1678  {
1679  if ( pParent->IsDialog() )
1680  {
1681  VclPtr<Dialog> xParent( static_cast<Dialog*>(pParent) );
1682  if ( xParent->IsInExecute() )
1683  xParent->EndDialog( RET_OK );
1684  // prevent recursive calls
1685  else if ( !xParent->IsInClose() )
1686  {
1687  if ( pParent->GetStyle() & WB_CLOSEABLE )
1688  xParent->Close();
1689  }
1690  }
1691  else
1692  {
1693  if ( pParent->GetStyle() & WB_CLOSEABLE )
1694  static_cast<SystemWindow*>(pParent)->Close();
1695  }
1696  }
1697  }
1698  else
1699  {
1701  }
1702 }
1703 
1705 {
1706  set_id("cancel");
1707  PushButton::ImplInit( pParent, nStyle );
1708 
1709  SetText( GetStandardText( StandardButtonType::Cancel ) );
1710 }
1711 
1714 {
1715  ImplInit( pParent, nStyle );
1716 }
1717 
1719 {
1720  // close parent if link not set
1721  if ( !GetClickHdl() )
1722  {
1723  vcl::Window* pParent = getNonLayoutParent(this);
1724  if ( pParent->IsSystemWindow() )
1725  {
1726  if ( pParent->IsDialog() )
1727  {
1728  if ( static_cast<Dialog*>(pParent)->IsInExecute() )
1729  static_cast<Dialog*>(pParent)->EndDialog();
1730  // prevent recursive calls
1731  else if ( !static_cast<Dialog*>(pParent)->IsInClose() )
1732  {
1733  if ( pParent->GetStyle() & WB_CLOSEABLE )
1734  static_cast<Dialog*>(pParent)->Close();
1735  }
1736  }
1737  else
1738  {
1739  if ( pParent->GetStyle() & WB_CLOSEABLE )
1740  static_cast<SystemWindow*>(pParent)->Close();
1741  }
1742  }
1743  }
1744  else
1745  {
1747  }
1748 }
1749 
1751  : CancelButton(pParent, nStyle)
1752 {
1753  SetText( GetStandardText( StandardButtonType::Close ) );
1754 }
1755 
1756 void HelpButton::ImplInit( vcl::Window* pParent, WinBits nStyle )
1757 {
1758  set_id("help");
1759  PushButton::ImplInit( pParent, nStyle | WB_NOPOINTERFOCUS );
1760 
1761  SetText( GetStandardText( StandardButtonType::Help ) );
1762 }
1763 
1766 {
1767  ImplInit( pParent, nStyle );
1768 }
1769 
1771 {
1772  // trigger help if no link set
1773  if ( !GetClickHdl() )
1774  {
1776  if ( !pFocusWin || comphelper::LibreOfficeKit::isActive() )
1777  pFocusWin = this;
1778 
1779  HelpEvent aEvt( pFocusWin->GetPointerPosPixel(), HelpEventMode::CONTEXT );
1780  pFocusWin->RequestHelp( aEvt );
1781  }
1783 }
1784 
1786 {
1787  // Hide when we have no help URL.
1789  officecfg::Office::Common::Help::HelpRootURL::get().isEmpty())
1790  Hide();
1791  else
1792  PushButton::StateChanged(nStateChange);
1793 }
1794 
1796 {
1797  mbChecked = false;
1798  mbRadioCheck = true;
1799  mbStateChanged = false;
1800 }
1801 
1803 {
1804  nStyle = ImplInitStyle(getPreviousSibling(pParent), nStyle);
1805  Button::ImplInit( pParent, nStyle, nullptr );
1806 
1807  ImplInitSettings( true );
1808 }
1809 
1811 {
1812  if ( !(nStyle & WB_NOGROUP) &&
1813  (!pPrevWindow || (pPrevWindow->GetType() != WindowType::RADIOBUTTON)) )
1814  nStyle |= WB_GROUP;
1815  if ( !(nStyle & WB_NOTABSTOP) )
1816  {
1817  if ( IsChecked() )
1818  nStyle |= WB_TABSTOP;
1819  else
1820  nStyle &= ~WB_TABSTOP;
1821  }
1822 
1823  return nStyle;
1824 }
1825 
1827 {
1828  return _rStyle.GetRadioCheckFont();
1829 }
1830 
1832 {
1833  return _rStyle.GetRadioCheckTextColor();
1834 }
1835 
1836 void RadioButton::ImplInitSettings( bool bBackground )
1837 {
1839 
1840  if ( !bBackground )
1841  return;
1842 
1843  vcl::Window* pParent = GetParent();
1844  if ( !IsControlBackground() &&
1846  {
1849  SetPaintTransparent( true );
1850  SetBackground();
1852  mpWindowImpl->mbUseNativeFocus = ImplGetSVData()->maNWFData.mbNoFocusRects;
1853  }
1854  else
1855  {
1856  EnableChildTransparentMode( false );
1858  SetPaintTransparent( false );
1859 
1860  if ( IsControlBackground() )
1862  else
1863  SetBackground( pParent->GetBackground() );
1864  }
1865 }
1866 
1868 {
1869  bool bNativeOK = false;
1870 
1871  // no native drawing for image radio buttons
1873  {
1877 
1879  nState |= ControlState::PRESSED;
1880  if (HasFocus())
1881  nState |= ControlState::FOCUSED;
1883  nState |= ControlState::DEFAULT;
1884  if (IsEnabled())
1885  nState |= ControlState::ENABLED;
1886 
1888  nState |= ControlState::ROLLOVER;
1889 
1890  bNativeOK = rRenderContext.DrawNativeControl(ControlType::Radiobutton, ControlPart::Entire, aCtrlRect,
1891  nState, aControlValue, OUString());
1892  }
1893 
1894  if (bNativeOK)
1895  return;
1896 
1897  if (!maImage)
1898  {
1899  DrawButtonFlags nStyle = GetButtonState();
1900  if (!IsEnabled())
1901  nStyle |= DrawButtonFlags::Disabled;
1902  if (mbChecked)
1903  nStyle |= DrawButtonFlags::Checked;
1904  Image aImage = GetRadioImage(rRenderContext.GetSettings(), nStyle);
1905  if (IsZoom())
1906  rRenderContext.DrawImage(maStateRect.TopLeft(), maStateRect.GetSize(), aImage);
1907  else
1908  rRenderContext.DrawImage(maStateRect.TopLeft(), aImage);
1909  }
1910  else
1911  {
1912  HideFocus();
1913 
1914  DecorationView aDecoView(&rRenderContext);
1915  const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
1916  tools::Rectangle aImageRect = maStateRect;
1917  Size aImageSize = maImage.GetSizePixel();
1918  bool bEnabled = IsEnabled();
1919 
1920  aImageSize.setWidth( CalcZoom(aImageSize.Width()) );
1921  aImageSize.setHeight( CalcZoom(aImageSize.Height()) );
1922 
1923  aImageRect.AdjustLeft( 1 );
1924  aImageRect.AdjustTop( 1 );
1925  aImageRect.AdjustRight( -1 );
1926  aImageRect.AdjustBottom( -1 );
1927 
1928  // display border and selection status
1929  aImageRect = aDecoView.DrawFrame(aImageRect, DrawFrameStyle::DoubleIn);
1930  if ((GetButtonState() & DrawButtonFlags::Pressed) || !bEnabled)
1931  rRenderContext.SetFillColor( rStyleSettings.GetFaceColor());
1932  else
1933  rRenderContext.SetFillColor(rStyleSettings.GetFieldColor());
1934  rRenderContext.SetLineColor();
1935  rRenderContext.DrawRect(aImageRect);
1936 
1937  // display image
1938  DrawImageFlags nImageStyle = DrawImageFlags::NONE;
1939  if (!bEnabled)
1940  nImageStyle |= DrawImageFlags::Disable;
1941 
1942  Image* pImage = &maImage;
1943 
1944  Point aImagePos(aImageRect.TopLeft());
1945  aImagePos.AdjustX((aImageRect.GetWidth() - aImageSize.Width()) / 2 );
1946  aImagePos.AdjustY((aImageRect.GetHeight() - aImageSize.Height()) / 2 );
1947  if (IsZoom())
1948  rRenderContext.DrawImage(aImagePos, aImageSize, *pImage, nImageStyle);
1949  else
1950  rRenderContext.DrawImage(aImagePos, *pImage, nImageStyle);
1951 
1952  aImageRect.AdjustLeft( 1 );
1953  aImageRect.AdjustTop( 1 );
1954  aImageRect.AdjustRight( -1 );
1955  aImageRect.AdjustBottom( -1 );
1956 
1957  ImplSetFocusRect(aImageRect);
1958 
1959  if (mbChecked)
1960  {
1961  rRenderContext.SetLineColor(rStyleSettings.GetHighlightColor());
1962  rRenderContext.SetFillColor();
1963  if ((aImageSize.Width() >= 20) || (aImageSize.Height() >= 20))
1964  {
1965  aImageRect.AdjustLeft( 1 );
1966  aImageRect.AdjustTop( 1 );
1967  aImageRect.AdjustRight( -1 );
1968  aImageRect.AdjustBottom( -1 );
1969  }
1970  rRenderContext.DrawRect(aImageRect);
1971  aImageRect.AdjustLeft( 1 );
1972  aImageRect.AdjustTop( 1 );
1973  aImageRect.AdjustRight( -1 );
1974  aImageRect.AdjustBottom( -1 );
1975  rRenderContext.DrawRect(aImageRect);
1976  }
1977 
1978  if (HasFocus())
1980  }
1981 }
1982 
1984  const Point& rPos, const Size& rSize,
1985  const Size& rImageSize, tools::Rectangle& rStateRect,
1986  tools::Rectangle& rMouseRect )
1987 {
1988  WinBits nWinStyle = GetStyle();
1989  OUString aText( GetText() );
1990 
1991  pDev->Push( PushFlags::CLIPREGION );
1992  pDev->IntersectClipRegion( tools::Rectangle( rPos, rSize ) );
1993 
1994  // no image radio button
1995  if ( !maImage )
1996  {
1997  if (!aText.isEmpty() || HasImage())
1998  {
1999  DrawTextFlags nTextStyle = Button::ImplGetTextStyle( nWinStyle, nDrawFlags );
2000 
2001  const tools::Long nImageSep = GetDrawPixel( pDev, ImplGetImageToTextDistance() );
2002  Size aSize( rSize );
2003  Point aPos( rPos );
2004  aPos.AdjustX(rImageSize.Width() + nImageSep );
2005  aSize.AdjustWidth( -(rImageSize.Width() + nImageSep) );
2006 
2007  // if the text rect height is smaller than the height of the image
2008  // then for single lines the default should be centered text
2009  if( (nWinStyle & (WB_TOP|WB_VCENTER|WB_BOTTOM)) == 0 &&
2010  (rImageSize.Height() > rSize.Height() || ! (nWinStyle & WB_WORDBREAK) ) )
2011  {
2013  nTextStyle |= DrawTextFlags::VCenter;
2014  aSize.setHeight( rImageSize.Height() );
2015  }
2016 
2017  ImplDrawAlignedImage( pDev, aPos, aSize, 1, nTextStyle );
2018 
2019  rMouseRect = tools::Rectangle(aPos, aSize);
2020  rMouseRect.SetLeft(rPos.X());
2021  rMouseRect.SetTop(rPos.Y());
2022 
2023  rStateRect.SetLeft( rPos.X() );
2024  rStateRect.SetTop( rMouseRect.Top() );
2025 
2026  if ( aSize.Height() > rImageSize.Height() )
2027  rStateRect.AdjustTop(( aSize.Height() - rImageSize.Height() ) / 2 );
2028  else
2029  {
2030  rStateRect.AdjustTop( -(( rImageSize.Height() - aSize.Height() ) / 2) );
2031  if( rStateRect.Top() < 0 )
2032  rStateRect.SetTop( 0 );
2033  }
2034 
2035  rStateRect.SetRight( rStateRect.Left() + rImageSize.Width()-1 );
2036  rStateRect.SetBottom( rStateRect.Top() + rImageSize.Height()-1 );
2037 
2038  if ( rStateRect.Bottom() > rMouseRect.Bottom() )
2039  rMouseRect.SetBottom( rStateRect.Bottom() );
2040  }
2041  else
2042  {
2043  rStateRect.SetLeft( rPos.X() );
2044  if ( nWinStyle & WB_VCENTER )
2045  rStateRect.SetTop( rPos.Y()+((rSize.Height()-rImageSize.Height())/2) );
2046  else if ( nWinStyle & WB_BOTTOM )
2047  rStateRect.SetTop( rPos.Y()+rSize.Height()-rImageSize.Height() ); //-1;
2048  else
2049  rStateRect.SetTop( rPos.Y() );
2050  rStateRect.SetRight( rStateRect.Left()+rImageSize.Width()-1 );
2051  rStateRect.SetBottom( rStateRect.Top()+rImageSize.Height()-1 );
2052  rMouseRect = rStateRect;
2053 
2054  ImplSetFocusRect( rStateRect );
2055  }
2056  }
2057  else
2058  {
2059  bool bTopImage = (nWinStyle & WB_TOP) != 0;
2060  Size aImageSize = maImage.GetSizePixel();
2061  tools::Rectangle aImageRect( rPos, rSize );
2062  tools::Long nTextHeight = pDev->GetTextHeight();
2063  tools::Long nTextWidth = pDev->GetCtrlTextWidth( aText );
2064 
2065  // calculate position and sizes
2066  if (!aText.isEmpty())
2067  {
2068  Size aTmpSize( (aImageSize.Width()+8), (aImageSize.Height()+8) );
2069  if ( bTopImage )
2070  {
2071  aImageRect.SetLeft( (rSize.Width()-aTmpSize.Width())/2 );
2072  aImageRect.SetTop( (rSize.Height()-(aTmpSize.Height()+nTextHeight+6))/2 );
2073  }
2074  else
2075  aImageRect.SetTop( (rSize.Height()-aTmpSize.Height())/2 );
2076 
2077  aImageRect.SetRight( aImageRect.Left()+aTmpSize.Width() );
2078  aImageRect.SetBottom( aImageRect.Top()+aTmpSize.Height() );
2079 
2080  // display text
2081  Point aTxtPos = rPos;
2082  if ( bTopImage )
2083  {
2084  aTxtPos.AdjustX((rSize.Width()-nTextWidth)/2 );
2085  aTxtPos.AdjustY(aImageRect.Bottom()+6 );
2086  }
2087  else
2088  {
2089  aTxtPos.AdjustX(aImageRect.Right()+8 );
2090  aTxtPos.AdjustY((rSize.Height()-nTextHeight)/2 );
2091  }
2092  pDev->DrawCtrlText( aTxtPos, aText, 0, aText.getLength() );
2093  }
2094 
2095  rMouseRect = aImageRect;
2096  rStateRect = aImageRect;
2097  }
2098 
2099  pDev->Pop();
2100 }
2101 
2103 {
2104  HideFocus();
2105 
2106  Size aImageSize;
2107  if (!maImage)
2108  aImageSize = ImplGetRadioImageSize();
2109  else
2110  aImageSize = maImage.GetSizePixel();
2111 
2112  aImageSize.setWidth( CalcZoom(aImageSize.Width()) );
2113  aImageSize.setHeight( CalcZoom(aImageSize.Height()) );
2114 
2115  // Draw control text
2116  ImplDraw(&rRenderContext, DrawFlags::NONE, Point(), GetOutputSizePixel(),
2117  aImageSize, maStateRect, maMouseRect);
2118 
2119  if (!maImage && HasFocus())
2121 
2122  ImplDrawRadioButtonState(rRenderContext);
2123 }
2124 
2126 {
2127  if (&rOther == this)
2128  return;
2129 
2130  if (!m_xGroup)
2131  {
2132  m_xGroup = std::make_shared<std::vector<VclPtr<RadioButton> >>();
2133  m_xGroup->push_back(this);
2134  }
2135 
2136  auto aFind = std::find(m_xGroup->begin(), m_xGroup->end(), VclPtr<RadioButton>(&rOther));
2137  if (aFind == m_xGroup->end())
2138  {
2139  m_xGroup->push_back(&rOther);
2140 
2141  if (rOther.m_xGroup)
2142  {
2143  std::vector< VclPtr<RadioButton> > aOthers(rOther.GetRadioButtonGroup(false));
2144  //make all members of the group share the same button group
2145  for (auto const& elem : aOthers)
2146  {
2147  aFind = std::find(m_xGroup->begin(), m_xGroup->end(), elem);
2148  if (aFind == m_xGroup->end())
2149  m_xGroup->push_back(elem);
2150  }
2151  }
2152 
2153  //make all members of the group share the same button group
2154  for (VclPtr<RadioButton> const & pButton : *m_xGroup)
2155  {
2156  pButton->m_xGroup = m_xGroup;
2157  }
2158  }
2159 
2160  //if this one is checked, uncheck all the others
2161  if (mbChecked)
2163 }
2164 
2165 std::vector< VclPtr<RadioButton> > RadioButton::GetRadioButtonGroup(bool bIncludeThis) const
2166 {
2167  if (m_xGroup)
2168  {
2169  if (bIncludeThis)
2170  return *m_xGroup;
2171  std::vector< VclPtr<RadioButton> > aGroup;
2172  for (VclPtr<RadioButton> const & pRadioButton : *m_xGroup)
2173  {
2174  if (pRadioButton == this)
2175  continue;
2176  aGroup.push_back(pRadioButton);
2177  }
2178  return aGroup;
2179  }
2180 
2181  std::vector<VclPtr<RadioButton>> aGroup;
2182  if (mbUsesExplicitGroup)
2183  return aGroup;
2184 
2185  //old-school
2186 
2187  // go back to first in group;
2188  vcl::Window* pFirst = const_cast<RadioButton*>(this);
2189  while( ( pFirst->GetStyle() & WB_GROUP ) == 0 )
2190  {
2191  vcl::Window* pWindow = pFirst->GetWindow( GetWindowType::Prev );
2192  if( pWindow )
2193  pFirst = pWindow;
2194  else
2195  break;
2196  }
2197  // insert radiobuttons up to next group
2198  do
2199  {
2200  if( pFirst->GetType() == WindowType::RADIOBUTTON )
2201  {
2202  if( pFirst != this || bIncludeThis )
2203  aGroup.emplace_back(static_cast<RadioButton*>(pFirst) );
2204  }
2205  pFirst = pFirst->GetWindow( GetWindowType::Next );
2206  } while( pFirst && ( ( pFirst->GetStyle() & WB_GROUP ) == 0 ) );
2207 
2208  return aGroup;
2209 }
2210 
2212 {
2213  mpWindowImpl->mnStyle |= WB_TABSTOP;
2214 
2215  std::vector<VclPtr<RadioButton> > aGroup(GetRadioButtonGroup(false));
2216  // iterate over radio button group and checked buttons
2217  for (VclPtr<RadioButton>& pWindow : aGroup)
2218  {
2219  if ( pWindow->IsChecked() )
2220  {
2221  pWindow->SetState( false );
2222  if ( pWindow->IsDisposed() )
2223  return;
2224  }
2225 
2226  // not inside if clause to always remove wrongly set WB_TABSTOPS
2227  pWindow->mpWindowImpl->mnStyle &= ~WB_TABSTOP;
2228  }
2229 }
2230 
2231 void RadioButton::ImplCallClick( bool bGrabFocus, GetFocusFlags nFocusFlags )
2232 {
2234  mbChecked = true;
2235  mpWindowImpl->mnStyle |= WB_TABSTOP;
2236  Invalidate();
2237  VclPtr<vcl::Window> xWindow = this;
2238  if ( mbRadioCheck )
2240  if ( xWindow->IsDisposed() )
2241  return;
2242  if ( bGrabFocus )
2243  ImplGrabFocus( nFocusFlags );
2244  if ( xWindow->IsDisposed() )
2245  return;
2246  if ( mbStateChanged )
2247  Toggle();
2248  if ( xWindow->IsDisposed() )
2249  return;
2250  Click();
2251  if ( xWindow->IsDisposed() )
2252  return;
2253  mbStateChanged = false;
2254 }
2255 
2256 RadioButton::RadioButton(vcl::Window* pParent, bool bUsesExplicitGroup, WinBits nStyle)
2258  , mbUsesExplicitGroup(bUsesExplicitGroup)
2259 {
2261  ImplInit( pParent, nStyle );
2262 }
2263 
2265 {
2266  disposeOnce();
2267 }
2268 
2270 {
2271  if (m_xGroup)
2272  {
2273  m_xGroup->erase(std::remove(m_xGroup->begin(), m_xGroup->end(), VclPtr<RadioButton>(this)),
2274  m_xGroup->end());
2275  m_xGroup.reset();
2276  }
2277  Button::dispose();
2278 }
2279 
2281 {
2282  if ( rMEvt.IsLeft() && maMouseRect.IsInside( rMEvt.GetPosPixel() ) )
2283  {
2285  Invalidate();
2286  StartTracking();
2287  return;
2288  }
2289 
2290  Button::MouseButtonDown( rMEvt );
2291 }
2292 
2294 {
2295  if ( rTEvt.IsTrackingEnded() )
2296  {
2298  {
2299  if ( !(GetStyle() & WB_NOPOINTERFOCUS) && !rTEvt.IsTrackingCanceled() )
2300  GrabFocus();
2301 
2303 
2304  // do not call click handler if aborted
2305  if ( !rTEvt.IsTrackingCanceled() )
2306  ImplCallClick();
2307  else
2308  {
2309  Invalidate();
2310  }
2311  }
2312  }
2313  else
2314  {
2315  if ( maMouseRect.IsInside( rTEvt.GetMouseEvent().GetPosPixel() ) )
2316  {
2318  {
2320  Invalidate();
2321  }
2322  }
2323  else
2324  {
2326  {
2328  Invalidate();
2329  }
2330  }
2331  }
2332 }
2333 
2334 void RadioButton::KeyInput( const KeyEvent& rKEvt )
2335 {
2336  vcl::KeyCode aKeyCode = rKEvt.GetKeyCode();
2337 
2338  if ( !aKeyCode.GetModifier() && (aKeyCode.GetCode() == KEY_SPACE) )
2339  {
2341  {
2343  Invalidate();
2344  }
2345  }
2346  else if ( (GetButtonState() & DrawButtonFlags::Pressed) && (aKeyCode.GetCode() == KEY_ESCAPE) )
2347  {
2349  Invalidate();
2350  }
2351  else
2352  Button::KeyInput( rKEvt );
2353 }
2354 
2355 void RadioButton::KeyUp( const KeyEvent& rKEvt )
2356 {
2357  vcl::KeyCode aKeyCode = rKEvt.GetKeyCode();
2358 
2359  if ( (GetButtonState() & DrawButtonFlags::Pressed) && (aKeyCode.GetCode() == KEY_SPACE) )
2360  {
2362  ImplCallClick();
2363  }
2364  else
2365  Button::KeyUp( rKEvt );
2366 }
2367 
2369 {
2370  mpControlData->mpLayoutData.reset( new vcl::ControlLayoutData );
2371  const_cast<RadioButton*>(this)->Invalidate();
2372 }
2373 
2375 {
2376  ImplDrawRadioButton(rRenderContext);
2377 }
2378 
2379 void RadioButton::Draw( OutputDevice* pDev, const Point& rPos,
2380  DrawFlags nFlags )
2381 {
2382  if ( !maImage )
2383  {
2384  MapMode aResMapMode( MapUnit::Map100thMM );
2385  Point aPos = pDev->LogicToPixel( rPos );
2386  Size aSize = GetSizePixel();
2387  Size aImageSize = pDev->LogicToPixel( Size( 300, 300 ), aResMapMode );
2388  Size aBrd1Size = pDev->LogicToPixel( Size( 20, 20 ), aResMapMode );
2389  Size aBrd2Size = pDev->LogicToPixel( Size( 60, 60 ), aResMapMode );
2390  vcl::Font aFont = GetDrawPixelFont( pDev );
2391  tools::Rectangle aStateRect;
2392  tools::Rectangle aMouseRect;
2393 
2394  aImageSize.setWidth( CalcZoom( aImageSize.Width() ) );
2395  aImageSize.setHeight( CalcZoom( aImageSize.Height() ) );
2396  aBrd1Size.setWidth( CalcZoom( aBrd1Size.Width() ) );
2397  aBrd1Size.setHeight( CalcZoom( aBrd1Size.Height() ) );
2398  aBrd2Size.setWidth( CalcZoom( aBrd2Size.Width() ) );
2399  aBrd2Size.setHeight( CalcZoom( aBrd2Size.Height() ) );
2400 
2401  if ( !aBrd1Size.Width() )
2402  aBrd1Size.setWidth( 1 );
2403  if ( !aBrd1Size.Height() )
2404  aBrd1Size.setHeight( 1 );
2405  if ( !aBrd2Size.Width() )
2406  aBrd2Size.setWidth( 1 );
2407  if ( !aBrd2Size.Height() )
2408  aBrd2Size.setHeight( 1 );
2409 
2410  pDev->Push();
2411  pDev->SetMapMode();
2412  pDev->SetFont( aFont );
2413  if ( nFlags & DrawFlags::Mono )
2414  pDev->SetTextColor( COL_BLACK );
2415  else
2416  pDev->SetTextColor( GetTextColor() );
2417  pDev->SetTextFillColor();
2418 
2419  ImplDraw( pDev, nFlags, aPos, aSize,
2420  aImageSize, aStateRect, aMouseRect );
2421 
2422  Point aCenterPos = aStateRect.Center();
2423  tools::Long nRadX = aImageSize.Width()/2;
2424  tools::Long nRadY = aImageSize.Height()/2;
2425 
2426  pDev->SetLineColor();
2427  pDev->SetFillColor( COL_BLACK );
2428  pDev->DrawPolygon( tools::Polygon( aCenterPos, nRadX, nRadY ) );
2429  nRadX -= aBrd1Size.Width();
2430  nRadY -= aBrd1Size.Height();
2431  pDev->SetFillColor( COL_WHITE );
2432  pDev->DrawPolygon( tools::Polygon( aCenterPos, nRadX, nRadY ) );
2433  if ( mbChecked )
2434  {
2435  nRadX -= aBrd1Size.Width();
2436  nRadY -= aBrd1Size.Height();
2437  if ( !nRadX )
2438  nRadX = 1;
2439  if ( !nRadY )
2440  nRadY = 1;
2441  pDev->SetFillColor( COL_BLACK );
2442  pDev->DrawPolygon( tools::Polygon( aCenterPos, nRadX, nRadY ) );
2443  }
2444 
2445  pDev->Pop();
2446  }
2447  else
2448  {
2449  OSL_FAIL( "RadioButton::Draw() - not implemented for RadioButton with Image" );
2450  }
2451 }
2452 
2454 {
2455  Control::Resize();
2456  Invalidate();
2457 }
2458 
2460 {
2463  Button::GetFocus();
2464 }
2465 
2467 {
2469  {
2471  Invalidate();
2472  }
2473 
2474  HideFocus();
2476 }
2477 
2479 {
2480  Button::StateChanged( nType );
2481 
2482  if ( nType == StateChangedType::State )
2483  {
2484  if ( IsReallyVisible() && IsUpdateMode() )
2486  }
2487  else if ( (nType == StateChangedType::Enable) ||
2488  (nType == StateChangedType::Text) ||
2489  (nType == StateChangedType::Data) ||
2490  (nType == StateChangedType::UpdateMode) )
2491  {
2492  if ( IsUpdateMode() )
2493  Invalidate();
2494  }
2495  else if ( nType == StateChangedType::Style )
2496  {
2498 
2499  if ( (GetPrevStyle() & RADIOBUTTON_VIEW_STYLE) !=
2501  {
2502  if ( IsUpdateMode() )
2503  Invalidate();
2504  }
2505  }
2506  else if ( (nType == StateChangedType::Zoom) ||
2507  (nType == StateChangedType::ControlFont) )
2508  {
2509  ImplInitSettings( false );
2510  Invalidate();
2511  }
2512  else if ( nType == StateChangedType::ControlForeground )
2513  {
2514  ImplInitSettings( false );
2515  Invalidate();
2516  }
2517  else if ( nType == StateChangedType::ControlBackground )
2518  {
2519  ImplInitSettings( true );
2520  Invalidate();
2521  }
2522 }
2523 
2525 {
2526  Button::DataChanged( rDCEvt );
2527 
2528  if ( (rDCEvt.GetType() == DataChangedEventType::FONTS) ||
2530  ((rDCEvt.GetType() == DataChangedEventType::SETTINGS) &&
2531  (rDCEvt.GetFlags() & AllSettingsFlags::STYLE)) )
2532  {
2533  ImplInitSettings( true );
2534  Invalidate();
2535  }
2536 }
2537 
2539 {
2540  if( rNEvt.GetType() == MouseNotifyEvent::MOUSEMOVE )
2541  {
2542  const MouseEvent* pMouseEvt = rNEvt.GetMouseEvent();
2543  if( pMouseEvt && !pMouseEvt->GetButtons() && !pMouseEvt->IsSynthetic() && !pMouseEvt->IsModifierChanged() )
2544  {
2545  // trigger redraw if mouse over state has changed
2547  {
2549  pMouseEvt->IsLeaveWindow() || pMouseEvt->IsEnterWindow())
2550  {
2552  }
2553  }
2554  }
2555  }
2556 
2557  return Button::PreNotify(rNEvt);
2558 }
2559 
2561 {
2563 }
2564 
2566 {
2567  if ( rImage != maImage )
2568  {
2569  maImage = rImage;
2571  queue_resize();
2572  }
2573 }
2574 
2575 
2576 void RadioButton::SetState( bool bCheck )
2577 {
2578  // carry the TabStop flag along correctly
2579  if ( bCheck )
2580  mpWindowImpl->mnStyle |= WB_TABSTOP;
2581  else
2582  mpWindowImpl->mnStyle &= ~WB_TABSTOP;
2583 
2584  if ( mbChecked != bCheck )
2585  {
2586  mbChecked = bCheck;
2588  Toggle();
2589  }
2590 }
2591 
2592 bool RadioButton::set_property(const OString &rKey, const OUString &rValue)
2593 {
2594  if (rKey == "active")
2595  SetState(toBool(rValue));
2596  else if (rKey == "image-position")
2597  {
2598  WinBits nBits = GetStyle();
2599  if (rValue == "left")
2600  {
2601  nBits &= ~(WB_CENTER | WB_RIGHT);
2602  nBits |= WB_LEFT;
2603  }
2604  else if (rValue == "right")
2605  {
2606  nBits &= ~(WB_CENTER | WB_LEFT);
2607  nBits |= WB_RIGHT;
2608  }
2609  else if (rValue == "top")
2610  {
2611  nBits &= ~(WB_VCENTER | WB_BOTTOM);
2612  nBits |= WB_TOP;
2613  }
2614  else if (rValue == "bottom")
2615  {
2616  nBits &= ~(WB_VCENTER | WB_TOP);
2617  nBits |= WB_BOTTOM;
2618  }
2619  //It's rather mad to have to set these bits when there is the other
2620  //image align. Looks like e.g. the radiobuttons etc weren't converted
2621  //over to image align fully.
2622  SetStyle(nBits);
2623  //Deliberate to set the sane ImageAlign property
2624  return Button::set_property(rKey, rValue);
2625  }
2626  else
2627  return Button::set_property(rKey, rValue);
2628  return true;
2629 }
2630 
2631 void RadioButton::Check( bool bCheck )
2632 {
2633  // TabStop-Flag richtig mitfuehren
2634  if ( bCheck )
2635  mpWindowImpl->mnStyle |= WB_TABSTOP;
2636  else
2637  mpWindowImpl->mnStyle &= ~WB_TABSTOP;
2638 
2639  if ( mbChecked == bCheck )
2640  return;
2641 
2642  mbChecked = bCheck;
2643  VclPtr<vcl::Window> xWindow = this;
2645  if ( xWindow->IsDisposed() )
2646  return;
2647  if ( bCheck && mbRadioCheck )
2649  if ( xWindow->IsDisposed() )
2650  return;
2651  Toggle();
2652 }
2653 
2655 {
2656  // 4 pixels, but take zoom into account, so the text doesn't "jump" relative to surrounding elements,
2657  // which might have been aligned with the text of the check box
2658  return CalcZoom( 4 );
2659 }
2660 
2662 {
2663  Size aSize;
2664  bool bDefaultSize = true;
2666  {
2667  ImplControlValue aControlValue;
2668  tools::Rectangle aCtrlRegion( Point( 0, 0 ), GetSizePixel() );
2669  tools::Rectangle aBoundingRgn, aContentRgn;
2670 
2671  // get native size of a radio button
2674  aControlValue,
2675  aBoundingRgn, aContentRgn ) )
2676  {
2677  aSize = aContentRgn.GetSize();
2678  bDefaultSize = false;
2679  }
2680  }
2681  if( bDefaultSize )
2683  return aSize;
2684 }
2685 
2686 static void LoadThemedImageList(const StyleSettings &rStyleSettings,
2687  std::vector<Image>& rList, const std::vector<OUString> &rResources)
2688 {
2689  Color aColorAry1[6];
2690  Color aColorAry2[6];
2691  aColorAry1[0] = Color( 0xC0, 0xC0, 0xC0 );
2692  aColorAry1[1] = Color( 0xFF, 0xFF, 0x00 );
2693  aColorAry1[2] = Color( 0xFF, 0xFF, 0xFF );
2694  aColorAry1[3] = Color( 0x80, 0x80, 0x80 );
2695  aColorAry1[4] = Color( 0x00, 0x00, 0x00 );
2696  aColorAry1[5] = Color( 0x00, 0xFF, 0x00 );
2697  aColorAry2[0] = rStyleSettings.GetFaceColor();
2698  aColorAry2[1] = rStyleSettings.GetWindowColor();
2699  aColorAry2[2] = rStyleSettings.GetLightColor();
2700  aColorAry2[3] = rStyleSettings.GetShadowColor();
2701  aColorAry2[4] = rStyleSettings.GetDarkShadowColor();
2702  aColorAry2[5] = rStyleSettings.GetWindowTextColor();
2703 
2704  static_assert( sizeof(aColorAry1) == sizeof(aColorAry2), "aColorAry1 must match aColorAry2" );
2705 
2706  for (const auto &a : rResources)
2707  {
2708  BitmapEx aBmpEx(a);
2709  aBmpEx.Replace(aColorAry1, aColorAry2, SAL_N_ELEMENTS(aColorAry1));
2710  rList.emplace_back(aBmpEx);
2711  }
2712 }
2713 
2715 {
2716  ImplSVData* pSVData = ImplGetSVData();
2717  const StyleSettings& rStyleSettings = rSettings.GetStyleSettings();
2718  sal_uInt16 nStyle = 0;
2719 
2720  if ( rStyleSettings.GetOptions() & StyleSettingsOptions::Mono )
2721  nStyle = STYLE_RADIOBUTTON_MONO;
2722 
2723  if ( pSVData->maCtrlData.maRadioImgList.empty() ||
2724  (pSVData->maCtrlData.mnRadioStyle != nStyle) ||
2725  (pSVData->maCtrlData.mnLastRadioFColor != rStyleSettings.GetFaceColor()) ||
2726  (pSVData->maCtrlData.mnLastRadioWColor != rStyleSettings.GetWindowColor()) ||
2727  (pSVData->maCtrlData.mnLastRadioLColor != rStyleSettings.GetLightColor()) )
2728  {
2729  pSVData->maCtrlData.maRadioImgList.clear();
2730 
2731  pSVData->maCtrlData.mnLastRadioFColor = rStyleSettings.GetFaceColor();
2732  pSVData->maCtrlData.mnLastRadioWColor = rStyleSettings.GetWindowColor();
2733  pSVData->maCtrlData.mnLastRadioLColor = rStyleSettings.GetLightColor();
2734 
2735  std::vector<OUString> aResources;
2736  if (nStyle)
2737  {
2738  aResources.emplace_back(SV_RESID_BITMAP_RADIOMONO1);
2739  aResources.emplace_back(SV_RESID_BITMAP_RADIOMONO2);
2740  aResources.emplace_back(SV_RESID_BITMAP_RADIOMONO3);
2741  aResources.emplace_back(SV_RESID_BITMAP_RADIOMONO4);
2742  aResources.emplace_back(SV_RESID_BITMAP_RADIOMONO5);
2743  aResources.emplace_back(SV_RESID_BITMAP_RADIOMONO6);
2744  }
2745  else
2746  {
2747  aResources.emplace_back(SV_RESID_BITMAP_RADIO1);
2748  aResources.emplace_back(SV_RESID_BITMAP_RADIO2);
2749  aResources.emplace_back(SV_RESID_BITMAP_RADIO3);
2750  aResources.emplace_back(SV_RESID_BITMAP_RADIO4);
2751  aResources.emplace_back(SV_RESID_BITMAP_RADIO5);
2752  aResources.emplace_back(SV_RESID_BITMAP_RADIO6);
2753  }
2754  LoadThemedImageList( rStyleSettings, pSVData->maCtrlData.maRadioImgList, aResources);
2755  pSVData->maCtrlData.mnRadioStyle = nStyle;
2756  }
2757 
2758  sal_uInt16 nIndex;
2759  if ( nFlags & DrawButtonFlags::Disabled )
2760  {
2761  if ( nFlags & DrawButtonFlags::Checked )
2762  nIndex = 5;
2763  else
2764  nIndex = 4;
2765  }
2766  else if ( nFlags & DrawButtonFlags::Pressed )
2767  {
2768  if ( nFlags & DrawButtonFlags::Checked )
2769  nIndex = 3;
2770  else
2771  nIndex = 2;
2772  }
2773  else
2774  {
2775  if ( nFlags & DrawButtonFlags::Checked )
2776  nIndex = 1;
2777  else
2778  nIndex = 0;
2779  }
2780  return pSVData->maCtrlData.maRadioImgList[nIndex];
2781 }
2782 
2784 {
2786  SetMapMode(MapMode(MapUnit::MapPixel));
2787 
2788  ImplControlValue aControlValue;
2789  Size aCurSize( GetSizePixel() );
2790  tools::Rectangle aCtrlRegion( Point( 0, 0 ), aCurSize );
2791  tools::Rectangle aBoundingRgn, aContentRgn;
2792 
2793  // get native size of a radiobutton
2796  aBoundingRgn, aContentRgn ) )
2797  {
2798  Size aSize = aContentRgn.GetSize();
2799 
2800  if( aSize.Height() > aCurSize.Height() )
2801  {
2802  aCurSize.setHeight( aSize.Height() );
2803  SetSizePixel( aCurSize );
2804  }
2805  }
2806 
2807  Pop();
2808 }
2809 
2811 {
2812  Size aSize;
2813  if ( !maImage )
2814  aSize = ImplGetRadioImageSize();
2815  else
2816  {
2817  aSize = maImage.GetSizePixel();
2818  aSize.AdjustWidth(8);
2819  aSize.AdjustHeight(8);
2820  }
2821 
2822  if (Button::HasImage())
2823  {
2824  Size aImgSize = GetModeImage().GetSizePixel();
2825  aSize = Size(std::max(aImgSize.Width(), aSize.Width()),
2826  std::max(aImgSize.Height(), aSize.Height()));
2827  }
2828 
2829  OUString aText = GetText();
2830  if (!aText.isEmpty())
2831  {
2832  bool bTopImage = (GetStyle() & WB_TOP) != 0;
2833 
2834  Size aTextSize = GetTextRect( tools::Rectangle( Point(), Size( nMaxWidth > 0 ? nMaxWidth : 0x7fffffff, 0x7fffffff ) ),
2836 
2837  aSize.AdjustWidth(2 ); // for focus rect
2838 
2839  if (!bTopImage)
2840  {
2842  aSize.AdjustWidth(aTextSize.Width() );
2843  if ( aSize.Height() < aTextSize.Height() )
2844  aSize.setHeight( aTextSize.Height() );
2845  }
2846  else
2847  {
2848  aSize.AdjustHeight(6 );
2849  aSize.AdjustHeight(GetTextHeight() );
2850  if ( aSize.Width() < aTextSize.Width() )
2851  aSize.setWidth( aTextSize.Width() );
2852  }
2853  }
2854 
2855  return CalcWindowSize( aSize );
2856 }
2857 
2859 {
2860  return CalcMinimumSize();
2861 }
2862 
2864 {
2866  {
2867  ImplControlValue aControlValue;
2868  tools::Rectangle aInRect(Point(0, 0), GetSizePixel());
2869 
2870  aInRect.SetLeft( rRect.Left() ); // exclude the radio element itself from the focusrect
2871 
2873  ControlState::FOCUSED, aControlValue, OUString());
2874  }
2875  Button::ShowFocus(rRect);
2876 }
2877 
2879 {
2880  Button::DumpAsPropertyTree(rJsonWriter);
2881  rJsonWriter.put("checked", IsChecked());
2882 }
2883 
2885 {
2887 }
2888 
2890 {
2892  mbTriState = false;
2893 }
2894 
2895 void CheckBox::ImplInit( vcl::Window* pParent, WinBits nStyle )
2896 {
2897  nStyle = ImplInitStyle(getPreviousSibling(pParent), nStyle);
2898  Button::ImplInit( pParent, nStyle, nullptr );
2899 
2900  ImplInitSettings( true );
2901 }
2902 
2904 {
2905  if ( !(nStyle & WB_NOTABSTOP) )
2906  nStyle |= WB_TABSTOP;
2907  if ( !(nStyle & WB_NOGROUP) &&
2908  (!pPrevWindow || (pPrevWindow->GetType() != WindowType::CHECKBOX)) )
2909  nStyle |= WB_GROUP;
2910  return nStyle;
2911 }
2912 
2914 {
2915  return _rStyle.GetRadioCheckFont();
2916 }
2917 
2919 {
2920  return _rStyle.GetRadioCheckTextColor();
2921 }
2922 
2923 void CheckBox::ImplInitSettings( bool bBackground )
2924 {
2926 
2927  if ( !bBackground )
2928  return;
2929 
2930  vcl::Window* pParent = GetParent();
2931  if ( !IsControlBackground() &&
2933  {
2936  SetPaintTransparent( true );
2937  SetBackground();
2940  }
2941  else
2942  {
2943  EnableChildTransparentMode( false );
2945  SetPaintTransparent( false );
2946 
2947  if ( IsControlBackground() )
2949  else
2950  SetBackground( pParent->GetBackground() );
2951  }
2952 }
2953 
2955 {
2956  bool bNativeOK = rRenderContext.IsNativeControlSupported(ControlType::Checkbox, ControlPart::Entire);
2957  if (bNativeOK)
2958  {
2960  tools::Rectangle aCtrlRegion(maStateRect);
2962 
2963  if (HasFocus())
2964  nState |= ControlState::FOCUSED;
2966  nState |= ControlState::DEFAULT;
2968  nState |= ControlState::PRESSED;
2969  if (IsEnabled())
2970  nState |= ControlState::ENABLED;
2971 
2972  if (meState == TRISTATE_TRUE)
2973  aControlValue.setTristateVal(ButtonValue::On);
2974  else if (meState == TRISTATE_INDET)
2975  aControlValue.setTristateVal(ButtonValue::Mixed);
2976 
2978  nState |= ControlState::ROLLOVER;
2979 
2980  bNativeOK = rRenderContext.DrawNativeControl(ControlType::Checkbox, ControlPart::Entire, aCtrlRegion,
2981  nState, aControlValue, OUString());
2982  }
2983 
2984  if (bNativeOK)
2985  return;
2986 
2987  DrawButtonFlags nStyle = GetButtonState();
2988  if (!IsEnabled())
2989  nStyle |= DrawButtonFlags::Disabled;
2990  if (meState == TRISTATE_INDET)
2991  nStyle |= DrawButtonFlags::DontKnow;
2992  else if (meState == TRISTATE_TRUE)
2993  nStyle |= DrawButtonFlags::Checked;
2994  Image aImage = GetCheckImage(GetSettings(), nStyle);
2995  if (IsZoom())
2996  rRenderContext.DrawImage(maStateRect.TopLeft(), maStateRect.GetSize(), aImage);
2997  else
2998  rRenderContext.DrawImage(maStateRect.TopLeft(), aImage);
2999 }
3000 
3002  const Point& rPos, const Size& rSize,
3003  const Size& rImageSize, tools::Rectangle& rStateRect,
3004  tools::Rectangle& rMouseRect )
3005 {
3006  WinBits nWinStyle = GetStyle();
3007  OUString aText( GetText() );
3008 
3010  pDev->IntersectClipRegion( tools::Rectangle( rPos, rSize ) );
3011 
3012  if (!aText.isEmpty() || HasImage())
3013  {
3014  DrawTextFlags nTextStyle = Button::ImplGetTextStyle( nWinStyle, nDrawFlags );
3015 
3016  const tools::Long nImageSep = GetDrawPixel( pDev, ImplGetImageToTextDistance() );
3017  Size aSize( rSize );
3018  Point aPos( rPos );
3019  aPos.AdjustX(rImageSize.Width() + nImageSep );
3020  aSize.AdjustWidth( -(rImageSize.Width() + nImageSep) );
3021 
3022  // if the text rect height is smaller than the height of the image
3023  // then for single lines the default should be centered text
3024  if( (nWinStyle & (WB_TOP|WB_VCENTER|WB_BOTTOM)) == 0 &&
3025  (rImageSize.Height() > rSize.Height() || ! (nWinStyle & WB_WORDBREAK) ) )
3026  {
3028  nTextStyle |= DrawTextFlags::VCenter;
3029  aSize.setHeight( rImageSize.Height() );
3030  }
3031 
3032  ImplDrawAlignedImage( pDev, aPos, aSize, 1, nTextStyle );
3033 
3034  rMouseRect = tools::Rectangle( aPos, aSize );
3035  rMouseRect.SetLeft( rPos.X() );
3036  rStateRect.SetLeft( rPos.X() );
3037  rStateRect.SetTop( rMouseRect.Top() );
3038 
3039  if ( aSize.Height() > rImageSize.Height() )
3040  rStateRect.AdjustTop(( aSize.Height() - rImageSize.Height() ) / 2 );
3041  else
3042  {
3043  rStateRect.AdjustTop( -(( rImageSize.Height() - aSize.Height() ) / 2) );
3044  if( rStateRect.Top() < 0 )
3045  rStateRect.SetTop( 0 );
3046  }
3047 
3048  rStateRect.SetRight( rStateRect.Left()+rImageSize.Width()-1 );
3049  rStateRect.SetBottom( rStateRect.Top()+rImageSize.Height()-1 );
3050  if ( rStateRect.Bottom() > rMouseRect.Bottom() )
3051  rMouseRect.SetBottom( rStateRect.Bottom() );
3052  }
3053  else
3054  {
3055  rStateRect.SetLeft( rPos.X() );
3056  if ( nWinStyle & WB_VCENTER )
3057  rStateRect.SetTop( rPos.Y()+((rSize.Height()-rImageSize.Height())/2) );
3058  else if ( nWinStyle & WB_BOTTOM )
3059  rStateRect.SetTop( rPos.Y()+rSize.Height()-rImageSize.Height() );
3060  else
3061  rStateRect.SetTop( rPos.Y() );
3062  rStateRect.SetRight( rStateRect.Left()+rImageSize.Width()-1 );
3063  rStateRect.SetBottom( rStateRect.Top()+rImageSize.Height()-1 );
3064  // provide space for focusrect
3065  // note: this assumes that the control's size was adjusted
3066  // accordingly in Get/LoseFocus, so the onscreen position won't change
3067  if( HasFocus() )
3068  rStateRect.Move( 1, 1 );
3069  rMouseRect = rStateRect;
3070 
3071  ImplSetFocusRect( rStateRect );
3072  }
3073 
3074  pDev->Pop();
3075 }
3076 
3078 {
3079  Size aImageSize = ImplGetCheckImageSize();
3080  aImageSize.setWidth( CalcZoom( aImageSize.Width() ) );
3081  aImageSize.setHeight( CalcZoom( aImageSize.Height() ) );
3082 
3083  HideFocus();
3084 
3085  ImplDraw(&rRenderContext, DrawFlags::NONE, Point(), GetOutputSizePixel(),
3086  aImageSize, maStateRect, maMouseRect);
3087 
3088  ImplDrawCheckBoxState(rRenderContext);
3089  if (HasFocus())
3091 }
3092 
3094 {
3095  TriState eNewState;
3096  if ( meState == TRISTATE_FALSE )
3097  eNewState = TRISTATE_TRUE;
3098  else if ( !mbTriState )
3099  eNewState = TRISTATE_FALSE;
3100  else if ( meState == TRISTATE_TRUE )
3101  eNewState = TRISTATE_INDET;
3102  else
3103  eNewState = TRISTATE_FALSE;
3104  meState = eNewState;
3105 
3106  VclPtr<vcl::Window> xWindow = this;
3107  Invalidate();
3108  Toggle();
3109  if ( xWindow->IsDisposed() )
3110  return;
3111  Click();
3112 }
3113 
3116 {
3118  ImplInit( pParent, nStyle );
3119 }
3120 
3122 {
3123  if ( rMEvt.IsLeft() && maMouseRect.IsInside( rMEvt.GetPosPixel() ) )
3124  {
3126  Invalidate();
3127  StartTracking();
3128  return;
3129  }
3130 
3131  Button::MouseButtonDown( rMEvt );
3132 }
3133 
3134 void CheckBox::Tracking( const TrackingEvent& rTEvt )
3135 {
3136  if ( rTEvt.IsTrackingEnded() )
3137  {
3139  {
3140  if ( !(GetStyle() & WB_NOPOINTERFOCUS) && !rTEvt.IsTrackingCanceled() )
3141  GrabFocus();
3142 
3144 
3145  // do not call click handler if aborted
3146  if ( !rTEvt.IsTrackingCanceled() )
3147  ImplCheck();
3148  else
3149  {
3150  Invalidate();
3151  }
3152  }
3153  }
3154  else
3155  {
3156  if ( maMouseRect.IsInside( rTEvt.GetMouseEvent().GetPosPixel() ) )
3157  {
3159  {
3161  Invalidate();
3162  }
3163  }
3164  else
3165  {
3167  {
3169  Invalidate();
3170  }
3171  }
3172  }
3173 }
3174 
3175 void CheckBox::KeyInput( const KeyEvent& rKEvt )
3176 {
3177  vcl::KeyCode aKeyCode = rKEvt.GetKeyCode();
3178 
3179  if ( !aKeyCode.GetModifier() && (aKeyCode.GetCode() == KEY_SPACE) )
3180  {
3182  {
3184  Invalidate();
3185  }
3186  }
3187  else if ( (GetButtonState() & DrawButtonFlags::Pressed) && (aKeyCode.GetCode() == KEY_ESCAPE) )
3188  {
3190  Invalidate();
3191  }
3192  else
3193  Button::KeyInput( rKEvt );
3194 }
3195 
3196 void CheckBox::KeyUp( const KeyEvent& rKEvt )
3197 {
3198  vcl::KeyCode aKeyCode = rKEvt.GetKeyCode();
3199 
3200  if ( (GetButtonState() & DrawButtonFlags::Pressed) && (aKeyCode.GetCode() == KEY_SPACE) )
3201  {
3203  ImplCheck();
3204  }
3205  else
3206  Button::KeyUp( rKEvt );
3207 }
3208 
3210 {
3211  mpControlData->mpLayoutData.reset( new vcl::ControlLayoutData );
3212  const_cast<CheckBox*>(this)->Invalidate();
3213 }
3214 
3216 {
3217  ImplDrawCheckBox(rRenderContext);
3218 }
3219 
3220 void CheckBox::Draw( OutputDevice* pDev, const Point& rPos,
3221  DrawFlags nFlags )
3222 {
3223  MapMode aResMapMode( MapUnit::Map100thMM );
3224  Point aPos = pDev->LogicToPixel( rPos );
3225  Size aSize = GetSizePixel();
3226  Size aImageSize = pDev->LogicToPixel( Size( 300, 300 ), aResMapMode );
3227  Size aBrd1Size = pDev->LogicToPixel( Size( 20, 20 ), aResMapMode );
3228  Size aBrd2Size = pDev->LogicToPixel( Size( 30, 30 ), aResMapMode );
3229  tools::Long nCheckWidth = pDev->LogicToPixel( Size( 20, 20 ), aResMapMode ).Width();
3230  vcl::Font aFont = GetDrawPixelFont( pDev );
3231  tools::Rectangle aStateRect;
3232  tools::Rectangle aMouseRect;
3233 
3234  aImageSize.setWidth( CalcZoom( aImageSize.Width() ) );
3235  aImageSize.setHeight( CalcZoom( aImageSize.Height() ) );
3236  aBrd1Size.setWidth( CalcZoom( aBrd1Size.Width() ) );
3237  aBrd1Size.setHeight( CalcZoom( aBrd1Size.Height() ) );
3238  aBrd2Size.setWidth( CalcZoom( aBrd2Size.Width() ) );
3239  aBrd2Size.setHeight( CalcZoom( aBrd2Size.Height() ) );
3240 
3241  if ( !aBrd1Size.Width() )
3242  aBrd1Size.setWidth( 1 );
3243  if ( !aBrd1Size.Height() )
3244  aBrd1Size.setHeight( 1 );
3245  if ( !aBrd2Size.Width() )
3246  aBrd2Size.setWidth( 1 );
3247  if ( !aBrd2Size.Height() )
3248  aBrd2Size.setHeight( 1 );
3249  if ( !nCheckWidth )
3250  nCheckWidth = 1;
3251 
3252  pDev->Push();
3253  pDev->SetMapMode();
3254  pDev->SetFont( aFont );
3255  if ( nFlags & DrawFlags::Mono )
3256  pDev->SetTextColor( COL_BLACK );
3257  else
3258  pDev->SetTextColor( GetTextColor() );
3259  pDev->SetTextFillColor();
3260 
3261  ImplDraw( pDev, nFlags, aPos, aSize,
3262  aImageSize, aStateRect, aMouseRect );
3263 
3264  pDev->SetLineColor();
3265  pDev->SetFillColor( COL_BLACK );
3266  pDev->DrawRect( aStateRect );
3267  aStateRect.AdjustLeft(aBrd1Size.Width() );
3268  aStateRect.AdjustTop(aBrd1Size.Height() );
3269  aStateRect.AdjustRight( -(aBrd1Size.Width()) );
3270  aStateRect.AdjustBottom( -(aBrd1Size.Height()) );
3271  if ( meState == TRISTATE_INDET )
3272  pDev->SetFillColor( COL_LIGHTGRAY );
3273  else
3274  pDev->SetFillColor( COL_WHITE );
3275  pDev->DrawRect( aStateRect );
3276 
3277  if ( meState == TRISTATE_TRUE )
3278  {
3279  aStateRect.AdjustLeft(aBrd2Size.Width() );
3280  aStateRect.AdjustTop(aBrd2Size.Height() );
3281  aStateRect.AdjustRight( -(aBrd2Size.Width()) );
3282  aStateRect.AdjustBottom( -(aBrd2Size.Height()) );
3283  Point aPos11( aStateRect.TopLeft() );
3284  Point aPos12( aStateRect.BottomRight() );
3285  Point aPos21( aStateRect.TopRight() );
3286  Point aPos22( aStateRect.BottomLeft() );
3287  Point aTempPos11( aPos11 );
3288  Point aTempPos12( aPos12 );
3289  Point aTempPos21( aPos21 );
3290  Point aTempPos22( aPos22 );
3291  pDev->SetLineColor( COL_BLACK );
3292  tools::Long nDX = 0;
3293  for ( tools::Long i = 0; i < nCheckWidth; i++ )
3294  {
3295  if ( !(i % 2) )
3296  {
3297  aTempPos11.setX( aPos11.X()+nDX );
3298  aTempPos12.setX( aPos12.X()+nDX );
3299  aTempPos21.setX( aPos21.X()+nDX );
3300  aTempPos22.setX( aPos22.X()+nDX );
3301  }
3302  else
3303  {
3304  nDX++;
3305  aTempPos11.setX( aPos11.X()-nDX );
3306  aTempPos12.setX( aPos12.X()-nDX );
3307  aTempPos21.setX( aPos21.X()-nDX );
3308  aTempPos22.setX( aPos22.X()-nDX );
3309  }
3310  pDev->DrawLine( aTempPos11, aTempPos12 );
3311  pDev->DrawLine( aTempPos21, aTempPos22 );
3312  }
3313  }
3314 
3315  pDev->Pop();
3316 }
3317 
3319 {
3320  Control::Resize();
3321  Invalidate();
3322 }
3323 
3325 {
3326  if (GetText().isEmpty())
3327  {
3328  // increase button size to have space for focus rect
3329  // checkboxes without text will draw focusrect around the check
3330  // See CheckBox::ImplDraw()
3331  Point aPos( GetPosPixel() );
3332  Size aSize( GetSizePixel() );
3333  aPos.Move(-1,-1);
3334  aSize.AdjustHeight(2 );
3335  aSize.AdjustWidth(2 );
3336  setPosSizePixel( aPos.X(), aPos.Y(), aSize.Width(), aSize.Height() );
3337  Invalidate();
3338  // Trigger drawing to initialize the mouse rectangle, otherwise the mouse button down
3339  // handler would ignore the mouse event.
3340  PaintImmediately();
3341  }
3342  else
3344 
3346  Button::GetFocus();
3347 }
3348 
3350 {
3352  {
3354  Invalidate();
3355  }
3356 
3357  HideFocus();
3359 
3360  if (GetText().isEmpty())
3361  {
3362  // decrease button size again (see GetFocus())
3363  // checkboxes without text will draw focusrect around the check
3364  Point aPos( GetPosPixel() );
3365  Size aSize( GetSizePixel() );
3366  aPos.Move(1,1);
3367  aSize.AdjustHeight( -2 );
3368  aSize.AdjustWidth( -2 );
3369  setPosSizePixel( aPos.X(), aPos.Y(), aSize.Width(), aSize.Height() );
3370  Invalidate();
3371  }
3372 }
3373 
3375 {
3376  Button::StateChanged( nType );
3377 
3378  if ( nType == StateChangedType::State )
3379  {
3380  if ( IsReallyVisible() && IsUpdateMode() )
3382  }
3383  else if ( (nType == StateChangedType::Enable) ||
3384  (nType == StateChangedType::Text) ||
3385  (nType == StateChangedType::Data) ||
3386  (nType == StateChangedType::UpdateMode) )
3387  {
3388  if ( IsUpdateMode() )
3389  Invalidate();
3390  }
3391  else if ( nType == StateChangedType::Style )
3392  {
3394 
3395  if ( (GetPrevStyle() & CHECKBOX_VIEW_STYLE) !=
3397  {
3398  if ( IsUpdateMode() )
3399  Invalidate();
3400  }
3401  }
3402  else if ( (nType == StateChangedType::Zoom) ||
3403  (nType == StateChangedType::ControlFont) )
3404  {
3405  ImplInitSettings( false );
3406  Invalidate();
3407  }
3408  else if ( nType == StateChangedType::ControlForeground )
3409  {
3410  ImplInitSettings( false );
3411  Invalidate();
3412  }
3413  else if ( nType == StateChangedType::ControlBackground )
3414  {
3415  ImplInitSettings( true );
3416  Invalidate();
3417  }
3418 }
3419 
3421 {
3422  Button::DataChanged( rDCEvt );
3423 
3424  if ( (rDCEvt.GetType() == DataChangedEventType::FONTS) ||
3426  ((rDCEvt.GetType() == DataChangedEventType::SETTINGS) &&
3427  (rDCEvt.GetFlags() & AllSettingsFlags::STYLE)) )
3428  {
3429  ImplInitSettings( true );
3430  Invalidate();
3431  }
3432 }
3433 
3435 {
3436  if( rNEvt.GetType() == MouseNotifyEvent::MOUSEMOVE )
3437  {
3438  const MouseEvent* pMouseEvt = rNEvt.GetMouseEvent();
3439  if( pMouseEvt && !pMouseEvt->GetButtons() && !pMouseEvt->IsSynthetic() && !pMouseEvt->IsModifierChanged() )
3440  {
3441  // trigger redraw if mouse over state has changed
3443  {
3445  pMouseEvt->IsLeaveWindow() || pMouseEvt->IsEnterWindow())
3446  {
3448  }
3449  }
3450  }
3451  }
3452 
3453  return Button::PreNotify(rNEvt);
3454 }
3455 
3457 {
3459 }
3460 
3462 {
3463  if ( !mbTriState && (eState == TRISTATE_INDET) )
3464  eState = TRISTATE_FALSE;
3465 
3466  if ( meState != eState )
3467  {
3468  meState = eState;
3470  Toggle();
3471  }
3472 }
3473 
3474 bool CheckBox::set_property(const OString &rKey, const OUString &rValue)
3475 {
3476  if (rKey == "active")
3478  else
3479  return Button::set_property(rKey, rValue);
3480  return true;
3481 }
3482 
3483 void CheckBox::EnableTriState( bool bTriState )
3484 {
3485  if ( mbTriState != bTriState )
3486  {
3487  mbTriState = bTriState;
3488 
3489  if ( !bTriState && (meState == TRISTATE_INDET) )
3491  }
3492 }
3493 
3495 {
3496  // 4 pixels, but take zoom into account, so the text doesn't "jump" relative to surrounding elements,
3497  // which might have been aligned with the text of the check box
3498  return CalcZoom( 4 );
3499 }
3500 
3502 {
3503  Size aSize;
3504  bool bDefaultSize = true;
3506  {
3507  ImplControlValue aControlValue;
3508  tools::Rectangle aCtrlRegion( Point( 0, 0 ), GetSizePixel() );
3509  tools::Rectangle aBoundingRgn, aContentRgn;
3510 
3511  // get native size of a check box
3514  aControlValue,
3515  aBoundingRgn, aContentRgn ) )
3516  {
3517  aSize = aContentRgn.GetSize();
3518  bDefaultSize = false;
3519  }
3520  }
3521  if( bDefaultSize )
3523  return aSize;
3524 }
3525 
3527 {
3528  ImplSVData* pSVData = ImplGetSVData();
3529  const StyleSettings& rStyleSettings = rSettings.GetStyleSettings();
3530  sal_uInt16 nStyle = 0;
3531 
3532  if ( rStyleSettings.GetOptions() & StyleSettingsOptions::Mono )
3533  nStyle = STYLE_CHECKBOX_MONO;
3534 
3535  if ( pSVData->maCtrlData.maCheckImgList.empty() ||
3536  (pSVData->maCtrlData.mnCheckStyle != nStyle) ||
3537  (pSVData->maCtrlData.mnLastCheckFColor != rStyleSettings.GetFaceColor()) ||
3538  (pSVData->maCtrlData.mnLastCheckWColor != rStyleSettings.GetWindowColor()) ||
3539  (pSVData->maCtrlData.mnLastCheckLColor != rStyleSettings.GetLightColor()) )
3540  {
3541  pSVData->maCtrlData.maCheckImgList.clear();
3542 
3543  pSVData->maCtrlData.mnLastCheckFColor = rStyleSettings.GetFaceColor();
3544  pSVData->maCtrlData.mnLastCheckWColor = rStyleSettings.GetWindowColor();
3545  pSVData->maCtrlData.mnLastCheckLColor = rStyleSettings.GetLightColor();
3546 
3547  std::vector<OUString> aResources;
3548  if (nStyle)
3549  {
3550  aResources.emplace_back(SV_RESID_BITMAP_CHECKMONO1);
3551  aResources.emplace_back(SV_RESID_BITMAP_CHECKMONO2);
3552  aResources.emplace_back(SV_RESID_BITMAP_CHECKMONO3);
3553  aResources.emplace_back(SV_RESID_BITMAP_CHECKMONO4);
3554  aResources.emplace_back(SV_RESID_BITMAP_CHECKMONO5);
3555  aResources.emplace_back(SV_RESID_BITMAP_CHECKMONO6);
3556  aResources.emplace_back(SV_RESID_BITMAP_CHECKMONO7);
3557  aResources.emplace_back(SV_RESID_BITMAP_CHECKMONO8);
3558  aResources.emplace_back(SV_RESID_BITMAP_CHECKMONO9);
3559  }
3560  else
3561  {
3562  aResources.emplace_back(SV_RESID_BITMAP_CHECK1);
3563  aResources.emplace_back(SV_RESID_BITMAP_CHECK2);
3564  aResources.emplace_back(SV_RESID_BITMAP_CHECK3);
3565  aResources.emplace_back(SV_RESID_BITMAP_CHECK4);
3566  aResources.emplace_back(SV_RESID_BITMAP_CHECK5);
3567  aResources.emplace_back(SV_RESID_BITMAP_CHECK6);
3568  aResources.emplace_back(SV_RESID_BITMAP_CHECK7);
3569  aResources.emplace_back(SV_RESID_BITMAP_CHECK8);
3570  aResources.emplace_back(SV_RESID_BITMAP_CHECK9);
3571  }
3572  LoadThemedImageList(rStyleSettings, pSVData->maCtrlData.maCheckImgList, aResources);
3573  pSVData->maCtrlData.mnCheckStyle = nStyle;
3574  }
3575 
3576  sal_uInt16 nIndex;
3577  if ( nFlags & DrawButtonFlags::Disabled )
3578  {
3579  if ( nFlags & DrawButtonFlags::DontKnow )
3580  nIndex = 8;
3581  else if ( nFlags & DrawButtonFlags::Checked )
3582  nIndex = 5;
3583  else
3584  nIndex = 4;
3585  }
3586  else if ( nFlags & DrawButtonFlags::Pressed )
3587  {
3588  if ( nFlags & DrawButtonFlags::DontKnow )
3589  nIndex = 7;
3590  else if ( nFlags & DrawButtonFlags::Checked )
3591  nIndex = 3;
3592  else
3593  nIndex = 2;
3594  }
3595  else
3596  {
3597  if ( nFlags & DrawButtonFlags::DontKnow )
3598  nIndex = 6;
3599  else if ( nFlags & DrawButtonFlags::Checked )
3600  nIndex = 1;
3601  else
3602  nIndex = 0;
3603  }
3604  return pSVData->maCtrlData.maCheckImgList[nIndex];
3605 }
3606 
3608 {
3610  SetMapMode(MapMode(MapUnit::MapPixel));
3611 
3612  ImplControlValue aControlValue;
3613  Size aCurSize( GetSizePixel() );
3614  tools::Rectangle aCtrlRegion( Point( 0, 0 ), aCurSize );
3615  tools::Rectangle aBoundingRgn, aContentRgn;
3616 
3617  // get native size of a radiobutton
3620  aBoundingRgn, aContentRgn ) )
3621  {
3622  Size aSize = aContentRgn.GetSize();
3623 
3624  if( aSize.Height() > aCurSize.Height() )
3625  {
3626  aCurSize.setHeight( aSize.Height() );
3627  SetSizePixel( aCurSize );
3628  }
3629  }
3630 
3631  Pop();
3632 }
3633 
3635 {
3636  Size aSize = ImplGetCheckImageSize();
3637  nMaxWidth -= aSize.Width();
3638 
3639  OUString aText = GetText();
3640  if (!aText.isEmpty())
3641  {
3642  // subtract what will be added later
3643  nMaxWidth-=2;
3644  nMaxWidth -= ImplGetImageToTextDistance();
3645 
3646  Size aTextSize = GetTextRect( tools::Rectangle( Point(), Size( nMaxWidth > 0 ? nMaxWidth : 0x7fffffff, 0x7fffffff ) ),
3648  aSize.AdjustWidth(2 ); // for focus rect
3650  aSize.AdjustWidth(aTextSize.Width() );
3651  if ( aSize.Height() < aTextSize.Height() )
3652  aSize.setHeight( aTextSize.Height() );
3653  }
3654  else
3655  {
3656  // is this still correct ? since the checkbox now
3657  // shows a focus rect it should be 2 pixels wider and longer
3658 /* since otherwise the controls in the Writer hang too far up
3659  aSize.Width() += 2;
3660  aSize.Height() += 2;
3661 */
3662  }
3663 
3664  return CalcWindowSize( aSize );
3665 }
3666 
3668 {
3669  int nWidthRequest(get_width_request());
3670  return CalcMinimumSize(nWidthRequest != -1 ? nWidthRequest : 0);
3671 }
3672 
3674 {
3676  {
3677  ImplControlValue aControlValue;
3678  tools::Rectangle aInRect(Point(0, 0), GetSizePixel());
3679 
3680  aInRect.SetLeft( rRect.Left() ); // exclude the checkbox itself from the focusrect
3681 
3683  ControlState::FOCUSED, aControlValue, OUString());
3684  }
3685  Button::ShowFocus(rRect);
3686 }
3687 
3689 {
3690  Button::DumpAsPropertyTree(rJsonWriter);
3691  rJsonWriter.put("checked", IsChecked());
3692 }
3693 
3695 {
3696  return CheckBoxUIObject::create;
3697 }
3698 
3700  PushButton( pParent, nStyle )
3701 {
3702  ImplInitStyle();
3703 }
3704 
3706 {
3707  WinBits nStyle = GetStyle();
3708 
3709  if ( ! ( nStyle & ( WB_RIGHT | WB_LEFT ) ) )
3710  nStyle |= WB_CENTER;
3711 
3712  if ( ! ( nStyle & ( WB_TOP | WB_BOTTOM ) ) )
3713  nStyle |= WB_VCENTER;
3714 
3715  SetStyle( nStyle );
3716 }
3717 
3718 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static bool toBool(std::string_view rValue)
Definition: builder.cxx:85
virtual Point GetPosPixel() const
Definition: window.cxx:2789
std::shared_ptr< std::vector< VclPtr< RadioButton > > > m_xGroup
virtual void Resize() override
Definition: button.cxx:2453
bool mbIsAction
Definition: button.hxx:209
virtual const vcl::Font & GetCanonicalFont(const StyleSettings &_rStyle) const override
Definition: button.cxx:638
Point TopLeft() const
virtual void FillLayoutData() const override
Definition: button.cxx:1305
virtual void DataChanged(const DataChangedEvent &rDCEvt) override
Definition: button.cxx:3420
Image const & GetCustomButtonImage() const
Definition: button.cxx:172
Size GetSizePixel() const
Definition: Image.cxx:86
const Color & GetTextColor() const
Definition: outdev.hxx:1132
void SetPos(const Point &rPoint)
const Color & GetShadowColor() const
bool IsControlBackground() const
Definition: window2.cxx:1087
static std::unique_ptr< UIObject > create(vcl::Window *pWindow)
SAL_DLLPRIVATE void ImplInitCheckBoxData()
Definition: button.cxx:2889
void Toggle()
Definition: button.cxx:3456
Color mnLastRadioLColor
Definition: svdata.hxx:283
TriState meState
Definition: button.hxx:207
virtual void statusChanged(const css::frame::FeatureStateEvent &rEvent) override
Sets the button state according to the FeatureStateEvent emitted by a Uno state change.
Definition: button.cxx:1559
bool ImplCallEventListenersAndHandler(VclEventId nEvent, std::function< void()> const &callHandler)
this calls both our event listeners, and a specified handler
Definition: ctrl.cxx:305
CheckBox(const CheckBox &)=delete
Point GetPointerPosPixel()
Definition: mouse.cxx:550
const Wallpaper & GetBackground() const
Definition: outdev.hxx:643
void EndSelection()
Definition: button.cxx:1575
void HideFocus()
Definition: window2.cxx:91
sal_Int32 nIndex
SAL_DLLPRIVATE tools::Long ImplGetImageToTextDistance() const
Definition: button.cxx:3494
DrawButtonFlags mnButtonState
Definition: button.cxx:79
bool mbIsActive
Definition: button.hxx:175
WinBits const WB_TOGGLE
virtual ~Button() override
Definition: button.cxx:103
static std::unique_ptr< UIObject > create(vcl::Window *pWindow)
Color mnLastCheckWColor
Definition: svdata.hxx:279
virtual void StateChanged(StateChangedType nType) override
Definition: button.cxx:3374
WinBits const WB_NOLABEL
void DrawImage(const Point &rPos, const Image &rImage, DrawImageFlags nStyle=DrawImageFlags::NONE)
This is an overloaded member function, provided for convenience. It differs from the above function o...
virtual Size GetOptimalSize() const override
Definition: button.cxx:3667
const Color & GetActionButtonTextColor() const
static Image GetRadioImage(const AllSettings &rSettings, DrawButtonFlags nFlags)
Definition: button.cxx:2714
tools::Long AdjustRight(tools::Long nHorzMoveDelta)
virtual bool Close() override
Definition: dialog.cxx:843
sal_uInt16 mnCheckStyle
Definition: svdata.hxx:276
SAL_DLLPRIVATE void ImplSetFocusRect(const tools::Rectangle &rFocusRect)
Definition: button.cxx:475
void SetModeRadioImage(const Image &rImage)
Definition: button.cxx:2565
void setWidth(tools::Long nWidth)
void Replace(const Color &rSearchColor, const Color &rReplaceColor)
Replace all pixel having the search color with the specified color.
Definition: BitmapEx.cxx:591
void group(RadioButton &rOther)
Definition: button.cxx:2125
void SetClickHdl(const Link< Button *, void > &rLink)
Definition: button.hxx:70
tools::Rectangle maStateRect
ImageAlign
bool GetNativeControlRegion(ControlType nType, ControlPart nPart, const tools::Rectangle &rControlRegion, ControlState nState, const ImplControlValue &aValue, tools::Rectangle &rNativeBoundingRegion, tools::Rectangle &rNativeContentRegion) const
Query the native control's actual drawing region (including adornment)
virtual void MouseButtonDown(const MouseEvent &rMEvt)
Definition: mouse.cxx:414
#define STYLE_RADIOBUTTON_MONO
Definition: button.cxx:69
StartTrackingFlags
Definition: window.hxx:291
virtual void KeyInput(const KeyEvent &rKEvt) override
Definition: button.cxx:1248
void SetModeImage(const Image &rImage)
Definition: button.cxx:129
SAL_DLLPRIVATE void ImplSetSeparatorX(tools::Long nX)
Definition: button.cxx:182
SAL_DLLPRIVATE void ImplSetDefButton(bool bSet)
Definition: button.cxx:1090
tools::Long getWidth() const
void Check(bool bCheck=true)
Definition: button.hxx:212
SymbolAlign
virtual void Click() override
Definition: button.cxx:1671
OUString GetStandardText(StandardButtonType eButton)
Definition: stdtext.cxx:93
void EndDialog(tools::Long nResult=RET_CANCEL)
Definition: dialog.cxx:1103
void SetStyleSettings(const StyleSettings &rSet)
SymbolAlign meSymbolAlign
Definition: button.cxx:84
static SAL_DLLPRIVATE WinBits ImplInitStyle(const vcl::Window *pPrevWindow, WinBits nStyle)
Definition: button.cxx:2903
Point BottomLeft() const
WinBits const WB_NOGROUP
void DrawCtrlText(const Point &rPos, const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, DrawTextFlags nStyle=DrawTextFlags::Mnemonic, MetricVector *pVector=nullptr, OUString *pDisplayText=nullptr, const SalLayoutGlyphs *pGlyphs=nullptr)
Definition: text.cxx:2057
tools::Long getWidth() const
void SetCommandHandler(const OUString &aCommand)
Setup handler for UNO commands so that commands like .uno:Something are handled automagically by this...
Definition: button.cxx:115
tools::Rectangle maStateRect
virtual void DataChanged(const DataChangedEvent &rDCEvt) override
Definition: button.cxx:1432
sal_uIntPtr sal_uLong
const Color & GetDefaultButtonTextColor() const
long Long
Link< CheckBox &, void > maToggleHdl
virtual void FillLayoutData() const override
Definition: button.cxx:3209
virtual void LoseFocus() override
Definition: button.cxx:2466
const StyleSettings & GetStyleSettings() const
static const AllSettings & GetSettings()
Gets the application's settings.
Definition: svapp.cxx:724
const Color & GetFaceColor() const
const vcl::Font & GetRadioCheckFont() const
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 ImplGrabFocus(GetFocusFlags nFlags)
Definition: mouse.cxx:195
ImplSVNWFData maNWFData
Definition: svdata.hxx:397
void Toggle()
Definition: button.cxx:2560
const OUString & GetQuickHelpText() const
Definition: window2.cxx:1232
void DrawPolygon(const tools::Polygon &rPoly)
Render the given polygon.
Definition: polygon.cxx:155
const Color & GetDefaultButtonPressedRolloverTextColor() const
std::function< std::unique_ptr< UIObject >vcl::Window *)> FactoryFunction
virtual Size GetSizePixel() const
Definition: window.cxx:2400
virtual void SetSizePixel(const Size &rNewSize)
Definition: window2.cxx:1262
WinBits const WB_RIGHT
virtual void KeyUp(const KeyEvent &rKEvt) override
Definition: button.cxx:2355
SAL_DLLPRIVATE WindowImpl * ImplGetWindowImpl() const
Definition: window.hxx:563
void SetState(bool bCheck)
Definition: button.cxx:2576
void CompatStateChanged(StateChangedType nStateChange)
Definition: window.cxx:3907
SAL_DLLPRIVATE void ImplCallClick(bool bGrabFocus=false, GetFocusFlags nFocusFlags=GetFocusFlags::NONE)
Definition: button.cxx:2231
PushButtonDropdownStyle
Definition: button.hxx:107
bool mbNoFocusRectsForFlatButtons
Definition: svdata.hxx:322
tools::Rectangle maMouseRect
void SetTextFillColor()
Definition: text.cxx:697
virtual bool set_property(const OString &rKey, const OUString &rValue) override
Definition: button.cxx:1629
sal_uInt16 GetCode() const
Definition: keycod.hxx:51
void SetParentClipMode(ParentClipMode nMode=ParentClipMode::NONE)
RadioButton(const RadioButton &)=delete
void setTristateVal(ButtonValue nTristate)
tools::Long GetWidth() const
WinBits GetPrevStyle() const
Definition: window2.cxx:958
DataChangedEventType GetType() const
Definition: event.hxx:356
virtual Size GetOptimalSize() const override
Definition: button.cxx:1624
void IntersectClipRegion(const tools::Rectangle &rRect)
DrawButtonFlags
Definition: decoview.hxx:53
SAL_DLLPRIVATE void ImplDrawRadioButtonState(vcl::RenderContext &rRenderContext)
Definition: button.cxx:1867
#define STYLE_CHECKBOX_MONO
Definition: button.cxx:70
constexpr::Color COL_LIGHTGRAY(0xC0, 0xC0, 0xC0)
virtual bool set_property(const OString &rKey, const OUString &rValue) override
Definition: button.cxx:534
SAL_DLLPRIVATE void ImplInit(vcl::Window *pParent, WinBits nStyle)
Definition: button.cxx:1802
const Color & GetControlBackground() const
Definition: window2.cxx:1082
void SetState(TriState eState)
Definition: button.cxx:3461
tools::Rectangle DrawButton(const tools::Rectangle &rRect, DrawButtonFlags nStyle)
Definition: decoview.cxx:931
constexpr sal_uInt16 KEY_SPACE
Definition: keycodes.hxx:123
virtual void ShowFocus(const tools::Rectangle &rRect) override
Definition: button.cxx:1644
virtual void Tracking(const TrackingEvent &rTEvt) override
Definition: button.cxx:1185
SAL_DLLPRIVATE void ImplDrawPushButtonContent(OutputDevice *pDev, DrawFlags nDrawFlags, const tools::Rectangle &rRect, bool bMenuBtnSep, DrawButtonFlags nButtonFlags)
Definition: button.cxx:752
void PaintImmediately()
Definition: paint.cxx:1288
SAL_DLLPRIVATE Size ImplGetRadioImageSize() const
Definition: button.cxx:2661
void SetQuickHelpText(const OUString &rHelpText)
Definition: window2.cxx:1226
TRISTATE_TRUE
void StartTracking(StartTrackingFlags nFlags=StartTrackingFlags::NONE)
Definition: window2.cxx:244
bool IsNativeControlSupported(ControlType nType, ControlPart nPart) const
Query the platform layer for control support.
void SetMapMode()
Definition: map.cxx:546
void SetRight(tools::Long v)
ImplSVCtrlData maCtrlData
Definition: svdata.hxx:395
const Color & GetHighlightColor() const
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects...
Definition: button.cxx:108
void SetDropDown(PushButtonDropdownStyle nStyle)
Definition: button.cxx:1527
IMPL_STATIC_LINK(Button, dispatchCommandHandler, Button *, pButton, void)
Definition: button.cxx:578
SAL_DLLPRIVATE void ImplInit(vcl::Window *pParent, WinBits nStyle)
Definition: button.cxx:606
NONE
SAL_DLLPRIVATE void ImplDrawRadioButton(vcl::RenderContext &rRenderContext)
Definition: button.cxx:2102
bool IsTrackingRepeat() const
Definition: event.hxx:261
The invalidated area is painted with the background color/pattern.
void SetSymbolAlign(SymbolAlign eAlign)
Definition: button.cxx:1522
tools::Rectangle GetControlTextRect(OutputDevice &_rTargetDevice, const tools::Rectangle &rRect, const OUString &_rStr, DrawTextFlags _nStyle, Size *o_pDeviceSize=nullptr) const
Definition: ctrl.cxx:458
bool IsEmpty() const
StateChangedType
Definition: window.hxx:317
WinBits const WB_NOPOINTERFOCUS
void DumpAsPropertyTree(tools::JsonWriter &) override
Button has additional stuff that we need to dump too.
Definition: button.cxx:2878
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
SAL_DLLPRIVATE void ImplDraw(OutputDevice *pDev, DrawFlags nDrawFlags, const Point &rPos, const Size &rSize, const Size &rImageSize, tools::Rectangle &rStateRect, tools::Rectangle &rMouseRect)
Definition: button.cxx:1983
virtual void KeyInput(const KeyEvent &rKEvt) override
Definition: button.cxx:3175
const Color & GetRadioCheckTextColor() const
rtl::Reference< VclStatusListener< Button > > mpStatusListener
StatusListener.
Definition: button.cxx:89
virtual bool set_property(const OString &rKey, const OUString &rValue) override
Definition: button.cxx:3474
sal_Int64 WinBits
void SetBackground()
Size CalcMinimumSize() const
Definition: button.cxx:1587
WinBits const WB_BOTTOM
WinBits const WB_TOP
void Enable(bool bEnable=true, bool bChild=true)
Definition: window.cxx:2431
const Color & GetDefaultButtonRolloverTextColor() const
sal_uInt16 GetButtons() const
Definition: event.hxx:144
tools::Long Left() const
void SetSymbol(SymbolType eSymbol)
Definition: button.cxx:1513
virtual void DumpAsPropertyTree(tools::JsonWriter &)
Dumps itself and potentially its children to a property tree, to be written easily to JSON...
Definition: window.cxx:3351
void SetLeft(tools::Long v)
WinBits const WB_DEFBUTTON
SymbolType
Definition: vclenum.hxx:73
Link< RadioButton &, void > maToggleHdl
PushButton(vcl::Window *pParent, WinBits nStyle=0)
Definition: button.cxx:1158
virtual void GetFocus() override
Definition: button.cxx:3324
const vcl::Font & GetFont() const
Definition: outdev.hxx:649
void ImplAdjustNWFSizes() override
Definition: button.cxx:3607
bool IsControlForeground() const
Definition: window2.cxx:1077
bool IsEnterWindow() const
Definition: event.hxx:135
bool dispatchCommand(const OUString &rCommand, const uno::Reference< css::frame::XFrame > &rFrame, const css::uno::Sequence< css::beans::PropertyValue > &rArguments, const uno::Reference< css::frame::XDispatchResultListener > &rListener)
void EndTracking(TrackingEventFlags nFlags=TrackingEventFlags::NONE)
Definition: window2.cxx:272
virtual const Color & GetCanonicalTextColor(const StyleSettings &_rStyle) const override
Definition: button.cxx:2918
OUString maCommand
Command URL (like .uno:Save) in case the button should handle it.
Definition: button.hxx:45
Link< Button *, void > maClickHdl
Definition: button.hxx:42
ImageAlign meImageAlign
Definition: button.cxx:83
void Hide()
Definition: window.hxx:948
bool IsChecked() const
AllSettingsFlags GetFlags() const
Definition: event.hxx:357
tools::Long Bottom() const
virtual void StateChanged(StateChangedType nStateChange) override
Definition: button.cxx:1785
const Color & GetLightColor() const
Image maCustomContentImage
Definition: button.cxx:86
virtual void GetFocus() override
Definition: button.cxx:1371
virtual void Click()
Definition: button.cxx:124
SAL_DLLPRIVATE tools::Long ImplGetSeparatorX() const
The x-coordinate of the vertical separator line, use in MenuButton subclass only. ...
Definition: button.cxx:177
virtual void queue_resize(StateChangedType eReason=StateChangedType::Layout)
Definition: window2.cxx:1327
static std::unique_ptr< UIObject > create(vcl::Window *pWindow)
void SetImageAlign(ImageAlign eAlign)
Definition: button.cxx:149
SAL_DLLPRIVATE const tools::Rectangle & ImplGetFocusRect() const
Definition: button.cxx:500
bool isAction() const
Definition: button.hxx:168
SAL_DLLPRIVATE DrawTextFlags ImplGetTextStyle(WinBits nWinStyle, DrawFlags nDrawFlags)
Definition: button.cxx:187
sal_uInt16 GetModifier() const
Definition: keycod.hxx:54
tools::Long GetCtrlTextWidth(const OUString &rStr, const SalLayoutGlyphs *pLayoutCache=nullptr) const
Definition: text.cxx:2200
virtual OUString GetText() const
Definition: window.cxx:3057
static Image GetCheckImage(const AllSettings &rSettings, DrawButtonFlags nFlags)
Definition: button.cxx:3526
static SAL_DLLPRIVATE void ImplCalcSymbolRect(tools::Rectangle &rRect)
Definition: brdwin.cxx:44
constexpr auto RADIOBUTTON_VIEW_STYLE
Definition: button.cxx:60
SAL_DLLPRIVATE void ImplInitRadioButtonData()
Definition: button.cxx:1795
Definition: edit.hxx:55
SymbolType meSymbol
Definition: button.hxx:206
Size CalcMinimumSize(tools::Long nMaxWidth=0) const
Definition: button.cxx:2810
virtual void LoseFocus() override
Definition: button.cxx:1378
PushButtonDropdownStyle mnDDStyle
Definition: button.hxx:174
tools::Long AdjustBottom(tools::Long nVertMoveDelta)
void DrawLine(const Point &rStartPt, const Point &rEndPt)
Definition: line.cxx:88
WinBits const WB_BEVELBUTTON
TRISTATE_INDET
bool IsChildTransparentModeEnabled() const
Definition: window2.cxx:1027
SAL_DLLPRIVATE void ImplCheck()
Definition: button.cxx:3093
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
GetFocusFlags
Definition: window.hxx:339
virtual bool PreNotify(NotifyEvent &rNEvt) override
Definition: button.cxx:3434
const Color & GetControlForeground() const
Definition: window2.cxx:1072
virtual void Draw(OutputDevice *pDev, const Point &rPos, DrawFlags nFlags) override
Definition: button.cxx:1322
#define SAL_N_ELEMENTS(arr)
SAL_DLLPRIVATE bool ImplUseNativeBorder(vcl::RenderContext const &rRenderContext, WinBits nStyle)
Definition: edit.cxx:289
static void LoadThemedImageList(const StyleSettings &rStyleSettings, std::vector< Image > &rList, const std::vector< OUString > &rResources)
Definition: button.cxx:2686
virtual void MouseButtonDown(const MouseEvent &rMEvt) override
Definition: button.cxx:2280
WinBits const WB_NOLIGHTBORDER
Point BottomRight() const
const Color & GetDarkShadowColor() const
ImplSVData * ImplGetSVData()
Definition: svdata.cxx:73
virtual bool PreNotify(NotifyEvent &rNEvt) override
Definition: button.cxx:2538
Size CalcWindowSize(const Size &rOutSz) const
Definition: window2.cxx:537
const Color & GetActionButtonRolloverTextColor() const
const vcl::Font & GetPushButtonFont() const
virtual void Click() override
Definition: button.cxx:1770
void setY(tools::Long y)
void SetLineColor()
virtual void ShowFocus(const tools::Rectangle &rRect) override
Definition: button.cxx:3673
virtual bool PreNotify(NotifyEvent &rNEvt)
Definition: event.cxx:50
void SetInputContext(const InputContext &rInputContext)
Definition: window.cxx:2075
bool IsLeaveWindow() const
Definition: event.hxx:137
const Color & GetActionButtonPressedRolloverTextColor() const
void Check(bool bCheck=true)
Definition: button.cxx:2631
int i
DrawFlags
Definition: window.hxx:360
uno_Any a
bool IsChecked() const
Definition: button.hxx:217
virtual bool PreNotify(NotifyEvent &rNEvt) override
Definition: button.cxx:1446
SAL_DLLPRIVATE void ImplInit(vcl::Window *pParent, WinBits nStyle)
Definition: button.cxx:1704
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects...
Definition: button.cxx:2269
bool IsSystemWindow() const
Definition: window2.cxx:997
constexpr auto CHECKBOX_VIEW_STYLE
Definition: button.cxx:64
virtual void Tracking(const TrackingEvent &rTEvt) override
Definition: button.cxx:3134
virtual void SetText(const OUString &rStr) override
Definition: ctrl.cxx:95
tools::Long mnSeparatorX
Definition: button.cxx:78
virtual void Resize() override
Definition: button.cxx:1365
std::unique_ptr< ImplCommonButtonData > mpButtonData
Definition: button.hxx:41
sal_uInt16 mnRadioStyle
Definition: svdata.hxx:277
virtual FactoryFunction GetUITestFactory() const override
Definition: button.cxx:567
WinBits const WB_VCENTER
virtual void Invalidate(InvalidateFlags nFlags=InvalidateFlags::NONE)
Definition: paint.cxx:1164
TRISTATE_FALSE
SAL_DLLPRIVATE DrawTextFlags ImplGetTextStyle(DrawFlags nDrawFlags) const
Definition: button.cxx:717
SAL_DLLPRIVATE Size ImplGetCheckImageSize() const
Definition: button.cxx:3501
void EnableTriState(bool bTriState=true)
Definition: button.cxx:3483
CancelButton(const CancelButton &)=delete
CloseButton(vcl::Window *pParent, WinBits nStyle=0)
Definition: button.cxx:1750
bool IsUpdateMode() const
Definition: window2.cxx:1173
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
const Color & GetFieldColor() const
std::vector< VclPtr< RadioButton > > GetRadioButtonGroup(bool bIncludeThis=true) const
GetRadioButtonGroup returns a list of pointers to RadioButtons in the same group. ...
Definition: button.cxx:2165
bool IsChecked() const
virtual FactoryFunction GetUITestFactory() const override
Definition: button.cxx:2884
bool IsDialog() const
Definition: window2.cxx:1002
void SetTextColor(const Color &rColor)
Definition: text.cxx:662
virtual const vcl::Font & GetCanonicalFont(const StyleSettings &_rStyle) const override
Definition: button.cxx:1826
std::unique_ptr< WindowImpl > mpWindowImpl
Definition: window.hxx:519
WinBits const WB_SMALLSTYLE
DrawSymbolFlags
Definition: decoview.hxx:34
virtual Size GetOptimalSize() const override
Definition: button.cxx:2858
bool IsZoom() const
Definition: window2.cxx:1215
WinBits const WB_RECTSTYLE
virtual void KeyInput(const KeyEvent &rKEvt) override
Definition: button.cxx:2334
virtual void KeyUp(const KeyEvent &rKEvt) override
Definition: button.cxx:3196
MouseNotifyEvent GetType() const
Definition: event.hxx:302
bool IsInside(const Point &rPOINT) const
bool DrawNativeControl(ControlType nType, ControlPart nPart, const tools::Rectangle &rControlRegion, ControlState nState, const ImplControlValue &aValue, const OUString &aCaption, const Color &rBackgroundColor=COL_AUTO)
Request rendering of a particular control and/or part.
void SetTop(tools::Long v)
void SetBottom(tools::Long v)
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:1026
Size GetOutputSizePixel() const
Definition: outdev.hxx:441
DrawTextFlags
Definition: outdev.hxx:143
TriState meState
bool IsInExecute() const
Definition: dialog.hxx:122
virtual bool set_property(const OString &rKey, const OUString &rValue)
Definition: window2.cxx:1445
static SAL_DLLPRIVATE WinBits ImplInitStyle(const vcl::Window *pPrevWindow, WinBits nStyle)
Definition: button.cxx:617
tools::Long Top() const
virtual void LoseFocus()
Definition: window.cxx:1854
Button(const Button &)=delete
void DumpAsPropertyTree(tools::JsonWriter &) override
Button has additional stuff that we need to dump too.
Definition: button.cxx:3688
virtual const Color & GetCanonicalTextColor(const StyleSettings &_rStyle) const override
Definition: button.cxx:643
Point ScreenToOutputPixel(const Point &rPos) const
Definition: window.cxx:2807
void GrabFocus()
Definition: window.cxx:2978
bool mbUsesExplicitGroup
virtual void ShowFocus(const tools::Rectangle &rRect)
Definition: window2.cxx:49
vcl::Window * GetParent() const
Definition: window2.cxx:1097
virtual void FillLayoutData() const override
Definition: button.cxx:2368
WinBits const WB_LEFT
const Color & GetDefaultActionButtonPressedRolloverTextColor() const
virtual void GetFocus() override
Definition: button.cxx:2459
void Toggle()
Definition: button.cxx:1508
SAL_DLLPRIVATE void ImplDrawPushButton(vcl::RenderContext &rRenderContext)
Definition: button.cxx:880
bool IsTrackingEnded() const
Definition: event.hxx:263
void SetStyle(WinBits nStyle)
Definition: window.cxx:1961
virtual void Draw(OutputDevice *pDev, const Point &rPos, DrawFlags nFlags) override
Definition: button.cxx:3220
void DrawSeparator(const Point &rStart, const Point &rStop, bool bVertical=true)
Definition: decoview.cxx:1010
Size GetSize() const
virtual void Draw(OutputDevice *pDev, const Point &rPos, DrawFlags nFlags) override
Definition: button.cxx:2379
virtual void MouseButtonDown(const MouseEvent &rMEvt) override
Definition: button.cxx:3121
void put(const char *pPropName, const OUString &rPropValue)
WinBits const WB_REPEAT
constexpr sal_uInt16 KEY_RETURN
Definition: keycodes.hxx:119
SAL_DLLPRIVATE void ImplInitPushButtonData()
Definition: button.cxx:586
const Color & GetButtonRolloverTextColor() const
SAL_DLLPRIVATE void ImplInitStyle()
Definition: button.cxx:3705
const Color & GetDefaultActionButtonRolloverTextColor() const
StyleSettingsOptions GetOptions() const
tools::Long AdjustTop(tools::Long nVertMoveDelta)
vcl::Window * GetWindow(GetWindowType nType) const
Definition: stacking.cxx:1039
virtual void StateChanged(StateChangedType nType) override
Definition: button.cxx:2478
Point LogicToPixel(const Point &rLogicPt) const
Definition: map.cxx:828
bool HasImage() const
Definition: button.cxx:144
ControlType
These types are all based on the supported variants vcl/salnativewidgets.hxx and must be kept in-sync...
virtual void setPosSizePixel(tools::Long nX, tools::Long nY, tools::Long nWidth, tools::Long nHeight, PosSizeFlags nFlags=PosSizeFlags::All)
Definition: window.cxx:2664
virtual void KeyInput(const KeyEvent &rKEvt)
Definition: window.cxx:1804
SAL_DLLPRIVATE void ImplInit(vcl::Window *pParent, WinBits nStyle, SystemParentData *pSystemParentData)
Definition: window.cxx:937
WinBits const WB_3DLOOK
bool mbUseNativeFocus
Definition: window.h:317
SAL_DLLPRIVATE void ImplInit(vcl::Window *pParent, WinBits nStyle)
Definition: button.cxx:2895
DrawButtonFlags GetButtonState() const
Definition: button.cxx:510
bool IsModifierChanged() const
Definition: event.hxx:141
virtual const Color & GetCanonicalTextColor(const StyleSettings &_rStyle) const override
Definition: button.cxx:1831
OKButton(const OKButton &)=delete
void set_id(const OUString &rID)
Sets an ID.
Definition: window.cxx:3939
void SetCustomButtonImage(const Image &rImage)
Set an image to use as the complete render view of a custom button, instead of the usual contents of ...
Definition: button.cxx:163
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
Definition: button.cxx:1311
virtual bool set_property(const OString &rKey, const OUString &rValue) override
Definition: button.cxx:2592
virtual void StateChanged(StateChangedType nType) override
Definition: button.cxx:1385
virtual const vcl::Font & GetCanonicalFont(const StyleSettings &_rStyle) const override
Definition: button.cxx:2913
const sal_uInt32 LEFT
virtual void ImplDrawCheckBoxState(vcl::RenderContext &rRenderContext)
Definition: button.cxx:2954
void ImplAdjustNWFSizes() override
Definition: button.cxx:2783
const vcl::KeyCode & GetKeyCode() const
Definition: event.hxx:54
static vcl::Window * GetFocusWindow()
Get the currently focused window.
Definition: svapp.cxx:1059
SAL_DLLPRIVATE void ImplDraw(OutputDevice *pDev, DrawFlags nDrawFlags, const Point &rPos, const Size &rSize, const Size &rImageSize, tools::Rectangle &rStateRect, tools::Rectangle &rMouseRect)
Definition: button.cxx:3001
void SetSmallSymbol()
Definition: button.cxx:524
void SetPressed(bool bPressed)
Definition: button.cxx:1566
void SetFaceColor(const Color &rColor)
static SAL_DLLPRIVATE DrawTextFlags ImplGetTextStyle(WinBits nWinBits)
Definition: fixed.cxx:104
bool IsMouseOver() const
Definition: mouse.cxx:606
virtual void Resize() override
Definition: ctrl.cxx:74
SAL_DLLPRIVATE bool ImplIsDefButton() const
Definition: button.cxx:1147
static SAL_DLLPRIVATE bool ImplHitTestPushButton(vcl::Window const *pDev, const Point &rPos)
Definition: button.cxx:709
WindowType
std::vector< Image > maCheckImgList
Definition: svdata.hxx:271
SAL_DLLPRIVATE tools::Long ImplGetImageToTextDistance() const
Definition: button.cxx:2654
Definition: ctrl.hxx:33
virtual void Resize() override
Definition: button.cxx:3318
bool IsSynthetic() const
Definition: event.hxx:139
virtual void GetFocus()
Definition: window.cxx:1840
tools::Rectangle & Union(const tools::Rectangle &rRect)
const Color & GetButtonTextColor() const
bool mbNoFocusRects
Definition: svdata.hxx:321
const Color & GetDefaultActionButtonTextColor() const
SAL_DLLPRIVATE void ImplDrawAlignedImage(OutputDevice *pDev, Point &rPos, Size &rSize, sal_uLong nImageSep, DrawTextFlags nTextStyle, tools::Rectangle *pSymbolRect=nullptr, bool bAddImageSep=false)
Definition: button.cxx:204
constexpr sal_uInt16 KEY_ESCAPE
Definition: keycodes.hxx:120
void SetFont(const vcl::Font &rNewFont)
std::vector< Image > maRadioImgList
Definition: svdata.hxx:272
const MouseEvent * GetMouseEvent() const
Definition: event.hxx:318
std::unique_ptr< vcl::ImplControlData > mpControlData
Definition: ctrl.hxx:36
SAL_DLLPRIVATE void ImplDrawCheckBox(vcl::RenderContext &rRenderContext)
Definition: button.cxx:3077
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
Definition: button.cxx:2374
const Color & GetFlatButtonRolloverTextColor() const
const ::std::vector< Color > ImpSvNumberformatScan::StandardColor COL_WHITE
tools::Long GetTextHeight() const
Height where any character of the current font fits; in logic coordinates.
Definition: text.cxx:891
sal_Int32 get_width_request() const
Definition: window2.cxx:1916
virtual void Tracking(const TrackingEvent &rTEvt) override
Definition: button.cxx:2293
const Color & GetFlatButtonPressedRolloverTextColor() const
virtual void DumpAsPropertyTree(tools::JsonWriter &) override
Dumps itself and potentially its children to a property tree, to be written easily to JSON...
Definition: button.cxx:572
vcl::Font GetDrawPixelFont(::OutputDevice const *pDev) const
Definition: window2.cxx:553
::OutputDevice const * GetOutDev() const
Definition: window.cxx:578
virtual FactoryFunction GetUITestFactory() const override
Definition: button.cxx:3694
void EnableChildTransparentMode(bool bEnable=true)
Definition: window2.cxx:1022
bool IsLeft() const
Definition: event.hxx:146
virtual void DataChanged(const DataChangedEvent &rDCEvt) override
Definition: button.cxx:2524
tools::Long AdjustWidth(tools::Long n)
Definition: image.hxx:39
tools::Rectangle maFocusRect
Definition: button.cxx:77
SAL_DLLPRIVATE WinBits ImplInitStyle(const vcl::Window *pPrevWindow, WinBits nStyle)
Definition: button.cxx:1810
Color mnLastRadioFColor
Definition: svdata.hxx:281
virtual void KeyUp(const KeyEvent &rKEvt) override
Definition: button.cxx:1274
void SetState(TriState eState)
Definition: button.cxx:1536
tools::Long Height() const
virtual void ShowFocus(const tools::Rectangle &rRect) override
Definition: button.cxx:2863
tools::Long CalcZoom(tools::Long n) const
Definition: window2.cxx:397
tools::Long GetDrawPixel(::OutputDevice const *pDev, tools::Long nPixels) const
Definition: window2.cxx:563
const ::std::vector< Color > ImpSvNumberformatScan::StandardColor COL_BLACK
Image const & GetModeImage() const
Definition: button.cxx:139