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  const tools::Rectangle& rRect, bool bMenuBtnSep,
733  DrawButtonFlags nButtonFlags)
734 {
735  const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
736  tools::Rectangle aInRect = rRect;
737  Color aColor;
738  DrawTextFlags nTextStyle = ImplGetTextStyle( nDrawFlags );
739  DrawSymbolFlags nStyle;
740 
741  if( aInRect.Right() < aInRect.Left() || aInRect.Bottom() < aInRect.Top() )
742  return; // nothing to do
743 
744  pDev->Push( PushFlags::CLIPREGION );
745  pDev->IntersectClipRegion( aInRect );
746 
747  if ( nDrawFlags & DrawFlags::Mono )
748  aColor = COL_BLACK;
750  {
751  if (nButtonFlags & DrawButtonFlags::Pressed)
752  aColor = rStyleSettings.GetButtonPressedRolloverTextColor();
753  else
754  aColor = isAction() ? rStyleSettings.GetActionButtonRolloverTextColor()
755  : rStyleSettings.GetButtonRolloverTextColor();
756  }
757  else if ( IsControlForeground() )
758  aColor = GetControlForeground();
759  else if( nButtonFlags & DrawButtonFlags::Highlight )
760  {
761  if (nButtonFlags & DrawButtonFlags::Pressed)
762  aColor = rStyleSettings.GetButtonPressedRolloverTextColor();
763  else
764  aColor = isAction() ? rStyleSettings.GetActionButtonRolloverTextColor()
765  : rStyleSettings.GetButtonRolloverTextColor();
766  }
767  else
768  {
770  ? rStyleSettings.GetDefaultActionButtonTextColor()
771  : rStyleSettings.GetActionButtonTextColor())
772  : rStyleSettings.GetButtonTextColor();
773  }
774 
775  pDev->SetTextColor( aColor );
776 
777  if ( IsEnabled() )
778  nStyle = DrawSymbolFlags::NONE;
779  else
780  nStyle = DrawSymbolFlags::Disable;
781 
782  Size aSize = rRect.GetSize();
783  Point aPos = rRect.TopLeft();
784 
785  sal_uLong nImageSep = 1 + (pDev->GetTextHeight()-10)/2;
786  if( nImageSep < 1 )
787  nImageSep = 1;
790  {
791  long nSeparatorX = 0;
792  tools::Rectangle aSymbolRect = aInRect;
793 
794  // calculate symbol size
795  long nSymbolSize = pDev->GetTextHeight() / 2 + 1;
796 
797  nSeparatorX = aInRect.Right() - 2*nSymbolSize;
798  aSize.AdjustWidth( -(2*nSymbolSize) );
799 
800  // center symbol rectangle in the separated area
801  aSymbolRect.AdjustRight( -(nSymbolSize/2) );
802  aSymbolRect.SetLeft( aSymbolRect.Right() - nSymbolSize );
803 
804  ImplDrawAlignedImage( pDev, aPos, aSize, nImageSep,
805  nTextStyle, nullptr, true );
806 
807  long nDistance = (aSymbolRect.GetHeight() > 10) ? 2 : 1;
808  DecorationView aDecoView( pDev );
809  if( bMenuBtnSep && nSeparatorX > 0 )
810  {
811  Point aStartPt( nSeparatorX, aSymbolRect.Top()+nDistance );
812  Point aEndPt( nSeparatorX, aSymbolRect.Bottom()-nDistance );
813  aDecoView.DrawSeparator( aStartPt, aEndPt );
814  }
815  ImplSetSeparatorX( nSeparatorX );
816 
817  aDecoView.DrawSymbol( aSymbolRect, SymbolType::SPIN_DOWN, aColor, nStyle );
818 
819  }
820  else
821  {
822  tools::Rectangle aSymbolRect;
823  ImplDrawAlignedImage( pDev, aPos, aSize, nImageSep,
824  nTextStyle, IsSymbol() ? &aSymbolRect : nullptr, true );
825 
826  if ( IsSymbol() )
827  {
828  DecorationView aDecoView( pDev );
829  aDecoView.DrawSymbol( aSymbolRect, meSymbol, aColor, nStyle );
830  }
831  }
832 
833  pDev->Pop(); // restore clipregion
834 }
835 
837 {
838  HideFocus();
839 
840  DrawButtonFlags nButtonStyle = GetButtonState();
841  Size aOutSz(GetOutputSizePixel());
842  tools::Rectangle aRect(Point(), aOutSz);
843  tools::Rectangle aInRect = aRect;
844  bool bNativeOK = false;
845 
846  // adjust style if button should be rendered 'pressed'
847  if (mbPressed || mbIsActive)
848  nButtonStyle |= DrawButtonFlags::Pressed;
849 
850  // TODO: move this to Window class or make it a member !!!
851  ControlType aCtrlType = ControlType::Generic;
852  switch(GetParent()->GetType())
853  {
854  case WindowType::LISTBOX:
855  case WindowType::MULTILISTBOX:
856  case WindowType::TREELISTBOX:
857  aCtrlType = ControlType::Listbox;
858  break;
859 
860  case WindowType::COMBOBOX:
861  case WindowType::PATTERNBOX:
862  case WindowType::NUMERICBOX:
863  case WindowType::METRICBOX:
864  case WindowType::CURRENCYBOX:
865  case WindowType::DATEBOX:
866  case WindowType::TIMEBOX:
867  case WindowType::LONGCURRENCYBOX:
868  aCtrlType = ControlType::Combobox;
869  break;
870  default:
871  break;
872  }
873 
874  bool bDropDown = (IsSymbol() && (GetSymbol() == SymbolType::SPIN_DOWN) && GetText().isEmpty());
875 
876  if( bDropDown && (aCtrlType == ControlType::Combobox || aCtrlType == ControlType::Listbox))
877  {
879  {
880  // skip painting if the button was already drawn by the theme
881  if (aCtrlType == ControlType::Combobox)
882  {
883  Edit* pEdit = static_cast<Edit*>(GetParent());
884  if (pEdit->ImplUseNativeBorder(rRenderContext, pEdit->GetStyle()))
885  bNativeOK = true;
886  }
888  {
889  bNativeOK = true;
890  }
891 
892  if (!bNativeOK && GetParent()->IsNativeControlSupported(aCtrlType, ControlPart::ButtonDown))
893  {
894  // let the theme draw it, note we then need support
895  // for ControlType::Listbox/ControlPart::ButtonDown and ControlType::Combobox/ControlPart::ButtonDown
896 
897  ImplControlValue aControlValue;
899 
900  if (mbPressed || mbIsActive)
901  nState |= ControlState::PRESSED;
903  nState |= ControlState::PRESSED;
904  if (HasFocus())
905  nState |= ControlState::FOCUSED;
907  nState |= ControlState::DEFAULT;
908  if (Window::IsEnabled())
909  nState |= ControlState::ENABLED;
910 
911  if (IsMouseOver() && aInRect.IsInside(GetPointerPosPixel()))
912  nState |= ControlState::ROLLOVER;
913 
914  if ( IsMouseOver() && aInRect.IsInside(GetPointerPosPixel()) && mbIsActive)
915  {
916  nState |= ControlState::ROLLOVER;
917  nButtonStyle &= ~DrawButtonFlags::Pressed;
918  }
919 
920  bNativeOK = rRenderContext.DrawNativeControl(aCtrlType, ControlPart::ButtonDown, aInRect, nState,
921  aControlValue, OUString());
922  }
923  }
924  }
925 
926  if (bNativeOK)
927  return;
928 
929  bool bRollOver = (IsMouseOver() && aInRect.IsInside(GetPointerPosPixel()));
930  if (bRollOver)
931  nButtonStyle |= DrawButtonFlags::Highlight;
933  if (GetStyle() & WB_FLATBUTTON)
934  {
935  if (!bRollOver && !HasFocus())
936  bDrawMenuSep = false;
937  }
938  // tdf#123175 if there is a custom control bg set, draw the button without outsourcing to the NWF
940  if (bNativeOK)
941  {
942  PushButtonValue aControlValue;
943  aControlValue.mbIsAction = isAction();
944 
945  tools::Rectangle aCtrlRegion(aInRect);
947 
948  if (mbPressed || IsChecked() || mbIsActive)
949  {
950  nState |= ControlState::PRESSED;
951  nButtonStyle |= DrawButtonFlags::Pressed;
952  }
954  nState |= ControlState::PRESSED;
955  if (HasFocus())
956  nState |= ControlState::FOCUSED;
958  nState |= ControlState::DEFAULT;
959  if (Window::IsEnabled())
960  nState |= ControlState::ENABLED;
961 
962  if (bRollOver || mbIsActive)
963  {
964  nButtonStyle |= DrawButtonFlags::Highlight;
965  nState |= ControlState::ROLLOVER;
966  }
967 
968  if (mbIsActive && bRollOver)
969  {
970  nState &= ~ControlState::PRESSED;
971  nButtonStyle &= ~DrawButtonFlags::Pressed;
972  }
973 
974  if (GetStyle() & WB_BEVELBUTTON)
975  aControlValue.mbBevelButton = true;
976 
977  // draw frame into invisible window to have aInRect modified correctly
978  // but do not shift the inner rect for pressed buttons (ie remove DrawButtonFlags::Pressed)
979  // this assumes the theme has enough visual cues to signalize the button was pressed
980  //Window aWin( this );
981  //ImplDrawPushButtonFrame( &aWin, aInRect, nButtonStyle & ~DrawButtonFlags::Pressed );
982 
983  // looks better this way as symbols were displaced slightly using the above approach
984  aInRect.AdjustTop(4 );
985  aInRect.AdjustBottom( -4 );
986  aInRect.AdjustLeft(4 );
987  aInRect.AdjustRight( -4 );
988 
989  // prepare single line hint (needed on mac to decide between normal push button and
990  // rectangular bevel button look)
991  Size aFontSize(Application::GetSettings().GetStyleSettings().GetPushButtonFont().GetFontSize());
992  aFontSize = rRenderContext.LogicToPixel(aFontSize, MapMode(MapUnit::MapPoint));
993  Size aInRectSize(rRenderContext.LogicToPixel(Size(aInRect.GetWidth(), aInRect.GetHeight())));
994  aControlValue.mbSingleLine = (aInRectSize.Height() < 2 * aFontSize.Height());
995 
996  if ((nState & ControlState::ROLLOVER) || !(GetStyle() & WB_FLATBUTTON))
997  {
998  bNativeOK = rRenderContext.DrawNativeControl(ControlType::Pushbutton, ControlPart::Entire, aCtrlRegion, nState,
999  aControlValue, OUString() /*PushButton::GetText()*/);
1000  }
1001  else
1002  {
1003  bNativeOK = true;
1004  }
1005 
1006  // draw content using the same aInRect as non-native VCL would do
1007  ImplDrawPushButtonContent(&rRenderContext, DrawFlags::NONE,
1008  aInRect, bDrawMenuSep, nButtonStyle);
1009 
1010  if (HasFocus())
1012  }
1013 
1014  if (!bNativeOK)
1015  {
1016  // draw PushButtonFrame, aInRect has content size afterwards
1017  if (GetStyle() & WB_FLATBUTTON)
1018  {
1019  tools::Rectangle aTempRect(aInRect);
1020  if (bRollOver)
1021  ImplDrawPushButtonFrame(rRenderContext, aTempRect, nButtonStyle);
1022  aInRect.AdjustLeft(2 );
1023  aInRect.AdjustTop(2 );
1024  aInRect.AdjustRight( -2 );
1025  aInRect.AdjustBottom( -2 );
1026  }
1027  else
1028  {
1029  ImplDrawPushButtonFrame(rRenderContext, aInRect, nButtonStyle);
1030  }
1031 
1032  // draw content
1033  ImplDrawPushButtonContent(&rRenderContext, DrawFlags::NONE, aInRect, bDrawMenuSep, nButtonStyle);
1034 
1035  if (HasFocus())
1036  {
1038  }
1039  }
1040 }
1041 
1043 {
1044  Size aSize( GetSizePixel() );
1045  Point aPos( GetPosPixel() );
1046  int dLeft(0), dRight(0), dTop(0), dBottom(0);
1047  bool bSetPos = false;
1048 
1050  {
1051  tools::Rectangle aBound, aCont;
1052  tools::Rectangle aCtrlRegion( 0, 0, 80, 20 ); // use a constant size to avoid accumulating
1053  // will not work if the theme has dynamic adornment sizes
1054  ImplControlValue aControlValue;
1055 
1056  // get native size of a 'default' button
1057  // and adjust the VCL button if more space for adornment is required
1060  aControlValue,
1061  aBound, aCont ) )
1062  {
1063  dLeft = aCont.Left() - aBound.Left();
1064  dTop = aCont.Top() - aBound.Top();
1065  dRight = aBound.Right() - aCont.Right();
1066  dBottom = aBound.Bottom() - aCont.Bottom();
1067  bSetPos = dLeft || dTop || dRight || dBottom;
1068  }
1069  }
1070 
1071  if ( bSet )
1072  {
1073  if( !(GetButtonState() & DrawButtonFlags::Default) && bSetPos )
1074  {
1075  // adjust pos/size when toggling from non-default to default
1076  aPos.Move(-dLeft, -dTop);
1077  aSize.AdjustWidth(dLeft + dRight );
1078  aSize.AdjustHeight(dTop + dBottom );
1079  }
1081  }
1082  else
1083  {
1084  if( (GetButtonState() & DrawButtonFlags::Default) && bSetPos )
1085  {
1086  // adjust pos/size when toggling from default to non-default
1087  aPos.Move(dLeft, dTop);
1088  aSize.AdjustWidth( -(dLeft + dRight) );
1089  aSize.AdjustHeight( -(dTop + dBottom) );
1090  }
1091  GetButtonState() &= ~DrawButtonFlags::Default;
1092  }
1093  if( bSetPos )
1094  setPosSizePixel( aPos.X(), aPos.Y(), aSize.Width(), aSize.Height() );
1095 
1096  Invalidate();
1097 }
1098 
1100 {
1101  return bool(GetButtonState() & DrawButtonFlags::Default);
1102 }
1103 
1105  Button( nType )
1106 {
1108 }
1109 
1112 {
1114  ImplInit( pParent, nStyle );
1115 }
1116 
1118 {
1119  if ( rMEvt.IsLeft() &&
1120  ImplHitTestPushButton( this, rMEvt.GetPosPixel() ) )
1121  {
1123 
1124  if ( ( GetStyle() & WB_REPEAT ) &&
1125  ! ( GetStyle() & WB_TOGGLE ) )
1126  nTrackFlags |= StartTrackingFlags::ButtonRepeat;
1127 
1129  Invalidate();
1130  StartTracking( nTrackFlags );
1131 
1132  if ( nTrackFlags & StartTrackingFlags::ButtonRepeat )
1133  Click();
1134  }
1135 }
1136 
1138 {
1139  if ( rTEvt.IsTrackingEnded() )
1140  {
1142  {
1143  if ( !(GetStyle() & WB_NOPOINTERFOCUS) && !rTEvt.IsTrackingCanceled() )
1144  GrabFocus();
1145 
1146  if ( GetStyle() & WB_TOGGLE )
1147  {
1148  // Don't toggle, when aborted
1149  if ( !rTEvt.IsTrackingCanceled() )
1150  {
1151  if ( IsChecked() )
1152  {
1153  Check( false );
1155  }
1156  else
1157  Check();
1158  }
1159  }
1160  else
1162 
1163  Invalidate();
1164 
1165  // do not call Click handler if aborted
1166  if ( !rTEvt.IsTrackingCanceled() )
1167  {
1168  if ( ! ( ( GetStyle() & WB_REPEAT ) &&
1169  ! ( GetStyle() & WB_TOGGLE ) ) )
1170  Click();
1171  }
1172  }
1173  }
1174  else
1175  {
1176  if ( ImplHitTestPushButton( this, rTEvt.GetMouseEvent().GetPosPixel() ) )
1177  {
1179  {
1180  if ( rTEvt.IsTrackingRepeat() && (GetStyle() & WB_REPEAT) &&
1181  ! ( GetStyle() & WB_TOGGLE ) )
1182  Click();
1183  }
1184  else
1185  {
1187  Invalidate();
1188  }
1189  }
1190  else
1191  {
1193  {
1195  Invalidate();
1196  }
1197  }
1198  }
1199 }
1200 
1201 void PushButton::KeyInput( const KeyEvent& rKEvt )
1202 {
1203  vcl::KeyCode aKeyCode = rKEvt.GetKeyCode();
1204 
1205  if ( !aKeyCode.GetModifier() &&
1206  ((aKeyCode.GetCode() == KEY_RETURN) || (aKeyCode.GetCode() == KEY_SPACE)) )
1207  {
1209  {
1211  Invalidate();
1212  }
1213 
1214  if ( ( GetStyle() & WB_REPEAT ) &&
1215  ! ( GetStyle() & WB_TOGGLE ) )
1216  Click();
1217  }
1218  else if ( (GetButtonState() & DrawButtonFlags::Pressed) && (aKeyCode.GetCode() == KEY_ESCAPE) )
1219  {
1221  Invalidate();
1222  }
1223  else
1224  Button::KeyInput( rKEvt );
1225 }
1226 
1227 void PushButton::KeyUp( const KeyEvent& rKEvt )
1228 {
1229  vcl::KeyCode aKeyCode = rKEvt.GetKeyCode();
1230 
1232  ((aKeyCode.GetCode() == KEY_RETURN) || (aKeyCode.GetCode() == KEY_SPACE)) )
1233  {
1234  if ( GetStyle() & WB_TOGGLE )
1235  {
1236  if ( IsChecked() )
1237  {
1238  Check( false );
1240  }
1241  else
1242  Check();
1243 
1244  Toggle();
1245  }
1246  else
1248 
1249  Invalidate();
1250 
1251  if ( !( ( GetStyle() & WB_REPEAT ) &&
1252  ! ( GetStyle() & WB_TOGGLE ) ) )
1253  Click();
1254  }
1255  else
1256  Button::KeyUp( rKEvt );
1257 }
1258 
1260 {
1261  mpControlData->mpLayoutData.reset( new vcl::ControlLayoutData );
1262  const_cast<PushButton*>(this)->Invalidate();
1263 }
1264 
1266 {
1267  ImplDrawPushButton(rRenderContext);
1268 }
1269 
1270 void PushButton::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize,
1271  DrawFlags nFlags )
1272 {
1273  Point aPos = pDev->LogicToPixel( rPos );
1274  Size aSize = pDev->LogicToPixel( rSize );
1275  tools::Rectangle aRect( aPos, aSize );
1276  vcl::Font aFont = GetDrawPixelFont( pDev );
1277 
1278  pDev->Push();
1279  pDev->SetMapMode();
1280  pDev->SetFont( aFont );
1281  if ( nFlags & DrawFlags::Mono )
1282  {
1283  pDev->SetTextColor( COL_BLACK );
1284  }
1285  else
1286  {
1287  pDev->SetTextColor( GetTextColor() );
1288 
1289  // DecoView uses the FaceColor...
1290  AllSettings aSettings = pDev->GetSettings();
1291  StyleSettings aStyleSettings = aSettings.GetStyleSettings();
1292  if ( IsControlBackground() )
1293  aStyleSettings.SetFaceColor( GetControlBackground() );
1294  else
1295  aStyleSettings.SetFaceColor( GetSettings().GetStyleSettings().GetFaceColor() );
1296  aSettings.SetStyleSettings( aStyleSettings );
1297  pDev->OutputDevice::SetSettings( aSettings );
1298  }
1299  pDev->SetTextFillColor();
1300 
1301  DecorationView aDecoView( pDev );
1302  DrawButtonFlags nButtonStyle = DrawButtonFlags::NONE;
1303  if ( nFlags & DrawFlags::Mono )
1304  nButtonStyle |= DrawButtonFlags::Mono;
1305  if ( IsChecked() )
1306  nButtonStyle |= DrawButtonFlags::Checked;
1307  aRect = aDecoView.DrawButton( aRect, nButtonStyle );
1308 
1309  ImplDrawPushButtonContent( pDev, nFlags, aRect, true, nButtonStyle );
1310  pDev->Pop();
1311 }
1312 
1314 {
1315  Control::Resize();
1316  Invalidate();
1317 }
1318 
1320 {
1323  Button::GetFocus();
1324 }
1325 
1327 {
1328  EndSelection();
1329  HideFocus();
1331 }
1332 
1334 {
1335  Button::StateChanged( nType );
1336 
1337  if ( (nType == StateChangedType::Enable) ||
1338  (nType == StateChangedType::Text) ||
1339  (nType == StateChangedType::Data) ||
1340  (nType == StateChangedType::State) ||
1341  (nType == StateChangedType::UpdateMode) )
1342  {
1343  if ( IsReallyVisible() && IsUpdateMode() )
1344  Invalidate();
1345  }
1346  else if ( nType == StateChangedType::Style )
1347  {
1349 
1350  bool bIsDefButton = ( GetStyle() & WB_DEFBUTTON ) != 0;
1351  bool bWasDefButton = ( GetPrevStyle() & WB_DEFBUTTON ) != 0;
1352  if ( bIsDefButton != bWasDefButton )
1353  ImplSetDefButton( bIsDefButton );
1354 
1355  if ( IsReallyVisible() && IsUpdateMode() )
1356  {
1357  if ( (GetPrevStyle() & PUSHBUTTON_VIEW_STYLE) !=
1359  Invalidate();
1360  }
1361  }
1362  else if ( (nType == StateChangedType::Zoom) ||
1363  (nType == StateChangedType::ControlFont) )
1364  {
1365  ImplInitSettings( false );
1366  Invalidate();
1367  }
1368  else if ( nType == StateChangedType::ControlForeground )
1369  {
1370  ImplInitSettings( false );
1371  Invalidate();
1372  }
1373  else if ( nType == StateChangedType::ControlBackground )
1374  {
1375  ImplInitSettings( true );
1376  Invalidate();
1377  }
1378 }
1379 
1381 {
1382  Button::DataChanged( rDCEvt );
1383 
1384  if ( (rDCEvt.GetType() == DataChangedEventType::FONTS) ||
1386  ((rDCEvt.GetType() == DataChangedEventType::SETTINGS) &&
1387  (rDCEvt.GetFlags() & AllSettingsFlags::STYLE)) )
1388  {
1389  ImplInitSettings( true );
1390  Invalidate();
1391  }
1392 }
1393 
1395 {
1396  const MouseEvent* pMouseEvt = nullptr;
1397 
1398  if( (rNEvt.GetType() == MouseNotifyEvent::MOUSEMOVE) && (pMouseEvt = rNEvt.GetMouseEvent()) != nullptr )
1399  {
1400  if( pMouseEvt->IsEnterWindow() || pMouseEvt->IsLeaveWindow() )
1401  {
1402  // trigger redraw as mouse over state has changed
1403 
1404  // TODO: move this to Window class or make it a member !!!
1405  ControlType aCtrlType = ControlType::Generic;
1406  switch( GetParent()->GetType() )
1407  {
1408  case WindowType::LISTBOX:
1409  case WindowType::MULTILISTBOX:
1410  case WindowType::TREELISTBOX:
1411  aCtrlType = ControlType::Listbox;
1412  break;
1413 
1414  case WindowType::COMBOBOX:
1415  case WindowType::PATTERNBOX:
1416  case WindowType::NUMERICBOX:
1417  case WindowType::METRICBOX:
1418  case WindowType::CURRENCYBOX:
1419  case WindowType::DATEBOX:
1420  case WindowType::TIMEBOX:
1421  case WindowType::LONGCURRENCYBOX:
1422  aCtrlType = ControlType::Combobox;
1423  break;
1424  default:
1425  break;
1426  }
1427 
1428  bool bDropDown = ( IsSymbol() && (GetSymbol()==SymbolType::SPIN_DOWN) && GetText().isEmpty() );
1429 
1430  if( bDropDown && GetParent()->IsNativeControlSupported( aCtrlType, ControlPart::Entire) &&
1432  {
1434  if(aCtrlType == ControlType::Combobox)
1435  {
1436  // only paint the button part to avoid flickering of the combobox text
1437  tools::Rectangle aClipRect( Point(), GetOutputSizePixel() );
1438  aClipRect.SetPos(pBorder->ScreenToOutputPixel(OutputToScreenPixel(aClipRect.TopLeft())));
1439  pBorder->Invalidate( aClipRect );
1440  }
1441  else
1442  {
1444  pBorder->Update();
1445  }
1446  }
1447  else if( (GetStyle() & WB_FLATBUTTON) ||
1449  {
1450  Invalidate();
1451  }
1452  }
1453  }
1454 
1455  return Button::PreNotify(rNEvt);
1456 }
1457 
1459 {
1461 }
1462 
1464 {
1465  if ( meSymbol != eSymbol )
1466  {
1467  meSymbol = eSymbol;
1469  }
1470 }
1471 
1473 {
1474  ImplSetSymbolAlign( eAlign );
1475 }
1476 
1478 {
1479  if ( mnDDStyle != nStyle )
1480  {
1481  mnDDStyle = nStyle;
1483  }
1484 }
1485 
1487 {
1488  if ( meState != eState )
1489  {
1490  meState = eState;
1491  if ( meState == TRISTATE_FALSE )
1493  else if ( meState == TRISTATE_TRUE )
1494  {
1495  GetButtonState() &= ~DrawButtonFlags::DontKnow;
1497  }
1498  else // TRISTATE_INDET
1499  {
1500  GetButtonState() &= ~DrawButtonFlags::Checked;
1502  }
1503 
1505  Toggle();
1506  }
1507 }
1508 
1509 void PushButton::statusChanged(const css::frame::FeatureStateEvent& rEvent)
1510 {
1511  Button::statusChanged(rEvent);
1512  if (rEvent.State.has<bool>())
1513  SetPressed(rEvent.State.get<bool>());
1514 }
1515 
1516 void PushButton::SetPressed( bool bPressed )
1517 {
1518  if ( mbPressed != bPressed )
1519  {
1520  mbPressed = bPressed;
1522  }
1523 }
1524 
1526 {
1528  if ( !IsDisposed() &&
1530  {
1532  if ( !mbPressed )
1533  Invalidate();
1534  }
1535 }
1536 
1538 {
1539  Size aSize;
1540 
1541  if ( IsSymbol() )
1542  {
1543  if ( IsSmallSymbol ())
1544  aSize = Size( 16, 12 );
1545  else
1546  aSize = Size( 26, 24 );
1547  }
1548  else if ( Button::HasImage() )
1549  aSize = GetModeImage().GetSizePixel();
1552  {
1553  long nSymbolSize = GetTextHeight() / 2 + 1;
1554  aSize.AdjustWidth(2*nSymbolSize );
1555  }
1556  if (!PushButton::GetText().isEmpty())
1557  {
1558  Size textSize = GetTextRect( tools::Rectangle( Point(), Size( 0x7fffffff, 0x7fffffff ) ),
1560  aSize.AdjustWidth(textSize.Width() );
1561  aSize.setHeight( std::max( aSize.Height(), long( textSize.Height() * 1.15 ) ) );
1562  }
1563 
1564  // cf. ImplDrawPushButton ...
1565  if( (GetStyle() & WB_SMALLSTYLE) == 0 )
1566  {
1567  aSize.AdjustWidth(24 );
1568  aSize.AdjustHeight(12 );
1569  }
1570 
1571  return CalcWindowSize( aSize );
1572 }
1573 
1575 {
1576  return CalcMinimumSize();
1577 }
1578 
1579 bool PushButton::set_property(const OString &rKey, const OUString &rValue)
1580 {
1581  if (rKey == "has-default")
1582  {
1583  WinBits nBits = GetStyle();
1584  nBits &= ~WB_DEFBUTTON;
1585  if (toBool(rValue))
1586  nBits |= WB_DEFBUTTON;
1587  SetStyle(nBits);
1588  }
1589  else
1590  return Button::set_property(rKey, rValue);
1591  return true;
1592 }
1593 
1595 {
1597  {
1598  PushButtonValue aControlValue;
1599  aControlValue.mbIsAction = isAction();
1602  ControlState::FOCUSED, aControlValue, OUString());
1603  }
1604  Button::ShowFocus(rRect);
1605 }
1606 
1607 void OKButton::ImplInit( vcl::Window* pParent, WinBits nStyle )
1608 {
1609  set_id("ok");
1610  PushButton::ImplInit( pParent, nStyle );
1611 
1612  SetText( GetStandardText( StandardButtonType::OK ) );
1613 }
1614 
1617 {
1618  ImplInit( pParent, nStyle );
1619 }
1620 
1622 {
1623  // close parent if no link set
1624  if ( !GetClickHdl() )
1625  {
1626  vcl::Window* pParent = getNonLayoutParent(this);
1627  if ( pParent->IsSystemWindow() )
1628  {
1629  if ( pParent->IsDialog() )
1630  {
1631  VclPtr<Dialog> xParent( static_cast<Dialog*>(pParent) );
1632  if ( xParent->IsInExecute() )
1633  xParent->EndDialog( RET_OK );
1634  // prevent recursive calls
1635  else if ( !xParent->IsInClose() )
1636  {
1637  if ( pParent->GetStyle() & WB_CLOSEABLE )
1638  xParent->Close();
1639  }
1640  }
1641  else
1642  {
1643  if ( pParent->GetStyle() & WB_CLOSEABLE )
1644  static_cast<SystemWindow*>(pParent)->Close();
1645  }
1646  }
1647  }
1648  else
1649  {
1651  }
1652 }
1653 
1655 {
1656  set_id("cancel");
1657  PushButton::ImplInit( pParent, nStyle );
1658 
1659  SetText( GetStandardText( StandardButtonType::Cancel ) );
1660 }
1661 
1664 {
1665  ImplInit( pParent, nStyle );
1666 }
1667 
1669 {
1670  // close parent if link not set
1671  if ( !GetClickHdl() )
1672  {
1673  vcl::Window* pParent = getNonLayoutParent(this);
1674  if ( pParent->IsSystemWindow() )
1675  {
1676  if ( pParent->IsDialog() )
1677  {
1678  if ( static_cast<Dialog*>(pParent)->IsInExecute() )
1679  static_cast<Dialog*>(pParent)->EndDialog();
1680  // prevent recursive calls
1681  else if ( !static_cast<Dialog*>(pParent)->IsInClose() )
1682  {
1683  if ( pParent->GetStyle() & WB_CLOSEABLE )
1684  static_cast<Dialog*>(pParent)->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  : CancelButton(pParent, nStyle)
1702 {
1703  SetText( GetStandardText( StandardButtonType::Close ) );
1704 }
1705 
1706 void HelpButton::ImplInit( vcl::Window* pParent, WinBits nStyle )
1707 {
1708  set_id("help");
1709  PushButton::ImplInit( pParent, nStyle | WB_NOPOINTERFOCUS );
1710 
1711  SetText( GetStandardText( StandardButtonType::Help ) );
1712 }
1713 
1716 {
1717  ImplInit( pParent, nStyle );
1718 }
1719 
1721 {
1722  // trigger help if no link set
1723  if ( !GetClickHdl() )
1724  {
1726  if ( !pFocusWin )
1727  pFocusWin = this;
1728 
1729  HelpEvent aEvt( pFocusWin->GetPointerPosPixel(), HelpEventMode::CONTEXT );
1730  pFocusWin->RequestHelp( aEvt );
1731  }
1733 }
1734 
1736 {
1737  // Hide when we have no help URL.
1739  officecfg::Office::Common::Help::HelpRootURL::get().isEmpty())
1740  Hide();
1741  else
1742  PushButton::StateChanged(nStateChange);
1743 }
1744 
1746 {
1747  mbChecked = false;
1748  mbRadioCheck = true;
1749  mbStateChanged = false;
1750 }
1751 
1753 {
1754  nStyle = ImplInitStyle(getPreviousSibling(pParent), nStyle);
1755  Button::ImplInit( pParent, nStyle, nullptr );
1756 
1757  ImplInitSettings( true );
1758 }
1759 
1761 {
1762  if ( !(nStyle & WB_NOGROUP) &&
1763  (!pPrevWindow || (pPrevWindow->GetType() != WindowType::RADIOBUTTON)) )
1764  nStyle |= WB_GROUP;
1765  if ( !(nStyle & WB_NOTABSTOP) )
1766  {
1767  if ( IsChecked() )
1768  nStyle |= WB_TABSTOP;
1769  else
1770  nStyle &= ~WB_TABSTOP;
1771  }
1772 
1773  if ( IsChecked() && IsRadioCheckEnabled() )
1774  ImplUncheckAllOther( /*bSetStyle=*/false );
1775 
1776  return nStyle;
1777 }
1778 
1780 {
1781  return _rStyle.GetRadioCheckFont();
1782 }
1783 
1785 {
1786  return _rStyle.GetRadioCheckTextColor();
1787 }
1788 
1789 void RadioButton::ImplInitSettings( bool bBackground )
1790 {
1792 
1793  if ( bBackground )
1794  {
1795  vcl::Window* pParent = GetParent();
1796  if ( !IsControlBackground() &&
1798  {
1801  SetPaintTransparent( true );
1802  SetBackground();
1804  mpWindowImpl->mbUseNativeFocus = ImplGetSVData()->maNWFData.mbNoFocusRects;
1805  }
1806  else
1807  {
1808  EnableChildTransparentMode( false );
1810  SetPaintTransparent( false );
1811 
1812  if ( IsControlBackground() )
1814  else
1815  SetBackground( pParent->GetBackground() );
1816  }
1817  }
1818 }
1819 
1821 {
1822  bool bNativeOK = false;
1823 
1824  // no native drawing for image radio buttons
1826  {
1830 
1832  nState |= ControlState::PRESSED;
1833  if (HasFocus())
1834  nState |= ControlState::FOCUSED;
1836  nState |= ControlState::DEFAULT;
1837  if (IsEnabled())
1838  nState |= ControlState::ENABLED;
1839 
1841  nState |= ControlState::ROLLOVER;
1842 
1843  bNativeOK = rRenderContext.DrawNativeControl(ControlType::Radiobutton, ControlPart::Entire, aCtrlRect,
1844  nState, aControlValue, OUString());
1845  }
1846 
1847  if (!bNativeOK)
1848  {
1849  if (!maImage)
1850  {
1851  DrawButtonFlags nStyle = GetButtonState();
1852  if (!IsEnabled())
1853  nStyle |= DrawButtonFlags::Disabled;
1854  if (mbChecked)
1855  nStyle |= DrawButtonFlags::Checked;
1856  Image aImage = GetRadioImage(rRenderContext.GetSettings(), nStyle);
1857  if (IsZoom())
1858  rRenderContext.DrawImage(maStateRect.TopLeft(), maStateRect.GetSize(), aImage);
1859  else
1860  rRenderContext.DrawImage(maStateRect.TopLeft(), aImage);
1861  }
1862  else
1863  {
1864  HideFocus();
1865 
1866  DecorationView aDecoView(&rRenderContext);
1867  const StyleSettings& rStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
1868  tools::Rectangle aImageRect = maStateRect;
1869  Size aImageSize = maImage.GetSizePixel();
1870  bool bEnabled = IsEnabled();
1871 
1872  aImageSize.setWidth( CalcZoom(aImageSize.Width()) );
1873  aImageSize.setHeight( CalcZoom(aImageSize.Height()) );
1874 
1875  aImageRect.AdjustLeft( 1 );
1876  aImageRect.AdjustTop( 1 );
1877  aImageRect.AdjustRight( -1 );
1878  aImageRect.AdjustBottom( -1 );
1879 
1880  // display border and selection status
1881  aImageRect = aDecoView.DrawFrame(aImageRect, DrawFrameStyle::DoubleIn);
1882  if ((GetButtonState() & DrawButtonFlags::Pressed) || !bEnabled)
1883  rRenderContext.SetFillColor( rStyleSettings.GetFaceColor());
1884  else
1885  rRenderContext.SetFillColor(rStyleSettings.GetFieldColor());
1886  rRenderContext.SetLineColor();
1887  rRenderContext.DrawRect(aImageRect);
1888 
1889  // display image
1890  DrawImageFlags nImageStyle = DrawImageFlags::NONE;
1891  if (!bEnabled)
1892  nImageStyle |= DrawImageFlags::Disable;
1893 
1894  Image* pImage = &maImage;
1895 
1896  Point aImagePos(aImageRect.TopLeft());
1897  aImagePos.AdjustX((aImageRect.GetWidth() - aImageSize.Width()) / 2 );
1898  aImagePos.AdjustY((aImageRect.GetHeight() - aImageSize.Height()) / 2 );
1899  if (IsZoom())
1900  rRenderContext.DrawImage(aImagePos, aImageSize, *pImage, nImageStyle);
1901  else
1902  rRenderContext.DrawImage(aImagePos, *pImage, nImageStyle);
1903 
1904  aImageRect.AdjustLeft( 1 );
1905  aImageRect.AdjustTop( 1 );
1906  aImageRect.AdjustRight( -1 );
1907  aImageRect.AdjustBottom( -1 );
1908 
1909  ImplSetFocusRect(aImageRect);
1910 
1911  if (mbChecked)
1912  {
1913  rRenderContext.SetLineColor(rStyleSettings.GetHighlightColor());
1914  rRenderContext.SetFillColor();
1915  if ((aImageSize.Width() >= 20) || (aImageSize.Height() >= 20))
1916  {
1917  aImageRect.AdjustLeft( 1 );
1918  aImageRect.AdjustTop( 1 );
1919  aImageRect.AdjustRight( -1 );
1920  aImageRect.AdjustBottom( -1 );
1921  }
1922  rRenderContext.DrawRect(aImageRect);
1923  aImageRect.AdjustLeft( 1 );
1924  aImageRect.AdjustTop( 1 );
1925  aImageRect.AdjustRight( -1 );
1926  aImageRect.AdjustBottom( -1 );
1927  rRenderContext.DrawRect(aImageRect);
1928  }
1929 
1930  if (HasFocus())
1932  }
1933  }
1934 }
1935 
1937  const Point& rPos, const Size& rSize,
1938  const Size& rImageSize, tools::Rectangle& rStateRect,
1939  tools::Rectangle& rMouseRect )
1940 {
1941  WinBits nWinStyle = GetStyle();
1942  OUString aText( GetText() );
1943 
1944  pDev->Push( PushFlags::CLIPREGION );
1945  pDev->IntersectClipRegion( tools::Rectangle( rPos, rSize ) );
1946 
1947  // no image radio button
1948  if ( !maImage )
1949  {
1950  if (!aText.isEmpty() || HasImage())
1951  {
1952  DrawTextFlags nTextStyle = Button::ImplGetTextStyle( nWinStyle, nDrawFlags );
1953 
1954  const long nImageSep = GetDrawPixel( pDev, ImplGetImageToTextDistance() );
1955  Size aSize( rSize );
1956  Point aPos( rPos );
1957  aPos.AdjustX(rImageSize.Width() + nImageSep );
1958  aSize.AdjustWidth( -(rImageSize.Width() + nImageSep) );
1959 
1960  // if the text rect height is smaller than the height of the image
1961  // then for single lines the default should be centered text
1962  if( (nWinStyle & (WB_TOP|WB_VCENTER|WB_BOTTOM)) == 0 &&
1963  (rImageSize.Height() > rSize.Height() || ! (nWinStyle & WB_WORDBREAK) ) )
1964  {
1966  nTextStyle |= DrawTextFlags::VCenter;
1967  aSize.setHeight( rImageSize.Height() );
1968  }
1969 
1970  ImplDrawAlignedImage( pDev, aPos, aSize, 1, nTextStyle );
1971 
1972  rMouseRect = tools::Rectangle(aPos, aSize);
1973  rMouseRect.SetLeft(rPos.X());
1974  rMouseRect.SetTop(rPos.Y());
1975 
1976  rStateRect.SetLeft( rPos.X() );
1977  rStateRect.SetTop( rMouseRect.Top() );
1978 
1979  if ( aSize.Height() > rImageSize.Height() )
1980  rStateRect.AdjustTop(( aSize.Height() - rImageSize.Height() ) / 2 );
1981  else
1982  {
1983  rStateRect.AdjustTop( -(( rImageSize.Height() - aSize.Height() ) / 2) );
1984  if( rStateRect.Top() < 0 )
1985  rStateRect.SetTop( 0 );
1986  }
1987 
1988  rStateRect.SetRight( rStateRect.Left() + rImageSize.Width()-1 );
1989  rStateRect.SetBottom( rStateRect.Top() + rImageSize.Height()-1 );
1990 
1991  if ( rStateRect.Bottom() > rMouseRect.Bottom() )
1992  rMouseRect.SetBottom( rStateRect.Bottom() );
1993  }
1994  else
1995  {
1996  rStateRect.SetLeft( rPos.X() );
1997  if ( nWinStyle & WB_VCENTER )
1998  rStateRect.SetTop( rPos.Y()+((rSize.Height()-rImageSize.Height())/2) );
1999  else if ( nWinStyle & WB_BOTTOM )
2000  rStateRect.SetTop( rPos.Y()+rSize.Height()-rImageSize.Height() ); //-1;
2001  else
2002  rStateRect.SetTop( rPos.Y() );
2003  rStateRect.SetRight( rStateRect.Left()+rImageSize.Width()-1 );
2004  rStateRect.SetBottom( rStateRect.Top()+rImageSize.Height()-1 );
2005  rMouseRect = rStateRect;
2006 
2007  ImplSetFocusRect( rStateRect );
2008  }
2009  }
2010  else
2011  {
2012  bool bTopImage = (nWinStyle & WB_TOP) != 0;
2013  Size aImageSize = maImage.GetSizePixel();
2014  tools::Rectangle aImageRect( rPos, rSize );
2015  long nTextHeight = pDev->GetTextHeight();
2016  long nTextWidth = pDev->GetCtrlTextWidth( aText );
2017 
2018  // calculate position and sizes
2019  if (!aText.isEmpty())
2020  {
2021  Size aTmpSize( (aImageSize.Width()+8), (aImageSize.Height()+8) );
2022  if ( bTopImage )
2023  {
2024  aImageRect.SetLeft( (rSize.Width()-aTmpSize.Width())/2 );
2025  aImageRect.SetTop( (rSize.Height()-(aTmpSize.Height()+nTextHeight+6))/2 );
2026  }
2027  else
2028  aImageRect.SetTop( (rSize.Height()-aTmpSize.Height())/2 );
2029 
2030  aImageRect.SetRight( aImageRect.Left()+aTmpSize.Width() );
2031  aImageRect.SetBottom( aImageRect.Top()+aTmpSize.Height() );
2032 
2033  // display text
2034  Point aTxtPos = rPos;
2035  if ( bTopImage )
2036  {
2037  aTxtPos.AdjustX((rSize.Width()-nTextWidth)/2 );
2038  aTxtPos.AdjustY(aImageRect.Bottom()+6 );
2039  }
2040  else
2041  {
2042  aTxtPos.AdjustX(aImageRect.Right()+8 );
2043  aTxtPos.AdjustY((rSize.Height()-nTextHeight)/2 );
2044  }
2045  pDev->DrawCtrlText( aTxtPos, aText, 0, aText.getLength() );
2046  }
2047 
2048  rMouseRect = aImageRect;
2049  rStateRect = aImageRect;
2050  }
2051 
2052  pDev->Pop();
2053 }
2054 
2056 {
2057  HideFocus();
2058 
2059  Size aImageSize;
2060  if (!maImage)
2061  aImageSize = ImplGetRadioImageSize();
2062  else
2063  aImageSize = maImage.GetSizePixel();
2064 
2065  aImageSize.setWidth( CalcZoom(aImageSize.Width()) );
2066  aImageSize.setHeight( CalcZoom(aImageSize.Height()) );
2067 
2068  // Draw control text
2069  ImplDraw(&rRenderContext, DrawFlags::NONE, Point(), GetOutputSizePixel(),
2070  aImageSize, maStateRect, maMouseRect);
2071 
2072  if (!maImage && HasFocus())
2074 
2075  ImplDrawRadioButtonState(rRenderContext);
2076 }
2077 
2079 {
2080  if (&rOther == this)
2081  return;
2082 
2083  if (!m_xGroup)
2084  {
2085  m_xGroup.reset(new std::vector<VclPtr<RadioButton> >);
2086  m_xGroup->push_back(this);
2087  }
2088 
2089  auto aFind = std::find(m_xGroup->begin(), m_xGroup->end(), VclPtr<RadioButton>(&rOther));
2090  if (aFind == m_xGroup->end())
2091  {
2092  m_xGroup->push_back(&rOther);
2093 
2094  if (rOther.m_xGroup)
2095  {
2096  std::vector< VclPtr<RadioButton> > aOthers(rOther.GetRadioButtonGroup(false));
2097  //make all members of the group share the same button group
2098  for (auto const& elem : aOthers)
2099  {
2100  aFind = std::find(m_xGroup->begin(), m_xGroup->end(), elem);
2101  if (aFind == m_xGroup->end())
2102  m_xGroup->push_back(elem);
2103  }
2104  }
2105 
2106  //make all members of the group share the same button group
2107  for (VclPtr<RadioButton> const & pButton : *m_xGroup)
2108  {
2109  pButton->m_xGroup = m_xGroup;
2110  }
2111  }
2112 
2113  //if this one is checked, uncheck all the others
2114  if (mbChecked)
2116 }
2117 
2118 std::vector< VclPtr<RadioButton> > RadioButton::GetRadioButtonGroup(bool bIncludeThis) const
2119 {
2120  if (m_xGroup)
2121  {
2122  if (bIncludeThis)
2123  return *m_xGroup;
2124  std::vector< VclPtr<RadioButton> > aGroup;
2125  for (VclPtr<RadioButton> const & pRadioButton : *m_xGroup)
2126  {
2127  if (pRadioButton == this)
2128  continue;
2129  aGroup.push_back(pRadioButton);
2130  }
2131  return aGroup;
2132  }
2133 
2134  //old-school
2135 
2136  // go back to first in group;
2137  vcl::Window* pFirst = const_cast<RadioButton*>(this);
2138  while( ( pFirst->GetStyle() & WB_GROUP ) == 0 )
2139  {
2140  vcl::Window* pWindow = pFirst->GetWindow( GetWindowType::Prev );
2141  if( pWindow )
2142  pFirst = pWindow;
2143  else
2144  break;
2145  }
2146  std::vector< VclPtr<RadioButton> > aGroup;
2147  // insert radiobuttons up to next group
2148  do
2149  {
2150  if( pFirst->GetType() == WindowType::RADIOBUTTON )
2151  {
2152  if( pFirst != this || bIncludeThis )
2153  aGroup.emplace_back(static_cast<RadioButton*>(pFirst) );
2154  }
2155  pFirst = pFirst->GetWindow( GetWindowType::Next );
2156  } while( pFirst && ( ( pFirst->GetStyle() & WB_GROUP ) == 0 ) );
2157 
2158  return aGroup;
2159 }
2160 
2161 void RadioButton::ImplUncheckAllOther( const bool bSetStyle )
2162 {
2163  if ( bSetStyle )
2164  mpWindowImpl->mnStyle |= WB_TABSTOP;
2165 
2166  std::vector<VclPtr<RadioButton> > aGroup(GetRadioButtonGroup(false));
2167  // iterate over radio button group and checked buttons
2168  for (VclPtr<RadioButton>& pWindow : aGroup)
2169  {
2170  if ( pWindow->IsChecked() )
2171  {
2172  pWindow->SetState( false );
2173  if ( pWindow->IsDisposed() )
2174  return;
2175  }
2176 
2177  // not inside if clause to always remove wrongly set WB_TABSTOPS
2178  pWindow->mpWindowImpl->mnStyle &= ~WB_TABSTOP;
2179  }
2180 }
2181 
2182 void RadioButton::ImplCallClick( bool bGrabFocus, GetFocusFlags nFocusFlags )
2183 {
2185  mbChecked = true;
2186  mpWindowImpl->mnStyle |= WB_TABSTOP;
2187  Invalidate();
2188  Update();
2189  VclPtr<vcl::Window> xWindow = this;
2190  if ( mbRadioCheck )
2192  if ( xWindow->IsDisposed() )
2193  return;
2194  if ( bGrabFocus )
2195  ImplGrabFocus( nFocusFlags );
2196  if ( xWindow->IsDisposed() )
2197  return;
2198  if ( mbStateChanged )
2199  Toggle();
2200  if ( xWindow->IsDisposed() )
2201  return;
2202  Click();
2203  if ( xWindow->IsDisposed() )
2204  return;
2205  mbStateChanged = false;
2206 }
2207 
2210 {
2212  ImplInit( pParent, nStyle );
2213 }
2214 
2216 {
2217  disposeOnce();
2218 }
2219 
2221 {
2222  if (m_xGroup)
2223  {
2224  m_xGroup->erase(std::remove(m_xGroup->begin(), m_xGroup->end(), VclPtr<RadioButton>(this)),
2225  m_xGroup->end());
2226  m_xGroup.reset();
2227  }
2228  Button::dispose();
2229 }
2230 
2232 {
2233  if ( rMEvt.IsLeft() && maMouseRect.IsInside( rMEvt.GetPosPixel() ) )
2234  {
2236  Invalidate();
2237  Update();
2238  StartTracking();
2239  return;
2240  }
2241 
2242  Button::MouseButtonDown( rMEvt );
2243 }
2244 
2246 {
2247  if ( rTEvt.IsTrackingEnded() )
2248  {
2250  {
2251  if ( !(GetStyle() & WB_NOPOINTERFOCUS) && !rTEvt.IsTrackingCanceled() )
2252  GrabFocus();
2253 
2255 
2256  // do not call click handler if aborted
2257  if ( !rTEvt.IsTrackingCanceled() )
2258  ImplCallClick();
2259  else
2260  {
2261  Invalidate();
2262  Update();
2263  }
2264  }
2265  }
2266  else
2267  {
2268  if ( maMouseRect.IsInside( rTEvt.GetMouseEvent().GetPosPixel() ) )
2269  {
2271  {
2273  Invalidate();
2274  Update();
2275  }
2276  }
2277  else
2278  {
2280  {
2282  Invalidate();
2283  Update();
2284  }
2285  }
2286  }
2287 }
2288 
2289 void RadioButton::KeyInput( const KeyEvent& rKEvt )
2290 {
2291  vcl::KeyCode aKeyCode = rKEvt.GetKeyCode();
2292 
2293  if ( !aKeyCode.GetModifier() && (aKeyCode.GetCode() == KEY_SPACE) )
2294  {
2296  {
2298  Invalidate();
2299  Update();
2300  }
2301  }
2302  else if ( (GetButtonState() & DrawButtonFlags::Pressed) && (aKeyCode.GetCode() == KEY_ESCAPE) )
2303  {
2305  Invalidate();
2306  Update();
2307  }
2308  else
2309  Button::KeyInput( rKEvt );
2310 }
2311 
2312 void RadioButton::KeyUp( const KeyEvent& rKEvt )
2313 {
2314  vcl::KeyCode aKeyCode = rKEvt.GetKeyCode();
2315 
2316  if ( (GetButtonState() & DrawButtonFlags::Pressed) && (aKeyCode.GetCode() == KEY_SPACE) )
2317  {
2319  ImplCallClick();
2320  }
2321  else
2322  Button::KeyUp( rKEvt );
2323 }
2324 
2326 {
2327  mpControlData->mpLayoutData.reset( new vcl::ControlLayoutData );
2328  const_cast<RadioButton*>(this)->Invalidate();
2329 }
2330 
2332 {
2333  ImplDrawRadioButton(rRenderContext);
2334 }
2335 
2336 void RadioButton::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize,
2337  DrawFlags nFlags )
2338 {
2339  if ( !maImage )
2340  {
2341  MapMode aResMapMode( MapUnit::Map100thMM );
2342  Point aPos = pDev->LogicToPixel( rPos );
2343  Size aSize = pDev->LogicToPixel( rSize );
2344  Size aImageSize = pDev->LogicToPixel( Size( 300, 300 ), aResMapMode );
2345  Size aBrd1Size = pDev->LogicToPixel( Size( 20, 20 ), aResMapMode );
2346  Size aBrd2Size = pDev->LogicToPixel( Size( 60, 60 ), aResMapMode );
2347  vcl::Font aFont = GetDrawPixelFont( pDev );
2348  tools::Rectangle aStateRect;
2349  tools::Rectangle aMouseRect;
2350 
2351  aImageSize.setWidth( CalcZoom( aImageSize.Width() ) );
2352  aImageSize.setHeight( CalcZoom( aImageSize.Height() ) );
2353  aBrd1Size.setWidth( CalcZoom( aBrd1Size.Width() ) );
2354  aBrd1Size.setHeight( CalcZoom( aBrd1Size.Height() ) );
2355  aBrd2Size.setWidth( CalcZoom( aBrd2Size.Width() ) );
2356  aBrd2Size.setHeight( CalcZoom( aBrd2Size.Height() ) );
2357 
2358  if ( !aBrd1Size.Width() )
2359  aBrd1Size.setWidth( 1 );
2360  if ( !aBrd1Size.Height() )
2361  aBrd1Size.setHeight( 1 );
2362  if ( !aBrd2Size.Width() )
2363  aBrd2Size.setWidth( 1 );
2364  if ( !aBrd2Size.Height() )
2365  aBrd2Size.setHeight( 1 );
2366 
2367  pDev->Push();
2368  pDev->SetMapMode();
2369  pDev->SetFont( aFont );
2370  if ( nFlags & DrawFlags::Mono )
2371  pDev->SetTextColor( COL_BLACK );
2372  else
2373  pDev->SetTextColor( GetTextColor() );
2374  pDev->SetTextFillColor();
2375 
2376  ImplDraw( pDev, nFlags, aPos, aSize,
2377  aImageSize, aStateRect, aMouseRect );
2378 
2379  Point aCenterPos = aStateRect.Center();
2380  long nRadX = aImageSize.Width()/2;
2381  long nRadY = aImageSize.Height()/2;
2382 
2383  pDev->SetLineColor();
2384  pDev->SetFillColor( COL_BLACK );
2385  pDev->DrawPolygon( tools::Polygon( aCenterPos, nRadX, nRadY ) );
2386  nRadX -= aBrd1Size.Width();
2387  nRadY -= aBrd1Size.Height();
2388  pDev->SetFillColor( COL_WHITE );
2389  pDev->DrawPolygon( tools::Polygon( aCenterPos, nRadX, nRadY ) );
2390  if ( mbChecked )
2391  {
2392  nRadX -= aBrd1Size.Width();
2393  nRadY -= aBrd1Size.Height();
2394  if ( !nRadX )
2395  nRadX = 1;
2396  if ( !nRadY )
2397  nRadY = 1;
2398  pDev->SetFillColor( COL_BLACK );
2399  pDev->DrawPolygon( tools::Polygon( aCenterPos, nRadX, nRadY ) );
2400  }
2401 
2402  pDev->Pop();
2403  }
2404  else
2405  {
2406  OSL_FAIL( "RadioButton::Draw() - not implemented for RadioButton with Image" );
2407  }
2408 }
2409 
2411 {
2412  Control::Resize();
2413  Invalidate();
2414 }
2415 
2417 {
2420  Button::GetFocus();
2421 }
2422 
2424 {
2426  {
2428  Invalidate();
2429  Update();
2430  }
2431 
2432  HideFocus();
2434 }
2435 
2437 {
2438  Button::StateChanged( nType );
2439 
2440  if ( nType == StateChangedType::State )
2441  {
2442  if ( IsReallyVisible() && IsUpdateMode() )
2444  }
2445  else if ( (nType == StateChangedType::Enable) ||
2446  (nType == StateChangedType::Text) ||
2447  (nType == StateChangedType::Data) ||
2448  (nType == StateChangedType::UpdateMode) )
2449  {
2450  if ( IsUpdateMode() )
2451  Invalidate();
2452  }
2453  else if ( nType == StateChangedType::Style )
2454  {
2456 
2457  if ( (GetPrevStyle() & RADIOBUTTON_VIEW_STYLE) !=
2459  {
2460  if ( IsUpdateMode() )
2461  Invalidate();
2462  }
2463  }
2464  else if ( (nType == StateChangedType::Zoom) ||
2465  (nType == StateChangedType::ControlFont) )
2466  {
2467  ImplInitSettings( false );
2468  Invalidate();
2469  }
2470  else if ( nType == StateChangedType::ControlForeground )
2471  {
2472  ImplInitSettings( false );
2473  Invalidate();
2474  }
2475  else if ( nType == StateChangedType::ControlBackground )
2476  {
2477  ImplInitSettings( true );
2478  Invalidate();
2479  }
2480 }
2481 
2483 {
2484  Button::DataChanged( rDCEvt );
2485 
2486  if ( (rDCEvt.GetType() == DataChangedEventType::FONTS) ||
2488  ((rDCEvt.GetType() == DataChangedEventType::SETTINGS) &&
2489  (rDCEvt.GetFlags() & AllSettingsFlags::STYLE)) )
2490  {
2491  ImplInitSettings( true );
2492  Invalidate();
2493  }
2494 }
2495 
2497 {
2498  const MouseEvent* pMouseEvt = nullptr;
2499 
2500  if( (rNEvt.GetType() == MouseNotifyEvent::MOUSEMOVE) && (pMouseEvt = rNEvt.GetMouseEvent()) != nullptr )
2501  {
2502  if( !pMouseEvt->GetButtons() && !pMouseEvt->IsSynthetic() && !pMouseEvt->IsModifierChanged() )
2503  {
2504  // trigger redraw if mouse over state has changed
2506  {
2508  pMouseEvt->IsLeaveWindow() || pMouseEvt->IsEnterWindow())
2509  {
2511  }
2512  }
2513  }
2514  }
2515 
2516  return Button::PreNotify(rNEvt);
2517 }
2518 
2520 {
2522 }
2523 
2525 {
2526  if ( rImage != maImage )
2527  {
2528  maImage = rImage;
2530  queue_resize();
2531  }
2532 }
2533 
2534 
2535 void RadioButton::SetState( bool bCheck )
2536 {
2537  // carry the TabStop flag along correctly
2538  if ( bCheck )
2539  mpWindowImpl->mnStyle |= WB_TABSTOP;
2540  else
2541  mpWindowImpl->mnStyle &= ~WB_TABSTOP;
2542 
2543  if ( mbChecked != bCheck )
2544  {
2545  mbChecked = bCheck;
2547  Toggle();
2548  }
2549 }
2550 
2551 bool RadioButton::set_property(const OString &rKey, const OUString &rValue)
2552 {
2553  if (rKey == "active")
2554  SetState(toBool(rValue));
2555  else if (rKey == "image-position")
2556  {
2557  WinBits nBits = GetStyle();
2558  if (rValue == "left")
2559  {
2560  nBits &= ~(WB_CENTER | WB_RIGHT);
2561  nBits |= WB_LEFT;
2562  }
2563  else if (rValue == "right")
2564  {
2565  nBits &= ~(WB_CENTER | WB_LEFT);
2566  nBits |= WB_RIGHT;
2567  }
2568  else if (rValue == "top")
2569  {
2570  nBits &= ~(WB_VCENTER | WB_BOTTOM);
2571  nBits |= WB_TOP;
2572  }
2573  else if (rValue == "bottom")
2574  {
2575  nBits &= ~(WB_VCENTER | WB_TOP);
2576  nBits |= WB_BOTTOM;
2577  }
2578  //It's rather mad to have to set these bits when there is the other
2579  //image align. Looks like e.g. the radiobuttons etc weren't converted
2580  //over to image align fully.
2581  SetStyle(nBits);
2582  //Deliberate to set the sane ImageAlign property
2583  return Button::set_property(rKey, rValue);
2584  }
2585  else
2586  return Button::set_property(rKey, rValue);
2587  return true;
2588 }
2589 
2590 void RadioButton::Check( bool bCheck )
2591 {
2592  // TabStop-Flag richtig mitfuehren
2593  if ( bCheck )
2594  mpWindowImpl->mnStyle |= WB_TABSTOP;
2595  else
2596  mpWindowImpl->mnStyle &= ~WB_TABSTOP;
2597 
2598  if ( mbChecked != bCheck )
2599  {
2600  mbChecked = bCheck;
2601  VclPtr<vcl::Window> xWindow = this;
2603  if ( xWindow->IsDisposed() )
2604  return;
2605  if ( bCheck && mbRadioCheck )
2607  if ( xWindow->IsDisposed() )
2608  return;
2609  Toggle();
2610  }
2611 }
2612 
2614 {
2615  // 4 pixels, but take zoom into account, so the text doesn't "jump" relative to surrounding elements,
2616  // which might have been aligned with the text of the check box
2617  return CalcZoom( 4 );
2618 }
2619 
2621 {
2622  Size aSize;
2623  bool bDefaultSize = true;
2625  {
2626  ImplControlValue aControlValue;
2627  tools::Rectangle aCtrlRegion( Point( 0, 0 ), GetSizePixel() );
2628  tools::Rectangle aBoundingRgn, aContentRgn;
2629 
2630  // get native size of a radio button
2633  aControlValue,
2634  aBoundingRgn, aContentRgn ) )
2635  {
2636  aSize = aContentRgn.GetSize();
2637  bDefaultSize = false;
2638  }
2639  }
2640  if( bDefaultSize )
2642  return aSize;
2643 }
2644 
2645 static void LoadThemedImageList(const StyleSettings &rStyleSettings,
2646  std::vector<Image>& rList, const std::vector<OUString> &rResources)
2647 {
2648  Color aColorAry1[6];
2649  Color aColorAry2[6];
2650  aColorAry1[0] = Color( 0xC0, 0xC0, 0xC0 );
2651  aColorAry1[1] = Color( 0xFF, 0xFF, 0x00 );
2652  aColorAry1[2] = Color( 0xFF, 0xFF, 0xFF );
2653  aColorAry1[3] = Color( 0x80, 0x80, 0x80 );
2654  aColorAry1[4] = Color( 0x00, 0x00, 0x00 );
2655  aColorAry1[5] = Color( 0x00, 0xFF, 0x00 );
2656  aColorAry2[0] = rStyleSettings.GetFaceColor();
2657  aColorAry2[1] = rStyleSettings.GetWindowColor();
2658  aColorAry2[2] = rStyleSettings.GetLightColor();
2659  aColorAry2[3] = rStyleSettings.GetShadowColor();
2660  aColorAry2[4] = rStyleSettings.GetDarkShadowColor();
2661  aColorAry2[5] = rStyleSettings.GetWindowTextColor();
2662 
2663  static_assert( sizeof(aColorAry1) == sizeof(aColorAry2), "aColorAry1 must match aColorAry2" );
2664 
2665  for (const auto &a : rResources)
2666  {
2667  BitmapEx aBmpEx(a);
2668  aBmpEx.Replace(aColorAry1, aColorAry2, SAL_N_ELEMENTS(aColorAry1));
2669  rList.emplace_back(aBmpEx);
2670  }
2671 }
2672 
2674 {
2675  ImplSVData* pSVData = ImplGetSVData();
2676  const StyleSettings& rStyleSettings = rSettings.GetStyleSettings();
2677  sal_uInt16 nStyle = 0;
2678 
2679  if ( rStyleSettings.GetOptions() & StyleSettingsOptions::Mono )
2680  nStyle = STYLE_RADIOBUTTON_MONO;
2681 
2682  if ( pSVData->maCtrlData.maRadioImgList.empty() ||
2683  (pSVData->maCtrlData.mnRadioStyle != nStyle) ||
2684  (pSVData->maCtrlData.mnLastRadioFColor != rStyleSettings.GetFaceColor()) ||
2685  (pSVData->maCtrlData.mnLastRadioWColor != rStyleSettings.GetWindowColor()) ||
2686  (pSVData->maCtrlData.mnLastRadioLColor != rStyleSettings.GetLightColor()) )
2687  {
2688  pSVData->maCtrlData.maRadioImgList.clear();
2689 
2690  pSVData->maCtrlData.mnLastRadioFColor = rStyleSettings.GetFaceColor();
2691  pSVData->maCtrlData.mnLastRadioWColor = rStyleSettings.GetWindowColor();
2692  pSVData->maCtrlData.mnLastRadioLColor = rStyleSettings.GetLightColor();
2693 
2694  std::vector<OUString> aResources;
2695  if (nStyle)
2696  {
2697  aResources.emplace_back(SV_RESID_BITMAP_RADIOMONO1);
2698  aResources.emplace_back(SV_RESID_BITMAP_RADIOMONO2);
2699  aResources.emplace_back(SV_RESID_BITMAP_RADIOMONO3);
2700  aResources.emplace_back(SV_RESID_BITMAP_RADIOMONO4);
2701  aResources.emplace_back(SV_RESID_BITMAP_RADIOMONO5);
2702  aResources.emplace_back(SV_RESID_BITMAP_RADIOMONO6);
2703  }
2704  else
2705  {
2706  aResources.emplace_back(SV_RESID_BITMAP_RADIO1);
2707  aResources.emplace_back(SV_RESID_BITMAP_RADIO2);
2708  aResources.emplace_back(SV_RESID_BITMAP_RADIO3);
2709  aResources.emplace_back(SV_RESID_BITMAP_RADIO4);
2710  aResources.emplace_back(SV_RESID_BITMAP_RADIO5);
2711  aResources.emplace_back(SV_RESID_BITMAP_RADIO6);
2712  }
2713  LoadThemedImageList( rStyleSettings, pSVData->maCtrlData.maRadioImgList, aResources);
2714  pSVData->maCtrlData.mnRadioStyle = nStyle;
2715  }
2716 
2717  sal_uInt16 nIndex;
2718  if ( nFlags & DrawButtonFlags::Disabled )
2719  {
2720  if ( nFlags & DrawButtonFlags::Checked )
2721  nIndex = 5;
2722  else
2723  nIndex = 4;
2724  }
2725  else if ( nFlags & DrawButtonFlags::Pressed )
2726  {
2727  if ( nFlags & DrawButtonFlags::Checked )
2728  nIndex = 3;
2729  else
2730  nIndex = 2;
2731  }
2732  else
2733  {
2734  if ( nFlags & DrawButtonFlags::Checked )
2735  nIndex = 1;
2736  else
2737  nIndex = 0;
2738  }
2739  return pSVData->maCtrlData.maRadioImgList[nIndex];
2740 }
2741 
2743 {
2745  SetMapMode(MapMode(MapUnit::MapPixel));
2746 
2747  ImplControlValue aControlValue;
2748  Size aCurSize( GetSizePixel() );
2749  tools::Rectangle aCtrlRegion( Point( 0, 0 ), aCurSize );
2750  tools::Rectangle aBoundingRgn, aContentRgn;
2751 
2752  // get native size of a radiobutton
2755  aBoundingRgn, aContentRgn ) )
2756  {
2757  Size aSize = aContentRgn.GetSize();
2758 
2759  if( aSize.Height() > aCurSize.Height() )
2760  {
2761  aCurSize.setHeight( aSize.Height() );
2762  SetSizePixel( aCurSize );
2763  }
2764  }
2765 
2766  Pop();
2767 }
2768 
2770 {
2771  Size aSize;
2772  if ( !maImage )
2773  aSize = ImplGetRadioImageSize();
2774  else
2775  {
2776  aSize = maImage.GetSizePixel();
2777  aSize.AdjustWidth(8);
2778  aSize.AdjustHeight(8);
2779  }
2780 
2781  if (Button::HasImage())
2782  {
2783  Size aImgSize = GetModeImage().GetSizePixel();
2784  aSize = Size(std::max(aImgSize.Width(), aSize.Width()),
2785  std::max(aImgSize.Height(), aSize.Height()));
2786  }
2787 
2788  OUString aText = GetText();
2789  if (!aText.isEmpty())
2790  {
2791  bool bTopImage = (GetStyle() & WB_TOP) != 0;
2792 
2793  Size aTextSize = GetTextRect( tools::Rectangle( Point(), Size( 0x7fffffff, 0x7fffffff ) ),
2795 
2796  aSize.AdjustWidth(2 ); // for focus rect
2797 
2798  if (!bTopImage)
2799  {
2801  aSize.AdjustWidth(aTextSize.Width() );
2802  if ( aSize.Height() < aTextSize.Height() )
2803  aSize.setHeight( aTextSize.Height() );
2804  }
2805  else
2806  {
2807  aSize.AdjustHeight(6 );
2808  aSize.AdjustHeight(GetTextHeight() );
2809  if ( aSize.Width() < aTextSize.Width() )
2810  aSize.setWidth( aTextSize.Width() );
2811  }
2812  }
2813 
2814  return CalcWindowSize( aSize );
2815 }
2816 
2818 {
2819  return CalcMinimumSize();
2820 }
2821 
2823 {
2825  {
2826  ImplControlValue aControlValue;
2827  tools::Rectangle aInRect(Point(0, 0), GetSizePixel());
2828 
2829  aInRect.SetLeft( rRect.Left() ); // exclude the radio element itself from the focusrect
2830 
2832  ControlState::FOCUSED, aControlValue, OUString());
2833  }
2834  Button::ShowFocus(rRect);
2835 }
2836 
2837 boost::property_tree::ptree RadioButton::DumpAsPropertyTree()
2838 {
2839  boost::property_tree::ptree aTree(Button::DumpAsPropertyTree());
2840  aTree.put("checked", IsChecked());
2841  return aTree;
2842 }
2843 
2845 {
2847 }
2848 
2850 {
2853  mbTriState = false;
2854 }
2855 
2856 void CheckBox::ImplInit( vcl::Window* pParent, WinBits nStyle )
2857 {
2858  nStyle = ImplInitStyle(getPreviousSibling(pParent), nStyle);
2859  Button::ImplInit( pParent, nStyle, nullptr );
2860 
2861  ImplInitSettings( true );
2862 }
2863 
2865 {
2866  if ( !(nStyle & WB_NOTABSTOP) )
2867  nStyle |= WB_TABSTOP;
2868  if ( !(nStyle & WB_NOGROUP) &&
2869  (!pPrevWindow || (pPrevWindow->GetType() != WindowType::CHECKBOX)) )
2870  nStyle |= WB_GROUP;
2871  return nStyle;
2872 }
2873 
2875 {
2876  return _rStyle.GetRadioCheckFont();
2877 }
2878 
2880 {
2881  return _rStyle.GetRadioCheckTextColor();
2882 }
2883 
2884 void CheckBox::ImplInitSettings( bool bBackground )
2885 {
2887 
2888  if ( bBackground )
2889  {
2890  vcl::Window* pParent = GetParent();
2891  if ( !IsControlBackground() &&
2893  {
2896  SetPaintTransparent( true );
2897  SetBackground();
2900  }
2901  else
2902  {
2903  EnableChildTransparentMode( false );
2905  SetPaintTransparent( false );
2906 
2907  if ( IsControlBackground() )
2909  else
2910  SetBackground( pParent->GetBackground() );
2911  }
2912  }
2913 }
2914 
2916 {
2917  bool bNativeOK = rRenderContext.IsNativeControlSupported(ControlType::Checkbox, ControlPart::Entire);
2918  if (bNativeOK)
2919  {
2921  tools::Rectangle aCtrlRegion(maStateRect);
2923 
2924  if (HasFocus())
2925  nState |= ControlState::FOCUSED;
2927  nState |= ControlState::DEFAULT;
2929  nState |= ControlState::PRESSED;
2930  if (IsEnabled())
2931  nState |= ControlState::ENABLED;
2932 
2933  if (meState == TRISTATE_TRUE)
2934  aControlValue.setTristateVal(ButtonValue::On);
2935  else if (meState == TRISTATE_INDET)
2936  aControlValue.setTristateVal(ButtonValue::Mixed);
2937 
2939  nState |= ControlState::ROLLOVER;
2940 
2941  bNativeOK = rRenderContext.DrawNativeControl(ControlType::Checkbox, ControlPart::Entire, aCtrlRegion,
2942  nState, aControlValue, OUString());
2943  }
2944 
2945  if (!bNativeOK)
2946  {
2947  DrawButtonFlags nStyle = GetButtonState();
2948  if (!IsEnabled())
2949  nStyle |= DrawButtonFlags::Disabled;
2950  if (meState == TRISTATE_INDET)
2951  nStyle |= DrawButtonFlags::DontKnow;
2952  else if (meState == TRISTATE_TRUE)
2953  nStyle |= DrawButtonFlags::Checked;
2954  Image aImage = GetCheckImage(GetSettings(), nStyle);
2955  if (IsZoom())
2956  rRenderContext.DrawImage(maStateRect.TopLeft(), maStateRect.GetSize(), aImage);
2957  else
2958  rRenderContext.DrawImage(maStateRect.TopLeft(), aImage);
2959  }
2960 }
2961 
2963  const Point& rPos, const Size& rSize,
2964  const Size& rImageSize, tools::Rectangle& rStateRect,
2965  tools::Rectangle& rMouseRect )
2966 {
2967  WinBits nWinStyle = GetStyle();
2968  OUString aText( GetText() );
2969 
2971  pDev->IntersectClipRegion( tools::Rectangle( rPos, rSize ) );
2972 
2973  if (!aText.isEmpty() || HasImage())
2974  {
2975  DrawTextFlags nTextStyle = Button::ImplGetTextStyle( nWinStyle, nDrawFlags );
2976 
2977  const long nImageSep = GetDrawPixel( pDev, ImplGetImageToTextDistance() );
2978  Size aSize( rSize );
2979  Point aPos( rPos );
2980  aPos.AdjustX(rImageSize.Width() + nImageSep );
2981  aSize.AdjustWidth( -(rImageSize.Width() + nImageSep) );
2982 
2983  // if the text rect height is smaller than the height of the image
2984  // then for single lines the default should be centered text
2985  if( (nWinStyle & (WB_TOP|WB_VCENTER|WB_BOTTOM)) == 0 &&
2986  (rImageSize.Height() > rSize.Height() || ! (nWinStyle & WB_WORDBREAK) ) )
2987  {
2989  nTextStyle |= DrawTextFlags::VCenter;
2990  aSize.setHeight( rImageSize.Height() );
2991  }
2992 
2993  ImplDrawAlignedImage( pDev, aPos, aSize, 1, nTextStyle );
2994 
2995  rMouseRect = tools::Rectangle( aPos, aSize );
2996  rMouseRect.SetLeft( rPos.X() );
2997  rStateRect.SetLeft( rPos.X() );
2998  rStateRect.SetTop( rMouseRect.Top() );
2999 
3000  if ( aSize.Height() > rImageSize.Height() )
3001  rStateRect.AdjustTop(( aSize.Height() - rImageSize.Height() ) / 2 );
3002  else
3003  {
3004  rStateRect.AdjustTop( -(( rImageSize.Height() - aSize.Height() ) / 2) );
3005  if( rStateRect.Top() < 0 )
3006  rStateRect.SetTop( 0 );
3007  }
3008 
3009  rStateRect.SetRight( rStateRect.Left()+rImageSize.Width()-1 );
3010  rStateRect.SetBottom( rStateRect.Top()+rImageSize.Height()-1 );
3011  if ( rStateRect.Bottom() > rMouseRect.Bottom() )
3012  rMouseRect.SetBottom( rStateRect.Bottom() );
3013  }
3014  else
3015  {
3016  if ( mbLegacyNoTextAlign && ( nWinStyle & WB_CENTER ) )
3017  rStateRect.SetLeft( rPos.X()+((rSize.Width()-rImageSize.Width())/2) );
3018  else if ( mbLegacyNoTextAlign && ( nWinStyle & WB_RIGHT ) )
3019  rStateRect.SetLeft( rPos.X()+rSize.Width()-rImageSize.Width() );
3020  else
3021  rStateRect.SetLeft( rPos.X() );
3022  if ( nWinStyle & WB_VCENTER )
3023  rStateRect.SetTop( rPos.Y()+((rSize.Height()-rImageSize.Height())/2) );
3024  else if ( nWinStyle & WB_BOTTOM )
3025  rStateRect.SetTop( rPos.Y()+rSize.Height()-rImageSize.Height() );
3026  else
3027  rStateRect.SetTop( rPos.Y() );
3028  rStateRect.SetRight( rStateRect.Left()+rImageSize.Width()-1 );
3029  rStateRect.SetBottom( rStateRect.Top()+rImageSize.Height()-1 );
3030  // provide space for focusrect
3031  // note: this assumes that the control's size was adjusted
3032  // accordingly in Get/LoseFocus, so the onscreen position won't change
3033  if( HasFocus() )
3034  rStateRect.Move( 1, 1 );
3035  rMouseRect = rStateRect;
3036 
3037  ImplSetFocusRect( rStateRect );
3038  }
3039 
3040  pDev->Pop();
3041 }
3042 
3044 {
3045  Size aImageSize = ImplGetCheckImageSize();
3046  aImageSize.setWidth( CalcZoom( aImageSize.Width() ) );
3047  aImageSize.setHeight( CalcZoom( aImageSize.Height() ) );
3048 
3049  HideFocus();
3050 
3051  ImplDraw(&rRenderContext, DrawFlags::NONE, Point(), GetOutputSizePixel(),
3052  aImageSize, maStateRect, maMouseRect);
3053 
3054  ImplDrawCheckBoxState(rRenderContext);
3055  if (HasFocus())
3057 }
3058 
3060 {
3061  TriState eNewState;
3062  if ( meState == TRISTATE_FALSE )
3063  eNewState = TRISTATE_TRUE;
3064  else if ( !mbTriState )
3065  eNewState = TRISTATE_FALSE;
3066  else if ( meState == TRISTATE_TRUE )
3067  eNewState = TRISTATE_INDET;
3068  else
3069  eNewState = TRISTATE_FALSE;
3070  meState = eNewState;
3071 
3072  VclPtr<vcl::Window> xWindow = this;
3073  Invalidate();
3074  Update();
3075  Toggle();
3076  if ( xWindow->IsDisposed() )
3077  return;
3078  Click();
3079 }
3080 
3082  Button( WindowType::CHECKBOX ), mbLegacyNoTextAlign( false )
3083 {
3085  ImplInit( pParent, nStyle );
3086 }
3087 
3089 {
3090  if ( rMEvt.IsLeft() && maMouseRect.IsInside( rMEvt.GetPosPixel() ) )
3091  {
3093  Invalidate();
3094  Update();
3095  StartTracking();
3096  return;
3097  }
3098 
3099  Button::MouseButtonDown( rMEvt );
3100 }
3101 
3102 void CheckBox::Tracking( const TrackingEvent& rTEvt )
3103 {
3104  if ( rTEvt.IsTrackingEnded() )
3105  {
3107  {
3108  if ( !(GetStyle() & WB_NOPOINTERFOCUS) && !rTEvt.IsTrackingCanceled() )
3109  GrabFocus();
3110 
3112 
3113  // do not call click handler if aborted
3114  if ( !rTEvt.IsTrackingCanceled() )
3115  ImplCheck();
3116  else
3117  {
3118  Invalidate();
3119  Update();
3120  }
3121  }
3122  }
3123  else
3124  {
3125  if ( maMouseRect.IsInside( rTEvt.GetMouseEvent().GetPosPixel() ) )
3126  {
3128  {
3130  Invalidate();
3131  Update();
3132  }
3133  }
3134  else
3135  {
3137  {
3139  Invalidate();
3140  Update();
3141  }
3142  }
3143  }
3144 }
3145 
3146 void CheckBox::KeyInput( const KeyEvent& rKEvt )
3147 {
3148  vcl::KeyCode aKeyCode = rKEvt.GetKeyCode();
3149 
3150  if ( !aKeyCode.GetModifier() && (aKeyCode.GetCode() == KEY_SPACE) )
3151  {
3153  {
3155  Invalidate();
3156  Update();
3157  }
3158  }
3159  else if ( (GetButtonState() & DrawButtonFlags::Pressed) && (aKeyCode.GetCode() == KEY_ESCAPE) )
3160  {
3162  Invalidate();
3163  Update();
3164  }
3165  else
3166  Button::KeyInput( rKEvt );
3167 }
3168 
3169 void CheckBox::KeyUp( const KeyEvent& rKEvt )
3170 {
3171  vcl::KeyCode aKeyCode = rKEvt.GetKeyCode();
3172 
3173  if ( (GetButtonState() & DrawButtonFlags::Pressed) && (aKeyCode.GetCode() == KEY_SPACE) )
3174  {
3176  ImplCheck();
3177  }
3178  else
3179  Button::KeyUp( rKEvt );
3180 }
3181 
3183 {
3184  mpControlData->mpLayoutData.reset( new vcl::ControlLayoutData );
3185  const_cast<CheckBox*>(this)->Invalidate();
3186 }
3187 
3189 {
3190  ImplDrawCheckBox(rRenderContext);
3191 }
3192 
3193 void CheckBox::Draw( OutputDevice* pDev, const Point& rPos, const Size& rSize,
3194  DrawFlags nFlags )
3195 {
3196  MapMode aResMapMode( MapUnit::Map100thMM );
3197  Point aPos = pDev->LogicToPixel( rPos );
3198  Size aSize = pDev->LogicToPixel( rSize );
3199  Size aImageSize = pDev->LogicToPixel( Size( 300, 300 ), aResMapMode );
3200  Size aBrd1Size = pDev->LogicToPixel( Size( 20, 20 ), aResMapMode );
3201  Size aBrd2Size = pDev->LogicToPixel( Size( 30, 30 ), aResMapMode );
3202  long nCheckWidth = pDev->LogicToPixel( Size( 20, 20 ), aResMapMode ).Width();
3203  vcl::Font aFont = GetDrawPixelFont( pDev );
3204  tools::Rectangle aStateRect;
3205  tools::Rectangle aMouseRect;
3206 
3207  aImageSize.setWidth( CalcZoom( aImageSize.Width() ) );
3208  aImageSize.setHeight( CalcZoom( aImageSize.Height() ) );
3209  aBrd1Size.setWidth( CalcZoom( aBrd1Size.Width() ) );
3210  aBrd1Size.setHeight( CalcZoom( aBrd1Size.Height() ) );
3211  aBrd2Size.setWidth( CalcZoom( aBrd2Size.Width() ) );
3212  aBrd2Size.setHeight( CalcZoom( aBrd2Size.Height() ) );
3213 
3214  if ( !aBrd1Size.Width() )
3215  aBrd1Size.setWidth( 1 );
3216  if ( !aBrd1Size.Height() )
3217  aBrd1Size.setHeight( 1 );
3218  if ( !aBrd2Size.Width() )
3219  aBrd2Size.setWidth( 1 );
3220  if ( !aBrd2Size.Height() )
3221  aBrd2Size.setHeight( 1 );
3222  if ( !nCheckWidth )
3223  nCheckWidth = 1;
3224 
3225  pDev->Push();
3226  pDev->SetMapMode();
3227  pDev->SetFont( aFont );
3228  if ( nFlags & DrawFlags::Mono )
3229  pDev->SetTextColor( COL_BLACK );
3230  else
3231  pDev->SetTextColor( GetTextColor() );
3232  pDev->SetTextFillColor();
3233 
3234  ImplDraw( pDev, nFlags, aPos, aSize,
3235  aImageSize, aStateRect, aMouseRect );
3236 
3237  pDev->SetLineColor();
3238  pDev->SetFillColor( COL_BLACK );
3239  pDev->DrawRect( aStateRect );
3240  aStateRect.AdjustLeft(aBrd1Size.Width() );
3241  aStateRect.AdjustTop(aBrd1Size.Height() );
3242  aStateRect.AdjustRight( -(aBrd1Size.Width()) );
3243  aStateRect.AdjustBottom( -(aBrd1Size.Height()) );
3244  if ( meState == TRISTATE_INDET )
3245  pDev->SetFillColor( COL_LIGHTGRAY );
3246  else
3247  pDev->SetFillColor( COL_WHITE );
3248  pDev->DrawRect( aStateRect );
3249 
3250  if ( meState == TRISTATE_TRUE )
3251  {
3252  aStateRect.AdjustLeft(aBrd2Size.Width() );
3253  aStateRect.AdjustTop(aBrd2Size.Height() );
3254  aStateRect.AdjustRight( -(aBrd2Size.Width()) );
3255  aStateRect.AdjustBottom( -(aBrd2Size.Height()) );
3256  Point aPos11( aStateRect.TopLeft() );
3257  Point aPos12( aStateRect.BottomRight() );
3258  Point aPos21( aStateRect.TopRight() );
3259  Point aPos22( aStateRect.BottomLeft() );
3260  Point aTempPos11( aPos11 );
3261  Point aTempPos12( aPos12 );
3262  Point aTempPos21( aPos21 );
3263  Point aTempPos22( aPos22 );
3264  pDev->SetLineColor( COL_BLACK );
3265  long nDX = 0;
3266  for ( long i = 0; i < nCheckWidth; i++ )
3267  {
3268  if ( !(i % 2) )
3269  {
3270  aTempPos11.setX( aPos11.X()+nDX );
3271  aTempPos12.setX( aPos12.X()+nDX );
3272  aTempPos21.setX( aPos21.X()+nDX );
3273  aTempPos22.setX( aPos22.X()+nDX );
3274  }
3275  else
3276  {
3277  nDX++;
3278  aTempPos11.setX( aPos11.X()-nDX );
3279  aTempPos12.setX( aPos12.X()-nDX );
3280  aTempPos21.setX( aPos21.X()-nDX );
3281  aTempPos22.setX( aPos22.X()-nDX );
3282  }
3283  pDev->DrawLine( aTempPos11, aTempPos12 );
3284  pDev->DrawLine( aTempPos21, aTempPos22 );
3285  }
3286  }
3287 
3288  pDev->Pop();
3289 }
3290 
3292 {
3293  Control::Resize();
3294  Invalidate();
3295 }
3296 
3298 {
3299  if (GetText().isEmpty())
3300  {
3301  // increase button size to have space for focus rect
3302  // checkboxes without text will draw focusrect around the check
3303  // See CheckBox::ImplDraw()
3304  Point aPos( GetPosPixel() );
3305  Size aSize( GetSizePixel() );
3306  aPos.Move(-1,-1);
3307  aSize.AdjustHeight(2 );
3308  aSize.AdjustWidth(2 );
3309  setPosSizePixel( aPos.X(), aPos.Y(), aSize.Width(), aSize.Height() );
3310  Invalidate();
3311  // Trigger drawing to initialize the mouse rectangle, otherwise the mouse button down
3312  // handler would ignore the mouse event.
3313  Update();
3314  }
3315  else
3317 
3319  Button::GetFocus();
3320 }
3321 
3323 {
3325  {
3327  Invalidate();
3328  Update();
3329  }
3330 
3331  HideFocus();
3333 
3334  if (GetText().isEmpty())
3335  {
3336  // decrease button size again (see GetFocus())
3337  // checkboxes without text will draw focusrect around the check
3338  Point aPos( GetPosPixel() );
3339  Size aSize( GetSizePixel() );
3340  aPos.Move(1,1);
3341  aSize.AdjustHeight( -2 );
3342  aSize.AdjustWidth( -2 );
3343  setPosSizePixel( aPos.X(), aPos.Y(), aSize.Width(), aSize.Height() );
3344  Invalidate();
3345  }
3346 }
3347 
3349 {
3350  Button::StateChanged( nType );
3351 
3352  if ( nType == StateChangedType::State )
3353  {
3354  if ( IsReallyVisible() && IsUpdateMode() )
3356  }
3357  else if ( (nType == StateChangedType::Enable) ||
3358  (nType == StateChangedType::Text) ||
3359  (nType == StateChangedType::Data) ||
3360  (nType == StateChangedType::UpdateMode) )
3361  {
3362  if ( IsUpdateMode() )
3363  Invalidate();
3364  }
3365  else if ( nType == StateChangedType::Style )
3366  {
3368 
3369  if ( (GetPrevStyle() & CHECKBOX_VIEW_STYLE) !=
3371  {
3372  if ( IsUpdateMode() )
3373  Invalidate();
3374  }
3375  }
3376  else if ( (nType == StateChangedType::Zoom) ||
3377  (nType == StateChangedType::ControlFont) )
3378  {
3379  ImplInitSettings( false );
3380  Invalidate();
3381  }
3382  else if ( nType == StateChangedType::ControlForeground )
3383  {
3384  ImplInitSettings( false );
3385  Invalidate();
3386  }
3387  else if ( nType == StateChangedType::ControlBackground )
3388  {
3389  ImplInitSettings( true );
3390  Invalidate();
3391  }
3392 }
3393 
3395 {
3396  Button::DataChanged( rDCEvt );
3397 
3398  if ( (rDCEvt.GetType() == DataChangedEventType::FONTS) ||
3400  ((rDCEvt.GetType() == DataChangedEventType::SETTINGS) &&
3401  (rDCEvt.GetFlags() & AllSettingsFlags::STYLE)) )
3402  {
3403  ImplInitSettings( true );
3404  Invalidate();
3405  }
3406 }
3407 
3409 {
3410  const MouseEvent* pMouseEvt = nullptr;
3411 
3412  if( (rNEvt.GetType() == MouseNotifyEvent::MOUSEMOVE) && (pMouseEvt = rNEvt.GetMouseEvent()) != nullptr )
3413  {
3414  if( !pMouseEvt->GetButtons() && !pMouseEvt->IsSynthetic() && !pMouseEvt->IsModifierChanged() )
3415  {
3416  // trigger redraw if mouse over state has changed
3418  {
3420  pMouseEvt->IsLeaveWindow() || pMouseEvt->IsEnterWindow())
3421  {
3423  }
3424  }
3425  }
3426  }
3427 
3428  return Button::PreNotify(rNEvt);
3429 }
3430 
3432 {
3434 }
3435 
3437 {
3438  if ( !mbTriState && (eState == TRISTATE_INDET) )
3439  eState = TRISTATE_FALSE;
3440 
3441  if ( meState != eState )
3442  {
3443  meState = eState;
3445  Toggle();
3446  }
3447 }
3448 
3449 bool CheckBox::set_property(const OString &rKey, const OUString &rValue)
3450 {
3451  if (rKey == "active")
3453  else
3454  return Button::set_property(rKey, rValue);
3455  return true;
3456 }
3457 
3458 void CheckBox::EnableTriState( bool bTriState )
3459 {
3460  if ( mbTriState != bTriState )
3461  {
3462  mbTriState = bTriState;
3463 
3464  if ( !bTriState && (meState == TRISTATE_INDET) )
3466  }
3467 }
3468 
3470 {
3471  // 4 pixels, but take zoom into account, so the text doesn't "jump" relative to surrounding elements,
3472  // which might have been aligned with the text of the check box
3473  return CalcZoom( 4 );
3474 }
3475 
3477 {
3478  Size aSize;
3479  bool bDefaultSize = true;
3481  {
3482  ImplControlValue aControlValue;
3483  tools::Rectangle aCtrlRegion( Point( 0, 0 ), GetSizePixel() );
3484  tools::Rectangle aBoundingRgn, aContentRgn;
3485 
3486  // get native size of a check box
3489  aControlValue,
3490  aBoundingRgn, aContentRgn ) )
3491  {
3492  aSize = aContentRgn.GetSize();
3493  bDefaultSize = false;
3494  }
3495  }
3496  if( bDefaultSize )
3498  return aSize;
3499 }
3500 
3502 {
3503  ImplSVData* pSVData = ImplGetSVData();
3504  const StyleSettings& rStyleSettings = rSettings.GetStyleSettings();
3505  sal_uInt16 nStyle = 0;
3506 
3507  if ( rStyleSettings.GetOptions() & StyleSettingsOptions::Mono )
3508  nStyle = STYLE_CHECKBOX_MONO;
3509 
3510  if ( pSVData->maCtrlData.maCheckImgList.empty() ||
3511  (pSVData->maCtrlData.mnCheckStyle != nStyle) ||
3512  (pSVData->maCtrlData.mnLastCheckFColor != rStyleSettings.GetFaceColor()) ||
3513  (pSVData->maCtrlData.mnLastCheckWColor != rStyleSettings.GetWindowColor()) ||
3514  (pSVData->maCtrlData.mnLastCheckLColor != rStyleSettings.GetLightColor()) )
3515  {
3516  pSVData->maCtrlData.maCheckImgList.clear();
3517 
3518  pSVData->maCtrlData.mnLastCheckFColor = rStyleSettings.GetFaceColor();
3519  pSVData->maCtrlData.mnLastCheckWColor = rStyleSettings.GetWindowColor();
3520  pSVData->maCtrlData.mnLastCheckLColor = rStyleSettings.GetLightColor();
3521 
3522  std::vector<OUString> aResources;
3523  if (nStyle)
3524  {
3525  aResources.emplace_back(SV_RESID_BITMAP_CHECKMONO1);
3526  aResources.emplace_back(SV_RESID_BITMAP_CHECKMONO2);
3527  aResources.emplace_back(SV_RESID_BITMAP_CHECKMONO3);
3528  aResources.emplace_back(SV_RESID_BITMAP_CHECKMONO4);
3529  aResources.emplace_back(SV_RESID_BITMAP_CHECKMONO5);
3530  aResources.emplace_back(SV_RESID_BITMAP_CHECKMONO6);
3531  aResources.emplace_back(SV_RESID_BITMAP_CHECKMONO7);
3532  aResources.emplace_back(SV_RESID_BITMAP_CHECKMONO8);
3533  aResources.emplace_back(SV_RESID_BITMAP_CHECKMONO9);
3534  }
3535  else
3536  {
3537  aResources.emplace_back(SV_RESID_BITMAP_CHECK1);
3538  aResources.emplace_back(SV_RESID_BITMAP_CHECK2);
3539  aResources.emplace_back(SV_RESID_BITMAP_CHECK3);
3540  aResources.emplace_back(SV_RESID_BITMAP_CHECK4);
3541  aResources.emplace_back(SV_RESID_BITMAP_CHECK5);
3542  aResources.emplace_back(SV_RESID_BITMAP_CHECK6);
3543  aResources.emplace_back(SV_RESID_BITMAP_CHECK7);
3544  aResources.emplace_back(SV_RESID_BITMAP_CHECK8);
3545  aResources.emplace_back(SV_RESID_BITMAP_CHECK9);
3546  }
3547  LoadThemedImageList(rStyleSettings, pSVData->maCtrlData.maCheckImgList, aResources);
3548  pSVData->maCtrlData.mnCheckStyle = nStyle;
3549  }
3550 
3551  sal_uInt16 nIndex;
3552  if ( nFlags & DrawButtonFlags::Disabled )
3553  {
3554  if ( nFlags & DrawButtonFlags::DontKnow )
3555  nIndex = 8;
3556  else if ( nFlags & DrawButtonFlags::Checked )
3557  nIndex = 5;
3558  else
3559  nIndex = 4;
3560  }
3561  else if ( nFlags & DrawButtonFlags::Pressed )
3562  {
3563  if ( nFlags & DrawButtonFlags::DontKnow )
3564  nIndex = 7;
3565  else if ( nFlags & DrawButtonFlags::Checked )
3566  nIndex = 3;
3567  else
3568  nIndex = 2;
3569  }
3570  else
3571  {
3572  if ( nFlags & DrawButtonFlags::DontKnow )
3573  nIndex = 6;
3574  else if ( nFlags & DrawButtonFlags::Checked )
3575  nIndex = 1;
3576  else
3577  nIndex = 0;
3578  }
3579  return pSVData->maCtrlData.maCheckImgList[nIndex];
3580 }
3581 
3583 {
3585  SetMapMode(MapMode(MapUnit::MapPixel));
3586 
3587  ImplControlValue aControlValue;
3588  Size aCurSize( GetSizePixel() );
3589  tools::Rectangle aCtrlRegion( Point( 0, 0 ), aCurSize );
3590  tools::Rectangle aBoundingRgn, aContentRgn;
3591 
3592  // get native size of a radiobutton
3595  aBoundingRgn, aContentRgn ) )
3596  {
3597  Size aSize = aContentRgn.GetSize();
3598 
3599  if( aSize.Height() > aCurSize.Height() )
3600  {
3601  aCurSize.setHeight( aSize.Height() );
3602  SetSizePixel( aCurSize );
3603  }
3604  }
3605 
3606  Pop();
3607 }
3608 
3609 Size CheckBox::CalcMinimumSize( long nMaxWidth ) const
3610 {
3611  Size aSize = ImplGetCheckImageSize();
3612  nMaxWidth -= aSize.Width();
3613 
3614  OUString aText = GetText();
3615  if (!aText.isEmpty())
3616  {
3617  // subtract what will be added later
3618  nMaxWidth-=2;
3619  nMaxWidth -= ImplGetImageToTextDistance();
3620 
3621  Size aTextSize = GetTextRect( tools::Rectangle( Point(), Size( nMaxWidth > 0 ? nMaxWidth : 0x7fffffff, 0x7fffffff ) ),
3623  aSize.AdjustWidth(2 ); // for focus rect
3625  aSize.AdjustWidth(aTextSize.Width() );
3626  if ( aSize.Height() < aTextSize.Height() )
3627  aSize.setHeight( aTextSize.Height() );
3628  }
3629  else
3630  {
3631  // is this still correct ? since the checkbox now
3632  // shows a focus rect it should be 2 pixels wider and longer
3633 /* since otherwise the controls in the Writer hang too far up
3634  aSize.Width() += 2;
3635  aSize.Height() += 2;
3636 */
3637  }
3638 
3639  return CalcWindowSize( aSize );
3640 }
3641 
3643 {
3644  int nWidthRequest(get_width_request());
3645  return CalcMinimumSize(nWidthRequest != -1 ? nWidthRequest : 0);
3646 }
3647 
3649 {
3651  {
3652  ImplControlValue aControlValue;
3653  tools::Rectangle aInRect(Point(0, 0), GetSizePixel());
3654 
3655  aInRect.SetLeft( rRect.Left() ); // exclude the checkbox itself from the focusrect
3656 
3658  ControlState::FOCUSED, aControlValue, OUString());
3659  }
3660  Button::ShowFocus(rRect);
3661 }
3662 
3663 boost::property_tree::ptree CheckBox::DumpAsPropertyTree()
3664 {
3665  boost::property_tree::ptree aTree(Button::DumpAsPropertyTree());
3666  aTree.put("checked", IsChecked());
3667  return aTree;
3668 }
3669 
3671 {
3672  return CheckBoxUIObject::create;
3673 }
3674 
3676  PushButton( pParent, nStyle )
3677 {
3678  ImplInitStyle();
3679 }
3680 
3682 {
3683  WinBits nStyle = GetStyle();
3684 
3685  if ( ! ( nStyle & ( WB_RIGHT | WB_LEFT ) ) )
3686  nStyle |= WB_CENTER;
3687 
3688  if ( ! ( nStyle & ( WB_TOP | WB_BOTTOM ) ) )
3689  nStyle |= WB_VCENTER;
3690 
3691  SetStyle( nStyle );
3692 }
3693 
3695  RadioButton( pParent, 0 )
3696 {
3697 }
3698 
3700  CheckBox( pParent, nStyle )
3701 {
3702  EnableTriState();
3703 }
3704 
3706  CheckBox( pParent, 0 )
3707 {
3708 }
3709 
3711 {
3712  /* HACK: DisclosureButton is currently assuming, that the disclosure sign
3713  will fit into the rectangle occupied by a normal checkbox on all themes.
3714  If this does not hold true for some theme, ImplGetCheckImageSize
3715  would have to be overridden for DisclosureButton; also GetNativeControlRegion
3716  for ControlType::ListNode would have to be implemented and taken into account
3717  */
3718 
3719  tools::Rectangle aStateRect(GetStateRect());
3720 
3722  tools::Rectangle aCtrlRegion(aStateRect);
3724 
3725  if (HasFocus())
3726  nState |= ControlState::FOCUSED;
3728  nState |= ControlState::DEFAULT;
3729  if (Window::IsEnabled())
3730  nState |= ControlState::ENABLED;
3731  if (IsMouseOver() && GetMouseRect().IsInside(GetPointerPosPixel()))
3732  nState |= ControlState::ROLLOVER;
3733 
3734  if (rRenderContext.DrawNativeControl(ControlType::ListNode, ControlPart::Entire, aCtrlRegion,
3735  nState, aControlValue, OUString()))
3736  return;
3737 
3738  ImplSVCtrlData& rCtrlData(ImplGetSVData()->maCtrlData);
3739  if (!rCtrlData.mpDisclosurePlus)
3740  rCtrlData.mpDisclosurePlus.reset(new Image(StockImage::Yes, SV_DISCLOSURE_PLUS));
3741  if (!rCtrlData.mpDisclosureMinus)
3742  rCtrlData.mpDisclosureMinus.reset(new Image(StockImage::Yes, SV_DISCLOSURE_MINUS));
3743 
3744  Image* pImg
3745  = IsChecked() ? rCtrlData.mpDisclosureMinus.get() : rCtrlData.mpDisclosurePlus.get();
3746 
3748  if (!IsEnabled())
3749  nStyle |= DrawImageFlags::Disable;
3750 
3751  Size aSize(aStateRect.GetSize());
3752  Size aImgSize(pImg->GetSizePixel());
3753  Point aOff((aSize.Width() - aImgSize.Width()) / 2,
3754  (aSize.Height() - aImgSize.Height()) / 2);
3755  aOff += aStateRect.TopLeft();
3756  rRenderContext.DrawImage(aOff, *pImg, nStyle);
3757 }
3758 
3760 {
3761  vcl::KeyCode aKeyCode = rKEvt.GetKeyCode();
3762 
3763  if( !aKeyCode.GetModifier() &&
3764  ( ( aKeyCode.GetCode() == KEY_ADD ) ||
3765  ( aKeyCode.GetCode() == KEY_SUBTRACT ) )
3766  )
3767  {
3768  Check( aKeyCode.GetCode() == KEY_ADD );
3769  }
3770  else
3771  CheckBox::KeyInput( rKEvt );
3772 }
3773 
3774 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
virtual Point GetPosPixel() const
Definition: window.cxx:2803
std::shared_ptr< std::vector< VclPtr< RadioButton > > > m_xGroup
Definition: button.hxx:279
virtual void Resize() override
Definition: button.cxx:2410
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:1259
virtual void DataChanged(const DataChangedEvent &rDCEvt) override
Definition: button.cxx:3394
#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:1082
static std::unique_ptr< UIObject > create(vcl::Window *pWindow)
SAL_DLLPRIVATE void ImplInitCheckBoxData()
Definition: button.cxx:2849
void Toggle()
Definition: button.cxx:3431
Color mnLastRadioLColor
Definition: svdata.hxx:245
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:1509
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:1525
void HideFocus()
Definition: window2.cxx:91
sal_Int32 nIndex
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:241
virtual void StateChanged(StateChangedType nType) override
Definition: button.cxx:3348
virtual void Draw(OutputDevice *pDev, const Point &rPos, const Size &rSize, DrawFlags nFlags) override
Definition: button.cxx:3193
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:3642
const Color & GetActionButtonTextColor() const
static Image GetRadioImage(const AllSettings &rSettings, DrawButtonFlags nFlags)
Definition: button.cxx:2673
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.
#define KEY_SPACE
Definition: keycodes.hxx:123
virtual bool Close() override
Definition: dialog.cxx:811
sal_uInt16 mnCheckStyle
Definition: svdata.hxx:238
SAL_DLLPRIVATE void ImplSetFocusRect(const tools::Rectangle &rFocusRect)
Definition: button.cxx:453
void SetModeRadioImage(const Image &rImage)
Definition: button.cxx:2524
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:2078
void SetClickHdl(const Link< Button *, void > &rLink)
Definition: button.hxx:70
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:1201
void SetModeImage(const Image &rImage)
Definition: button.cxx:126
SAL_DLLPRIVATE void ImplSetDefButton(bool bSet)
Definition: button.cxx:1042
void Check(bool bCheck=true)
Definition: button.hxx:208
SymbolAlign
virtual void Click() override
Definition: button.cxx:1621
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:2864
Point BottomLeft() const
WinBits const WB_NOGROUP
void DrawCtrlText(const Point &rPos, const OUString &rStr, sal_Int32 nIndex=0, sal_Int32 nLen=-1, DrawTextFlags nStyle=DrawTextFlags::Mnemonic, MetricVector *pVector=nullptr, OUString *pDisplayText=nullptr, const SalLayoutGlyphs *pGlyphs=nullptr)
Definition: text.cxx:2057
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:1380
sal_uIntPtr sal_uLong
Link< CheckBox &, void > maToggleHdl
Definition: button.hxx:394
virtual void FillLayoutData() const override
Definition: button.cxx:3182
virtual void LoseFocus() override
Definition: button.cxx:2423
const StyleSettings & GetStyleSettings() const
static const AllSettings & GetSettings()
Gets the application's settings.
Definition: svapp.cxx:705
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:361
void Toggle()
Definition: button.cxx:2519
SAL_DLLPRIVATE const tools::Rectangle & GetStateRect() const
Definition: button.hxx:424
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:2365
virtual void SetSizePixel(const Size &rNewSize)
Definition: window2.cxx:1257
WinBits const WB_RIGHT
virtual void KeyUp(const KeyEvent &rKEvt) override
Definition: button.cxx:2312
SAL_DLLPRIVATE WindowImpl * ImplGetWindowImpl() const
Definition: window.hxx:555
void SetState(bool bCheck)
Definition: button.cxx:2535
void CompatStateChanged(StateChangedType nStateChange)
Definition: window.cxx:3851
SAL_DLLPRIVATE void ImplCallClick(bool bGrabFocus=false, GetFocusFlags nFocusFlags=GetFocusFlags::NONE)
Definition: button.cxx:2182
PushButtonDropdownStyle
Definition: button.hxx:103
bool mbNoFocusRectsForFlatButtons
Definition: svdata.hxx:284
boost::property_tree::ptree DumpAsPropertyTree() override
Button hes additional stuff that we need to dump too.
Definition: button.cxx:2837
tools::Rectangle maMouseRect
Definition: button.hxx:390
void SetTextFillColor()
Definition: text.cxx:699
virtual bool set_property(const OString &rKey, const OUString &rValue) override
Definition: button.cxx:1579
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:953
DataChangedEventType GetType() const
Definition: event.hxx:348
virtual Size GetOptimalSize() const override
Definition: button.cxx:1574
void IntersectClipRegion(const tools::Rectangle &rRect)
DrawButtonFlags
Definition: decoview.hxx:68
SAL_DLLPRIVATE void ImplDrawRadioButtonState(vcl::RenderContext &rRenderContext)
Definition: button.cxx:1820
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:1752
const Color & GetControlBackground() const
Definition: window2.cxx:1077
void SetState(TriState eState)
Definition: button.cxx:3436
tools::Rectangle DrawButton(const tools::Rectangle &rRect, DrawButtonFlags nStyle)
Definition: decoview.cxx:942
virtual void ShowFocus(const tools::Rectangle &rRect) override
Definition: button.cxx:1594
virtual void Tracking(const TrackingEvent &rTEvt) override
Definition: button.cxx:1137
SAL_DLLPRIVATE void ImplDrawPushButtonContent(OutputDevice *pDev, DrawFlags nDrawFlags, const tools::Rectangle &rRect, bool bMenuBtnSep, DrawButtonFlags nButtonFlags)
Definition: button.cxx:731
SAL_DLLPRIVATE Size ImplGetRadioImageSize() const
Definition: button.cxx:2620
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:3710
ImplSVCtrlData maCtrlData
Definition: svdata.hxx:359
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:1477
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:2055
bool IsTrackingRepeat() const
Definition: event.hxx:252
void SetSymbolAlign(SymbolAlign eAlign)
Definition: button.cxx:1472
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:1796
SAL_DLLPRIVATE void ImplDraw(OutputDevice *pDev, DrawFlags nDrawFlags, const Point &rPos, const Size &rSize, const Size &rImageSize, tools::Rectangle &rStateRect, tools::Rectangle &rMouseRect)
Definition: button.cxx:1936
virtual void KeyInput(const KeyEvent &rKEvt) override
Definition: button.cxx:3146
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:3449
virtual void setPosSizePixel(long nX, long nY, long nWidth, long nHeight, PosSizeFlags nFlags=PosSizeFlags::All)
Definition: window.cxx:2682
sal_Int64 WinBits
void SetBackground()
Size CalcMinimumSize() const
Definition: button.cxx:1537
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:2396
sal_uInt16 GetButtons() const
Definition: event.hxx:131
void SetSymbol(SymbolType eSymbol)
Definition: button.cxx:1463
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:1110
virtual void GetFocus() override
Definition: button.cxx:3297
const vcl::Font & GetFont() const
Definition: outdev.hxx:637
void ImplAdjustNWFSizes() override
Definition: button.cxx:3582
bool IsControlForeground() const
Definition: window2.cxx:1072
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:2879
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:934
bool IsChecked() const
Definition: button.hxx:348
AllSettingsFlags GetFlags() const
Definition: event.hxx:349
virtual void StateChanged(StateChangedType nStateChange) override
Definition: button.cxx:1735
const Color & GetLightColor() const
virtual void GetFocus() override
Definition: button.cxx:1319
virtual void Click()
Definition: button.cxx:121
virtual void queue_resize(StateChangedType eReason=StateChangedType::Layout)
Definition: window2.cxx:1309
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:3056
static Image GetCheckImage(const AllSettings &rSettings, DrawButtonFlags nFlags)
Definition: button.cxx:3501
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:1745
Definition: edit.hxx:55
SymbolType meSymbol
Definition: button.hxx:202
void setY(long nY)
virtual void LoseFocus() override
Definition: button.cxx:1326
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:1022
SAL_DLLPRIVATE void ImplCheck()
Definition: button.cxx:3059
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:3408
const Color & GetControlForeground() const
Definition: window2.cxx:1067
long GetDrawPixel(::OutputDevice const *pDev, long nPixels) const
Definition: window2.cxx:563
void Update()
Definition: paint.cxx:1284
#define SAL_N_ELEMENTS(arr)
SAL_DLLPRIVATE bool ImplUseNativeBorder(vcl::RenderContext const &rRenderContext, WinBits nStyle)
Definition: edit.cxx:282
static void LoadThemedImageList(const StyleSettings &rStyleSettings, std::vector< Image > &rList, const std::vector< OUString > &rResources)
Definition: button.cxx:2645
virtual void MouseButtonDown(const MouseEvent &rMEvt) override
Definition: button.cxx:2231
WinBits const WB_NOLIGHTBORDER
Point BottomRight() const
const Color & GetDarkShadowColor() const
bool mbLegacyNoTextAlign
Definition: button.hxx:399
ImplSVData * ImplGetSVData()
Definition: svdata.cxx:75
virtual bool PreNotify(NotifyEvent &rNEvt) override
Definition: button.cxx:2496
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:1720
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:3353
void SetLineColor()
virtual void ShowFocus(const tools::Rectangle &rRect) override
Definition: button.cxx:3648
void SetTop(long v)
virtual bool PreNotify(NotifyEvent &rNEvt)
Definition: event.cxx:51
void SetInputContext(const InputContext &rInputContext)
Definition: window.cxx:2040
bool IsLeaveWindow() const
Definition: event.hxx:124
void Check(bool bCheck=true)
Definition: button.cxx:2590
long AdjustY(long nVertMove)
DrawFlags
Definition: window.hxx:354
uno_Any a
bool IsChecked() const
Definition: button.hxx:213
virtual bool PreNotify(NotifyEvent &rNEvt) override
Definition: button.cxx:1394
SAL_DLLPRIVATE void ImplInit(vcl::Window *pParent, WinBits nStyle)
Definition: button.cxx:1654
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects...
Definition: button.cxx:2220
void setY(long y)
bool IsSystemWindow() const
Definition: window2.cxx:992
static constexpr auto CHECKBOX_VIEW_STYLE
Definition: button.cxx:63
SAL_DLLPRIVATE long ImplGetImageToTextDistance() const
Definition: button.cxx:3469
virtual void Tracking(const TrackingEvent &rTEvt) override
Definition: button.cxx:3102
std::unique_ptr< Image > mpDisclosureMinus
Definition: svdata.hxx:236
virtual void SetText(const OUString &rStr) override
Definition: ctrl.cxx:95
virtual void Resize() override
Definition: button.cxx:1313
std::unique_ptr< ImplCommonButtonData > mpButtonData
Definition: button.hxx:41
sal_uInt16 mnRadioStyle
Definition: svdata.hxx:239
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:1160
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:3476
void EnableTriState(bool bTriState=true)
Definition: button.cxx:3458
CancelButton(const CancelButton &)=delete
Size CalcMinimumSize(long nMaxWidth=0) const
Definition: button.cxx:3609
CloseButton(vcl::Window *pParent, WinBits nStyle=0)
Definition: button.cxx:1700
bool IsUpdateMode() const
Definition: window2.cxx:1168
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
std::vector< VclPtr< RadioButton > > GetRadioButtonGroup(bool bIncludeThis=true) const
GetRadioButtonGroup returns a list of pointers to RadioButtons in the same group. ...
Definition: button.cxx:2118
bool IsChecked() const
Definition: button.hxx:482
virtual FactoryFunction GetUITestFactory() const override
Definition: button.cxx:2844
bool IsDialog() const
Definition: window2.cxx:997
void SetTextColor(const Color &rColor)
Definition: text.cxx:664
long Bottom() const
virtual const vcl::Font & GetCanonicalFont(const StyleSettings &_rStyle) const override
Definition: button.cxx:1779
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:2817
bool IsZoom() const
Definition: window2.cxx:1210
WinBits const WB_RECTSTYLE
virtual void KeyInput(const KeyEvent &rKEvt) override
Definition: button.cxx:2289
virtual void KeyUp(const KeyEvent &rKEvt) override
Definition: button.cxx:3169
virtual void Draw(OutputDevice *pDev, const Point &rPos, const Size &rSize, DrawFlags nFlags) override
Definition: button.cxx:1270
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:72
const AllSettings & GetSettings() const
Definition: outdev.hxx:420
void SetPaintTransparent(bool bTransparent)
Definition: paint.cxx:1022
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:1427
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:1819
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:2821
void GrabFocus()
Definition: window.cxx:2977
long GetTextHeight() const
Height where any character of the current font fits; in logic coordinates.
Definition: text.cxx:890
virtual void ShowFocus(const tools::Rectangle &rRect)
Definition: window2.cxx:49
vcl::Window * GetParent() const
Definition: window2.cxx:1092
virtual void FillLayoutData() const override
Definition: button.cxx:2325
WinBits const WB_LEFT
virtual void GetFocus() override
Definition: button.cxx:2416
long X() const
void Toggle()
Definition: button.cxx:1458
SAL_DLLPRIVATE void ImplDrawPushButton(vcl::RenderContext &rRenderContext)
Definition: button.cxx:836
bool IsTrackingEnded() const
Definition: event.hxx:254
void SetStyle(WinBits nStyle)
Definition: window.cxx:1926
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:3088
WinBits const WB_REPEAT
SAL_DLLPRIVATE void ImplInitPushButtonData()
Definition: button.cxx:565
const Color & GetButtonRolloverTextColor() const
SAL_DLLPRIVATE void ImplInitStyle()
Definition: button.cxx:3681
StyleSettingsOptions GetOptions() const
vcl::Window * GetWindow(GetWindowType nType) const
Definition: stacking.cxx:1046
DisclosureButton(vcl::Window *pParent)
Definition: button.cxx:3705
virtual void StateChanged(StateChangedType nType) override
Definition: button.cxx:2436
Point LogicToPixel(const Point &rLogicPt) const
Definition: map.cxx:934
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:1769
SAL_DLLPRIVATE void ImplInit(vcl::Window *pParent, WinBits nStyle, SystemParentData *pSystemParentData)
Definition: window.cxx:932
#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:2856
DrawButtonFlags GetButtonState() const
Definition: button.cxx:488
bool IsModifierChanged() const
Definition: event.hxx:128
virtual const Color & GetCanonicalTextColor(const StyleSettings &_rStyle) const override
Definition: button.cxx:1784
OKButton(const OKButton &)=delete
long GetCtrlTextWidth(const OUString &rStr, const SalLayoutGlyphs *pLayoutCache=nullptr) const
Definition: text.cxx:2200
void set_id(const OUString &rID)
Sets an ID.
Definition: window.cxx:3877
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
Definition: button.cxx:1265
ImageRadioButton(const ImageRadioButton &)=delete
virtual bool set_property(const OString &rKey, const OUString &rValue) override
Definition: button.cxx:2551
virtual void StateChanged(StateChangedType nType) override
Definition: button.cxx:1333
virtual const vcl::Font & GetCanonicalFont(const StyleSettings &_rStyle) const override
Definition: button.cxx:2874
virtual void ImplDrawCheckBoxState(vcl::RenderContext &rRenderContext)
Definition: button.cxx:2915
void ImplAdjustNWFSizes() override
Definition: button.cxx:2742
const vcl::KeyCode & GetKeyCode() const
Definition: event.hxx:53
static vcl::Window * GetFocusWindow()
Get the currently focused window.
Definition: svapp.cxx:1045
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:2962
void SetSmallSymbol()
Definition: button.cxx:502
void SetPressed(bool bPressed)
Definition: button.cxx:1516
void SetFaceColor(const Color &rColor)
static SAL_DLLPRIVATE DrawTextFlags ImplGetTextStyle(WinBits nWinBits)
Definition: fixed.cxx:103
bool IsMouseOver() const
Definition: mouse.cxx:605
virtual void Resize() override
Definition: ctrl.cxx:74
long AdjustRight(long nHorzMoveDelta)
SAL_DLLPRIVATE bool ImplIsDefButton() const
Definition: button.cxx:1099
static SAL_DLLPRIVATE bool ImplHitTestPushButton(vcl::Window const *pDev, const Point &rPos)
Definition: button.cxx