1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
* This file is part of the LibreOffice project.
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* This file incorporates work covered by the following license notice:
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed
* with this work for additional information regarding copyright
* ownership. The ASF licenses this file to you under the Apache
* License, Version 2.0 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.apache.org/licenses/LICENSE-2.0 .
*/
#ifndef INCLUDED_BASCTL_SOURCE_BASICIDE_BASICBOX_HXX
#define INCLUDED_BASCTL_SOURCE_BASICIDE_BASICBOX_HXX
#include <svl/stritem.hxx>
#include <sfx2/tbxctrl.hxx>
#include <vcl/InterimItemWindow.hxx>
#include "doceventnotifier.hxx"
#include "scriptdocument.hxx"
namespace basctl
{
/*!
* @brief Manage states of macro and dialog Library ComboBox
*
* @see LibBox Class
*/
class LibBoxControl : public SfxToolBoxControl
{
public:
/*!
* Macro for registering two methods
*
* @code
* static SfxToolBoxControl* CreateImpl(sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx)
* static void RegisterControl(sal_uInt16 nSlotId = 0, SfxModule* pMod=nullptr)
* @endcode
* @see Macro SFX_IMPL_TOOLBOX_CONTROL
*/
SFX_DECL_TOOLBOX_CONTROL();
/*!
* @param nSlotId -- the slot as internal operation number
* @param nId -- this item's unique id in ToolBox
* @param rTbx -- the ToolBox which contains this ComboBox
*/
LibBoxControl(sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx);
/*!
* Triggered if state was changed
*
* @param nSlotID -- the slot as internal operation number (not used in this place)
* @param eState -- enum value which contains ComboBox state
* @param pState --
*/
virtual void StateChanged(sal_uInt16 nSlotID, SfxItemState eState,
const SfxPoolItem* pState) override;
/*!
* Create combobox of Macro and Dialog Library
*
* @param pParent -- parent window
* @return ComboBox of macro and dialog Library
*/
virtual VclPtr<InterimItemWindow> CreateItemWindow(vcl::Window* pParent) override;
};
/*!
* @brief Base class for all ComboBox elements.
*
* Base class for ComboBoxes which need to update their content according
* to the list of open documents.
*/
class DocListenerBox : public InterimItemWindow, public DocumentEventListener
{
private:
DECL_LINK(SelectHdl, weld::ComboBox&, void);
DECL_LINK(KeyInputHdl, const KeyEvent&, bool);
protected:
std::unique_ptr<weld::ComboBox> m_xWidget;
/// @param pParent -- parent window
DocListenerBox(vcl::Window* pParent);
virtual ~DocListenerBox() override;
virtual void dispose() override;
virtual void Select() = 0;
virtual void FillBox() = 0;
virtual void GetFocus() override
{
if (m_xWidget)
m_xWidget->grab_focus();
InterimItemWindow::GetFocus();
}
/// key strokes the ComboBox receives
virtual bool HandleKeyInput(const KeyEvent& rKEvt);
private:
// DocumentEventListener
virtual void onDocumentCreated(const ScriptDocument& _rDoc) override;
virtual void onDocumentOpened(const ScriptDocument& _rDoc) override;
virtual void onDocumentSave(const ScriptDocument& _rDoc) override;
virtual void onDocumentSaveDone(const ScriptDocument& _rDoc) override;
virtual void onDocumentSaveAs(const ScriptDocument& _rDoc) override;
virtual void onDocumentSaveAsDone(const ScriptDocument& _rDoc) override;
virtual void onDocumentClosed(const ScriptDocument& _rDoc) override;
virtual void onDocumentTitleChanged(const ScriptDocument& _rDoc) override;
virtual void onDocumentModeChanged(const ScriptDocument& _rDoc) override;
DocumentEventNotifier maNotifier;
public:
void set_sensitive(bool bSensitive);
};
/*!
* @brief Macros and Dialogs Library ComboBox
*
* @see LibBoxControl Class
*/
class LibBox : public DocListenerBox
{
public:
/// @param pParent
LibBox(vcl::Window* pParent);
virtual ~LibBox() override;
virtual void dispose() override;
/*!
* Update selection in ComboBox of macro and dialog Library
*
* @param pItem -- string that was selected
*/
void Update(const SfxStringItem* pItem);
protected:
/// Called for setting language when user selects a language in ComboBox
virtual void Select() override;
/*!
* Handle keystrokes and mouse
*
* @param rNEvt represents mouse event
* @return a bool value: true if was handled, and false if there was nothing handled
*/
//TODO virtual bool PreNotify(NotifyEvent& rNEvt) override;
private:
static void ReleaseFocus();
/*!
* Insert name library in specified position
*
* @param rDocument -- macro or dialog
* @param eLocation -- enum value of Locations
*/
void InsertEntries(const ScriptDocument& rDocument, LibraryLocation eLocation);
void ClearBox();
void NotifyIDE();
/// Fill up the combobox
virtual void FillBox() override;
virtual bool HandleKeyInput(const KeyEvent& rKEvt) override;
DECL_LINK(FocusInHdl, weld::Widget&, void);
DECL_LINK(FocusOutHdl, weld::Widget&, void);
OUString maCurrentText;
bool mbIgnoreSelect;
bool mbFillBox; ///< If true, when FillBox() is called
};
/*!
* @brief Manage stats of Language ComboBox
*
* @see LanguageBox Class
*/
class LanguageBoxControl : public SfxToolBoxControl
{
public:
/*! Macro for registering two methods
*
* @code
* static SfxToolBoxControl* CreateImpl(sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx)
* static void RegisterControl(sal_uInt16 nSlotId = 0, SfxModule* pMod=nullptr)
* @endcode
* @see Macro SFX_IMPL_TOOLBOX_CONTROL
*/
SFX_DECL_TOOLBOX_CONTROL();
/*!
* @param nSlotId -- the slot as internal operation number
* @param nId -- this item's unique id in ToolBox
* @param rTbx -- the ToolBox which contains this ComboBox
*/
LanguageBoxControl(sal_uInt16 nSlotId, sal_uInt16 nId, ToolBox& rTbx);
/*!
* Triggered if state was changed
*
* @param nSlotID -- the slot as internal operation number (not used in this place)
* @param eState -- enum value which contains ComboBox state
* @param pState --
*/
virtual void StateChanged(sal_uInt16 nSID, SfxItemState eState,
const SfxPoolItem* pState) override;
/*!
* Create ComboBox of Language
*
* @param pParent
* @return LanguageBox ComboBox
*/
virtual VclPtr<InterimItemWindow> CreateItemWindow(vcl::Window* pParent) override;
};
/*!
* @brief Class language ComboBox
*
* @see LanguageBoxControl Class
*/
class LanguageBox : public DocListenerBox
{
public:
/*!
* @param pParent
*/
LanguageBox(vcl::Window* pParent);
virtual ~LanguageBox() override;
virtual void dispose() override;
/*!
* Update selection in ComboBox of macro and dialog Library
*
* @param pItem -- string that was selected
*/
void Update(const SfxStringItem* pItem);
protected:
/// Called for setting language when user selects a language in ComboBox
virtual void Select() override;
virtual bool HandleKeyInput(const KeyEvent& rKEvt) override;
/*!
* Handle keystrokes and mouse
*
* @param rNEvt represents mouse event
* @return a bool value: true if was handled, and false if there was nothing handled
*/
//TODO virtual bool PreNotify(NotifyEvent& rNEvt) override;
private:
/// Delete all languages from ComboBox
void ClearBox();
/// Switch interface of dialog to selected language
void SetLanguage();
/// Fill up the language combobox
virtual void FillBox() override;
OUString msNotLocalizedStr;
OUString msDefaultLanguageStr;
OUString msCurrentText;
bool mbIgnoreSelect; ///< do not use in this class
};
} // namespace basctl
#endif // INCLUDED_BASCTL_SOURCE_BASICIDE_BASICBOX_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|