diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-11-29 11:45:47 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-11-30 00:48:49 +0100 |
commit | d8d231f97d829350d965105e3a5be119d1a6494c (patch) | |
tree | b9fd2678c493cd8be44f2289f24ad103090aa09f /vcl | |
parent | b937c6deb2e5610c26dc7082fcdbb0f4835ecd99 (diff) |
weld OfaAutocorrReplacePage
Change-Id: I143792cfe123942d44b2e39cb1910a5127b2f592
Reviewed-on: https://gerrit.libreoffice.org/64254
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/app/salvtables.cxx | 74 | ||||
-rw-r--r-- | vcl/source/control/combobox.cxx | 2 | ||||
-rw-r--r-- | vcl/source/control/edit.cxx | 3 | ||||
-rw-r--r-- | vcl/unx/gtk3/gtk3gtkinst.cxx | 75 |
4 files changed, 107 insertions, 47 deletions
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index d95d3de9f92f..b740bad17699 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -212,6 +212,7 @@ private: DECL_LINK(FocusInListener, VclWindowEvent&, void); DECL_LINK(FocusOutListener, VclWindowEvent&, void); + DECL_LINK(ResizeListener, VclWindowEvent&, void); const bool m_bTakeOwnership; int m_nBlockNotify; @@ -424,6 +425,22 @@ public: weld::Widget::connect_focus_out(rLink); } + virtual void connect_size_allocate(const Link<const Size&, void>& rLink) override + { + m_xWidget->AddEventListener(LINK(this, SalInstanceWidget, ResizeListener)); + weld::Widget::connect_size_allocate(rLink); + } + + virtual bool get_extents_relative_to(Widget& rRelative, int& x, int &y, int& width, int &height) override + { + tools::Rectangle aRect(m_xWidget->GetWindowExtentsRelative(dynamic_cast<SalInstanceWidget&>(rRelative).getWidget())); + x = aRect.Left(); + y = aRect.Top(); + width = aRect.GetWidth(); + height = aRect.GetHeight(); + return true; + } + virtual void grab_add() override { m_xWidget->CaptureMouse(); @@ -463,6 +480,8 @@ public: virtual ~SalInstanceWidget() override { + if (m_aSizeAllocateHdl.IsSet()) + m_xWidget->RemoveEventListener(LINK(this, SalInstanceWidget, ResizeListener)); if (m_aFocusInHdl.IsSet()) m_xWidget->RemoveEventListener(LINK(this, SalInstanceWidget, FocusInListener)); if (m_aFocusOutHdl.IsSet()) @@ -509,6 +528,14 @@ IMPL_LINK(SalInstanceWidget, FocusOutListener, VclWindowEvent&, rEvent, void) signal_focus_out(); } +IMPL_LINK(SalInstanceWidget, ResizeListener, VclWindowEvent&, rEvent, void) +{ + if (rEvent.GetId() == VclEventId::WindowResize) + { + m_aSizeAllocateHdl.Call(m_xWidget->GetSizePixel()); + } +} + namespace { Image createImage(const OUString& rImage) @@ -752,21 +779,6 @@ public: m_xWindow->SetPosPixel(Point(x, y)); } - vcl::Window* getWindow() - { - return m_xWindow.get(); - } - - virtual bool get_extents_relative_to(Window& rRelative, int& x, int &y, int& width, int &height) override - { - tools::Rectangle aRect(m_xWindow->GetWindowExtentsRelative(dynamic_cast<SalInstanceWindow&>(rRelative).getWindow())); - x = aRect.Left(); - y = aRect.Top(); - width = aRect.GetWidth(); - height = aRect.GetHeight(); - return true; - } - virtual Size get_size() const override { return m_xWindow->GetSizePixel(); @@ -1592,6 +1604,7 @@ private: DECL_LINK(ChangeHdl, Edit&, void); DECL_LINK(CursorListener, VclWindowEvent&, void); + DECL_LINK(ActivateHdl, Edit&, bool); class WeldTextFilter : public TextFilter { @@ -1624,6 +1637,7 @@ public: , m_aTextFilter(m_aInsertTextHdl) { m_xEntry->SetModifyHdl(LINK(this, SalInstanceEntry, ChangeHdl)); + m_xEntry->SetActivateHdl(LINK(this, SalInstanceEntry, ActivateHdl)); m_xEntry->SetTextFilter(&m_aTextFilter); } @@ -1744,6 +1758,7 @@ public: if (m_aCursorPositionHdl.IsSet()) m_xEntry->RemoveEventListener(LINK(this, SalInstanceEntry, CursorListener)); m_xEntry->SetTextFilter(nullptr); + m_xEntry->SetActivateHdl(Link<Edit&, bool>()); m_xEntry->SetModifyHdl(Link<Edit&, void>()); } }; @@ -1761,6 +1776,11 @@ IMPL_LINK(SalInstanceEntry, CursorListener, VclWindowEvent&, rEvent, void) signal_cursor_position(); } +IMPL_LINK_NOARG(SalInstanceEntry, ActivateHdl, Edit&, bool) +{ + return m_aActivateHdl.Call(*this); +} + struct SalInstanceTreeIter : public weld::TreeIter { SalInstanceTreeIter(const SalInstanceTreeIter* pOrig) @@ -1937,6 +1957,17 @@ public: enable_notify_events(); } + virtual void set_cursor(int pos) override + { + if (pos == -1) + m_xTreeView->SetCurEntry(nullptr); + else + { + SvTreeListEntry* pEntry = m_xTreeView->GetEntry(nullptr, pos); + m_xTreeView->SetCurEntry(pEntry); + } + } + virtual void scroll_to_row(int pos) override { assert(m_xTreeView->IsUpdateMode() && "don't select when frozen"); @@ -2646,6 +2677,11 @@ public: m_xDrawingArea->queue_resize(); } + virtual void connect_size_allocate(const Link<const Size&, void>& rLink) override + { + weld::Widget::connect_size_allocate(rLink); + } + virtual a11yref get_accessible_parent() override { vcl::Window* pParent = m_xDrawingArea->GetParent(); @@ -2980,7 +3016,7 @@ class SalInstanceComboBoxWithEdit : public SalInstanceComboBox<ComboBox> { private: DECL_LINK(ChangeHdl, Edit&, void); - DECL_LINK(EntryActivateHdl, Edit&, void); + DECL_LINK(EntryActivateHdl, Edit&, bool); public: SalInstanceComboBoxWithEdit(::ComboBox* pComboBox, bool bTakeOwnership) : SalInstanceComboBox<::ComboBox>(pComboBox, bTakeOwnership) @@ -3065,7 +3101,7 @@ public: virtual ~SalInstanceComboBoxWithEdit() override { - m_xComboBox->SetEntryActivateHdl(Link<Edit&, void>()); + m_xComboBox->SetEntryActivateHdl(Link<Edit&, bool>()); m_xComboBox->SetModifyHdl(Link<Edit&, void>()); } }; @@ -3075,9 +3111,9 @@ IMPL_LINK_NOARG(SalInstanceComboBoxWithEdit, ChangeHdl, Edit&, void) signal_changed(); } -IMPL_LINK_NOARG(SalInstanceComboBoxWithEdit, EntryActivateHdl, Edit&, void) +IMPL_LINK_NOARG(SalInstanceComboBoxWithEdit, EntryActivateHdl, Edit&, bool) { - m_aEntryActivateHdl.Call(*this); + return m_aEntryActivateHdl.Call(*this); } class SalInstanceEntryTreeView : public SalInstanceContainer, public virtual weld::EntryTreeView diff --git a/vcl/source/control/combobox.cxx b/vcl/source/control/combobox.cxx index 8dee63269d0e..9d34f9001182 100644 --- a/vcl/source/control/combobox.cxx +++ b/vcl/source/control/combobox.cxx @@ -999,7 +999,7 @@ void ComboBox::SetDoubleClickHdl(const Link<ComboBox&,void>& rLink) { m_pImpl->m const Link<ComboBox&,void>& ComboBox::GetDoubleClickHdl() const { return m_pImpl->m_DoubleClickHdl; } -void ComboBox::SetEntryActivateHdl(const Link<Edit&,void>& rLink) +void ComboBox::SetEntryActivateHdl(const Link<Edit&,bool>& rLink) { if (!m_pImpl->m_pSubEdit) return; diff --git a/vcl/source/control/edit.cxx b/vcl/source/control/edit.cxx index c1337c5dfe24..6e2667258190 100644 --- a/vcl/source/control/edit.cxx +++ b/vcl/source/control/edit.cxx @@ -1672,8 +1672,7 @@ bool Edit::ImplHandleKeyEvent( const KeyEvent& rKEvt ) case KEY_RETURN: if (maActivateHdl.IsSet()) { - maActivateHdl.Call(*this); - bDone = true; + bDone = maActivateHdl.Call(*this); } break; diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx index e04c6e66a829..4af889dd4d08 100644 --- a/vcl/unx/gtk3/gtk3gtkinst.cxx +++ b/vcl/unx/gtk3/gtk3gtkinst.cxx @@ -1190,6 +1190,7 @@ private: gulong m_nFocusInSignalId; gulong m_nFocusOutSignalId; gulong m_nKeyPressSignalId; + gulong m_nSizeAllocateSignalId; static void signalFocusIn(GtkWidget*, GdkEvent*, gpointer widget) { @@ -1205,6 +1206,13 @@ private: pThis->signal_focus_out(); } + static void signalSizeAllocate(GtkWidget*, GdkRectangle* allocation, gpointer widget) + { + GtkInstanceWidget* pThis = static_cast<GtkInstanceWidget*>(widget); + SolarMutexGuard aGuard; + pThis->signal_size_allocate(allocation->width, allocation->height); + } + static gboolean signalKeyPress(GtkWidget*, GdkEventKey* pEvent, gpointer) { // #i1820# use locale specific decimal separator @@ -1223,6 +1231,7 @@ public: , m_bFrozen(false) , m_nFocusInSignalId(0) , m_nFocusOutSignalId(0) + , m_nSizeAllocateSignalId(0) { GdkEventMask eEventMask(static_cast<GdkEventMask>(gtk_widget_get_events(pWidget))); if (eEventMask & GDK_BUTTON_PRESS_MASK) @@ -1439,6 +1448,17 @@ public: return OUString(pStr, pStr ? strlen(pStr) : 0, RTL_TEXTENCODING_UTF8); } + virtual bool get_extents_relative_to(weld::Widget& rRelative, int& x, int &y, int& width, int &height) override + { + //for toplevel windows this is sadly futile under wayland, so we can't tell where a dialog is in order to allow + //the document underneath to auto-scroll to place content in a visible location + gboolean ret = gtk_widget_translate_coordinates(dynamic_cast<GtkInstanceWidget&>(rRelative).getWidget(), + m_pWidget, 0, 0, &x, &y); + width = gtk_widget_get_allocated_width(m_pWidget); + height = gtk_widget_get_allocated_height(m_pWidget); + return ret; + } + virtual void set_tooltip_text(const OUString& rTip) override { gtk_widget_set_tooltip_text(m_pWidget, OUStringToOString(rTip, RTL_TEXTENCODING_UTF8).getStr()); @@ -1487,6 +1507,17 @@ public: weld::Widget::connect_focus_out(rLink); } + virtual void connect_size_allocate(const Link<const Size&, void>& rLink) override + { + m_nSizeAllocateSignalId = g_signal_connect(m_pWidget, "size_allocate", G_CALLBACK(signalSizeAllocate), this); + weld::Widget::connect_size_allocate(rLink); + } + + virtual void signal_size_allocate(guint nWidth, guint nHeight) + { + m_aSizeAllocateHdl.Call(Size(nWidth, nHeight)); + } + virtual void grab_add() override { gtk_grab_add(m_pWidget); @@ -1534,6 +1565,8 @@ public: g_signal_handler_disconnect(m_pWidget, m_nFocusInSignalId); if (m_nFocusOutSignalId) g_signal_handler_disconnect(m_pWidget, m_nFocusOutSignalId); + if (m_nSizeAllocateSignalId) + g_signal_handler_disconnect(m_pWidget, m_nSizeAllocateSignalId); if (m_bTakeOwnership) gtk_widget_destroy(m_pWidget); } @@ -1544,10 +1577,14 @@ public: g_signal_handler_block(m_pWidget, m_nFocusInSignalId); if (m_nFocusOutSignalId) g_signal_handler_block(m_pWidget, m_nFocusOutSignalId); + if (m_nSizeAllocateSignalId) + g_signal_handler_block(m_pWidget, m_nSizeAllocateSignalId); } virtual void enable_notify_events() { + if (m_nSizeAllocateSignalId) + g_signal_handler_unblock(m_pWidget, m_nSizeAllocateSignalId); if (m_nFocusOutSignalId) g_signal_handler_unblock(m_pWidget, m_nFocusOutSignalId); if (m_nFocusInSignalId) @@ -2095,16 +2132,6 @@ public: gtk_window_move(m_pWindow, x, y); } - virtual bool get_extents_relative_to(Window& rRelative, int& x, int &y, int& width, int &height) override - { - //this is sadly futile under wayland, so we can't tell where a dialog is in order to allow - //the document underneath to auto-scroll to place content in a visible location - gboolean ret = gtk_widget_translate_coordinates(dynamic_cast<GtkInstanceWindow&>(rRelative).getWidget(), m_pWidget, 0, 0, &x, &y); - width = gtk_widget_get_allocated_width(m_pWidget); - height = gtk_widget_get_allocated_height(m_pWidget); - return ret; - } - virtual SystemEnvData get_system_data() const override { assert(false && "nothing should call this impl, yet anyway, if ever"); @@ -3113,7 +3140,7 @@ private: // if > 6, but only if the notebook would auto-scroll, then flip tabs // to left which allows themes like Ambience under Ubuntu 16.04 to keep // tabs on top when they would fit - void signal_size_allocate() + void signal_notebook_size_allocate() { gint nPages = gtk_notebook_get_n_pages(m_pNotebook); if (nPages > 6 && gtk_notebook_get_tab_pos(m_pNotebook) == GTK_POS_TOP) @@ -3133,7 +3160,7 @@ private: static void signalSizeAllocate(GtkWidget*, GdkRectangle*, gpointer widget) { GtkInstanceNotebook* pThis = static_cast<GtkInstanceNotebook*>(widget); - pThis->signal_size_allocate(); + pThis->signal_notebook_size_allocate(); } public: @@ -4571,6 +4598,13 @@ public: enable_notify_events(); } + virtual void set_cursor(int pos) override + { + GtkTreePath* path = gtk_tree_path_new_from_indices(pos, -1); + gtk_tree_view_set_cursor(m_pTreeView, path, nullptr, false); + gtk_tree_path_free(path); + } + virtual void scroll_to_row(int pos) override { assert(gtk_tree_view_get_model(m_pTreeView) && "don't select when frozen"); @@ -5473,7 +5507,6 @@ private: cairo_surface_t* m_pSurface; sal_uInt16 m_nLastMouseButton; gulong m_nDrawSignalId; - gulong m_nSizeAllocateSignalId; gulong m_nButtonPressSignalId; gulong m_nMotionSignalId; gulong m_nButtonReleaseSignalId; @@ -5510,17 +5543,11 @@ private: aFocusRect.Left(), aFocusRect.Top(), aFocusRect.GetWidth(), aFocusRect.GetHeight()); } } - static void signalSizeAllocate(GtkWidget*, GdkRectangle* allocation, gpointer widget) - { - GtkInstanceDrawingArea* pThis = static_cast<GtkInstanceDrawingArea*>(widget); - SolarMutexGuard aGuard; - pThis->signal_size_allocate(allocation->width, allocation->height); - } - void signal_size_allocate(guint nWidth, guint nHeight) + virtual void signal_size_allocate(guint nWidth, guint nHeight) override { m_xDevice->SetOutputSizePixel(Size(nWidth, nHeight)); m_pSurface = get_underlying_cairo_surface(*m_xDevice); - m_aSizeAllocateHdl.Call(Size(nWidth, nHeight)); + GtkInstanceWidget::signal_size_allocate(nWidth, nHeight); } static void signalStyleUpdated(GtkWidget*, gpointer widget) { @@ -5690,7 +5717,6 @@ public: , m_pSurface(nullptr) , m_nLastMouseButton(0) , m_nDrawSignalId(g_signal_connect(m_pDrawingArea, "draw", G_CALLBACK(signalDraw), this)) - , m_nSizeAllocateSignalId(g_signal_connect(m_pDrawingArea, "size_allocate", G_CALLBACK(signalSizeAllocate), this)) , m_nButtonPressSignalId(g_signal_connect(m_pDrawingArea, "button-press-event", G_CALLBACK(signalButton), this)) , m_nMotionSignalId(g_signal_connect(m_pDrawingArea, "motion-notify-event", G_CALLBACK(signalMotion), this)) , m_nButtonReleaseSignalId(g_signal_connect(m_pDrawingArea, "button-release-event", G_CALLBACK(signalButton), this)) @@ -5795,7 +5821,6 @@ public: g_signal_handler_disconnect(m_pDrawingArea, m_nButtonPressSignalId); g_signal_handler_disconnect(m_pDrawingArea, m_nMotionSignalId); g_signal_handler_disconnect(m_pDrawingArea, m_nButtonReleaseSignalId); - g_signal_handler_disconnect(m_pDrawingArea, m_nSizeAllocateSignalId); g_signal_handler_disconnect(m_pDrawingArea, m_nDrawSignalId); } @@ -5858,8 +5883,8 @@ private: if (m_aEntryActivateHdl.IsSet()) { SolarMutexGuard aGuard; - m_aEntryActivateHdl.Call(*this); - g_signal_stop_emission_by_name(get_entry(), "activate"); + if (m_aEntryActivateHdl.Call(*this)) + g_signal_stop_emission_by_name(get_entry(), "activate"); } } |