summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2020-02-17 09:15:01 +0000
committerCaolán McNamara <caolanm@redhat.com>2020-02-17 13:39:41 +0100
commit295bdf4a1749113ecee350d5d671f7807c7ca13f (patch)
tree5d3fec4c9726a58af5dbbd7550142ed18e19fd76
parenttdf#126785 qt5: Ignore external QEvent::ShortcutOverride (diff)
downloadcore-295bdf4a1749113ecee350d5d671f7807c7ca13f.tar.gz
core-295bdf4a1749113ecee350d5d671f7807c7ca13f.zip
weld SelectorListBox Item Window
Change-Id: I9752d03d9a70831d6e15fe3ac3ebdfc7d2728550 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/88853 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--basctl/source/basicide/IDEComboBox.cxx2
-rw-r--r--chart2/UIConfig_chart2.mk1
-rw-r--r--chart2/source/controller/main/ElementSelector.cxx114
-rw-r--r--chart2/source/controller/main/ElementSelector.hxx33
-rw-r--r--chart2/uiconfig/ui/combobox.ui38
5 files changed, 121 insertions, 67 deletions
diff --git a/basctl/source/basicide/IDEComboBox.cxx b/basctl/source/basicide/IDEComboBox.cxx
index b748577e9c63..1a3837091ec0 100644
--- a/basctl/source/basicide/IDEComboBox.cxx
+++ b/basctl/source/basicide/IDEComboBox.cxx
@@ -294,7 +294,7 @@ IMPL_LINK_NOARG(LibBox, FocusInHdl, weld::Widget&, void)
IMPL_LINK_NOARG(LibBox, FocusOutHdl, weld::Widget&, void)
{
// comboboxes can be comprised of multiple widgets, ensure all have lost focus
- if (!m_xWidget->has_focus())
+ if (m_xWidget && !m_xWidget->has_focus())
mbFillBox = true;
}
diff --git a/chart2/UIConfig_chart2.mk b/chart2/UIConfig_chart2.mk
index da0fcc1259a8..fd381de77acb 100644
--- a/chart2/UIConfig_chart2.mk
+++ b/chart2/UIConfig_chart2.mk
@@ -41,6 +41,7 @@ $(eval $(call gb_UIConfig_add_uifiles,modules/schart,\
chart2/uiconfig/ui/chartdatadialog \
chart2/uiconfig/ui/charttypedialog \
chart2/uiconfig/ui/columnfragment \
+ chart2/uiconfig/ui/combobox \
chart2/uiconfig/ui/datarangedialog \
chart2/uiconfig/ui/dlg_DataLabel \
chart2/uiconfig/ui/dlg_InsertErrorBars \
diff --git a/chart2/source/controller/main/ElementSelector.cxx b/chart2/source/controller/main/ElementSelector.cxx
index 30cc4102c3e2..c3433a08018d 100644
--- a/chart2/source/controller/main/ElementSelector.cxx
+++ b/chart2/source/controller/main/ElementSelector.cxx
@@ -51,10 +51,37 @@ namespace
static const char lcl_aServiceName[] = "com.sun.star.comp.chart.ElementSelectorToolbarController";
}
-SelectorListBox::SelectorListBox( vcl::Window* pParent, WinBits nStyle )
- : ListBox( pParent, nStyle )
- , m_bReleaseFocus( true )
+SelectorListBox::SelectorListBox(vcl::Window* pParent)
+ : InterimItemWindow(pParent, "modules/schart/ui/combobox.ui", "ComboBox")
+ , m_xWidget(m_xBuilder->weld_combo_box("combobox"))
+ , m_bReleaseFocus(true)
{
+ m_xWidget->connect_key_press(LINK(this, SelectorListBox, KeyInputHdl));
+ m_xWidget->connect_changed(LINK(this, SelectorListBox, SelectHdl));
+ m_xWidget->connect_focus_out(LINK(this, SelectorListBox, FocusOutHdl));
+
+ ::Size aLogicalSize(75, 0);
+ ::Size aPixelSize = LogicToPixel(aLogicalSize, MapMode(MapUnit::MapAppFont));
+ m_xWidget->set_size_request(aPixelSize.Width(), -1);
+ SetSizePixel(m_xContainer->get_preferred_size());
+}
+
+void SelectorListBox::dispose()
+{
+ m_xWidget.reset();
+ InterimItemWindow::dispose();
+}
+
+void SelectorListBox::GetFocus()
+{
+ if (m_xWidget)
+ m_xWidget->grab_focus();
+ InterimItemWindow::GetFocus();
+}
+
+SelectorListBox::~SelectorListBox()
+{
+ disposeOnce();
}
static void lcl_addObjectsToList( const ObjectHierarchy& rHierarchy, const ObjectIdentifier & rParent, std::vector< ListBoxEntryData >& rEntries
@@ -79,7 +106,7 @@ void SelectorListBox::SetChartController( const Reference< frame::XController >&
void SelectorListBox::UpdateChartElementsListAndSelection()
{
- Clear();
+ m_xWidget->clear();
m_aEntries.clear();
Reference< frame::XController > xChartController( m_xChartController );
@@ -138,11 +165,12 @@ void SelectorListBox::UpdateChartElementsListAndSelection()
}
}
+ m_xWidget->freeze();
sal_uInt16 nEntryPosToSelect = 0; bool bSelectionFound = false;
sal_uInt16 nN=0;
for (auto const& entry : m_aEntries)
{
- InsertEntry(entry.UIName);
+ m_xWidget->append_text(entry.UIName);
if ( !bSelectionFound && aSelectedOID == entry.OID )
{
nEntryPosToSelect = nN;
@@ -150,16 +178,12 @@ void SelectorListBox::UpdateChartElementsListAndSelection()
}
++nN;
}
+ m_xWidget->thaw();
if( bSelectionFound )
- SelectEntryPos(nEntryPosToSelect);
-
- sal_Int32 nEntryCount = GetEntryCount();
- if( nEntryCount > 100 )
- nEntryCount = 100;
- SetDropDownLineCount( nEntryCount );
+ m_xWidget->set_active(nEntryPosToSelect);
}
- SaveValue(); //remind current selection pos
+ m_xWidget->save_value(); //remind current selection pos
}
void SelectorListBox::ReleaseFocus_Impl()
@@ -176,14 +200,12 @@ void SelectorListBox::ReleaseFocus_Impl()
xFrame->getContainerWindow()->setFocus();
}
-void SelectorListBox::Select()
+IMPL_LINK(SelectorListBox, SelectHdl, weld::ComboBox&, rComboBox, void)
{
- ListBox::Select();
-
- if ( !IsTravelSelect() )
+ if (rComboBox.changed_by_direct_pick())
{
- const sal_Int32 nPos = GetSelectedEntryPos();
- if( o3tl::make_unsigned(nPos) < m_aEntries.size() )
+ const sal_Int32 nPos = rComboBox.get_active();
+ if (o3tl::make_unsigned(nPos) < m_aEntries.size())
{
ObjectIdentifier aOID = m_aEntries[nPos].OID;
Reference< view::XSelectionSupplier > xSelectionSupplier( m_xChartController.get(), uno::UNO_QUERY );
@@ -194,46 +216,38 @@ void SelectorListBox::Select()
}
}
-bool SelectorListBox::EventNotify( NotifyEvent& rNEvt )
+IMPL_LINK(SelectorListBox, KeyInputHdl, const KeyEvent&, rKEvt, bool)
{
bool bHandled = false;
- if ( rNEvt.GetType() == MouseNotifyEvent::KEYINPUT )
- {
- sal_uInt16 nCode = rNEvt.GetKeyEvent()->GetKeyCode().GetCode();
+ sal_uInt16 nCode = rKEvt.GetKeyCode().GetCode();
- switch ( nCode )
+ switch ( nCode )
+ {
+ case KEY_RETURN:
+ case KEY_TAB:
{
- case KEY_RETURN:
- case KEY_TAB:
- {
- if ( nCode == KEY_TAB )
- m_bReleaseFocus = false;
- else
- bHandled = true;
- Select();
- break;
- }
-
- case KEY_ESCAPE:
- SelectEntryPos( GetSavedValue() ); //restore saved selection
- ReleaseFocus_Impl();
- break;
+ if ( nCode == KEY_TAB )
+ m_bReleaseFocus = false;
+ else
+ bHandled = true;
+ SelectHdl(*m_xWidget);
+ break;
}
- }
- else if ( rNEvt.GetType() == MouseNotifyEvent::LOSEFOCUS )
- {
- if ( !HasFocus() )
- SelectEntryPos( GetSavedValue() );
+
+ case KEY_ESCAPE:
+ m_xWidget->set_active_text(m_xWidget->get_saved_value()); //restore saved selection
+ ReleaseFocus_Impl();
+ break;
}
- return bHandled || ListBox::EventNotify(rNEvt);
+ return bHandled || ChildKeyInput(rKEvt);
}
-Reference< css::accessibility::XAccessible > SelectorListBox::CreateAccessible()
+IMPL_LINK_NOARG(SelectorListBox, FocusOutHdl, weld::Widget&, void)
{
- UpdateChartElementsListAndSelection();
- return ListBox::CreateAccessible();
+ if (m_xWidget && !m_xWidget->has_focus()) // comboboxes can be comprised of multiple widgets, ensure all have lost focus
+ m_xWidget->set_active_text(m_xWidget->get_saved_value());
}
OUString SAL_CALL ElementSelectorToolbarController::getImplementationName()
@@ -294,11 +308,7 @@ uno::Reference< awt::XWindow > SAL_CALL ElementSelectorToolbarController::create
VclPtr<vcl::Window> pParent = VCLUnoHelper::GetWindow( xParent );
if( pParent )
{
- m_apSelectorListBox.reset( VclPtr<SelectorListBox>::Create( pParent, WB_DROPDOWN|WB_AUTOHSCROLL|WB_BORDER ) );
- ::Size aLogicalSize( 75, 160 );
- ::Size aPixelSize = m_apSelectorListBox->LogicToPixel(aLogicalSize, MapMode(MapUnit::MapAppFont));
- m_apSelectorListBox->SetSizePixel( aPixelSize );
- m_apSelectorListBox->SetDropDownLineCount( 5 );
+ m_apSelectorListBox.reset(VclPtr<SelectorListBox>::Create(pParent));
}
}
if( m_apSelectorListBox.get() )
diff --git a/chart2/source/controller/main/ElementSelector.hxx b/chart2/source/controller/main/ElementSelector.hxx
index 379fc0e57821..178fb080eaae 100644
--- a/chart2/source/controller/main/ElementSelector.hxx
+++ b/chart2/source/controller/main/ElementSelector.hxx
@@ -25,7 +25,7 @@
#include <cppuhelper/implbase1.hxx>
#include <svtools/toolboxcontroller.hxx>
-#include <vcl/lstbox.hxx>
+#include <sfx2/InterimItemWindow.hxx>
#include <cppuhelper/weakref.hxx>
namespace chart
@@ -42,26 +42,31 @@ struct ListBoxEntryData
}
};
-class SelectorListBox : public ListBox
+class SelectorListBox final : public InterimItemWindow
{
- public:
- SelectorListBox( vcl::Window* pParent, WinBits nStyle );
+public:
+ SelectorListBox(vcl::Window* pParent);
+ virtual void dispose() override;
+ virtual ~SelectorListBox() override;
+
+ virtual void GetFocus() override;
- virtual void Select() override;
- virtual bool EventNotify( NotifyEvent& rNEvt ) override;
- virtual css::uno::Reference< css::accessibility::XAccessible > CreateAccessible() override;
+ void ReleaseFocus_Impl();
- void ReleaseFocus_Impl();
+ void SetChartController( const css::uno::Reference< css::frame::XController >& xChartController );
+ void UpdateChartElementsListAndSelection();
- void SetChartController( const css::uno::Reference< css::frame::XController >& xChartController );
- void UpdateChartElementsListAndSelection();
+private:
+ css::uno::WeakReference<css::frame::XController> m_xChartController;
+ std::unique_ptr<weld::ComboBox> m_xWidget;
- private:
- css::uno::WeakReference< css::frame::XController > m_xChartController;
+ std::vector<ListBoxEntryData> m_aEntries;
- std::vector< ListBoxEntryData > m_aEntries;
+ bool m_bReleaseFocus;
- bool m_bReleaseFocus;
+ DECL_LINK(KeyInputHdl, const KeyEvent&, bool);
+ DECL_LINK(SelectHdl, weld::ComboBox&, void);
+ DECL_LINK(FocusOutHdl, weld::Widget&, void);
};
typedef ::cppu::ImplHelper1 < css::lang::XServiceInfo> ElementSelectorToolbarController_BASE;
diff --git a/chart2/uiconfig/ui/combobox.ui b/chart2/uiconfig/ui/combobox.ui
new file mode 100644
index 000000000000..b72cf753cb52
--- /dev/null
+++ b/chart2/uiconfig/ui/combobox.ui
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.22.1 -->
+<interface domain="chart">
+ <requires lib="gtk+" version="3.18"/>
+ <object class="GtkBox" id="ComboBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="orientation">vertical</property>
+ <child>
+ <object class="GtkBox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_right">6</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ <property name="spacing">6</property>
+ <child>
+ <object class="GtkComboBoxText" id="combobox">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="hexpand">True</property>
+ <property name="vexpand">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ </object>
+</interface>