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