summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2018-11-29 20:11:34 +0000
committerCaolán McNamara <caolanm@redhat.com>2018-12-01 22:37:22 +0100
commit9c5d20105f0b123fca724cb4845f0e7227c217d8 (patch)
tree00481857132abda3963231c181e04ab2321d0d61 /vcl
parent4e0be0c35024fc35d4815d2665e12f9ebf241025 (diff)
weld OfaAutoCompleteTabPage
Change-Id: I84f051fd1dc127663fd510c81addb0fd0cdc2c26 Reviewed-on: https://gerrit.libreoffice.org/64278 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.cxx89
-rw-r--r--vcl/source/control/button.cxx3
-rw-r--r--vcl/unx/gtk3/gtk3gtkinst.cxx93
3 files changed, 118 insertions, 67 deletions
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index b740bad17699..d9cdc5e0a63f 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -210,17 +210,26 @@ class SalInstanceWidget : public virtual weld::Widget
private:
VclPtr<vcl::Window> m_xWidget;
- DECL_LINK(FocusInListener, VclWindowEvent&, void);
- DECL_LINK(FocusOutListener, VclWindowEvent&, void);
- DECL_LINK(ResizeListener, VclWindowEvent&, void);
+ DECL_LINK(EventListener, VclWindowEvent&, void);
const bool m_bTakeOwnership;
+ bool m_bEventListener;
int m_nBlockNotify;
+ void ensure_event_listener()
+ {
+ if (!m_bEventListener)
+ {
+ m_xWidget->AddEventListener(LINK(this, SalInstanceWidget, EventListener));
+ m_bEventListener = true;
+ }
+ }
+
public:
SalInstanceWidget(vcl::Window* pWidget, bool bTakeOwnership)
: m_xWidget(pWidget)
, m_bTakeOwnership(bTakeOwnership)
+ , m_bEventListener(false)
, m_nBlockNotify(0)
{
}
@@ -415,22 +424,34 @@ public:
virtual void connect_focus_in(const Link<Widget&, void>& rLink) override
{
- m_xWidget->AddEventListener(LINK(this, SalInstanceWidget, FocusInListener));
+ ensure_event_listener();
weld::Widget::connect_focus_in(rLink);
}
virtual void connect_focus_out(const Link<Widget&, void>& rLink) override
{
- m_xWidget->AddEventListener(LINK(this, SalInstanceWidget, FocusOutListener));
+ ensure_event_listener();
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));
+ ensure_event_listener();
weld::Widget::connect_size_allocate(rLink);
}
+ virtual void connect_key_press(const Link<const KeyEvent&, bool>& rLink) override
+ {
+ ensure_event_listener();
+ weld::Widget::connect_key_press(rLink);
+ }
+
+ virtual void connect_key_release(const Link<const KeyEvent&, bool>& rLink) override
+ {
+ ensure_event_listener();
+ weld::Widget::connect_key_release(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()));
@@ -480,12 +501,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())
- m_xWidget->RemoveEventListener(LINK(this, SalInstanceWidget, FocusOutListener));
+ if (m_bEventListener)
+ m_xWidget->RemoveEventListener(LINK(this, SalInstanceWidget, EventListener));
if (m_bTakeOwnership)
m_xWidget.disposeAndClear();
}
@@ -516,23 +533,23 @@ public:
}
};
-IMPL_LINK(SalInstanceWidget, FocusInListener, VclWindowEvent&, rEvent, void)
+IMPL_LINK(SalInstanceWidget, EventListener, VclWindowEvent&, rEvent, void)
{
if (rEvent.GetId() == VclEventId::WindowGetFocus || rEvent.GetId() == VclEventId::WindowActivate)
- signal_focus_in();
-}
-
-IMPL_LINK(SalInstanceWidget, FocusOutListener, VclWindowEvent&, rEvent, void)
-{
- if (rEvent.GetId() == VclEventId::WindowLoseFocus || rEvent.GetId() == VclEventId::WindowDeactivate)
- signal_focus_out();
-}
-
-IMPL_LINK(SalInstanceWidget, ResizeListener, VclWindowEvent&, rEvent, void)
-{
- if (rEvent.GetId() == VclEventId::WindowResize)
- {
+ m_aFocusInHdl.Call(*this);
+ else if (rEvent.GetId() == VclEventId::WindowLoseFocus || rEvent.GetId() == VclEventId::WindowDeactivate)
+ m_aFocusOutHdl.Call(*this);
+ else if (rEvent.GetId() == VclEventId::WindowResize)
m_aSizeAllocateHdl.Call(m_xWidget->GetSizePixel());
+ else if (rEvent.GetId() == VclEventId::WindowKeyInput)
+ {
+ const KeyEvent* pKeyEvent = static_cast<const KeyEvent*>(rEvent.GetData());
+ m_aKeyPressHdl.Call(*pKeyEvent);
+ }
+ else if (rEvent.GetId() == VclEventId::WindowKeyUp)
+ {
+ const KeyEvent* pKeyEvent = static_cast<const KeyEvent*>(rEvent.GetData());
+ m_aKeyReleaseHdl.Call(*pKeyEvent);
}
}
@@ -1222,6 +1239,16 @@ public:
m_xButton->SetModeImage(::Image(BitmapEx(rIconName)));
}
+ virtual void set_label_line_wrap(bool wrap) override
+ {
+ WinBits nBits = m_xButton->GetStyle();
+ nBits &= ~WB_WORDBREAK;
+ if (wrap)
+ nBits |= WB_WORDBREAK;
+ m_xButton->SetStyle(nBits);
+ m_xButton->queue_resize();
+ }
+
virtual OUString get_label() const override
{
return m_xButton->GetText();
@@ -2682,6 +2709,16 @@ public:
weld::Widget::connect_size_allocate(rLink);
}
+ virtual void connect_key_press(const Link<const KeyEvent&, bool>& rLink) override
+ {
+ weld::Widget::connect_key_press(rLink);
+ }
+
+ virtual void connect_key_release(const Link<const KeyEvent&, bool>& rLink) override
+ {
+ weld::Widget::connect_key_release(rLink);
+ }
+
virtual a11yref get_accessible_parent() override
{
vcl::Window* pParent = m_xDrawingArea->GetParent();
diff --git a/vcl/source/control/button.cxx b/vcl/source/control/button.cxx
index b5e889d92e0d..b8dea3f8ee73 100644
--- a/vcl/source/control/button.cxx
+++ b/vcl/source/control/button.cxx
@@ -3696,7 +3696,8 @@ Size CheckBox::CalcMinimumSize( long nMaxWidth ) const
Size CheckBox::GetOptimalSize() const
{
- return CalcMinimumSize();
+ int nWidthRequest(get_width_request());
+ return CalcMinimumSize(nWidthRequest != -1 ? nWidthRequest : 0);
}
void CheckBox::ShowFocus(const tools::Rectangle& rRect)
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index 7cf2f66a6434..a37d199e1511 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -1178,6 +1178,18 @@ namespace
const gchar* pStr = static_cast<const gchar*>(pData);
return OString(pStr, pStr ? strlen(pStr) : 0);
}
+
+ KeyEvent GtkToVcl(GdkEventKey& rEvent)
+ {
+ sal_uInt16 nKeyCode = GtkSalFrame::GetKeyCode(rEvent.keyval);
+ if (nKeyCode == 0)
+ {
+ guint updated_keyval = GtkSalFrame::GetKeyValFor(gdk_keymap_get_default(), rEvent.hardware_keycode, rEvent.group);
+ nKeyCode = GtkSalFrame::GetKeyCode(updated_keyval);
+ }
+ nKeyCode |= GtkSalFrame::GetKeyModCode(rEvent.state);
+ return KeyEvent(gdk_keyval_to_unicode(rEvent.keyval), nKeyCode, 0);
+ }
}
class GtkInstanceWidget : public virtual weld::Widget
@@ -1190,6 +1202,7 @@ private:
gulong m_nFocusInSignalId;
gulong m_nFocusOutSignalId;
gulong m_nKeyPressSignalId;
+ gulong m_nKeyReleaseSignalId;
gulong m_nSizeAllocateSignalId;
static void signalFocusIn(GtkWidget*, GdkEvent*, gpointer widget)
@@ -1199,6 +1212,11 @@ private:
pThis->signal_focus_in();
}
+ void signal_focus_in()
+ {
+ m_aFocusInHdl.Call(*this);
+ }
+
static void signalFocusOut(GtkWidget*, GdkEvent*, gpointer widget)
{
GtkInstanceWidget* pThis = static_cast<GtkInstanceWidget*>(widget);
@@ -1206,6 +1224,11 @@ private:
pThis->signal_focus_out();
}
+ void signal_focus_out()
+ {
+ m_aFocusOutHdl.Call(*this);
+ }
+
static void signalSizeAllocate(GtkWidget*, GdkRectangle* allocation, gpointer widget)
{
GtkInstanceWidget* pThis = static_cast<GtkInstanceWidget*>(widget);
@@ -1213,7 +1236,7 @@ private:
pThis->signal_size_allocate(allocation->width, allocation->height);
}
- static gboolean signalKeyPress(GtkWidget*, GdkEventKey* pEvent, gpointer)
+ static gboolean signalKey(GtkWidget*, GdkEventKey* pEvent, gpointer widget)
{
// #i1820# use locale specific decimal separator
if (pEvent->keyval == GDK_KEY_KP_Decimal && Application::GetSettings().GetMiscSettings().GetEnableLocalizedDecimalSep())
@@ -1221,7 +1244,9 @@ private:
OUString aSep(Application::GetSettings().GetLocaleDataWrapper().getNumDecimalSep());
pEvent->keyval = aSep[0];
}
- return false;
+
+ GtkInstanceWidget* pThis = static_cast<GtkInstanceWidget*>(widget);
+ return pThis->signal_key(pEvent);
}
public:
@@ -1235,9 +1260,13 @@ public:
{
GdkEventMask eEventMask(static_cast<GdkEventMask>(gtk_widget_get_events(pWidget)));
if (eEventMask & GDK_BUTTON_PRESS_MASK)
- m_nKeyPressSignalId = g_signal_connect(pWidget, "key-press-event", G_CALLBACK(signalKeyPress), this);
+ m_nKeyPressSignalId = g_signal_connect(pWidget, "key-press-event", G_CALLBACK(signalKey), this);
else
m_nKeyPressSignalId = 0;
+ if (eEventMask & GDK_BUTTON_RELEASE_MASK)
+ m_nKeyReleaseSignalId = g_signal_connect(pWidget, "key-release-event", G_CALLBACK(signalKey), this);
+ else
+ m_nKeyReleaseSignalId = 0;
}
virtual void set_sensitive(bool sensitive) override
@@ -1519,6 +1548,21 @@ public:
m_aSizeAllocateHdl.Call(Size(nWidth, nHeight));
}
+ gboolean signal_key(GdkEventKey* pEvent)
+ {
+ if (pEvent->type == GDK_KEY_PRESS && m_aKeyPressHdl.IsSet())
+ {
+ SolarMutexGuard aGuard;
+ return m_aKeyPressHdl.Call(GtkToVcl(*pEvent));
+ }
+ if (pEvent->type == GDK_KEY_RELEASE && m_aKeyReleaseHdl.IsSet())
+ {
+ SolarMutexGuard aGuard;
+ return m_aKeyReleaseHdl.Call(GtkToVcl(*pEvent));
+ }
+ return false;
+ }
+
virtual void grab_add() override
{
gtk_grab_add(m_pWidget);
@@ -3321,6 +3365,12 @@ public:
return ::get_label(m_pButton);
}
+ virtual void set_label_line_wrap(bool wrap) override
+ {
+ GtkWidget* pChild = gtk_bin_get_child(GTK_BIN(m_pButton));
+ gtk_label_set_line_wrap(GTK_LABEL(pChild), wrap);
+ }
+
// allow us to block buttons with click handlers making dialogs return a response
bool has_click_handler() const
{
@@ -5484,18 +5534,6 @@ static MouseEventModifiers ImplGetMouseMoveMode(sal_uInt16 nCode)
namespace
{
AtkObject* (*default_drawing_area_get_accessible)(GtkWidget *widget);
-
- KeyEvent GtkToVcl(GdkEventKey& rEvent)
- {
- sal_uInt16 nKeyCode = GtkSalFrame::GetKeyCode(rEvent.keyval);
- if (nKeyCode == 0)
- {
- guint updated_keyval = GtkSalFrame::GetKeyValFor(gdk_keymap_get_default(), rEvent.hardware_keycode, rEvent.group);
- nKeyCode = GtkSalFrame::GetKeyCode(updated_keyval);
- }
- nKeyCode |= GtkSalFrame::GetKeyModCode(rEvent.state);
- return KeyEvent(gdk_keyval_to_unicode(rEvent.keyval), nKeyCode, 0);
- }
}
class GtkInstanceDrawingArea : public GtkInstanceWidget, public virtual weld::DrawingArea
@@ -5511,8 +5549,6 @@ private:
gulong m_nButtonPressSignalId;
gulong m_nMotionSignalId;
gulong m_nButtonReleaseSignalId;
- gulong m_nKeyPressSignalId;
- gulong m_nKeyReleaseSignalId;
gulong m_nStyleUpdatedSignalId;
gulong m_nQueryTooltip;
gulong m_nPopupMenu;
@@ -5689,25 +5725,6 @@ private:
m_aMouseMotionHdl.Call(aMEvt);
return true;
}
- static gboolean signalKey(GtkWidget*, GdkEventKey* pEvent, gpointer widget)
- {
- GtkInstanceDrawingArea* pThis = static_cast<GtkInstanceDrawingArea*>(widget);
- SolarMutexGuard aGuard;
- return pThis->signal_key(pEvent);
- }
- gboolean signal_key(GdkEventKey* pEvent)
- {
- KeyEvent aKeyEvt(GtkToVcl(*pEvent));
-
- bool bProcessed;
- if (pEvent->type == GDK_KEY_PRESS)
- bProcessed = m_aKeyPressHdl.Call(aKeyEvt);
- else
- bProcessed = m_aKeyReleaseHdl.Call(aKeyEvt);
-
- return bProcessed;
- }
-
public:
GtkInstanceDrawingArea(GtkDrawingArea* pDrawingArea, const a11yref& rA11y, bool bTakeOwnership)
: GtkInstanceWidget(GTK_WIDGET(pDrawingArea), bTakeOwnership)
@@ -5721,8 +5738,6 @@ public:
, 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))
- , m_nKeyPressSignalId(g_signal_connect(m_pDrawingArea, "key-press-event", G_CALLBACK(signalKey), this))
- , m_nKeyReleaseSignalId(g_signal_connect(m_pDrawingArea,"key-release-event", G_CALLBACK(signalKey), this))
, m_nStyleUpdatedSignalId(g_signal_connect(m_pDrawingArea,"style-updated", G_CALLBACK(signalStyleUpdated), this))
, m_nQueryTooltip(g_signal_connect(m_pDrawingArea, "query-tooltip", G_CALLBACK(signalQueryTooltip), this))
, m_nPopupMenu(g_signal_connect(m_pDrawingArea, "popup-menu", G_CALLBACK(signalPopupMenu), this))
@@ -5817,8 +5832,6 @@ public:
g_signal_handler_disconnect(m_pDrawingArea, m_nPopupMenu);
g_signal_handler_disconnect(m_pDrawingArea, m_nQueryTooltip);
g_signal_handler_disconnect(m_pDrawingArea, m_nStyleUpdatedSignalId);
- g_signal_handler_disconnect(m_pDrawingArea, m_nKeyPressSignalId);
- g_signal_handler_disconnect(m_pDrawingArea, m_nKeyReleaseSignalId);
g_signal_handler_disconnect(m_pDrawingArea, m_nButtonPressSignalId);
g_signal_handler_disconnect(m_pDrawingArea, m_nMotionSignalId);
g_signal_handler_disconnect(m_pDrawingArea, m_nButtonReleaseSignalId);