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