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;
189}
190
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;
203 }
204
205 return nTextStyle;
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 OUString &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 if (isToggleButton())
647 rJsonWriter.put("isToggle", true);
648}
649
650IMPL_STATIC_LINK( Button, dispatchCommandHandler, Button*, pButton, void )
651{
652 if (pButton == nullptr)
653 return;
654
655 comphelper::dispatchCommand(pButton->maCommand, uno::Sequence<beans::PropertyValue>());
656}
657
659{
660 mpWindowImpl->mbPushButton = true;
661
665 mbIsActive = false;
666 mbPressed = false;
667 mbIsAction = false;
668}
669
670namespace
671{
672 vcl::Window* getPreviousSibling(vcl::Window const *pParent)
673 {
674 return pParent ? pParent->GetWindow(GetWindowType::LastChild) : nullptr;
675 }
676}
677
679{
680 nStyle = ImplInitStyle(getPreviousSibling(pParent), nStyle);
681 Button::ImplInit( pParent, nStyle, nullptr );
682
683 if ( nStyle & WB_NOLIGHTBORDER )
685
686 ImplInitSettings( true );
687}
688
690{
691 if ( !(nStyle & WB_NOTABSTOP) )
692 nStyle |= WB_TABSTOP;
693
694 // if no alignment is given, default to "vertically centered". This is because since
695 // #i26046#, we respect the vertical alignment flags (previously we didn't completely),
696 // but we of course want to look as before when no vertical alignment is specified
697 if ( ( nStyle & ( WB_TOP | WB_VCENTER | WB_BOTTOM ) ) == 0 )
698 nStyle |= WB_VCENTER;
699
700 if ( !(nStyle & WB_NOGROUP) &&
701 (!pPrevWindow ||
702 ((pPrevWindow->GetType() != WindowType::PUSHBUTTON ) &&
703 (pPrevWindow->GetType() != WindowType::OKBUTTON ) &&
704 (pPrevWindow->GetType() != WindowType::CANCELBUTTON) &&
705 (pPrevWindow->GetType() != WindowType::HELPBUTTON )) ) )
706 nStyle |= WB_GROUP;
707 return nStyle;
708}
709
711{
712 return _rStyle.GetPushButtonFont();
713}
714
716{
717 return _rStyle.GetButtonTextColor();
718}
719
720void PushButton::ImplInitSettings( bool bBackground )
721{
723
724 if ( !bBackground )
725 return;
726
728 // #i38498#: do not check for GetParent()->IsChildTransparentModeEnabled()
729 // otherwise the formcontrol button will be overdrawn due to ParentClipMode::NoClip
730 // for radio and checkbox this is ok as they should appear transparent in documents
732 (GetStyle() & WB_FLATBUTTON) != 0 )
733 {
736 SetPaintTransparent( true );
737
738 if ((GetStyle() & WB_FLATBUTTON) == 0)
739 mpWindowImpl->mbUseNativeFocus = ImplGetSVData()->maNWFData.mbNoFocusRects;
740 else
742 }
743 else
744 {
747 SetPaintTransparent( false );
748 }
749}
750
752 tools::Rectangle& rRect, DrawButtonFlags nStyle)
753{
754 if (!(GetStyle() & (WB_RECTSTYLE | WB_SMALLSTYLE)))
755 {
756 StyleSettings aStyleSettings = rRenderContext.GetSettings().GetStyleSettings();
758 aStyleSettings.Set3DColors(GetControlBackground());
759 }
760
761 DecorationView aDecoView(&rRenderContext);
763 {
764 AllSettings aSettings = rRenderContext.GetSettings();
765 AllSettings aOldSettings = aSettings;
766 StyleSettings aStyleSettings = aSettings.GetStyleSettings();
767 if (nStyle & DrawButtonFlags::Highlight)
768 {
769 // with the custom background, native highlight do nothing, so code below mimic
770 // native highlight by changing luminance
771 Color controlBackgroundColorHighlighted = GetControlBackground();
772 sal_uInt8 colorLuminance = controlBackgroundColorHighlighted.GetLuminance();
773 if (colorLuminance < 205)
774 controlBackgroundColorHighlighted.IncreaseLuminance(50);
775 else
776 controlBackgroundColorHighlighted.DecreaseLuminance(50);
777 aStyleSettings.Set3DColors(controlBackgroundColorHighlighted);
778 }
779 else
780 aStyleSettings.Set3DColors(GetControlBackground());
781 aSettings.SetStyleSettings(aStyleSettings);
782
783 // Call OutputDevice::SetSettings() explicitly, as rRenderContext may
784 // be a vcl::Window in fact, and vcl::Window::SetSettings() will call
785 // Invalidate(), which is a problem, since we're in Paint().
786 rRenderContext.OutputDevice::SetSettings(aSettings);
787 rRect = aDecoView.DrawButton(rRect, nStyle);
788 rRenderContext.OutputDevice::SetSettings(aOldSettings);
789 }
790 else
791 rRect = aDecoView.DrawButton(rRect, nStyle);
792}
793
795 const Point& rPos )
796{
797 tools::Rectangle aTestRect( Point(), pDev->GetOutputSizePixel() );
798
799 return aTestRect.Contains( rPos );
800}
801
803{
804 const StyleSettings& rStyleSettings = GetSettings().GetStyleSettings();
805
807
808 if ( ( rStyleSettings.GetOptions() & StyleSettingsOptions::Mono ) ||
809 ( nSystemTextColorFlags & SystemTextColorFlags::Mono ) )
810 nTextStyle |= DrawTextFlags::Mono;
811
812 if ( GetStyle() & WB_WORDBREAK )
813 nTextStyle |= DrawTextFlags::WordBreak;
814 if ( GetStyle() & WB_NOLABEL )
815 nTextStyle &= ~DrawTextFlags::Mnemonic;
816
817 if ( GetStyle() & WB_LEFT )
818 nTextStyle |= DrawTextFlags::Left;
819 else if ( GetStyle() & WB_RIGHT )
820 nTextStyle |= DrawTextFlags::Right;
821 else
822 nTextStyle |= DrawTextFlags::Center;
823
824 if ( GetStyle() & WB_TOP )
825 nTextStyle |= DrawTextFlags::Top;
826 else if ( GetStyle() & WB_BOTTOM )
827 nTextStyle |= DrawTextFlags::Bottom;
828 else
829 nTextStyle |= DrawTextFlags::VCenter;
830
831 if ( !IsEnabled() )
832 nTextStyle |= DrawTextFlags::Disable;
833
834 return nTextStyle;
835}
836
838 const tools::Rectangle &rRect, bool bMenuBtnSep,
839 DrawButtonFlags nButtonFlags)
840{
841 const StyleSettings &rStyleSettings = GetSettings().GetStyleSettings();
842 tools::Rectangle aInRect = rRect;
843 Color aColor;
844 DrawTextFlags nTextStyle = ImplGetTextStyle(nSystemTextColorFlags);
845 DrawSymbolFlags nStyle;
846
847 if (aInRect.Right() < aInRect.Left() || aInRect.Bottom() < aInRect.Top())
848 return;
849
851 pDev->IntersectClipRegion(aInRect);
852
853 if (nSystemTextColorFlags & SystemTextColorFlags::Mono)
854 aColor = COL_BLACK;
855
856 else if (IsControlForeground())
857 aColor = GetControlForeground();
858
859 // Button types with possibly different text coloring are flat buttons and regular buttons. Regular buttons may be action
860 // buttons and may have an additional default status. Moreover all buttons may have an additional pressed and rollover
861 // (highlight) status. Pressed buttons are always in rollover status.
862
863 else if (GetStyle() & WB_FLATBUTTON)
864 if (nButtonFlags & DrawButtonFlags::Pressed)
865 aColor = rStyleSettings.GetFlatButtonPressedRolloverTextColor();
866 else if (nButtonFlags & DrawButtonFlags::Highlight)
867 aColor = rStyleSettings.GetFlatButtonRolloverTextColor();
868 else
869 aColor = rStyleSettings.GetFlatButtonTextColor();
870 else
871 if (isAction() && (nButtonFlags & DrawButtonFlags::Default))
872 if (nButtonFlags & DrawButtonFlags::Pressed)
873 aColor = rStyleSettings.GetDefaultActionButtonPressedRolloverTextColor();
874 else if (nButtonFlags & DrawButtonFlags::Highlight)
875 aColor = rStyleSettings.GetDefaultActionButtonRolloverTextColor();
876 else
877 aColor = rStyleSettings.GetDefaultActionButtonTextColor();
878 else if (isAction())
879 if (nButtonFlags & DrawButtonFlags::Pressed)
880 aColor = rStyleSettings.GetActionButtonPressedRolloverTextColor();
881 else if (nButtonFlags & DrawButtonFlags::Highlight)
882 aColor = rStyleSettings.GetActionButtonRolloverTextColor();
883 else
884 aColor = rStyleSettings.GetActionButtonTextColor();
885 else if (nButtonFlags & DrawButtonFlags::Default)
886 if (nButtonFlags & DrawButtonFlags::Pressed)
887 aColor = rStyleSettings.GetDefaultButtonPressedRolloverTextColor();
888 else if (nButtonFlags & DrawButtonFlags::Highlight)
889 aColor = rStyleSettings.GetDefaultButtonRolloverTextColor();
890 else
891 aColor = rStyleSettings.GetDefaultButtonTextColor();
892 else
893 if (nButtonFlags & DrawButtonFlags::Pressed)
894 aColor = rStyleSettings.GetButtonPressedRolloverTextColor();
895 else if (nButtonFlags & DrawButtonFlags::Highlight)
896 aColor = rStyleSettings.GetButtonRolloverTextColor();
897 else
898 aColor = rStyleSettings.GetButtonTextColor();
899
900#if defined(MACOSX) || defined(IOS)
901 // tdf#152486 These are the buttons in infobars where the infobar has a custom
902 // background color and on these platforms the buttons blend with
903 // their background.
904 vcl::Window* pParent = GetParent();
905 if (pParent->get_id() == "ExtraButton")
906 {
907 while (pParent && !pParent->IsControlBackground())
908 pParent = pParent->GetParent();
909 if (pParent)
910 {
911 if (aColor.IsBright() && !pParent->GetControlBackground().IsDark())
912 aColor = COL_BLACK;
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 OUString &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 Size aSize = GetSizePixel();
2535 Size aImageSize = pDev->LogicToPixel( Size( 300, 300 ), aResMapMode );
2536 Size aBrd1Size = pDev->LogicToPixel( Size( 20, 20 ), aResMapMode );
2537 Size aBrd2Size = pDev->LogicToPixel( Size( 60, 60 ), aResMapMode );
2538 vcl::Font aFont = GetDrawPixelFont( pDev );
2539 tools::Rectangle aStateRect;
2540 tools::Rectangle aMouseRect;
2541
2542 aImageSize.setWidth( CalcZoom( aImageSize.Width() ) );
2543 aImageSize.setHeight( CalcZoom( aImageSize.Height() ) );
2544 aBrd1Size.setWidth( CalcZoom( aBrd1Size.Width() ) );
2545 aBrd1Size.setHeight( CalcZoom( aBrd1Size.Height() ) );
2546 aBrd2Size.setWidth( CalcZoom( aBrd2Size.Width() ) );
2547 aBrd2Size.setHeight( CalcZoom( aBrd2Size.Height() ) );
2548
2549 if ( !aBrd1Size.Width() )
2550 aBrd1Size.setWidth( 1 );
2551 if ( !aBrd1Size.Height() )
2552 aBrd1Size.setHeight( 1 );
2553 if ( !aBrd2Size.Width() )
2554 aBrd2Size.setWidth( 1 );
2555 if ( !aBrd2Size.Height() )
2556 aBrd2Size.setHeight( 1 );
2557
2558 pDev->Push();
2559 pDev->SetMapMode();
2560 pDev->SetFont( aFont );
2561 if ( nFlags & SystemTextColorFlags::Mono )
2562 pDev->SetTextColor( COL_BLACK );
2563 else
2564 pDev->SetTextColor( GetTextColor() );
2565 pDev->SetTextFillColor();
2566
2567 ImplDraw( pDev, nFlags, rPos, aSize,
2568 aImageSize, aStateRect, aMouseRect );
2569
2570 Point aCenterPos = aStateRect.Center();
2571 tools::Long nRadX = aImageSize.Width()/2;
2572 tools::Long nRadY = aImageSize.Height()/2;
2573
2574 pDev->SetLineColor();
2575 pDev->SetFillColor( COL_BLACK );
2576 pDev->DrawPolygon( tools::Polygon( aCenterPos, nRadX, nRadY ) );
2577 nRadX -= aBrd1Size.Width();
2578 nRadY -= aBrd1Size.Height();
2579 pDev->SetFillColor( COL_WHITE );
2580 pDev->DrawPolygon( tools::Polygon( aCenterPos, nRadX, nRadY ) );
2581 if ( mbChecked )
2582 {
2583 nRadX -= aBrd1Size.Width();
2584 nRadY -= aBrd1Size.Height();
2585 if ( !nRadX )
2586 nRadX = 1;
2587 if ( !nRadY )
2588 nRadY = 1;
2589 pDev->SetFillColor( COL_BLACK );
2590 pDev->DrawPolygon( tools::Polygon( aCenterPos, nRadX, nRadY ) );
2591 }
2592
2593 pDev->Pop();
2594 }
2595 else
2596 {
2597 OSL_FAIL( "RadioButton::Draw() - not implemented for RadioButton with Image" );
2598 }
2599}
2600
2602{
2604 Invalidate();
2605}
2606
2608{
2612}
2613
2615{
2617 {
2619 Invalidate();
2620 }
2621
2622 HideFocus();
2624}
2625
2627{
2629
2631 {
2632 if ( IsReallyVisible() && IsUpdateMode() )
2634 }
2635 else if ( (nType == StateChangedType::Enable) ||
2639 {
2640 if ( IsUpdateMode() )
2641 Invalidate();
2642 }
2643 else if ( nType == StateChangedType::Style )
2644 {
2646
2649 {
2650 if ( IsUpdateMode() )
2651 Invalidate();
2652 }
2653 }
2654 else if ( (nType == StateChangedType::Zoom) ||
2656 {
2657 ImplInitSettings( false );
2658 Invalidate();
2659 }
2661 {
2662 ImplInitSettings( false );
2663 Invalidate();
2664 }
2666 {
2667 ImplInitSettings( true );
2668 Invalidate();
2669 }
2670}
2671
2673{
2674 Button::DataChanged( rDCEvt );
2675
2676 if ( (rDCEvt.GetType() == DataChangedEventType::FONTS) ||
2678 ((rDCEvt.GetType() == DataChangedEventType::SETTINGS) &&
2679 (rDCEvt.GetFlags() & AllSettingsFlags::STYLE)) )
2680 {
2681 ImplInitSettings( true );
2682 Invalidate();
2683 }
2684}
2685
2687{
2688 if( rNEvt.GetType() == NotifyEventType::MOUSEMOVE )
2689 {
2690 const MouseEvent* pMouseEvt = rNEvt.GetMouseEvent();
2691 if( pMouseEvt && !pMouseEvt->GetButtons() && !pMouseEvt->IsSynthetic() && !pMouseEvt->IsModifierChanged() )
2692 {
2693 // trigger redraw if mouse over state has changed
2695 {
2697 pMouseEvt->IsLeaveWindow() || pMouseEvt->IsEnterWindow())
2698 {
2700 }
2701 }
2702 }
2703 }
2704
2705 return Button::PreNotify(rNEvt);
2706}
2707
2709{
2711}
2712
2714{
2715 if ( rImage != maImage )
2716 {
2717 maImage = rImage;
2719 queue_resize();
2720 }
2721}
2722
2723
2724void RadioButton::SetState( bool bCheck )
2725{
2726 // carry the TabStop flag along correctly
2727 if ( bCheck )
2728 mpWindowImpl->mnStyle |= WB_TABSTOP;
2729 else
2730 mpWindowImpl->mnStyle &= ~WB_TABSTOP;
2731
2732 if ( mbChecked != bCheck )
2733 {
2734 mbChecked = bCheck;
2736 Toggle();
2737 }
2738}
2739
2740bool RadioButton::set_property(const OUString &rKey, const OUString &rValue)
2741{
2742 if (rKey == "active")
2743 SetState(toBool(rValue));
2744 else if (rKey == "image-position")
2745 {
2746 WinBits nBits = GetStyle();
2747 if (rValue == "left")
2748 {
2749 nBits &= ~(WB_CENTER | WB_RIGHT);
2750 nBits |= WB_LEFT;
2751 }
2752 else if (rValue == "right")
2753 {
2754 nBits &= ~(WB_CENTER | WB_LEFT);
2755 nBits |= WB_RIGHT;
2756 }
2757 else if (rValue == "top")
2758 {
2759 nBits &= ~(WB_VCENTER | WB_BOTTOM);
2760 nBits |= WB_TOP;
2761 }
2762 else if (rValue == "bottom")
2763 {
2764 nBits &= ~(WB_VCENTER | WB_TOP);
2765 nBits |= WB_BOTTOM;
2766 }
2767 //It's rather mad to have to set these bits when there is the other
2768 //image align. Looks like e.g. the radiobuttons etc weren't converted
2769 //over to image align fully.
2770 SetStyle(nBits);
2771 //Deliberate to set the sane ImageAlign property
2772 return Button::set_property(rKey, rValue);
2773 }
2774 else
2775 return Button::set_property(rKey, rValue);
2776 return true;
2777}
2778
2779void RadioButton::Check( bool bCheck )
2780{
2781 // TabStop-Flag richtig mitfuehren
2782 if ( bCheck )
2783 mpWindowImpl->mnStyle |= WB_TABSTOP;
2784 else
2785 mpWindowImpl->mnStyle &= ~WB_TABSTOP;
2786
2787 if ( mbChecked == bCheck )
2788 return;
2789
2790 mbChecked = bCheck;
2791 VclPtr<vcl::Window> xWindow = this;
2793 if ( xWindow->isDisposed() )
2794 return;
2795 if ( bCheck && mbRadioCheck )
2797 if ( xWindow->isDisposed() )
2798 return;
2799 Toggle();
2800}
2801
2803{
2804 // 4 pixels, but take zoom into account, so the text doesn't "jump" relative to surrounding elements,
2805 // which might have been aligned with the text of the check box
2806 return CalcZoom( 4 );
2807}
2808
2810{
2811 Size aSize;
2812 bool bDefaultSize = true;
2814 {
2815 ImplControlValue aControlValue;
2816 tools::Rectangle aCtrlRegion( Point( 0, 0 ), GetSizePixel() );
2817 tools::Rectangle aBoundingRgn, aContentRgn;
2818
2819 // get native size of a radio button
2822 aControlValue,
2823 aBoundingRgn, aContentRgn ) )
2824 {
2825 aSize = aContentRgn.GetSize();
2826 bDefaultSize = false;
2827 }
2828 }
2829 if( bDefaultSize )
2831 return aSize;
2832}
2833
2834static void LoadThemedImageList(const StyleSettings &rStyleSettings,
2835 std::vector<Image>& rList, const std::vector<OUString> &rResources)
2836{
2837 Color aColorAry1[6];
2838 Color aColorAry2[6];
2839 aColorAry1[0] = Color( 0xC0, 0xC0, 0xC0 );
2840 aColorAry1[1] = Color( 0xFF, 0xFF, 0x00 );
2841 aColorAry1[2] = Color( 0xFF, 0xFF, 0xFF );
2842 aColorAry1[3] = Color( 0x80, 0x80, 0x80 );
2843 aColorAry1[4] = Color( 0x00, 0x00, 0x00 );
2844 aColorAry1[5] = Color( 0x00, 0xFF, 0x00 );
2845 aColorAry2[0] = rStyleSettings.GetFaceColor();
2846 aColorAry2[1] = rStyleSettings.GetWindowColor();
2847 aColorAry2[2] = rStyleSettings.GetLightColor();
2848 aColorAry2[3] = rStyleSettings.GetShadowColor();
2849 aColorAry2[4] = rStyleSettings.GetDarkShadowColor();
2850 aColorAry2[5] = rStyleSettings.GetWindowTextColor();
2851
2852 static_assert( sizeof(aColorAry1) == sizeof(aColorAry2), "aColorAry1 must match aColorAry2" );
2853
2854 for (const auto &a : rResources)
2855 {
2856 BitmapEx aBmpEx(a);
2857 aBmpEx.Replace(aColorAry1, aColorAry2, SAL_N_ELEMENTS(aColorAry1));
2858 rList.emplace_back(aBmpEx);
2859 }
2860}
2861
2863{
2864 ImplSVData* pSVData = ImplGetSVData();
2865 const StyleSettings& rStyleSettings = rSettings.GetStyleSettings();
2866 sal_uInt16 nStyle = 0;
2867
2868 if ( rStyleSettings.GetOptions() & StyleSettingsOptions::Mono )
2869 nStyle = STYLE_RADIOBUTTON_MONO;
2870
2871 if ( pSVData->maCtrlData.maRadioImgList.empty() ||
2872 (pSVData->maCtrlData.mnRadioStyle != nStyle) ||
2873 (pSVData->maCtrlData.mnLastRadioFColor != rStyleSettings.GetFaceColor()) ||
2874 (pSVData->maCtrlData.mnLastRadioWColor != rStyleSettings.GetWindowColor()) ||
2875 (pSVData->maCtrlData.mnLastRadioLColor != rStyleSettings.GetLightColor()) )
2876 {
2877 pSVData->maCtrlData.maRadioImgList.clear();
2878
2879 pSVData->maCtrlData.mnLastRadioFColor = rStyleSettings.GetFaceColor();
2880 pSVData->maCtrlData.mnLastRadioWColor = rStyleSettings.GetWindowColor();
2881 pSVData->maCtrlData.mnLastRadioLColor = rStyleSettings.GetLightColor();
2882
2883 std::vector<OUString> aResources;
2884 if (nStyle)
2885 {
2886 aResources.emplace_back(SV_RESID_BITMAP_RADIOMONO1);
2887 aResources.emplace_back(SV_RESID_BITMAP_RADIOMONO2);
2888 aResources.emplace_back(SV_RESID_BITMAP_RADIOMONO3);
2889 aResources.emplace_back(SV_RESID_BITMAP_RADIOMONO4);
2890 aResources.emplace_back(SV_RESID_BITMAP_RADIOMONO5);
2891 aResources.emplace_back(SV_RESID_BITMAP_RADIOMONO6);
2892 }
2893 else
2894 {
2895 aResources.emplace_back(SV_RESID_BITMAP_RADIO1);
2896 aResources.emplace_back(SV_RESID_BITMAP_RADIO2);
2897 aResources.emplace_back(SV_RESID_BITMAP_RADIO3);
2898 aResources.emplace_back(SV_RESID_BITMAP_RADIO4);
2899 aResources.emplace_back(SV_RESID_BITMAP_RADIO5);
2900 aResources.emplace_back(SV_RESID_BITMAP_RADIO6);
2901 }
2902 LoadThemedImageList( rStyleSettings, pSVData->maCtrlData.maRadioImgList, aResources);
2903 pSVData->maCtrlData.mnRadioStyle = nStyle;
2904 }
2905
2906 sal_uInt16 nIndex;
2907 if ( nFlags & DrawButtonFlags::Disabled )
2908 {
2909 if ( nFlags & DrawButtonFlags::Checked )
2910 nIndex = 5;
2911 else
2912 nIndex = 4;
2913 }
2914 else if ( nFlags & DrawButtonFlags::Pressed )
2915 {
2916 if ( nFlags & DrawButtonFlags::Checked )
2917 nIndex = 3;
2918 else
2919 nIndex = 2;
2920 }
2921 else
2922 {
2923 if ( nFlags & DrawButtonFlags::Checked )
2924 nIndex = 1;
2925 else
2926 nIndex = 0;
2927 }
2928 return pSVData->maCtrlData.maRadioImgList[nIndex];
2929}
2930
2932{
2934 SetMapMode(MapMode(MapUnit::MapPixel));
2935
2936 ImplControlValue aControlValue;
2937 Size aCurSize( GetSizePixel() );
2938 tools::Rectangle aCtrlRegion( Point( 0, 0 ), aCurSize );
2939 tools::Rectangle aBoundingRgn, aContentRgn;
2940
2941 // get native size of a radiobutton
2944 aBoundingRgn, aContentRgn ) )
2945 {
2946 Size aSize = aContentRgn.GetSize();
2947
2948 if( aSize.Height() > aCurSize.Height() )
2949 {
2950 aCurSize.setHeight( aSize.Height() );
2951 SetSizePixel( aCurSize );
2952 }
2953 }
2954
2955 GetOutDev()->Pop();
2956}
2957
2959{
2960 Size aSize;
2961 if ( !maImage )
2962 aSize = ImplGetRadioImageSize();
2963 else
2964 {
2965 aSize = maImage.GetSizePixel();
2966 aSize.AdjustWidth(8);
2967 aSize.AdjustHeight(8);
2968 }
2969
2970 if (Button::HasImage())
2971 {
2972 Size aImgSize = GetModeImage().GetSizePixel();
2973 aSize = Size(std::max(aImgSize.Width(), aSize.Width()),
2974 std::max(aImgSize.Height(), aSize.Height()));
2975 }
2976
2977 OUString aText = GetText();
2978 if (!aText.isEmpty())
2979 {
2980 bool bTopImage = (GetStyle() & WB_TOP) != 0;
2981
2982 Size aTextSize = GetTextRect( tools::Rectangle( Point(), Size( nMaxWidth > 0 ? nMaxWidth : 0x7fffffff, 0x7fffffff ) ),
2984
2985 aSize.AdjustWidth(2 ); // for focus rect
2986
2987 if (!bTopImage)
2988 {
2990 aSize.AdjustWidth(aTextSize.Width() );
2991 if ( aSize.Height() < aTextSize.Height() )
2992 aSize.setHeight( aTextSize.Height() );
2993 }
2994 else
2995 {
2996 aSize.AdjustHeight(6 );
2997 aSize.AdjustHeight(GetTextHeight() );
2998 if ( aSize.Width() < aTextSize.Width() )
2999 aSize.setWidth( aTextSize.Width() );
3000 }
3001 }
3002
3003 return CalcWindowSize( aSize );
3004}
3005
3007{
3008 return CalcMinimumSize();
3009}
3010
3012{
3014 {
3015 ImplControlValue aControlValue;
3016 tools::Rectangle aInRect(Point(0, 0), GetSizePixel());
3017
3018 aInRect.SetLeft( rRect.Left() ); // exclude the radio element itself from the focusrect
3019
3021 ControlState::FOCUSED, aControlValue, OUString());
3022 }
3023 Button::ShowFocus(rRect);
3024}
3025
3027{
3028 Button::DumpAsPropertyTree(rJsonWriter);
3029 rJsonWriter.put("checked", IsChecked());
3030
3031 OUString sGroupId;
3032 std::vector<VclPtr<RadioButton>> aGroup = GetRadioButtonGroup();
3033 for(const auto& pButton : aGroup)
3034 sGroupId += pButton->get_id();
3035
3036 if (!sGroupId.isEmpty())
3037 rJsonWriter.put("group", sGroupId);
3038
3039 if (!!maImage)
3040 {
3041 SvMemoryStream aOStm(6535, 6535);
3043 {
3044 css::uno::Sequence<sal_Int8> aSeq( static_cast<sal_Int8 const *>(aOStm.GetData()), aOStm.Tell());
3045 OStringBuffer aBuffer("data:image/png;base64,");
3047 rJsonWriter.put("image", aBuffer);
3048 }
3049 }
3050}
3051
3053{
3055}
3056
3058{
3060 mbTriState = false;
3061}
3062
3064{
3065 nStyle = ImplInitStyle(getPreviousSibling(pParent), nStyle);
3066 Button::ImplInit( pParent, nStyle, nullptr );
3067
3068 ImplInitSettings( true );
3069}
3070
3072{
3073 if ( !(nStyle & WB_NOTABSTOP) )
3074 nStyle |= WB_TABSTOP;
3075 if ( !(nStyle & WB_NOGROUP) &&
3076 (!pPrevWindow || (pPrevWindow->GetType() != WindowType::CHECKBOX)) )
3077 nStyle |= WB_GROUP;
3078 return nStyle;
3079}
3080
3082{
3083 return _rStyle.GetRadioCheckFont();
3084}
3085
3087{
3088 return _rStyle.GetRadioCheckTextColor();
3089}
3090
3091void CheckBox::ImplInitSettings( bool bBackground )
3092{
3094
3095 if ( !bBackground )
3096 return;
3097
3098 vcl::Window* pParent = GetParent();
3099 if ( !IsControlBackground() &&
3101 {
3104 SetPaintTransparent( true );
3105 SetBackground();
3108 }
3109 else
3110 {
3113 SetPaintTransparent( false );
3114
3115 if ( IsControlBackground() )
3117 else
3118 SetBackground( pParent->GetBackground() );
3119 }
3120}
3121
3123{
3124 bool bNativeOK = rRenderContext.IsNativeControlSupported(ControlType::Checkbox, ControlPart::Entire);
3125 if (bNativeOK)
3126 {
3128 tools::Rectangle aCtrlRegion(maStateRect);
3130
3131 if (HasFocus())
3137 if (IsEnabled())
3139
3140 if (meState == TRISTATE_TRUE)
3141 aControlValue.setTristateVal(ButtonValue::On);
3142 else if (meState == TRISTATE_INDET)
3143 aControlValue.setTristateVal(ButtonValue::Mixed);
3144
3147
3148 bNativeOK = rRenderContext.DrawNativeControl(ControlType::Checkbox, ControlPart::Entire, aCtrlRegion,
3149 nState, aControlValue, OUString());
3150 }
3151
3152 if (bNativeOK)
3153 return;
3154
3156 if (!IsEnabled())
3157 nStyle |= DrawButtonFlags::Disabled;
3158 if (meState == TRISTATE_INDET)
3159 nStyle |= DrawButtonFlags::DontKnow;
3160 else if (meState == TRISTATE_TRUE)
3161 nStyle |= DrawButtonFlags::Checked;
3162 Image aImage = GetCheckImage(GetSettings(), nStyle);
3163 if (IsZoom())
3164 rRenderContext.DrawImage(maStateRect.TopLeft(), maStateRect.GetSize(), aImage);
3165 else
3166 rRenderContext.DrawImage(maStateRect.TopLeft(), aImage);
3167}
3168
3169void CheckBox::ImplDraw( OutputDevice* pDev, SystemTextColorFlags nSystemTextColorFlags,
3170 const Point& rPos, const Size& rSize,
3171 const Size& rImageSize, tools::Rectangle& rStateRect,
3172 tools::Rectangle& rMouseRect )
3173{
3174 WinBits nWinStyle = GetStyle();
3175 OUString aText( GetText() );
3176
3178 pDev->IntersectClipRegion( tools::Rectangle( rPos, rSize ) );
3179
3180 if (!aText.isEmpty() || HasImage())
3181 {
3182 Button::ImplDrawRadioCheck(pDev, nWinStyle, nSystemTextColorFlags,
3183 rPos, rSize, rImageSize,
3184 rStateRect, rMouseRect);
3185 }
3186 else
3187 {
3188 rStateRect.SetLeft( rPos.X() );
3189 if ( nWinStyle & WB_VCENTER )
3190 rStateRect.SetTop( rPos.Y()+((rSize.Height()-rImageSize.Height())/2) );
3191 else if ( nWinStyle & WB_BOTTOM )
3192 rStateRect.SetTop( rPos.Y()+rSize.Height()-rImageSize.Height() );
3193 else
3194 rStateRect.SetTop( rPos.Y() );
3195 rStateRect.SetRight( rStateRect.Left()+rImageSize.Width()-1 );
3196 rStateRect.SetBottom( rStateRect.Top()+rImageSize.Height()-1 );
3197 // provide space for focusrect
3198 // note: this assumes that the control's size was adjusted
3199 // accordingly in Get/LoseFocus, so the onscreen position won't change
3200 if( HasFocus() )
3201 rStateRect.Move( 1, 1 );
3202 rMouseRect = rStateRect;
3203
3204 ImplSetFocusRect( rStateRect );
3205 }
3206
3207 pDev->Pop();
3208}
3209
3211{
3212 Size aImageSize = ImplGetCheckImageSize();
3213 aImageSize.setWidth( CalcZoom( aImageSize.Width() ) );
3214 aImageSize.setHeight( CalcZoom( aImageSize.Height() ) );
3215
3216 HideFocus();
3217
3219 aImageSize, maStateRect, maMouseRect);
3220
3221 ImplDrawCheckBoxState(rRenderContext);
3222 if (HasFocus())
3224}
3225
3227{
3228 TriState eNewState;
3229 if ( meState == TRISTATE_FALSE )
3230 eNewState = TRISTATE_TRUE;
3231 else if ( !mbTriState )
3232 eNewState = TRISTATE_FALSE;
3233 else if ( meState == TRISTATE_TRUE )
3234 eNewState = TRISTATE_INDET;
3235 else
3236 eNewState = TRISTATE_FALSE;
3237 meState = eNewState;
3238
3239 VclPtr<vcl::Window> xWindow = this;
3240 Invalidate();
3241 Toggle();
3242 if ( xWindow->isDisposed() )
3243 return;
3244 Click();
3245}
3246
3249{
3251 ImplInit( pParent, nStyle );
3252}
3253
3255{
3256 if ( rMEvt.IsLeft() && maMouseRect.Contains( rMEvt.GetPosPixel() ) )
3257 {
3259 Invalidate();
3260 StartTracking();
3261 return;
3262 }
3263
3264 Button::MouseButtonDown( rMEvt );
3265}
3266
3268{
3269 if ( rTEvt.IsTrackingEnded() )
3270 {
3272 {
3273 if ( !(GetStyle() & WB_NOPOINTERFOCUS) && !rTEvt.IsTrackingCanceled() )
3274 GrabFocus();
3275
3277
3278 // do not call click handler if aborted
3279 if ( !rTEvt.IsTrackingCanceled() )
3280 ImplCheck();
3281 else
3282 {
3283 Invalidate();
3284 }
3285 }
3286 }
3287 else
3288 {
3289 if ( maMouseRect.Contains( rTEvt.GetMouseEvent().GetPosPixel() ) )
3290 {
3292 {
3294 Invalidate();
3295 }
3296 }
3297 else
3298 {
3300 {
3302 Invalidate();
3303 }
3304 }
3305 }
3306}
3307
3308void CheckBox::KeyInput( const KeyEvent& rKEvt )
3309{
3310 vcl::KeyCode aKeyCode = rKEvt.GetKeyCode();
3311
3312 if ( !aKeyCode.GetModifier() && (aKeyCode.GetCode() == KEY_SPACE) )
3313 {
3315 {
3317 Invalidate();
3318 }
3319 }
3320 else if ( (GetButtonState() & DrawButtonFlags::Pressed) && (aKeyCode.GetCode() == KEY_ESCAPE) )
3321 {
3323 Invalidate();
3324 }
3325 else
3326 Button::KeyInput( rKEvt );
3327}
3328
3329void CheckBox::KeyUp( const KeyEvent& rKEvt )
3330{
3331 vcl::KeyCode aKeyCode = rKEvt.GetKeyCode();
3332
3333 if ( (GetButtonState() & DrawButtonFlags::Pressed) && (aKeyCode.GetCode() == KEY_SPACE) )
3334 {
3336 ImplCheck();
3337 }
3338 else
3339 Button::KeyUp( rKEvt );
3340}
3341
3343{
3344 mxLayoutData.emplace();
3345 const_cast<CheckBox*>(this)->Invalidate();
3346}
3347
3349{
3350 ImplDrawCheckBox(rRenderContext);
3351}
3352
3353void CheckBox::Draw( OutputDevice* pDev, const Point& rPos,
3354 SystemTextColorFlags nFlags )
3355{
3356 MapMode aResMapMode( MapUnit::Map100thMM );
3357 Size aSize = GetSizePixel();
3358 Size aImageSize = pDev->LogicToPixel( Size( 300, 300 ), aResMapMode );
3359 Size aBrd1Size = pDev->LogicToPixel( Size( 20, 20 ), aResMapMode );
3360 Size aBrd2Size = pDev->LogicToPixel( Size( 30, 30 ), aResMapMode );
3361 tools::Long nCheckWidth = pDev->LogicToPixel( Size( 20, 20 ), aResMapMode ).Width();
3362 vcl::Font aFont = GetDrawPixelFont( pDev );
3363 tools::Rectangle aStateRect;
3364 tools::Rectangle aMouseRect;
3365
3366 aImageSize.setWidth( CalcZoom( aImageSize.Width() ) );
3367 aImageSize.setHeight( CalcZoom( aImageSize.Height() ) );
3368 aBrd1Size.setWidth( CalcZoom( aBrd1Size.Width() ) );
3369 aBrd1Size.setHeight( CalcZoom( aBrd1Size.Height() ) );
3370 aBrd2Size.setWidth( CalcZoom( aBrd2Size.Width() ) );
3371 aBrd2Size.setHeight( CalcZoom( aBrd2Size.Height() ) );
3372
3373 if ( !aBrd1Size.Width() )
3374 aBrd1Size.setWidth( 1 );
3375 if ( !aBrd1Size.Height() )
3376 aBrd1Size.setHeight( 1 );
3377 if ( !aBrd2Size.Width() )
3378 aBrd2Size.setWidth( 1 );
3379 if ( !aBrd2Size.Height() )
3380 aBrd2Size.setHeight( 1 );
3381 if ( !nCheckWidth )
3382 nCheckWidth = 1;
3383
3384 pDev->Push();
3385 pDev->SetMapMode();
3386 pDev->SetFont( aFont );
3387 if ( nFlags & SystemTextColorFlags::Mono )
3388 pDev->SetTextColor( COL_BLACK );
3389 else
3390 pDev->SetTextColor( GetTextColor() );
3391 pDev->SetTextFillColor();
3392
3393 ImplDraw( pDev, nFlags, rPos, aSize,
3394 aImageSize, aStateRect, aMouseRect );
3395
3396 pDev->SetLineColor();
3397 pDev->SetFillColor( COL_BLACK );
3398 pDev->DrawRect( aStateRect );
3399 aStateRect.AdjustLeft(aBrd1Size.Width() );
3400 aStateRect.AdjustTop(aBrd1Size.Height() );
3401 aStateRect.AdjustRight( -(aBrd1Size.Width()) );
3402 aStateRect.AdjustBottom( -(aBrd1Size.Height()) );
3403 if ( meState == TRISTATE_INDET )
3404 pDev->SetFillColor( COL_LIGHTGRAY );
3405 else
3406 pDev->SetFillColor( COL_WHITE );
3407 pDev->DrawRect( aStateRect );
3408
3409 if ( meState == TRISTATE_TRUE )
3410 {
3411 aStateRect.AdjustLeft(aBrd2Size.Width() );
3412 aStateRect.AdjustTop(aBrd2Size.Height() );
3413 aStateRect.AdjustRight( -(aBrd2Size.Width()) );
3414 aStateRect.AdjustBottom( -(aBrd2Size.Height()) );
3415 Point aPos11( aStateRect.TopLeft() );
3416 Point aPos12( aStateRect.BottomRight() );
3417 Point aPos21( aStateRect.TopRight() );
3418 Point aPos22( aStateRect.BottomLeft() );
3419 Point aTempPos11( aPos11 );
3420 Point aTempPos12( aPos12 );
3421 Point aTempPos21( aPos21 );
3422 Point aTempPos22( aPos22 );
3423 pDev->SetLineColor( COL_BLACK );
3424 tools::Long nDX = 0;
3425 for ( tools::Long i = 0; i < nCheckWidth; i++ )
3426 {
3427 if ( !(i % 2) )
3428 {
3429 aTempPos11.setX( aPos11.X()+nDX );
3430 aTempPos12.setX( aPos12.X()+nDX );
3431 aTempPos21.setX( aPos21.X()+nDX );
3432 aTempPos22.setX( aPos22.X()+nDX );
3433 }
3434 else
3435 {
3436 nDX++;
3437 aTempPos11.setX( aPos11.X()-nDX );
3438 aTempPos12.setX( aPos12.X()-nDX );
3439 aTempPos21.setX( aPos21.X()-nDX );
3440 aTempPos22.setX( aPos22.X()-nDX );
3441 }
3442 pDev->DrawLine( aTempPos11, aTempPos12 );
3443 pDev->DrawLine( aTempPos21, aTempPos22 );
3444 }
3445 }
3446
3447 pDev->Pop();
3448}
3449
3451{
3453 Invalidate();
3454}
3455
3457{
3458 if (GetText().isEmpty())
3459 {
3460 // increase button size to have space for focus rect
3461 // checkboxes without text will draw focusrect around the check
3462 // See CheckBox::ImplDraw()
3463 Point aPos( GetPosPixel() );
3464 Size aSize( GetSizePixel() );
3465 aPos.Move(-1,-1);
3466 aSize.AdjustHeight(2 );
3467 aSize.AdjustWidth(2 );
3468 setPosSizePixel( aPos.X(), aPos.Y(), aSize.Width(), aSize.Height() );
3469 Invalidate();
3470 // Trigger drawing to initialize the mouse rectangle, otherwise the mouse button down
3471 // handler would ignore the mouse event.
3473 }
3474 else
3476
3479}
3480
3482{
3484 {
3486 Invalidate();
3487 }
3488
3489 HideFocus();
3491
3492 if (GetText().isEmpty())
3493 {
3494 // decrease button size again (see GetFocus())
3495 // checkboxes without text will draw focusrect around the check
3496 Point aPos( GetPosPixel() );
3497 Size aSize( GetSizePixel() );
3498 aPos.Move(1,1);
3499 aSize.AdjustHeight( -2 );
3500 aSize.AdjustWidth( -2 );
3501 setPosSizePixel( aPos.X(), aPos.Y(), aSize.Width(), aSize.Height() );
3502 Invalidate();
3503 }
3504}
3505
3507{
3509
3511 {
3512 if ( IsReallyVisible() && IsUpdateMode() )
3514 }
3515 else if ( (nType == StateChangedType::Enable) ||
3519 {
3520 if ( IsUpdateMode() )
3521 Invalidate();
3522 }
3523 else if ( nType == StateChangedType::Style )
3524 {
3526
3527 if ( (GetPrevStyle() & CHECKBOX_VIEW_STYLE) !=
3529 {
3530 if ( IsUpdateMode() )
3531 Invalidate();
3532 }
3533 }
3534 else if ( (nType == StateChangedType::Zoom) ||
3536 {
3537 ImplInitSettings( false );
3538 Invalidate();
3539 }
3541 {
3542 ImplInitSettings( false );
3543 Invalidate();
3544 }
3546 {
3547 ImplInitSettings( true );
3548 Invalidate();
3549 }
3550}
3551
3553{
3554 Button::DataChanged( rDCEvt );
3555
3556 if ( (rDCEvt.GetType() == DataChangedEventType::FONTS) ||
3558 ((rDCEvt.GetType() == DataChangedEventType::SETTINGS) &&
3559 (rDCEvt.GetFlags() & AllSettingsFlags::STYLE)) )
3560 {
3561 ImplInitSettings( true );
3562 Invalidate();
3563 }
3564}
3565
3567{
3568 if( rNEvt.GetType() == NotifyEventType::MOUSEMOVE )
3569 {
3570 const MouseEvent* pMouseEvt = rNEvt.GetMouseEvent();
3571 if( pMouseEvt && !pMouseEvt->GetButtons() && !pMouseEvt->IsSynthetic() && !pMouseEvt->IsModifierChanged() )
3572 {
3573 // trigger redraw if mouse over state has changed
3575 {
3577 pMouseEvt->IsLeaveWindow() || pMouseEvt->IsEnterWindow())
3578 {
3580 }
3581 }
3582 }
3583 }
3584
3585 return Button::PreNotify(rNEvt);
3586}
3587
3589{
3591}
3592
3594{
3595 if ( !mbTriState && (eState == TRISTATE_INDET) )
3596 eState = TRISTATE_FALSE;
3597
3598 if ( meState != eState )
3599 {
3600 meState = eState;
3602 Toggle();
3603 }
3604}
3605
3606bool CheckBox::set_property(const OUString &rKey, const OUString &rValue)
3607{
3608 if (rKey == "active")
3610 else
3611 return Button::set_property(rKey, rValue);
3612 return true;
3613}
3614
3615void CheckBox::EnableTriState( bool bTriState )
3616{
3617 if ( mbTriState != bTriState )
3618 {
3619 mbTriState = bTriState;
3620
3621 if ( !bTriState && (meState == TRISTATE_INDET) )
3623 }
3624}
3625
3627{
3628 Size aSize;
3629 bool bDefaultSize = true;
3631 {
3632 ImplControlValue aControlValue;
3633 tools::Rectangle aCtrlRegion( Point( 0, 0 ), GetSizePixel() );
3634 tools::Rectangle aBoundingRgn, aContentRgn;
3635
3636 // get native size of a check box
3639 aControlValue,
3640 aBoundingRgn, aContentRgn ) )
3641 {
3642 aSize = aContentRgn.GetSize();
3643 bDefaultSize = false;
3644 }
3645 }
3646 if( bDefaultSize )
3648 return aSize;
3649}
3650
3652{
3653 ImplSVData* pSVData = ImplGetSVData();
3654 const StyleSettings& rStyleSettings = rSettings.GetStyleSettings();
3655 sal_uInt16 nStyle = 0;
3656
3657 if ( rStyleSettings.GetOptions() & StyleSettingsOptions::Mono )
3658 nStyle = STYLE_CHECKBOX_MONO;
3659
3660 if ( pSVData->maCtrlData.maCheckImgList.empty() ||
3661 (pSVData->maCtrlData.mnCheckStyle != nStyle) ||
3662 (pSVData->maCtrlData.mnLastCheckFColor != rStyleSettings.GetFaceColor()) ||
3663 (pSVData->maCtrlData.mnLastCheckWColor != rStyleSettings.GetWindowColor()) ||
3664 (pSVData->maCtrlData.mnLastCheckLColor != rStyleSettings.GetLightColor()) )
3665 {
3666 pSVData->maCtrlData.maCheckImgList.clear();
3667
3668 pSVData->maCtrlData.mnLastCheckFColor = rStyleSettings.GetFaceColor();
3669 pSVData->maCtrlData.mnLastCheckWColor = rStyleSettings.GetWindowColor();
3670 pSVData->maCtrlData.mnLastCheckLColor = rStyleSettings.GetLightColor();
3671
3672 std::vector<OUString> aResources;
3673 if (nStyle)
3674 {
3675 aResources.emplace_back(SV_RESID_BITMAP_CHECKMONO1);
3676 aResources.emplace_back(SV_RESID_BITMAP_CHECKMONO2);
3677 aResources.emplace_back(SV_RESID_BITMAP_CHECKMONO3);
3678 aResources.emplace_back(SV_RESID_BITMAP_CHECKMONO4);
3679 aResources.emplace_back(SV_RESID_BITMAP_CHECKMONO5);
3680 aResources.emplace_back(SV_RESID_BITMAP_CHECKMONO6);
3681 aResources.emplace_back(SV_RESID_BITMAP_CHECKMONO7);
3682 aResources.emplace_back(SV_RESID_BITMAP_CHECKMONO8);
3683 aResources.emplace_back(SV_RESID_BITMAP_CHECKMONO9);
3684 }
3685 else
3686 {
3687 aResources.emplace_back(SV_RESID_BITMAP_CHECK1);
3688 aResources.emplace_back(SV_RESID_BITMAP_CHECK2);
3689 aResources.emplace_back(SV_RESID_BITMAP_CHECK3);
3690 aResources.emplace_back(SV_RESID_BITMAP_CHECK4);
3691 aResources.emplace_back(SV_RESID_BITMAP_CHECK5);
3692 aResources.emplace_back(SV_RESID_BITMAP_CHECK6);
3693 aResources.emplace_back(SV_RESID_BITMAP_CHECK7);
3694 aResources.emplace_back(SV_RESID_BITMAP_CHECK8);
3695 aResources.emplace_back(SV_RESID_BITMAP_CHECK9);
3696 }
3697 LoadThemedImageList(rStyleSettings, pSVData->maCtrlData.maCheckImgList, aResources);
3698 pSVData->maCtrlData.mnCheckStyle = nStyle;
3699 }
3700
3701 sal_uInt16 nIndex;
3702 if ( nFlags & DrawButtonFlags::Disabled )
3703 {
3704 if ( nFlags & DrawButtonFlags::DontKnow )
3705 nIndex = 8;
3706 else if ( nFlags & DrawButtonFlags::Checked )
3707 nIndex = 5;
3708 else
3709 nIndex = 4;
3710 }
3711 else if ( nFlags & DrawButtonFlags::Pressed )
3712 {
3713 if ( nFlags & DrawButtonFlags::DontKnow )
3714 nIndex = 7;
3715 else if ( nFlags & DrawButtonFlags::Checked )
3716 nIndex = 3;
3717 else
3718 nIndex = 2;
3719 }
3720 else
3721 {
3722 if ( nFlags & DrawButtonFlags::DontKnow )
3723 nIndex = 6;
3724 else if ( nFlags & DrawButtonFlags::Checked )
3725 nIndex = 1;
3726 else
3727 nIndex = 0;
3728 }
3729 return pSVData->maCtrlData.maCheckImgList[nIndex];
3730}
3731
3733{
3735 SetMapMode(MapMode(MapUnit::MapPixel));
3736
3737 ImplControlValue aControlValue;
3738 Size aCurSize( GetSizePixel() );
3739 tools::Rectangle aCtrlRegion( Point( 0, 0 ), aCurSize );
3740 tools::Rectangle aBoundingRgn, aContentRgn;
3741
3742 // get native size of a radiobutton
3745 aBoundingRgn, aContentRgn ) )
3746 {
3747 Size aSize = aContentRgn.GetSize();
3748
3749 if( aSize.Height() > aCurSize.Height() )
3750 {
3751 aCurSize.setHeight( aSize.Height() );
3752 SetSizePixel( aCurSize );
3753 }
3754 }
3755
3756 GetOutDev()->Pop();
3757}
3758
3760{
3761 Size aSize = ImplGetCheckImageSize();
3762 nMaxWidth -= aSize.Width();
3763
3764 OUString aText = GetText();
3765 if (!aText.isEmpty())
3766 {
3767 // subtract what will be added later
3768 nMaxWidth-=2;
3769 nMaxWidth -= ImplGetImageToTextDistance();
3770
3771 Size aTextSize = GetTextRect( tools::Rectangle( Point(), Size( nMaxWidth > 0 ? nMaxWidth : 0x7fffffff, 0x7fffffff ) ),
3773 aSize.AdjustWidth(2 ); // for focus rect
3775 aSize.AdjustWidth(aTextSize.Width() );
3776 if ( aSize.Height() < aTextSize.Height() )
3777 aSize.setHeight( aTextSize.Height() );
3778 }
3779 else
3780 {
3781 // is this still correct ? since the checkbox now
3782 // shows a focus rect it should be 2 pixels wider and longer
3783/* since otherwise the controls in the Writer hang too far up
3784 aSize.Width() += 2;
3785 aSize.Height() += 2;
3786*/
3787 }
3788
3789 return CalcWindowSize( aSize );
3790}
3791
3793{
3794 int nWidthRequest(get_width_request());
3795 return CalcMinimumSize(nWidthRequest != -1 ? nWidthRequest : 0);
3796}
3797
3799{
3801 {
3802 ImplControlValue aControlValue;
3803 tools::Rectangle aInRect(Point(0, 0), GetSizePixel());
3804
3805 aInRect.SetLeft( rRect.Left() ); // exclude the checkbox itself from the focusrect
3806
3808 ControlState::FOCUSED, aControlValue, OUString());
3809 }
3810 Button::ShowFocus(rRect);
3811}
3812
3814{
3815 Button::DumpAsPropertyTree(rJsonWriter);
3816 rJsonWriter.put("checked", IsChecked());
3817}
3818
3820{
3822}
3823
3825 PushButton( pParent, nStyle )
3826{
3827 ImplInitStyle();
3828}
3829
3831{
3832 WinBits nStyle = GetStyle();
3833
3834 if ( ! ( nStyle & ( WB_RIGHT | WB_LEFT ) ) )
3835 nStyle |= WB_CENTER;
3836
3837 if ( ! ( nStyle & ( WB_TOP | WB_BOTTOM ) ) )
3838 nStyle |= WB_VCENTER;
3839
3840 SetStyle( nStyle );
3841}
3842
3843/* 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:650
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:2834
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:638
static vcl::Window * GetFocusWindow()
Get the currently focused window.
Definition: svapp.cxx:1038
void Replace(const Color &rSearchColor, const Color &rReplaceColor)
Replace all pixel having the search color with the specified color.
Definition: BitmapEx.cxx:482
static std::unique_ptr< UIObject > create(vcl::Window *pWindow)
ImageAlign GetImageAlign() const
Definition: button.cxx:162
virtual bool set_property(const OUString &rKey, const OUString &rValue) override
Definition: button.cxx:543
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:2802
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:3813
virtual void StateChanged(StateChangedType nType) override
Definition: button.cxx:3506
SAL_DLLPRIVATE void ImplCheck()
Definition: button.cxx:3226
virtual void KeyUp(const KeyEvent &rKEvt) override
Definition: button.cxx:3329
tools::Rectangle maStateRect
Definition: button.hxx:295
bool mbTriState
Definition: button.hxx:298
static Image GetCheckImage(const AllSettings &rSettings, DrawButtonFlags nFlags)
Definition: button.cxx:3651
void EnableTriState(bool bTriState=true)
Definition: button.cxx:3615
virtual Size GetOptimalSize() const override
Definition: button.cxx:3792
SAL_DLLPRIVATE void ImplInitCheckBoxData()
Definition: button.cxx:3057
virtual void GetFocus() override
Definition: button.cxx:3456
virtual void Resize() override
Definition: button.cxx:3450
virtual bool PreNotify(NotifyEvent &rNEvt) override
Definition: button.cxx:3566
SAL_DLLPRIVATE void ImplInit(vcl::Window *pParent, WinBits nStyle)
Definition: button.cxx:3063
virtual void MouseButtonDown(const MouseEvent &rMEvt) override
Definition: button.cxx:3254
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
Definition: button.cxx:3348
virtual void Tracking(const TrackingEvent &rTEvt) override
Definition: button.cxx:3267
virtual void LoseFocus() override
Definition: button.cxx:3481
virtual FactoryFunction GetUITestFactory() const override
Definition: button.cxx:3819
void Toggle()
Definition: button.cxx:3588
virtual void ShowFocus(const tools::Rectangle &rRect) override
Definition: button.cxx:3798
virtual bool set_property(const OUString &rKey, const OUString &rValue) override
Definition: button.cxx:3606
void ImplAdjustNWFSizes() override
Definition: button.cxx:3732
virtual void KeyInput(const KeyEvent &rKEvt) override
Definition: button.cxx:3308
Link< CheckBox &, void > maToggleHdl
Definition: button.hxx:299
tools::Rectangle maMouseRect
Definition: button.hxx:296
void SetState(TriState eState)
Definition: button.cxx:3593
Size CalcMinimumSize(tools::Long nMaxWidth=0) const
Definition: button.cxx:3759
SAL_DLLPRIVATE void ImplDrawCheckBox(vcl::RenderContext &rRenderContext)
Definition: button.cxx:3210
virtual void Draw(OutputDevice *pDev, const Point &rPos, SystemTextColorFlags nFlags) override
Definition: button.cxx:3353
virtual void ImplDrawCheckBoxState(vcl::RenderContext &rRenderContext)
Definition: button.cxx:3122
TriState meState
Definition: button.hxx:297
bool IsChecked() const
Definition: button.hxx:354
virtual const Color & GetCanonicalTextColor(const StyleSettings &_rStyle) const override
Definition: button.cxx:3086
virtual void DataChanged(const DataChangedEvent &rDCEvt) override
Definition: button.cxx:3552
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:3169
virtual const vcl::Font & GetCanonicalFont(const StyleSettings &_rStyle) const override
Definition: button.cxx:3081
void ImplInitSettings()
Definition: ctrl.cxx:423
static SAL_DLLPRIVATE WinBits ImplInitStyle(const vcl::Window *pPrevWindow, WinBits nStyle)
Definition: button.cxx:3071
SAL_DLLPRIVATE Size ImplGetCheckImageSize() const
Definition: button.cxx:3626
virtual void FillLayoutData() const override
Definition: button.cxx:3342
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:80
std::optional< vcl::ControlLayoutData > mxLayoutData
Definition: ctrl.hxx:82
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:428
bool ImplCallEventListenersAndHandler(VclEventId nEvent, std::function< void()> const &callHandler)
this calls both our event listeners, and a specified handler
Definition: ctrl.cxx:301
tools::Rectangle GetControlTextRect(OutputDevice &_rTargetDevice, const tools::Rectangle &rRect, const OUString &_rStr, DrawTextFlags _nStyle, Size *o_pDeviceSize=nullptr) const
Definition: ctrl.cxx:450
virtual void StateChanged(StateChangedType nStateChange) override
Definition: ctrl.cxx:256
virtual void Resize() override
Definition: ctrl.cxx:77
virtual void SetText(const OUString &rStr) override
Definition: ctrl.cxx:98
void ImplInitSettings()
Definition: ctrl.cxx:423
virtual void dispose() override
This is intended to be used to clear any locally held references to other Window-subclass objects.
Definition: ctrl.cxx:61
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:894
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:965
bool IsInExecute() const
Definition: dialog.hxx:125
SAL_DLLPRIVATE bool IsInClose() const
Definition: dialog.hxx:87
void EndDialog(tools::Long nResult=RET_CANCEL)
Definition: dialog.cxx:1134
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:3830
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:2290
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:2149
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:597
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:879
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.
constexpr tools::Long Y() const
void setX(tools::Long nX)
void Move(tools::Long nHorzMove, tools::Long nVertMove)
void setY(tools::Long nY)
tools::Long AdjustY(tools::Long nVertMove)
tools::Long AdjustX(tools::Long nHorzMove)
constexpr tools::Long X() const
SAL_DLLPRIVATE DrawTextFlags ImplGetTextStyle(SystemTextColorFlags nSystemTextColorFlags) const
Definition: button.cxx:802
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:837
void EndSelection()
Definition: button.cxx:1692
PushButtonDropdownStyle mnDDStyle
Definition: button.hxx:188
SAL_DLLPRIVATE void ImplDrawPushButtonFrame(vcl::RenderContext &rRenderContext, tools::Rectangle &rRect, DrawButtonFlags nStyle)
Definition: button.cxx:751
Size CalcMinimumSize() const
Definition: button.cxx:1704
virtual void Resize() override
Definition: button.cxx:1482
SAL_DLLPRIVATE bool IsSymbol() const
Definition: button.hxx:200
void SetPressed(bool bPressed)
Definition: button.cxx:1683
bool mbIsAction
Definition: button.hxx:223
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:220
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:678
SAL_DLLPRIVATE void ImplSetDefButton(bool bSet)
Definition: button.cxx:1194
bool mbIsActive
Definition: button.hxx:189
static SAL_DLLPRIVATE bool ImplHitTestPushButton(vcl::Window const *pDev, const Point &rPos)
Definition: button.cxx:794
void Check(bool bCheck=true)
Definition: button.hxx:227
static SAL_DLLPRIVATE WinBits ImplInitStyle(const vcl::Window *pPrevWindow, WinBits nStyle)
Definition: button.cxx:689
PushButton(vcl::Window *pParent, WinBits nStyle=0)
Definition: button.cxx:1262
bool mbPressed
Definition: button.hxx:222
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:232
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
bool isToggleButton()
Definition: button.hxx:184
TriState meState
Definition: button.hxx:221
virtual void KeyInput(const KeyEvent &rKEvt) override
Definition: button.cxx:1352
virtual const Color & GetCanonicalTextColor(const StyleSettings &_rStyle) const override
Definition: button.cxx:715
virtual const vcl::Font & GetCanonicalFont(const StyleSettings &_rStyle) const override
Definition: button.cxx:710
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
virtual bool set_property(const OUString &rKey, const OUString &rValue) override
Definition: button.cxx:1759
void ImplInitSettings()
Definition: ctrl.cxx:423
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:658
static std::unique_ptr< UIObject > create(vcl::Window *pWindow)
bool IsChecked() const
Definition: button.hxx:459
void DumpAsPropertyTree(tools::JsonWriter &) override
Button has additional stuff that we need to dump too.
Definition: button.cxx:3026
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:388
void Toggle()
Definition: button.cxx:2708
SAL_DLLPRIVATE void ImplDrawRadioButtonState(vcl::RenderContext &rRenderContext)
Definition: button.cxx:1997
virtual bool set_property(const OUString &rKey, const OUString &rValue) override
Definition: button.cxx:2740
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:2607
virtual void FillLayoutData() const override
Definition: button.cxx:2517
void SetState(bool bCheck)
Definition: button.cxx:2724
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:3006
SAL_DLLPRIVATE void ImplDrawRadioButton(vcl::RenderContext &rRenderContext)
Definition: button.cxx:2251
Image maImage
Definition: button.hxx:386
SAL_DLLPRIVATE void ImplCallClick(bool bGrabFocus=false, GetFocusFlags nFocusFlags=GetFocusFlags::NONE)
Definition: button.cxx:2380
virtual void LoseFocus() override
Definition: button.cxx:2614
SAL_DLLPRIVATE void ImplInitRadioButtonData()
Definition: button.cxx:1925
RadioButton(const RadioButton &)=delete
virtual FactoryFunction GetUITestFactory() const override
Definition: button.cxx:3052
tools::Rectangle maMouseRect
Definition: button.hxx:385
virtual void ShowFocus(const tools::Rectangle &rRect) override
Definition: button.cxx:3011
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:2931
Link< RadioButton &, void > maToggleHdl
Definition: button.hxx:391
virtual void StateChanged(StateChangedType nType) override
Definition: button.cxx:2626
virtual void KeyInput(const KeyEvent &rKEvt) override
Definition: button.cxx:2483
virtual bool PreNotify(NotifyEvent &rNEvt) override
Definition: button.cxx:2686
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:2809
virtual void Paint(vcl::RenderContext &rRenderContext, const tools::Rectangle &rRect) override
Definition: button.cxx:2523
void Check(bool bCheck=true)
Definition: button.cxx:2779
virtual void MouseButtonDown(const MouseEvent &rMEvt) override
Definition: button.cxx:2429
std::shared_ptr< std::vector< VclPtr< RadioButton > > > m_xGroup
Definition: button.hxx:383
bool mbChecked
Definition: button.hxx:387
bool mbStateChanged
Definition: button.hxx:389
tools::Rectangle maStateRect
Definition: button.hxx:384
static Image GetRadioImage(const AllSettings &rSettings, DrawButtonFlags nFlags)
Definition: button.cxx:2862
virtual void DataChanged(const DataChangedEvent &rDCEvt) override
Definition: button.cxx:2672
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:390
void ImplInitSettings()
Definition: ctrl.cxx:423
virtual ~RadioButton() override
Definition: button.cxx:2413
void SetModeRadioImage(const Image &rImage)
Definition: button.cxx:2713
virtual void Tracking(const TrackingEvent &rTEvt) override
Definition: button.cxx:2442
Size CalcMinimumSize(tools::Long nMaxWidth=0) const
Definition: button.cxx:2958
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:2601
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(std::u16string_view 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:2806
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:1962
SAL_DLLPRIVATE void ImplGrabFocus(GetFocusFlags nFlags)
Definition: mouse.cxx:195
void SetInputContext(const InputContext &rInputContext)
Definition: window.cxx:2076
bool IsReallyVisible() const
Definition: window2.cxx:1133
virtual void GetFocus()
Definition: window.cxx:1841
void StartTracking(StartTrackingFlags nFlags=StartTrackingFlags::NONE)
Definition: window2.cxx:252
vcl::Window * GetParent() const
Definition: window2.cxx:1123
virtual void RequestHelp(const HelpEvent &rHEvt)
Definition: window.cxx:1869
void PaintImmediately()
Definition: paint.cxx:1268
WinBits GetPrevStyle() const
Definition: window2.cxx:984
void EndTracking(TrackingEventFlags nFlags=TrackingEventFlags::NONE)
Definition: window2.cxx:293
bool IsMouseOver() const
Definition: mouse.cxx:596
const OUString & get_id() const
Get the ID of the window.
Definition: window.cxx:3935
WindowType GetType() const
Definition: window2.cxx:1000
virtual void SetSizePixel(const Size &rNewSize)
Definition: window2.cxx:1288
tools::Long CalcZoom(tools::Long n) const
Definition: window2.cxx:426
vcl::Window * GetWindow(GetWindowType nType) const
Definition: stacking.cxx:1036
void SetParentClipMode(ParentClipMode nMode=ParentClipMode::NONE)
void HideFocus()
Definition: window2.cxx:95
virtual void queue_resize(StateChangedType eReason=StateChangedType::Layout)
Definition: window2.cxx:1353
const Color & GetControlForeground() const
Definition: window2.cxx:1098
void GrabFocus()
Definition: window.cxx:2976
void set_id(const OUString &rID)
Sets an ID.
Definition: window.cxx:3930
bool IsUpdateMode() const
Definition: window2.cxx:1199
bool IsChildTransparentModeEnabled() const
Definition: window2.cxx:1053
bool HasFocus() const
Definition: window.cxx:2981
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:552
virtual Point GetPosPixel() const
Definition: window.cxx:2794
vcl::Font GetDrawPixelFont(::OutputDevice const *pDev) const
Definition: window2.cxx:582
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:2433
bool IsControlForeground() const
Definition: window2.cxx:1103
WinBits GetStyle() const
Definition: window2.cxx:979
const AllSettings & GetSettings() const
Definition: window3.cxx:129
virtual void KeyInput(const KeyEvent &rKEvt)
Definition: window.cxx:1805
Size CalcWindowSize(const Size &rOutSz) const
Definition: window2.cxx:566
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:1028
bool IsZoom() const
Definition: window2.cxx:1241
::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:2666
const vcl::Font & GetFont() const
Definition: window3.cxx:58
void Hide()
Definition: window.hxx:879
SAL_DLLPRIVATE WindowImpl * ImplGetWindowImpl() const
Definition: window.hxx:528
tools::Long GetDrawPixel(::OutputDevice const *pDev, tools::Long nPixels) const
Definition: window2.cxx:592
const Color & GetTextColor() const
Definition: window3.cxx:109
std::unique_ptr< WindowImpl > mpWindowImpl
Definition: window.hxx:484
virtual void ShowFocus(const tools::Rectangle &rRect)
Definition: window2.cxx:53
virtual void DumpAsPropertyTree(tools::JsonWriter &)
Dumps itself and potentially its children to a property tree, to be written easily to JSON.
Definition: window.cxx:3356
bool IsSystemWindow() const
Definition: window2.cxx:1023
virtual Size GetSizePixel() const
Definition: window.cxx:2402
Size GetOutputSizePixel() const
Definition: window3.cxx:89
bool IsControlBackground() const
Definition: window2.cxx:1113
virtual void DataChanged(const DataChangedEvent &rDCEvt)
Definition: event.cxx:36
Point GetPointerPosPixel()
Definition: mouse.cxx:540
virtual void LoseFocus()
Definition: window.cxx:1855
const Color & GetControlBackground() const
Definition: window2.cxx:1108
sal_Int32 get_width_request() const
Definition: window2.cxx:1951
void SetPaintTransparent(bool bTransparent)
Definition: paint.cxx:1025
void Invalidate(InvalidateFlags nFlags=InvalidateFlags::NONE)
Definition: paint.cxx:1143
virtual void KeyUp(const KeyEvent &rKEvt)
Definition: window.cxx:1822
void SetQuickHelpText(const OUString &rHelpText)
Definition: window2.cxx:1252
virtual OUString GetText() const
Definition: window.cxx:3055
static SAL_DLLPRIVATE void ImplCalcSymbolRect(tools::Rectangle &rRect)
Definition: brdwin.cxx:44
virtual bool set_property(const OUString &rKey, const OUString &rValue)
Definition: window2.cxx:1478
Point ScreenToOutputPixel(const Point &rPos) const
Definition: window.cxx:2812
const OUString & GetQuickHelpText() const
Definition: window2.cxx:1258
bool IsEnabled() const
Definition: window2.cxx:1148
SAL_DLLPRIVATE void ImplInit(vcl::Window *pParent, WinBits nStyle, SystemParentData *pSystemParentData)
Definition: window.cxx:941
void EnableChildTransparentMode(bool bEnable=true)
Definition: window2.cxx:1048
void SetBackground()
Definition: window3.cxx:100
SAL_DLLPRIVATE void CompatStateChanged(StateChangedType nStateChange)
Definition: window.cxx:3898
constexpr ::Color COL_WHITE(0xFF, 0xFF, 0xFF)
constexpr ::Color COL_LIGHTGRAY(0xC0, 0xC0, 0xC0)
constexpr ::Color COL_BLACK(0x00, 0x00, 0x00)
DrawButtonFlags
Definition: decoview.hxx:54
DrawSymbolFlags
Definition: decoview.hxx:35
virtual void EndDialog(sal_Int32 nResult) override
sal_Int32 nState
#define ERRCODE_NONE
TriState
TRISTATE_FALSE
TRISTATE_INDET
TRISTATE_TRUE
std::function< std::unique_ptr< UIObject >(vcl::Window *)> FactoryFunction
sal_Int32 nIndex
uno_Any a
constexpr sal_uInt16 KEY_RETURN
Definition: keycodes.hxx:119
constexpr sal_uInt16 KEY_ESCAPE
Definition: keycodes.hxx:120
constexpr sal_uInt16 KEY_SPACE
Definition: keycodes.hxx:123
vcl::Window * getNonLayoutParent(vcl::Window *pWindow)
Definition: layout.cxx:2968
Sequence< sal_Int8 > aSeq
#define SAL_N_ELEMENTS(arr)
sal_uInt16 GetFontSize(sal_uInt16 nPos)
NONE
const sal_uInt32 LEFT
bool dispatchCommand(const OUString &rCommand, const uno::Reference< css::frame::XFrame > &rFrame, const css::uno::Sequence< css::beans::PropertyValue > &rArguments, const uno::Reference< css::frame::XDispatchResultListener > &rListener)
int i
@ eSymbol
Definition: ppdparser.hxx:44
long Long
BitmapEx GetBitmapEx(BitmapEx const &rBitmapEx, DrawModeFlags nDrawMode)
Definition: drawmode.cxx:242
QPRO_FUNC_TYPE nType
OUString GetStandardText(StandardButtonType eButton)
Definition: stdtext.cxx:93
std::vector< Image > maCheckImgList
Definition: svdata.hxx:275
Color mnLastCheckFColor
Definition: svdata.hxx:282
sal_uInt16 mnRadioStyle
Definition: svdata.hxx:281
Color mnLastRadioLColor
Definition: svdata.hxx:287
Color mnLastCheckWColor
Definition: svdata.hxx:283
std::vector< Image > maRadioImgList
Definition: svdata.hxx:276
Color mnLastCheckLColor
Definition: svdata.hxx:284
Color mnLastRadioFColor
Definition: svdata.hxx:285
Color mnLastRadioWColor
Definition: svdata.hxx:286
sal_uInt16 mnCheckStyle
Definition: svdata.hxx:280
ImplSVCtrlData maCtrlData
Definition: svdata.hxx:401
ImplSVNWFData maNWFData
Definition: svdata.hxx:403
bool mbNoFocusRects
Definition: svdata.hxx:325
bool mbNoFocusRectsForFlatButtons
Definition: svdata.hxx:326
ImplSVData * ImplGetSVData()
Definition: svdata.cxx:77
OUString aCommand
unsigned char sal_uInt8
signed char sal_Int8
SymbolType
Definition: vclenum.hxx:74
@ RET_OK
Definition: vclenum.hxx:206
GetFocusFlags
Definition: window.hxx:313
StartTrackingFlags
Definition: window.hxx:265
StateChangedType
Definition: window.hxx:291
@ NoErase
The invalidated area is painted with the background color/pattern.
sal_Int64 WinBits
Definition: wintypes.hxx:109
WinBits const WB_CLOSEABLE
Definition: wintypes.hxx:123
WinBits const WB_TOP
Definition: wintypes.hxx:149
WinBits const WB_VCENTER
Definition: wintypes.hxx:150
WinBits const WB_CENTER
Definition: wintypes.hxx:147
WindowType
Definition: wintypes.hxx:27
WinBits const WB_NOTABSTOP
Definition: wintypes.hxx:141
WinBits const WB_NOLABEL
Definition: wintypes.hxx:157
WinBits const WB_TOGGLE
Definition: wintypes.hxx:185
WinBits const WB_REPEAT
Definition: wintypes.hxx:154
WinBits const WB_NOPOINTERFOCUS
Definition: wintypes.hxx:155
ImageAlign
Definition: wintypes.hxx:234
WinBits const WB_3DLOOK
Definition: wintypes.hxx:118
SymbolAlign
Definition: wintypes.hxx:239
WinBits const WB_GROUP
Definition: wintypes.hxx:142
WinBits const WB_FLATBUTTON
Definition: wintypes.hxx:186
WinBits const WB_RIGHT
Definition: wintypes.hxx:148
WinBits const WB_WORDBREAK
Definition: wintypes.hxx:156
WinBits const WB_SMALLSTYLE
Definition: wintypes.hxx:184
WinBits const WB_NOGROUP
Definition: wintypes.hxx:143
WinBits const WB_DEFBUTTON
Definition: wintypes.hxx:181
WinBits const WB_NOLIGHTBORDER
Definition: wintypes.hxx:182
WinBits const WB_TABSTOP
Definition: wintypes.hxx:140
WinBits const WB_BOTTOM
Definition: wintypes.hxx:151
WinBits const WB_LEFT
Definition: wintypes.hxx:146
WinBits const WB_RECTSTYLE
Definition: wintypes.hxx:183
std::unique_ptr< char[]> aBuffer