summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2018-05-23 14:15:46 +0100
committerCaolán McNamara <caolanm@redhat.com>2018-05-28 14:02:20 +0200
commit4883fd31141c3598b25a123033297f847cd18552 (patch)
tree2558d6a498a3466ab04a5b81e7289099766a6695 /vcl
parentf66510f1da3ab0584cd13e55f59728f7a2f2f488 (diff)
weld ScTabBgColorDlg
Change-Id: I864382bc55dead850c13faae9958fb660fd4f156 Reviewed-on: https://gerrit.libreoffice.org/54809 Tested-by: Jenkins <ci@libreoffice.org> 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/customweld.cxx6
-rw-r--r--vcl/source/app/salvtables.cxx23
-rw-r--r--vcl/unx/gtk3/gtk3gtkinst.cxx56
3 files changed, 81 insertions, 4 deletions
diff --git a/vcl/source/app/customweld.cxx b/vcl/source/app/customweld.cxx
index 706d3992304e..860a9d2c515e 100644
--- a/vcl/source/app/customweld.cxx
+++ b/vcl/source/app/customweld.cxx
@@ -30,6 +30,7 @@ CustomWeld::CustomWeld(weld::Builder& rBuilder, const OString& rDrawingId,
m_xDrawingArea->connect_key_press(LINK(this, CustomWeld, DoKeyPress));
m_xDrawingArea->connect_focus_rect(LINK(this, CustomWeld, DoFocusRect));
m_xDrawingArea->connect_style_updated(LINK(this, CustomWeld, DoStyleUpdated));
+ m_xDrawingArea->connect_query_tooltip(LINK(this, CustomWeld, DoRequestHelp));
m_rWidgetController.SetDrawingArea(m_xDrawingArea.get());
}
@@ -77,6 +78,11 @@ IMPL_LINK_NOARG(CustomWeld, DoStyleUpdated, weld::Widget&, void)
{
m_rWidgetController.StyleUpdated();
}
+
+IMPL_LINK(CustomWeld, DoRequestHelp, tools::Rectangle&, rHelpArea, OUString)
+{
+ return m_rWidgetController.RequestHelp(rHelpArea);
+}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index 154e1adb420f..2c6fdac648ae 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -346,6 +346,11 @@ public:
return m_xWidget->GetAccessibleName();
}
+ virtual void set_tooltip_text(const OUString& rTip) override
+ {
+ m_xWidget->SetQuickHelpText(rTip);
+ }
+
virtual void connect_focus_in(const Link<Widget&, void>& rLink) override
{
m_xWidget->AddEventListener(LINK(this, SalInstanceWidget, FocusInListener));
@@ -368,6 +373,11 @@ public:
m_xWidget->ReleaseMouse();
}
+ virtual bool get_direction() const override
+ {
+ return m_xWidget->IsRTLEnabled();
+ }
+
virtual weld::Container* weld_parent() const override;
virtual ~SalInstanceWidget() override
@@ -1720,6 +1730,7 @@ private:
DECL_LINK(KeyPressHdl, const KeyEvent&, bool);
DECL_LINK(KeyReleaseHdl, const KeyEvent&, bool);
DECL_LINK(StyleUpdatedHdl, VclDrawingArea&, void);
+ DECL_LINK(QueryTooltipHdl, tools::Rectangle&, OUString);
public:
SalInstanceDrawingArea(VclDrawingArea* pDrawingArea, const a11yref& rAlly,
@@ -1737,6 +1748,7 @@ public:
m_xDrawingArea->SetKeyPressHdl(LINK(this, SalInstanceDrawingArea, KeyPressHdl));
m_xDrawingArea->SetKeyReleaseHdl(LINK(this, SalInstanceDrawingArea, KeyReleaseHdl));
m_xDrawingArea->SetStyleUpdatedHdl(LINK(this, SalInstanceDrawingArea, StyleUpdatedHdl));
+ m_xDrawingArea->SetQueryTooltipHdl(LINK(this, SalInstanceDrawingArea, QueryTooltipHdl));
}
virtual void queue_draw() override
@@ -1749,6 +1761,11 @@ public:
m_xDrawingArea->Invalidate(tools::Rectangle(Point(x, y), Size(width, height)));
}
+ virtual void queue_resize() override
+ {
+ m_xDrawingArea->queue_resize();
+ }
+
virtual a11yref get_accessible_parent() override
{
vcl::Window* pParent = m_xDrawingArea->GetParent();
@@ -1782,6 +1799,7 @@ public:
virtual ~SalInstanceDrawingArea() override
{
+ m_xDrawingArea->SetQueryTooltipHdl(Link<tools::Rectangle&, OUString>());
m_xDrawingArea->SetStyleUpdatedHdl(Link<VclDrawingArea&, void>());
m_xDrawingArea->SetMousePressHdl(Link<const MouseEvent&, void>());
m_xDrawingArea->SetMouseMoveHdl(Link<const MouseEvent&, void>());
@@ -1836,6 +1854,11 @@ IMPL_LINK_NOARG(SalInstanceDrawingArea, StyleUpdatedHdl, VclDrawingArea&, void)
m_aStyleUpdatedHdl.Call(*this);
}
+IMPL_LINK(SalInstanceDrawingArea, QueryTooltipHdl, tools::Rectangle&, rHelpArea, OUString)
+{
+ return m_aQueryTooltipHdl.Call(rHelpArea);
+}
+
//ComboBox and ListBox have similar apis, ComboBoxes in LibreOffice have an edit box and ListBoxes
//don't. This distinction isn't there in Gtk. Use a template to sort this problem out.
template <class vcl_type>
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index 6ed971e2123b..da393b7ced7e 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -1253,6 +1253,17 @@ public:
virtual void set_size_request(int nWidth, int nHeight) override
{
+ GtkWidget* pParent = gtk_widget_get_parent(m_pWidget);
+ if (GTK_IS_VIEWPORT(pParent))
+ {
+ pParent = gtk_widget_get_parent(pParent);
+ if (GTK_IS_SCROLLED_WINDOW(pParent))
+ {
+ gtk_scrolled_window_set_min_content_width(GTK_SCROLLED_WINDOW(pParent), nWidth);
+ gtk_scrolled_window_set_min_content_height(GTK_SCROLLED_WINDOW(pParent), nHeight);
+ return;
+ }
+ }
gtk_widget_set_size_request(m_pWidget, nWidth, nHeight);
}
@@ -1369,6 +1380,11 @@ public:
return OUString(pStr, pStr ? strlen(pStr) : 0, RTL_TEXTENCODING_UTF8);
}
+ virtual void set_tooltip_text(const OUString& rTip) override
+ {
+ gtk_widget_set_tooltip_text(m_pWidget, OUStringToOString(rTip, RTL_TEXTENCODING_UTF8).getStr());
+ }
+
virtual weld::Container* weld_parent() const override;
virtual OString get_buildable_name() const override
@@ -1422,6 +1438,11 @@ public:
gtk_grab_remove(m_pWidget);
}
+ virtual bool get_direction() const override
+ {
+ return gtk_widget_get_direction(m_pWidget) == GTK_TEXT_DIR_RTL;
+ }
+
virtual ~GtkInstanceWidget() override
{
if (m_nFocusInSignalId)
@@ -3307,9 +3328,9 @@ public:
{
gtk_scrolled_window_set_min_content_width(GTK_SCROLLED_WINDOW(pParent), nWidth);
gtk_scrolled_window_set_min_content_height(GTK_SCROLLED_WINDOW(pParent), nHeight);
+ return;
}
- else
- gtk_widget_set_size_request(m_pWidget, nWidth, nHeight);
+ gtk_widget_set_size_request(m_pWidget, nWidth, nHeight);
}
virtual void set_selection_mode(bool bMultiple) override
@@ -3524,9 +3545,9 @@ public:
{
gtk_scrolled_window_set_min_content_width(GTK_SCROLLED_WINDOW(pParent), nWidth);
gtk_scrolled_window_set_min_content_height(GTK_SCROLLED_WINDOW(pParent), nHeight);
+ return;
}
- else
- gtk_widget_set_size_request(m_pWidget, nWidth, nHeight);
+ gtk_widget_set_size_request(m_pWidget, nWidth, nHeight);
}
virtual void set_text(const OUString& rText) override
@@ -3627,6 +3648,7 @@ private:
gulong m_nKeyPressSignalId;
gulong m_nKeyReleaseSignalId;
gulong m_nStyleUpdatedSignalId;
+ gulong m_nQueryTooltip;
static gboolean signalDraw(GtkWidget*, cairo_t* cr, gpointer widget)
{
@@ -3688,6 +3710,24 @@ private:
{
m_aStyleUpdatedHdl.Call(*this);
}
+ static gboolean signalQueryTooltip(GtkWidget*, gint x, gint y,
+ gboolean /*keyboard_mode*/, GtkTooltip *tooltip,
+ gpointer widget)
+ {
+ GtkInstanceDrawingArea* pThis = static_cast<GtkInstanceDrawingArea*>(widget);
+ tools::Rectangle aHelpArea(x, y);
+ OUString aTooltip = pThis->signal_query_tooltip(aHelpArea);
+ if (aTooltip.isEmpty())
+ return false;
+ gtk_tooltip_set_text(tooltip, OUStringToOString(aTooltip, RTL_TEXTENCODING_UTF8).getStr());
+ GdkRectangle aGdkHelpArea;
+ aGdkHelpArea.x = aHelpArea.Left();
+ aGdkHelpArea.y = aHelpArea.Top();
+ aGdkHelpArea.width = aHelpArea.GetWidth();
+ aGdkHelpArea.height = aHelpArea.GetHeight();
+ gtk_tooltip_set_tip_area(tooltip, &aGdkHelpArea);
+ return true;
+ }
static gboolean signalButton(GtkWidget*, GdkEventButton* pEvent, gpointer widget)
{
GtkInstanceDrawingArea* pThis = static_cast<GtkInstanceDrawingArea*>(widget);
@@ -3815,7 +3855,9 @@ public:
, 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))
{
+ gtk_widget_set_has_tooltip(m_pWidget, true);
g_object_set_data(G_OBJECT(m_pDrawingArea), "g-lo-GtkInstanceDrawingArea", this);
}
@@ -3840,6 +3882,11 @@ public:
gtk_widget_queue_draw_area(GTK_WIDGET(m_pDrawingArea), x, y, width, height);
}
+ virtual void queue_resize() override
+ {
+ gtk_widget_queue_resize(GTK_WIDGET(m_pDrawingArea));
+ }
+
virtual a11yref get_accessible_parent() override
{
//get_accessible_parent should only be needed for the vcl implementation,
@@ -3865,6 +3912,7 @@ public:
g_object_unref(m_pAccessible);
if (m_pSurface)
cairo_surface_destroy(m_pSurface);
+ 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);