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