android: Update app-specific/MIME type icons
[LibreOffice.git] / basctl / source / inc / IDEComboBox.hxx
bloba5e7008a42e939c2a76dae304e85c46da5d65dbb
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 <svl/stritem.hxx>
23 #include <sfx2/tbxctrl.hxx>
24 #include <vcl/InterimItemWindow.hxx>
26 #include "doceventnotifier.hxx"
27 #include "scriptdocument.hxx"
29 namespace basctl
31 /*!
32 * @brief Manage states of macro and dialog Library ComboBox
34 * @see LibBox Class
36 class LibBoxControl : public SfxToolBoxControl
38 public:
39 /*!
40 * Macro for registering two methods
42 * @code
43 * static SfxToolBoxControl* CreateImpl(sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx)
44 * static void RegisterControl(sal_uInt16 nSlotId = 0, SfxModule* pMod=nullptr)
45 * @endcode
46 * @see Macro SFX_IMPL_TOOLBOX_CONTROL
48 SFX_DECL_TOOLBOX_CONTROL();
50 /*!
51 * @param nSlotId -- the slot as internal operation number
52 * @param nId -- this item's unique id in ToolBox
53 * @param rTbx -- the ToolBox which contains this ComboBox
55 LibBoxControl(sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox& rTbx);
57 /*!
58 * Triggered if state was changed
60 * @param nSlotID -- the slot as internal operation number (not used in this place)
61 * @param eState -- enum value which contains ComboBox state
62 * @param pState --
64 virtual void StateChangedAtToolBoxControl(sal_uInt16 nSlotID, SfxItemState eState,
65 const SfxPoolItem* pState) override;
66 /*!
67 * Create combobox of Macro and Dialog Library
69 * @param pParent -- parent window
70 * @return ComboBox of macro and dialog Library
72 virtual VclPtr<InterimItemWindow> CreateItemWindow(vcl::Window* pParent) override;
75 /*!
76 * @brief Base class for all ComboBox elements.
78 * Base class for ComboBoxes which need to update their content according
79 * to the list of open documents.
81 class DocListenerBox : public InterimItemWindow, public DocumentEventListener
83 private:
84 DECL_LINK(SelectHdl, weld::ComboBox&, void);
85 DECL_LINK(KeyInputHdl, const KeyEvent&, bool);
87 protected:
88 std::unique_ptr<weld::ComboBox> m_xWidget;
90 /// @param pParent -- parent window
91 DocListenerBox(vcl::Window* pParent);
92 virtual ~DocListenerBox() override;
93 virtual void dispose() override;
95 virtual void Select() = 0;
96 virtual void FillBox() = 0;
98 /// key strokes the ComboBox receives
99 virtual bool HandleKeyInput(const KeyEvent& rKEvt);
101 private:
102 // DocumentEventListener
103 virtual void onDocumentCreated(const ScriptDocument& _rDoc) override;
104 virtual void onDocumentOpened(const ScriptDocument& _rDoc) override;
105 virtual void onDocumentSave(const ScriptDocument& _rDoc) override;
106 virtual void onDocumentSaveDone(const ScriptDocument& _rDoc) override;
107 virtual void onDocumentSaveAs(const ScriptDocument& _rDoc) override;
108 virtual void onDocumentSaveAsDone(const ScriptDocument& _rDoc) override;
109 virtual void onDocumentClosed(const ScriptDocument& _rDoc) override;
110 virtual void onDocumentTitleChanged(const ScriptDocument& _rDoc) override;
111 virtual void onDocumentModeChanged(const ScriptDocument& _rDoc) override;
113 DocumentEventNotifier maNotifier;
115 public:
116 void set_sensitive(bool bSensitive);
120 * @brief Macros and Dialogs Library ComboBox
122 * @see LibBoxControl Class
124 class LibBox : public DocListenerBox
126 public:
127 /// @param pParent
128 LibBox(vcl::Window* pParent);
129 virtual ~LibBox() override;
130 virtual void dispose() override;
133 * Update selection in ComboBox of macro and dialog Library
135 * @param pItem -- string that was selected
137 void Update(const SfxStringItem* pItem);
139 protected:
140 /// Called for setting language when user selects a language in ComboBox
141 virtual void Select() override;
143 private:
144 static void ReleaseFocus();
147 * Insert name library in specified position
149 * @param rDocument -- macro or dialog
150 * @param eLocation -- enum value of Locations
152 void InsertEntries(const ScriptDocument& rDocument, LibraryLocation eLocation);
154 void ClearBox();
155 void NotifyIDE();
157 /// Fill up the combobox
158 virtual void FillBox() override;
161 * Handle keystrokes
163 * @param rKEvt represents key event
164 * @return a bool value: true if was handled, and false if there was nothing handled
166 virtual bool HandleKeyInput(const KeyEvent& rKEvt) override;
168 DECL_LINK(FocusInHdl, weld::Widget&, void);
169 DECL_LINK(FocusOutHdl, weld::Widget&, void);
171 OUString maCurrentText;
172 bool mbIgnoreSelect;
173 bool mbFillBox; ///< If true, when FillBox() is called
177 * @brief Manage stats of Language ComboBox
179 * @see LanguageBox Class
181 class LanguageBoxControl : public SfxToolBoxControl
183 public:
184 /*! Macro for registering two methods
186 * @code
187 * static SfxToolBoxControl* CreateImpl(sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx)
188 * static void RegisterControl(sal_uInt16 nSlotId = 0, SfxModule* pMod=nullptr)
189 * @endcode
190 * @see Macro SFX_IMPL_TOOLBOX_CONTROL
192 SFX_DECL_TOOLBOX_CONTROL();
195 * @param nSlotId -- the slot as internal operation number
196 * @param nId -- this item's unique id in ToolBox
197 * @param rTbx -- the ToolBox which contains this ComboBox
199 LanguageBoxControl(sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox& rTbx);
202 * Triggered if state was changed
204 * @param nSlotID -- the slot as internal operation number (not used in this place)
205 * @param eState -- enum value which contains ComboBox state
206 * @param pState --
208 virtual void StateChangedAtToolBoxControl(sal_uInt16 nSID, SfxItemState eState,
209 const SfxPoolItem* pState) override;
211 * Create ComboBox of Language
213 * @param pParent
214 * @return LanguageBox ComboBox
216 virtual VclPtr<InterimItemWindow> CreateItemWindow(vcl::Window* pParent) override;
220 * @brief Class language ComboBox
222 * @see LanguageBoxControl Class
224 class LanguageBox : public DocListenerBox
226 public:
228 * @param pParent
230 LanguageBox(vcl::Window* pParent);
231 virtual ~LanguageBox() override;
232 virtual void dispose() override;
235 * Update selection in ComboBox of macro and dialog Library
237 * @param pItem -- string that was selected
239 void Update(const SfxStringItem* pItem);
241 protected:
242 /// Called for setting language when user selects a language in ComboBox
243 virtual void Select() override;
246 * Handle keystrokes
248 * @param rKEvt represents key event
249 * @return a bool value: true if was handled, and false if there was nothing handled
251 virtual bool HandleKeyInput(const KeyEvent& rKEvt) override;
253 private:
254 /// Delete all languages from ComboBox
255 void ClearBox();
256 /// Switch interface of dialog to selected language
257 void SetLanguage();
259 /// Fill up the language combobox
260 virtual void FillBox() override;
262 OUString msNotLocalizedStr;
263 OUString msDefaultLanguageStr;
264 OUString msCurrentText;
266 bool mbIgnoreSelect; ///< do not use in this class
269 } // namespace basctl
271 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */