diff options
-rw-r--r-- | framework/inc/uielement/FixedTextToolbarController.hxx | 5 | ||||
-rw-r--r-- | framework/source/uielement/FixedTextToolbarController.cxx | 51 | ||||
-rw-r--r-- | svtools/UIConfig_svt.mk | 1 | ||||
-rw-r--r-- | svtools/uiconfig/ui/fixedtextcontrol.ui | 22 |
4 files changed, 71 insertions, 8 deletions
diff --git a/framework/inc/uielement/FixedTextToolbarController.hxx b/framework/inc/uielement/FixedTextToolbarController.hxx index 299bb80982b3..ceecade1db5c 100644 --- a/framework/inc/uielement/FixedTextToolbarController.hxx +++ b/framework/inc/uielement/FixedTextToolbarController.hxx @@ -27,10 +27,11 @@ #include <vcl/fixed.hxx> class ToolBox; -class FixedText; namespace framework { +class FixedTextControl; + class FixedTextToolbarController final : public ComplexToolbarController { public: @@ -46,7 +47,7 @@ private: virtual css::uno::Sequence<css::beans::PropertyValue> getExecuteArgs(sal_Int16 KeyModifier) const override; - VclPtr<FixedText> m_pFixedTextControl; + VclPtr<FixedTextControl> m_pFixedTextControl; }; } diff --git a/framework/source/uielement/FixedTextToolbarController.cxx b/framework/source/uielement/FixedTextToolbarController.cxx index 531c0f8b64a5..a6bb5d25ad88 100644 --- a/framework/source/uielement/FixedTextToolbarController.cxx +++ b/framework/source/uielement/FixedTextToolbarController.cxx @@ -20,7 +20,7 @@ #include <uielement/FixedTextToolbarController.hxx> #include <vcl/toolbox.hxx> -#include <vcl/fixed.hxx> +#include <vcl/InterimItemWindow.hxx> #include <vcl/svapp.hxx> using namespace ::com::sun::star; @@ -33,13 +33,52 @@ using namespace ::com::sun::star::util; namespace framework { +class FixedTextControl final : public InterimItemWindow +{ +public: + FixedTextControl(vcl::Window* pParent); + virtual ~FixedTextControl() override; + virtual void dispose() override; + virtual void GetFocus() override + { + if (m_xWidget) + m_xWidget->grab_focus(); + InterimItemWindow::GetFocus(); + } + OUString get_label() const { return m_xWidget->get_label(); } + void set_label(const OUString& rLabel) { return m_xWidget->set_label(rLabel); } + DECL_LINK(KeyInputHdl, const ::KeyEvent&, bool); + +private: + std::unique_ptr<weld::Label> m_xWidget; +}; + +FixedTextControl::FixedTextControl(vcl::Window* pParent) + : InterimItemWindow(pParent, "svt/ui/fixedtextcontrol.ui", "FixedTextControl") + , m_xWidget(m_xBuilder->weld_label("label")) +{ + m_xWidget->connect_key_press(LINK(this, FixedTextControl, KeyInputHdl)); +} + +IMPL_LINK(FixedTextControl, KeyInputHdl, const ::KeyEvent&, rKEvt, bool) +{ + return ChildKeyInput(rKEvt); +} + +FixedTextControl::~FixedTextControl() { disposeOnce(); } + +void FixedTextControl::dispose() +{ + m_xWidget.reset(); + InterimItemWindow::dispose(); +} + FixedTextToolbarController::FixedTextToolbarController( const Reference<XComponentContext>& rxContext, const Reference<XFrame>& rFrame, ToolBox* pToolbar, sal_uInt16 nID, const OUString& aCommand) : ComplexToolbarController(rxContext, rFrame, pToolbar, nID, aCommand) { - m_pFixedTextControl = VclPtr<FixedText>::Create(m_xToolbar, WB_NOMULTILINE | WB_VCENTER - | WB_LEFT | WB_NOPOINTERFOCUS); + m_pFixedTextControl = VclPtr<FixedTextControl>::Create(m_xToolbar); m_xToolbar->SetItemWindow(m_nID, m_pFixedTextControl); m_xToolbar->SetItemBits(m_nID, ToolBoxItemBits::AUTOSIZE | m_xToolbar->GetItemBits(m_nID)); } @@ -55,7 +94,7 @@ void SAL_CALL FixedTextToolbarController::dispose() Sequence<PropertyValue> FixedTextToolbarController::getExecuteArgs(sal_Int16 KeyModifier) const { Sequence<PropertyValue> aArgs(2); - const OUString aSelectedText = m_pFixedTextControl->GetText(); + const OUString aSelectedText = m_pFixedTextControl->get_label(); // Add key modifier to argument list aArgs[0].Name = "KeyModifier"; @@ -79,8 +118,8 @@ void FixedTextToolbarController::executeControlCommand( { OUString aText; rArg.Value >>= aText; - m_pFixedTextControl->SetText(aText); - m_pFixedTextControl->SetSizePixel(m_pFixedTextControl->GetOptimalSize()); + m_pFixedTextControl->set_label(aText); + m_pFixedTextControl->SetSizePixel(m_pFixedTextControl->get_preferred_size()); // send notification notifyTextChanged(aText); diff --git a/svtools/UIConfig_svt.mk b/svtools/UIConfig_svt.mk index cca4c8c824e9..4c2a7cfd0703 100644 --- a/svtools/UIConfig_svt.mk +++ b/svtools/UIConfig_svt.mk @@ -18,6 +18,7 @@ $(eval $(call gb_UIConfig_add_uifiles,svt,\ svtools/uiconfig/ui/emptypage \ svtools/uiconfig/ui/fileviewmenu \ svtools/uiconfig/ui/fixedimagecontrol \ + svtools/uiconfig/ui/fixedtextcontrol \ svtools/uiconfig/ui/graphicexport \ svtools/uiconfig/ui/inputbox \ svtools/uiconfig/ui/javadisableddialog \ diff --git a/svtools/uiconfig/ui/fixedtextcontrol.ui b/svtools/uiconfig/ui/fixedtextcontrol.ui new file mode 100644 index 000000000000..116ae85bdd7a --- /dev/null +++ b/svtools/uiconfig/ui/fixedtextcontrol.ui @@ -0,0 +1,22 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- Generated with glade 3.22.2 --> +<interface domain="svt"> + <requires lib="gtk+" version="3.18"/> + <object class="GtkBox" id="FixedTextControl"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="orientation">vertical</property> + <child> + <object class="GtkLabel" id="label"> + <property name="visible">True</property> + <property name="can_focus">False</property> + <property name="hexpand">True</property> + </object> + <packing> + <property name="expand">True</property> + <property name="fill">True</property> + <property name="position">0</property> + </packing> + </child> + </object> +</interface> |