diff options
author | Caolán McNamara <caolanm@redhat.com> | 2020-06-20 16:01:07 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-06-23 12:50:00 +0200 |
commit | 5bbd8aecad3d2cc97c075490ef27aecc9180ef99 (patch) | |
tree | 6c5c2084d81ac5930bddb1668c86a6a1f322072f /vcl/inc | |
parent | 9d5e36c216d01a2cc0b2aefa801bb96ddb6eb199 (diff) |
most of jsdialogbuilder is not used outside vcl
so split it into the bit that is needed and just include that.
add missing license headers
Change-Id: I875f91176e6881e830fee6a58368d0b28ce9a0f7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96774
Tested-by: Jenkins
Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
Diffstat (limited to 'vcl/inc')
-rw-r--r-- | vcl/inc/jsdialog/jsdialogbuilder.hxx | 208 |
1 files changed, 208 insertions, 0 deletions
diff --git a/vcl/inc/jsdialog/jsdialogbuilder.hxx b/vcl/inc/jsdialog/jsdialogbuilder.hxx new file mode 100644 index 000000000000..5c7f5879af27 --- /dev/null +++ b/vcl/inc/jsdialog/jsdialogbuilder.hxx @@ -0,0 +1,208 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * 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/. + */ + +#pragma once + +#include <vcl/jsdialog/builder.hxx> +#include <vcl/weld.hxx> +#include <comphelper/string.hxx> +#include <vcl/sysdata.hxx> +#include <vcl/virdev.hxx> +#include <vcl/builder.hxx> +#include <vcl/salvtables.hxx> +#include <vcl/button.hxx> +#include <vcl/fmtfield.hxx> + +class ComboBox; +typedef std::map<OString, weld::Widget*> WidgetMap; + +class JSDialogNotifyIdle : public Idle +{ + VclPtr<vcl::Window> m_aWindow; + std::string m_LastNotificationMessage; + +public: + JSDialogNotifyIdle(VclPtr<vcl::Window> aWindow); + + void Invoke() override; +}; + +class VCL_DLLPUBLIC JSDialogSender +{ + std::unique_ptr<JSDialogNotifyIdle> mpIdleNotify; + +public: + JSDialogSender(VclPtr<vcl::Window> aOwnedToplevel) + : mpIdleNotify(new JSDialogNotifyIdle(aOwnedToplevel)) + { + } + + void notifyDialogState(); +}; + +class JSInstanceBuilder : public SalInstanceBuilder +{ + vcl::LOKWindowId m_nWindowId; + /// used in case of tab pages where dialog is not a direct top level + VclPtr<vcl::Window> m_aParentDialog; + bool m_bHasTopLevelDialog; + + friend VCL_DLLPUBLIC weld::Widget* jsdialog::FindWeldWidgetsMap(vcl::LOKWindowId nWindowId, + const OString& rWidget); + + static std::map<vcl::LOKWindowId, WidgetMap>& GetLOKWeldWidgetsMap(); + static void InsertWindowToMap(int nWindowId); + void RememberWidget(const OString& id, weld::Widget* pWidget); + +public: + JSInstanceBuilder(weld::Widget* pParent, const OUString& rUIRoot, const OUString& rUIFile); + virtual ~JSInstanceBuilder() override; + virtual std::unique_ptr<weld::Dialog> weld_dialog(const OString& id, + bool bTakeOwnership = true) override; + virtual std::unique_ptr<weld::Label> weld_label(const OString& id, + bool bTakeOwnership = false) override; + virtual std::unique_ptr<weld::Button> weld_button(const OString& id, + bool bTakeOwnership = false) override; + virtual std::unique_ptr<weld::Entry> weld_entry(const OString& id, + bool bTakeOwnership = false) override; + virtual std::unique_ptr<weld::ComboBox> weld_combo_box(const OString& id, + bool bTakeOwnership = false) override; + virtual std::unique_ptr<weld::Notebook> weld_notebook(const OString& id, + bool bTakeOwnership = false) override; + virtual std::unique_ptr<weld::SpinButton> + weld_spin_button(const OString& id, bool bTakeOwnership = false) override; + virtual std::unique_ptr<weld::CheckButton> + weld_check_button(const OString& id, bool bTakeOwnership = false) override; + + static weld::MessageDialog* CreateMessageDialog(weld::Widget* pParent, + VclMessageType eMessageType, + VclButtonsType eButtonType, + const OUString& rPrimaryMessage); +}; + +template <class BaseInstanceClass, class VclClass> +class JSWidget : public BaseInstanceClass, public JSDialogSender +{ +public: + JSWidget(VclPtr<vcl::Window> aOwnedToplevel, VclClass* pObject, SalInstanceBuilder* pBuilder, + bool bTakeOwnership) + : BaseInstanceClass(pObject, pBuilder, bTakeOwnership) + , JSDialogSender(aOwnedToplevel) + { + } + + virtual void show() override + { + BaseInstanceClass::show(); + notifyDialogState(); + } + + virtual void hide() override + { + BaseInstanceClass::hide(); + notifyDialogState(); + } + + virtual void set_sensitive(bool sensitive) override + { + BaseInstanceClass::set_sensitive(sensitive); + notifyDialogState(); + } +}; + +class JSLabel : public JSWidget<SalInstanceLabel, FixedText> +{ +public: + JSLabel(VclPtr<vcl::Window> aOwnedToplevel, FixedText* pLabel, SalInstanceBuilder* pBuilder, + bool bTakeOwnership); + virtual void set_label(const OUString& rText) override; +}; + +class JSButton : public JSWidget<SalInstanceButton, ::Button> +{ +public: + JSButton(VclPtr<vcl::Window> aOwnedToplevel, ::Button* pButton, SalInstanceBuilder* pBuilder, + bool bTakeOwnership); +}; + +class JSEntry : public JSWidget<SalInstanceEntry, ::Edit> +{ +public: + JSEntry(VclPtr<vcl::Window> aOwnedToplevel, ::Edit* pEntry, SalInstanceBuilder* pBuilder, + bool bTakeOwnership); + virtual void set_text(const OUString& rText) override; +}; + +class JSListBox : public JSWidget<SalInstanceComboBoxWithoutEdit, ::ListBox> +{ +public: + JSListBox(VclPtr<vcl::Window> aOwnedToplevel, ::ListBox* pListBox, SalInstanceBuilder* pBuilder, + bool bTakeOwnership); + virtual void insert(int pos, const OUString& rStr, const OUString* pId, + const OUString* pIconName, VirtualDevice* pImageSurface) override; + virtual void remove(int pos) override; + virtual void set_active(int pos) override; +}; + +class JSComboBox : public JSWidget<SalInstanceComboBoxWithEdit, ::ComboBox> +{ +public: + JSComboBox(VclPtr<vcl::Window> aOwnedToplevel, ::ComboBox* pComboBox, + SalInstanceBuilder* pBuilder, bool bTakeOwnership); + virtual void insert(int pos, const OUString& rStr, const OUString* pId, + const OUString* pIconName, VirtualDevice* pImageSurface) override; + virtual void remove(int pos) override; + virtual void set_entry_text(const OUString& rText) override; + virtual void set_active(int pos) override; +}; + +class JSNotebook : public JSWidget<SalInstanceNotebook, ::TabControl> +{ +public: + JSNotebook(VclPtr<vcl::Window> aOwnedToplevel, ::TabControl* pControl, + SalInstanceBuilder* pBuilder, bool bTakeOwnership); + + virtual void set_current_page(int nPage) override; + + virtual void set_current_page(const OString& rIdent) override; + + virtual void remove_page(const OString& rIdent) override; + + virtual void insert_page(const OString& rIdent, const OUString& rLabel, int nPos) override; +}; + +class VCL_DLLPUBLIC JSSpinButton : public JSWidget<SalInstanceSpinButton, ::FormattedField> +{ +public: + JSSpinButton(VclPtr<vcl::Window> aOwnedToplevel, ::FormattedField* pSpin, + SalInstanceBuilder* pBuilder, bool bTakeOwnership); + + virtual void set_value(int value) override; +}; + +class VCL_DLLPUBLIC JSMessageDialog : public SalInstanceMessageDialog, public JSDialogSender +{ +public: + JSMessageDialog(::MessageDialog* pDialog, SalInstanceBuilder* pBuilder, bool bTakeOwnership); + + virtual void set_primary_text(const OUString& rText) override; + + virtual void set_secondary_text(const OUString& rText) override; +}; + +class VCL_DLLPUBLIC JSCheckButton : public JSWidget<SalInstanceCheckButton, ::CheckBox> +{ +public: + JSCheckButton(VclPtr<vcl::Window> aOwnedToplevel, ::CheckBox* pCheckBox, + SalInstanceBuilder* pBuilder, bool bTakeOwnership); + + virtual void set_active(bool active) override; +}; + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ |