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