1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include <sal/config.h>
23 #include <string_view>
25 #include <com/sun/star/accessibility/AccessibleRelationType.hpp>
26 #include <com/sun/star/awt/XWindow.hpp>
27 #include <com/sun/star/awt/XVclWindowPeer.hpp>
28 #include <o3tl/safeint.hxx>
29 #include <o3tl/sorted_vector.hxx>
30 #include <o3tl/string_view.hxx>
31 #include <officecfg/Office/Common.hxx>
32 #include <salframe.hxx>
33 #include <salinst.hxx>
36 #include <saltimer.hxx>
37 #include <salsession.hxx>
41 #include <salmenu.hxx>
42 #include <strings.hrc>
44 #include <svimpbox.hxx>
45 #include <messagedialog.hxx>
46 #include <treeglue.hxx>
47 #include <unotools/accessiblerelationsethelper.hxx>
48 #include <unotools/configmgr.hxx>
50 #include <tools/helpers.hxx>
51 #include <vcl/abstdlg.hxx>
52 #include <vcl/builder.hxx>
53 #include <vcl/toolkit/combobox.hxx>
54 #include <vcl/toolkit/dialog.hxx>
55 #include <vcl/toolkit/fixed.hxx>
56 #include <vcl/toolkit/fmtfield.hxx>
57 #include <vcl/headbar.hxx>
58 #include <vcl/toolkit/ivctrl.hxx>
59 #include <vcl/layout.hxx>
60 #include <vcl/toolkit/menubtn.hxx>
61 #include <vcl/toolkit/prgsbar.hxx>
62 #include <vcl/ptrstyle.hxx>
64 #include <vcl/sysdata.hxx>
65 #include <vcl/toolkit/svlbitm.hxx>
66 #include <vcl/toolkit/svtabbx.hxx>
67 #include <vcl/tabctrl.hxx>
68 #include <vcl/tabpage.hxx>
69 #include <vcl/toolbox.hxx>
70 #include <vcl/toolkit/treelistentry.hxx>
71 #include <vcl/toolkit/throbber.hxx>
72 #include <vcl/toolkit/unowrap.hxx>
73 #include <vcl/weld.hxx>
74 #include <vcl/weldutils.hxx>
75 #include <vcl/toolkit/vclmedit.hxx>
76 #include <vcl/toolkit/viewdataentry.hxx>
77 #include <vcl/virdev.hxx>
78 #include <bitmaps.hlst>
79 #include <calendar.hxx>
80 #include <menutogglebutton.hxx>
81 #include <verticaltabctrl.hxx>
84 #include <salvtables.hxx>
85 #include <comphelper/lok.hxx>
93 // this file contains the virtual destructors of the sal interface
94 // compilers usually put their vtables where the destructor is
96 SalFrame::~SalFrame() {}
98 void SalFrame::SetCallback(vcl::Window
* pWindow
, SALFRAMEPROC pProc
)
104 // default to full-frame flushes
105 // on ports where partial-flushes are much cheaper this method should be overridden
106 void SalFrame::Flush(const tools::Rectangle
&) { Flush(); }
108 void SalFrame::SetRepresentedURL(const OUString
&)
110 // currently this is Mac only functionality
113 OUString
SalFrame::DumpSetPosSize(tools::Long nX
, tools::Long nY
, tools::Long nWidth
,
114 tools::Long nHeight
, sal_uInt16 nFlags
)
116 // assuming the 4 integers normally don't have more than 4 digits, but might be negative
117 OUStringBuffer
aBuffer(4 * 5 + 5);
118 if (nFlags
& SAL_FRAME_POSSIZE_WIDTH
)
119 aBuffer
<< nWidth
<< "x";
122 if (nFlags
& SAL_FRAME_POSSIZE_HEIGHT
)
123 aBuffer
<< nHeight
<< "@(";
126 if (nFlags
& SAL_FRAME_POSSIZE_X
)
127 aBuffer
<< nX
<< ",";
130 if (nFlags
& SAL_FRAME_POSSIZE_Y
)
131 aBuffer
<< nY
<< ")";
134 return aBuffer
.makeStringAndClear();
137 SalInstance::SalInstance(std::unique_ptr
<comphelper::SolarMutex
> pMutex
)
138 : m_pYieldMutex(std::move(pMutex
))
142 SalInstance::~SalInstance() {}
144 comphelper::SolarMutex
* SalInstance::GetYieldMutex() { return m_pYieldMutex
.get(); }
146 sal_uInt32
SalInstance::ReleaseYieldMutexAll() { return m_pYieldMutex
->release(true); }
148 void SalInstance::AcquireYieldMutex(sal_uInt32 nCount
) { m_pYieldMutex
->acquire(nCount
); }
150 std::unique_ptr
<SalSession
> SalInstance::CreateSalSession() { return nullptr; }
152 OpenGLContext
* SalInstance::CreateOpenGLContext()
154 assert(!m_bSupportsOpenGL
);
158 std::unique_ptr
<SalMenu
> SalInstance::CreateMenu(bool, Menu
*)
160 // default: no native menus
164 std::unique_ptr
<SalMenuItem
> SalInstance::CreateMenuItem(const SalItemParams
&) { return nullptr; }
166 bool SalInstance::CallEventCallback(void const* pEvent
, int nBytes
)
168 return m_pEventInst
.is() && m_pEventInst
->dispatchEvent(pEvent
, nBytes
);
171 bool SalInstance::DoExecute(int&)
173 // can't run on system event loop without implementing DoExecute and DoQuit
174 if (Application::IsOnSystemEventLoop())
179 void SalInstance::DoQuit()
181 if (Application::IsOnSystemEventLoop())
185 SalTimer::~SalTimer() COVERITY_NOEXCEPT_FALSE
{}
187 void SalBitmap::DropScaledCache()
189 if (ImplSVData
* pSVData
= ImplGetSVData())
191 auto& rCache
= pSVData
->maGDIData
.maScaleCache
;
193 rCache
.remove_if([this](const lru_scale_cache::key_value_pair_t
& rKeyValuePair
) {
194 return rKeyValuePair
.first
.mpBitmap
== this;
199 SalBitmap::~SalBitmap() { DropScaledCache(); }
201 SalSystem::~SalSystem() {}
203 SalPrinter::~SalPrinter() {}
205 bool SalPrinter::StartJob(const OUString
*, const OUString
&, const OUString
&, ImplJobSetup
*,
206 vcl::PrinterController
&)
211 SalInfoPrinter::~SalInfoPrinter() {}
213 SalVirtualDevice::~SalVirtualDevice() {}
215 SalObject::~SalObject() {}
217 SalMenu::~SalMenu() {}
219 bool SalMenu::ShowNativePopupMenu(FloatingWindow
*, const tools::Rectangle
&, FloatWinPopupFlags
)
224 void SalMenu::ShowCloseButton(bool) {}
226 bool SalMenu::AddMenuBarButton(const SalMenuButtonItem
&) { return false; }
228 void SalMenu::RemoveMenuBarButton(sal_uInt16
) {}
230 tools::Rectangle
SalMenu::GetMenuBarButtonRectPixel(sal_uInt16
, SalFrame
*)
232 return tools::Rectangle();
235 int SalMenu::GetMenuBarHeight() const { return 0; }
237 void SalMenu::ApplyPersona() {}
239 SalMenuItem::~SalMenuItem() {}
241 class SalFlashAttention
244 VclPtr
<vcl::Window
> m_xWidget
;
246 Color m_aOrigControlBackground
;
247 Wallpaper m_aOrigBackground
;
248 bool m_bOrigControlBackground
;
253 Color
aColor(Application::GetSettings().GetStyleSettings().GetHighlightColor());
254 m_xWidget
->SetControlBackground(aColor
);
259 if (m_bOrigControlBackground
)
260 m_xWidget
->SetControlBackground(m_aOrigControlBackground
);
262 m_xWidget
->SetControlBackground();
267 constexpr int FlashesWanted
= 1;
269 if (m_nFlashCount
% 2 == 0)
274 if (m_nFlashCount
== FlashesWanted
* 2)
279 m_aFlashTimer
.Start();
282 DECL_LINK(FlashTimeout
, Timer
*, void);
285 SalFlashAttention(VclPtr
<vcl::Window
> xWidget
)
286 : m_xWidget(std::move(xWidget
))
287 , m_aFlashTimer("SalFlashAttention")
288 , m_bOrigControlBackground(false)
291 m_aFlashTimer
.SetTimeout(150);
292 m_aFlashTimer
.SetInvokeHandler(LINK(this, SalFlashAttention
, FlashTimeout
));
297 m_bOrigControlBackground
= m_xWidget
->IsControlBackground();
298 if (m_bOrigControlBackground
)
299 m_aOrigControlBackground
= m_xWidget
->GetControlBackground();
300 m_aFlashTimer
.Start();
303 ~SalFlashAttention() { ClearFlash(); }
306 IMPL_LINK_NOARG(SalFlashAttention
, FlashTimeout
, Timer
*, void) { Flash(); }
308 void SalInstanceWidget::ensure_event_listener()
310 if (!m_bEventListener
)
312 m_xWidget
->AddEventListener(LINK(this, SalInstanceWidget
, EventListener
));
313 m_bEventListener
= true;
317 // we want the ability to mark key events as handled, so use this variant
318 // for those, we get all keystrokes in this case, so we will need to filter
320 void SalInstanceWidget::ensure_key_listener()
322 if (!m_bKeyEventListener
)
324 Application::AddKeyListener(LINK(this, SalInstanceWidget
, KeyEventListener
));
325 m_bKeyEventListener
= true;
329 // we want the ability to know about mouse events that happen in our children
330 // so use this variant, we will need to filter them later
331 void SalInstanceWidget::ensure_mouse_listener()
333 if (!m_bMouseEventListener
)
335 m_xWidget
->AddChildEventListener(LINK(this, SalInstanceWidget
, MouseEventListener
));
336 m_bMouseEventListener
= true;
340 void SalInstanceWidget::set_background(const Color
& rColor
)
342 m_xWidget
->SetControlBackground(rColor
);
343 m_xWidget
->SetBackground(m_xWidget
->GetControlBackground());
344 if (m_xWidget
->GetStyle() & WB_CLIPCHILDREN
)
346 // turn off WB_CLIPCHILDREN otherwise the bg won't extend "under"
347 // transparent children of the widget e.g. expander in sidebar panel header
348 m_xWidget
->SetStyle(m_xWidget
->GetStyle() & ~WB_CLIPCHILDREN
);
349 // and toggle mbClipChildren on instead otherwise the bg won't fill e.g.
350 // deck titlebar header when its width is stretched
351 WindowImpl
* pImpl
= m_xWidget
->ImplGetWindowImpl();
352 pImpl
->mbClipChildren
= true;
356 SalInstanceWidget::SalInstanceWidget(vcl::Window
* pWidget
, SalInstanceBuilder
* pBuilder
,
359 , m_pBuilder(pBuilder
)
360 , m_bTakeOwnership(bTakeOwnership
)
361 , m_bEventListener(false)
362 , m_bKeyEventListener(false)
363 , m_bMouseEventListener(false)
369 void SalInstanceWidget::set_sensitive(bool sensitive
) { m_xWidget
->Enable(sensitive
); }
371 bool SalInstanceWidget::get_sensitive() const { return m_xWidget
->IsEnabled(); }
373 bool SalInstanceWidget::get_visible() const { return m_xWidget
->IsVisible(); }
375 bool SalInstanceWidget::is_visible() const { return m_xWidget
->IsReallyVisible(); }
377 void SalInstanceWidget::set_can_focus(bool bCanFocus
)
379 auto nStyle
= m_xWidget
->GetStyle() & ~(WB_TABSTOP
| WB_NOTABSTOP
);
381 nStyle
|= WB_TABSTOP
;
383 nStyle
|= WB_NOTABSTOP
;
384 m_xWidget
->SetStyle(nStyle
);
387 void SalInstanceWidget::grab_focus()
391 m_xWidget
->GrabFocus();
394 bool SalInstanceWidget::has_focus() const { return m_xWidget
->HasFocus(); }
396 bool SalInstanceWidget::is_active() const { return m_xWidget
->IsActive(); }
398 bool SalInstanceWidget::has_child_focus() const { return m_xWidget
->HasChildPathFocus(true); }
400 void SalInstanceWidget::show() { m_xWidget
->Show(); }
402 void SalInstanceWidget::hide() { m_xWidget
->Hide(); }
404 void SalInstanceWidget::set_size_request(int nWidth
, int nHeight
)
406 m_xWidget
->set_width_request(nWidth
);
407 m_xWidget
->set_height_request(nHeight
);
410 Size
SalInstanceWidget::get_size_request() const
412 return Size(m_xWidget
->get_width_request(), m_xWidget
->get_height_request());
415 Size
SalInstanceWidget::get_preferred_size() const { return m_xWidget
->get_preferred_size(); }
417 float SalInstanceWidget::get_approximate_digit_width() const
419 return m_xWidget
->approximate_digit_width();
422 int SalInstanceWidget::get_text_height() const { return m_xWidget
->GetTextHeight(); }
424 Size
SalInstanceWidget::get_pixel_size(const OUString
& rText
) const
426 //TODO, or do I want GetTextBoundRect ?, just using width at the moment anyway
427 return Size(m_xWidget
->GetTextWidth(rText
), m_xWidget
->GetTextHeight());
430 vcl::Font
SalInstanceWidget::get_font() { return m_xWidget
->GetPointFont(*m_xWidget
->GetOutDev()); }
432 OUString
SalInstanceWidget::get_buildable_name() const { return m_xWidget
->get_id(); }
434 void SalInstanceWidget::set_buildable_name(const OUString
& rId
) { return m_xWidget
->set_id(rId
); }
436 void SalInstanceWidget::set_help_id(const OUString
& rId
) { return m_xWidget
->SetHelpId(rId
); }
438 OUString
SalInstanceWidget::get_help_id() const { return m_xWidget
->GetHelpId(); }
440 void SalInstanceWidget::set_grid_left_attach(int nAttach
)
442 m_xWidget
->set_grid_left_attach(nAttach
);
445 int SalInstanceWidget::get_grid_left_attach() const { return m_xWidget
->get_grid_left_attach(); }
447 void SalInstanceWidget::set_grid_width(int nCols
) { m_xWidget
->set_grid_width(nCols
); }
449 void SalInstanceWidget::set_grid_top_attach(int nAttach
)
451 m_xWidget
->set_grid_top_attach(nAttach
);
454 int SalInstanceWidget::get_grid_top_attach() const { return m_xWidget
->get_grid_top_attach(); }
456 void SalInstanceWidget::set_hexpand(bool bExpand
) { m_xWidget
->set_hexpand(bExpand
); }
458 bool SalInstanceWidget::get_hexpand() const { return m_xWidget
->get_hexpand(); }
460 void SalInstanceWidget::set_vexpand(bool bExpand
) { m_xWidget
->set_vexpand(bExpand
); }
462 bool SalInstanceWidget::get_vexpand() const { return m_xWidget
->get_vexpand(); }
464 void SalInstanceWidget::set_margin_top(int nMargin
) { m_xWidget
->set_margin_top(nMargin
); }
466 void SalInstanceWidget::set_margin_bottom(int nMargin
) { m_xWidget
->set_margin_bottom(nMargin
); }
468 void SalInstanceWidget::set_margin_start(int nMargin
) { m_xWidget
->set_margin_start(nMargin
); }
470 void SalInstanceWidget::set_margin_end(int nMargin
) { m_xWidget
->set_margin_end(nMargin
); }
472 int SalInstanceWidget::get_margin_top() const { return m_xWidget
->get_margin_top(); }
474 int SalInstanceWidget::get_margin_bottom() const { return m_xWidget
->get_margin_bottom(); }
476 int SalInstanceWidget::get_margin_start() const { return m_xWidget
->get_margin_start(); }
478 int SalInstanceWidget::get_margin_end() const { return m_xWidget
->get_margin_end(); }
480 void SalInstanceWidget::set_accessible_name(const OUString
& rName
)
482 m_xWidget
->SetAccessibleName(rName
);
485 void SalInstanceWidget::set_accessible_description(const OUString
& rDescription
)
487 m_xWidget
->SetAccessibleDescription(rDescription
);
490 OUString
SalInstanceWidget::get_accessible_name() const { return m_xWidget
->GetAccessibleName(); }
492 OUString
SalInstanceWidget::get_accessible_description() const
494 return m_xWidget
->GetAccessibleDescription();
497 void SalInstanceWidget::set_accessible_relation_labeled_by(weld::Widget
* pLabel
)
499 if (vcl::Window
* pOldLabel
= m_xWidget
->GetAccessibleRelationLabeledBy())
500 pOldLabel
->SetAccessibleRelationLabelFor(nullptr);
501 vcl::Window
* pA11yLabel
502 = pLabel
? dynamic_cast<SalInstanceWidget
&>(*pLabel
).getWidget() : nullptr;
503 m_xWidget
->SetAccessibleRelationLabeledBy(pA11yLabel
);
505 pA11yLabel
->SetAccessibleRelationLabelFor(m_xWidget
);
508 void SalInstanceWidget::set_tooltip_text(const OUString
& rTip
)
510 m_xWidget
->SetQuickHelpText(rTip
);
513 OUString
SalInstanceWidget::get_tooltip_text() const { return m_xWidget
->GetQuickHelpText(); }
515 void SalInstanceWidget::set_cursor_data(void* pData
)
517 vcl::Cursor
* pCursor
= static_cast<vcl::Cursor
*>(pData
);
521 m_xWidget
->SetCursor(pCursor
);
524 void SalInstanceWidget::connect_focus_in(const Link
<Widget
&, void>& rLink
)
526 ensure_event_listener();
527 weld::Widget::connect_focus_in(rLink
);
530 void SalInstanceWidget::connect_mnemonic_activate(const Link
<Widget
&, bool>& rLink
)
532 m_xWidget
->SetMnemonicActivateHdl(LINK(this, SalInstanceWidget
, MnemonicActivateHdl
));
533 weld::Widget::connect_mnemonic_activate(rLink
);
536 void SalInstanceWidget::connect_focus_out(const Link
<Widget
&, void>& rLink
)
538 ensure_event_listener();
539 weld::Widget::connect_focus_out(rLink
);
542 void SalInstanceWidget::connect_size_allocate(const Link
<const Size
&, void>& rLink
)
544 ensure_event_listener();
545 weld::Widget::connect_size_allocate(rLink
);
548 void SalInstanceWidget::connect_mouse_press(const Link
<const MouseEvent
&, bool>& rLink
)
550 ensure_mouse_listener();
551 weld::Widget::connect_mouse_press(rLink
);
554 void SalInstanceWidget::connect_mouse_move(const Link
<const MouseEvent
&, bool>& rLink
)
556 ensure_mouse_listener();
557 weld::Widget::connect_mouse_move(rLink
);
560 void SalInstanceWidget::connect_mouse_release(const Link
<const MouseEvent
&, bool>& rLink
)
562 ensure_mouse_listener();
563 weld::Widget::connect_mouse_release(rLink
);
566 void SalInstanceWidget::connect_key_press(const Link
<const KeyEvent
&, bool>& rLink
)
568 ensure_key_listener();
569 weld::Widget::connect_key_press(rLink
);
572 void SalInstanceWidget::connect_key_release(const Link
<const KeyEvent
&, bool>& rLink
)
574 ensure_key_listener();
575 weld::Widget::connect_key_release(rLink
);
578 IMPL_LINK(SalInstanceWidget
, SettingsChangedHdl
, VclWindowEvent
&, rEvent
, void)
580 if (rEvent
.GetId() != VclEventId::WindowDataChanged
)
583 DataChangedEvent
* pData
= static_cast<DataChangedEvent
*>(rEvent
.GetData());
584 if (pData
->GetType() == DataChangedEventType::SETTINGS
)
585 m_aStyleUpdatedHdl
.Call(*this);
588 void SalInstanceWidget::connect_style_updated(const Link
<Widget
&, void>& rLink
)
590 if (m_aStyleUpdatedHdl
.IsSet())
591 m_xWidget
->RemoveEventListener(LINK(this, SalInstanceWidget
, SettingsChangedHdl
));
592 weld::Widget::connect_style_updated(rLink
);
593 if (m_aStyleUpdatedHdl
.IsSet())
594 m_xWidget
->AddEventListener(LINK(this, SalInstanceWidget
, SettingsChangedHdl
));
597 bool SalInstanceWidget::get_extents_relative_to(const Widget
& rRelative
, int& x
, int& y
, int& width
,
600 tools::Rectangle
aRect(m_xWidget
->GetWindowExtentsRelative(
601 dynamic_cast<const SalInstanceWidget
&>(rRelative
).getWidget()));
604 width
= aRect
.GetWidth();
605 height
= aRect
.GetHeight();
609 void SalInstanceWidget::grab_add() { m_xWidget
->CaptureMouse(); }
611 bool SalInstanceWidget::has_grab() const { return m_xWidget
->IsMouseCaptured(); }
613 void SalInstanceWidget::grab_remove() { m_xWidget
->ReleaseMouse(); }
615 bool SalInstanceWidget::get_direction() const { return m_xWidget
->IsRTLEnabled(); }
617 void SalInstanceWidget::set_direction(bool bRTL
) { m_xWidget
->EnableRTL(bRTL
); }
619 void SalInstanceWidget::freeze()
621 if (m_nFreezeCount
== 0)
622 m_xWidget
->SetUpdateMode(false);
626 void SalInstanceWidget::thaw()
629 if (m_nFreezeCount
== 0)
630 m_xWidget
->SetUpdateMode(true);
633 void SalInstanceWidget::set_busy_cursor(bool bBusy
)
641 m_xWidget
->EnterWait();
643 m_xWidget
->LeaveWait();
646 void SalInstanceWidget::queue_resize() { m_xWidget
->queue_resize(); }
648 SalInstanceWidget::~SalInstanceWidget()
650 if (m_aStyleUpdatedHdl
.IsSet())
651 m_xWidget
->RemoveEventListener(LINK(this, SalInstanceWidget
, SettingsChangedHdl
));
652 if (m_aMnemonicActivateHdl
.IsSet())
653 m_xWidget
->SetMnemonicActivateHdl(Link
<vcl::Window
&, bool>());
654 if (m_bMouseEventListener
)
655 m_xWidget
->RemoveChildEventListener(LINK(this, SalInstanceWidget
, MouseEventListener
));
656 if (m_bKeyEventListener
)
657 Application::RemoveKeyListener(LINK(this, SalInstanceWidget
, KeyEventListener
));
658 if (m_bEventListener
)
659 m_xWidget
->RemoveEventListener(LINK(this, SalInstanceWidget
, EventListener
));
660 if (m_bTakeOwnership
)
661 m_xWidget
.disposeAndClear();
664 vcl::Window
* SalInstanceWidget::getWidget() const { return m_xWidget
; }
666 void SalInstanceWidget::disable_notify_events() { ++m_nBlockNotify
; }
668 bool SalInstanceWidget::notify_events_disabled() const { return m_nBlockNotify
!= 0; }
670 void SalInstanceWidget::enable_notify_events() { --m_nBlockNotify
; }
672 OUString
SalInstanceWidget::strip_mnemonic(const OUString
& rLabel
) const
674 return rLabel
.replaceFirst("~", "");
677 VclPtr
<VirtualDevice
> SalInstanceWidget::create_virtual_device() const
679 // create with (annoying) separate alpha layer that LibreOffice itself uses
680 return VclPtr
<VirtualDevice
>::Create(*Application::GetDefaultDevice(),
681 DeviceFormat::WITH_ALPHA
);
684 void SalInstanceWidget::call_attention_to()
686 m_xFlashAttention
.reset(new SalFlashAttention(m_xWidget
));
687 m_xFlashAttention
->Start();
690 css::uno::Reference
<css::datatransfer::dnd::XDropTarget
> SalInstanceWidget::get_drop_target()
692 return m_xWidget
->GetDropTarget();
695 css::uno::Reference
<css::datatransfer::clipboard::XClipboard
>
696 SalInstanceWidget::get_clipboard() const
698 return m_xWidget
->GetClipboard();
701 void SalInstanceWidget::connect_get_property_tree(const Link
<tools::JsonWriter
&, void>& rLink
)
703 m_xWidget
->SetDumpAsPropertyTreeHdl(rLink
);
706 void SalInstanceWidget::get_property_tree(tools::JsonWriter
& rJsonWriter
)
708 m_xWidget
->DumpAsPropertyTree(rJsonWriter
);
711 void SalInstanceWidget::set_stack_background()
713 set_background(m_xWidget
->GetSettings().GetStyleSettings().GetWindowColor());
716 void SalInstanceWidget::set_title_background()
718 set_background(m_xWidget
->GetSettings().GetStyleSettings().GetShadowColor());
721 void SalInstanceWidget::set_toolbar_background()
723 m_xWidget
->SetBackground();
724 m_xWidget
->SetPaintTransparent(true);
727 void SalInstanceWidget::set_highlight_background()
729 set_background(m_xWidget
->GetSettings().GetStyleSettings().GetHighlightColor());
732 SystemWindow
* SalInstanceWidget::getSystemWindow() { return m_xWidget
->GetSystemWindow(); }
734 void SalInstanceWidget::HandleEventListener(VclWindowEvent
& rEvent
)
736 if (rEvent
.GetId() == VclEventId::WindowGetFocus
)
737 m_aFocusInHdl
.Call(*this);
738 else if (rEvent
.GetId() == VclEventId::WindowLoseFocus
)
739 m_aFocusOutHdl
.Call(*this);
740 else if (rEvent
.GetId() == VclEventId::WindowResize
)
741 m_aSizeAllocateHdl
.Call(m_xWidget
->GetSizePixel());
746 MouseEvent
TransformEvent(const MouseEvent
& rEvent
, const vcl::Window
* pParent
,
747 const vcl::Window
* pChild
)
750 pParent
->ScreenToOutputPixel(pChild
->OutputToScreenPixel(rEvent
.GetPosPixel())),
751 rEvent
.GetClicks(), rEvent
.GetMode(), rEvent
.GetButtons(), rEvent
.GetModifier());
755 void SalInstanceWidget::HandleMouseEventListener(VclWindowEvent
& rWinEvent
)
757 if (rWinEvent
.GetId() == VclEventId::WindowMouseButtonDown
)
759 if (m_xWidget
== rWinEvent
.GetWindow())
761 const MouseEvent
* pMouseEvent
= static_cast<const MouseEvent
*>(rWinEvent
.GetData());
762 m_aMousePressHdl
.Call(*pMouseEvent
);
764 else if (m_xWidget
->ImplIsChild(rWinEvent
.GetWindow()))
766 const MouseEvent
* pMouseEvent
= static_cast<const MouseEvent
*>(rWinEvent
.GetData());
767 const MouseEvent
aTransformedEvent(
768 TransformEvent(*pMouseEvent
, m_xWidget
, rWinEvent
.GetWindow()));
769 m_aMousePressHdl
.Call(aTransformedEvent
);
772 else if (rWinEvent
.GetId() == VclEventId::WindowMouseButtonUp
)
774 if (m_xWidget
== rWinEvent
.GetWindow())
776 const MouseEvent
* pMouseEvent
= static_cast<const MouseEvent
*>(rWinEvent
.GetData());
777 m_aMouseReleaseHdl
.Call(*pMouseEvent
);
779 else if (m_xWidget
->ImplIsChild(rWinEvent
.GetWindow()))
781 const MouseEvent
* pMouseEvent
= static_cast<const MouseEvent
*>(rWinEvent
.GetData());
782 const MouseEvent
aTransformedEvent(
783 TransformEvent(*pMouseEvent
, m_xWidget
, rWinEvent
.GetWindow()));
784 m_aMouseReleaseHdl
.Call(aTransformedEvent
);
787 else if (rWinEvent
.GetId() == VclEventId::WindowMouseMove
)
789 if (m_xWidget
== rWinEvent
.GetWindow())
791 const MouseEvent
* pMouseEvent
= static_cast<const MouseEvent
*>(rWinEvent
.GetData());
792 m_aMouseMotionHdl
.Call(*pMouseEvent
);
794 else if (m_xWidget
->ImplIsChild(rWinEvent
.GetWindow()))
796 const MouseEvent
* pMouseEvent
= static_cast<const MouseEvent
*>(rWinEvent
.GetData());
797 const MouseEvent
aTransformedEvent(
798 TransformEvent(*pMouseEvent
, m_xWidget
, rWinEvent
.GetWindow()));
799 m_aMouseMotionHdl
.Call(aTransformedEvent
);
804 bool SalInstanceWidget::HandleKeyEventListener(VclWindowEvent
& rEvent
)
806 // we get all key events here, ignore them unless we have focus
807 if (!m_xWidget
->HasChildPathFocus())
809 if (rEvent
.GetId() == VclEventId::WindowKeyInput
)
811 const KeyEvent
* pKeyEvent
= static_cast<const KeyEvent
*>(rEvent
.GetData());
812 return m_aKeyPressHdl
.Call(*pKeyEvent
);
814 else if (rEvent
.GetId() == VclEventId::WindowKeyUp
)
816 const KeyEvent
* pKeyEvent
= static_cast<const KeyEvent
*>(rEvent
.GetData());
817 return m_aKeyReleaseHdl
.Call(*pKeyEvent
);
822 IMPL_LINK(SalInstanceWidget
, EventListener
, VclWindowEvent
&, rEvent
, void)
824 HandleEventListener(rEvent
);
827 IMPL_LINK(SalInstanceWidget
, KeyEventListener
, VclWindowEvent
&, rEvent
, bool)
829 return HandleKeyEventListener(rEvent
);
832 IMPL_LINK(SalInstanceWidget
, MouseEventListener
, VclWindowEvent
&, rEvent
, void)
834 HandleMouseEventListener(rEvent
);
837 IMPL_LINK_NOARG(SalInstanceWidget
, MnemonicActivateHdl
, vcl::Window
&, bool)
839 return m_aMnemonicActivateHdl
.Call(*this);
844 Image
createImage(const OUString
& rImage
)
846 if (rImage
.isEmpty())
848 if (rImage
.lastIndexOf('.') != rImage
.getLength() - 4)
850 assert((rImage
== "dialog-warning" || rImage
== "dialog-error"
851 || rImage
== "dialog-information")
852 && "unknown stock image");
853 if (rImage
== "dialog-warning")
854 return Image(StockImage::Yes
, IMG_WARN
);
855 else if (rImage
== "dialog-error")
856 return Image(StockImage::Yes
, IMG_ERROR
);
857 else if (rImage
== "dialog-information")
858 return Image(StockImage::Yes
, IMG_INFO
);
860 return Image(StockImage::Yes
, rImage
);
863 Image
createImage(const VirtualDevice
& rDevice
)
865 return Image(rDevice
.GetBitmapEx(Point(), rDevice
.GetOutputSizePixel()));
868 sal_uInt16
insert_to_menu(sal_uInt16 nLastId
, PopupMenu
* pMenu
, int pos
, const OUString
& rId
,
869 const OUString
& rStr
, const OUString
* pIconName
,
870 const VirtualDevice
* pImageSurface
,
871 const css::uno::Reference
<css::graphic::XGraphic
>& rImage
,
872 TriState eCheckRadioFalse
)
874 const sal_uInt16 nNewid
= nLastId
+ 1;
877 if (eCheckRadioFalse
== TRISTATE_TRUE
)
878 nBits
= MenuItemBits::CHECKABLE
;
879 else if (eCheckRadioFalse
== TRISTATE_FALSE
)
880 nBits
= MenuItemBits::CHECKABLE
| MenuItemBits::RADIOCHECK
;
882 nBits
= MenuItemBits::NONE
;
884 pMenu
->InsertItem(nNewid
, rStr
, nBits
, rId
, pos
== -1 ? MENU_APPEND
: pos
);
887 pMenu
->SetItemImage(nNewid
, createImage(*pIconName
));
889 else if (pImageSurface
)
891 pMenu
->SetItemImage(nNewid
, createImage(*pImageSurface
));
895 pMenu
->SetItemImage(nNewid
, Image(rImage
));
901 SalInstanceMenu::SalInstanceMenu(PopupMenu
* pMenu
, bool bTakeOwnership
)
903 , m_bTakeOwnership(bTakeOwnership
)
905 const auto nCount
= m_xMenu
->GetItemCount();
906 m_nLastId
= nCount
? pMenu
->GetItemId(nCount
- 1) : 0;
907 m_xMenu
->SetSelectHdl(LINK(this, SalInstanceMenu
, SelectMenuHdl
));
909 OUString
SalInstanceMenu::popup_at_rect(weld::Widget
* pParent
, const tools::Rectangle
& rRect
,
910 weld::Placement ePlace
)
912 SalInstanceWidget
* pVclWidget
= dynamic_cast<SalInstanceWidget
*>(pParent
);
914 PopupMenuFlags eFlags
= PopupMenuFlags::NoMouseUpClose
;
915 if (ePlace
== weld::Placement::Under
)
916 eFlags
= eFlags
| PopupMenuFlags::ExecuteDown
;
918 eFlags
= eFlags
| PopupMenuFlags::ExecuteRight
;
919 m_xMenu
->Execute(pVclWidget
->getWidget(), rRect
, eFlags
);
920 return m_xMenu
->GetCurItemIdent();
922 void SalInstanceMenu::set_sensitive(const OUString
& rIdent
, bool bSensitive
)
924 m_xMenu
->EnableItem(rIdent
, bSensitive
);
926 bool SalInstanceMenu::get_sensitive(const OUString
& rIdent
) const
928 return m_xMenu
->IsItemEnabled(m_xMenu
->GetItemId(rIdent
));
930 void SalInstanceMenu::set_active(const OUString
& rIdent
, bool bActive
)
932 m_xMenu
->CheckItem(rIdent
, bActive
);
934 bool SalInstanceMenu::get_active(const OUString
& rIdent
) const
936 return m_xMenu
->IsItemChecked(m_xMenu
->GetItemId(rIdent
));
938 void SalInstanceMenu::set_label(const OUString
& rIdent
, const OUString
& rLabel
)
940 m_xMenu
->SetItemText(m_xMenu
->GetItemId(rIdent
), rLabel
);
942 OUString
SalInstanceMenu::get_label(const OUString
& rIdent
) const
944 return m_xMenu
->GetItemText(m_xMenu
->GetItemId(rIdent
));
946 void SalInstanceMenu::set_visible(const OUString
& rIdent
, bool bShow
)
948 m_xMenu
->ShowItem(m_xMenu
->GetItemId(rIdent
), bShow
);
950 void SalInstanceMenu::clear() { m_xMenu
->Clear(); }
951 void SalInstanceMenu::insert(int pos
, const OUString
& rId
, const OUString
& rStr
,
952 const OUString
* pIconName
, VirtualDevice
* pImageSurface
,
953 const css::uno::Reference
<css::graphic::XGraphic
>& rImage
,
954 TriState eCheckRadioFalse
)
956 m_nLastId
= insert_to_menu(m_nLastId
, m_xMenu
, pos
, rId
, rStr
, pIconName
, pImageSurface
, rImage
,
959 void SalInstanceMenu::insert_separator(int pos
, const OUString
& rId
)
961 auto nInsertPos
= pos
== -1 ? MENU_APPEND
: pos
;
962 m_xMenu
->InsertSeparator(rId
, nInsertPos
);
964 void SalInstanceMenu::remove(const OUString
& rId
)
966 m_xMenu
->RemoveItem(m_xMenu
->GetItemPos(m_xMenu
->GetItemId(rId
)));
968 int SalInstanceMenu::n_children() const { return m_xMenu
->GetItemCount(); }
969 OUString
SalInstanceMenu::get_id(int pos
) const
971 return m_xMenu
->GetItemIdent(m_xMenu
->GetItemId(pos
));
973 PopupMenu
* SalInstanceMenu::getMenu() const { return m_xMenu
.get(); }
974 SalInstanceMenu::~SalInstanceMenu()
976 m_xMenu
->SetSelectHdl(Link
<::Menu
*, bool>());
977 if (m_bTakeOwnership
)
978 m_xMenu
.disposeAndClear();
981 IMPL_LINK_NOARG(SalInstanceMenu
, SelectMenuHdl
, ::Menu
*, bool)
983 signal_activate(m_xMenu
->GetCurItemIdent());
984 /* tdf#131333 Menu::Select depends on a false here to allow
985 propagating a submens's selected id to its parent menu to become its
988 without this, while gen menus already have propagated this to its parent
989 in MenuFloatingWindow::EndExecute, SalMenus as used under kf5/macOS
990 won't propagate the selected id
995 SalInstanceToolbar::SalInstanceToolbar(ToolBox
* pToolBox
, SalInstanceBuilder
* pBuilder
,
997 : SalInstanceWidget(pToolBox
, pBuilder
, bTakeOwnership
)
998 , m_xToolBox(pToolBox
)
1000 m_xToolBox
->SetSelectHdl(LINK(this, SalInstanceToolbar
, ClickHdl
));
1001 m_xToolBox
->SetDropdownClickHdl(LINK(this, SalInstanceToolbar
, DropdownClick
));
1004 void SalInstanceToolbar::set_item_sensitive(const OUString
& rIdent
, bool bSensitive
)
1006 m_xToolBox
->EnableItem(m_xToolBox
->GetItemId(rIdent
), bSensitive
);
1009 bool SalInstanceToolbar::get_item_sensitive(const OUString
& rIdent
) const
1011 return m_xToolBox
->IsItemEnabled(m_xToolBox
->GetItemId(rIdent
));
1014 void SalInstanceToolbar::set_item_visible(const OUString
& rIdent
, bool bVisible
)
1016 m_xToolBox
->ShowItem(m_xToolBox
->GetItemId(rIdent
), bVisible
);
1019 void SalInstanceToolbar::set_item_help_id(const OUString
& rIdent
, const OUString
& rHelpId
)
1021 m_xToolBox
->SetHelpId(m_xToolBox
->GetItemId(rIdent
), rHelpId
);
1024 bool SalInstanceToolbar::get_item_visible(const OUString
& rIdent
) const
1026 return m_xToolBox
->IsItemVisible(m_xToolBox
->GetItemId(rIdent
));
1029 void SalInstanceToolbar::set_item_active(const OUString
& rIdent
, bool bActive
)
1031 ToolBoxItemId nItemId
= m_xToolBox
->GetItemId(rIdent
);
1032 m_xToolBox
->CheckItem(nItemId
, bActive
);
1035 bool SalInstanceToolbar::get_item_active(const OUString
& rIdent
) const
1037 return m_xToolBox
->IsItemChecked(m_xToolBox
->GetItemId(rIdent
));
1040 void SalInstanceToolbar::set_menu_item_active(const OUString
& rIdent
, bool bActive
)
1042 ToolBoxItemId nItemId
= m_xToolBox
->GetItemId(rIdent
);
1043 assert(m_xToolBox
->GetItemBits(nItemId
) & ToolBoxItemBits::DROPDOWN
);
1047 m_sStartShowIdent
= m_xToolBox
->GetItemCommand(nItemId
);
1048 signal_toggle_menu(m_sStartShowIdent
);
1051 auto pFloat
= m_aFloats
[nItemId
];
1055 vcl::Window::GetDockingManager()->StartPopupMode(m_xToolBox
, pFloat
,
1056 FloatWinPopupFlags::GrabFocus
);
1058 vcl::Window::GetDockingManager()->EndPopupMode(pFloat
);
1060 auto pPopup
= m_aMenus
[nItemId
];
1065 tools::Rectangle aRect
= m_xToolBox
->GetItemRect(nItemId
);
1066 pPopup
->Execute(m_xToolBox
, aRect
, PopupMenuFlags::ExecuteDown
);
1069 pPopup
->EndExecute();
1072 m_sStartShowIdent
.clear();
1075 bool SalInstanceToolbar::get_menu_item_active(const OUString
& rIdent
) const
1077 ToolBoxItemId nItemId
= m_xToolBox
->GetItemId(rIdent
);
1078 assert(m_xToolBox
->GetItemBits(nItemId
) & ToolBoxItemBits::DROPDOWN
);
1080 if (rIdent
== m_sStartShowIdent
)
1083 auto aFloat
= m_aFloats
.find(nItemId
);
1084 if (aFloat
!= m_aFloats
.end())
1086 return vcl::Window::GetDockingManager()->IsInPopupMode(aFloat
->second
);
1089 auto aPopup
= m_aMenus
.find(nItemId
);
1090 if (aPopup
!= m_aMenus
.end())
1092 return PopupMenu::GetActivePopupMenu() == aPopup
->second
;
1098 void SalInstanceToolbar::set_item_popover(const OUString
& rIdent
, weld::Widget
* pPopover
)
1100 SalInstanceWidget
* pPopoverWidget
= dynamic_cast<SalInstanceWidget
*>(pPopover
);
1102 vcl::Window
* pFloat
= pPopoverWidget
? pPopoverWidget
->getWidget() : nullptr;
1105 pFloat
->AddEventListener(LINK(this, SalInstanceToolbar
, MenuToggleListener
));
1106 pFloat
->EnableDocking();
1109 ToolBoxItemId nId
= m_xToolBox
->GetItemId(rIdent
);
1110 auto xOldFloat
= m_aFloats
[nId
];
1113 xOldFloat
->RemoveEventListener(LINK(this, SalInstanceToolbar
, MenuToggleListener
));
1115 m_aFloats
[nId
] = pFloat
;
1116 m_aMenus
[nId
] = nullptr;
1119 void SalInstanceToolbar::set_item_menu(const OUString
& rIdent
, weld::Menu
* pMenu
)
1121 SalInstanceMenu
* pInstanceMenu
= dynamic_cast<SalInstanceMenu
*>(pMenu
);
1123 PopupMenu
* pPopup
= pInstanceMenu
? pInstanceMenu
->getMenu() : nullptr;
1125 ToolBoxItemId nId
= m_xToolBox
->GetItemId(rIdent
);
1126 m_aMenus
[nId
] = pPopup
;
1127 m_aFloats
[nId
] = nullptr;
1130 void SalInstanceToolbar::insert_item(int pos
, const OUString
& rId
)
1132 ToolBoxItemId
nId(pos
);
1133 m_xToolBox
->InsertItem(nId
, OUString(), rId
, ToolBoxItemBits::ICON_ONLY
);
1136 void SalInstanceToolbar::insert_separator(int pos
, const OUString
& /*rId*/)
1138 auto nInsertPos
= pos
== -1 ? ToolBox::APPEND
: pos
;
1139 m_xToolBox
->InsertSeparator(nInsertPos
, 5);
1142 int SalInstanceToolbar::get_n_items() const { return m_xToolBox
->GetItemCount(); }
1144 OUString
SalInstanceToolbar::get_item_ident(int nIndex
) const
1146 return m_xToolBox
->GetItemCommand(m_xToolBox
->GetItemId(nIndex
));
1149 void SalInstanceToolbar::set_item_ident(int nIndex
, const OUString
& rIdent
)
1151 return m_xToolBox
->SetItemCommand(m_xToolBox
->GetItemId(nIndex
), rIdent
);
1154 void SalInstanceToolbar::set_item_label(int nIndex
, const OUString
& rLabel
)
1156 m_xToolBox
->SetItemText(m_xToolBox
->GetItemId(nIndex
), rLabel
);
1159 OUString
SalInstanceToolbar::get_item_label(const OUString
& rIdent
) const
1161 return m_xToolBox
->GetItemText(m_xToolBox
->GetItemId(rIdent
));
1164 void SalInstanceToolbar::set_item_label(const OUString
& rIdent
, const OUString
& rLabel
)
1166 m_xToolBox
->SetItemText(m_xToolBox
->GetItemId(rIdent
), rLabel
);
1169 void SalInstanceToolbar::set_item_icon_name(const OUString
& rIdent
, const OUString
& rIconName
)
1171 m_xToolBox
->SetItemImage(m_xToolBox
->GetItemId(rIdent
), Image(StockImage::Yes
, rIconName
));
1174 void SalInstanceToolbar::set_item_image_mirrored(const OUString
& rIdent
, bool bMirrored
)
1176 m_xToolBox
->SetItemImageMirrorMode(m_xToolBox
->GetItemId(rIdent
), bMirrored
);
1179 void SalInstanceToolbar::set_item_image(const OUString
& rIdent
,
1180 const css::uno::Reference
<css::graphic::XGraphic
>& rIcon
)
1182 m_xToolBox
->SetItemImage(m_xToolBox
->GetItemId(rIdent
), Image(rIcon
));
1185 void SalInstanceToolbar::set_item_image(const OUString
& rIdent
, VirtualDevice
* pDevice
)
1188 m_xToolBox
->SetItemImage(m_xToolBox
->GetItemId(rIdent
), createImage(*pDevice
));
1190 m_xToolBox
->SetItemImage(m_xToolBox
->GetItemId(rIdent
), Image());
1193 void SalInstanceToolbar::set_item_image(int nIndex
,
1194 const css::uno::Reference
<css::graphic::XGraphic
>& rIcon
)
1196 m_xToolBox
->SetItemImage(m_xToolBox
->GetItemId(nIndex
), Image(rIcon
));
1199 void SalInstanceToolbar::set_item_tooltip_text(int nIndex
, const OUString
& rTip
)
1201 m_xToolBox
->SetQuickHelpText(m_xToolBox
->GetItemId(nIndex
), rTip
);
1204 void SalInstanceToolbar::set_item_tooltip_text(const OUString
& rIdent
, const OUString
& rTip
)
1206 m_xToolBox
->SetQuickHelpText(m_xToolBox
->GetItemId(rIdent
), rTip
);
1209 OUString
SalInstanceToolbar::get_item_tooltip_text(const OUString
& rIdent
) const
1211 return m_xToolBox
->GetQuickHelpText(m_xToolBox
->GetItemId(rIdent
));
1214 vcl::ImageType
SalInstanceToolbar::get_icon_size() const { return m_xToolBox
->GetImageSize(); }
1216 void SalInstanceToolbar::set_icon_size(vcl::ImageType eType
)
1218 ToolBoxButtonSize eButtonSize
= ToolBoxButtonSize::DontCare
;
1221 case vcl::ImageType::Size16
:
1222 eButtonSize
= ToolBoxButtonSize::Small
;
1224 case vcl::ImageType::Size26
:
1225 eButtonSize
= ToolBoxButtonSize::Large
;
1227 case vcl::ImageType::Size32
:
1228 eButtonSize
= ToolBoxButtonSize::Size32
;
1231 if (m_xToolBox
->GetToolboxButtonSize() != eButtonSize
)
1233 m_xToolBox
->SetToolboxButtonSize(eButtonSize
);
1234 m_xToolBox
->queue_resize();
1238 sal_uInt16
SalInstanceToolbar::get_modifier_state() const { return m_xToolBox
->GetModifier(); }
1240 int SalInstanceToolbar::get_drop_index(const Point
& rPoint
) const
1242 auto nRet
= m_xToolBox
->GetItemPos(rPoint
);
1243 if (nRet
== ToolBox::ITEM_NOTFOUND
)
1248 SalInstanceToolbar::~SalInstanceToolbar()
1250 m_xToolBox
->SetDropdownClickHdl(Link
<ToolBox
*, void>());
1251 m_xToolBox
->SetSelectHdl(Link
<ToolBox
*, void>());
1254 IMPL_LINK_NOARG(SalInstanceToolbar
, ClickHdl
, ToolBox
*, void)
1256 ToolBoxItemId nItemId
= m_xToolBox
->GetCurItemId();
1257 signal_clicked(m_xToolBox
->GetItemCommand(nItemId
));
1260 IMPL_LINK_NOARG(SalInstanceToolbar
, DropdownClick
, ToolBox
*, void)
1262 ToolBoxItemId nItemId
= m_xToolBox
->GetCurItemId();
1263 set_menu_item_active(m_xToolBox
->GetItemCommand(nItemId
), true);
1266 IMPL_LINK(SalInstanceToolbar
, MenuToggleListener
, VclWindowEvent
&, rEvent
, void)
1268 if (rEvent
.GetId() == VclEventId::WindowEndPopupMode
)
1270 for (const auto& rFloat
: m_aFloats
)
1272 if (rEvent
.GetWindow() == rFloat
.second
)
1274 ToolBoxItemId nItemId
= rFloat
.first
;
1275 signal_toggle_menu(m_xToolBox
->GetItemCommand(nItemId
));
1284 class SalInstanceSizeGroup
: public weld::SizeGroup
1287 std::shared_ptr
<VclSizeGroup
> m_xGroup
;
1290 SalInstanceSizeGroup()
1291 : m_xGroup(std::make_shared
<VclSizeGroup
>())
1294 virtual void add_widget(weld::Widget
* pWidget
) override
1296 SalInstanceWidget
* pVclWidget
= dynamic_cast<SalInstanceWidget
*>(pWidget
);
1297 assert(pVclWidget
&& pVclWidget
->getWidget());
1298 pVclWidget
->getWidget()->add_to_size_group(m_xGroup
);
1300 virtual void set_mode(VclSizeGroupMode eMode
) override
{ m_xGroup
->set_mode(eMode
); }
1304 void SalInstanceContainer::connect_container_focus_changed(const Link
<Container
&, void>& rLink
)
1306 ensure_event_listener();
1307 weld::Container::connect_container_focus_changed(rLink
);
1310 void SalInstanceContainer::HandleEventListener(VclWindowEvent
& rEvent
)
1312 if (rEvent
.GetId() == VclEventId::WindowActivate
1313 || rEvent
.GetId() == VclEventId::WindowDeactivate
)
1315 signal_container_focus_changed();
1318 SalInstanceWidget::HandleEventListener(rEvent
);
1321 SalInstanceContainer::SalInstanceContainer(vcl::Window
* pContainer
, SalInstanceBuilder
* pBuilder
,
1322 bool bTakeOwnership
)
1323 : SalInstanceWidget(pContainer
, pBuilder
, bTakeOwnership
)
1324 , m_xContainer(pContainer
)
1328 void SalInstanceContainer::move(weld::Widget
* pWidget
, weld::Container
* pNewParent
)
1330 SalInstanceWidget
* pVclWidget
= dynamic_cast<SalInstanceWidget
*>(pWidget
);
1332 SalInstanceContainer
* pNewVclParent
= dynamic_cast<SalInstanceContainer
*>(pNewParent
);
1333 assert(!pNewParent
|| pNewVclParent
);
1334 vcl::Window
* pVclWindow
= pVclWidget
->getWidget();
1337 vcl::Window
* pNew
= pNewVclParent
->getWidget();
1338 if (!pNew
->isDisposed())
1339 pVclWindow
->SetParent(pNewVclParent
->getWidget());
1341 SAL_WARN("vcl", "ignoring move because new parent is already disposed");
1346 pVclWindow
->SetParent(ImplGetDefaultWindow());
1350 void SalInstanceContainer::child_grab_focus()
1352 m_xContainer
->GrabFocus();
1353 if (vcl::Window
* pFirstChild
= m_xContainer
->ImplGetDlgWindow(0, GetDlgWindowType::First
))
1354 pFirstChild
->ImplControlFocus();
1357 css::uno::Reference
<css::awt::XWindow
> SalInstanceContainer::CreateChildFrame()
1359 auto xPage
= VclPtr
<VclBin
>::Create(m_xContainer
.get());
1360 xPage
->set_expand(true);
1362 return css::uno::Reference
<css::awt::XWindow
>(xPage
->GetComponentInterface(),
1363 css::uno::UNO_QUERY
);
1366 std::unique_ptr
<weld::Container
> SalInstanceWidget::weld_parent() const
1368 vcl::Window
* pParent
= m_xWidget
->GetParent();
1371 return std::make_unique
<SalInstanceContainer
>(pParent
, m_pBuilder
, false);
1374 void SalInstanceWidget::DoRecursivePaint(vcl::Window
* pWindow
, const Point
& rRenderLogicPos
,
1375 OutputDevice
& rOutput
)
1378 bool bOldMapModeEnabled
= pWindow
->IsMapModeEnabled();
1380 if (pWindow
->GetMapMode().GetMapUnit() != rOutput
.GetMapMode().GetMapUnit())
1382 // This is needed for e.g. the scrollbar in writer comments in margins that has its map unit in pixels
1383 // as seen with bin/run gtktiledviewer --enable-tiled-annotations on a document containing a comment
1384 // long enough to need a scrollbar
1385 pWindow
->EnableMapMode();
1386 MapMode aMapMode
= pWindow
->GetMapMode();
1387 aMapMode
.SetMapUnit(rOutput
.GetMapMode().GetMapUnit());
1388 aMapMode
.SetScaleX(rOutput
.GetMapMode().GetScaleX());
1389 aMapMode
.SetScaleY(rOutput
.GetMapMode().GetScaleY());
1390 pWindow
->SetMapMode(aMapMode
);
1393 VclPtr
<VirtualDevice
> xOutput(VclPtr
<VirtualDevice
>::Create(DeviceFormat::WITHOUT_ALPHA
));
1394 Size
aChildSizePixel(pWindow
->GetSizePixel());
1395 xOutput
->SetOutputSizePixel(aChildSizePixel
);
1397 MapMode
aMapMode(xOutput
->GetMapMode());
1398 aMapMode
.SetMapUnit(rOutput
.GetMapMode().GetMapUnit());
1399 aMapMode
.SetScaleX(rOutput
.GetMapMode().GetScaleX());
1400 aMapMode
.SetScaleY(rOutput
.GetMapMode().GetScaleY());
1401 xOutput
->SetMapMode(aMapMode
);
1403 Size
aTempLogicSize(xOutput
->PixelToLogic(aChildSizePixel
));
1404 Size
aRenderLogicSize(rOutput
.PixelToLogic(aChildSizePixel
));
1406 switch (rOutput
.GetOutDevType())
1410 xOutput
->DrawOutDev(Point(), aTempLogicSize
, rRenderLogicPos
, aRenderLogicSize
,
1413 case OUTDEV_PRINTER
:
1415 xOutput
->SetBackground(rOutput
.GetBackground());
1420 //set ReallyVisible to match Visible, we restore the original state after Paint
1421 WindowImpl
* pImpl
= pWindow
->ImplGetWindowImpl();
1422 bool bRVisible
= pImpl
->mbReallyVisible
;
1423 pImpl
->mbReallyVisible
= pWindow
->IsVisible();
1425 pWindow
->ApplySettings(*xOutput
);
1426 pWindow
->Paint(*xOutput
, tools::Rectangle(Point(), pWindow
->PixelToLogic(aChildSizePixel
)));
1428 pImpl
->mbReallyVisible
= bRVisible
;
1430 switch (rOutput
.GetOutDevType())
1434 rOutput
.DrawOutDev(rRenderLogicPos
, aRenderLogicSize
, Point(), aTempLogicSize
,
1437 case OUTDEV_PRINTER
:
1439 rOutput
.DrawBitmapEx(rRenderLogicPos
, aRenderLogicSize
,
1440 xOutput
->GetBitmapEx(Point(), aTempLogicSize
));
1444 bool bHasMirroredGraphics
= pWindow
->GetOutDev()->HasMirroredGraphics();
1446 xOutput
.disposeAndClear();
1448 pWindow
->EnableMapMode(bOldMapModeEnabled
);
1451 for (vcl::Window
* pChild
= pWindow
->GetWindow(GetWindowType::FirstChild
); pChild
;
1452 pChild
= pChild
->GetWindow(GetWindowType::Next
))
1454 if (!pChild
->IsVisible())
1458 = pChild
->GetOutDev()->GetOutOffXPixel() - pWindow
->GetOutDev()->GetOutOffXPixel();
1459 if (bHasMirroredGraphics
)
1460 nDeltaX
= pWindow
->GetOutDev()->GetOutputWidthPixel() - nDeltaX
1461 - pChild
->GetOutDev()->GetOutputWidthPixel();
1464 = pChild
->GetOutDev()->GetOutOffYPixel() - pWindow
->GetOutDev()->GetOutOffYPixel();
1466 Point
aPos(rRenderLogicPos
);
1467 aPos
+= Point(nDeltaX
, nDeltaY
);
1469 DoRecursivePaint(pChild
, aPos
, rOutput
);
1473 void SalInstanceWidget::draw(OutputDevice
& rOutput
, const Point
& rPos
, const Size
& rSizePixel
)
1475 Size
aOrigSize(m_xWidget
->GetSizePixel());
1476 bool bChangeSize
= aOrigSize
!= rSizePixel
;
1478 m_xWidget
->SetSizePixel(rSizePixel
);
1480 DoRecursivePaint(m_xWidget
, rPos
, rOutput
);
1483 m_xWidget
->SetSizePixel(aOrigSize
);
1486 SalInstanceBox::SalInstanceBox(VclBox
* pContainer
, SalInstanceBuilder
* pBuilder
,
1487 bool bTakeOwnership
)
1488 : SalInstanceContainer(pContainer
, pBuilder
, bTakeOwnership
)
1489 , m_xBox(pContainer
)
1492 void SalInstanceBox::reorder_child(weld::Widget
* pWidget
, int nNewPosition
)
1494 SalInstanceWidget
* pVclWidget
= dynamic_cast<SalInstanceWidget
*>(pWidget
);
1496 pVclWidget
->getWidget()->reorderWithinParent(nNewPosition
);
1499 void SalInstanceBox::sort_native_button_order() { ::sort_native_button_order(*m_xBox
); }
1503 void CollectChildren(const vcl::Window
& rCurrent
, const basegfx::B2IPoint
& rTopLeft
,
1504 weld::ScreenShotCollection
& rControlDataCollection
)
1506 if (!rCurrent
.IsVisible())
1509 const Point
aCurrentPos(rCurrent
.GetPosPixel());
1510 const Size
aCurrentSize(rCurrent
.GetSizePixel());
1511 const basegfx::B2IPoint
aCurrentTopLeft(rTopLeft
.getX() + aCurrentPos
.X(),
1512 rTopLeft
.getY() + aCurrentPos
.Y());
1513 const basegfx::B2IRange
aCurrentRange(
1515 aCurrentTopLeft
+ basegfx::B2IPoint(aCurrentSize
.Width(), aCurrentSize
.Height()));
1517 if (!aCurrentRange
.isEmpty())
1519 rControlDataCollection
.emplace_back(rCurrent
.GetHelpId(), aCurrentRange
);
1522 for (sal_uInt16
a(0); a
< rCurrent
.GetChildCount(); a
++)
1524 vcl::Window
* pChild
= rCurrent
.GetChild(a
);
1525 if (nullptr != pChild
)
1527 CollectChildren(*pChild
, aCurrentTopLeft
, rControlDataCollection
);
1533 void SalInstanceWindow::override_child_help(vcl::Window
* pParent
)
1535 for (vcl::Window
* pChild
= pParent
->GetWindow(GetWindowType::FirstChild
); pChild
;
1536 pChild
= pChild
->GetWindow(GetWindowType::Next
))
1537 override_child_help(pChild
);
1538 pParent
->SetHelpHdl(LINK(this, SalInstanceWindow
, HelpHdl
));
1541 void SalInstanceWindow::clear_child_help(vcl::Window
* pParent
)
1543 for (vcl::Window
* pChild
= pParent
->GetWindow(GetWindowType::FirstChild
); pChild
;
1544 pChild
= pChild
->GetWindow(GetWindowType::Next
))
1545 clear_child_help(pChild
);
1546 pParent
->SetHelpHdl(Link
<vcl::Window
&, bool>());
1549 SalInstanceWindow::SalInstanceWindow(vcl::Window
* pWindow
, SalInstanceBuilder
* pBuilder
,
1550 bool bTakeOwnership
)
1551 : SalInstanceContainer(pWindow
, pBuilder
, bTakeOwnership
)
1552 , m_xWindow(pWindow
)
1554 // tdf#129745 only override child help for the normal case, not for
1555 // m_pBuilder of null which is the toplevel application frame case.
1557 override_child_help(m_xWindow
);
1560 void SalInstanceWindow::set_title(const OUString
& rTitle
) { m_xWindow
->SetText(rTitle
); }
1562 OUString
SalInstanceWindow::get_title() const { return m_xWindow
->GetText(); }
1564 css::uno::Reference
<css::awt::XWindow
> SalInstanceWindow::GetXWindow()
1566 css::uno::Reference
<css::awt::XWindow
> xWindow(m_xWindow
->GetComponentInterface(),
1567 css::uno::UNO_QUERY
);
1573 void resize_to_request(vcl::Window
* pWindow
)
1575 if (SystemWindow
* pSysWin
= dynamic_cast<SystemWindow
*>(pWindow
))
1577 pSysWin
->setOptimalLayoutSize(true);
1580 if (DockingWindow
* pDockWin
= dynamic_cast<DockingWindow
*>(pWindow
))
1582 pDockWin
->setOptimalLayoutSize();
1585 assert(false && "must be system or docking window");
1589 void SalInstanceWindow::resize_to_request() { ::resize_to_request(m_xWindow
.get()); }
1591 void SalInstanceWindow::set_modal(bool bModal
) { m_xWindow
->ImplGetFrame()->SetModal(bModal
); }
1593 bool SalInstanceWindow::get_modal() const { return m_xWindow
->ImplGetFrame()->GetModal(); }
1595 void SalInstanceWindow::window_move(int x
, int y
) { m_xWindow
->SetPosPixel(Point(x
, y
)); }
1597 Size
SalInstanceWindow::get_size() const { return m_xWindow
->GetSizePixel(); }
1599 Point
SalInstanceWindow::get_position() const { return m_xWindow
->GetPosPixel(); }
1601 tools::Rectangle
SalInstanceWindow::get_monitor_workarea() const
1603 return m_xWindow
->GetDesktopRectPixel();
1606 void SalInstanceWindow::set_centered_on_parent(bool /*bTrackGeometryRequests*/)
1608 if (vcl::Window
* pParent
= m_xWidget
->GetParent())
1610 Size
aParentGeometry(pParent
->GetSizePixel());
1611 Size
aGeometry(m_xWidget
->get_preferred_size());
1612 auto nX
= (aParentGeometry
.Width() - aGeometry
.Width()) / 2;
1613 auto nY
= (aParentGeometry
.Height() - aGeometry
.Height()) / 2;
1614 m_xWidget
->SetPosPixel(Point(nX
, nY
));
1618 bool SalInstanceWindow::get_resizable() const { return m_xWindow
->GetStyle() & WB_SIZEABLE
; }
1620 bool SalInstanceWindow::has_toplevel_focus() const { return m_xWindow
->HasChildPathFocus(); }
1622 void SalInstanceWindow::present()
1624 m_xWindow
->ToTop(ToTopFlags::RestoreWhenMin
| ToTopFlags::ForegroundTask
);
1627 void SalInstanceWindow::implResetDefault(const vcl::Window
* _pWindow
)
1629 vcl::Window
* pChildLoop
= _pWindow
->GetWindow(GetWindowType::FirstChild
);
1632 // does the window participate in the tabbing order?
1633 if (pChildLoop
->GetStyle() & WB_DIALOGCONTROL
)
1634 implResetDefault(pChildLoop
);
1637 WindowType eType
= pChildLoop
->GetType();
1638 if ((WindowType::PUSHBUTTON
== eType
) || (WindowType::OKBUTTON
== eType
)
1639 || (WindowType::CANCELBUTTON
== eType
) || (WindowType::HELPBUTTON
== eType
)
1640 || (WindowType::IMAGEBUTTON
== eType
) || (WindowType::MENUBUTTON
== eType
)
1641 || (WindowType::MOREBUTTON
== eType
))
1643 pChildLoop
->SetStyle(pChildLoop
->GetStyle() & ~WB_DEFBUTTON
);
1647 pChildLoop
= pChildLoop
->GetWindow(GetWindowType::Next
);
1651 void SalInstanceWindow::recursively_unset_default_buttons() { implResetDefault(m_xWindow
.get()); }
1653 void SalInstanceWindow::change_default_widget(weld::Widget
* pOld
, weld::Widget
* pNew
)
1655 SalInstanceWidget
* pVclNew
= dynamic_cast<SalInstanceWidget
*>(pNew
);
1656 vcl::Window
* pWidgetNew
= pVclNew
? pVclNew
->getWidget() : nullptr;
1657 SalInstanceWidget
* pVclOld
= dynamic_cast<SalInstanceWidget
*>(pOld
);
1658 vcl::Window
* pWidgetOld
= pVclOld
? pVclOld
->getWidget() : nullptr;
1660 pWidgetOld
->set_property("has-default", OUString::boolean(false));
1662 recursively_unset_default_buttons();
1664 pWidgetNew
->set_property("has-default", OUString::boolean(true));
1667 bool SalInstanceWindow::is_default_widget(const weld::Widget
* pCandidate
) const
1669 const SalInstanceWidget
* pVclCandidate
= dynamic_cast<const SalInstanceWidget
*>(pCandidate
);
1670 vcl::Window
* pWidget
= pVclCandidate
? pVclCandidate
->getWidget() : nullptr;
1671 return pWidget
&& pWidget
->GetStyle() & WB_DEFBUTTON
;
1674 void SalInstanceWindow::set_window_state(const OUString
& rStr
)
1676 SystemWindow
* pSysWin
= dynamic_cast<SystemWindow
*>(m_xWindow
.get());
1678 pSysWin
->SetWindowState(rStr
);
1681 OUString
SalInstanceWindow::get_window_state(vcl::WindowDataMask nMask
) const
1683 SystemWindow
* pSysWin
= dynamic_cast<SystemWindow
*>(m_xWindow
.get());
1685 return pSysWin
->GetWindowState(nMask
);
1688 SystemEnvData
SalInstanceWindow::get_system_data() const { return *m_xWindow
->GetSystemData(); }
1690 VclPtr
<VirtualDevice
> SalInstanceWindow::screenshot()
1692 SystemWindow
* pSysWin
= dynamic_cast<SystemWindow
*>(m_xWindow
.get());
1694 return pSysWin
->createScreenshot();
1697 weld::ScreenShotCollection
SalInstanceWindow::collect_screenshot_data()
1699 weld::ScreenShotCollection aRet
;
1701 // collect all children. Choose start pos to be negative
1702 // of target dialog's position to get all positions relative to (0,0)
1703 const Point
aParentPos(m_xWindow
->GetPosPixel());
1704 const basegfx::B2IPoint
aTopLeft(-aParentPos
.X(), -aParentPos
.Y());
1705 CollectChildren(*m_xWindow
, aTopLeft
, aRet
);
1710 const vcl::ILibreOfficeKitNotifier
* SalInstanceWindow::GetLOKNotifier()
1712 return m_xWindow
? m_xWindow
->GetLOKNotifier() : nullptr;
1715 SalInstanceWindow::~SalInstanceWindow()
1717 // tdf#129745 only undo overriding child help for the normal case, not for
1718 // m_pBuilder of null which is the toplevel application frame case.
1720 clear_child_help(m_xWindow
);
1723 IMPL_LINK_NOARG(SalInstanceWindow
, HelpHdl
, vcl::Window
&, bool)
1729 typedef std::set
<VclPtr
<vcl::Window
>> winset
;
1733 void hideUnless(const vcl::Window
* pTop
, const winset
& rVisibleWidgets
,
1734 std::vector
<VclPtr
<vcl::Window
>>& rWasVisibleWidgets
)
1736 for (vcl::Window
* pChild
= pTop
->GetWindow(GetWindowType::FirstChild
); pChild
;
1737 pChild
= pChild
->GetWindow(GetWindowType::Next
))
1739 if (!pChild
->IsVisible())
1741 if (rVisibleWidgets
.find(pChild
) == rVisibleWidgets
.end())
1743 rWasVisibleWidgets
.emplace_back(pChild
);
1746 else if (isContainerWindow(pChild
))
1748 hideUnless(pChild
, rVisibleWidgets
, rWasVisibleWidgets
);
1754 SalInstanceDialog::SalInstanceDialog(::Dialog
* pDialog
, SalInstanceBuilder
* pBuilder
,
1755 bool bTakeOwnership
)
1756 : SalInstanceWindow(pDialog
, pBuilder
, bTakeOwnership
)
1757 , m_xDialog(pDialog
)
1758 , m_nOldEditWidthReq(0)
1759 , m_nOldBorderWidth(0)
1761 const bool bScreenshotMode(officecfg::Office::Common::Misc::ScreenshotMode::get());
1762 if (bScreenshotMode
)
1764 m_xDialog
->SetPopupMenuHdl(LINK(this, SalInstanceDialog
, PopupScreenShotMenuHdl
));
1768 bool SalInstanceDialog::runAsync(std::shared_ptr
<weld::DialogController
> aOwner
,
1769 const std::function
<void(sal_Int32
)>& rEndDialogFn
)
1771 VclAbstractDialog::AsyncContext aCtx
;
1772 aCtx
.mxOwnerDialogController
= aOwner
;
1773 aCtx
.maEndDialogFn
= rEndDialogFn
;
1774 VclButtonBox
* pActionArea
= m_xDialog
->get_action_area();
1776 sort_native_button_order(*pActionArea
);
1777 return m_xDialog
->StartExecuteAsync(aCtx
);
1780 bool SalInstanceDialog::runAsync(std::shared_ptr
<Dialog
> const& rxSelf
,
1781 const std::function
<void(sal_Int32
)>& rEndDialogFn
)
1783 assert(rxSelf
.get() == this);
1784 VclAbstractDialog::AsyncContext aCtx
;
1785 // In order to store a shared_ptr to ourself, we have to have been constructed by make_shared,
1786 // which is that rxSelf enforces.
1787 aCtx
.mxOwnerSelf
= rxSelf
;
1788 aCtx
.maEndDialogFn
= rEndDialogFn
;
1789 VclButtonBox
* pActionArea
= m_xDialog
->get_action_area();
1791 sort_native_button_order(*pActionArea
);
1792 return m_xDialog
->StartExecuteAsync(aCtx
);
1795 void SalInstanceDialog::collapse(weld::Widget
* pEdit
, weld::Widget
* pButton
)
1797 SalInstanceWidget
* pVclEdit
= dynamic_cast<SalInstanceWidget
*>(pEdit
);
1799 SalInstanceWidget
* pVclButton
= dynamic_cast<SalInstanceWidget
*>(pButton
);
1801 vcl::Window
* pRefEdit
= pVclEdit
->getWidget();
1802 vcl::Window
* pRefBtn
= pVclButton
? pVclButton
->getWidget() : nullptr;
1804 auto nOldEditWidth
= pRefEdit
->GetSizePixel().Width();
1805 m_nOldEditWidthReq
= pRefEdit
->get_width_request();
1807 //We want just pRefBtn and pRefEdit to be shown
1808 //mark widgets we want to be visible, starting with pRefEdit
1809 //and all its direct parents.
1810 winset aVisibleWidgets
;
1811 vcl::Window
* pContentArea
= m_xDialog
->get_content_area();
1812 for (vcl::Window
* pCandidate
= pRefEdit
;
1813 pCandidate
&& (pCandidate
!= pContentArea
&& pCandidate
->IsVisible());
1814 pCandidate
= pCandidate
->GetWindow(GetWindowType::RealParent
))
1816 aVisibleWidgets
.insert(pCandidate
);
1818 //same again with pRefBtn, except stop if there's a
1819 //shared parent in the existing widgets
1820 for (vcl::Window
* pCandidate
= pRefBtn
;
1821 pCandidate
&& (pCandidate
!= pContentArea
&& pCandidate
->IsVisible());
1822 pCandidate
= pCandidate
->GetWindow(GetWindowType::RealParent
))
1824 if (aVisibleWidgets
.insert(pCandidate
).second
)
1828 //hide everything except the aVisibleWidgets
1829 hideUnless(pContentArea
, aVisibleWidgets
, m_aHiddenWidgets
);
1831 // the insert function case has an initially hidden edit widget, so it has
1832 // not start size, so take larger of actual size and size request
1833 pRefEdit
->set_width_request(std::max(nOldEditWidth
, m_nOldEditWidthReq
));
1834 m_nOldBorderWidth
= m_xDialog
->get_border_width();
1835 m_xDialog
->set_border_width(0);
1836 if (vcl::Window
* pActionArea
= m_xDialog
->get_action_area())
1837 pActionArea
->Hide();
1838 m_xDialog
->setOptimalLayoutSize(true);
1839 m_xRefEdit
= pRefEdit
;
1842 void SalInstanceDialog::undo_collapse()
1844 // All others: Show();
1845 for (VclPtr
<vcl::Window
> const& pWindow
: m_aHiddenWidgets
)
1849 m_aHiddenWidgets
.clear();
1851 m_xRefEdit
->set_width_request(m_nOldEditWidthReq
);
1853 m_xDialog
->set_border_width(m_nOldBorderWidth
);
1854 if (vcl::Window
* pActionArea
= m_xDialog
->get_action_area())
1855 pActionArea
->Show();
1856 m_xDialog
->setOptimalLayoutSize(true);
1859 void SalInstanceDialog::SetInstallLOKNotifierHdl(
1860 const Link
<void*, vcl::ILibreOfficeKitNotifier
*>& rLink
)
1862 m_xDialog
->SetInstallLOKNotifierHdl(rLink
);
1865 int SalInstanceDialog::run()
1867 VclButtonBox
* pActionArea
= m_xDialog
->get_action_area();
1869 sort_native_button_order(*pActionArea
);
1870 return m_xDialog
->Execute();
1873 void SalInstanceDialog::response(int nResponse
) { m_xDialog
->EndDialog(nResponse
); }
1875 void SalInstanceDialog::add_button(const OUString
& rText
, int nResponse
, const OUString
& rHelpId
)
1877 VclButtonBox
* pBox
= m_xDialog
->get_action_area();
1878 VclPtr
<PushButton
> xButton(
1879 VclPtr
<PushButton
>::Create(pBox
, WB_CLIPCHILDREN
| WB_CENTER
| WB_VCENTER
));
1880 xButton
->SetText(rText
);
1881 xButton
->SetHelpId(rHelpId
);
1886 xButton
->set_id("ok");
1889 xButton
->set_id("close");
1892 xButton
->set_id("cancel");
1895 xButton
->set_id("yes");
1898 xButton
->set_id("no");
1903 m_xDialog
->add_button(xButton
, nResponse
, true);
1906 void SalInstanceDialog::set_modal(bool bModal
)
1908 if (get_modal() == bModal
)
1910 m_xDialog
->SetModalInputMode(bModal
);
1913 bool SalInstanceDialog::get_modal() const { return m_xDialog
->IsModalInputMode(); }
1915 void SalInstanceDialog::set_default_response(int nResponse
)
1917 m_xDialog
->set_default_response(nResponse
);
1920 weld::Container
* SalInstanceDialog::weld_content_area()
1922 return new SalInstanceContainer(m_xDialog
->get_content_area(), m_pBuilder
, false);
1925 IMPL_LINK(SalInstanceDialog
, PopupScreenShotMenuHdl
, const CommandEvent
&, rCEvt
, bool)
1927 if (CommandEventId::ContextMenu
== rCEvt
.GetCommand())
1929 const Point
aMenuPos(rCEvt
.GetMousePosPixel());
1930 ScopedVclPtrInstance
<PopupMenu
> aMenu
;
1931 sal_uInt16
nLocalID(1);
1933 aMenu
->InsertItem(nLocalID
, VclResId(SV_BUTTONTEXT_SCREENSHOT
));
1934 aMenu
->SetHelpText(nLocalID
, VclResId(SV_HELPTEXT_SCREENSHOT
));
1935 aMenu
->SetHelpId(nLocalID
, "InteractiveScreenshotMode");
1936 aMenu
->EnableItem(nLocalID
);
1938 const sal_uInt16
nId(aMenu
->Execute(m_xDialog
, aMenuPos
));
1940 // 0 == no selection (so not usable as ID)
1943 // open screenshot annotation dialog
1944 VclAbstractDialogFactory
* pFact
= VclAbstractDialogFactory::Create();
1945 VclPtr
<AbstractScreenshotAnnotationDlg
> pTmp
1946 = pFact
->CreateScreenshotAnnotationDlg(*this);
1947 ScopedVclPtr
<AbstractScreenshotAnnotationDlg
> pDialog(pTmp
);
1951 // currently just execute the dialog, no need to do
1952 // different things for ok/cancel. This may change later,
1953 // for that case use 'if (pDlg->Execute() == RET_OK)'
1958 // consume event when:
1959 // - CommandEventId::ContextMenu
1960 // - bScreenshotMode
1967 SalInstanceMessageDialog::SalInstanceMessageDialog(::MessageDialog
* pDialog
,
1968 SalInstanceBuilder
* pBuilder
,
1969 bool bTakeOwnership
)
1970 : SalInstanceDialog(pDialog
, pBuilder
, bTakeOwnership
)
1971 , m_xMessageDialog(pDialog
)
1975 void SalInstanceMessageDialog::set_primary_text(const OUString
& rText
)
1977 m_xMessageDialog
->set_primary_text(rText
);
1980 OUString
SalInstanceMessageDialog::get_primary_text() const
1982 return m_xMessageDialog
->get_primary_text();
1985 void SalInstanceMessageDialog::set_secondary_text(const OUString
& rText
)
1987 m_xMessageDialog
->set_secondary_text(rText
);
1990 OUString
SalInstanceMessageDialog::get_secondary_text() const
1992 return m_xMessageDialog
->get_secondary_text();
1995 weld::Container
* SalInstanceMessageDialog::weld_message_area()
1997 return new SalInstanceContainer(m_xMessageDialog
->get_message_area(), m_pBuilder
, false);
2000 int SalInstanceAssistant::find_page(std::u16string_view rIdent
) const
2002 for (size_t i
= 0; i
< m_aAddedPages
.size(); ++i
)
2004 if (m_aAddedPages
[i
]->get_id() == rIdent
)
2010 int SalInstanceAssistant::find_id(int nId
) const
2012 for (size_t i
= 0; i
< m_aIds
.size(); ++i
)
2014 if (nId
== m_aIds
[i
])
2020 SalInstanceAssistant::SalInstanceAssistant(vcl::RoadmapWizard
* pDialog
,
2021 SalInstanceBuilder
* pBuilder
, bool bTakeOwnership
)
2022 : SalInstanceDialog(pDialog
, pBuilder
, bTakeOwnership
)
2023 , m_xWizard(pDialog
)
2024 , m_aUpdateRoadmapIdle("SalInstanceAssistant m_aUpdateRoadmapIdle")
2026 m_xWizard
->SetItemSelectHdl(LINK(this, SalInstanceAssistant
, OnRoadmapItemSelected
));
2028 m_aUpdateRoadmapIdle
.SetInvokeHandler(LINK(this, SalInstanceAssistant
, UpdateRoadmap_Hdl
));
2029 m_aUpdateRoadmapIdle
.SetPriority(TaskPriority::HIGHEST
);
2032 int SalInstanceAssistant::get_current_page() const { return find_id(m_xWizard
->GetCurLevel()); }
2034 int SalInstanceAssistant::get_n_pages() const { return m_aAddedPages
.size(); }
2036 OUString
SalInstanceAssistant::get_page_ident(int nPage
) const
2038 return m_aAddedPages
[nPage
]->get_id();
2041 OUString
SalInstanceAssistant::get_current_page_ident() const
2043 return get_page_ident(get_current_page());
2046 void SalInstanceAssistant::set_current_page(int nPage
)
2048 disable_notify_events();
2050 // take the first shown page as the size for all pages
2051 if (m_xWizard
->GetPageSizePixel().Width() == 0)
2054 for (int i
= 0, nPages
= get_n_pages(); i
< nPages
; ++i
)
2056 TabPage
* pPage
= m_xWizard
->GetPage(m_aIds
[i
]);
2058 Size
aPageSize(pPage
->get_preferred_size());
2059 if (aPageSize
.Width() > aFinalSize
.Width())
2060 aFinalSize
.setWidth(aPageSize
.Width());
2061 if (aPageSize
.Height() > aFinalSize
.Height())
2062 aFinalSize
.setHeight(aPageSize
.Height());
2064 m_xWizard
->SetPageSizePixel(aFinalSize
);
2067 (void)m_xWizard
->ShowPage(m_aIds
[nPage
]);
2068 enable_notify_events();
2071 void SalInstanceAssistant::set_current_page(const OUString
& rIdent
)
2073 int nIndex
= find_page(rIdent
);
2076 set_current_page(nIndex
);
2079 void SalInstanceAssistant::set_page_index(const OUString
& rIdent
, int nNewIndex
)
2081 int nOldIndex
= find_page(rIdent
);
2083 if (nOldIndex
== -1)
2086 if (nOldIndex
== nNewIndex
)
2089 disable_notify_events();
2091 auto entry
= std::move(m_aAddedPages
[nOldIndex
]);
2092 m_aAddedPages
.erase(m_aAddedPages
.begin() + nOldIndex
);
2093 m_aAddedPages
.insert(m_aAddedPages
.begin() + nNewIndex
, std::move(entry
));
2095 int nId
= m_aIds
[nOldIndex
];
2096 m_aIds
.erase(m_aIds
.begin() + nOldIndex
);
2097 m_aIds
.insert(m_aIds
.begin() + nNewIndex
, nId
);
2099 m_aUpdateRoadmapIdle
.Start();
2101 enable_notify_events();
2104 weld::Container
* SalInstanceAssistant::append_page(const OUString
& rIdent
)
2106 VclPtrInstance
<TabPage
> xPage(m_xWizard
);
2107 VclPtrInstance
<VclGrid
> xGrid(xPage
);
2108 xPage
->set_id(rIdent
);
2110 xGrid
->set_hexpand(true);
2111 xGrid
->set_vexpand(true);
2113 m_xWizard
->AddPage(xPage
);
2114 m_aIds
.push_back(m_aAddedPages
.size());
2115 m_xWizard
->SetPage(m_aIds
.back(), xPage
);
2116 m_aAddedPages
.push_back(xPage
);
2117 m_aAddedGrids
.push_back(xGrid
);
2119 m_aUpdateRoadmapIdle
.Start();
2121 m_aPages
.emplace_back(new SalInstanceContainer(xGrid
, m_pBuilder
, false));
2122 return m_aPages
.back().get();
2125 OUString
SalInstanceAssistant::get_page_title(const OUString
& rIdent
) const
2127 int nIndex
= find_page(rIdent
);
2130 return m_aAddedPages
[nIndex
]->GetText();
2133 void SalInstanceAssistant::set_page_title(const OUString
& rIdent
, const OUString
& rTitle
)
2135 int nIndex
= find_page(rIdent
);
2138 if (m_aAddedPages
[nIndex
]->GetText() != rTitle
)
2140 disable_notify_events();
2141 m_aAddedPages
[nIndex
]->SetText(rTitle
);
2142 m_aUpdateRoadmapIdle
.Start();
2143 enable_notify_events();
2147 void SalInstanceAssistant::set_page_sensitive(const OUString
& rIdent
, bool bSensitive
)
2149 int nIndex
= find_page(rIdent
);
2152 if (m_aAddedPages
[nIndex
]->IsEnabled() != bSensitive
)
2154 disable_notify_events();
2155 m_aAddedPages
[nIndex
]->Enable(bSensitive
);
2156 m_aUpdateRoadmapIdle
.Start();
2157 enable_notify_events();
2161 void SalInstanceAssistant::set_page_side_help_id(const OUString
& rHelpId
)
2163 m_xWizard
->SetRoadmapHelpId(rHelpId
);
2166 void SalInstanceAssistant::set_page_side_image(const OUString
& rImage
)
2168 m_xWizard
->SetRoadmapBitmap(createImage(rImage
).GetBitmapEx());
2171 SalInstanceAssistant::~SalInstanceAssistant()
2173 for (auto& rGrid
: m_aAddedGrids
)
2174 rGrid
.disposeAndClear();
2175 for (auto& rPage
: m_aAddedPages
)
2176 rPage
.disposeAndClear();
2179 IMPL_LINK_NOARG(SalInstanceAssistant
, OnRoadmapItemSelected
, LinkParamNone
*, void)
2181 if (notify_events_disabled())
2183 auto nCurItemId
= m_xWizard
->GetCurrentRoadmapItemID();
2184 int nPageIndex(find_id(nCurItemId
));
2185 if (!signal_jump_page(get_page_ident(nPageIndex
)) && nCurItemId
!= m_xWizard
->GetCurLevel())
2186 m_xWizard
->SelectRoadmapItemByID(m_xWizard
->GetCurLevel());
2189 IMPL_LINK_NOARG(SalInstanceAssistant
, UpdateRoadmap_Hdl
, Timer
*, void)
2191 disable_notify_events();
2193 m_xWizard
->DeleteRoadmapItems();
2196 for (size_t i
= 0; i
< m_aAddedPages
.size(); ++i
)
2198 const OUString
& rLabel
= m_aAddedPages
[i
]->GetText();
2199 bool bSensitive
= m_aAddedPages
[i
]->IsEnabled();
2200 if (rLabel
.isEmpty())
2202 m_xWizard
->InsertRoadmapItem(nPos
++, rLabel
, m_aIds
[i
], bSensitive
);
2205 m_xWizard
->SelectRoadmapItemByID(m_aIds
[get_current_page()], false);
2207 m_xWizard
->ShowRoadmap(nPos
!= 0);
2209 enable_notify_events();
2212 SalInstanceFrame::SalInstanceFrame(VclFrame
* pFrame
, SalInstanceBuilder
* pBuilder
,
2213 bool bTakeOwnership
)
2214 : SalInstanceContainer(pFrame
, pBuilder
, bTakeOwnership
)
2219 void SalInstanceFrame::set_label(const OUString
& rText
) { m_xFrame
->set_label(rText
); }
2221 OUString
SalInstanceFrame::get_label() const { return m_xFrame
->get_label(); }
2225 class SalInstancePaned
: public SalInstanceContainer
, public virtual weld::Paned
2228 VclPtr
<VclPaned
> m_xPaned
;
2231 SalInstancePaned(VclPaned
* pPaned
, SalInstanceBuilder
* pBuilder
, bool bTakeOwnership
)
2232 : SalInstanceContainer(pPaned
, pBuilder
, bTakeOwnership
)
2237 virtual void set_position(int nPos
) override
{ m_xPaned
->set_position(nPos
); }
2239 virtual int get_position() const override
{ return m_xPaned
->get_position(); }
2243 void SalInstanceScrolledWindow::customize_scrollbars(ScrollBar
& rScrollBar
,
2244 const Color
& rButtonTextColor
,
2245 const Color
& rBackgroundColor
,
2246 const Color
& rShadowColor
,
2247 const Color
& rFaceColor
)
2249 rScrollBar
.EnableNativeWidget(false);
2250 AllSettings aSettings
= rScrollBar
.GetSettings();
2251 StyleSettings aStyleSettings
= aSettings
.GetStyleSettings();
2252 aStyleSettings
.SetButtonTextColor(rButtonTextColor
);
2253 aStyleSettings
.SetCheckedColor(rBackgroundColor
); // background
2254 aStyleSettings
.SetShadowColor(rShadowColor
);
2255 aStyleSettings
.SetFaceColor(rFaceColor
);
2256 aSettings
.SetStyleSettings(aStyleSettings
);
2257 rScrollBar
.SetSettings(aSettings
);
2260 SalInstanceScrolledWindow::SalInstanceScrolledWindow(VclScrolledWindow
* pScrolledWindow
,
2261 SalInstanceBuilder
* pBuilder
,
2262 bool bTakeOwnership
,
2263 bool bUserManagedScrolling
)
2264 : SalInstanceContainer(pScrolledWindow
, pBuilder
, bTakeOwnership
)
2265 , m_xScrolledWindow(pScrolledWindow
)
2266 , m_bUserManagedScrolling(bUserManagedScrolling
)
2268 ScrollBar
& rVertScrollBar
= m_xScrolledWindow
->getVertScrollBar();
2269 m_aOrigVScrollHdl
= rVertScrollBar
.GetScrollHdl();
2270 rVertScrollBar
.SetScrollHdl(LINK(this, SalInstanceScrolledWindow
, VscrollHdl
));
2271 ScrollBar
& rHorzScrollBar
= m_xScrolledWindow
->getHorzScrollBar();
2272 m_aOrigHScrollHdl
= rHorzScrollBar
.GetScrollHdl();
2273 rHorzScrollBar
.SetScrollHdl(LINK(this, SalInstanceScrolledWindow
, HscrollHdl
));
2274 m_xScrolledWindow
->setUserManagedScrolling(m_bUserManagedScrolling
);
2277 void SalInstanceScrolledWindow::hadjustment_configure(int value
, int lower
, int upper
,
2278 int step_increment
, int page_increment
,
2281 ScrollBar
& rHorzScrollBar
= m_xScrolledWindow
->getHorzScrollBar();
2282 rHorzScrollBar
.SetRangeMin(lower
);
2283 rHorzScrollBar
.SetRangeMax(upper
);
2284 rHorzScrollBar
.SetLineSize(step_increment
);
2285 rHorzScrollBar
.SetPageSize(page_increment
);
2286 rHorzScrollBar
.SetThumbPos(value
);
2287 rHorzScrollBar
.SetVisibleSize(page_size
);
2290 int SalInstanceScrolledWindow::hadjustment_get_value() const
2292 ScrollBar
& rHorzScrollBar
= m_xScrolledWindow
->getHorzScrollBar();
2293 return rHorzScrollBar
.GetThumbPos();
2296 void SalInstanceScrolledWindow::hadjustment_set_value(int value
)
2298 ScrollBar
& rHorzScrollBar
= m_xScrolledWindow
->getHorzScrollBar();
2299 rHorzScrollBar
.SetThumbPos(value
);
2300 if (!m_bUserManagedScrolling
)
2301 m_aOrigHScrollHdl
.Call(&rHorzScrollBar
);
2304 int SalInstanceScrolledWindow::hadjustment_get_upper() const
2306 ScrollBar
& rHorzScrollBar
= m_xScrolledWindow
->getHorzScrollBar();
2307 return rHorzScrollBar
.GetRangeMax();
2310 void SalInstanceScrolledWindow::hadjustment_set_upper(int upper
)
2312 ScrollBar
& rHorzScrollBar
= m_xScrolledWindow
->getHorzScrollBar();
2313 rHorzScrollBar
.SetRangeMax(upper
);
2316 int SalInstanceScrolledWindow::hadjustment_get_page_size() const
2318 ScrollBar
& rHorzScrollBar
= m_xScrolledWindow
->getHorzScrollBar();
2319 return rHorzScrollBar
.GetVisibleSize();
2322 void SalInstanceScrolledWindow::hadjustment_set_page_size(int size
)
2324 ScrollBar
& rHorzScrollBar
= m_xScrolledWindow
->getHorzScrollBar();
2325 return rHorzScrollBar
.SetVisibleSize(size
);
2328 void SalInstanceScrolledWindow::hadjustment_set_page_increment(int size
)
2330 ScrollBar
& rHorzScrollBar
= m_xScrolledWindow
->getHorzScrollBar();
2331 return rHorzScrollBar
.SetPageSize(size
);
2334 void SalInstanceScrolledWindow::hadjustment_set_step_increment(int size
)
2336 ScrollBar
& rHorzScrollBar
= m_xScrolledWindow
->getHorzScrollBar();
2337 return rHorzScrollBar
.SetLineSize(size
);
2340 void SalInstanceScrolledWindow::set_hpolicy(VclPolicyType eHPolicy
)
2342 WinBits nWinBits
= m_xScrolledWindow
->GetStyle() & ~(WB_AUTOHSCROLL
| WB_HSCROLL
);
2343 if (eHPolicy
== VclPolicyType::ALWAYS
)
2344 nWinBits
|= WB_HSCROLL
;
2345 else if (eHPolicy
== VclPolicyType::AUTOMATIC
)
2346 nWinBits
|= WB_AUTOHSCROLL
;
2347 m_xScrolledWindow
->SetStyle(nWinBits
);
2348 m_xScrolledWindow
->queue_resize();
2351 VclPolicyType
SalInstanceScrolledWindow::get_hpolicy() const
2353 WinBits nWinBits
= m_xScrolledWindow
->GetStyle();
2354 if (nWinBits
& WB_AUTOHSCROLL
)
2355 return VclPolicyType::AUTOMATIC
;
2356 else if (nWinBits
& WB_HSCROLL
)
2357 return VclPolicyType::ALWAYS
;
2358 return VclPolicyType::NEVER
;
2361 void SalInstanceScrolledWindow::vadjustment_configure(int value
, int lower
, int upper
,
2362 int step_increment
, int page_increment
,
2365 ScrollBar
& rVertScrollBar
= m_xScrolledWindow
->getVertScrollBar();
2366 rVertScrollBar
.SetRangeMin(lower
);
2367 rVertScrollBar
.SetRangeMax(upper
);
2368 rVertScrollBar
.SetLineSize(step_increment
);
2369 rVertScrollBar
.SetPageSize(page_increment
);
2370 rVertScrollBar
.SetThumbPos(value
);
2371 rVertScrollBar
.SetVisibleSize(page_size
);
2374 int SalInstanceScrolledWindow::vadjustment_get_value() const
2376 ScrollBar
& rVertScrollBar
= m_xScrolledWindow
->getVertScrollBar();
2377 return rVertScrollBar
.GetThumbPos();
2380 void SalInstanceScrolledWindow::vadjustment_set_value(int value
)
2382 ScrollBar
& rVertScrollBar
= m_xScrolledWindow
->getVertScrollBar();
2383 rVertScrollBar
.SetThumbPos(value
);
2384 if (!m_bUserManagedScrolling
)
2385 m_aOrigVScrollHdl
.Call(&rVertScrollBar
);
2388 int SalInstanceScrolledWindow::vadjustment_get_upper() const
2390 ScrollBar
& rVertScrollBar
= m_xScrolledWindow
->getVertScrollBar();
2391 return rVertScrollBar
.GetRangeMax();
2394 void SalInstanceScrolledWindow::vadjustment_set_upper(int upper
)
2396 ScrollBar
& rVertScrollBar
= m_xScrolledWindow
->getVertScrollBar();
2397 rVertScrollBar
.SetRangeMax(upper
);
2400 int SalInstanceScrolledWindow::vadjustment_get_lower() const
2402 ScrollBar
& rVertScrollBar
= m_xScrolledWindow
->getVertScrollBar();
2403 return rVertScrollBar
.GetRangeMin();
2406 void SalInstanceScrolledWindow::vadjustment_set_lower(int lower
)
2408 ScrollBar
& rVertScrollBar
= m_xScrolledWindow
->getVertScrollBar();
2409 rVertScrollBar
.SetRangeMin(lower
);
2412 int SalInstanceScrolledWindow::vadjustment_get_page_size() const
2414 ScrollBar
& rVertScrollBar
= m_xScrolledWindow
->getVertScrollBar();
2415 return rVertScrollBar
.GetVisibleSize();
2418 void SalInstanceScrolledWindow::vadjustment_set_page_size(int size
)
2420 ScrollBar
& rVertScrollBar
= m_xScrolledWindow
->getVertScrollBar();
2421 return rVertScrollBar
.SetVisibleSize(size
);
2424 void SalInstanceScrolledWindow::vadjustment_set_page_increment(int size
)
2426 ScrollBar
& rVertScrollBar
= m_xScrolledWindow
->getVertScrollBar();
2427 return rVertScrollBar
.SetPageSize(size
);
2430 void SalInstanceScrolledWindow::vadjustment_set_step_increment(int size
)
2432 ScrollBar
& rVertScrollBar
= m_xScrolledWindow
->getVertScrollBar();
2433 return rVertScrollBar
.SetLineSize(size
);
2436 void SalInstanceScrolledWindow::set_vpolicy(VclPolicyType eVPolicy
)
2438 WinBits nWinBits
= m_xScrolledWindow
->GetStyle() & ~(WB_AUTOVSCROLL
| WB_VSCROLL
);
2439 if (eVPolicy
== VclPolicyType::ALWAYS
)
2440 nWinBits
|= WB_VSCROLL
;
2441 else if (eVPolicy
== VclPolicyType::AUTOMATIC
)
2442 nWinBits
|= WB_AUTOVSCROLL
;
2443 m_xScrolledWindow
->SetStyle(nWinBits
);
2444 m_xScrolledWindow
->queue_resize();
2447 VclPolicyType
SalInstanceScrolledWindow::get_vpolicy() const
2449 WinBits nWinBits
= m_xScrolledWindow
->GetStyle();
2450 if (nWinBits
& WB_AUTOVSCROLL
)
2451 return VclPolicyType::AUTOMATIC
;
2452 else if (nWinBits
& WB_VSCROLL
)
2453 return VclPolicyType::ALWAYS
;
2454 return VclPolicyType::NEVER
;
2457 int SalInstanceScrolledWindow::get_scroll_thickness() const
2459 return m_xScrolledWindow
->getVertScrollBar().get_preferred_size().Width();
2462 void SalInstanceScrolledWindow::set_scroll_thickness(int nThickness
)
2464 ScrollBar
& rHorzScrollBar
= m_xScrolledWindow
->getHorzScrollBar();
2465 ScrollBar
& rVertScrollBar
= m_xScrolledWindow
->getVertScrollBar();
2466 rHorzScrollBar
.set_height_request(nThickness
);
2467 rVertScrollBar
.set_width_request(nThickness
);
2470 void SalInstanceScrolledWindow::customize_scrollbars(const Color
& rBackgroundColor
,
2471 const Color
& rShadowColor
,
2472 const Color
& rFaceColor
)
2474 ScrollBar
& rHorzScrollBar
= m_xScrolledWindow
->getHorzScrollBar();
2475 ScrollBar
& rVertScrollBar
= m_xScrolledWindow
->getVertScrollBar();
2476 customize_scrollbars(rHorzScrollBar
, Color(0, 0, 0), rBackgroundColor
, rShadowColor
,
2478 customize_scrollbars(rVertScrollBar
, Color(0, 0, 0), rBackgroundColor
, rShadowColor
,
2482 SalInstanceScrolledWindow::~SalInstanceScrolledWindow()
2484 ScrollBar
& rVertScrollBar
= m_xScrolledWindow
->getVertScrollBar();
2485 rVertScrollBar
.SetScrollHdl(m_aOrigVScrollHdl
);
2488 IMPL_LINK(SalInstanceScrolledWindow
, VscrollHdl
, ScrollBar
*, pScrollBar
, void)
2490 signal_vadjustment_changed();
2491 if (!m_bUserManagedScrolling
)
2492 m_aOrigVScrollHdl
.Call(pScrollBar
);
2495 IMPL_LINK_NOARG(SalInstanceScrolledWindow
, HscrollHdl
, ScrollBar
*, void)
2497 signal_hadjustment_changed();
2498 if (!m_bUserManagedScrolling
)
2499 m_aOrigHScrollHdl
.Call(&m_xScrolledWindow
->getHorzScrollBar());
2504 class SalInstanceScrollbar
: public SalInstanceWidget
, public virtual weld::Scrollbar
2507 VclPtr
<ScrollBar
> m_xScrollBar
;
2509 DECL_LINK(ScrollHdl
, ScrollBar
*, void);
2512 SalInstanceScrollbar(ScrollBar
* pScrollbar
, SalInstanceBuilder
* pBuilder
, bool bTakeOwnership
)
2513 : SalInstanceWidget(pScrollbar
, pBuilder
, bTakeOwnership
)
2514 , m_xScrollBar(pScrollbar
)
2516 m_xScrollBar
->SetScrollHdl(LINK(this, SalInstanceScrollbar
, ScrollHdl
));
2517 m_xScrollBar
->EnableDrag();
2520 virtual void adjustment_configure(int value
, int lower
, int upper
, int step_increment
,
2521 int page_increment
, int page_size
) override
2523 m_xScrollBar
->SetRangeMin(lower
);
2524 m_xScrollBar
->SetRangeMax(upper
);
2525 m_xScrollBar
->SetLineSize(step_increment
);
2526 m_xScrollBar
->SetPageSize(page_increment
);
2527 m_xScrollBar
->SetThumbPos(value
);
2528 m_xScrollBar
->SetVisibleSize(page_size
);
2531 virtual int adjustment_get_value() const override
{ return m_xScrollBar
->GetThumbPos(); }
2533 virtual void adjustment_set_value(int value
) override
{ m_xScrollBar
->SetThumbPos(value
); }
2535 virtual int adjustment_get_upper() const override
{ return m_xScrollBar
->GetRangeMax(); }
2537 virtual void adjustment_set_upper(int upper
) override
{ m_xScrollBar
->SetRangeMax(upper
); }
2539 virtual int adjustment_get_lower() const override
{ return m_xScrollBar
->GetRangeMin(); }
2541 virtual void adjustment_set_lower(int lower
) override
{ m_xScrollBar
->SetRangeMin(lower
); }
2543 virtual int adjustment_get_page_size() const override
{ return m_xScrollBar
->GetVisibleSize(); }
2545 virtual void adjustment_set_page_size(int size
) override
{ m_xScrollBar
->SetVisibleSize(size
); }
2547 virtual int adjustment_get_page_increment() const override
2549 return m_xScrollBar
->GetPageSize();
2552 virtual void adjustment_set_page_increment(int size
) override
2554 m_xScrollBar
->SetPageSize(size
);
2557 virtual int adjustment_get_step_increment() const override
2559 return m_xScrollBar
->GetLineSize();
2562 virtual void adjustment_set_step_increment(int size
) override
2564 m_xScrollBar
->SetLineSize(size
);
2567 virtual ScrollType
get_scroll_type() const override
{ return m_xScrollBar
->GetType(); }
2569 virtual int get_scroll_thickness() const override
2571 if (m_xScrollBar
->GetStyle() & WB_HORZ
)
2572 return m_xScrollBar
->get_preferred_size().Height();
2573 return m_xScrollBar
->get_preferred_size().Width();
2576 virtual void set_scroll_thickness(int nThickness
) override
2578 if (m_xScrollBar
->GetStyle() & WB_HORZ
)
2579 m_xScrollBar
->set_height_request(nThickness
);
2581 m_xScrollBar
->set_width_request(nThickness
);
2586 IMPL_LINK_NOARG(SalInstanceScrollbar
, ScrollHdl
, ScrollBar
*, void) { signal_adjustment_changed(); }
2588 SalInstanceNotebook::SalInstanceNotebook(TabControl
* pNotebook
, SalInstanceBuilder
* pBuilder
,
2589 bool bTakeOwnership
)
2590 : SalInstanceWidget(pNotebook
, pBuilder
, bTakeOwnership
)
2591 , m_xNotebook(pNotebook
)
2593 m_xNotebook
->SetActivatePageHdl(LINK(this, SalInstanceNotebook
, ActivatePageHdl
));
2594 m_xNotebook
->SetDeactivatePageHdl(LINK(this, SalInstanceNotebook
, DeactivatePageHdl
));
2597 int SalInstanceNotebook::get_current_page() const
2599 return m_xNotebook
->GetPagePos(m_xNotebook
->GetCurPageId());
2602 OUString
SalInstanceNotebook::get_page_ident(int nPage
) const
2604 return m_xNotebook
->GetPageName(m_xNotebook
->GetPageId(nPage
));
2607 OUString
SalInstanceNotebook::get_current_page_ident() const
2609 return m_xNotebook
->GetPageName(m_xNotebook
->GetCurPageId());
2612 int SalInstanceNotebook::get_page_index(const OUString
& rIdent
) const
2614 sal_uInt16 nPageId
= m_xNotebook
->GetPageId(rIdent
);
2615 sal_uInt16 nPageIndex
= m_xNotebook
->GetPagePos(nPageId
);
2616 if (nPageIndex
== TAB_PAGE_NOTFOUND
)
2621 weld::Container
* SalInstanceNotebook::get_page(const OUString
& rIdent
) const
2623 int nPageIndex
= get_page_index(rIdent
);
2624 if (nPageIndex
== -1)
2626 sal_uInt16 nPageId
= m_xNotebook
->GetPageId(rIdent
);
2627 TabPage
* pPage
= m_xNotebook
->GetTabPage(nPageId
);
2628 vcl::Window
* pChild
= pPage
->GetChild(0);
2629 if (m_aPages
.size() < nPageIndex
+ 1U)
2630 m_aPages
.resize(nPageIndex
+ 1U);
2631 if (!m_aPages
[nPageIndex
])
2632 m_aPages
[nPageIndex
] = std::make_shared
<SalInstanceContainer
>(pChild
, m_pBuilder
, false);
2633 return m_aPages
[nPageIndex
].get();
2636 void SalInstanceNotebook::set_current_page(int nPage
)
2638 m_xNotebook
->SetCurPageId(m_xNotebook
->GetPageId(nPage
));
2641 void SalInstanceNotebook::set_current_page(const OUString
& rIdent
)
2643 m_xNotebook
->SetCurPageId(m_xNotebook
->GetPageId(rIdent
));
2646 void SalInstanceNotebook::remove_page(const OUString
& rIdent
)
2648 sal_uInt16 nPageId
= m_xNotebook
->GetPageId(rIdent
);
2649 sal_uInt16 nPageIndex
= m_xNotebook
->GetPagePos(nPageId
);
2650 if (nPageIndex
== TAB_PAGE_NOTFOUND
)
2653 m_xNotebook
->RemovePage(nPageId
);
2654 if (nPageIndex
< m_aPages
.size())
2655 m_aPages
.erase(m_aPages
.begin() + nPageIndex
);
2657 auto iter
= m_aAddedPages
.find(rIdent
);
2658 if (iter
!= m_aAddedPages
.end())
2660 iter
->second
.second
.disposeAndClear();
2661 iter
->second
.first
.disposeAndClear();
2662 m_aAddedPages
.erase(iter
);
2666 void SalInstanceNotebook::insert_page(const OUString
& rIdent
, const OUString
& rLabel
, int nPos
)
2668 sal_uInt16 nPageCount
= m_xNotebook
->GetPageCount();
2669 sal_uInt16 nLastPageId
= nPageCount
? m_xNotebook
->GetPageId(nPageCount
- 1) : 0;
2670 sal_uInt16 nNewPageId
= nLastPageId
+ 1;
2671 while (m_xNotebook
->GetPagePos(nNewPageId
) != TAB_PAGE_NOTFOUND
)
2673 m_xNotebook
->InsertPage(nNewPageId
, rLabel
, nPos
== -1 ? TAB_APPEND
: nPos
);
2674 VclPtrInstance
<TabPage
> xPage(m_xNotebook
);
2675 VclPtrInstance
<VclGrid
> xGrid(xPage
);
2677 xGrid
->set_hexpand(true);
2678 xGrid
->set_vexpand(true);
2680 m_xNotebook
->SetTabPage(nNewPageId
, xPage
);
2681 m_xNotebook
->SetPageName(nNewPageId
, rIdent
);
2682 m_aAddedPages
.try_emplace(rIdent
, xPage
, xGrid
);
2686 unsigned int nPageIndex
= static_cast<unsigned int>(nPos
);
2687 if (nPageIndex
< m_aPages
.size())
2688 m_aPages
.insert(m_aPages
.begin() + nPageIndex
, nullptr);
2692 int SalInstanceNotebook::get_n_pages() const { return m_xNotebook
->GetPageCount(); }
2694 OUString
SalInstanceNotebook::get_tab_label_text(const OUString
& rIdent
) const
2696 return m_xNotebook
->GetPageText(m_xNotebook
->GetPageId(rIdent
));
2699 void SalInstanceNotebook::set_tab_label_text(const OUString
& rIdent
, const OUString
& rText
)
2701 return m_xNotebook
->SetPageText(m_xNotebook
->GetPageId(rIdent
), rText
);
2704 void SalInstanceNotebook::set_show_tabs(bool bShow
)
2706 m_xNotebook
->set_property("show-tabs", OUString::boolean(bShow
));
2709 SalInstanceNotebook::~SalInstanceNotebook()
2711 for (auto& rItem
: m_aAddedPages
)
2713 rItem
.second
.second
.disposeAndClear();
2714 rItem
.second
.first
.disposeAndClear();
2716 m_xNotebook
->SetActivatePageHdl(Link
<TabControl
*, void>());
2717 m_xNotebook
->SetDeactivatePageHdl(Link
<TabControl
*, bool>());
2720 IMPL_LINK_NOARG(SalInstanceNotebook
, DeactivatePageHdl
, TabControl
*, bool)
2722 return !m_aLeavePageHdl
.IsSet() || m_aLeavePageHdl
.Call(get_current_page_ident());
2725 IMPL_LINK_NOARG(SalInstanceNotebook
, ActivatePageHdl
, TabControl
*, void)
2727 m_aEnterPageHdl
.Call(get_current_page_ident());
2732 class SalInstanceVerticalNotebook
: public SalInstanceWidget
, public virtual weld::Notebook
2735 VclPtr
<VerticalTabControl
> m_xNotebook
;
2736 mutable std::vector
<std::unique_ptr
<SalInstanceContainer
>> m_aPages
;
2738 DECL_LINK(DeactivatePageHdl
, VerticalTabControl
*, bool);
2739 DECL_LINK(ActivatePageHdl
, VerticalTabControl
*, void);
2742 SalInstanceVerticalNotebook(VerticalTabControl
* pNotebook
, SalInstanceBuilder
* pBuilder
,
2743 bool bTakeOwnership
)
2744 : SalInstanceWidget(pNotebook
, pBuilder
, bTakeOwnership
)
2745 , m_xNotebook(pNotebook
)
2747 m_xNotebook
->SetActivatePageHdl(LINK(this, SalInstanceVerticalNotebook
, ActivatePageHdl
));
2748 m_xNotebook
->SetDeactivatePageHdl(
2749 LINK(this, SalInstanceVerticalNotebook
, DeactivatePageHdl
));
2752 virtual int get_current_page() const override
2754 return m_xNotebook
->GetPagePos(m_xNotebook
->GetCurPageId());
2757 virtual OUString
get_page_ident(int nPage
) const override
2759 return m_xNotebook
->GetPageId(nPage
);
2762 virtual OUString
get_current_page_ident() const override
{ return m_xNotebook
->GetCurPageId(); }
2764 virtual int get_page_index(const OUString
& rIdent
) const override
2766 sal_uInt16 nPageIndex
= m_xNotebook
->GetPagePos(rIdent
);
2767 if (nPageIndex
== TAB_PAGE_NOTFOUND
)
2772 virtual weld::Container
* get_page(const OUString
& rIdent
) const override
2774 int nPageIndex
= get_page_index(rIdent
);
2775 if (nPageIndex
== -1)
2777 auto pChild
= m_xNotebook
->GetPage(rIdent
);
2778 if (m_aPages
.size() < nPageIndex
+ 1U)
2779 m_aPages
.resize(nPageIndex
+ 1U);
2780 if (!m_aPages
[nPageIndex
])
2781 m_aPages
[nPageIndex
].reset(new SalInstanceContainer(pChild
, m_pBuilder
, false));
2782 return m_aPages
[nPageIndex
].get();
2785 virtual void set_current_page(int nPage
) override
2787 m_xNotebook
->SetCurPageId(m_xNotebook
->GetPageId(nPage
));
2790 virtual void set_current_page(const OUString
& rIdent
) override
2792 m_xNotebook
->SetCurPageId(rIdent
);
2795 virtual void remove_page(const OUString
& rIdent
) override
2797 sal_uInt16 nPageIndex
= m_xNotebook
->GetPagePos(rIdent
);
2798 if (nPageIndex
== TAB_PAGE_NOTFOUND
)
2800 m_xNotebook
->RemovePage(rIdent
);
2801 if (nPageIndex
< m_aPages
.size())
2802 m_aPages
.erase(m_aPages
.begin() + nPageIndex
);
2805 virtual void insert_page(const OUString
& rIdent
, const OUString
& rLabel
, int nPos
) override
2807 VclPtrInstance
<VclGrid
> xGrid(m_xNotebook
->GetPageParent());
2808 xGrid
->set_hexpand(true);
2809 xGrid
->set_vexpand(true);
2810 m_xNotebook
->InsertPage(rIdent
, rLabel
, Image(), "", xGrid
, nPos
);
2814 unsigned int nPageIndex
= static_cast<unsigned int>(nPos
);
2815 if (nPageIndex
< m_aPages
.size())
2816 m_aPages
.insert(m_aPages
.begin() + nPageIndex
, nullptr);
2820 virtual int get_n_pages() const override
{ return m_xNotebook
->GetPageCount(); }
2822 virtual void set_tab_label_text(const OUString
& rIdent
, const OUString
& rText
) override
2824 return m_xNotebook
->SetPageText(rIdent
, rText
);
2827 virtual OUString
get_tab_label_text(const OUString
& rIdent
) const override
2829 return m_xNotebook
->GetPageText(rIdent
);
2832 virtual void set_show_tabs(bool /*bShow*/) override
2834 // if someone needs this they will have to implement it in VerticalTabControl
2835 assert(false && "not implemented");
2838 virtual ~SalInstanceVerticalNotebook() override
2840 m_xNotebook
->SetActivatePageHdl(Link
<VerticalTabControl
*, void>());
2841 m_xNotebook
->SetDeactivatePageHdl(Link
<VerticalTabControl
*, bool>());
2846 IMPL_LINK_NOARG(SalInstanceVerticalNotebook
, DeactivatePageHdl
, VerticalTabControl
*, bool)
2848 return !m_aLeavePageHdl
.IsSet() || m_aLeavePageHdl
.Call(get_current_page_ident());
2851 IMPL_LINK_NOARG(SalInstanceVerticalNotebook
, ActivatePageHdl
, VerticalTabControl
*, void)
2853 m_aEnterPageHdl
.Call(get_current_page_ident());
2856 SalInstanceButton::SalInstanceButton(::Button
* pButton
, SalInstanceBuilder
* pBuilder
,
2857 bool bTakeOwnership
)
2858 : SalInstanceWidget(pButton
, pBuilder
, bTakeOwnership
)
2859 , m_xButton(pButton
)
2860 , m_aOldClickHdl(pButton
->GetClickHdl())
2862 m_xButton
->SetClickHdl(LINK(this, SalInstanceButton
, ClickHdl
));
2865 void SalInstanceButton::set_label(const OUString
& rText
) { m_xButton
->SetText(rText
); }
2867 void SalInstanceButton::set_image(VirtualDevice
* pDevice
)
2869 m_xButton
->SetImageAlign(ImageAlign::Left
);
2871 m_xButton
->SetModeImage(createImage(*pDevice
));
2873 m_xButton
->SetModeImage(Image());
2876 void SalInstanceButton::set_image(const css::uno::Reference
<css::graphic::XGraphic
>& rImage
)
2878 m_xButton
->SetImageAlign(ImageAlign::Left
);
2879 m_xButton
->SetModeImage(Image(rImage
));
2882 void SalInstanceButton::set_from_icon_name(const OUString
& rIconName
)
2884 m_xButton
->SetModeImage(Image(StockImage::Yes
, rIconName
));
2887 static void set_label_wrap(Control
& rWidget
, bool wrap
)
2889 WinBits nBits
= rWidget
.GetStyle();
2890 nBits
&= ~WB_WORDBREAK
;
2892 nBits
|= WB_WORDBREAK
;
2893 rWidget
.SetStyle(nBits
);
2894 rWidget
.queue_resize();
2897 void SalInstanceButton::set_font(const vcl::Font
& rFont
)
2899 m_xButton
->SetControlFont(rFont
);
2900 m_xButton
->Invalidate();
2903 void SalInstanceButton::set_custom_button(VirtualDevice
* pDevice
)
2906 m_xButton
->SetCustomButtonImage(createImage(*pDevice
));
2908 m_xButton
->SetCustomButtonImage(Image());
2909 m_xButton
->Invalidate();
2912 OUString
SalInstanceButton::get_label() const { return m_xButton
->GetText(); }
2914 SalInstanceButton::~SalInstanceButton() { m_xButton
->SetClickHdl(Link
<::Button
*, void>()); }
2916 IMPL_LINK(SalInstanceButton
, ClickHdl
, ::Button
*, pButton
, void)
2918 //if there's no handler set, disengage our intercept and
2919 //run the click again to get default behaviour for cancel/ok
2921 if (!m_aClickHdl
.IsSet())
2923 pButton
->SetClickHdl(m_aOldClickHdl
);
2925 pButton
->SetClickHdl(LINK(this, SalInstanceButton
, ClickHdl
));
2931 weld::Button
* SalInstanceDialog::weld_widget_for_response(int nResponse
)
2933 PushButton
* pButton
= dynamic_cast<PushButton
*>(m_xDialog
->get_widget_for_response(nResponse
));
2934 return pButton
? new SalInstanceButton(pButton
, nullptr, false) : nullptr;
2937 weld::Button
* SalInstanceAssistant::weld_widget_for_response(int nResponse
)
2939 PushButton
* pButton
= nullptr;
2940 if (nResponse
== RET_YES
)
2941 pButton
= m_xWizard
->m_pNextPage
;
2942 else if (nResponse
== RET_NO
)
2943 pButton
= m_xWizard
->m_pPrevPage
;
2944 else if (nResponse
== RET_OK
)
2945 pButton
= m_xWizard
->m_pFinish
;
2946 else if (nResponse
== RET_CANCEL
)
2947 pButton
= m_xWizard
->m_pCancel
;
2948 else if (nResponse
== RET_HELP
)
2949 pButton
= m_xWizard
->m_pHelp
;
2951 return new SalInstanceButton(pButton
, nullptr, false);
2955 SalInstanceMenuButton::SalInstanceMenuButton(::MenuButton
* pButton
, SalInstanceBuilder
* pBuilder
,
2956 bool bTakeOwnership
)
2957 : SalInstanceButton(pButton
, pBuilder
, bTakeOwnership
)
2958 , m_xMenuButton(pButton
)
2961 m_xMenuButton
->SetActivateHdl(LINK(this, SalInstanceMenuButton
, ActivateHdl
));
2962 m_xMenuButton
->SetSelectHdl(LINK(this, SalInstanceMenuButton
, MenuSelectHdl
));
2963 if (PopupMenu
* pMenu
= m_xMenuButton
->GetPopupMenu())
2965 pMenu
->SetMenuFlags(MenuFlags::NoAutoMnemonics
);
2966 const auto nCount
= pMenu
->GetItemCount();
2967 m_nLastId
= nCount
? pMenu
->GetItemId(nCount
- 1) : 0;
2971 void SalInstanceMenuButton::set_active(bool active
)
2973 if (active
== get_active())
2976 m_xMenuButton
->ExecuteMenu();
2978 m_xMenuButton
->CancelMenu();
2981 bool SalInstanceMenuButton::get_active() const { return m_xMenuButton
->InPopupMode(); }
2983 void SalInstanceMenuButton::set_inconsistent(bool /*inconsistent*/)
2988 bool SalInstanceMenuButton::get_inconsistent() const { return false; }
2990 void SalInstanceMenuButton::insert_item(int pos
, const OUString
& rId
, const OUString
& rStr
,
2991 const OUString
* pIconName
, VirtualDevice
* pImageSurface
,
2992 TriState eCheckRadioFalse
)
2994 m_nLastId
= insert_to_menu(m_nLastId
, m_xMenuButton
->GetPopupMenu(), pos
, rId
, rStr
, pIconName
,
2995 pImageSurface
, nullptr, eCheckRadioFalse
);
2998 void SalInstanceMenuButton::insert_separator(int pos
, const OUString
& rId
)
3000 auto nInsertPos
= pos
== -1 ? MENU_APPEND
: pos
;
3001 m_xMenuButton
->GetPopupMenu()->InsertSeparator(rId
, nInsertPos
);
3004 void SalInstanceMenuButton::set_item_sensitive(const OUString
& rIdent
, bool bSensitive
)
3006 PopupMenu
* pMenu
= m_xMenuButton
->GetPopupMenu();
3007 pMenu
->EnableItem(rIdent
, bSensitive
);
3010 void SalInstanceMenuButton::remove_item(const OUString
& rId
)
3012 PopupMenu
* pMenu
= m_xMenuButton
->GetPopupMenu();
3013 pMenu
->RemoveItem(pMenu
->GetItemPos(pMenu
->GetItemId(rId
)));
3016 void SalInstanceMenuButton::clear()
3018 PopupMenu
* pMenu
= m_xMenuButton
->GetPopupMenu();
3022 void SalInstanceMenuButton::set_item_active(const OUString
& rIdent
, bool bActive
)
3024 PopupMenu
* pMenu
= m_xMenuButton
->GetPopupMenu();
3025 pMenu
->CheckItem(rIdent
, bActive
);
3028 void SalInstanceMenuButton::set_item_label(const OUString
& rIdent
, const OUString
& rText
)
3030 PopupMenu
* pMenu
= m_xMenuButton
->GetPopupMenu();
3031 pMenu
->SetItemText(pMenu
->GetItemId(rIdent
), rText
);
3034 OUString
SalInstanceMenuButton::get_item_label(const OUString
& rIdent
) const
3036 PopupMenu
* pMenu
= m_xMenuButton
->GetPopupMenu();
3037 return pMenu
->GetItemText(pMenu
->GetItemId(rIdent
));
3040 void SalInstanceMenuButton::set_item_visible(const OUString
& rIdent
, bool bShow
)
3042 PopupMenu
* pMenu
= m_xMenuButton
->GetPopupMenu();
3043 pMenu
->ShowItem(pMenu
->GetItemId(rIdent
), bShow
);
3046 void SalInstanceMenuButton::set_popover(weld::Widget
* pPopover
)
3048 SalInstanceWidget
* pPopoverWidget
= dynamic_cast<SalInstanceWidget
*>(pPopover
);
3049 m_xMenuButton
->SetPopover(pPopoverWidget
? pPopoverWidget
->getWidget() : nullptr);
3052 SalInstanceMenuButton::~SalInstanceMenuButton()
3054 m_xMenuButton
->SetSelectHdl(Link
<::MenuButton
*, void>());
3055 m_xMenuButton
->SetActivateHdl(Link
<::MenuButton
*, void>());
3058 IMPL_LINK_NOARG(SalInstanceMenuButton
, MenuSelectHdl
, ::MenuButton
*, void)
3060 signal_selected(m_xMenuButton
->GetCurItemIdent());
3063 IMPL_LINK_NOARG(SalInstanceMenuButton
, ActivateHdl
, ::MenuButton
*, void)
3065 if (notify_events_disabled())
3072 class SalInstanceMenuToggleButton
: public SalInstanceMenuButton
,
3073 public virtual weld::MenuToggleButton
3076 VclPtr
<::MenuToggleButton
> m_xMenuToggleButton
;
3079 SalInstanceMenuToggleButton(::MenuToggleButton
* pButton
, SalInstanceBuilder
* pBuilder
,
3080 bool bTakeOwnership
)
3081 : SalInstanceMenuButton(pButton
, pBuilder
, bTakeOwnership
)
3082 , m_xMenuToggleButton(pButton
)
3084 m_xMenuToggleButton
->SetDelayMenu(true);
3085 m_xMenuToggleButton
->SetDropDown(PushButtonDropdownStyle::SplitMenuButton
);
3088 virtual void set_active(bool active
) override
3090 disable_notify_events();
3091 m_xMenuToggleButton
->SetActive(active
);
3092 enable_notify_events();
3095 virtual bool get_active() const override
{ return m_xMenuToggleButton
->GetActive(); }
3099 IMPL_LINK(SalInstanceLinkButton
, ClickHdl
, FixedHyperlink
&, rButton
, void)
3101 bool bConsumed
= signal_activate_link();
3103 m_aOrigClickHdl
.Call(rButton
);
3106 void SalInstanceLinkButton::set_label_wrap(bool bWrap
) { ::set_label_wrap(*m_xButton
, bWrap
); }
3108 SalInstanceRadioButton::SalInstanceRadioButton(::RadioButton
* pButton
, SalInstanceBuilder
* pBuilder
,
3109 bool bTakeOwnership
)
3110 : SalInstanceButton(pButton
, pBuilder
, bTakeOwnership
)
3111 , m_xRadioButton(pButton
)
3113 m_xRadioButton
->SetToggleHdl(LINK(this, SalInstanceRadioButton
, ToggleHdl
));
3116 void SalInstanceRadioButton::set_active(bool active
)
3118 disable_notify_events();
3119 m_xRadioButton
->Check(active
);
3120 enable_notify_events();
3123 bool SalInstanceRadioButton::get_active() const { return m_xRadioButton
->IsChecked(); }
3125 void SalInstanceRadioButton::set_image(VirtualDevice
* pDevice
)
3127 m_xRadioButton
->SetImageAlign(ImageAlign::Center
);
3129 m_xRadioButton
->SetModeImage(createImage(*pDevice
));
3131 m_xRadioButton
->SetModeImage(Image());
3134 void SalInstanceRadioButton::set_image(const css::uno::Reference
<css::graphic::XGraphic
>& rImage
)
3136 m_xRadioButton
->SetImageAlign(ImageAlign::Center
);
3137 m_xRadioButton
->SetModeImage(Image(rImage
));
3140 void SalInstanceRadioButton::set_from_icon_name(const OUString
& rIconName
)
3142 m_xRadioButton
->SetModeRadioImage(Image(StockImage::Yes
, rIconName
));
3145 void SalInstanceRadioButton::set_inconsistent(bool /*inconsistent*/)
3150 bool SalInstanceRadioButton::get_inconsistent() const { return false; }
3152 void SalInstanceRadioButton::set_label_wrap(bool bWrap
)
3154 ::set_label_wrap(*m_xRadioButton
, bWrap
);
3157 SalInstanceRadioButton::~SalInstanceRadioButton()
3159 m_xRadioButton
->SetToggleHdl(Link
<::RadioButton
&, void>());
3162 IMPL_LINK_NOARG(SalInstanceRadioButton
, ToggleHdl
, ::RadioButton
&, void)
3164 if (notify_events_disabled())
3169 IMPL_LINK(SalInstanceToggleButton
, ToggleListener
, VclWindowEvent
&, rEvent
, void)
3171 if (notify_events_disabled())
3173 if (rEvent
.GetId() == VclEventId::PushbuttonToggle
)
3177 SalInstanceCheckButton::SalInstanceCheckButton(CheckBox
* pButton
, SalInstanceBuilder
* pBuilder
,
3178 bool bTakeOwnership
)
3179 : SalInstanceButton(pButton
, pBuilder
, bTakeOwnership
)
3180 , m_xCheckButton(pButton
)
3182 m_xCheckButton
->SetToggleHdl(LINK(this, SalInstanceCheckButton
, ToggleHdl
));
3185 void SalInstanceCheckButton::set_active(bool active
)
3187 disable_notify_events();
3188 m_xCheckButton
->EnableTriState(false);
3189 m_xCheckButton
->Check(active
);
3190 enable_notify_events();
3193 bool SalInstanceCheckButton::get_active() const { return m_xCheckButton
->IsChecked(); }
3195 void SalInstanceCheckButton::set_inconsistent(bool inconsistent
)
3197 disable_notify_events();
3198 m_xCheckButton
->EnableTriState(true);
3199 m_xCheckButton
->SetState(inconsistent
? TRISTATE_INDET
: TRISTATE_FALSE
);
3200 enable_notify_events();
3203 bool SalInstanceCheckButton::get_inconsistent() const
3205 return m_xCheckButton
->GetState() == TRISTATE_INDET
;
3208 void SalInstanceCheckButton::set_label_wrap(bool bWrap
)
3210 ::set_label_wrap(*m_xCheckButton
, bWrap
);
3213 SalInstanceCheckButton::~SalInstanceCheckButton()
3215 m_xCheckButton
->SetToggleHdl(Link
<CheckBox
&, void>());
3218 IMPL_LINK_NOARG(SalInstanceCheckButton
, ToggleHdl
, CheckBox
&, void)
3220 if (notify_events_disabled())
3222 m_xCheckButton
->EnableTriState(false);
3228 class SalInstanceScale
: public SalInstanceWidget
, public virtual weld::Scale
3231 VclPtr
<Slider
> m_xScale
;
3233 DECL_LINK(SlideHdl
, Slider
*, void);
3236 SalInstanceScale(Slider
* pScale
, SalInstanceBuilder
* pBuilder
, bool bTakeOwnership
)
3237 : SalInstanceWidget(pScale
, pBuilder
, bTakeOwnership
)
3240 m_xScale
->SetSlideHdl(LINK(this, SalInstanceScale
, SlideHdl
));
3243 virtual void set_value(int value
) override
{ m_xScale
->SetThumbPos(value
); }
3245 virtual void set_range(int min
, int max
) override
3247 m_xScale
->SetRangeMin(min
);
3248 m_xScale
->SetRangeMax(max
);
3251 virtual int get_value() const override
{ return m_xScale
->GetThumbPos(); }
3253 virtual void set_increments(int step
, int page
) override
3255 m_xScale
->SetLineSize(step
);
3256 m_xScale
->SetPageSize(page
);
3259 virtual void get_increments(int& step
, int& page
) const override
3261 step
= m_xScale
->GetLineSize();
3262 page
= m_xScale
->GetPageSize();
3265 virtual ~SalInstanceScale() override
{ m_xScale
->SetSlideHdl(Link
<Slider
*, void>()); }
3269 IMPL_LINK_NOARG(SalInstanceScale
, SlideHdl
, Slider
*, void) { signal_value_changed(); }
3273 class SalInstanceSpinner
: public SalInstanceWidget
, public virtual weld::Spinner
3276 VclPtr
<Throbber
> m_xThrobber
;
3279 SalInstanceSpinner(Throbber
* pThrobber
, SalInstanceBuilder
* pBuilder
, bool bTakeOwnership
)
3280 : SalInstanceWidget(pThrobber
, pBuilder
, bTakeOwnership
)
3281 , m_xThrobber(pThrobber
)
3285 virtual void start() override
{ m_xThrobber
->start(); }
3287 virtual void stop() override
{ m_xThrobber
->stop(); }
3290 class SalInstanceProgressBar
: public SalInstanceWidget
, public virtual weld::ProgressBar
3293 VclPtr
<::ProgressBar
> m_xProgressBar
;
3296 SalInstanceProgressBar(::ProgressBar
* pProgressBar
, SalInstanceBuilder
* pBuilder
,
3297 bool bTakeOwnership
)
3298 : SalInstanceWidget(pProgressBar
, pBuilder
, bTakeOwnership
)
3299 , m_xProgressBar(pProgressBar
)
3303 virtual void set_percentage(int value
) override
{ m_xProgressBar
->SetValue(value
); }
3305 virtual OUString
get_text() const override
{ return m_xProgressBar
->GetText(); }
3307 virtual void set_text(const OUString
& rText
) override
{ m_xProgressBar
->SetText(rText
); }
3310 class SalInstanceCalendar
: public SalInstanceWidget
, public virtual weld::Calendar
3313 VclPtr
<::Calendar
> m_xCalendar
;
3315 DECL_LINK(SelectHdl
, ::Calendar
*, void);
3316 DECL_LINK(ActivateHdl
, ::Calendar
*, void);
3319 SalInstanceCalendar(::Calendar
* pCalendar
, SalInstanceBuilder
* pBuilder
, bool bTakeOwnership
)
3320 : SalInstanceWidget(pCalendar
, pBuilder
, bTakeOwnership
)
3321 , m_xCalendar(pCalendar
)
3323 m_xCalendar
->SetSelectHdl(LINK(this, SalInstanceCalendar
, SelectHdl
));
3324 m_xCalendar
->SetActivateHdl(LINK(this, SalInstanceCalendar
, ActivateHdl
));
3327 virtual void set_date(const Date
& rDate
) override
{ m_xCalendar
->SetCurDate(rDate
); }
3329 virtual Date
get_date() const override
{ return m_xCalendar
->GetFirstSelectedDate(); }
3331 virtual ~SalInstanceCalendar() override
3333 m_xCalendar
->SetSelectHdl(Link
<::Calendar
*, void>());
3334 m_xCalendar
->SetActivateHdl(Link
<::Calendar
*, void>());
3339 IMPL_LINK_NOARG(SalInstanceCalendar
, SelectHdl
, ::Calendar
*, void)
3341 if (notify_events_disabled())
3346 IMPL_LINK_NOARG(SalInstanceCalendar
, ActivateHdl
, ::Calendar
*, void)
3348 if (notify_events_disabled())
3353 SalInstanceImage::SalInstanceImage(FixedImage
* pImage
, SalInstanceBuilder
* pBuilder
,
3354 bool bTakeOwnership
)
3355 : SalInstanceWidget(pImage
, pBuilder
, bTakeOwnership
)
3360 void SalInstanceImage::set_from_icon_name(const OUString
& rIconName
)
3362 m_xImage
->SetImage(::Image(StockImage::Yes
, rIconName
));
3365 void SalInstanceImage::set_image(VirtualDevice
* pDevice
)
3368 m_xImage
->SetImage(createImage(*pDevice
));
3370 m_xImage
->SetImage(::Image());
3373 void SalInstanceImage::set_image(const css::uno::Reference
<css::graphic::XGraphic
>& rImage
)
3375 m_xImage
->SetImage(::Image(rImage
));
3378 WeldTextFilter::WeldTextFilter(Link
<OUString
&, bool>& rInsertTextHdl
)
3379 : TextFilter(OUString())
3380 , m_rInsertTextHdl(rInsertTextHdl
)
3384 OUString
WeldTextFilter::filter(const OUString
& rText
)
3386 if (!m_rInsertTextHdl
.IsSet())
3388 OUString
sText(rText
);
3389 const bool bContinue
= m_rInsertTextHdl
.Call(sText
);
3395 SalInstanceEntry::SalInstanceEntry(Edit
* pEntry
, SalInstanceBuilder
* pBuilder
, bool bTakeOwnership
)
3396 : SalInstanceWidget(pEntry
, pBuilder
, bTakeOwnership
)
3398 , m_aTextFilter(m_aInsertTextHdl
)
3400 m_xEntry
->SetModifyHdl(LINK(this, SalInstanceEntry
, ChangeHdl
));
3401 m_xEntry
->SetActivateHdl(LINK(this, SalInstanceEntry
, ActivateHdl
));
3402 m_xEntry
->SetTextFilter(&m_aTextFilter
);
3405 void SalInstanceEntry::set_text(const OUString
& rText
)
3407 disable_notify_events();
3408 m_xEntry
->SetText(rText
);
3409 enable_notify_events();
3412 OUString
SalInstanceEntry::get_text() const { return m_xEntry
->GetText(); }
3414 void SalInstanceEntry::set_width_chars(int nChars
) { m_xEntry
->SetWidthInChars(nChars
); }
3416 int SalInstanceEntry::get_width_chars() const { return m_xEntry
->GetWidthInChars(); }
3418 void SalInstanceEntry::set_max_length(int nChars
) { m_xEntry
->SetMaxTextLen(nChars
); }
3420 void SalInstanceEntry::select_region(int nStartPos
, int nEndPos
)
3422 disable_notify_events();
3423 tools::Long nStart
= nStartPos
< 0 ? SELECTION_MAX
: nStartPos
;
3424 tools::Long nEnd
= nEndPos
< 0 ? SELECTION_MAX
: nEndPos
;
3425 m_xEntry
->SetSelection(Selection(nStart
, nEnd
));
3426 enable_notify_events();
3429 bool SalInstanceEntry::get_selection_bounds(int& rStartPos
, int& rEndPos
)
3431 const Selection
& rSelection
= m_xEntry
->GetSelection();
3432 rStartPos
= rSelection
.Min();
3433 rEndPos
= rSelection
.Max();
3434 return rSelection
.Len();
3437 void SalInstanceEntry::replace_selection(const OUString
& rText
)
3439 m_xEntry
->ReplaceSelected(rText
);
3442 void SalInstanceEntry::set_position(int nCursorPos
)
3444 disable_notify_events();
3446 m_xEntry
->SetCursorAtLast();
3448 m_xEntry
->SetSelection(Selection(nCursorPos
, nCursorPos
));
3449 enable_notify_events();
3452 int SalInstanceEntry::get_position() const { return m_xEntry
->GetSelection().Max(); }
3454 void SalInstanceEntry::set_editable(bool bEditable
) { m_xEntry
->SetReadOnly(!bEditable
); }
3456 bool SalInstanceEntry::get_editable() const { return !m_xEntry
->IsReadOnly(); }
3458 void SalInstanceEntry::set_overwrite_mode(bool bOn
) { m_xEntry
->SetInsertMode(!bOn
); }
3460 bool SalInstanceEntry::get_overwrite_mode() const { return !m_xEntry
->IsInsertMode(); }
3464 void set_message_type(Edit
* pEntry
, weld::EntryMessageType eType
)
3468 case weld::EntryMessageType::Normal
:
3469 pEntry
->SetForceControlBackground(false);
3470 pEntry
->SetControlForeground();
3471 pEntry
->SetControlBackground();
3473 case weld::EntryMessageType::Warning
:
3474 // tdf#114603: enable setting the background to a different color;
3475 // relevant for GTK; see also #i75179#
3476 pEntry
->SetForceControlBackground(true);
3477 pEntry
->SetControlForeground(COL_BLACK
);
3478 pEntry
->SetControlBackground(0xffff38); // "light yellow 1"
3480 case weld::EntryMessageType::Error
:
3481 // tdf#114603: enable setting the background to a different color;
3482 // relevant for GTK; see also #i75179#
3483 pEntry
->SetForceControlBackground(true);
3484 pEntry
->SetControlForeground(COL_BLACK
); // contrast of 5.87 to the red background
3485 pEntry
->SetControlBackground(0xff3838); // "light red 1"
3491 void SalInstanceEntry::set_message_type(weld::EntryMessageType eType
)
3493 ::set_message_type(m_xEntry
, eType
);
3496 void SalInstanceEntry::set_font(const vcl::Font
& rFont
)
3498 m_xEntry
->SetControlFont(rFont
);
3499 m_xEntry
->Invalidate();
3502 void SalInstanceEntry::set_font_color(const Color
& rColor
)
3504 if (rColor
== COL_AUTO
)
3505 m_xEntry
->SetControlForeground();
3507 m_xEntry
->SetControlForeground(rColor
);
3510 void SalInstanceEntry::connect_cursor_position(const Link
<Entry
&, void>& rLink
)
3512 assert(!m_aCursorPositionHdl
.IsSet());
3513 m_xEntry
->AddEventListener(LINK(this, SalInstanceEntry
, CursorListener
));
3514 weld::Entry::connect_cursor_position(rLink
);
3517 void SalInstanceEntry::set_placeholder_text(const OUString
& rText
)
3519 m_xEntry
->SetPlaceholderText(rText
);
3522 Edit
& SalInstanceEntry::getEntry() { return *m_xEntry
; }
3524 void SalInstanceEntry::fire_signal_changed() { signal_changed(); }
3526 void SalInstanceEntry::cut_clipboard()
3532 void SalInstanceEntry::copy_clipboard() { m_xEntry
->Copy(); }
3534 void SalInstanceEntry::paste_clipboard()
3542 void set_alignment(Edit
& rEntry
, TxtAlign eXAlign
)
3547 case TxtAlign::Left
:
3550 case TxtAlign::Center
:
3553 case TxtAlign::Right
:
3557 WinBits nBits
= rEntry
.GetStyle();
3558 nBits
&= ~(WB_LEFT
| WB_CENTER
| WB_RIGHT
);
3559 rEntry
.SetStyle(nBits
| nAlign
);
3563 void SalInstanceEntry::set_alignment(TxtAlign eXAlign
) { ::set_alignment(*m_xEntry
, eXAlign
); }
3565 SalInstanceEntry::~SalInstanceEntry()
3567 if (m_aCursorPositionHdl
.IsSet())
3568 m_xEntry
->RemoveEventListener(LINK(this, SalInstanceEntry
, CursorListener
));
3569 m_xEntry
->SetTextFilter(nullptr);
3570 m_xEntry
->SetActivateHdl(Link
<Edit
&, bool>());
3571 m_xEntry
->SetModifyHdl(Link
<Edit
&, void>());
3574 IMPL_LINK_NOARG(SalInstanceEntry
, ChangeHdl
, Edit
&, void) { signal_changed(); }
3576 IMPL_LINK(SalInstanceEntry
, CursorListener
, VclWindowEvent
&, rEvent
, void)
3578 if (notify_events_disabled())
3580 if (rEvent
.GetId() == VclEventId::EditSelectionChanged
3581 || rEvent
.GetId() == VclEventId::EditCaretChanged
)
3582 signal_cursor_position();
3585 IMPL_LINK_NOARG(SalInstanceEntry
, ActivateHdl
, Edit
&, bool) { return m_aActivateHdl
.Call(*this); }
3587 class SalInstanceTreeView
;
3589 static SalInstanceTreeView
* g_DragSource
;
3593 // tdf#131581 if the TreeView is hidden then there are possibly additional
3594 // optimizations available
3595 class UpdateGuardIfHidden
3598 SvTabListBox
& m_rTreeView
;
3600 bool m_bOrigEnableInvalidate
;
3603 UpdateGuardIfHidden(SvTabListBox
& rTreeView
)
3604 : m_rTreeView(rTreeView
)
3605 // tdf#136962 only do SetUpdateMode(false) optimization if the widget is currently hidden
3606 , m_bOrigUpdate(!m_rTreeView
.IsVisible() && m_rTreeView
.IsUpdateMode())
3607 // tdf#137432 only do EnableInvalidate(false) optimization if the widget is currently hidden
3608 , m_bOrigEnableInvalidate(!m_rTreeView
.IsVisible()
3609 && m_rTreeView
.GetModel()->IsEnableInvalidate())
3612 m_rTreeView
.SetUpdateMode(false);
3613 if (m_bOrigEnableInvalidate
)
3614 m_rTreeView
.GetModel()->EnableInvalidate(false);
3617 ~UpdateGuardIfHidden()
3619 if (m_bOrigEnableInvalidate
)
3620 m_rTreeView
.GetModel()->EnableInvalidate(true);
3622 m_rTreeView
.SetUpdateMode(true);
3627 // Each row has a cell for the expander image, (and an optional cell for a
3628 // checkbutton if enable_toggle_buttons has been called) which precede
3630 int SalInstanceTreeView::to_internal_model(int col
) const
3632 if (m_xTreeView
->nTreeFlags
& SvTreeFlags::CHKBTN
)
3633 ++col
; // skip checkbutton column
3634 ++col
; //skip expander column
3638 int SalInstanceTreeView::to_external_model(int col
) const
3640 if (m_xTreeView
->nTreeFlags
& SvTreeFlags::CHKBTN
)
3641 --col
; // skip checkbutton column
3642 --col
; //skip expander column
3646 bool SalInstanceTreeView::IsDummyEntry(SvTreeListEntry
* pEntry
) const
3648 return o3tl::trim(m_xTreeView
->GetEntryText(pEntry
)) == u
"<dummy>";
3651 SvTreeListEntry
* SalInstanceTreeView::GetPlaceHolderChild(SvTreeListEntry
* pEntry
) const
3653 if (pEntry
->HasChildren())
3655 auto pChild
= m_xTreeView
->FirstChild(pEntry
);
3657 if (IsDummyEntry(pChild
))
3663 void SalInstanceTreeView::set_font_color(SvTreeListEntry
* pEntry
, const Color
& rColor
)
3665 if (rColor
== COL_AUTO
)
3666 pEntry
->SetTextColor(std::optional
<Color
>());
3668 pEntry
->SetTextColor(rColor
);
3671 void SalInstanceTreeView::AddStringItem(SvTreeListEntry
* pEntry
, const OUString
& rStr
, int nCol
)
3673 auto xCell
= std::make_unique
<SvLBoxString
>(rStr
);
3674 if (m_aCustomRenders
.count(nCol
))
3675 xCell
->SetCustomRender();
3676 pEntry
->AddItem(std::move(xCell
));
3679 void SalInstanceTreeView::do_insert(const weld::TreeIter
* pParent
, int pos
, const OUString
* pStr
,
3680 const OUString
* pId
, const OUString
* pIconName
,
3681 const VirtualDevice
* pImageSurface
, bool bChildrenOnDemand
,
3682 weld::TreeIter
* pRet
, bool bIsSeparator
)
3684 disable_notify_events();
3685 const SalInstanceTreeIter
* pVclIter
= static_cast<const SalInstanceTreeIter
*>(pParent
);
3686 SvTreeListEntry
* iter
= pVclIter
? pVclIter
->iter
: nullptr;
3687 auto nInsertPos
= pos
== -1 ? TREELIST_APPEND
: pos
;
3691 m_aUserData
.emplace_back(std::make_unique
<OUString
>(*pId
));
3692 pUserData
= m_aUserData
.back().get();
3695 pUserData
= nullptr;
3697 SvTreeListEntry
* pEntry
= new SvTreeListEntry
;
3699 pEntry
->SetFlags(pEntry
->GetFlags() | SvTLEntryFlags::IS_SEPARATOR
);
3701 if (m_xTreeView
->nTreeFlags
& SvTreeFlags::CHKBTN
)
3702 AddStringItem(pEntry
, "", -1);
3704 if (pIconName
|| pImageSurface
)
3706 Image
aImage(pIconName
? createImage(*pIconName
) : createImage(*pImageSurface
));
3707 pEntry
->AddItem(std::make_unique
<SvLBoxContextBmp
>(aImage
, aImage
, false));
3712 pEntry
->AddItem(std::make_unique
<SvLBoxContextBmp
>(aDummy
, aDummy
, false));
3715 AddStringItem(pEntry
, *pStr
, pEntry
->ItemCount());
3716 pEntry
->SetUserData(pUserData
);
3717 m_xTreeView
->Insert(pEntry
, iter
, nInsertPos
);
3721 SalInstanceTreeIter
* pVclRetIter
= static_cast<SalInstanceTreeIter
*>(pRet
);
3722 pVclRetIter
->iter
= pEntry
;
3725 if (bChildrenOnDemand
)
3727 SvTreeListEntry
* pPlaceHolder
3728 = m_xTreeView
->InsertEntry("<dummy>", pEntry
, false, 0, nullptr);
3729 SvViewDataEntry
* pViewData
= m_xTreeView
->GetViewDataEntry(pPlaceHolder
);
3730 pViewData
->SetSelectable(false);
3735 SvViewDataEntry
* pViewData
= m_xTreeView
->GetViewDataEntry(pEntry
);
3736 pViewData
->SetSelectable(false);
3739 enable_notify_events();
3742 void SalInstanceTreeView::update_checkbutton_column_width(SvTreeListEntry
* pEntry
)
3744 SvViewDataEntry
* pViewData
= m_xTreeView
->GetViewDataEntry(pEntry
);
3745 m_xTreeView
->InitViewData(pViewData
, pEntry
);
3746 m_xTreeView
->CheckBoxInserted(pEntry
);
3749 void SalInstanceTreeView::InvalidateModelEntry(SvTreeListEntry
* pEntry
)
3751 if (!m_xTreeView
->GetModel()->IsEnableInvalidate())
3753 m_xTreeView
->ModelHasEntryInvalidated(pEntry
);
3756 void SalInstanceTreeView::do_set_toggle(SvTreeListEntry
* pEntry
, TriState eState
, int col
)
3758 assert(col
>= 0 && o3tl::make_unsigned(col
) < pEntry
->ItemCount());
3759 // if it's the placeholder to allow a blank column, replace it now
3760 if (pEntry
->GetItem(col
).GetType() != SvLBoxItemType::Button
)
3762 SvLBoxButtonData
* pData
= m_bTogglesAsRadio
? &m_aRadioButtonData
: &m_aCheckButtonData
;
3763 pEntry
->ReplaceItem(std::make_unique
<SvLBoxButton
>(pData
), 0);
3764 update_checkbutton_column_width(pEntry
);
3766 SvLBoxItem
& rItem
= pEntry
->GetItem(col
);
3767 assert(dynamic_cast<SvLBoxButton
*>(&rItem
));
3771 static_cast<SvLBoxButton
&>(rItem
).SetStateChecked();
3773 case TRISTATE_FALSE
:
3774 static_cast<SvLBoxButton
&>(rItem
).SetStateUnchecked();
3776 case TRISTATE_INDET
:
3777 static_cast<SvLBoxButton
&>(rItem
).SetStateTristate();
3781 InvalidateModelEntry(pEntry
);
3784 TriState
SalInstanceTreeView::do_get_toggle(SvTreeListEntry
* pEntry
, int col
)
3786 if (static_cast<size_t>(col
) == pEntry
->ItemCount())
3787 return TRISTATE_FALSE
;
3789 assert(col
>= 0 && o3tl::make_unsigned(col
) < pEntry
->ItemCount());
3790 SvLBoxItem
& rItem
= pEntry
->GetItem(col
);
3791 assert(dynamic_cast<SvLBoxButton
*>(&rItem
));
3792 SvLBoxButton
& rToggle
= static_cast<SvLBoxButton
&>(rItem
);
3793 if (rToggle
.IsStateTristate())
3794 return TRISTATE_INDET
;
3795 else if (rToggle
.IsStateChecked())
3796 return TRISTATE_TRUE
;
3797 return TRISTATE_FALSE
;
3800 TriState
SalInstanceTreeView::get_toggle(SvTreeListEntry
* pEntry
, int col
) const
3804 assert(m_xTreeView
->nTreeFlags
& SvTreeFlags::CHKBTN
);
3805 return do_get_toggle(pEntry
, 0);
3807 col
= to_internal_model(col
);
3808 return do_get_toggle(pEntry
, col
);
3811 void SalInstanceTreeView::set_toggle(SvTreeListEntry
* pEntry
, TriState eState
, int col
)
3815 assert(m_xTreeView
->nTreeFlags
& SvTreeFlags::CHKBTN
);
3816 do_set_toggle(pEntry
, eState
, 0);
3820 col
= to_internal_model(col
);
3822 // blank out missing entries
3823 for (int i
= pEntry
->ItemCount(); i
< col
; ++i
)
3824 AddStringItem(pEntry
, "", i
- 1);
3826 if (static_cast<size_t>(col
) == pEntry
->ItemCount())
3828 SvLBoxButtonData
* pData
= m_bTogglesAsRadio
? &m_aRadioButtonData
: &m_aCheckButtonData
;
3829 pEntry
->AddItem(std::make_unique
<SvLBoxButton
>(pData
));
3830 update_checkbutton_column_width(pEntry
);
3833 do_set_toggle(pEntry
, eState
, col
);
3836 bool SalInstanceTreeView::get_text_emphasis(SvTreeListEntry
* pEntry
, int col
) const
3838 col
= to_internal_model(col
);
3840 assert(col
>= 0 && o3tl::make_unsigned(col
) < pEntry
->ItemCount());
3841 SvLBoxItem
& rItem
= pEntry
->GetItem(col
);
3842 assert(dynamic_cast<SvLBoxString
*>(&rItem
));
3843 return static_cast<SvLBoxString
&>(rItem
).IsEmphasized();
3846 void SalInstanceTreeView::set_header_item_width(const std::vector
<int>& rWidths
)
3848 LclHeaderTabListBox
* pHeaderBox
= dynamic_cast<LclHeaderTabListBox
*>(m_xTreeView
.get());
3849 if (HeaderBar
* pHeaderBar
= pHeaderBox
? pHeaderBox
->GetHeaderBar() : nullptr)
3851 for (size_t i
= 0; i
< rWidths
.size(); ++i
)
3852 pHeaderBar
->SetItemSize(pHeaderBar
->GetItemId(i
), rWidths
[i
]);
3856 SalInstanceTreeView::SalInstanceTreeView(SvTabListBox
* pTreeView
, SalInstanceBuilder
* pBuilder
,
3857 bool bTakeOwnership
)
3858 : SalInstanceWidget(pTreeView
, pBuilder
, bTakeOwnership
)
3859 , m_xTreeView(pTreeView
)
3860 , m_aCheckButtonData(pTreeView
, false)
3861 , m_aRadioButtonData(pTreeView
, true)
3862 , m_bTogglesAsRadio(false)
3865 m_xTreeView
->SetNodeDefaultImages();
3866 m_xTreeView
->SetForceMakeVisible(true);
3867 m_xTreeView
->SetSelectHdl(LINK(this, SalInstanceTreeView
, SelectHdl
));
3868 m_xTreeView
->SetDeselectHdl(LINK(this, SalInstanceTreeView
, DeSelectHdl
));
3869 m_xTreeView
->SetDoubleClickHdl(LINK(this, SalInstanceTreeView
, DoubleClickHdl
));
3870 m_xTreeView
->SetExpandingHdl(LINK(this, SalInstanceTreeView
, ExpandingHdl
));
3871 m_xTreeView
->SetPopupMenuHdl(LINK(this, SalInstanceTreeView
, PopupMenuHdl
));
3872 m_xTreeView
->SetCustomRenderHdl(LINK(this, SalInstanceTreeView
, CustomRenderHdl
));
3873 m_xTreeView
->SetCustomMeasureHdl(LINK(this, SalInstanceTreeView
, CustomMeasureHdl
));
3874 const tools::Long aTabPositions
[] = { 0 };
3875 m_xTreeView
->SetTabs(SAL_N_ELEMENTS(aTabPositions
), aTabPositions
);
3876 LclHeaderTabListBox
* pHeaderBox
= dynamic_cast<LclHeaderTabListBox
*>(m_xTreeView
.get());
3880 if (HeaderBar
* pHeaderBar
= pHeaderBox
->GetHeaderBar())
3882 //make the last entry fill available space
3883 pHeaderBar
->SetItemSize(pHeaderBar
->GetItemId(pHeaderBar
->GetItemCount() - 1),
3884 HEADERBAR_FULLSIZE
);
3885 pHeaderBar
->SetEndDragHdl(LINK(this, SalInstanceTreeView
, EndDragHdl
));
3886 pHeaderBar
->SetSelectHdl(LINK(this, SalInstanceTreeView
, HeaderBarClickedHdl
));
3888 pHeaderBox
->SetEditingEntryHdl(LINK(this, SalInstanceTreeView
, EditingEntryHdl
));
3889 pHeaderBox
->SetEditedEntryHdl(LINK(this, SalInstanceTreeView
, EditedEntryHdl
));
3893 static_cast<LclTabListBox
&>(*m_xTreeView
)
3894 .SetModelChangedHdl(LINK(this, SalInstanceTreeView
, ModelChangedHdl
));
3895 static_cast<LclTabListBox
&>(*m_xTreeView
)
3896 .SetStartDragHdl(LINK(this, SalInstanceTreeView
, StartDragHdl
));
3897 static_cast<LclTabListBox
&>(*m_xTreeView
)
3898 .SetEndDragHdl(LINK(this, SalInstanceTreeView
, FinishDragHdl
));
3899 static_cast<LclTabListBox
&>(*m_xTreeView
)
3900 .SetEditingEntryHdl(LINK(this, SalInstanceTreeView
, EditingEntryHdl
));
3901 static_cast<LclTabListBox
&>(*m_xTreeView
)
3902 .SetEditedEntryHdl(LINK(this, SalInstanceTreeView
, EditedEntryHdl
));
3904 m_aCheckButtonData
.SetLink(LINK(this, SalInstanceTreeView
, ToggleHdl
));
3905 m_aRadioButtonData
.SetLink(LINK(this, SalInstanceTreeView
, ToggleHdl
));
3908 void SalInstanceTreeView::connect_query_tooltip(const Link
<const weld::TreeIter
&, OUString
>& rLink
)
3910 weld::TreeView::connect_query_tooltip(rLink
);
3911 m_xTreeView
->SetTooltipHdl(LINK(this, SalInstanceTreeView
, TooltipHdl
));
3914 void SalInstanceTreeView::columns_autosize()
3916 std::vector
<tools::Long
> aWidths
;
3917 m_xTreeView
->getPreferredDimensions(aWidths
);
3918 if (aWidths
.size() > 2)
3920 std::vector
<int> aColWidths
;
3921 for (size_t i
= 1; i
< aWidths
.size() - 1; ++i
)
3922 aColWidths
.push_back(aWidths
[i
] - aWidths
[i
- 1]);
3923 set_column_fixed_widths(aColWidths
);
3927 void SalInstanceTreeView::freeze()
3929 bool bIsFirstFreeze
= IsFirstFreeze();
3930 SalInstanceWidget::freeze();
3933 m_xTreeView
->SetUpdateMode(false);
3934 m_xTreeView
->GetModel()->EnableInvalidate(false);
3938 void SalInstanceTreeView::thaw()
3940 bool bIsLastThaw
= IsLastThaw();
3943 m_xTreeView
->GetModel()->EnableInvalidate(true);
3944 m_xTreeView
->SetUpdateMode(true);
3946 SalInstanceWidget::thaw();
3949 void SalInstanceTreeView::set_column_fixed_widths(const std::vector
<int>& rWidths
)
3951 std::vector
<tools::Long
> aTabPositions
{ 0 };
3952 for (size_t i
= 0; i
< rWidths
.size(); ++i
)
3953 aTabPositions
.push_back(aTabPositions
[i
] + rWidths
[i
]);
3954 m_xTreeView
->SetTabs(aTabPositions
.size(), aTabPositions
.data(), MapUnit::MapPixel
);
3955 set_header_item_width(rWidths
);
3956 // call Resize to recalculate based on the new tabs
3957 m_xTreeView
->Resize();
3960 void SalInstanceTreeView::set_column_editables(const std::vector
<bool>& rEditables
)
3962 size_t nTabCount
= rEditables
.size();
3963 for (size_t i
= 0; i
< nTabCount
; ++i
)
3964 m_xTreeView
->SetTabEditable(i
, rEditables
[i
]);
3967 void SalInstanceTreeView::set_centered_column(int nCol
)
3969 m_xTreeView
->SetTabJustify(nCol
, SvTabJustify::AdjustCenter
);
3972 int SalInstanceTreeView::get_column_width(int nColumn
) const
3974 LclHeaderTabListBox
* pHeaderBox
= dynamic_cast<LclHeaderTabListBox
*>(m_xTreeView
.get());
3975 if (HeaderBar
* pHeaderBar
= pHeaderBox
? pHeaderBox
->GetHeaderBar() : nullptr)
3976 return pHeaderBar
->GetItemSize(pHeaderBar
->GetItemId(nColumn
));
3977 // GetTab(0) gives the position of the bitmap which is automatically inserted by the TabListBox.
3978 // So the first text column's width is Tab(2)-Tab(1).
3980 = m_xTreeView
->GetLogicTab(nColumn
+ 2) - m_xTreeView
->GetLogicTab(nColumn
+ 1);
3981 nWidthPixel
-= SV_TAB_BORDER
;
3985 OUString
SalInstanceTreeView::get_column_title(int nColumn
) const
3987 LclHeaderTabListBox
* pHeaderBox
= dynamic_cast<LclHeaderTabListBox
*>(m_xTreeView
.get());
3988 if (HeaderBar
* pHeaderBar
= pHeaderBox
? pHeaderBox
->GetHeaderBar() : nullptr)
3990 return pHeaderBar
->GetItemText(pHeaderBar
->GetItemId(nColumn
));
3995 void SalInstanceTreeView::set_column_title(int nColumn
, const OUString
& rTitle
)
3997 LclHeaderTabListBox
* pHeaderBox
= dynamic_cast<LclHeaderTabListBox
*>(m_xTreeView
.get());
3998 if (HeaderBar
* pHeaderBar
= pHeaderBox
? pHeaderBox
->GetHeaderBar() : nullptr)
4000 return pHeaderBar
->SetItemText(pHeaderBar
->GetItemId(nColumn
), rTitle
);
4004 void SalInstanceTreeView::set_column_custom_renderer(int nColumn
, bool bEnable
)
4006 assert(n_children() == 0 && "tree must be empty");
4008 m_aCustomRenders
.insert(nColumn
);
4010 m_aCustomRenders
.erase(nColumn
);
4013 void SalInstanceTreeView::queue_draw()
4015 // invalidate the entries
4016 SvTreeList
* pModel
= m_xTreeView
->GetModel();
4017 for (SvTreeListEntry
* pEntry
= m_xTreeView
->First(); pEntry
; pEntry
= m_xTreeView
->Next(pEntry
))
4018 pModel
->InvalidateEntry(pEntry
);
4021 void SalInstanceTreeView::show()
4023 if (LclHeaderTabListBox
* pHeaderBox
= dynamic_cast<LclHeaderTabListBox
*>(m_xTreeView
.get()))
4024 pHeaderBox
->GetParent()->Show();
4025 SalInstanceWidget::show();
4028 void SalInstanceTreeView::hide()
4030 if (LclHeaderTabListBox
* pHeaderBox
= dynamic_cast<LclHeaderTabListBox
*>(m_xTreeView
.get()))
4031 pHeaderBox
->GetParent()->Hide();
4032 SalInstanceWidget::hide();
4035 void SalInstanceTreeView::insert(const weld::TreeIter
* pParent
, int pos
, const OUString
* pStr
,
4036 const OUString
* pId
, const OUString
* pIconName
,
4037 VirtualDevice
* pImageSurface
, bool bChildrenOnDemand
,
4038 weld::TreeIter
* pRet
)
4040 do_insert(pParent
, pos
, pStr
, pId
, pIconName
, pImageSurface
, bChildrenOnDemand
, pRet
, false);
4043 void SalInstanceTreeView::insert_separator(int pos
, const OUString
& /*rId*/)
4045 OUString
sSep(VclResId(STR_SEPARATOR
));
4046 do_insert(nullptr, pos
, &sSep
, nullptr, nullptr, nullptr, false, nullptr, true);
4049 void SalInstanceTreeView::bulk_insert_for_each(
4050 int nSourceCount
, const std::function
<void(weld::TreeIter
&, int nSourceIndex
)>& func
,
4051 const weld::TreeIter
* pParent
, const std::vector
<int>* pFixedWidths
)
4053 const SalInstanceTreeIter
* pVclIter
= static_cast<const SalInstanceTreeIter
*>(pParent
);
4054 SvTreeListEntry
* pVclParent
= pVclIter
? pVclIter
->iter
: nullptr;
4061 while (SvTreeListEntry
* pChild
= m_xTreeView
->FirstChild(pVclParent
))
4062 m_xTreeView
->RemoveEntry(pChild
);
4064 SalInstanceTreeIter
aVclIter(static_cast<SvTreeListEntry
*>(nullptr));
4066 m_xTreeView
->nTreeFlags
|= SvTreeFlags::MANINS
;
4069 set_header_item_width(*pFixedWidths
);
4071 bool bHasAutoCheckButton(m_xTreeView
->nTreeFlags
& SvTreeFlags::CHKBTN
);
4072 size_t nExtraCols
= bHasAutoCheckButton
? 2 : 1;
4075 for (int i
= 0; i
< nSourceCount
; ++i
)
4077 aVclIter
.iter
= new SvTreeListEntry
;
4078 if (bHasAutoCheckButton
)
4079 AddStringItem(aVclIter
.iter
, "", -1);
4080 aVclIter
.iter
->AddItem(std::make_unique
<SvLBoxContextBmp
>(aDummy
, aDummy
, false));
4081 m_xTreeView
->Insert(aVclIter
.iter
, pVclParent
, TREELIST_APPEND
);
4087 size_t nFixedWidths
= std::min(pFixedWidths
->size(), aVclIter
.iter
->ItemCount());
4088 for (size_t j
= 0; j
< nFixedWidths
; ++j
)
4090 SvLBoxItem
& rItem
= aVclIter
.iter
->GetItem(j
+ nExtraCols
);
4091 SvViewDataItem
* pViewDataItem
= m_xTreeView
->GetViewDataItem(aVclIter
.iter
, &rItem
);
4092 pViewDataItem
->mnWidth
= (*pFixedWidths
)[j
];
4096 m_xTreeView
->nTreeFlags
&= ~SvTreeFlags::MANINS
;
4101 void SalInstanceTreeView::set_font_color(int pos
, const Color
& rColor
)
4103 SvTreeListEntry
* pEntry
= m_xTreeView
->GetEntry(nullptr, pos
);
4104 set_font_color(pEntry
, rColor
);
4107 void SalInstanceTreeView::set_font_color(const weld::TreeIter
& rIter
, const Color
& rColor
)
4109 const SalInstanceTreeIter
& rVclIter
= static_cast<const SalInstanceTreeIter
&>(rIter
);
4110 set_font_color(rVclIter
.iter
, rColor
);
4113 void SalInstanceTreeView::remove(int pos
)
4115 disable_notify_events();
4116 SvTreeListEntry
* pEntry
= m_xTreeView
->GetEntry(nullptr, pos
);
4117 m_xTreeView
->RemoveEntry(pEntry
);
4118 enable_notify_events();
4121 int SalInstanceTreeView::find_text(const OUString
& rText
) const
4123 for (SvTreeListEntry
* pEntry
= m_xTreeView
->First(); pEntry
; pEntry
= m_xTreeView
->Next(pEntry
))
4125 if (SvTabListBox::GetEntryText(pEntry
, 0) == rText
)
4126 return SvTreeList::GetRelPos(pEntry
);
4131 int SalInstanceTreeView::find_id(const OUString
& rId
) const
4133 for (SvTreeListEntry
* pEntry
= m_xTreeView
->First(); pEntry
; pEntry
= m_xTreeView
->Next(pEntry
))
4135 const OUString
* pId
= static_cast<const OUString
*>(pEntry
->GetUserData());
4139 return SvTreeList::GetRelPos(pEntry
);
4144 void SalInstanceTreeView::swap(int pos1
, int pos2
)
4146 int min
= std::min(pos1
, pos2
);
4147 int max
= std::max(pos1
, pos2
);
4148 SvTreeList
* pModel
= m_xTreeView
->GetModel();
4149 SvTreeListEntry
* pEntry1
= pModel
->GetEntry(nullptr, min
);
4150 SvTreeListEntry
* pEntry2
= pModel
->GetEntry(nullptr, max
);
4151 pModel
->Move(pEntry1
, pEntry2
);
4154 void SalInstanceTreeView::clear()
4156 disable_notify_events();
4157 m_xTreeView
->Clear();
4158 m_aUserData
.clear();
4159 enable_notify_events();
4162 int SalInstanceTreeView::n_children() const
4164 return m_xTreeView
->GetModel()->GetChildList(nullptr).size();
4167 int SalInstanceTreeView::iter_n_children(const weld::TreeIter
& rIter
) const
4169 const SalInstanceTreeIter
& rVclIter
= static_cast<const SalInstanceTreeIter
&>(rIter
);
4170 return m_xTreeView
->GetModel()->GetChildList(rVclIter
.iter
).size();
4173 void SalInstanceTreeView::select(int pos
)
4175 assert(m_xTreeView
->IsUpdateMode()
4176 && "don't select when frozen, select after thaw. Note selection doesn't survive a "
4178 disable_notify_events();
4179 if (pos
== -1 || (pos
== 0 && n_children() == 0))
4180 m_xTreeView
->SelectAll(false);
4183 SvTreeListEntry
* pEntry
= m_xTreeView
->GetEntry(nullptr, pos
);
4184 assert(pEntry
&& "bad pos?");
4185 m_xTreeView
->Select(pEntry
, true);
4186 m_xTreeView
->MakeVisible(pEntry
);
4188 enable_notify_events();
4191 int SalInstanceTreeView::get_cursor_index() const
4193 SvTreeListEntry
* pEntry
= m_xTreeView
->GetCurEntry();
4196 return SvTreeList::GetRelPos(pEntry
);
4199 void SalInstanceTreeView::set_cursor(int pos
)
4201 disable_notify_events();
4203 m_xTreeView
->SetCurEntry(nullptr);
4206 SvTreeListEntry
* pEntry
= m_xTreeView
->GetEntry(nullptr, pos
);
4207 m_xTreeView
->SetCurEntry(pEntry
);
4209 enable_notify_events();
4212 void SalInstanceTreeView::scroll_to_row(int pos
)
4214 assert(m_xTreeView
->IsUpdateMode()
4215 && "don't select when frozen, select after thaw. Note selection doesn't survive a "
4217 disable_notify_events();
4218 SvTreeListEntry
* pEntry
= m_xTreeView
->GetEntry(nullptr, pos
);
4219 m_xTreeView
->MakeVisible(pEntry
);
4220 enable_notify_events();
4223 bool SalInstanceTreeView::is_selected(int pos
) const
4225 SvTreeListEntry
* pEntry
= m_xTreeView
->GetEntry(nullptr, pos
);
4226 return m_xTreeView
->IsSelected(pEntry
);
4229 void SalInstanceTreeView::unselect(int pos
)
4231 assert(m_xTreeView
->IsUpdateMode()
4232 && "don't select when frozen, select after thaw. Note selection doesn't survive a "
4234 disable_notify_events();
4236 m_xTreeView
->SelectAll(true);
4239 SvTreeListEntry
* pEntry
= m_xTreeView
->GetEntry(nullptr, pos
);
4240 m_xTreeView
->Select(pEntry
, false);
4242 enable_notify_events();
4245 std::vector
<int> SalInstanceTreeView::get_selected_rows() const
4247 std::vector
<int> aRows
;
4249 aRows
.reserve(m_xTreeView
->GetSelectionCount());
4250 for (SvTreeListEntry
* pEntry
= m_xTreeView
->FirstSelected(); pEntry
;
4251 pEntry
= m_xTreeView
->NextSelected(pEntry
))
4252 aRows
.push_back(SvTreeList::GetRelPos(pEntry
));
4257 OUString
SalInstanceTreeView::get_text(SvTreeListEntry
* pEntry
, int col
) const
4260 return SvTabListBox::GetEntryText(pEntry
, 0);
4262 col
= to_internal_model(col
);
4264 if (static_cast<size_t>(col
) == pEntry
->ItemCount())
4267 assert(col
>= 0 && o3tl::make_unsigned(col
) < pEntry
->ItemCount());
4268 SvLBoxItem
& rItem
= pEntry
->GetItem(col
);
4269 assert(dynamic_cast<SvLBoxString
*>(&rItem
));
4270 return static_cast<SvLBoxString
&>(rItem
).GetText();
4273 OUString
SalInstanceTreeView::get_text(int pos
, int col
) const
4275 SvTreeListEntry
* pEntry
= m_xTreeView
->GetEntry(nullptr, pos
);
4276 return get_text(pEntry
, col
);
4279 void SalInstanceTreeView::set_text(SvTreeListEntry
* pEntry
, const OUString
& rText
, int col
)
4283 m_xTreeView
->SetEntryText(pEntry
, rText
);
4287 col
= to_internal_model(col
);
4289 // blank out missing entries
4290 for (int i
= pEntry
->ItemCount(); i
< col
; ++i
)
4291 AddStringItem(pEntry
, "", i
- 1);
4293 if (static_cast<size_t>(col
) == pEntry
->ItemCount())
4295 AddStringItem(pEntry
, rText
, col
- 1);
4296 SvViewDataEntry
* pViewData
= m_xTreeView
->GetViewDataEntry(pEntry
);
4297 m_xTreeView
->InitViewData(pViewData
, pEntry
);
4301 assert(col
>= 0 && o3tl::make_unsigned(col
) < pEntry
->ItemCount());
4302 SvLBoxItem
& rItem
= pEntry
->GetItem(col
);
4303 assert(dynamic_cast<SvLBoxString
*>(&rItem
));
4304 static_cast<SvLBoxString
&>(rItem
).SetText(rText
);
4307 InvalidateModelEntry(pEntry
);
4310 void SalInstanceTreeView::set_text(int pos
, const OUString
& rText
, int col
)
4312 SvTreeListEntry
* pEntry
= m_xTreeView
->GetEntry(nullptr, pos
);
4313 set_text(pEntry
, rText
, col
);
4316 void SalInstanceTreeView::set_sensitive(SvTreeListEntry
* pEntry
, bool bSensitive
, int col
)
4320 auto nFlags
= pEntry
->GetFlags() & ~SvTLEntryFlags::SEMITRANSPARENT
;
4322 nFlags
= nFlags
| SvTLEntryFlags::SEMITRANSPARENT
;
4323 pEntry
->SetFlags(nFlags
);
4324 const sal_uInt16 nCount
= pEntry
->ItemCount();
4325 for (sal_uInt16 nCur
= 0; nCur
< nCount
; ++nCur
)
4327 SvLBoxItem
& rItem
= pEntry
->GetItem(nCur
);
4328 if (rItem
.GetType() == SvLBoxItemType::String
4329 || rItem
.GetType() == SvLBoxItemType::Button
4330 || rItem
.GetType() == SvLBoxItemType::ContextBmp
)
4332 rItem
.Enable(bSensitive
);
4333 InvalidateModelEntry(pEntry
);
4339 col
= to_internal_model(col
);
4341 assert(col
>= 0 && o3tl::make_unsigned(col
) < pEntry
->ItemCount());
4342 SvLBoxItem
& rItem
= pEntry
->GetItem(col
);
4343 rItem
.Enable(bSensitive
);
4345 InvalidateModelEntry(pEntry
);
4348 bool SalInstanceTreeView::do_get_sensitive(SvTreeListEntry
* pEntry
, int col
)
4350 if (static_cast<size_t>(col
) == pEntry
->ItemCount())
4353 assert(col
>= 0 && o3tl::make_unsigned(col
) < pEntry
->ItemCount());
4354 SvLBoxItem
& rItem
= pEntry
->GetItem(col
);
4355 return rItem
.isEnable();
4358 bool SalInstanceTreeView::get_sensitive(SvTreeListEntry
* pEntry
, int col
) const
4360 col
= to_internal_model(col
);
4361 return do_get_sensitive(pEntry
, col
);
4364 void SalInstanceTreeView::set_sensitive(int pos
, bool bSensitive
, int col
)
4366 SvTreeListEntry
* pEntry
= m_xTreeView
->GetEntry(nullptr, pos
);
4367 set_sensitive(pEntry
, bSensitive
, col
);
4370 bool SalInstanceTreeView::get_sensitive(int pos
, int col
) const
4372 SvTreeListEntry
* pEntry
= m_xTreeView
->GetEntry(nullptr, pos
);
4373 return get_sensitive(pEntry
, col
);
4376 void SalInstanceTreeView::set_sensitive(const weld::TreeIter
& rIter
, bool bSensitive
, int col
)
4378 const SalInstanceTreeIter
& rVclIter
= static_cast<const SalInstanceTreeIter
&>(rIter
);
4379 set_sensitive(rVclIter
.iter
, bSensitive
, col
);
4382 bool SalInstanceTreeView::get_sensitive(const weld::TreeIter
& rIter
, int col
) const
4384 const SalInstanceTreeIter
& rVclIter
= static_cast<const SalInstanceTreeIter
&>(rIter
);
4385 return get_sensitive(rVclIter
.iter
, col
);
4388 TriState
SalInstanceTreeView::get_toggle(int pos
, int col
) const
4390 SvTreeListEntry
* pEntry
= m_xTreeView
->GetEntry(nullptr, pos
);
4391 return get_toggle(pEntry
, col
);
4394 TriState
SalInstanceTreeView::get_toggle(const weld::TreeIter
& rIter
, int col
) const
4396 const SalInstanceTreeIter
& rVclIter
= static_cast<const SalInstanceTreeIter
&>(rIter
);
4397 return get_toggle(rVclIter
.iter
, col
);
4400 void SalInstanceTreeView::enable_toggle_buttons(weld::ColumnToggleType eType
)
4402 assert(n_children() == 0 && "tree must be empty");
4403 m_bTogglesAsRadio
= eType
== weld::ColumnToggleType::Radio
;
4405 SvLBoxButtonData
* pData
= m_bTogglesAsRadio
? &m_aRadioButtonData
: &m_aCheckButtonData
;
4406 m_xTreeView
->EnableCheckButton(pData
);
4407 // EnableCheckButton clobbered this, restore it
4408 pData
->SetLink(LINK(this, SalInstanceTreeView
, ToggleHdl
));
4411 void SalInstanceTreeView::set_toggle(int pos
, TriState eState
, int col
)
4413 SvTreeListEntry
* pEntry
= m_xTreeView
->GetEntry(nullptr, pos
);
4414 set_toggle(pEntry
, eState
, col
);
4417 void SalInstanceTreeView::set_toggle(const weld::TreeIter
& rIter
, TriState eState
, int col
)
4419 const SalInstanceTreeIter
& rVclIter
= static_cast<const SalInstanceTreeIter
&>(rIter
);
4420 set_toggle(rVclIter
.iter
, eState
, col
);
4423 void SalInstanceTreeView::set_clicks_to_toggle(int nToggleBehavior
)
4425 m_xTreeView
->SetClicksToToggle(nToggleBehavior
);
4428 void SalInstanceTreeView::set_extra_row_indent(const weld::TreeIter
& rIter
, int nIndentLevel
)
4430 const SalInstanceTreeIter
& rVclIter
= static_cast<const SalInstanceTreeIter
&>(rIter
);
4431 rVclIter
.iter
->SetExtraIndent(nIndentLevel
);
4434 void SalInstanceTreeView::set_text_emphasis(SvTreeListEntry
* pEntry
, bool bOn
, int col
)
4436 col
= to_internal_model(col
);
4438 assert(col
>= 0 && o3tl::make_unsigned(col
) < pEntry
->ItemCount());
4439 SvLBoxItem
& rItem
= pEntry
->GetItem(col
);
4440 assert(dynamic_cast<SvLBoxString
*>(&rItem
));
4441 static_cast<SvLBoxString
&>(rItem
).Emphasize(bOn
);
4443 InvalidateModelEntry(pEntry
);
4446 void SalInstanceTreeView::set_text_emphasis(const weld::TreeIter
& rIter
, bool bOn
, int col
)
4448 const SalInstanceTreeIter
& rVclIter
= static_cast<const SalInstanceTreeIter
&>(rIter
);
4449 set_text_emphasis(rVclIter
.iter
, bOn
, col
);
4452 void SalInstanceTreeView::set_text_emphasis(int pos
, bool bOn
, int col
)
4454 SvTreeListEntry
* pEntry
= m_xTreeView
->GetEntry(nullptr, pos
);
4455 set_text_emphasis(pEntry
, bOn
, col
);
4458 bool SalInstanceTreeView::get_text_emphasis(const weld::TreeIter
& rIter
, int col
) const
4460 const SalInstanceTreeIter
& rVclIter
= static_cast<const SalInstanceTreeIter
&>(rIter
);
4461 return get_text_emphasis(rVclIter
.iter
, col
);
4464 bool SalInstanceTreeView::get_text_emphasis(int pos
, int col
) const
4466 SvTreeListEntry
* pEntry
= m_xTreeView
->GetEntry(nullptr, pos
);
4467 return get_text_emphasis(pEntry
, col
);
4470 void SalInstanceTreeView::set_text_align(SvTreeListEntry
* pEntry
, double fAlign
, int col
)
4472 col
= to_internal_model(col
);
4474 assert(col
>= 0 && o3tl::make_unsigned(col
) < pEntry
->ItemCount());
4475 SvLBoxItem
& rItem
= pEntry
->GetItem(col
);
4476 assert(dynamic_cast<SvLBoxString
*>(&rItem
));
4477 static_cast<SvLBoxString
&>(rItem
).Align(fAlign
);
4479 InvalidateModelEntry(pEntry
);
4482 void SalInstanceTreeView::set_text_align(const weld::TreeIter
& rIter
, double fAlign
, int col
)
4484 const SalInstanceTreeIter
& rVclIter
= static_cast<const SalInstanceTreeIter
&>(rIter
);
4485 set_text_align(rVclIter
.iter
, fAlign
, col
);
4488 void SalInstanceTreeView::set_text_align(int pos
, double fAlign
, int col
)
4490 SvTreeListEntry
* pEntry
= m_xTreeView
->GetEntry(nullptr, pos
);
4491 set_text_align(pEntry
, fAlign
, col
);
4494 void SalInstanceTreeView::connect_editing(const Link
<const weld::TreeIter
&, bool>& rStartLink
,
4495 const Link
<const iter_string
&, bool>& rEndLink
)
4497 m_xTreeView
->EnableInplaceEditing(rStartLink
.IsSet() || rEndLink
.IsSet());
4498 weld::TreeView::connect_editing(rStartLink
, rEndLink
);
4501 void SalInstanceTreeView::start_editing(const weld::TreeIter
& rIter
)
4503 const SalInstanceTreeIter
& rVclIter
= static_cast<const SalInstanceTreeIter
&>(rIter
);
4504 m_xTreeView
->EditEntry(rVclIter
.iter
);
4507 void SalInstanceTreeView::end_editing() { m_xTreeView
->EndEditing(); }
4509 void SalInstanceTreeView::set_image(SvTreeListEntry
* pEntry
, const Image
& rImage
, int col
)
4513 m_xTreeView
->SetExpandedEntryBmp(pEntry
, rImage
);
4514 m_xTreeView
->SetCollapsedEntryBmp(pEntry
, rImage
);
4518 col
= to_internal_model(col
);
4520 // blank out missing entries
4521 for (int i
= pEntry
->ItemCount(); i
< col
; ++i
)
4522 AddStringItem(pEntry
, "", i
- 1);
4524 if (static_cast<size_t>(col
) == pEntry
->ItemCount())
4526 pEntry
->AddItem(std::make_unique
<SvLBoxContextBmp
>(rImage
, rImage
, false));
4527 SvViewDataEntry
* pViewData
= m_xTreeView
->GetViewDataEntry(pEntry
);
4528 m_xTreeView
->InitViewData(pViewData
, pEntry
);
4532 assert(col
>= 0 && o3tl::make_unsigned(col
) < pEntry
->ItemCount());
4533 SvLBoxItem
& rItem
= pEntry
->GetItem(col
);
4534 assert(dynamic_cast<SvLBoxContextBmp
*>(&rItem
));
4535 static_cast<SvLBoxContextBmp
&>(rItem
).SetBitmap1(rImage
);
4536 static_cast<SvLBoxContextBmp
&>(rItem
).SetBitmap2(rImage
);
4539 m_xTreeView
->CalcEntryHeight(pEntry
);
4540 InvalidateModelEntry(pEntry
);
4543 void SalInstanceTreeView::set_image(int pos
, const OUString
& rImage
, int col
)
4545 set_image(m_xTreeView
->GetEntry(nullptr, pos
), createImage(rImage
), col
);
4548 void SalInstanceTreeView::set_image(int pos
,
4549 const css::uno::Reference
<css::graphic::XGraphic
>& rImage
,
4552 set_image(m_xTreeView
->GetEntry(nullptr, pos
), Image(rImage
), col
);
4555 void SalInstanceTreeView::set_image(int pos
, VirtualDevice
& rImage
, int col
)
4557 set_image(m_xTreeView
->GetEntry(nullptr, pos
), createImage(rImage
), col
);
4560 void SalInstanceTreeView::set_image(const weld::TreeIter
& rIter
, const OUString
& rImage
, int col
)
4562 const SalInstanceTreeIter
& rVclIter
= static_cast<const SalInstanceTreeIter
&>(rIter
);
4563 set_image(rVclIter
.iter
, createImage(rImage
), col
);
4566 void SalInstanceTreeView::set_image(const weld::TreeIter
& rIter
,
4567 const css::uno::Reference
<css::graphic::XGraphic
>& rImage
,
4570 const SalInstanceTreeIter
& rVclIter
= static_cast<const SalInstanceTreeIter
&>(rIter
);
4571 set_image(rVclIter
.iter
, Image(rImage
), col
);
4574 void SalInstanceTreeView::set_image(const weld::TreeIter
& rIter
, VirtualDevice
& rImage
, int col
)
4576 const SalInstanceTreeIter
& rVclIter
= static_cast<const SalInstanceTreeIter
&>(rIter
);
4577 set_image(rVclIter
.iter
, createImage(rImage
), col
);
4580 const OUString
* SalInstanceTreeView::getEntryData(int index
) const
4582 SvTreeListEntry
* pEntry
= m_xTreeView
->GetEntry(nullptr, index
);
4583 return pEntry
? static_cast<const OUString
*>(pEntry
->GetUserData()) : nullptr;
4586 OUString
SalInstanceTreeView::get_id(int pos
) const
4588 const OUString
* pRet
= getEntryData(pos
);
4594 void SalInstanceTreeView::set_id(SvTreeListEntry
* pEntry
, const OUString
& rId
)
4596 m_aUserData
.emplace_back(std::make_unique
<OUString
>(rId
));
4597 pEntry
->SetUserData(m_aUserData
.back().get());
4600 void SalInstanceTreeView::set_id(int pos
, const OUString
& rId
)
4602 SvTreeListEntry
* pEntry
= m_xTreeView
->GetEntry(nullptr, pos
);
4603 set_id(pEntry
, rId
);
4606 int SalInstanceTreeView::get_selected_index() const
4608 assert(m_xTreeView
->IsUpdateMode() && "don't request selection when frozen");
4609 SvTreeListEntry
* pEntry
= m_xTreeView
->FirstSelected();
4612 return SvTreeList::GetRelPos(pEntry
);
4615 OUString
SalInstanceTreeView::get_selected_text() const
4617 assert(m_xTreeView
->IsUpdateMode() && "don't request selection when frozen");
4618 if (SvTreeListEntry
* pEntry
= m_xTreeView
->FirstSelected())
4619 return SvTabListBox::GetEntryText(pEntry
, 0);
4623 OUString
SalInstanceTreeView::get_selected_id() const
4625 assert(m_xTreeView
->IsUpdateMode() && "don't request selection when frozen");
4626 if (SvTreeListEntry
* pEntry
= m_xTreeView
->FirstSelected())
4628 if (const OUString
* pStr
= static_cast<const OUString
*>(pEntry
->GetUserData()))
4634 std::unique_ptr
<weld::TreeIter
>
4635 SalInstanceTreeView::make_iterator(const weld::TreeIter
* pOrig
) const
4637 return std::unique_ptr
<weld::TreeIter
>(
4638 new SalInstanceTreeIter(static_cast<const SalInstanceTreeIter
*>(pOrig
)));
4641 void SalInstanceTreeView::copy_iterator(const weld::TreeIter
& rSource
, weld::TreeIter
& rDest
) const
4643 const SalInstanceTreeIter
& rVclSource(static_cast<const SalInstanceTreeIter
&>(rSource
));
4644 SalInstanceTreeIter
& rVclDest(static_cast<SalInstanceTreeIter
&>(rDest
));
4645 rVclDest
.iter
= rVclSource
.iter
;
4648 bool SalInstanceTreeView::get_selected(weld::TreeIter
* pIter
) const
4650 SvTreeListEntry
* pEntry
= m_xTreeView
->FirstSelected();
4651 auto pVclIter
= static_cast<SalInstanceTreeIter
*>(pIter
);
4653 pVclIter
->iter
= pEntry
;
4654 return pEntry
!= nullptr;
4657 bool SalInstanceTreeView::get_cursor(weld::TreeIter
* pIter
) const
4659 SvTreeListEntry
* pEntry
= m_xTreeView
->GetCurEntry();
4660 auto pVclIter
= static_cast<SalInstanceTreeIter
*>(pIter
);
4662 pVclIter
->iter
= pEntry
;
4663 return pEntry
!= nullptr;
4666 void SalInstanceTreeView::set_cursor(const weld::TreeIter
& rIter
)
4668 const SalInstanceTreeIter
& rVclIter
= static_cast<const SalInstanceTreeIter
&>(rIter
);
4669 disable_notify_events();
4670 m_xTreeView
->SetCurEntry(rVclIter
.iter
);
4671 enable_notify_events();
4674 bool SalInstanceTreeView::get_iter_first(weld::TreeIter
& rIter
) const
4676 SalInstanceTreeIter
& rVclIter
= static_cast<SalInstanceTreeIter
&>(rIter
);
4677 rVclIter
.iter
= m_xTreeView
->GetEntry(0);
4678 return rVclIter
.iter
!= nullptr;
4681 bool SalInstanceTreeView::get_iter_abs_pos(weld::TreeIter
& rIter
, int nAbsPos
) const
4683 SalInstanceTreeIter
& rVclIter
= static_cast<SalInstanceTreeIter
&>(rIter
);
4684 rVclIter
.iter
= m_xTreeView
->GetEntryAtAbsPos(nAbsPos
);
4685 return rVclIter
.iter
!= nullptr;
4688 bool SalInstanceTreeView::iter_next_sibling(weld::TreeIter
& rIter
) const
4690 SalInstanceTreeIter
& rVclIter
= static_cast<SalInstanceTreeIter
&>(rIter
);
4691 rVclIter
.iter
= rVclIter
.iter
->NextSibling();
4692 return rVclIter
.iter
!= nullptr;
4695 bool SalInstanceTreeView::iter_previous_sibling(weld::TreeIter
& rIter
) const
4697 SalInstanceTreeIter
& rVclIter
= static_cast<SalInstanceTreeIter
&>(rIter
);
4698 rVclIter
.iter
= rVclIter
.iter
->PrevSibling();
4699 return rVclIter
.iter
!= nullptr;
4702 bool SalInstanceTreeView::iter_next(weld::TreeIter
& rIter
) const
4704 SalInstanceTreeIter
& rVclIter
= static_cast<SalInstanceTreeIter
&>(rIter
);
4705 rVclIter
.iter
= m_xTreeView
->Next(rVclIter
.iter
);
4706 if (rVclIter
.iter
&& IsDummyEntry(rVclIter
.iter
))
4707 return iter_next(rVclIter
);
4708 return rVclIter
.iter
!= nullptr;
4711 bool SalInstanceTreeView::iter_previous(weld::TreeIter
& rIter
) const
4713 SalInstanceTreeIter
& rVclIter
= static_cast<SalInstanceTreeIter
&>(rIter
);
4714 rVclIter
.iter
= m_xTreeView
->Prev(rVclIter
.iter
);
4715 if (rVclIter
.iter
&& IsDummyEntry(rVclIter
.iter
))
4716 return iter_previous(rVclIter
);
4717 return rVclIter
.iter
!= nullptr;
4720 bool SalInstanceTreeView::iter_children(weld::TreeIter
& rIter
) const
4722 SalInstanceTreeIter
& rVclIter
= static_cast<SalInstanceTreeIter
&>(rIter
);
4723 rVclIter
.iter
= m_xTreeView
->FirstChild(rVclIter
.iter
);
4724 bool bRet
= rVclIter
.iter
!= nullptr;
4727 //on-demand dummy entry doesn't count
4728 return !IsDummyEntry(rVclIter
.iter
);
4733 bool SalInstanceTreeView::iter_parent(weld::TreeIter
& rIter
) const
4735 SalInstanceTreeIter
& rVclIter
= static_cast<SalInstanceTreeIter
&>(rIter
);
4736 rVclIter
.iter
= m_xTreeView
->GetParent(rVclIter
.iter
);
4737 return rVclIter
.iter
!= nullptr;
4740 void SalInstanceTreeView::remove(const weld::TreeIter
& rIter
)
4742 disable_notify_events();
4743 const SalInstanceTreeIter
& rVclIter
= static_cast<const SalInstanceTreeIter
&>(rIter
);
4744 m_xTreeView
->RemoveEntry(rVclIter
.iter
);
4745 enable_notify_events();
4748 void SalInstanceTreeView::select(const weld::TreeIter
& rIter
)
4750 assert(m_xTreeView
->IsUpdateMode()
4751 && "don't select when frozen, select after thaw. Note selection doesn't survive a "
4753 disable_notify_events();
4754 const SalInstanceTreeIter
& rVclIter
= static_cast<const SalInstanceTreeIter
&>(rIter
);
4755 m_xTreeView
->Select(rVclIter
.iter
, true);
4756 enable_notify_events();
4759 void SalInstanceTreeView::scroll_to_row(const weld::TreeIter
& rIter
)
4761 assert(m_xTreeView
->IsUpdateMode()
4762 && "don't select when frozen, select after thaw. Note selection doesn't survive a "
4764 disable_notify_events();
4765 const SalInstanceTreeIter
& rVclIter
= static_cast<const SalInstanceTreeIter
&>(rIter
);
4766 m_xTreeView
->MakeVisible(rVclIter
.iter
);
4767 enable_notify_events();
4770 void SalInstanceTreeView::unselect(const weld::TreeIter
& rIter
)
4772 assert(m_xTreeView
->IsUpdateMode() && "don't unselect when frozen");
4773 disable_notify_events();
4774 const SalInstanceTreeIter
& rVclIter
= static_cast<const SalInstanceTreeIter
&>(rIter
);
4775 m_xTreeView
->Select(rVclIter
.iter
, false);
4776 enable_notify_events();
4779 int SalInstanceTreeView::get_iter_depth(const weld::TreeIter
& rIter
) const
4781 const SalInstanceTreeIter
& rVclIter
= static_cast<const SalInstanceTreeIter
&>(rIter
);
4782 return m_xTreeView
->GetModel()->GetDepth(rVclIter
.iter
);
4785 bool SalInstanceTreeView::iter_has_child(const weld::TreeIter
& rIter
) const
4787 SalInstanceTreeIter
aTempCopy(static_cast<const SalInstanceTreeIter
*>(&rIter
));
4788 return iter_children(aTempCopy
);
4791 bool SalInstanceTreeView::get_row_expanded(const weld::TreeIter
& rIter
) const
4793 const SalInstanceTreeIter
& rVclIter
= static_cast<const SalInstanceTreeIter
&>(rIter
);
4794 return m_xTreeView
->IsExpanded(rVclIter
.iter
);
4797 bool SalInstanceTreeView::get_children_on_demand(const weld::TreeIter
& rIter
) const
4799 const SalInstanceTreeIter
& rVclIter
= static_cast<const SalInstanceTreeIter
&>(rIter
);
4800 if (m_aExpandingPlaceHolderParents
.count(rVclIter
.iter
))
4802 return GetPlaceHolderChild(rVclIter
.iter
) != nullptr;
4805 void SalInstanceTreeView::set_children_on_demand(const weld::TreeIter
& rIter
,
4806 bool bChildrenOnDemand
)
4808 disable_notify_events();
4810 const SalInstanceTreeIter
& rVclIter
= static_cast<const SalInstanceTreeIter
&>(rIter
);
4812 SvTreeListEntry
* pPlaceHolder
= GetPlaceHolderChild(rVclIter
.iter
);
4814 if (bChildrenOnDemand
&& !pPlaceHolder
)
4816 pPlaceHolder
= m_xTreeView
->InsertEntry("<dummy>", rVclIter
.iter
, false, 0, nullptr);
4817 SvViewDataEntry
* pViewData
= m_xTreeView
->GetViewDataEntry(pPlaceHolder
);
4818 pViewData
->SetSelectable(false);
4820 else if (!bChildrenOnDemand
&& pPlaceHolder
)
4821 m_xTreeView
->RemoveEntry(pPlaceHolder
);
4823 enable_notify_events();
4826 void SalInstanceTreeView::expand_row(const weld::TreeIter
& rIter
)
4828 assert(m_xTreeView
->IsUpdateMode() && "don't expand when frozen");
4829 const SalInstanceTreeIter
& rVclIter
= static_cast<const SalInstanceTreeIter
&>(rIter
);
4830 if (!m_xTreeView
->IsExpanded(rVclIter
.iter
) && ExpandRow(rVclIter
))
4831 m_xTreeView
->Expand(rVclIter
.iter
);
4834 void SalInstanceTreeView::collapse_row(const weld::TreeIter
& rIter
)
4836 const SalInstanceTreeIter
& rVclIter
= static_cast<const SalInstanceTreeIter
&>(rIter
);
4837 if (m_xTreeView
->IsExpanded(rVclIter
.iter
) && signal_collapsing(rIter
))
4838 m_xTreeView
->Collapse(rVclIter
.iter
);
4841 OUString
SalInstanceTreeView::get_text(const weld::TreeIter
& rIter
, int col
) const
4843 const SalInstanceTreeIter
& rVclIter
= static_cast<const SalInstanceTreeIter
&>(rIter
);
4844 return get_text(rVclIter
.iter
, col
);
4847 void SalInstanceTreeView::set_text(const weld::TreeIter
& rIter
, const OUString
& rText
, int col
)
4849 const SalInstanceTreeIter
& rVclIter
= static_cast<const SalInstanceTreeIter
&>(rIter
);
4850 set_text(rVclIter
.iter
, rText
, col
);
4853 OUString
SalInstanceTreeView::get_id(const weld::TreeIter
& rIter
) const
4855 const SalInstanceTreeIter
& rVclIter
= static_cast<const SalInstanceTreeIter
&>(rIter
);
4856 const OUString
* pStr
= static_cast<const OUString
*>(rVclIter
.iter
->GetUserData());
4862 void SalInstanceTreeView::set_id(const weld::TreeIter
& rIter
, const OUString
& rId
)
4864 const SalInstanceTreeIter
& rVclIter
= static_cast<const SalInstanceTreeIter
&>(rIter
);
4865 set_id(rVclIter
.iter
, rId
);
4868 void SalInstanceTreeView::enable_drag_source(rtl::Reference
<TransferDataContainer
>& rHelper
,
4869 sal_uInt8 eDNDConstants
)
4871 m_xTreeView
->SetDragHelper(rHelper
, eDNDConstants
);
4874 void SalInstanceTreeView::set_selection_mode(SelectionMode eMode
)
4876 m_xTreeView
->SetSelectionMode(eMode
);
4879 void SalInstanceTreeView::all_foreach(const std::function
<bool(weld::TreeIter
&)>& func
)
4881 UpdateGuardIfHidden
aGuard(*m_xTreeView
);
4883 SalInstanceTreeIter
aVclIter(m_xTreeView
->First());
4884 while (aVclIter
.iter
)
4888 iter_next(aVclIter
);
4892 void SalInstanceTreeView::selected_foreach(const std::function
<bool(weld::TreeIter
&)>& func
)
4894 UpdateGuardIfHidden
aGuard(*m_xTreeView
);
4896 SalInstanceTreeIter
aVclIter(m_xTreeView
->FirstSelected());
4897 while (aVclIter
.iter
)
4901 aVclIter
.iter
= m_xTreeView
->NextSelected(aVclIter
.iter
);
4905 void SalInstanceTreeView::visible_foreach(const std::function
<bool(weld::TreeIter
&)>& func
)
4907 UpdateGuardIfHidden
aGuard(*m_xTreeView
);
4909 SalInstanceTreeIter
aVclIter(m_xTreeView
->GetFirstEntryInView());
4910 while (aVclIter
.iter
)
4914 aVclIter
.iter
= m_xTreeView
->GetNextEntryInView(aVclIter
.iter
);
4918 void SalInstanceTreeView::connect_visible_range_changed(const Link
<weld::TreeView
&, void>& rLink
)
4920 weld::TreeView::connect_visible_range_changed(rLink
);
4921 m_xTreeView
->SetScrolledHdl(LINK(this, SalInstanceTreeView
, VisibleRangeChangedHdl
));
4924 void SalInstanceTreeView::remove_selection()
4926 disable_notify_events();
4927 SvTreeListEntry
* pSelected
= m_xTreeView
->FirstSelected();
4930 SvTreeListEntry
* pNextSelected
= m_xTreeView
->NextSelected(pSelected
);
4931 m_xTreeView
->RemoveEntry(pSelected
);
4932 pSelected
= pNextSelected
;
4934 enable_notify_events();
4937 bool SalInstanceTreeView::is_selected(const weld::TreeIter
& rIter
) const
4939 const SalInstanceTreeIter
& rVclIter
= static_cast<const SalInstanceTreeIter
&>(rIter
);
4940 return m_xTreeView
->IsSelected(rVclIter
.iter
);
4943 int SalInstanceTreeView::get_iter_index_in_parent(const weld::TreeIter
& rIter
) const
4945 const SalInstanceTreeIter
& rVclIter
= static_cast<const SalInstanceTreeIter
&>(rIter
);
4946 return SvTreeList::GetRelPos(rVclIter
.iter
);
4949 int SalInstanceTreeView::iter_compare(const weld::TreeIter
& a
, const weld::TreeIter
& b
) const
4951 const SalInstanceTreeIter
& rVclIterA
= static_cast<const SalInstanceTreeIter
&>(a
);
4952 const SalInstanceTreeIter
& rVclIterB
= static_cast<const SalInstanceTreeIter
&>(b
);
4953 const SvTreeList
* pModel
= m_xTreeView
->GetModel();
4954 auto nAbsPosA
= pModel
->GetAbsPos(rVclIterA
.iter
);
4955 auto nAbsPosB
= pModel
->GetAbsPos(rVclIterB
.iter
);
4956 if (nAbsPosA
< nAbsPosB
)
4958 if (nAbsPosA
> nAbsPosB
)
4963 void SalInstanceTreeView::move_subtree(weld::TreeIter
& rNode
, const weld::TreeIter
* pNewParent
,
4964 int nIndexInNewParent
)
4966 SalInstanceTreeIter
& rVclIter
= static_cast<SalInstanceTreeIter
&>(rNode
);
4967 const SalInstanceTreeIter
* pVclParentIter
= static_cast<const SalInstanceTreeIter
*>(pNewParent
);
4968 m_xTreeView
->GetModel()->Move(rVclIter
.iter
, pVclParentIter
? pVclParentIter
->iter
: nullptr,
4972 int SalInstanceTreeView::count_selected_rows() const { return m_xTreeView
->GetSelectionCount(); }
4974 int SalInstanceTreeView::get_height_rows(int nRows
) const
4976 int nHeight
= m_xTreeView
->GetEntryHeight() * nRows
;
4978 sal_Int32
nLeftBorder(0), nTopBorder(0), nRightBorder(0), nBottomBorder(0);
4979 m_xTreeView
->GetBorder(nLeftBorder
, nTopBorder
, nRightBorder
, nBottomBorder
);
4980 nHeight
+= nTopBorder
+ nBottomBorder
;
4985 void SalInstanceTreeView::make_sorted()
4987 assert(m_xTreeView
->IsUpdateMode() && "don't sort when frozen");
4988 m_xTreeView
->SetStyle(m_xTreeView
->GetStyle() | WB_SORT
);
4989 m_xTreeView
->GetModel()->SetCompareHdl(LINK(this, SalInstanceTreeView
, CompareHdl
));
4990 set_sort_order(true);
4993 void SalInstanceTreeView::set_sort_func(
4994 const std::function
<int(const weld::TreeIter
&, const weld::TreeIter
&)>& func
)
4996 weld::TreeView::set_sort_func(func
);
4997 SvTreeList
* pListModel
= m_xTreeView
->GetModel();
4998 pListModel
->Resort();
5001 void SalInstanceTreeView::make_unsorted()
5003 m_xTreeView
->SetStyle(m_xTreeView
->GetStyle() & ~WB_SORT
);
5006 void SalInstanceTreeView::set_sort_order(bool bAscending
)
5008 SvTreeList
* pListModel
= m_xTreeView
->GetModel();
5009 pListModel
->SetSortMode(bAscending
? SvSortMode::Ascending
: SvSortMode::Descending
);
5010 pListModel
->Resort();
5013 bool SalInstanceTreeView::get_sort_order() const
5015 return m_xTreeView
->GetModel()->GetSortMode() == SvSortMode::Ascending
;
5018 void SalInstanceTreeView::set_sort_indicator(TriState eState
, int col
)
5020 assert(col
>= 0 && "cannot sort on expander column");
5022 LclHeaderTabListBox
* pHeaderBox
= dynamic_cast<LclHeaderTabListBox
*>(m_xTreeView
.get());
5023 HeaderBar
* pHeaderBar
= pHeaderBox
? pHeaderBox
->GetHeaderBar() : nullptr;
5027 sal_uInt16 nTextId
= pHeaderBar
->GetItemId(col
);
5028 HeaderBarItemBits nBits
= pHeaderBar
->GetItemBits(nTextId
);
5029 nBits
&= ~HeaderBarItemBits::UPARROW
;
5030 nBits
&= ~HeaderBarItemBits::DOWNARROW
;
5031 if (eState
!= TRISTATE_INDET
)
5033 if (eState
== TRISTATE_TRUE
)
5034 nBits
|= HeaderBarItemBits::DOWNARROW
;
5036 nBits
|= HeaderBarItemBits::UPARROW
;
5038 pHeaderBar
->SetItemBits(nTextId
, nBits
);
5041 TriState
SalInstanceTreeView::get_sort_indicator(int col
) const
5043 assert(col
>= 0 && "cannot sort on expander column");
5045 LclHeaderTabListBox
* pHeaderBox
= dynamic_cast<LclHeaderTabListBox
*>(m_xTreeView
.get());
5046 if (HeaderBar
* pHeaderBar
= pHeaderBox
? pHeaderBox
->GetHeaderBar() : nullptr)
5048 sal_uInt16 nTextId
= pHeaderBar
->GetItemId(col
);
5049 HeaderBarItemBits nBits
= pHeaderBar
->GetItemBits(nTextId
);
5050 if (nBits
& HeaderBarItemBits::DOWNARROW
)
5051 return TRISTATE_TRUE
;
5052 if (nBits
& HeaderBarItemBits::UPARROW
)
5053 return TRISTATE_FALSE
;
5056 return TRISTATE_INDET
;
5059 int SalInstanceTreeView::get_sort_column() const { return m_nSortColumn
; }
5061 void SalInstanceTreeView::set_sort_column(int nColumn
)
5070 if (nColumn
!= m_nSortColumn
)
5072 m_nSortColumn
= nColumn
;
5073 m_xTreeView
->GetModel()->Resort();
5077 SvTabListBox
& SalInstanceTreeView::getTreeView() { return *m_xTreeView
; }
5079 bool SalInstanceTreeView::get_dest_row_at_pos(const Point
& rPos
, weld::TreeIter
* pResult
,
5080 bool bDnDMode
, bool bAutoScroll
)
5082 LclTabListBox
* pTreeView
5083 = !bDnDMode
? dynamic_cast<LclTabListBox
*>(m_xTreeView
.get()) : nullptr;
5084 SvTreeListEntry
* pTarget
= pTreeView
? pTreeView
->GetTargetAtPoint(rPos
, false, bAutoScroll
)
5085 : m_xTreeView
->GetDropTarget(rPos
);
5087 if (pTarget
&& pResult
)
5089 SalInstanceTreeIter
& rSalIter
= static_cast<SalInstanceTreeIter
&>(*pResult
);
5090 rSalIter
.iter
= pTarget
;
5093 return pTarget
!= nullptr;
5096 void SalInstanceTreeView::unset_drag_dest_row() { m_xTreeView
->UnsetDropTarget(); }
5098 tools::Rectangle
SalInstanceTreeView::get_row_area(const weld::TreeIter
& rIter
) const
5100 return m_xTreeView
->GetBoundingRect(static_cast<const SalInstanceTreeIter
&>(rIter
).iter
);
5103 weld::TreeView
* SalInstanceTreeView::get_drag_source() const { return g_DragSource
; }
5105 int SalInstanceTreeView::vadjustment_get_value() const
5108 const SvTreeListEntry
* pEntry
= m_xTreeView
->GetFirstEntryInView();
5110 nValue
= m_xTreeView
->GetAbsPos(pEntry
);
5114 void SalInstanceTreeView::vadjustment_set_value(int nValue
)
5118 bool bUpdate
= m_xTreeView
->IsUpdateMode();
5120 m_xTreeView
->SetUpdateMode(false);
5121 m_xTreeView
->ScrollToAbsPos(nValue
);
5123 m_xTreeView
->SetUpdateMode(true);
5126 void SalInstanceTreeView::set_show_expanders(bool bShow
)
5128 m_xTreeView
->set_property("show-expanders", OUString::boolean(bShow
));
5131 bool SalInstanceTreeView::changed_by_hover() const { return m_xTreeView
->IsSelectDueToHover(); }
5133 SalInstanceTreeView::~SalInstanceTreeView()
5135 LclHeaderTabListBox
* pHeaderBox
= dynamic_cast<LclHeaderTabListBox
*>(m_xTreeView
.get());
5138 if (HeaderBar
* pHeaderBar
= pHeaderBox
->GetHeaderBar())
5140 pHeaderBar
->SetSelectHdl(Link
<HeaderBar
*, void>());
5141 pHeaderBar
->SetEndDragHdl(Link
<HeaderBar
*, void>());
5146 static_cast<LclTabListBox
&>(*m_xTreeView
).SetEndDragHdl(Link
<SvTreeListBox
*, void>());
5147 static_cast<LclTabListBox
&>(*m_xTreeView
).SetStartDragHdl(Link
<SvTreeListBox
*, bool>());
5148 static_cast<LclTabListBox
&>(*m_xTreeView
).SetModelChangedHdl(Link
<SvTreeListBox
*, void>());
5150 if (g_DragSource
== this)
5151 g_DragSource
= nullptr;
5152 m_xTreeView
->SetPopupMenuHdl(Link
<const CommandEvent
&, bool>());
5153 m_xTreeView
->SetExpandingHdl(Link
<SvTreeListBox
*, bool>());
5154 m_xTreeView
->SetDoubleClickHdl(Link
<SvTreeListBox
*, bool>());
5155 m_xTreeView
->SetSelectHdl(Link
<SvTreeListBox
*, void>());
5156 m_xTreeView
->SetDeselectHdl(Link
<SvTreeListBox
*, void>());
5157 m_xTreeView
->SetScrolledHdl(Link
<SvTreeListBox
*, void>());
5158 m_xTreeView
->SetTooltipHdl({});
5159 m_xTreeView
->SetCustomRenderHdl(Link
<svtree_render_args
, void>());
5160 m_xTreeView
->SetCustomMeasureHdl(Link
<svtree_measure_args
, Size
>());
5163 IMPL_LINK(SalInstanceTreeView
, TooltipHdl
, SvTreeListEntry
*, pEntry
, OUString
)
5165 if (pEntry
&& !notify_events_disabled())
5166 return signal_query_tooltip(SalInstanceTreeIter(pEntry
));
5171 IMPL_LINK(SalInstanceTreeView
, CustomRenderHdl
, svtree_render_args
, payload
, void)
5173 vcl::RenderContext
& rRenderDevice
= std::get
<0>(payload
);
5174 const tools::Rectangle
& rRect
= std::get
<1>(payload
);
5175 const SvTreeListEntry
& rEntry
= std::get
<2>(payload
);
5176 const OUString
* pId
= static_cast<const OUString
*>(rEntry
.GetUserData());
5179 signal_custom_render(rRenderDevice
, rRect
, m_xTreeView
->IsSelected(&rEntry
), *pId
);
5182 IMPL_LINK(SalInstanceTreeView
, CustomMeasureHdl
, svtree_measure_args
, payload
, Size
)
5184 vcl::RenderContext
& rRenderDevice
= payload
.first
;
5185 const SvTreeListEntry
& rEntry
= payload
.second
;
5186 const OUString
* pId
= static_cast<const OUString
*>(rEntry
.GetUserData());
5189 return signal_custom_get_size(rRenderDevice
, *pId
);
5192 IMPL_LINK(SalInstanceTreeView
, CompareHdl
, const SvSortData
&, rSortData
, sal_Int32
)
5194 const SvTreeListEntry
* pLHS
= rSortData
.pLeft
;
5195 const SvTreeListEntry
* pRHS
= rSortData
.pRight
;
5196 assert(pLHS
&& pRHS
);
5199 return m_aCustomSort(SalInstanceTreeIter(const_cast<SvTreeListEntry
*>(pLHS
)),
5200 SalInstanceTreeIter(const_cast<SvTreeListEntry
*>(pRHS
)));
5202 const SvLBoxString
* pLeftTextItem
;
5203 const SvLBoxString
* pRightTextItem
;
5205 if (m_nSortColumn
!= -1)
5207 size_t col
= to_internal_model(m_nSortColumn
);
5209 if (col
< pLHS
->ItemCount())
5211 const SvLBoxString
& rLeftTextItem
5212 = static_cast<const SvLBoxString
&>(pLHS
->GetItem(col
));
5213 pLeftTextItem
= &rLeftTextItem
;
5216 pLeftTextItem
= nullptr;
5217 if (col
< pRHS
->ItemCount())
5219 const SvLBoxString
& rRightTextItem
5220 = static_cast<const SvLBoxString
&>(pRHS
->GetItem(col
));
5221 pRightTextItem
= &rRightTextItem
;
5224 pRightTextItem
= nullptr;
5229 = static_cast<const SvLBoxString
*>(pLHS
->GetFirstItem(SvLBoxItemType::String
));
5231 = static_cast<const SvLBoxString
*>(pRHS
->GetFirstItem(SvLBoxItemType::String
));
5234 return m_xTreeView
->DefaultCompare(pLeftTextItem
, pRightTextItem
);
5237 IMPL_LINK_NOARG(SalInstanceTreeView
, VisibleRangeChangedHdl
, SvTreeListBox
*, void)
5239 if (notify_events_disabled())
5241 signal_visible_range_changed();
5244 IMPL_LINK_NOARG(SalInstanceTreeView
, ModelChangedHdl
, SvTreeListBox
*, void)
5246 if (notify_events_disabled())
5248 signal_model_changed();
5251 IMPL_LINK_NOARG(SalInstanceTreeView
, StartDragHdl
, SvTreeListBox
*, bool)
5253 bool bUnsetDragIcon(false); // ignored for vcl
5254 if (m_aDragBeginHdl
.Call(bUnsetDragIcon
))
5256 g_DragSource
= this;
5260 IMPL_STATIC_LINK_NOARG(SalInstanceTreeView
, FinishDragHdl
, SvTreeListBox
*, void)
5262 g_DragSource
= nullptr;
5265 IMPL_LINK(SalInstanceTreeView
, ToggleHdl
, SvLBoxButtonData
*, pData
, void)
5267 SvTreeListEntry
* pEntry
= pData
->GetActEntry();
5268 SvLBoxButton
* pBox
= pData
->GetActBox();
5270 // tdf#122874 Select the row, calling SelectHdl, before handling
5272 if (!m_xTreeView
->IsSelected(pEntry
))
5274 m_xTreeView
->SelectAll(false);
5275 m_xTreeView
->Select(pEntry
, true);
5278 // additionally set the cursor into the row the toggled element is in
5279 m_xTreeView
->pImpl
->m_pCursor
= pEntry
;
5281 for (int i
= 0, nCount
= pEntry
->ItemCount(); i
< nCount
; ++i
)
5283 SvLBoxItem
& rItem
= pEntry
->GetItem(i
);
5286 int nCol
= to_external_model(i
);
5287 signal_toggled(iter_col(SalInstanceTreeIter(pEntry
), nCol
));
5293 IMPL_LINK_NOARG(SalInstanceTreeView
, SelectHdl
, SvTreeListBox
*, void)
5295 if (notify_events_disabled())
5300 IMPL_LINK_NOARG(SalInstanceTreeView
, DeSelectHdl
, SvTreeListBox
*, void)
5302 if (notify_events_disabled())
5304 if (m_xTreeView
->GetSelectionMode() == SelectionMode::Single
5305 && !m_xTreeView
->GetHoverSelection())
5310 IMPL_LINK_NOARG(SalInstanceTreeView
, DoubleClickHdl
, SvTreeListBox
*, bool)
5312 if (notify_events_disabled())
5314 return !signal_row_activated();
5317 IMPL_LINK(SalInstanceTreeView
, EndDragHdl
, HeaderBar
*, pHeaderBar
, void)
5319 std::vector
<tools::Long
> aTabPositions
{ 0 };
5320 for (int i
= 0; i
< pHeaderBar
->GetItemCount() - 1; ++i
)
5321 aTabPositions
.push_back(aTabPositions
[i
]
5322 + pHeaderBar
->GetItemSize(pHeaderBar
->GetItemId(i
)));
5323 m_xTreeView
->SetTabs(aTabPositions
.size(), aTabPositions
.data(), MapUnit::MapPixel
);
5326 IMPL_LINK(SalInstanceTreeView
, HeaderBarClickedHdl
, HeaderBar
*, pHeaderBar
, void)
5328 sal_uInt16 nId
= pHeaderBar
->GetCurItemId();
5329 if (!(pHeaderBar
->GetItemBits(nId
) & HeaderBarItemBits::CLICKABLE
))
5331 signal_column_clicked(pHeaderBar
->GetItemPos(nId
));
5334 IMPL_LINK_NOARG(SalInstanceTreeView
, ExpandingHdl
, SvTreeListBox
*, bool)
5336 SvTreeListEntry
* pEntry
= m_xTreeView
->GetHdlEntry();
5337 SalInstanceTreeIter
aIter(pEntry
);
5339 if (m_xTreeView
->IsExpanded(pEntry
))
5342 return signal_collapsing(aIter
);
5346 return ExpandRow(aIter
);
5349 bool SalInstanceTreeView::ExpandRow(const SalInstanceTreeIter
& rIter
)
5351 SvTreeListEntry
* pEntry
= rIter
.iter
;
5352 // if there's a preexisting placeholder child, required to make this
5353 // potentially expandable in the first place, now we remove it
5354 SvTreeListEntry
* pPlaceHolder
= GetPlaceHolderChild(pEntry
);
5357 m_aExpandingPlaceHolderParents
.insert(pEntry
);
5358 m_xTreeView
->RemoveEntry(pPlaceHolder
);
5361 bool bRet
= signal_expanding(rIter
);
5365 //expand disallowed, restore placeholder
5368 pPlaceHolder
= m_xTreeView
->InsertEntry("<dummy>", pEntry
, false, 0, nullptr);
5369 SvViewDataEntry
* pViewData
= m_xTreeView
->GetViewDataEntry(pPlaceHolder
);
5370 pViewData
->SetSelectable(false);
5372 m_aExpandingPlaceHolderParents
.erase(pEntry
);
5378 IMPL_LINK(SalInstanceTreeView
, PopupMenuHdl
, const CommandEvent
&, rEvent
, bool)
5380 return m_aPopupMenuHdl
.Call(rEvent
);
5383 IMPL_LINK(SalInstanceTreeView
, EditingEntryHdl
, SvTreeListEntry
*, pEntry
, bool)
5385 return signal_editing_started(SalInstanceTreeIter(pEntry
));
5388 IMPL_LINK(SalInstanceTreeView
, EditedEntryHdl
, IterString
, rIterString
, bool)
5390 return signal_editing_done(
5391 iter_string(SalInstanceTreeIter(rIterString
.first
), rIterString
.second
));
5394 SalInstanceIconView::SalInstanceIconView(::IconView
* pIconView
, SalInstanceBuilder
* pBuilder
,
5395 bool bTakeOwnership
)
5396 : SalInstanceWidget(pIconView
, pBuilder
, bTakeOwnership
)
5397 , m_xIconView(pIconView
)
5399 m_xIconView
->SetSelectHdl(LINK(this, SalInstanceIconView
, SelectHdl
));
5400 m_xIconView
->SetDeselectHdl(LINK(this, SalInstanceIconView
, DeSelectHdl
));
5401 m_xIconView
->SetDoubleClickHdl(LINK(this, SalInstanceIconView
, DoubleClickHdl
));
5402 m_xIconView
->SetPopupMenuHdl(LINK(this, SalInstanceIconView
, CommandHdl
));
5404 m_xIconView
->SetEntryAccessibleDescriptionHdl(
5405 LINK(this, SalInstanceIconView
, EntryAccessibleDescriptionHdl
));
5406 m_xIconView
->SetAccessible(m_xIconView
->CreateAccessible());
5409 int SalInstanceIconView::get_item_width() const { return m_xIconView
->GetEntryWidth(); }
5410 void SalInstanceIconView::set_item_width(int width
)
5412 m_xIconView
->SetEntryWidth(width
);
5413 m_xIconView
->Resize();
5416 void SalInstanceIconView::freeze()
5418 bool bIsFirstFreeze
= IsFirstFreeze();
5419 SalInstanceWidget::freeze();
5421 m_xIconView
->SetUpdateMode(false);
5424 void SalInstanceIconView::thaw()
5426 bool bIsLastThaw
= IsLastThaw();
5428 m_xIconView
->SetUpdateMode(true);
5429 SalInstanceWidget::thaw();
5432 void SalInstanceIconView::insert(int pos
, const OUString
* pStr
, const OUString
* pId
,
5433 const OUString
* pIconName
, weld::TreeIter
* pRet
)
5435 disable_notify_events();
5436 auto nInsertPos
= pos
== -1 ? TREELIST_APPEND
: pos
;
5440 m_aUserData
.emplace_back(std::make_unique
<OUString
>(*pId
));
5441 pUserData
= m_aUserData
.back().get();
5444 pUserData
= nullptr;
5446 SvTreeListEntry
* pEntry
= new SvTreeListEntry
;
5449 Image
aImage(createImage(*pIconName
));
5450 pEntry
->AddItem(std::make_unique
<SvLBoxContextBmp
>(aImage
, aImage
, false));
5455 pEntry
->AddItem(std::make_unique
<SvLBoxContextBmp
>(aDummy
, aDummy
, false));
5458 pEntry
->AddItem(std::make_unique
<SvLBoxString
>(*pStr
));
5459 pEntry
->SetUserData(pUserData
);
5460 m_xIconView
->Insert(pEntry
, nullptr, nInsertPos
);
5464 SalInstanceTreeIter
* pVclRetIter
= static_cast<SalInstanceTreeIter
*>(pRet
);
5465 pVclRetIter
->iter
= pEntry
;
5468 enable_notify_events();
5471 void SalInstanceIconView::insert(int pos
, const OUString
* pStr
, const OUString
* pId
,
5472 const VirtualDevice
* pIcon
, weld::TreeIter
* pRet
)
5474 disable_notify_events();
5475 auto nInsertPos
= pos
== -1 ? TREELIST_APPEND
: pos
;
5479 m_aUserData
.emplace_back(std::make_unique
<OUString
>(*pId
));
5480 pUserData
= m_aUserData
.back().get();
5483 pUserData
= nullptr;
5485 SvTreeListEntry
* pEntry
= new SvTreeListEntry
;
5488 const Point
aNull(0, 0);
5489 const Size aSize
= pIcon
->GetOutputSize();
5490 Image
aImage(pIcon
->GetBitmapEx(aNull
, aSize
));
5491 pEntry
->AddItem(std::make_unique
<SvLBoxContextBmp
>(aImage
, aImage
, false));
5496 pEntry
->AddItem(std::make_unique
<SvLBoxContextBmp
>(aDummy
, aDummy
, false));
5499 pEntry
->AddItem(std::make_unique
<SvLBoxString
>(*pStr
));
5500 pEntry
->SetUserData(pUserData
);
5501 m_xIconView
->Insert(pEntry
, nullptr, nInsertPos
);
5505 SalInstanceTreeIter
* pVclRetIter
= static_cast<SalInstanceTreeIter
*>(pRet
);
5506 pVclRetIter
->iter
= pEntry
;
5509 enable_notify_events();
5512 void SalInstanceIconView::insert_separator(int pos
, const OUString
* /* pId */)
5514 const auto nInsertPos
= pos
== -1 ? TREELIST_APPEND
: pos
;
5515 const OUString
sSep(VclResId(STR_SEPARATOR
));
5516 SvTreeListEntry
* pEntry
= new SvTreeListEntry
;
5517 pEntry
->SetFlags(pEntry
->GetFlags() | SvTLEntryFlags::IS_SEPARATOR
);
5519 pEntry
->AddItem(std::make_unique
<SvLBoxContextBmp
>(aDummy
, aDummy
, false));
5520 pEntry
->AddItem(std::make_unique
<SvLBoxString
>(sSep
));
5521 pEntry
->SetUserData(nullptr);
5522 m_xIconView
->Insert(pEntry
, nullptr, nInsertPos
);
5523 SvViewDataEntry
* pViewData
= m_xIconView
->GetViewDataEntry(pEntry
);
5524 pViewData
->SetSelectable(false);
5527 IMPL_LINK(SalInstanceIconView
, TooltipHdl
, SvTreeListEntry
*, pEntry
, OUString
)
5529 if (pEntry
&& !notify_events_disabled())
5530 return signal_query_tooltip(SalInstanceTreeIter(pEntry
));
5535 IMPL_LINK(SalInstanceIconView
, EntryAccessibleDescriptionHdl
, SvTreeListEntry
*, pEntry
, OUString
)
5537 OUString s
= SvTreeListBox::SearchEntryTextWithHeadTitle(pEntry
);
5539 s
= signal_query_tooltip(SalInstanceTreeIter(pEntry
));
5543 void SalInstanceIconView::connect_query_tooltip(const Link
<const weld::TreeIter
&, OUString
>& rLink
)
5545 weld::IconView::connect_query_tooltip(rLink
);
5546 m_xIconView
->SetTooltipHdl(LINK(this, SalInstanceIconView
, TooltipHdl
));
5549 IMPL_LINK(SalInstanceIconView
, DumpElemToPropertyTreeHdl
, const ::IconView::json_prop_query
&,
5552 SvTreeListEntry
* pEntry
= std::get
<1>(rQuery
);
5553 return m_aGetPropertyTreeElemHdl
.Call(weld::json_prop_query(
5554 std::get
<0>(rQuery
), SalInstanceTreeIter(pEntry
), std::get
<2>(rQuery
)));
5557 void SalInstanceIconView::connect_get_property_tree_elem(
5558 const Link
<const weld::json_prop_query
&, bool>& rLink
)
5560 weld::IconView::connect_get_property_tree_elem(rLink
);
5561 m_xIconView
->SetDumpElemToPropertyTreeHdl(
5562 LINK(this, SalInstanceIconView
, DumpElemToPropertyTreeHdl
));
5565 OUString
SalInstanceIconView::get_selected_id() const
5567 assert(m_xIconView
->IsUpdateMode() && "don't request selection when frozen");
5568 if (SvTreeListEntry
* pEntry
= m_xIconView
->FirstSelected())
5570 if (const OUString
* pStr
= static_cast<const OUString
*>(pEntry
->GetUserData()))
5576 OUString
SalInstanceIconView::get_selected_text() const
5578 assert(m_xIconView
->IsUpdateMode() && "don't request selection when frozen");
5579 if (SvTreeListEntry
* pEntry
= m_xIconView
->FirstSelected())
5580 return m_xIconView
->GetEntryText(pEntry
);
5584 int SalInstanceIconView::count_selected_items() const { return m_xIconView
->GetSelectionCount(); }
5586 void SalInstanceIconView::select(int pos
)
5588 assert(m_xIconView
->IsUpdateMode()
5589 && "don't select when frozen, select after thaw. Note selection doesn't survive a "
5591 disable_notify_events();
5592 if (pos
== -1 || (pos
== 0 && n_children() == 0))
5593 m_xIconView
->SelectAll(false);
5596 SvTreeListEntry
* pEntry
= m_xIconView
->GetEntry(nullptr, pos
);
5597 m_xIconView
->Select(pEntry
, true);
5598 m_xIconView
->MakeVisible(pEntry
);
5600 enable_notify_events();
5603 void SalInstanceIconView::unselect(int pos
)
5605 assert(m_xIconView
->IsUpdateMode()
5606 && "don't select when frozen, select after thaw. Note selection doesn't survive a "
5608 disable_notify_events();
5610 m_xIconView
->SelectAll(true);
5613 SvTreeListEntry
* pEntry
= m_xIconView
->GetEntry(nullptr, pos
);
5614 m_xIconView
->Select(pEntry
, false);
5616 enable_notify_events();
5619 int SalInstanceIconView::n_children() const
5621 return m_xIconView
->GetModel()->GetChildList(nullptr).size();
5624 std::unique_ptr
<weld::TreeIter
>
5625 SalInstanceIconView::make_iterator(const weld::TreeIter
* pOrig
) const
5627 return std::unique_ptr
<weld::TreeIter
>(
5628 new SalInstanceTreeIter(static_cast<const SalInstanceTreeIter
*>(pOrig
)));
5631 bool SalInstanceIconView::get_selected(weld::TreeIter
* pIter
) const
5633 SvTreeListEntry
* pEntry
= m_xIconView
->FirstSelected();
5634 auto pVclIter
= static_cast<SalInstanceTreeIter
*>(pIter
);
5636 pVclIter
->iter
= pEntry
;
5637 return pEntry
!= nullptr;
5640 bool SalInstanceIconView::get_cursor(weld::TreeIter
* pIter
) const
5642 SvTreeListEntry
* pEntry
= m_xIconView
->GetCurEntry();
5643 auto pVclIter
= static_cast<SalInstanceTreeIter
*>(pIter
);
5645 pVclIter
->iter
= pEntry
;
5646 return pEntry
!= nullptr;
5649 void SalInstanceIconView::set_cursor(const weld::TreeIter
& rIter
)
5651 const SalInstanceTreeIter
& rVclIter
= static_cast<const SalInstanceTreeIter
&>(rIter
);
5652 disable_notify_events();
5653 m_xIconView
->SetCurEntry(rVclIter
.iter
);
5654 enable_notify_events();
5657 bool SalInstanceIconView::get_iter_first(weld::TreeIter
& rIter
) const
5659 SalInstanceTreeIter
& rVclIter
= static_cast<SalInstanceTreeIter
&>(rIter
);
5660 rVclIter
.iter
= m_xIconView
->GetEntry(0);
5661 return rVclIter
.iter
!= nullptr;
5664 void SalInstanceIconView::scroll_to_item(const weld::TreeIter
& rIter
)
5666 assert(m_xIconView
->IsUpdateMode()
5667 && "don't select when frozen, select after thaw. Note selection doesn't survive a "
5669 disable_notify_events();
5670 const SalInstanceTreeIter
& rVclIter
= static_cast<const SalInstanceTreeIter
&>(rIter
);
5671 m_xIconView
->MakeVisible(rVclIter
.iter
);
5672 enable_notify_events();
5675 void SalInstanceIconView::selected_foreach(const std::function
<bool(weld::TreeIter
&)>& func
)
5677 SalInstanceTreeIter
aVclIter(m_xIconView
->FirstSelected());
5678 while (aVclIter
.iter
)
5682 aVclIter
.iter
= m_xIconView
->NextSelected(aVclIter
.iter
);
5686 OUString
SalInstanceIconView::get_id(const weld::TreeIter
& rIter
) const
5688 const SalInstanceTreeIter
& rVclIter
= static_cast<const SalInstanceTreeIter
&>(rIter
);
5689 const OUString
* pStr
= static_cast<const OUString
*>(rVclIter
.iter
->GetUserData());
5695 OUString
SalInstanceIconView::get_text(const weld::TreeIter
& rIter
) const
5697 const SalInstanceTreeIter
& rVclIter
= static_cast<const SalInstanceTreeIter
&>(rIter
);
5698 return SvTabListBox::GetEntryText(rVclIter
.iter
, 0);
5701 void SalInstanceIconView::clear()
5703 disable_notify_events();
5704 m_xIconView
->Clear();
5705 m_aUserData
.clear();
5706 enable_notify_events();
5709 SalInstanceIconView::~SalInstanceIconView()
5711 m_xIconView
->SetDoubleClickHdl(Link
<SvTreeListBox
*, bool>());
5712 m_xIconView
->SetSelectHdl(Link
<SvTreeListBox
*, void>());
5713 m_xIconView
->SetDeselectHdl(Link
<SvTreeListBox
*, void>());
5716 IMPL_LINK_NOARG(SalInstanceIconView
, SelectHdl
, SvTreeListBox
*, void)
5718 if (notify_events_disabled())
5720 signal_selection_changed();
5723 IMPL_LINK_NOARG(SalInstanceIconView
, DeSelectHdl
, SvTreeListBox
*, void)
5725 if (notify_events_disabled())
5727 if (m_xIconView
->GetSelectionMode() == SelectionMode::Single
)
5729 signal_selection_changed();
5732 IMPL_LINK_NOARG(SalInstanceIconView
, DoubleClickHdl
, SvTreeListBox
*, bool)
5734 if (notify_events_disabled())
5736 return !signal_item_activated();
5739 IMPL_LINK(SalInstanceIconView
, CommandHdl
, const CommandEvent
&, rEvent
, bool)
5741 return m_aCommandHdl
.Call(rEvent
);
5744 double SalInstanceSpinButton::toField(sal_Int64 nValue
) const
5746 return static_cast<double>(nValue
) / Power10(get_digits());
5749 sal_Int64
SalInstanceSpinButton::fromField(double fValue
) const
5751 auto const x
= fValue
* Power10(get_digits());
5752 return x
== double(std::numeric_limits
<sal_Int64
>::max())
5753 ? std::numeric_limits
<sal_Int64
>::max()
5754 : sal_Int64(std::round(x
));
5757 SalInstanceSpinButton::SalInstanceSpinButton(FormattedField
* pButton
, SalInstanceBuilder
* pBuilder
,
5758 bool bTakeOwnership
)
5759 : SalInstanceEntry(pButton
, pBuilder
, bTakeOwnership
)
5760 , m_xButton(pButton
)
5761 , m_rFormatter(m_xButton
->GetFormatter())
5763 m_rFormatter
.SetThousandsSep(false); //off by default, MetricSpinButton enables it
5764 m_xButton
->SetUpHdl(LINK(this, SalInstanceSpinButton
, UpDownHdl
));
5765 m_xButton
->SetDownHdl(LINK(this, SalInstanceSpinButton
, UpDownHdl
));
5766 m_xButton
->SetLoseFocusHdl(LINK(this, SalInstanceSpinButton
, LoseFocusHdl
));
5767 m_rFormatter
.SetOutputHdl(LINK(this, SalInstanceSpinButton
, OutputHdl
));
5768 m_rFormatter
.SetInputHdl(LINK(this, SalInstanceSpinButton
, InputHdl
));
5769 if (Edit
* pEdit
= m_xButton
->GetSubEdit())
5770 pEdit
->SetActivateHdl(LINK(this, SalInstanceSpinButton
, ActivateHdl
));
5772 m_xButton
->SetActivateHdl(LINK(this, SalInstanceSpinButton
, ActivateHdl
));
5775 sal_Int64
SalInstanceSpinButton::get_value() const { return fromField(m_rFormatter
.GetValue()); }
5777 void SalInstanceSpinButton::set_value(sal_Int64 value
) { m_rFormatter
.SetValue(toField(value
)); }
5779 void SalInstanceSpinButton::set_range(sal_Int64 min
, sal_Int64 max
)
5781 m_rFormatter
.SetMinValue(toField(min
));
5782 m_rFormatter
.SetMaxValue(toField(max
));
5785 void SalInstanceSpinButton::get_range(sal_Int64
& min
, sal_Int64
& max
) const
5787 min
= fromField(m_rFormatter
.GetMinValue());
5788 max
= fromField(m_rFormatter
.GetMaxValue());
5791 void SalInstanceSpinButton::set_increments(int step
, int /*page*/)
5793 m_rFormatter
.SetSpinSize(toField(step
));
5796 void SalInstanceSpinButton::get_increments(int& step
, int& page
) const
5798 step
= fromField(m_rFormatter
.GetSpinSize());
5799 page
= fromField(m_rFormatter
.GetSpinSize());
5802 void SalInstanceSpinButton::set_digits(unsigned int digits
)
5804 m_rFormatter
.SetDecimalDigits(digits
);
5807 // SpinButton may be comprised of multiple subwidgets, consider the lot as
5808 // one thing for focus
5809 bool SalInstanceSpinButton::has_focus() const { return m_xWidget
->HasChildPathFocus(); }
5811 //off by default for direct SpinButtons, MetricSpinButton enables it
5812 void SalInstanceSpinButton::SetUseThousandSep() { m_rFormatter
.SetThousandsSep(true); }
5814 unsigned int SalInstanceSpinButton::get_digits() const { return m_rFormatter
.GetDecimalDigits(); }
5816 SalInstanceSpinButton::~SalInstanceSpinButton()
5818 if (Edit
* pEdit
= m_xButton
->GetSubEdit())
5819 pEdit
->SetActivateHdl(Link
<Edit
&, bool>());
5821 m_xButton
->SetActivateHdl(Link
<Edit
&, bool>());
5822 m_rFormatter
.SetInputHdl(Link
<sal_Int64
*, TriState
>());
5823 m_rFormatter
.SetOutputHdl(Link
<LinkParamNone
*, bool>());
5824 m_xButton
->SetLoseFocusHdl(Link
<Control
&, void>());
5825 m_xButton
->SetDownHdl(Link
<SpinField
&, void>());
5826 m_xButton
->SetUpHdl(Link
<SpinField
&, void>());
5829 IMPL_LINK_NOARG(SalInstanceSpinButton
, ActivateHdl
, Edit
&, bool)
5831 // tdf#122348 return pressed to end dialog
5832 signal_value_changed();
5833 return m_aActivateHdl
.Call(*this);
5836 IMPL_LINK_NOARG(SalInstanceSpinButton
, UpDownHdl
, SpinField
&, void) { signal_value_changed(); }
5838 IMPL_LINK_NOARG(SalInstanceSpinButton
, LoseFocusHdl
, Control
&, void) { signal_value_changed(); }
5840 IMPL_LINK_NOARG(SalInstanceSpinButton
, OutputHdl
, LinkParamNone
*, bool) { return signal_output(); }
5842 IMPL_LINK(SalInstanceSpinButton
, InputHdl
, sal_Int64
*, pResult
, TriState
)
5845 TriState eRet
= signal_input(&nResult
);
5846 if (eRet
== TRISTATE_TRUE
)
5853 class SalInstanceFormattedSpinButton
: public SalInstanceEntry
,
5854 public virtual weld::FormattedSpinButton
5857 VclPtr
<FormattedField
> m_xButton
;
5858 weld::EntryFormatter
* m_pFormatter
;
5859 Link
<weld::Widget
&, void> m_aLoseFocusHdl
;
5861 DECL_LINK(UpDownHdl
, SpinField
&, void);
5862 DECL_LINK(LoseFocusHdl
, Control
&, void);
5865 SalInstanceFormattedSpinButton(FormattedField
* pButton
, SalInstanceBuilder
* pBuilder
,
5866 bool bTakeOwnership
)
5867 : SalInstanceEntry(pButton
, pBuilder
, bTakeOwnership
)
5868 , m_xButton(pButton
)
5869 , m_pFormatter(nullptr)
5871 m_xButton
->SetUpHdl(LINK(this, SalInstanceFormattedSpinButton
, UpDownHdl
));
5872 m_xButton
->SetDownHdl(LINK(this, SalInstanceFormattedSpinButton
, UpDownHdl
));
5873 m_xButton
->SetLoseFocusHdl(LINK(this, SalInstanceFormattedSpinButton
, LoseFocusHdl
));
5876 virtual void set_text(const OUString
& rText
) override
5878 disable_notify_events();
5879 m_xButton
->SpinField::SetText(rText
);
5880 enable_notify_events();
5883 virtual void connect_changed(const Link
<weld::Entry
&, void>& rLink
) override
5885 if (!m_pFormatter
) // once a formatter is set, it takes over "changed"
5887 SalInstanceEntry::connect_changed(rLink
);
5890 m_pFormatter
->connect_changed(rLink
);
5893 virtual void connect_focus_out(const Link
<weld::Widget
&, void>& rLink
) override
5895 if (!m_pFormatter
) // once a formatter is set, it takes over "focus-out"
5897 m_aLoseFocusHdl
= rLink
;
5900 m_pFormatter
->connect_focus_out(rLink
);
5903 virtual void SetFormatter(weld::EntryFormatter
* pFormatter
) override
5905 m_pFormatter
= pFormatter
;
5906 m_xButton
->SetFormatter(pFormatter
);
5909 virtual void sync_value_from_formatter() override
5914 virtual void sync_range_from_formatter() override
5919 virtual void sync_increments_from_formatter() override
5924 virtual Formatter
& GetFormatter() override
{ return m_xButton
->GetFormatter(); }
5926 virtual ~SalInstanceFormattedSpinButton() override
5928 m_xButton
->SetLoseFocusHdl(Link
<Control
&, void>());
5929 m_xButton
->SetDownHdl(Link
<SpinField
&, void>());
5930 m_xButton
->SetUpHdl(Link
<SpinField
&, void>());
5934 IMPL_LINK_NOARG(SalInstanceFormattedSpinButton
, UpDownHdl
, SpinField
&, void)
5936 signal_value_changed();
5939 IMPL_LINK_NOARG(SalInstanceFormattedSpinButton
, LoseFocusHdl
, Control
&, void)
5942 signal_value_changed();
5943 m_aLoseFocusHdl
.Call(*this);
5947 SalInstanceLabel::SalInstanceLabel(Control
* pLabel
, SalInstanceBuilder
* pBuilder
,
5948 bool bTakeOwnership
)
5949 : SalInstanceWidget(pLabel
, pBuilder
, bTakeOwnership
)
5954 void SalInstanceLabel::set_label(const OUString
& rText
) { m_xLabel
->SetText(rText
); }
5956 OUString
SalInstanceLabel::get_label() const { return m_xLabel
->GetText(); }
5958 void SalInstanceLabel::set_mnemonic_widget(Widget
* pTarget
)
5960 FixedText
* pLabel
= dynamic_cast<FixedText
*>(m_xLabel
.get());
5961 assert(pLabel
&& "can't use set_mnemonic_widget on SelectableFixedText");
5962 SalInstanceWidget
* pTargetWidget
= dynamic_cast<SalInstanceWidget
*>(pTarget
);
5963 pLabel
->set_mnemonic_widget(pTargetWidget
? pTargetWidget
->getWidget() : nullptr);
5966 void SalInstanceLabel::set_label_type(weld::LabelType eType
)
5970 case weld::LabelType::Normal
:
5971 m_xLabel
->SetControlForeground();
5972 m_xLabel
->SetControlBackground();
5974 case weld::LabelType::Warning
:
5975 m_xLabel
->SetControlForeground();
5976 m_xLabel
->SetControlBackground(
5977 m_xLabel
->GetSettings().GetStyleSettings().GetWarningColor());
5979 case weld::LabelType::Error
:
5980 m_xLabel
->SetControlForeground();
5981 m_xLabel
->SetControlBackground(
5982 m_xLabel
->GetSettings().GetStyleSettings().GetHighlightColor());
5984 case weld::LabelType::Title
:
5985 m_xLabel
->SetControlForeground(
5986 m_xLabel
->GetSettings().GetStyleSettings().GetLightColor());
5987 m_xLabel
->SetControlBackground();
5992 void SalInstanceLabel::set_font_color(const Color
& rColor
)
5994 if (rColor
!= COL_AUTO
)
5995 m_xLabel
->SetControlForeground(rColor
);
5997 m_xLabel
->SetControlForeground();
6000 void SalInstanceLabel::set_font(const vcl::Font
& rFont
)
6002 m_xLabel
->SetControlFont(rFont
);
6003 m_xLabel
->Invalidate();
6006 std::unique_ptr
<weld::Label
> SalInstanceFrame::weld_label_widget() const
6008 FixedText
* pLabel
= dynamic_cast<FixedText
*>(m_xFrame
->get_label_widget());
6011 return std::make_unique
<SalInstanceLabel
>(pLabel
, m_pBuilder
, false);
6014 SalInstanceTextView::SalInstanceTextView(VclMultiLineEdit
* pTextView
, SalInstanceBuilder
* pBuilder
,
6015 bool bTakeOwnership
)
6016 : SalInstanceWidget(pTextView
, pBuilder
, bTakeOwnership
)
6017 , m_xTextView(pTextView
)
6019 m_xTextView
->SetModifyHdl(LINK(this, SalInstanceTextView
, ChangeHdl
));
6020 ScrollBar
& rVertScrollBar
= m_xTextView
->GetVScrollBar();
6021 m_aOrigVScrollHdl
= rVertScrollBar
.GetScrollHdl();
6022 rVertScrollBar
.SetScrollHdl(LINK(this, SalInstanceTextView
, VscrollHdl
));
6025 void SalInstanceTextView::set_text(const OUString
& rText
)
6027 disable_notify_events();
6028 m_xTextView
->SetText(rText
);
6029 enable_notify_events();
6032 void SalInstanceTextView::replace_selection(const OUString
& rText
)
6034 disable_notify_events();
6035 m_xTextView
->ReplaceSelected(rText
);
6036 enable_notify_events();
6039 OUString
SalInstanceTextView::get_text() const { return m_xTextView
->GetText(); }
6041 bool SalInstanceTextView::get_selection_bounds(int& rStartPos
, int& rEndPos
)
6043 const Selection
& rSelection
= m_xTextView
->GetSelection();
6044 rStartPos
= rSelection
.Min();
6045 rEndPos
= rSelection
.Max();
6046 return rSelection
.Len();
6049 void SalInstanceTextView::select_region(int nStartPos
, int nEndPos
)
6051 disable_notify_events();
6052 tools::Long nStart
= nStartPos
< 0 ? SELECTION_MAX
: nStartPos
;
6053 tools::Long nEnd
= nEndPos
< 0 ? SELECTION_MAX
: nEndPos
;
6054 m_xTextView
->SetSelection(Selection(nStart
, nEnd
));
6055 enable_notify_events();
6058 void SalInstanceTextView::set_editable(bool bEditable
) { m_xTextView
->SetReadOnly(!bEditable
); }
6059 bool SalInstanceTextView::get_editable() const { return !m_xTextView
->IsReadOnly(); }
6060 void SalInstanceTextView::set_max_length(int nChars
) { m_xTextView
->SetMaxTextLen(nChars
); }
6062 void SalInstanceTextView::set_monospace(bool bMonospace
)
6064 vcl::Font aOrigFont
= m_xTextView
->GetControlFont();
6068 = OutputDevice::GetDefaultFont(DefaultFontType::UI_FIXED
, LANGUAGE_DONTKNOW
,
6069 GetDefaultFontFlags::OnlyOne
, m_xTextView
->GetOutDev());
6071 aFont
= Application::GetSettings().GetStyleSettings().GetFieldFont();
6072 aFont
.SetFontHeight(aOrigFont
.GetFontHeight());
6076 void SalInstanceTextView::set_font_color(const Color
& rColor
)
6078 if (rColor
!= COL_AUTO
)
6079 m_xTextView
->SetControlForeground(rColor
);
6081 m_xTextView
->SetControlForeground();
6084 void SalInstanceTextView::set_font(const vcl::Font
& rFont
)
6086 m_xTextView
->SetFont(rFont
);
6087 m_xTextView
->SetControlFont(rFont
);
6088 m_xTextView
->Invalidate();
6091 void SalInstanceTextView::connect_cursor_position(const Link
<TextView
&, void>& rLink
)
6093 assert(!m_aCursorPositionHdl
.IsSet());
6094 m_xTextView
->AddEventListener(LINK(this, SalInstanceTextView
, CursorListener
));
6095 weld::TextView::connect_cursor_position(rLink
);
6098 bool SalInstanceTextView::can_move_cursor_with_up() const
6100 bool bNoSelection
= !m_xTextView
->GetSelection();
6101 return !bNoSelection
|| m_xTextView
->CanUp();
6104 bool SalInstanceTextView::can_move_cursor_with_down() const
6106 bool bNoSelection
= !m_xTextView
->GetSelection();
6107 return !bNoSelection
|| m_xTextView
->CanDown();
6110 void SalInstanceTextView::cut_clipboard() { m_xTextView
->Cut(); }
6112 void SalInstanceTextView::copy_clipboard() { m_xTextView
->Copy(); }
6114 void SalInstanceTextView::paste_clipboard() { m_xTextView
->Paste(); }
6116 void SalInstanceTextView::set_alignment(TxtAlign eXAlign
)
6118 ::set_alignment(*m_xTextView
, eXAlign
);
6121 int SalInstanceTextView::vadjustment_get_value() const
6123 ScrollBar
& rVertScrollBar
= m_xTextView
->GetVScrollBar();
6124 return rVertScrollBar
.GetThumbPos();
6127 void SalInstanceTextView::vadjustment_set_value(int value
)
6129 ScrollBar
& rVertScrollBar
= m_xTextView
->GetVScrollBar();
6130 rVertScrollBar
.SetThumbPos(value
);
6131 m_aOrigVScrollHdl
.Call(&rVertScrollBar
);
6134 int SalInstanceTextView::vadjustment_get_upper() const
6136 ScrollBar
& rVertScrollBar
= m_xTextView
->GetVScrollBar();
6137 return rVertScrollBar
.GetRangeMax();
6140 int SalInstanceTextView::vadjustment_get_lower() const
6142 ScrollBar
& rVertScrollBar
= m_xTextView
->GetVScrollBar();
6143 return rVertScrollBar
.GetRangeMin();
6146 int SalInstanceTextView::vadjustment_get_page_size() const
6148 ScrollBar
& rVertScrollBar
= m_xTextView
->GetVScrollBar();
6149 return rVertScrollBar
.GetVisibleSize();
6152 bool SalInstanceTextView::has_focus() const { return m_xTextView
->HasChildPathFocus(); }
6154 SalInstanceTextView::~SalInstanceTextView()
6156 if (!m_xTextView
->isDisposed())
6158 if (m_aCursorPositionHdl
.IsSet())
6159 m_xTextView
->RemoveEventListener(LINK(this, SalInstanceTextView
, CursorListener
));
6160 m_xTextView
->SetModifyHdl(Link
<Edit
&, void>());
6161 ScrollBar
& rVertScrollBar
= m_xTextView
->GetVScrollBar();
6162 rVertScrollBar
.SetScrollHdl(m_aOrigVScrollHdl
);
6166 IMPL_LINK(SalInstanceTextView
, VscrollHdl
, ScrollBar
*, pScrollBar
, void)
6168 signal_vadjustment_changed();
6169 m_aOrigVScrollHdl
.Call(pScrollBar
);
6172 IMPL_LINK_NOARG(SalInstanceTextView
, ChangeHdl
, Edit
&, void) { signal_changed(); }
6174 IMPL_LINK(SalInstanceTextView
, CursorListener
, VclWindowEvent
&, rEvent
, void)
6176 if (notify_events_disabled())
6178 if (rEvent
.GetId() == VclEventId::EditSelectionChanged
6179 || rEvent
.GetId() == VclEventId::EditCaretChanged
)
6180 signal_cursor_position();
6183 SalInstanceExpander::SalInstanceExpander(VclExpander
* pExpander
, SalInstanceBuilder
* pBuilder
,
6184 bool bTakeOwnership
)
6185 : SalInstanceWidget(pExpander
, pBuilder
, bTakeOwnership
)
6186 , m_xExpander(pExpander
)
6188 m_xExpander
->SetExpandedHdl(LINK(this, SalInstanceExpander
, ExpandedHdl
));
6191 void SalInstanceExpander::set_label(const OUString
& rText
) { m_xExpander
->set_label(rText
); }
6193 OUString
SalInstanceExpander::get_label() const { return m_xExpander
->get_label(); }
6195 bool SalInstanceExpander::get_expanded() const { return m_xExpander
->get_expanded(); }
6197 void SalInstanceExpander::set_expanded(bool bExpand
) { m_xExpander
->set_expanded(bExpand
); }
6199 bool SalInstanceExpander::has_focus() const
6201 return m_xExpander
->get_label_widget()->HasFocus() || SalInstanceWidget::has_focus();
6204 void SalInstanceExpander::grab_focus() { return m_xExpander
->get_label_widget()->GrabFocus(); }
6206 SalInstanceExpander::~SalInstanceExpander()
6208 m_xExpander
->SetExpandedHdl(Link
<VclExpander
&, void>());
6211 IMPL_LINK_NOARG(SalInstanceExpander
, ExpandedHdl
, VclExpander
&, void) { signal_expanded(); }
6213 // SalInstanceWidget has a generic listener for all these
6214 // events, ignore the ones we have specializations for
6215 // in VclDrawingArea
6216 void SalInstanceDrawingArea::HandleEventListener(VclWindowEvent
& rEvent
)
6218 if (rEvent
.GetId() == VclEventId::WindowResize
)
6220 SalInstanceWidget::HandleEventListener(rEvent
);
6223 void SalInstanceDrawingArea::HandleMouseEventListener(VclWindowEvent
& rEvent
)
6225 if (rEvent
.GetId() == VclEventId::WindowMouseButtonDown
6226 || rEvent
.GetId() == VclEventId::WindowMouseButtonUp
6227 || rEvent
.GetId() == VclEventId::WindowMouseMove
)
6231 SalInstanceWidget::HandleMouseEventListener(rEvent
);
6234 bool SalInstanceDrawingArea::HandleKeyEventListener(VclWindowEvent
& /*rEvent*/) { return false; }
6236 SalInstanceDrawingArea::SalInstanceDrawingArea(VclDrawingArea
* pDrawingArea
,
6237 SalInstanceBuilder
* pBuilder
, const a11yref
& rAlly
,
6238 FactoryFunction pUITestFactoryFunction
,
6239 void* pUserData
, bool bTakeOwnership
)
6240 : SalInstanceWidget(pDrawingArea
, pBuilder
, bTakeOwnership
)
6241 , m_xDrawingArea(pDrawingArea
)
6243 m_xDrawingArea
->SetAccessible(rAlly
);
6244 m_xDrawingArea
->SetUITestFactory(std::move(pUITestFactoryFunction
), pUserData
);
6245 m_xDrawingArea
->SetPaintHdl(LINK(this, SalInstanceDrawingArea
, PaintHdl
));
6246 m_xDrawingArea
->SetResizeHdl(LINK(this, SalInstanceDrawingArea
, ResizeHdl
));
6247 m_xDrawingArea
->SetMousePressHdl(LINK(this, SalInstanceDrawingArea
, MousePressHdl
));
6248 m_xDrawingArea
->SetMouseMoveHdl(LINK(this, SalInstanceDrawingArea
, MouseMoveHdl
));
6249 m_xDrawingArea
->SetMouseReleaseHdl(LINK(this, SalInstanceDrawingArea
, MouseReleaseHdl
));
6250 m_xDrawingArea
->SetKeyPressHdl(LINK(this, SalInstanceDrawingArea
, KeyPressHdl
));
6251 m_xDrawingArea
->SetKeyReleaseHdl(LINK(this, SalInstanceDrawingArea
, KeyReleaseHdl
));
6252 m_xDrawingArea
->SetStyleUpdatedHdl(LINK(this, SalInstanceDrawingArea
, StyleUpdatedHdl
));
6253 m_xDrawingArea
->SetCommandHdl(LINK(this, SalInstanceDrawingArea
, CommandHdl
));
6254 m_xDrawingArea
->SetQueryTooltipHdl(LINK(this, SalInstanceDrawingArea
, QueryTooltipHdl
));
6255 m_xDrawingArea
->SetGetSurroundingHdl(LINK(this, SalInstanceDrawingArea
, GetSurroundingHdl
));
6256 m_xDrawingArea
->SetDeleteSurroundingHdl(
6257 LINK(this, SalInstanceDrawingArea
, DeleteSurroundingHdl
));
6258 m_xDrawingArea
->SetStartDragHdl(LINK(this, SalInstanceDrawingArea
, StartDragHdl
));
6261 void SalInstanceDrawingArea::queue_draw() { m_xDrawingArea
->Invalidate(); }
6263 void SalInstanceDrawingArea::queue_draw_area(int x
, int y
, int width
, int height
)
6265 m_xDrawingArea
->Invalidate(tools::Rectangle(Point(x
, y
), Size(width
, height
)));
6268 void SalInstanceDrawingArea::connect_size_allocate(const Link
<const Size
&, void>& rLink
)
6270 weld::Widget::connect_size_allocate(rLink
);
6273 void SalInstanceDrawingArea::connect_key_press(const Link
<const KeyEvent
&, bool>& rLink
)
6275 weld::Widget::connect_key_press(rLink
);
6278 void SalInstanceDrawingArea::connect_key_release(const Link
<const KeyEvent
&, bool>& rLink
)
6280 weld::Widget::connect_key_release(rLink
);
6283 void SalInstanceDrawingArea::connect_style_updated(const Link
<Widget
&, void>& rLink
)
6285 weld::Widget::connect_style_updated(rLink
);
6288 void SalInstanceDrawingArea::set_cursor(PointerStyle ePointerStyle
)
6290 m_xDrawingArea
->SetPointer(ePointerStyle
);
6293 void SalInstanceDrawingArea::set_input_context(const InputContext
& rInputContext
)
6295 m_xDrawingArea
->SetInputContext(rInputContext
);
6298 void SalInstanceDrawingArea::im_context_set_cursor_location(const tools::Rectangle
& rCursorRect
,
6299 int nExtTextInputWidth
)
6301 tools::Rectangle aCursorRect
= m_xDrawingArea
->PixelToLogic(rCursorRect
);
6302 m_xDrawingArea
->SetCursorRect(
6303 &aCursorRect
, m_xDrawingArea
->PixelToLogic(Size(nExtTextInputWidth
, 0)).Width());
6306 a11yref
SalInstanceDrawingArea::get_accessible_parent()
6308 vcl::Window
* pParent
= m_xDrawingArea
->GetParent();
6310 return pParent
->GetAccessible();
6311 return css::uno::Reference
<css::accessibility::XAccessible
>();
6314 a11yrelationset
SalInstanceDrawingArea::get_accessible_relation_set()
6316 rtl::Reference
<utl::AccessibleRelationSetHelper
> pRelationSetHelper
6317 = new utl::AccessibleRelationSetHelper
;
6318 vcl::Window
* pWindow
= m_xDrawingArea
.get();
6321 vcl::Window
* pLabeledBy
= pWindow
->GetAccessibleRelationLabeledBy();
6322 if (pLabeledBy
&& pLabeledBy
!= pWindow
)
6324 css::uno::Sequence
<css::uno::Reference
<css::uno::XInterface
>> aSequence
{
6325 pLabeledBy
->GetAccessible()
6327 pRelationSetHelper
->AddRelation(css::accessibility::AccessibleRelation(
6328 css::accessibility::AccessibleRelationType::LABELED_BY
, aSequence
));
6330 vcl::Window
* pMemberOf
= pWindow
->GetAccessibleRelationMemberOf();
6331 if (pMemberOf
&& pMemberOf
!= pWindow
)
6333 css::uno::Sequence
<css::uno::Reference
<css::uno::XInterface
>> aSequence
{
6334 pMemberOf
->GetAccessible()
6336 pRelationSetHelper
->AddRelation(css::accessibility::AccessibleRelation(
6337 css::accessibility::AccessibleRelationType::MEMBER_OF
, aSequence
));
6340 return pRelationSetHelper
;
6343 Point
SalInstanceDrawingArea::get_accessible_location_on_screen()
6345 return m_xDrawingArea
->OutputToAbsoluteScreenPixel(Point());
6348 Point
SalInstanceDrawingArea::get_pointer_position() const
6350 return m_xDrawingArea
->GetPointerPosPixel();
6353 void SalInstanceDrawingArea::enable_drag_source(rtl::Reference
<TransferDataContainer
>& rHelper
,
6354 sal_uInt8 eDNDConstants
)
6356 m_xDrawingArea
->SetDragHelper(rHelper
, eDNDConstants
);
6359 SalInstanceDrawingArea::~SalInstanceDrawingArea()
6361 m_xDrawingArea
->SetDeleteSurroundingHdl(Link
<const Selection
&, bool>());
6362 m_xDrawingArea
->SetGetSurroundingHdl(Link
<OUString
&, int>());
6363 m_xDrawingArea
->SetQueryTooltipHdl(Link
<tools::Rectangle
&, OUString
>());
6364 m_xDrawingArea
->SetCommandHdl(Link
<const CommandEvent
&, bool>());
6365 m_xDrawingArea
->SetStyleUpdatedHdl(Link
<VclDrawingArea
&, void>());
6366 m_xDrawingArea
->SetMousePressHdl(Link
<const MouseEvent
&, bool>());
6367 m_xDrawingArea
->SetMouseMoveHdl(Link
<const MouseEvent
&, bool>());
6368 m_xDrawingArea
->SetMouseReleaseHdl(Link
<const MouseEvent
&, bool>());
6369 m_xDrawingArea
->SetKeyPressHdl(Link
<const KeyEvent
&, bool>());
6370 m_xDrawingArea
->SetKeyReleaseHdl(Link
<const KeyEvent
&, bool>());
6371 m_xDrawingArea
->SetResizeHdl(Link
<const Size
&, void>());
6372 m_xDrawingArea
->SetPaintHdl(
6373 Link
<std::pair
<vcl::RenderContext
&, const tools::Rectangle
&>, void>());
6376 OutputDevice
& SalInstanceDrawingArea::get_ref_device() { return *m_xDrawingArea
->GetOutDev(); }
6378 void SalInstanceDrawingArea::click(const Point
& rPos
)
6380 MouseEvent
aEvent(rPos
, 1, MouseEventModifiers::NONE
, MOUSE_LEFT
, 0);
6381 VclPtr
<VclDrawingArea
> xDrawingArea(m_xDrawingArea
);
6382 xDrawingArea
->MouseButtonDown(aEvent
);
6383 xDrawingArea
->MouseButtonUp(aEvent
);
6386 void SalInstanceDrawingArea::dblclick(const Point
& rPos
)
6388 MouseEvent
aEvent(rPos
, 2, MouseEventModifiers::NONE
, MOUSE_LEFT
, 0);
6389 VclPtr
<VclDrawingArea
> xDrawingArea(m_xDrawingArea
);
6390 xDrawingArea
->MouseButtonDown(aEvent
);
6391 xDrawingArea
->MouseButtonUp(aEvent
);
6394 void SalInstanceDrawingArea::mouse_up(const Point
& rPos
)
6396 MouseEvent
aEvent(rPos
, 0, MouseEventModifiers::NONE
, MOUSE_LEFT
, 0);
6397 m_xDrawingArea
->MouseButtonUp(aEvent
);
6400 void SalInstanceDrawingArea::mouse_down(const Point
& rPos
)
6402 MouseEvent
aEvent(rPos
, 0, MouseEventModifiers::NONE
, MOUSE_LEFT
, 0);
6403 m_xDrawingArea
->MouseButtonDown(aEvent
);
6406 void SalInstanceDrawingArea::mouse_move(const Point
& rPos
)
6408 MouseEvent
aEvent(rPos
, 0, MouseEventModifiers::NONE
, MOUSE_LEFT
, 0);
6409 m_xDrawingArea
->MouseMove(aEvent
);
6412 IMPL_LINK(SalInstanceDrawingArea
, PaintHdl
, target_and_area
, aPayload
, void)
6414 m_aDrawHdl
.Call(aPayload
);
6415 tools::Rectangle
aFocusRect(m_aGetFocusRectHdl
.Call(*this));
6416 if (!aFocusRect
.IsEmpty())
6417 InvertFocusRect(aPayload
.first
, aFocusRect
);
6420 IMPL_LINK(SalInstanceDrawingArea
, ResizeHdl
, const Size
&, rSize
, void)
6422 m_aSizeAllocateHdl
.Call(rSize
);
6425 IMPL_LINK(SalInstanceDrawingArea
, MousePressHdl
, const MouseEvent
&, rEvent
, bool)
6427 return m_aMousePressHdl
.Call(rEvent
);
6430 IMPL_LINK(SalInstanceDrawingArea
, MouseMoveHdl
, const MouseEvent
&, rEvent
, bool)
6432 return m_aMouseMotionHdl
.Call(rEvent
);
6435 IMPL_LINK(SalInstanceDrawingArea
, MouseReleaseHdl
, const MouseEvent
&, rEvent
, bool)
6437 return m_aMouseReleaseHdl
.Call(rEvent
);
6440 IMPL_LINK(SalInstanceDrawingArea
, KeyPressHdl
, const KeyEvent
&, rEvent
, bool)
6442 return m_aKeyPressHdl
.Call(rEvent
);
6445 IMPL_LINK(SalInstanceDrawingArea
, KeyReleaseHdl
, const KeyEvent
&, rEvent
, bool)
6447 return m_aKeyReleaseHdl
.Call(rEvent
);
6450 IMPL_LINK_NOARG(SalInstanceDrawingArea
, StyleUpdatedHdl
, VclDrawingArea
&, void)
6452 m_aStyleUpdatedHdl
.Call(*this);
6455 IMPL_LINK(SalInstanceDrawingArea
, CommandHdl
, const CommandEvent
&, rEvent
, bool)
6457 return m_aCommandHdl
.Call(rEvent
);
6460 IMPL_LINK(SalInstanceDrawingArea
, GetSurroundingHdl
, OUString
&, rSurrounding
, int)
6462 return m_aGetSurroundingHdl
.Call(rSurrounding
);
6465 IMPL_LINK(SalInstanceDrawingArea
, DeleteSurroundingHdl
, const Selection
&, rSelection
, bool)
6467 return m_aDeleteSurroundingHdl
.Call(rSelection
);
6470 IMPL_LINK(SalInstanceDrawingArea
, QueryTooltipHdl
, tools::Rectangle
&, rHelpArea
, OUString
)
6472 return m_aQueryTooltipHdl
.Call(rHelpArea
);
6475 IMPL_LINK_NOARG(SalInstanceDrawingArea
, StartDragHdl
, VclDrawingArea
*, bool)
6477 if (m_aDragBeginHdl
.Call(*this))
6482 SalInstanceComboBoxWithoutEdit::SalInstanceComboBoxWithoutEdit(ListBox
* pListBox
,
6483 SalInstanceBuilder
* pBuilder
,
6484 bool bTakeOwnership
)
6485 : SalInstanceComboBox
<ListBox
>(pListBox
, pBuilder
, bTakeOwnership
)
6487 m_xComboBox
->SetSelectHdl(LINK(this, SalInstanceComboBoxWithoutEdit
, SelectHdl
));
6490 OUString
SalInstanceComboBoxWithoutEdit::get_active_text() const
6492 return m_xComboBox
->GetSelectedEntry();
6495 void SalInstanceComboBoxWithoutEdit::remove(int pos
) { m_xComboBox
->RemoveEntry(pos
); }
6497 void SalInstanceComboBoxWithoutEdit::insert(int pos
, const OUString
& rStr
, const OUString
* pId
,
6498 const OUString
* pIconName
, VirtualDevice
* pImageSurface
)
6500 auto nInsertPos
= pos
== -1 ? COMBOBOX_APPEND
: pos
;
6501 sal_Int32 nInsertedAt
;
6502 if (!pIconName
&& !pImageSurface
)
6503 nInsertedAt
= m_xComboBox
->InsertEntry(rStr
, nInsertPos
);
6505 nInsertedAt
= m_xComboBox
->InsertEntry(rStr
, createImage(*pIconName
), nInsertPos
);
6507 nInsertedAt
= m_xComboBox
->InsertEntry(rStr
, createImage(*pImageSurface
), nInsertPos
);
6510 m_aUserData
.emplace_back(std::make_unique
<OUString
>(*pId
));
6511 m_xComboBox
->SetEntryData(nInsertedAt
, m_aUserData
.back().get());
6515 void SalInstanceComboBoxWithoutEdit::insert_separator(int pos
, const OUString
& /*rId*/)
6517 auto nInsertPos
= pos
== -1 ? m_xComboBox
->GetEntryCount() : pos
;
6518 m_xComboBox
->AddSeparator(nInsertPos
- 1);
6521 bool SalInstanceComboBoxWithoutEdit::has_entry() const { return false; }
6523 bool SalInstanceComboBoxWithoutEdit::changed_by_direct_pick() const { return true; }
6525 void SalInstanceComboBoxWithoutEdit::set_entry_message_type(weld::EntryMessageType
/*eType*/)
6530 void SalInstanceComboBoxWithoutEdit::set_entry_text(const OUString
& /*rText*/) { assert(false); }
6532 void SalInstanceComboBoxWithoutEdit::select_entry_region(int /*nStartPos*/, int /*nEndPos*/)
6537 bool SalInstanceComboBoxWithoutEdit::get_entry_selection_bounds(int& /*rStartPos*/,
6544 void SalInstanceComboBoxWithoutEdit::set_entry_width_chars(int /*nChars*/) { assert(false); }
6546 void SalInstanceComboBoxWithoutEdit::set_entry_max_length(int /*nChars*/) { assert(false); }
6548 void SalInstanceComboBoxWithoutEdit::set_entry_completion(bool, bool) { assert(false); }
6550 void SalInstanceComboBoxWithoutEdit::set_entry_placeholder_text(const OUString
&) { assert(false); }
6552 void SalInstanceComboBoxWithoutEdit::set_entry_editable(bool /*bEditable*/) { assert(false); }
6554 void SalInstanceComboBoxWithoutEdit::cut_entry_clipboard() { assert(false); }
6556 void SalInstanceComboBoxWithoutEdit::copy_entry_clipboard() { assert(false); }
6558 void SalInstanceComboBoxWithoutEdit::paste_entry_clipboard() { assert(false); }
6560 void SalInstanceComboBoxWithoutEdit::set_font(const vcl::Font
& rFont
)
6562 m_xComboBox
->SetControlFont(rFont
);
6563 m_xComboBox
->Invalidate();
6566 void SalInstanceComboBoxWithoutEdit::set_entry_font(const vcl::Font
&) { assert(false); }
6568 vcl::Font
SalInstanceComboBoxWithoutEdit::get_entry_font()
6574 void SalInstanceComboBoxWithoutEdit::set_custom_renderer(bool /*bOn*/)
6576 assert(false && "not implemented");
6579 int SalInstanceComboBoxWithoutEdit::get_max_mru_count() const
6581 assert(false && "not implemented");
6585 void SalInstanceComboBoxWithoutEdit::set_max_mru_count(int) { assert(false && "not implemented"); }
6587 OUString
SalInstanceComboBoxWithoutEdit::get_mru_entries() const
6589 assert(false && "not implemented");
6593 void SalInstanceComboBoxWithoutEdit::set_mru_entries(const OUString
&)
6595 assert(false && "not implemented");
6598 void SalInstanceComboBoxWithoutEdit::HandleEventListener(VclWindowEvent
& rEvent
)
6600 CallHandleEventListener(rEvent
);
6603 SalInstanceComboBoxWithoutEdit::~SalInstanceComboBoxWithoutEdit()
6605 m_xComboBox
->SetSelectHdl(Link
<ListBox
&, void>());
6608 IMPL_LINK_NOARG(SalInstanceComboBoxWithoutEdit
, SelectHdl
, ListBox
&, void)
6610 return signal_changed();
6613 SalInstanceComboBoxWithEdit::SalInstanceComboBoxWithEdit(::ComboBox
* pComboBox
,
6614 SalInstanceBuilder
* pBuilder
,
6615 bool bTakeOwnership
)
6616 : SalInstanceComboBox
<::ComboBox
>(pComboBox
, pBuilder
, bTakeOwnership
)
6617 , m_aTextFilter(m_aEntryInsertTextHdl
)
6618 , m_bInSelect(false)
6620 m_xComboBox
->SetModifyHdl(LINK(this, SalInstanceComboBoxWithEdit
, ChangeHdl
));
6621 m_xComboBox
->SetSelectHdl(LINK(this, SalInstanceComboBoxWithEdit
, SelectHdl
));
6622 m_xComboBox
->SetEntryActivateHdl(LINK(this, SalInstanceComboBoxWithEdit
, EntryActivateHdl
));
6623 m_xComboBox
->SetTextFilter(&m_aTextFilter
);
6626 bool SalInstanceComboBoxWithEdit::has_entry() const { return true; }
6628 void SalInstanceComboBoxWithEdit::call_attention_to()
6630 Edit
* pEdit
= m_xComboBox
->GetSubEdit();
6632 m_xFlashAttention
.reset(new SalFlashAttention(pEdit
));
6633 m_xFlashAttention
->Start();
6636 bool SalInstanceComboBoxWithEdit::changed_by_direct_pick() const
6638 return m_bInSelect
&& !m_xComboBox
->IsModifyByKeyboard() && !m_xComboBox
->IsTravelSelect();
6641 void SalInstanceComboBoxWithEdit::set_entry_message_type(weld::EntryMessageType eType
)
6643 Edit
* pEdit
= m_xComboBox
->GetSubEdit();
6645 ::set_message_type(pEdit
, eType
);
6648 OUString
SalInstanceComboBoxWithEdit::get_active_text() const { return m_xComboBox
->GetText(); }
6650 void SalInstanceComboBoxWithEdit::remove(int pos
) { m_xComboBox
->RemoveEntryAt(pos
); }
6652 void SalInstanceComboBoxWithEdit::insert(int pos
, const OUString
& rStr
, const OUString
* pId
,
6653 const OUString
* pIconName
, VirtualDevice
* pImageSurface
)
6655 auto nInsertPos
= pos
== -1 ? COMBOBOX_APPEND
: pos
;
6656 sal_Int32 nInsertedAt
;
6657 if (!pIconName
&& !pImageSurface
)
6658 nInsertedAt
= m_xComboBox
->InsertEntry(rStr
, nInsertPos
);
6660 nInsertedAt
= m_xComboBox
->InsertEntryWithImage(rStr
, createImage(*pIconName
), nInsertPos
);
6663 = m_xComboBox
->InsertEntryWithImage(rStr
, createImage(*pImageSurface
), nInsertPos
);
6666 m_aUserData
.emplace_back(std::make_unique
<OUString
>(*pId
));
6667 m_xComboBox
->SetEntryData(nInsertedAt
, m_aUserData
.back().get());
6671 void SalInstanceComboBoxWithEdit::insert_separator(int pos
, const OUString
& /*rId*/)
6673 auto nInsertPos
= pos
== -1 ? m_xComboBox
->GetEntryCount() : pos
;
6674 m_xComboBox
->AddSeparator(nInsertPos
- 1);
6677 void SalInstanceComboBoxWithEdit::set_entry_text(const OUString
& rText
)
6679 m_xComboBox
->SetText(rText
);
6682 void SalInstanceComboBoxWithEdit::set_entry_width_chars(int nChars
)
6684 m_xComboBox
->SetWidthInChars(nChars
);
6687 void SalInstanceComboBoxWithEdit::set_entry_max_length(int nChars
)
6689 m_xComboBox
->SetMaxTextLen(nChars
);
6692 void SalInstanceComboBoxWithEdit::set_entry_completion(bool bEnable
, bool bCaseSensitive
)
6694 m_xComboBox
->EnableAutocomplete(bEnable
, bCaseSensitive
);
6697 void SalInstanceComboBoxWithEdit::set_entry_placeholder_text(const OUString
& rText
)
6699 m_xComboBox
->SetPlaceholderText(rText
);
6702 void SalInstanceComboBoxWithEdit::set_entry_editable(bool bEditable
)
6704 m_xComboBox
->SetReadOnly(!bEditable
);
6707 void SalInstanceComboBoxWithEdit::cut_entry_clipboard() { m_xComboBox
->Cut(); }
6709 void SalInstanceComboBoxWithEdit::copy_entry_clipboard() { m_xComboBox
->Copy(); }
6711 void SalInstanceComboBoxWithEdit::paste_entry_clipboard() { m_xComboBox
->Paste(); }
6713 void SalInstanceComboBoxWithEdit::select_entry_region(int nStartPos
, int nEndPos
)
6715 m_xComboBox
->SetSelection(Selection(nStartPos
, nEndPos
< 0 ? SELECTION_MAX
: nEndPos
));
6718 bool SalInstanceComboBoxWithEdit::get_entry_selection_bounds(int& rStartPos
, int& rEndPos
)
6720 const Selection
& rSelection
= m_xComboBox
->GetSelection();
6721 rStartPos
= rSelection
.Min();
6722 rEndPos
= rSelection
.Max();
6723 return rSelection
.Len();
6726 void SalInstanceComboBoxWithEdit::set_font(const vcl::Font
& rFont
)
6728 m_xComboBox
->SetControlFont(rFont
);
6729 m_xComboBox
->Invalidate();
6732 void SalInstanceComboBoxWithEdit::set_entry_font(const vcl::Font
& rFont
)
6734 Edit
* pEdit
= m_xComboBox
->GetSubEdit();
6736 pEdit
->SetControlFont(rFont
); // tdf#134601 set it as control font to take effect properly
6737 pEdit
->Invalidate();
6740 vcl::Font
SalInstanceComboBoxWithEdit::get_entry_font()
6742 Edit
* pEdit
= m_xComboBox
->GetSubEdit();
6744 return pEdit
->GetPointFont(*pEdit
->GetOutDev());
6747 void SalInstanceComboBoxWithEdit::set_custom_renderer(bool bOn
)
6749 if (m_xComboBox
->IsUserDrawEnabled() == bOn
)
6752 auto nOldEntryHeight
= m_xComboBox
->GetDropDownEntryHeight();
6753 auto nDropDownLineCount
= m_xComboBox
->GetDropDownLineCount();
6755 m_xComboBox
->EnableUserDraw(bOn
);
6757 m_xComboBox
->SetUserDrawHdl(LINK(this, SalInstanceComboBoxWithEdit
, UserDrawHdl
));
6759 m_xComboBox
->SetUserDrawHdl(Link
<UserDrawEvent
*, void>());
6761 // adjust the line count to fit approx the height it would have been before
6762 // changing the renderer
6763 auto nNewEntryHeight
= m_xComboBox
->GetDropDownEntryHeight();
6764 double fRatio
= nOldEntryHeight
/ static_cast<double>(nNewEntryHeight
);
6765 m_xComboBox
->SetDropDownLineCount(nDropDownLineCount
* fRatio
);
6768 int SalInstanceComboBoxWithEdit::get_max_mru_count() const { return m_xComboBox
->GetMaxMRUCount(); }
6770 void SalInstanceComboBoxWithEdit::set_max_mru_count(int nCount
)
6772 return m_xComboBox
->SetMaxMRUCount(nCount
);
6775 OUString
SalInstanceComboBoxWithEdit::get_mru_entries() const
6777 return m_xComboBox
->GetMRUEntries();
6780 void SalInstanceComboBoxWithEdit::set_mru_entries(const OUString
& rEntries
)
6782 m_xComboBox
->SetMRUEntries(rEntries
);
6785 void SalInstanceComboBoxWithEdit::HandleEventListener(VclWindowEvent
& rEvent
)
6787 if (rEvent
.GetId() == VclEventId::DropdownPreOpen
)
6789 Size
aRowSize(signal_custom_get_size(*m_xComboBox
->GetOutDev()));
6790 m_xComboBox
->SetUserItemSize(aRowSize
);
6792 CallHandleEventListener(rEvent
);
6795 SalInstanceComboBoxWithEdit::~SalInstanceComboBoxWithEdit()
6797 m_xComboBox
->SetTextFilter(nullptr);
6798 m_xComboBox
->SetEntryActivateHdl(Link
<Edit
&, bool>());
6799 m_xComboBox
->SetModifyHdl(Link
<Edit
&, void>());
6800 m_xComboBox
->SetSelectHdl(Link
<::ComboBox
&, void>());
6803 IMPL_LINK_NOARG(SalInstanceComboBoxWithEdit
, ChangeHdl
, Edit
&, void)
6805 if (!m_xComboBox
->IsSyntheticModify()) // SelectHdl will be called
6809 IMPL_LINK_NOARG(SalInstanceComboBoxWithEdit
, SelectHdl
, ::ComboBox
&, void)
6813 m_bInSelect
= false;
6816 IMPL_LINK_NOARG(SalInstanceComboBoxWithEdit
, EntryActivateHdl
, Edit
&, bool)
6818 return m_aEntryActivateHdl
.Call(*this);
6821 IMPL_LINK(SalInstanceComboBoxWithEdit
, UserDrawHdl
, UserDrawEvent
*, pEvent
, void)
6823 call_signal_custom_render(pEvent
);
6826 class SalInstanceEntryTreeView
: public SalInstanceContainer
, public virtual weld::EntryTreeView
6829 DECL_LINK(AutocompleteHdl
, Edit
&, void);
6830 DECL_LINK(KeyPressListener
, VclWindowEvent
&, void);
6831 SalInstanceEntry
* m_pEntry
;
6832 SalInstanceTreeView
* m_pTreeView
;
6836 SalInstanceEntryTreeView(vcl::Window
* pContainer
, SalInstanceBuilder
* pBuilder
,
6837 bool bTakeOwnership
, std::unique_ptr
<weld::Entry
> xEntry
,
6838 std::unique_ptr
<weld::TreeView
> xTreeView
)
6839 : EntryTreeView(std::move(xEntry
), std::move(xTreeView
))
6840 , SalInstanceContainer(pContainer
, pBuilder
, bTakeOwnership
)
6841 , m_pEntry(dynamic_cast<SalInstanceEntry
*>(m_xEntry
.get()))
6842 , m_pTreeView(dynamic_cast<SalInstanceTreeView
*>(m_xTreeView
.get()))
6843 , m_bTreeChange(false)
6845 assert(m_pEntry
&& m_pTreeView
);
6847 Edit
& rEntry
= m_pEntry
->getEntry();
6848 rEntry
.SetAutocompleteHdl(LINK(this, SalInstanceEntryTreeView
, AutocompleteHdl
));
6849 rEntry
.AddEventListener(LINK(this, SalInstanceEntryTreeView
, KeyPressListener
));
6852 virtual void insert_separator(int /*pos*/, const OUString
& /*rId*/) override
{ assert(false); }
6854 virtual void make_sorted() override
6856 vcl::Window
* pTreeView
= m_pTreeView
->getWidget();
6857 pTreeView
->SetStyle(pTreeView
->GetStyle() | WB_SORT
);
6860 virtual void set_entry_completion(bool bEnable
, bool /*bCaseSensitive*/) override
6862 assert(!bEnable
&& "not implemented yet");
6864 Edit
& rEntry
= m_pEntry
->getEntry();
6865 rEntry
.SetAutocompleteHdl(Link
<Edit
&, void>());
6868 virtual void set_font(const vcl::Font
&) override
{ assert(false && "not implemented"); }
6870 virtual void set_entry_font(const vcl::Font
& rFont
) override
{ m_pEntry
->set_font(rFont
); }
6872 virtual vcl::Font
get_entry_font() override
6874 Edit
& rEntry
= m_pEntry
->getEntry();
6875 return rEntry
.GetPointFont(*rEntry
.GetOutDev());
6878 virtual void set_entry_placeholder_text(const OUString
& rText
) override
6880 Edit
& rEntry
= m_pEntry
->getEntry();
6881 rEntry
.SetPlaceholderText(rText
);
6884 virtual void set_entry_editable(bool bEditable
) override
6886 Edit
& rEntry
= m_pEntry
->getEntry();
6887 rEntry
.SetReadOnly(!bEditable
);
6890 virtual void cut_entry_clipboard() override
6892 Edit
& rEntry
= m_pEntry
->getEntry();
6896 virtual void copy_entry_clipboard() override
6898 Edit
& rEntry
= m_pEntry
->getEntry();
6902 virtual void paste_entry_clipboard() override
6904 Edit
& rEntry
= m_pEntry
->getEntry();
6908 virtual void grab_focus() override
{ m_xEntry
->grab_focus(); }
6910 virtual void connect_focus_in(const Link
<Widget
&, void>& rLink
) override
6912 m_xEntry
->connect_focus_in(rLink
);
6915 virtual void connect_focus_out(const Link
<Widget
&, void>& rLink
) override
6917 m_xEntry
->connect_focus_out(rLink
);
6920 virtual bool changed_by_direct_pick() const override
{ return m_bTreeChange
; }
6922 virtual void set_custom_renderer(bool /*bOn*/) override
{ assert(false && "not implemented"); }
6924 virtual int get_max_mru_count() const override
6926 assert(false && "not implemented");
6930 virtual void set_max_mru_count(int) override
{ assert(false && "not implemented"); }
6932 virtual OUString
get_mru_entries() const override
6934 assert(false && "not implemented");
6938 virtual void set_mru_entries(const OUString
&) override
{ assert(false && "not implemented"); }
6940 virtual void set_item_menu(const OUString
&, weld::Menu
*) override
6942 assert(false && "not implemented");
6945 int get_menu_button_width() const override
6947 assert(false && "not implemented");
6951 VclPtr
<VirtualDevice
> create_render_virtual_device() const override
6953 return VclPtr
<VirtualDevice
>::Create();
6956 virtual ~SalInstanceEntryTreeView() override
6958 Edit
& rEntry
= m_pEntry
->getEntry();
6959 rEntry
.RemoveEventListener(LINK(this, SalInstanceEntryTreeView
, KeyPressListener
));
6960 rEntry
.SetAutocompleteHdl(Link
<Edit
&, void>());
6964 IMPL_LINK(SalInstanceEntryTreeView
, KeyPressListener
, VclWindowEvent
&, rEvent
, void)
6966 if (rEvent
.GetId() != VclEventId::WindowKeyInput
)
6968 const KeyEvent
& rKeyEvent
= *static_cast<KeyEvent
*>(rEvent
.GetData());
6969 sal_uInt16 nKeyCode
= rKeyEvent
.GetKeyCode().GetCode();
6970 if (!(nKeyCode
== KEY_UP
|| nKeyCode
== KEY_DOWN
|| nKeyCode
== KEY_PAGEUP
6971 || nKeyCode
== KEY_PAGEDOWN
))
6974 m_pTreeView
->disable_notify_events();
6975 auto& rListBox
= m_pTreeView
->getTreeView();
6976 if (!rListBox
.FirstSelected())
6978 if (SvTreeListEntry
* pEntry
= rListBox
.First())
6979 rListBox
.Select(pEntry
, true);
6982 rListBox
.KeyInput(rKeyEvent
);
6983 m_xEntry
->set_text(m_xTreeView
->get_selected_text());
6984 m_xEntry
->select_region(0, -1);
6985 m_pTreeView
->enable_notify_events();
6986 m_bTreeChange
= true;
6987 m_pEntry
->fire_signal_changed();
6988 m_bTreeChange
= false;
6991 IMPL_LINK(SalInstanceEntryTreeView
, AutocompleteHdl
, Edit
&, rEdit
, void)
6993 Selection aSel
= rEdit
.GetSelection();
6995 OUString aFullText
= rEdit
.GetText();
6996 OUString aStartText
= aFullText
.copy(0, static_cast<sal_Int32
>(aSel
.Max()));
6999 int nCount
= m_xTreeView
->n_children();
7000 for (int i
= 0; i
< nCount
; ++i
)
7002 if (m_xTreeView
->get_text(i
).startsWithIgnoreAsciiCase(aStartText
))
7009 m_xTreeView
->select(nPos
);
7013 OUString aText
= m_xTreeView
->get_text(nPos
);
7014 Selection
aSelection(aText
.getLength(), aStartText
.getLength());
7015 rEdit
.SetText(aText
, aSelection
);
7019 SalInstancePopover::SalInstancePopover(DockingWindow
* pPopover
, SalInstanceBuilder
* pBuilder
,
7020 bool bTakeOwnership
)
7021 : SalInstanceContainer(pPopover
, pBuilder
, bTakeOwnership
)
7022 , m_xPopover(pPopover
)
7026 SalInstancePopover::~SalInstancePopover()
7028 DockingManager
* pDockingManager
= vcl::Window::GetDockingManager();
7029 if (pDockingManager
->IsInPopupMode(m_xPopover
))
7033 void SalInstancePopover::popup_at_rect(weld::Widget
* pParent
, const tools::Rectangle
& rRect
,
7034 weld::Placement ePlace
)
7036 SalInstanceWidget
* pVclWidget
= dynamic_cast<SalInstanceWidget
*>(pParent
);
7038 vcl::Window
* pWidget
= pVclWidget
->getWidget();
7040 tools::Rectangle aRect
;
7041 Point aPt
= pWidget
->OutputToScreenPixel(rRect
.TopLeft());
7042 aRect
.SetLeft(aPt
.X());
7043 aRect
.SetTop(aPt
.Y());
7044 aPt
= pWidget
->OutputToScreenPixel(rRect
.BottomRight());
7045 aRect
.SetRight(aPt
.X());
7046 aRect
.SetBottom(aPt
.Y());
7048 FloatWinPopupFlags nFlags
= FloatWinPopupFlags::GrabFocus
| FloatWinPopupFlags::NoMouseUpClose
;
7049 if (ePlace
== weld::Placement::Under
)
7050 nFlags
= nFlags
| FloatWinPopupFlags::Down
;
7052 nFlags
= nFlags
| FloatWinPopupFlags::Right
;
7054 m_xPopover
->EnableDocking();
7055 DockingManager
* pDockingManager
= vcl::Window::GetDockingManager();
7056 pDockingManager
->SetPopupModeEndHdl(m_xPopover
,
7057 LINK(this, SalInstancePopover
, PopupModeEndHdl
));
7058 pDockingManager
->StartPopupMode(m_xPopover
, aRect
, nFlags
);
7061 void SalInstancePopover::ImplPopDown()
7063 vcl::Window::GetDockingManager()->EndPopupMode(m_xPopover
);
7064 m_xPopover
->EnableDocking(false);
7068 void SalInstancePopover::popdown() { ImplPopDown(); }
7070 void SalInstancePopover::resize_to_request()
7072 ::resize_to_request(m_xPopover
.get());
7074 DockingManager
* pDockingManager
= vcl::Window::GetDockingManager();
7075 if (pDockingManager
->IsInPopupMode(m_xPopover
.get()))
7077 Size aSize
= m_xPopover
->get_preferred_size();
7078 tools::Rectangle aRect
= pDockingManager
->GetPosSizePixel(m_xPopover
.get());
7079 pDockingManager
->SetPosSizePixel(m_xPopover
.get(), aRect
.Left(), aRect
.Top(), aSize
.Width(),
7080 aSize
.Height(), PosSizeFlags::Size
);
7084 IMPL_LINK_NOARG(SalInstancePopover
, PopupModeEndHdl
, FloatingWindow
*, void) { signal_closed(); }
7086 SalInstanceBuilder::SalInstanceBuilder(vcl::Window
* pParent
, const OUString
& rUIRoot
,
7087 const OUString
& rUIFile
,
7088 const css::uno::Reference
<css::frame::XFrame
>& rFrame
)
7090 , m_xBuilder(new VclBuilder(pParent
, rUIRoot
, rUIFile
, {}, rFrame
, false))
7094 std::unique_ptr
<weld::MessageDialog
> SalInstanceBuilder::weld_message_dialog(const OUString
& id
)
7096 MessageDialog
* pMessageDialog
= m_xBuilder
->get
<MessageDialog
>(id
);
7097 std::unique_ptr
<weld::MessageDialog
> pRet(
7098 pMessageDialog
? new SalInstanceMessageDialog(pMessageDialog
, this, false) : nullptr);
7101 assert(!m_aOwnedToplevel
&& "only one toplevel per .ui allowed");
7102 m_aOwnedToplevel
.set(pMessageDialog
);
7103 m_xBuilder
->drop_ownership(pMessageDialog
);
7108 std::unique_ptr
<weld::Dialog
> SalInstanceBuilder::weld_dialog(const OUString
& id
)
7110 Dialog
* pDialog
= m_xBuilder
->get
<Dialog
>(id
);
7111 std::unique_ptr
<weld::Dialog
> pRet(pDialog
? new SalInstanceDialog(pDialog
, this, false)
7115 assert(!m_aOwnedToplevel
&& "only one toplevel per .ui allowed");
7116 m_aOwnedToplevel
.set(pDialog
);
7117 m_xBuilder
->drop_ownership(pDialog
);
7122 std::unique_ptr
<weld::Assistant
> SalInstanceBuilder::weld_assistant(const OUString
& id
)
7124 vcl::RoadmapWizard
* pDialog
= m_xBuilder
->get
<vcl::RoadmapWizard
>(id
);
7125 std::unique_ptr
<weld::Assistant
> pRet(pDialog
? new SalInstanceAssistant(pDialog
, this, false)
7129 assert(!m_aOwnedToplevel
&& "only one toplevel per .ui allowed");
7130 m_aOwnedToplevel
.set(pDialog
);
7131 m_xBuilder
->drop_ownership(pDialog
);
7136 std::unique_ptr
<weld::Window
> SalInstanceBuilder::create_screenshot_window()
7138 assert(!m_aOwnedToplevel
&& "only one toplevel per .ui allowed");
7140 vcl::Window
* pRoot
= m_xBuilder
->get_widget_root();
7141 if (SystemWindow
* pWindow
= dynamic_cast<SystemWindow
*>(pRoot
))
7143 std::unique_ptr
<weld::Window
> xRet(new SalInstanceWindow(pWindow
, this, false));
7144 m_aOwnedToplevel
.set(pWindow
);
7145 m_xBuilder
->drop_ownership(pWindow
);
7149 VclPtrInstance
<Dialog
> xDialog(nullptr, WB_HIDE
| WB_STDDIALOG
| WB_SIZEABLE
| WB_CLOSEABLE
,
7150 Dialog::InitFlag::NoParent
);
7151 xDialog
->SetText(utl::ConfigManager::getProductName());
7153 auto xContentArea
= VclPtr
<VclVBox
>::Create(xDialog
, false, 12);
7154 pRoot
->SetParent(xContentArea
);
7155 assert(pRoot
== xContentArea
->GetWindow(GetWindowType::FirstChild
));
7156 xContentArea
->Show();
7158 xDialog
->SetHelpId(pRoot
->GetHelpId());
7160 m_aOwnedToplevel
.set(xDialog
);
7162 return std::unique_ptr
<weld::Dialog
>(new SalInstanceDialog(xDialog
, this, false));
7165 std::unique_ptr
<weld::Widget
> SalInstanceBuilder::weld_widget(const OUString
& id
)
7167 vcl::Window
* pWidget
= m_xBuilder
->get(id
);
7168 return pWidget
? std::make_unique
<SalInstanceWidget
>(pWidget
, this, false) : nullptr;
7171 std::unique_ptr
<weld::Container
> SalInstanceBuilder::weld_container(const OUString
& id
)
7173 vcl::Window
* pContainer
= m_xBuilder
->get(id
);
7174 return pContainer
? std::make_unique
<SalInstanceContainer
>(pContainer
, this, false) : nullptr;
7177 std::unique_ptr
<weld::Box
> SalInstanceBuilder::weld_box(const OUString
& id
)
7179 VclBox
* pContainer
= m_xBuilder
->get
<VclBox
>(id
);
7180 return pContainer
? std::make_unique
<SalInstanceBox
>(pContainer
, this, false) : nullptr;
7183 std::unique_ptr
<weld::Paned
> SalInstanceBuilder::weld_paned(const OUString
& id
)
7185 VclPaned
* pPaned
= m_xBuilder
->get
<VclPaned
>(id
);
7186 return pPaned
? std::make_unique
<SalInstancePaned
>(pPaned
, this, false) : nullptr;
7189 std::unique_ptr
<weld::Frame
> SalInstanceBuilder::weld_frame(const OUString
& id
)
7191 VclFrame
* pFrame
= m_xBuilder
->get
<VclFrame
>(id
);
7192 std::unique_ptr
<weld::Frame
> pRet(pFrame
? new SalInstanceFrame(pFrame
, this, false) : nullptr);
7196 std::unique_ptr
<weld::ScrolledWindow
>
7197 SalInstanceBuilder::weld_scrolled_window(const OUString
& id
, bool bUserManagedScrolling
)
7199 VclScrolledWindow
* pScrolledWindow
= m_xBuilder
->get
<VclScrolledWindow
>(id
);
7200 return pScrolledWindow
? std::make_unique
<SalInstanceScrolledWindow
>(
7201 pScrolledWindow
, this, false, bUserManagedScrolling
)
7205 std::unique_ptr
<weld::Notebook
> SalInstanceBuilder::weld_notebook(const OUString
& id
)
7207 vcl::Window
* pNotebook
= m_xBuilder
->get(id
);
7210 if (pNotebook
->GetType() == WindowType::TABCONTROL
)
7211 return std::make_unique
<SalInstanceNotebook
>(static_cast<TabControl
*>(pNotebook
), this,
7213 if (pNotebook
->GetType() == WindowType::VERTICALTABCONTROL
)
7214 return std::make_unique
<SalInstanceVerticalNotebook
>(
7215 static_cast<VerticalTabControl
*>(pNotebook
), this, false);
7219 std::unique_ptr
<weld::Button
> SalInstanceBuilder::weld_button(const OUString
& id
)
7221 Button
* pButton
= m_xBuilder
->get
<Button
>(id
);
7222 return pButton
? std::make_unique
<SalInstanceButton
>(pButton
, this, false) : nullptr;
7225 std::unique_ptr
<weld::MenuButton
> SalInstanceBuilder::weld_menu_button(const OUString
& id
)
7227 MenuButton
* pButton
= m_xBuilder
->get
<MenuButton
>(id
);
7228 return pButton
? std::make_unique
<SalInstanceMenuButton
>(pButton
, this, false) : nullptr;
7231 std::unique_ptr
<weld::MenuToggleButton
>
7232 SalInstanceBuilder::weld_menu_toggle_button(const OUString
& id
)
7234 MenuToggleButton
* pButton
= m_xBuilder
->get
<MenuToggleButton
>(id
);
7235 return pButton
? std::make_unique
<SalInstanceMenuToggleButton
>(pButton
, this, false) : nullptr;
7238 std::unique_ptr
<weld::LinkButton
> SalInstanceBuilder::weld_link_button(const OUString
& id
)
7240 FixedHyperlink
* pButton
= m_xBuilder
->get
<FixedHyperlink
>(id
);
7241 return pButton
? std::make_unique
<SalInstanceLinkButton
>(pButton
, this, false) : nullptr;
7244 std::unique_ptr
<weld::ToggleButton
> SalInstanceBuilder::weld_toggle_button(const OUString
& id
)
7246 PushButton
* pToggleButton
= m_xBuilder
->get
<PushButton
>(id
);
7247 return pToggleButton
? std::make_unique
<SalInstanceToggleButton
>(pToggleButton
, this, false)
7251 std::unique_ptr
<weld::RadioButton
> SalInstanceBuilder::weld_radio_button(const OUString
& id
)
7253 RadioButton
* pRadioButton
= m_xBuilder
->get
<RadioButton
>(id
);
7254 return pRadioButton
? std::make_unique
<SalInstanceRadioButton
>(pRadioButton
, this, false)
7258 std::unique_ptr
<weld::CheckButton
> SalInstanceBuilder::weld_check_button(const OUString
& id
)
7260 CheckBox
* pCheckButton
= m_xBuilder
->get
<CheckBox
>(id
);
7261 return pCheckButton
? std::make_unique
<SalInstanceCheckButton
>(pCheckButton
, this, false)
7265 std::unique_ptr
<weld::Scale
> SalInstanceBuilder::weld_scale(const OUString
& id
)
7267 Slider
* pSlider
= m_xBuilder
->get
<Slider
>(id
);
7268 return pSlider
? std::make_unique
<SalInstanceScale
>(pSlider
, this, false) : nullptr;
7271 std::unique_ptr
<weld::ProgressBar
> SalInstanceBuilder::weld_progress_bar(const OUString
& id
)
7273 ::ProgressBar
* pProgress
= m_xBuilder
->get
<::ProgressBar
>(id
);
7274 return pProgress
? std::make_unique
<SalInstanceProgressBar
>(pProgress
, this, false) : nullptr;
7277 std::unique_ptr
<weld::Spinner
> SalInstanceBuilder::weld_spinner(const OUString
& id
)
7279 Throbber
* pThrobber
= m_xBuilder
->get
<Throbber
>(id
);
7280 return pThrobber
? std::make_unique
<SalInstanceSpinner
>(pThrobber
, this, false) : nullptr;
7283 std::unique_ptr
<weld::Image
> SalInstanceBuilder::weld_image(const OUString
& id
)
7285 FixedImage
* pImage
= m_xBuilder
->get
<FixedImage
>(id
);
7286 return pImage
? std::make_unique
<SalInstanceImage
>(pImage
, this, false) : nullptr;
7289 std::unique_ptr
<weld::Calendar
> SalInstanceBuilder::weld_calendar(const OUString
& id
)
7291 Calendar
* pCalendar
= m_xBuilder
->get
<Calendar
>(id
);
7292 return pCalendar
? std::make_unique
<SalInstanceCalendar
>(pCalendar
, this, false) : nullptr;
7295 std::unique_ptr
<weld::Entry
> SalInstanceBuilder::weld_entry(const OUString
& id
)
7297 Edit
* pEntry
= m_xBuilder
->get
<Edit
>(id
);
7298 return pEntry
? std::make_unique
<SalInstanceEntry
>(pEntry
, this, false) : nullptr;
7301 std::unique_ptr
<weld::SpinButton
> SalInstanceBuilder::weld_spin_button(const OUString
& id
)
7303 FormattedField
* pSpinButton
= m_xBuilder
->get
<FormattedField
>(id
);
7304 return pSpinButton
? std::make_unique
<SalInstanceSpinButton
>(pSpinButton
, this, false)
7308 std::unique_ptr
<weld::MetricSpinButton
>
7309 SalInstanceBuilder::weld_metric_spin_button(const OUString
& id
, FieldUnit eUnit
)
7311 std::unique_ptr
<weld::SpinButton
> xButton(weld_spin_button(id
));
7314 SalInstanceSpinButton
& rButton
= dynamic_cast<SalInstanceSpinButton
&>(*xButton
);
7315 rButton
.SetUseThousandSep();
7317 return std::make_unique
<weld::MetricSpinButton
>(std::move(xButton
), eUnit
);
7320 std::unique_ptr
<weld::FormattedSpinButton
>
7321 SalInstanceBuilder::weld_formatted_spin_button(const OUString
& id
)
7323 FormattedField
* pSpinButton
= m_xBuilder
->get
<FormattedField
>(id
);
7324 return pSpinButton
? std::make_unique
<SalInstanceFormattedSpinButton
>(pSpinButton
, this, false)
7328 std::unique_ptr
<weld::ComboBox
> SalInstanceBuilder::weld_combo_box(const OUString
& id
)
7330 vcl::Window
* pWidget
= m_xBuilder
->get(id
);
7331 ::ComboBox
* pComboBox
= dynamic_cast<::ComboBox
*>(pWidget
);
7333 return std::make_unique
<SalInstanceComboBoxWithEdit
>(pComboBox
, this, false);
7334 ListBox
* pListBox
= dynamic_cast<ListBox
*>(pWidget
);
7335 return pListBox
? std::make_unique
<SalInstanceComboBoxWithoutEdit
>(pListBox
, this, false)
7339 std::unique_ptr
<weld::EntryTreeView
>
7340 SalInstanceBuilder::weld_entry_tree_view(const OUString
& containerid
, const OUString
& entryid
,
7341 const OUString
& treeviewid
)
7343 vcl::Window
* pContainer
= m_xBuilder
->get(containerid
);
7344 return pContainer
? std::make_unique
<SalInstanceEntryTreeView
>(pContainer
, this, false,
7345 weld_entry(entryid
),
7346 weld_tree_view(treeviewid
))
7350 std::unique_ptr
<weld::TreeView
> SalInstanceBuilder::weld_tree_view(const OUString
& id
)
7352 SvTabListBox
* pTreeView
= m_xBuilder
->get
<SvTabListBox
>(id
);
7353 return pTreeView
? std::make_unique
<SalInstanceTreeView
>(pTreeView
, this, false) : nullptr;
7356 std::unique_ptr
<weld::IconView
> SalInstanceBuilder::weld_icon_view(const OUString
& id
)
7358 IconView
* pIconView
= m_xBuilder
->get
<IconView
>(id
);
7359 return pIconView
? std::make_unique
<SalInstanceIconView
>(pIconView
, this, false) : nullptr;
7362 std::unique_ptr
<weld::Label
> SalInstanceBuilder::weld_label(const OUString
& id
)
7364 Control
* pLabel
= m_xBuilder
->get
<Control
>(id
);
7365 return pLabel
? std::make_unique
<SalInstanceLabel
>(pLabel
, this, false) : nullptr;
7368 std::unique_ptr
<weld::TextView
> SalInstanceBuilder::weld_text_view(const OUString
& id
)
7370 VclMultiLineEdit
* pTextView
= m_xBuilder
->get
<VclMultiLineEdit
>(id
);
7371 return pTextView
? std::make_unique
<SalInstanceTextView
>(pTextView
, this, false) : nullptr;
7374 std::unique_ptr
<weld::Expander
> SalInstanceBuilder::weld_expander(const OUString
& id
)
7376 VclExpander
* pExpander
= m_xBuilder
->get
<VclExpander
>(id
);
7377 return pExpander
? std::make_unique
<SalInstanceExpander
>(pExpander
, this, false) : nullptr;
7380 std::unique_ptr
<weld::DrawingArea
>
7381 SalInstanceBuilder::weld_drawing_area(const OUString
& id
, const a11yref
& rA11yImpl
,
7382 FactoryFunction pUITestFactoryFunction
, void* pUserData
)
7384 VclDrawingArea
* pDrawingArea
= m_xBuilder
->get
<VclDrawingArea
>(id
);
7386 ? std::make_unique
<SalInstanceDrawingArea
>(pDrawingArea
, this, rA11yImpl
,
7387 pUITestFactoryFunction
, pUserData
, false)
7391 std::unique_ptr
<weld::Menu
> SalInstanceBuilder::weld_menu(const OUString
& id
)
7393 PopupMenu
* pMenu
= m_xBuilder
->get_menu(id
);
7394 return pMenu
? std::make_unique
<SalInstanceMenu
>(pMenu
, true) : nullptr;
7397 std::unique_ptr
<weld::Popover
> SalInstanceBuilder::weld_popover(const OUString
& id
)
7399 DockingWindow
* pDockingWindow
= m_xBuilder
->get
<DockingWindow
>(id
);
7400 std::unique_ptr
<weld::Popover
> pRet(
7401 pDockingWindow
? new SalInstancePopover(pDockingWindow
, this, false) : nullptr);
7404 assert(!m_aOwnedToplevel
&& "only one toplevel per .ui allowed");
7405 m_aOwnedToplevel
.set(pDockingWindow
);
7406 m_xBuilder
->drop_ownership(pDockingWindow
);
7411 std::unique_ptr
<weld::Toolbar
> SalInstanceBuilder::weld_toolbar(const OUString
& id
)
7413 ToolBox
* pToolBox
= m_xBuilder
->get
<ToolBox
>(id
);
7414 return pToolBox
? std::make_unique
<SalInstanceToolbar
>(pToolBox
, this, false) : nullptr;
7417 std::unique_ptr
<weld::Scrollbar
> SalInstanceBuilder::weld_scrollbar(const OUString
& id
)
7419 ScrollBar
* pScrollbar
= m_xBuilder
->get
<ScrollBar
>(id
);
7420 return pScrollbar
? std::make_unique
<SalInstanceScrollbar
>(pScrollbar
, this, false) : nullptr;
7423 std::unique_ptr
<weld::SizeGroup
> SalInstanceBuilder::create_size_group()
7425 return std::make_unique
<SalInstanceSizeGroup
>();
7428 OUString
SalInstanceBuilder::get_current_page_help_id() const
7430 vcl::Window
* pCtrl
= m_xBuilder
->get("tabcontrol");
7433 VclPtr
<vcl::Window
> xTabPage
;
7434 if (pCtrl
->GetType() == WindowType::TABCONTROL
)
7436 TabControl
* pTabCtrl
= static_cast<TabControl
*>(pCtrl
);
7437 xTabPage
= pTabCtrl
->GetTabPage(pTabCtrl
->GetCurPageId());
7439 else if (pCtrl
->GetType() == WindowType::VERTICALTABCONTROL
)
7441 VerticalTabControl
* pTabCtrl
= static_cast<VerticalTabControl
*>(pCtrl
);
7442 xTabPage
= pTabCtrl
->GetPage(pTabCtrl
->GetCurPageId());
7444 vcl::Window
* pTabChild
= xTabPage
? xTabPage
->GetWindow(GetWindowType::FirstChild
) : nullptr;
7445 pTabChild
= pTabChild
? pTabChild
->GetWindow(GetWindowType::FirstChild
) : nullptr;
7447 return pTabChild
->GetHelpId();
7451 SalInstanceBuilder::~SalInstanceBuilder()
7453 if (VclBuilderContainer
* pOwnedToplevel
7454 = dynamic_cast<VclBuilderContainer
*>(m_aOwnedToplevel
.get()))
7455 pOwnedToplevel
->m_pUIBuilder
= std::move(m_xBuilder
);
7458 m_aOwnedToplevel
.disposeAndClear();
7461 std::unique_ptr
<weld::Builder
>
7462 SalInstance::CreateBuilder(weld::Widget
* pParent
, const OUString
& rUIRoot
, const OUString
& rUIFile
)
7464 SalInstanceWidget
* pParentInstance
= dynamic_cast<SalInstanceWidget
*>(pParent
);
7465 vcl::Window
* pParentWidget
= pParentInstance
? pParentInstance
->getWidget() : nullptr;
7466 return std::make_unique
<SalInstanceBuilder
>(pParentWidget
, rUIRoot
, rUIFile
);
7469 std::unique_ptr
<weld::Builder
> SalInstance::CreateInterimBuilder(vcl::Window
* pParent
,
7470 const OUString
& rUIRoot
,
7471 const OUString
& rUIFile
, bool,
7474 return std::make_unique
<SalInstanceBuilder
>(pParent
, rUIRoot
, rUIFile
);
7477 void SalInstanceWindow::help()
7479 //show help for widget with keyboard focus
7480 vcl::Window
* pWidget
= ImplGetSVData()->mpWinData
->mpFocusWin
;
7482 pWidget
= m_xWindow
;
7483 if (comphelper::LibreOfficeKit::isActive() && m_xWindow
->GetFocusedWindow())
7484 pWidget
= m_xWindow
->GetFocusedWindow().get();
7485 OUString sHelpId
= pWidget
->GetHelpId();
7486 while (sHelpId
.isEmpty())
7488 pWidget
= pWidget
->GetParent();
7491 sHelpId
= pWidget
->GetHelpId();
7493 std::unique_ptr
<weld::Widget
> xTemp(
7494 pWidget
!= m_xWindow
? new SalInstanceWidget(pWidget
, m_pBuilder
, false) : nullptr);
7495 weld::Widget
* pSource
= xTemp
? xTemp
.get() : this;
7496 bool bRunNormalHelpRequest
= !m_aHelpRequestHdl
.IsSet() || m_aHelpRequestHdl
.Call(*pSource
);
7497 Help
* pHelp
= bRunNormalHelpRequest
? Application::GetHelp() : nullptr;
7501 // tdf#126007, there's a nice fallback route for offline help where
7502 // the current page of a notebook will get checked when the help
7503 // button is pressed and there was no help for the dialog found.
7505 // But for online help that route doesn't get taken, so bodge this here
7506 // by using the page help id if available and if the help button itself
7507 // was the original id
7508 if (m_pBuilder
&& sHelpId
.endsWith("/help"))
7510 OUString sPageId
= m_pBuilder
->get_current_page_help_id();
7511 if (!sPageId
.isEmpty())
7515 // tdf#129068 likewise the help for the wrapping dialog is less
7516 // helpful than the help for the content area could be
7517 vcl::Window
* pContentArea
= nullptr;
7518 if (::Dialog
* pDialog
= dynamic_cast<::Dialog
*>(m_xWindow
.get()))
7519 pContentArea
= pDialog
->get_content_area();
7522 vcl::Window
* pContentWidget
= pContentArea
->GetWindow(GetWindowType::LastChild
);
7524 sHelpId
= pContentWidget
->GetHelpId();
7528 pHelp
->Start(sHelpId
, pSource
);
7531 //iterate upwards through the hierarchy from this widgets through its parents
7532 //calling func with their helpid until func returns true or we run out of parents
7533 void SalInstanceWidget::help_hierarchy_foreach(const std::function
<bool(const OUString
&)>& func
)
7535 vcl::Window
* pParent
= m_xWidget
;
7536 while ((pParent
= pParent
->GetParent()))
7538 if (func(pParent
->GetHelpId()))
7543 weld::MessageDialog
* SalInstance::CreateMessageDialog(weld::Widget
* pParent
,
7544 VclMessageType eMessageType
,
7545 VclButtonsType eButtonsType
,
7546 const OUString
& rPrimaryMessage
)
7548 SalInstanceWidget
* pParentInstance
= dynamic_cast<SalInstanceWidget
*>(pParent
);
7549 SystemWindow
* pParentWidget
= pParentInstance
? pParentInstance
->getSystemWindow() : nullptr;
7550 VclPtrInstance
<MessageDialog
> xMessageDialog(pParentWidget
, rPrimaryMessage
, eMessageType
,
7552 return new SalInstanceMessageDialog(xMessageDialog
, nullptr, true);
7555 weld::Window
* SalInstance::GetFrameWeld(const css::uno::Reference
<css::awt::XWindow
>& rWindow
)
7557 UnoWrapperBase
* pWrapper
= UnoWrapperBase::GetUnoWrapper();
7560 VclPtr
<vcl::Window
> xWindow
= pWrapper
->GetWindow(rWindow
);
7563 return xWindow
->GetFrameWeld();
7566 weld::Window
* SalFrame::GetFrameWeld() const
7570 vcl::Window
* pWindow
= GetWindow();
7573 assert(pWindow
== pWindow
->GetFrameWindow());
7574 m_xFrameWeld
.reset(new SalInstanceWindow(pWindow
, nullptr, false));
7577 return m_xFrameWeld
.get();
7580 Selection
SalFrame::CalcDeleteSurroundingSelection(const OUString
& rSurroundingText
,
7581 sal_Int32 nCursorIndex
, int nOffset
, int nChars
)
7583 Selection
aInvalid(SAL_MAX_UINT32
, SAL_MAX_UINT32
);
7585 if (nCursorIndex
== -1)
7590 while (nOffset
&& nCursorIndex
< rSurroundingText
.getLength())
7592 rSurroundingText
.iterateCodePoints(&nCursorIndex
, 1);
7596 else if (nOffset
< 0)
7598 while (nOffset
&& nCursorIndex
> 0)
7600 rSurroundingText
.iterateCodePoints(&nCursorIndex
, -1);
7608 "SalFrame::CalcDeleteSurroundingSelection, unable to move to offset: " << nOffset
);
7612 sal_Int32
nCursorEndIndex(nCursorIndex
);
7613 sal_Int32
nCount(0);
7614 while (nCount
< nChars
&& nCursorEndIndex
< rSurroundingText
.getLength())
7616 rSurroundingText
.iterateCodePoints(&nCursorEndIndex
, 1);
7620 if (nCount
!= nChars
)
7622 SAL_WARN("vcl", "SalFrame::CalcDeleteSurroundingSelection, unable to select: "
7623 << nChars
<< " characters");
7627 return Selection(nCursorIndex
, nCursorEndIndex
);
7630 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */