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