tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / extensions / source / bibliography / toolbar.hxx
blobd4e45b2e0b80dbcfda54125874dbb4ddc0dd0987
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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 #pragma once
22 #include <com/sun/star/frame/XController.hpp>
23 #include <com/sun/star/frame/XStatusListener.hpp>
25 #include <vcl/InterimItemWindow.hxx>
26 #include <vcl/toolbox.hxx>
27 #include <vcl/timer.hxx>
28 #include <cppuhelper/implbase.hxx>
29 #include <vector>
31 class BibDataManager;
32 class BibToolBar;
34 class BibToolBarListener: public cppu::WeakImplHelper < css::frame::XStatusListener>
36 private:
38 ToolBoxItemId nIndex;
39 OUString aCommand;
41 protected:
43 VclPtr<BibToolBar> pToolBar;
45 public:
47 BibToolBarListener(BibToolBar *pTB, OUString aStr, ToolBoxItemId nId);
48 virtual ~BibToolBarListener() override;
50 const OUString& GetCommand() const { return aCommand;}
52 // css::lang::XEventListener
53 // we do not hold References to dispatches, so there is nothing to do on disposal
54 virtual void SAL_CALL disposing(const css::lang::EventObject& /*Source*/) override {};
56 // css::frame::XStatusListener
57 virtual void SAL_CALL statusChanged(const css::frame::FeatureStateEvent& Event) override;
61 class BibTBListBoxListener: public BibToolBarListener
63 public:
65 BibTBListBoxListener(BibToolBar *pTB, const OUString& aStr, ToolBoxItemId nId);
66 virtual ~BibTBListBoxListener() override;
68 virtual void SAL_CALL statusChanged(const css::frame::FeatureStateEvent& Event) override;
72 class BibTBEditListener: public BibToolBarListener
74 public:
76 BibTBEditListener(BibToolBar *pTB, const OUString& aStr, ToolBoxItemId nId);
77 virtual ~BibTBEditListener() override;
79 virtual void SAL_CALL statusChanged(const css::frame::FeatureStateEvent& Event) override;
83 class BibTBQueryMenuListener: public BibToolBarListener
85 public:
87 BibTBQueryMenuListener(BibToolBar *pTB, const OUString& aStr, ToolBoxItemId nId);
88 virtual ~BibTBQueryMenuListener() override;
90 virtual void SAL_CALL statusChanged(const css::frame::FeatureStateEvent& Event) override;
95 typedef std::vector< css::uno::Reference< css::frame::XStatusListener> > BibToolBarListenerArr;
97 class ComboBoxControl final : public InterimItemWindow
99 public:
100 ComboBoxControl(vcl::Window* pParent);
101 virtual ~ComboBoxControl() override;
102 virtual void dispose() override;
104 weld::ComboBox* get_widget() { return m_xLBSource.get(); }
106 void set_sensitive(bool bSensitive)
108 m_xFtSource->set_sensitive(bSensitive);
109 m_xLBSource->set_sensitive(bSensitive);
110 Enable(bSensitive);
113 private:
114 std::unique_ptr<weld::Label> m_xFtSource;
115 std::unique_ptr<weld::ComboBox> m_xLBSource;
118 class EditControl final : public InterimItemWindow
120 public:
121 EditControl(vcl::Window* pParent);
122 virtual ~EditControl() override;
123 virtual void dispose() override;
125 weld::Entry* get_widget() { return m_xEdQuery.get(); }
127 void set_sensitive(bool bSensitive)
129 m_xFtQuery->set_sensitive(bSensitive);
130 m_xEdQuery->set_sensitive(bSensitive);
131 Enable(bSensitive);
134 private:
135 std::unique_ptr<weld::Label> m_xFtQuery;
136 std::unique_ptr<weld::Entry> m_xEdQuery;
139 class BibToolBar: public ToolBox
141 private:
143 BibToolBarListenerArr aListenerArr;
144 css::uno::Reference< css::frame::XController > xController;
145 Idle aIdle;
146 VclPtr<ComboBoxControl> xSource;
147 weld::ComboBox* pLbSource;
148 VclPtr<EditControl> xQuery;
149 weld::Entry* pEdQuery;
150 std::unique_ptr<weld::Builder> xBuilder;
151 std::unique_ptr<weld::Menu> xPopupMenu;
152 sal_uInt16 nMenuId;
153 OUString sSelMenuItem;
154 OUString aQueryField;
155 Link<void*,void> aLayoutManager;
156 sal_Int16 nSymbolsSize;
158 ToolBoxItemId nTBC_SOURCE;
159 ToolBoxItemId nTBC_QUERY;
160 ToolBoxItemId nTBC_BT_AUTOFILTER;
161 ToolBoxItemId nTBC_BT_COL_ASSIGN;
162 ToolBoxItemId nTBC_BT_CHANGESOURCE;
163 ToolBoxItemId nTBC_BT_FILTERCRIT;
164 ToolBoxItemId nTBC_BT_REMOVEFILTER;
166 BibDataManager* pDatMan;
167 DECL_LINK( SelHdl, weld::ComboBox&, void );
168 DECL_LINK( SendSelHdl, Timer*, void );
169 DECL_LINK( MenuHdl, ToolBox*, void );
170 DECL_LINK( OptionsChanged_Impl, LinkParamNone*, void );
171 DECL_LINK( SettingsChanged_Impl, VclSimpleEvent&, void );
173 void ApplyImageList();
174 void RebuildToolbar();
176 protected:
178 void DataChanged( const DataChangedEvent& rDCEvt ) override;
179 void InitListener();
180 virtual void Select() override;
181 virtual void Click() override;
182 virtual bool PreNotify( NotifyEvent& rNEvt ) override;
185 public:
187 BibToolBar(vcl::Window* pParent, Link<void*,void> aLink);
188 virtual ~BibToolBar() override;
189 virtual void dispose() override;
191 ToolBoxItemId GetChangeSourceId() const { return nTBC_BT_CHANGESOURCE; }
193 void SetXController(const css::uno::Reference< css::frame::XController > &);
195 void ClearSourceList();
196 void UpdateSourceList(bool bFlag);
197 void EnableSourceList(bool bFlag);
198 void InsertSourceEntry(const OUString& );
199 void SelectSourceEntry(const OUString& );
201 void EnableQuery(bool bFlag);
202 void SetQueryString(const OUString& );
203 void AdjustToolBox();
205 void ClearFilterMenu();
206 sal_uInt16 InsertFilterItem(const OUString& );
207 void SelectFilterItem(sal_uInt16 nId);
209 /// @throws css::uno::RuntimeException
210 void statusChanged(const css::frame::FeatureStateEvent& Event);
212 void SetDatMan(BibDataManager& rDatMan) {pDatMan = &rDatMan;}
213 void SendDispatch(ToolBoxItemId nId, const css::uno::Sequence< css::beans::PropertyValue >& rArgs);
217 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */