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