diff options
author | Caolán McNamara <caolanm@redhat.com> | 2019-06-14 21:56:44 +0100 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2019-06-21 21:33:30 +0200 |
commit | 5261417cbb3051b812164838d19c0f748573df45 (patch) | |
tree | d159cce1d6903854fc13437c5cca5ce15e48281f /vcl | |
parent | fda464112540011dd6e2bd267720d2800af3a5f2 (diff) |
weld SpellDialog
a) use EditEngine instead of TextEngine as the former can be hosted in a
foreign widget
b) use a SfxGrabBagItem to hold the custom spellchecking info inside the
EditEngine
c) in longer paragraphs the current word is now auto-scrolled into view
d) rename Invalidate to InvalidateDialog
Change-Id: Ic6db019c32cdfd5f354c58ee7394fdaa040b86e1
Reviewed-on: https://gerrit.libreoffice.org/74119
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 | 33 | ||||
-rw-r--r-- | vcl/source/control/edit.cxx | 4 | ||||
-rw-r--r-- | vcl/source/edit/vclmedit.cxx | 4 | ||||
-rw-r--r-- | vcl/unx/gtk3/gtk3gtkinst.cxx | 50 |
4 files changed, 84 insertions, 7 deletions
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx index fadd5607c365..b17e0215258d 100644 --- a/vcl/source/app/salvtables.cxx +++ b/vcl/source/app/salvtables.cxx @@ -695,9 +695,9 @@ public: void SalInstanceWidget::HandleEventListener(VclWindowEvent& rEvent) { - if (rEvent.GetId() == VclEventId::WindowGetFocus || rEvent.GetId() == VclEventId::WindowActivate) + if (rEvent.GetId() == VclEventId::WindowGetFocus) m_aFocusInHdl.Call(*this); - else if (rEvent.GetId() == VclEventId::WindowLoseFocus || rEvent.GetId() == VclEventId::WindowDeactivate) + else if (rEvent.GetId() == VclEventId::WindowLoseFocus) m_aFocusOutHdl.Call(*this); else if (rEvent.GetId() == VclEventId::WindowResize) m_aSizeAllocateHdl.Call(m_xWidget->GetSizePixel()); @@ -1140,6 +1140,22 @@ public: return *m_xWindow->GetSystemData(); } + virtual void connect_toplevel_focus_changed(const Link<weld::Widget&, void>& rLink) override + { + ensure_event_listener(); + weld::Window::connect_toplevel_focus_changed(rLink); + } + + virtual void HandleEventListener(VclWindowEvent& rEvent) override + { + if (rEvent.GetId() == VclEventId::WindowActivate || rEvent.GetId() == VclEventId::WindowDeactivate) + { + signal_toplevel_focus_changed(); + return; + } + SalInstanceContainer::HandleEventListener(rEvent); + } + virtual ~SalInstanceWindow() override { clear_child_help(m_xWindow); @@ -1893,6 +1909,7 @@ public: m_xMenuButton->SetSelectHdl(LINK(this, SalInstanceMenuButton, MenuSelectHdl)); if (PopupMenu* pMenu = m_xMenuButton->GetPopupMenu()) { + pMenu->SetMenuFlags(MenuFlags::NoAutoMnemonics); const auto nCount = pMenu->GetItemCount(); m_nLastId = nCount ? pMenu->GetItemId(nCount-1) : 0; } @@ -1947,6 +1964,12 @@ public: pMenu->RemoveItem(pMenu->GetItemPos(pMenu->GetItemId(rId))); } + virtual void clear() override + { + PopupMenu* pMenu = m_xMenuButton->GetPopupMenu(); + pMenu->Clear(); + } + virtual void set_item_active(const OString& rIdent, bool bActive) override { PopupMenu* pMenu = m_xMenuButton->GetPopupMenu(); @@ -1959,6 +1982,12 @@ public: pMenu->SetItemText(pMenu->GetItemId(rIdent), rText); } + virtual OUString get_item_label(const OString& rIdent) const override + { + PopupMenu* pMenu = m_xMenuButton->GetPopupMenu(); + return pMenu->GetItemText(pMenu->GetItemId(rIdent)); + } + virtual void set_item_visible(const OString& rIdent, bool bShow) override { PopupMenu* pMenu = m_xMenuButton->GetPopupMenu(); diff --git a/vcl/source/control/edit.cxx b/vcl/source/control/edit.cxx index 57d037546c5f..926bc3193a7a 100644 --- a/vcl/source/control/edit.cxx +++ b/vcl/source/control/edit.cxx @@ -1467,7 +1467,7 @@ bool Edit::ImplHandleKeyEvent( const KeyEvent& rKEvt ) if ( pImplFncGetSpecialChars ) { Selection aSaveSel = GetSelection(); // if someone changes the selection in Get/LoseFocus, e.g. URL bar - OUString aChars = pImplFncGetSpecialChars( this, GetFont() ); + OUString aChars = pImplFncGetSpecialChars( GetFrameWeld(), GetFont() ); SetSelection( aSaveSel ); if ( !aChars.isEmpty() ) { @@ -2028,7 +2028,7 @@ void Edit::Command( const CommandEvent& rCEvt ) } else if (sCommand == "specialchar" && pImplFncGetSpecialChars) { - OUString aChars = pImplFncGetSpecialChars( this, GetFont() ); + OUString aChars = pImplFncGetSpecialChars(GetFrameWeld(), GetFont()); SetSelection( aSaveSel ); if (!aChars.isEmpty()) { diff --git a/vcl/source/edit/vclmedit.cxx b/vcl/source/edit/vclmedit.cxx index df9e23683d62..faa8e18061a5 100644 --- a/vcl/source/edit/vclmedit.cxx +++ b/vcl/source/edit/vclmedit.cxx @@ -715,7 +715,7 @@ void TextWindow::KeyInput( const KeyEvent& rKEvent ) { // to maintain the selection mbActivePopup = true; - OUString aChars = Edit::GetGetSpecialCharsFunction()( this, GetFont() ); + OUString aChars = Edit::GetGetSpecialCharsFunction()(GetFrameWeld(), GetFont()); if (!aChars.isEmpty()) { mpExtTextView->InsertText( aChars ); @@ -829,7 +829,7 @@ void TextWindow::Command( const CommandEvent& rCEvt ) } else if (sCommand == "specialchar") { - OUString aChars = Edit::GetGetSpecialCharsFunction()( this, GetFont() ); + OUString aChars = Edit::GetGetSpecialCharsFunction()(GetFrameWeld(), GetFont()); if (!aChars.isEmpty()) { mpExtTextView->InsertText( aChars ); diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx index 06f49b7aefc1..712dd51b9ae6 100644 --- a/vcl/unx/gtk3/gtk3gtkinst.cxx +++ b/vcl/unx/gtk3/gtk3gtkinst.cxx @@ -2421,7 +2421,7 @@ public: bool bCheck) { GtkWidget* pImage = nullptr; - if (pIconName) + if (pIconName && !pIconName->isEmpty()) { GdkPixbuf* pixbuf = load_icon_by_name(*pIconName); if (!pixbuf) @@ -2497,6 +2497,12 @@ public: gtk_menu_item_set_label(m_aMap[rIdent], MapToGtkAccelerator(rText).getStr()); } + OUString get_item_label(const OString& rIdent) const + { + const gchar* pText = gtk_menu_item_get_label(m_aMap.find(rIdent)->second); + return OUString(pText, pText ? strlen(pText) : 0, RTL_TEXTENCODING_UTF8); + } + void set_item_help_id(const OString& rIdent, const OString& rHelpId) { set_help_id(GTK_WIDGET(m_aMap[rIdent]), rHelpId); @@ -2634,18 +2640,27 @@ class GtkInstanceWindow : public GtkInstanceContainer, public virtual weld::Wind private: GtkWindow* m_pWindow; rtl::Reference<SalGtkXWindow> m_xWindow; //uno api + gulong m_nToplevelFocusChangedSignalId; static void help_pressed(GtkAccelGroup*, GObject*, guint, GdkModifierType, gpointer widget) { GtkInstanceWindow* pThis = static_cast<GtkInstanceWindow*>(widget); pThis->help(); } + + static void signalToplevelFocusChanged(GtkWindow*, GParamSpec*, gpointer widget) + { + GtkInstanceWindow* pThis = static_cast<GtkInstanceWindow*>(widget); + pThis->signal_toplevel_focus_changed(); + } + protected: void help(); public: GtkInstanceWindow(GtkWindow* pWindow, GtkInstanceBuilder* pBuilder, bool bTakeOwnership) : GtkInstanceContainer(GTK_CONTAINER(pWindow), pBuilder, bTakeOwnership) , m_pWindow(pWindow) + , m_nToplevelFocusChangedSignalId(0) { //hook up F1 to show help GtkAccelGroup *pGroup = gtk_accel_group_new(); @@ -2801,8 +2816,31 @@ public: return ImplWindowStateToStr(aData); } + virtual void connect_toplevel_focus_changed(const Link<weld::Widget&, void>& rLink) override + { + assert(!m_nToplevelFocusChangedSignalId); + m_nToplevelFocusChangedSignalId = g_signal_connect(m_pWindow, "notify::has-toplevel-focus", G_CALLBACK(signalToplevelFocusChanged), this); + weld::Window::connect_toplevel_focus_changed(rLink); + } + + virtual void disable_notify_events() override + { + if (m_nToplevelFocusChangedSignalId) + g_signal_handler_block(m_pWidget, m_nToplevelFocusChangedSignalId); + GtkInstanceContainer::disable_notify_events(); + } + + virtual void enable_notify_events() override + { + GtkInstanceContainer::enable_notify_events(); + if (m_nToplevelFocusChangedSignalId) + g_signal_handler_unblock(m_pWidget, m_nToplevelFocusChangedSignalId); + } + virtual ~GtkInstanceWindow() override { + if (m_nToplevelFocusChangedSignalId) + g_signal_handler_disconnect(m_pWindow, m_nToplevelFocusChangedSignalId); if (m_xWindow.is()) m_xWindow->clear(); } @@ -5214,6 +5252,11 @@ public: MenuHelper::remove_item(rId); } + virtual void clear() override + { + clear_items(); + } + virtual void set_item_active(const OString& rIdent, bool bActive) override { MenuHelper::set_item_active(rIdent, bActive); @@ -5229,6 +5272,11 @@ public: MenuHelper::set_item_label(rIdent, rLabel); } + virtual OUString get_item_label(const OString& rIdent) const override + { + return MenuHelper::get_item_label(rIdent); + } + virtual void set_item_visible(const OString& rIdent, bool bVisible) override { MenuHelper::set_item_visible(rIdent, bVisible); |