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