LibreOffice Module dbaccess (master) 1
AppSwapWindow.cxx
Go to the documentation of this file.
1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2/*
3 * This file is part of the LibreOffice project.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 *
9 * This file incorporates work covered by the following license notice:
10 *
11 * Licensed to the Apache Software Foundation (ASF) under one or more
12 * contributor license agreements. See the NOTICE file distributed
13 * with this work for additional information regarding copyright
14 * ownership. The ASF licenses this file to you under the Apache
15 * License, Version 2.0 (the "License"); you may not use this file
16 * except in compliance with the License. You may obtain a copy of
17 * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 */
19
20#include "AppSwapWindow.hxx"
21#include <helpids.h>
22#include "AppView.hxx"
24#include <vcl/event.hxx>
25#include <vcl/mnemonic.hxx>
26#include <vcl/svapp.hxx>
27#include "AppController.hxx"
28
29using namespace ::dbaui;
30using namespace ::com::sun::star::uno;
31using namespace ::com::sun::star::sdbc;
32using namespace ::com::sun::star::lang;
33using namespace ::com::sun::star::container;
34
35OApplicationSwapWindow::OApplicationSwapWindow(weld::Container* pParent,
36 OAppBorderWindow& rBorderWindow)
37 : OChildWindow(pParent, "dbaccess/ui/appswapwindow.ui", "AppSwapWindow")
38 , m_xIconControl(new OApplicationIconControl(m_xBuilder->weld_scrolled_window("scroll", true)))
39 , m_xIconControlWin(new weld::CustomWeld(*m_xBuilder, "valueset", *m_xIconControl))
40 , m_eLastType(E_NONE)
41 , m_rBorderWin(rBorderWindow)
42 , m_nChangeEvent(nullptr)
43{
44 m_xContainer->set_stack_background();
45
47 m_xIconControl->Fill();
48 m_xIconControl->setItemStateHdl(LINK(this, OApplicationSwapWindow, OnContainerSelectHdl));
49 m_xIconControl->setControlActionListener(&m_rBorderWin.getView()->getAppController());
50}
51
53{
55 m_xIconControl->GrabFocus();
56}
57
59{
60 return m_xIconControl && m_xIconControl->HasFocus();
61}
62
64{
67}
68
70{
71 m_xIconControl->deselectItems();
73}
74
76{
77 m_xIconControl->createIconAutoMnemonics(rMnemonics);
78}
79
81{
82 const vcl::KeyCode& rKeyCode = _rEvent.GetKeyCode();
83 if (rKeyCode.GetModifier() == KEY_MOD2)
84 return m_xIconControl->DoKeyShortCut(_rEvent);
85 // not handled
86 return false;
87}
88
90{
91 return m_xIconControl->GetSelectedItem();
92}
93
95{
96 if (m_eLastType == _eType)
97 return true;
98
100 {
101 if (_eType != E_NONE)
102 m_eLastType = _eType;
103 return true;
104 }
105
106 if (!m_nChangeEvent)
108 = Application::PostUserEvent(LINK(this, OApplicationSwapWindow, ChangeToLastSelected));
109 return false;
110}
111
112IMPL_LINK(OApplicationSwapWindow, OnContainerSelectHdl, const ThumbnailViewItem*, pEntry, void)
113{
114 if (pEntry->mbSelected)
115 {
116 ElementType eType = static_cast<ElementType>(pEntry->mnId - 1);
117 onContainerSelected(eType); // i87582
118 }
119}
120
121IMPL_LINK_NOARG(OApplicationSwapWindow, ChangeToLastSelected, void*, void)
122{
123 m_nChangeEvent = nullptr;
124 selectContainer(m_eLastType);
125}
126
128{
129 m_xIconControl->deselectItems();
130 m_xIconControl->SelectItem(eType + 1); // will trigger onContainerSelected
131}
132
133/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
static ImplSVEvent * PostUserEvent(const Link< void *, void > &rLink, void *pCaller=nullptr, bool bReferenceLink=false)
static void RemoveUserEvent(ImplSVEvent *nUserEvent)
const vcl::KeyCode & GetKeyCode() const
OApplicationView * getView() const
Definition: AppView.hxx:59
bool onContainerSelect(ElementType _eType)
called when a container (category) in the application view has been selected
bool interceptKeyInput(const KeyEvent &_rEvent)
called to give the window the chance to intercept key events, while it has not the focus
ElementType getElementType() const
return the element of currently select entry
bool onContainerSelected(ElementType _eType)
void selectContainer(ElementType _eType)
changes the container which should be displayed.
std::unique_ptr< OApplicationIconControl > m_xIconControl
virtual ~OApplicationSwapWindow() override
void createIconAutoMnemonics(MnemonicGenerator &_rMnemonics)
automatically creates mnemonics for the icon/texts in our left hand side panel
virtual void GrabFocus() override
OAppBorderWindow & m_rBorderWin
virtual bool HasChildPathFocus() const override
void clearSelection()
clears the selection in the icon choice control and calls the handler
OApplicationController & getAppController() const
Definition: AppView.hxx:114
std::unique_ptr< weld::Container > m_xContainer
Definition: ChildWindow.hxx:21
sal_uInt16 GetModifier() const
OUString eType
Definition: generalpage.cxx:78
constexpr OUStringLiteral HID_APP_SWAP_ICONCONTROL
Definition: helpids.h:91
constexpr sal_uInt16 KEY_MOD2
IMPL_LINK_NOARG(OApplicationController, OnClipboardChanged, TransferableDataHelper *, void)
IMPL_LINK(OApplicationController, OnSelectContainer, void *, _pType, void)