summaryrefslogtreecommitdiff
path: root/svtools
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2020-05-13 13:59:11 +0100
committerCaolán McNamara <caolanm@redhat.com>2020-05-20 20:24:16 +0200
commit68d161c6803654f4ce816af7e79371a2d3497b4f (patch)
tree97cc8e55906b91ac966d7b1c09bdfcf51e8480f9 /svtools
parent96536d92e8026cebfde11e5539ee90471d0e7933 (diff)
weld ComboBoxControl
Change-Id: Ie862bb782b4c3e203af88d45c850ce0cab60f2e5 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94123 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'svtools')
-rw-r--r--svtools/source/brwbox/ebbcontrols.cxx59
1 files changed, 15 insertions, 44 deletions
diff --git a/svtools/source/brwbox/ebbcontrols.cxx b/svtools/source/brwbox/ebbcontrols.cxx
index c90561c6a89a..65f333d09cf9 100644
--- a/svtools/source/brwbox/ebbcontrols.cxx
+++ b/svtools/source/brwbox/ebbcontrols.cxx
@@ -26,75 +26,47 @@
namespace svt
{
-
//= ComboBoxControl
-
ComboBoxControl::ComboBoxControl(vcl::Window* pParent)
- :ComboBox(pParent, WB_DROPDOWN|WB_NOBORDER)
- {
- EnableAutoSize(false);
- EnableAutocomplete(true);
- SetDropDownLineCount(5);
- }
-
-
- bool ComboBoxControl::PreNotify( NotifyEvent& rNEvt )
+ : InterimItemWindow(pParent, "svt/ui/combocontrol.ui", "ComboControl")
+ , m_xWidget(m_xBuilder->weld_combo_box("combobox"))
{
- if (rNEvt.GetType() == MouseNotifyEvent::KEYINPUT && !IsInDropDown())
- {
- const KeyEvent *pEvt = rNEvt.GetKeyEvent();
- const vcl::KeyCode rKey = pEvt->GetKeyCode();
-
- if ((rKey.GetCode() == KEY_UP || rKey.GetCode() == KEY_DOWN) &&
- (!pEvt->GetKeyCode().IsShift() && pEvt->GetKeyCode().IsMod1()))
- {
- // select next resp. previous entry
- sal_Int32 nPos = GetEntryPos(GetText());
- int nDir = (rKey.GetCode() == KEY_DOWN ? 1 : -1);
- if (!((nPos == 0 && nDir == -1) || (nPos >= GetEntryCount() && nDir == 1)))
- {
- nPos += nDir;
- SetText(GetEntry(nPos));
- }
- return true;
- }
- }
- return ComboBox::PreNotify(rNEvt);
}
//= ComboBoxCellController
ComboBoxCellController::ComboBoxCellController(ComboBoxControl* pWin)
:CellController(pWin)
{
- GetComboBox().SetModifyHdl( LINK(this, ComboBoxCellController, ModifyHdl) );
+ GetComboBox().connect_changed(LINK(this, ComboBoxCellController, ModifyHdl));
}
- IMPL_LINK_NOARG(ComboBoxCellController, ModifyHdl, Edit&, void)
+ IMPL_LINK_NOARG(ComboBoxCellController, ModifyHdl, weld::ComboBox&, void)
{
callModifyHdl();
}
-
bool ComboBoxCellController::MoveAllowed(const KeyEvent& rEvt) const
{
- ComboBoxControl& rBox = GetComboBox();
+ weld::ComboBox& rBox = GetComboBox();
switch (rEvt.GetKeyCode().GetCode())
{
case KEY_END:
case KEY_RIGHT:
{
- Selection aSel = rBox.GetSelection();
- return !aSel && aSel.Max() == rBox.GetText().getLength();
+ int nStartPos, nEndPos;
+ bool bNoSelection = rBox.get_entry_selection_bounds(nStartPos, nEndPos);
+ return bNoSelection && nEndPos == rBox.get_active_text().getLength();
}
case KEY_HOME:
case KEY_LEFT:
{
- Selection aSel = rBox.GetSelection();
- return !aSel && aSel.Min() == 0;
+ int nStartPos, nEndPos;
+ bool bNoSelection = rBox.get_entry_selection_bounds(nStartPos, nEndPos);
+ return bNoSelection && nStartPos == 0;
}
case KEY_UP:
case KEY_DOWN:
- if (rBox.IsInDropDown())
+ if (rBox.get_popup_shown())
return false;
if (!rEvt.GetKeyCode().IsShift() &&
rEvt.GetKeyCode().IsMod1())
@@ -106,7 +78,7 @@ namespace svt
case KEY_PAGEUP:
case KEY_PAGEDOWN:
case KEY_RETURN:
- if (rBox.IsInDropDown())
+ if (rBox.get_popup_shown())
return false;
[[fallthrough]];
default:
@@ -114,15 +86,14 @@ namespace svt
}
}
-
bool ComboBoxCellController::IsModified() const
{
- return GetComboBox().IsValueChangedFromSaved();
+ return GetComboBox().get_value_changed_from_saved();
}
void ComboBoxCellController::ClearModified()
{
- GetComboBox().SaveValue();
+ GetComboBox().save_value();
}
//= ListBoxControl