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 "AppSwapWindow.hxx"
22 #include "AppView.hxx"
23 #include <sfx2/thumbnailviewitem.hxx>
24 #include <vcl/event.hxx>
25 #include <vcl/mnemonic.hxx>
26 #include <vcl/svapp.hxx>
27 #include "AppController.hxx"
29 using namespace ::dbaui
;
30 using namespace ::com::sun::star::uno
;
32 OApplicationSwapWindow::OApplicationSwapWindow(weld::Container
* pParent
,
33 OAppBorderWindow
& rBorderWindow
)
34 : OChildWindow(pParent
, u
"dbaccess/ui/appswapwindow.ui"_ustr
, u
"AppSwapWindow"_ustr
)
36 new OApplicationIconControl(m_xBuilder
->weld_scrolled_window(u
"scroll"_ustr
, true)))
37 , m_xIconControlWin(new weld::CustomWeld(*m_xBuilder
, u
"valueset"_ustr
, *m_xIconControl
))
39 , m_rBorderWin(rBorderWindow
)
40 , m_nChangeEvent(nullptr)
42 m_xContainer
->set_stack_background();
44 m_xIconControl
->SetHelpId(HID_APP_SWAP_ICONCONTROL
);
45 m_xIconControl
->Fill();
46 m_xIconControl
->setItemStateHdl(LINK(this, OApplicationSwapWindow
, OnContainerSelectHdl
));
47 m_xIconControl
->setControlActionListener(&m_rBorderWin
.getView()->getAppController());
50 void OApplicationSwapWindow::GrabFocus()
53 m_xIconControl
->GrabFocus();
56 bool OApplicationSwapWindow::HasChildPathFocus() const
58 return m_xIconControl
&& m_xIconControl
->HasFocus();
61 OApplicationSwapWindow::~OApplicationSwapWindow()
64 Application::RemoveUserEvent(m_nChangeEvent
);
67 void OApplicationSwapWindow::clearSelection()
69 m_xIconControl
->deselectItems();
70 onContainerSelected(E_NONE
);
73 void OApplicationSwapWindow::createIconAutoMnemonics(MnemonicGenerator
& rMnemonics
)
75 m_xIconControl
->createIconAutoMnemonics(rMnemonics
);
78 bool OApplicationSwapWindow::interceptKeyInput(const KeyEvent
& _rEvent
)
80 const vcl::KeyCode
& rKeyCode
= _rEvent
.GetKeyCode();
81 if (rKeyCode
.GetModifier() == KEY_MOD2
)
82 return m_xIconControl
->DoKeyShortCut(_rEvent
);
87 ElementType
OApplicationSwapWindow::getElementType() const
89 return m_xIconControl
->GetSelectedItem();
92 bool OApplicationSwapWindow::onContainerSelected(ElementType _eType
)
94 if (m_eLastType
== _eType
)
97 if (m_rBorderWin
.getView()->getAppController().onContainerSelect(_eType
))
100 m_eLastType
= _eType
;
106 = Application::PostUserEvent(LINK(this, OApplicationSwapWindow
, ChangeToLastSelected
));
110 IMPL_LINK(OApplicationSwapWindow
, OnContainerSelectHdl
, const ThumbnailViewItem
*, pEntry
, void)
112 if (pEntry
->mbSelected
)
114 ElementType eType
= static_cast<ElementType
>(pEntry
->mnId
- 1);
115 onContainerSelected(eType
); // i87582
119 IMPL_LINK_NOARG(OApplicationSwapWindow
, ChangeToLastSelected
, void*, void)
121 m_nChangeEvent
= nullptr;
122 selectContainer(m_eLastType
);
125 void OApplicationSwapWindow::selectContainer(ElementType eType
)
127 m_xIconControl
->deselectItems();
128 m_xIconControl
->SelectItem(eType
+ 1); // will trigger onContainerSelected
131 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */