[Libreoffice-commits] core.git: cui/source include/vcl sfx2/source sw/source vcl/source vcl/unx
Caolán McNamara
caolanm at redhat.com
Fri Mar 16 20:30:15 UTC 2018
cui/source/dialogs/colorpicker.cxx | 6 +++---
include/vcl/outdev.hxx | 1 +
include/vcl/weld.hxx | 2 +-
sfx2/source/doc/new.cxx | 2 +-
sfx2/source/doc/saveastemplatedlg.cxx | 2 +-
sw/source/ui/table/instable.cxx | 2 +-
sw/source/ui/table/tautofmt.cxx | 2 +-
sw/source/uibase/dialog/SignatureLineDialog.cxx | 2 +-
vcl/source/app/salvtables.cxx | 4 ++--
vcl/source/outdev/text.cxx | 8 ++++++++
vcl/source/window/builder.cxx | 2 +-
vcl/unx/gtk3/gtk3gtkinst.cxx | 5 ++---
12 files changed, 23 insertions(+), 15 deletions(-)
New commits:
commit ca1ed645036cab9ba5e94a9d2e22ef8110e852e0
Author: Caolán McNamara <caolanm at redhat.com>
Date: Fri Mar 16 12:03:58 2018 +0000
use digit width instead of char width
its the same across backends
Change-Id: I37c83cbf1139babcd014c7cfdee06a13bea845c7
Reviewed-on: https://gerrit.libreoffice.org/51423
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Caolán McNamara <caolanm at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/cui/source/dialogs/colorpicker.cxx b/cui/source/dialogs/colorpicker.cxx
index 70a059a29014..87605abe22d5 100644
--- a/cui/source/dialogs/colorpicker.cxx
+++ b/cui/source/dialogs/colorpicker.cxx
@@ -166,7 +166,7 @@ public:
{
m_xDrawingArea->connect_size_allocate(LINK(this, ColorPreviewControl, DoResize));
m_xDrawingArea->connect_draw(LINK(this, ColorPreviewControl, DoPaint));
- m_xDrawingArea->set_size_request(m_xDrawingArea->get_approximate_char_width() * 10,
+ m_xDrawingArea->set_size_request(m_xDrawingArea->get_approximate_digit_width() * 10,
m_xDrawingArea->get_text_height() * 2);
}
@@ -212,7 +212,7 @@ public:
, mdX( -1.0 )
, mdY( -1.0 )
{
- m_xDrawingArea->set_size_request(m_xDrawingArea->get_approximate_char_width() * 40,
+ m_xDrawingArea->set_size_request(m_xDrawingArea->get_approximate_digit_width() * 40,
m_xDrawingArea->get_text_height() * 10);
m_xDrawingArea->connect_size_allocate(LINK(this, ColorFieldControl, DoResize));
m_xDrawingArea->connect_draw(LINK(this, ColorFieldControl, DoPaint));
@@ -559,7 +559,7 @@ ColorSliderControl::ColorSliderControl(weld::DrawingArea* pDrawingArea)
, mnLevel( 0 )
, mdValue( -1.0 )
{
- m_xDrawingArea->set_size_request(m_xDrawingArea->get_approximate_char_width() * 3, -1);
+ m_xDrawingArea->set_size_request(m_xDrawingArea->get_approximate_digit_width() * 3, -1);
m_xDrawingArea->connect_size_allocate(LINK(this, ColorSliderControl, DoResize));
m_xDrawingArea->connect_draw(LINK(this, ColorSliderControl, DoPaint));
m_xDrawingArea->connect_mouse_press(LINK(this, ColorSliderControl, DoButtonDown));
diff --git a/include/vcl/outdev.hxx b/include/vcl/outdev.hxx
index e2cec1c195dd..4b766ccd797a 100644
--- a/include/vcl/outdev.hxx
+++ b/include/vcl/outdev.hxx
@@ -1138,6 +1138,7 @@ public:
*/
long GetTextHeight() const;
float approximate_char_width() const;
+ float approximate_digit_width() const;
void DrawTextArray( const Point& rStartPt, const OUString& rStr,
const long* pDXAry,
diff --git a/include/vcl/weld.hxx b/include/vcl/weld.hxx
index 98c53f882e2f..eb1f8501cf04 100644
--- a/include/vcl/weld.hxx
+++ b/include/vcl/weld.hxx
@@ -42,7 +42,7 @@ public:
}
virtual void set_size_request(int nWidth, int nHeight) = 0;
virtual Size get_preferred_size() const = 0;
- virtual float get_approximate_char_width() const = 0;
+ virtual float get_approximate_digit_width() const = 0;
virtual int get_text_height() const = 0;
virtual Size get_pixel_size(const OUString& rText) const = 0;
virtual OString get_buildable_name() const = 0;
diff --git a/sfx2/source/doc/new.cxx b/sfx2/source/doc/new.cxx
index be99751c9a05..ef6fbf939a93 100644
--- a/sfx2/source/doc/new.cxx
+++ b/sfx2/source/doc/new.cxx
@@ -253,7 +253,7 @@ SfxNewFileDialog::SfxNewFileDialog(weld::Window *pParent, SfxNewFileDialogMode n
, m_sLoadTemplate(m_xAltTitleFt->get_label())
, m_nFlags(nFlags)
{
- const int nWidth = m_xRegionLb->get_approximate_char_width() * 32;
+ const int nWidth = m_xRegionLb->get_approximate_digit_width() * 32;
const int nHeight = m_xRegionLb->get_height_rows(8);
m_xRegionLb->set_size_request(nWidth, nHeight);
m_xTemplateLb->set_size_request(nWidth, nHeight);
diff --git a/sfx2/source/doc/saveastemplatedlg.cxx b/sfx2/source/doc/saveastemplatedlg.cxx
index e1f8101fa78d..76a647e94fa6 100644
--- a/sfx2/source/doc/saveastemplatedlg.cxx
+++ b/sfx2/source/doc/saveastemplatedlg.cxx
@@ -49,7 +49,7 @@ SfxSaveAsTemplateDialog::SfxSaveAsTemplateDialog(weld::Window* pParent, const un
m_xTemplateNameEdit->connect_changed(LINK(this, SfxSaveAsTemplateDialog, TemplateNameEditHdl));
m_xLBCategory->connect_changed(LINK(this, SfxSaveAsTemplateDialog, SelectCategoryHdl));
- m_xLBCategory->set_size_request(m_xLBCategory->get_approximate_char_width() * 32,
+ m_xLBCategory->set_size_request(m_xLBCategory->get_approximate_digit_width() * 32,
m_xLBCategory->get_height_rows(8));
m_xOKButton->connect_clicked(LINK(this, SfxSaveAsTemplateDialog, OkClickHdl));
diff --git a/sw/source/ui/table/instable.cxx b/sw/source/ui/table/instable.cxx
index 535ba075a15c..1b1f46f52be5 100644
--- a/sw/source/ui/table/instable.cxx
+++ b/sw/source/ui/table/instable.cxx
@@ -77,7 +77,7 @@ SwInsTableDlg::SwInsTableDlg(SwView& rView)
, pTAutoFormat(nullptr)
, nEnteredValRepeatHeaderNF(-1)
{
- const int nWidth = m_xLbFormat->get_approximate_char_width() * 32;
+ const int nWidth = m_xLbFormat->get_approximate_digit_width() * 32;
const int nHeight = m_xLbFormat->get_height_rows(8);
m_xLbFormat->set_size_request(nWidth, nHeight);
m_xWndPreview->set_size_request(nWidth, nHeight);
diff --git a/sw/source/ui/table/tautofmt.cxx b/sw/source/ui/table/tautofmt.cxx
index 97034075c537..68e5ba5b46c5 100644
--- a/sw/source/ui/table/tautofmt.cxx
+++ b/sw/source/ui/table/tautofmt.cxx
@@ -83,7 +83,7 @@ SwAutoFormatDlg::SwAutoFormatDlg(weld::Window* pParent, SwWrtShell* pWrtShell,
m_xWndPreview->DetectRTL(pWrtShell);
m_xTableTable->Load();
- const int nWidth = m_xLbFormat->get_approximate_char_width() * 32;
+ const int nWidth = m_xLbFormat->get_approximate_digit_width() * 32;
const int nHeight = m_xLbFormat->get_height_rows(8);
m_xLbFormat->set_size_request(nWidth, nHeight);
m_xWndPreview->set_size_request(nWidth, nHeight);
diff --git a/sw/source/uibase/dialog/SignatureLineDialog.cxx b/sw/source/uibase/dialog/SignatureLineDialog.cxx
index 815636d86ab9..2b0f48a42703 100644
--- a/sw/source/uibase/dialog/SignatureLineDialog.cxx
+++ b/sw/source/uibase/dialog/SignatureLineDialog.cxx
@@ -47,7 +47,7 @@ SignatureLineDialog::SignatureLineDialog(weld::Window* pParent, SwView& rView)
, m_xCheckboxShowSignDate(m_xBuilder->weld_check_button("checkbox_show_sign_date"))
, mrView(rView)
{
- m_xEditInstructions->set_size_request(m_xEditInstructions->get_approximate_char_width() * 24,
+ m_xEditInstructions->set_size_request(m_xEditInstructions->get_approximate_digit_width() * 48,
m_xEditInstructions->get_text_height() * 5);
// No signature line selected - start with empty dialog and generate a new one
diff --git a/vcl/source/app/salvtables.cxx b/vcl/source/app/salvtables.cxx
index ffcb468a458e..ed2f3b2d08cf 100644
--- a/vcl/source/app/salvtables.cxx
+++ b/vcl/source/app/salvtables.cxx
@@ -238,9 +238,9 @@ public:
return m_xWidget->get_preferred_size();
}
- virtual float get_approximate_char_width() const override
+ virtual float get_approximate_digit_width() const override
{
- return m_xWidget->approximate_char_width();
+ return m_xWidget->approximate_digit_width();
}
virtual int get_text_height() const override
diff --git a/vcl/source/outdev/text.cxx b/vcl/source/outdev/text.cxx
index f51dbabc558c..204feccc9da6 100644
--- a/vcl/source/outdev/text.cxx
+++ b/vcl/source/outdev/text.cxx
@@ -935,9 +935,17 @@ long OutputDevice::GetTextHeight() const
float OutputDevice::approximate_char_width() const
{
+ //note pango uses "The quick brown fox jumps over the lazy dog." for english
+ //and has a bunch of per-language strings which corresponds somewhat with
+ //makeRepresentativeText in include/svtools/sampletext.hxx
return GetTextWidth("aemnnxEM") / 8.0;
}
+float OutputDevice::approximate_digit_width() const
+{
+ return GetTextWidth("0123456789") / 10.0;
+}
+
void OutputDevice::DrawTextArray( const Point& rStartPt, const OUString& rStr,
const long* pDXAry,
sal_Int32 nIndex, sal_Int32 nLen, SalLayoutFlags flags )
diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx
index 064c91a825f8..1c1f63e7cdf6 100644
--- a/vcl/source/window/builder.cxx
+++ b/vcl/source/window/builder.cxx
@@ -173,7 +173,7 @@ namespace weld
m_xSpinButton->get_range(min, max);
auto width = std::max(m_xSpinButton->get_pixel_size(format_number(min)).Width(),
m_xSpinButton->get_pixel_size(format_number(max)).Width());
- int chars = ceil(width / m_xSpinButton->get_approximate_char_width());
+ int chars = ceil(width / m_xSpinButton->get_approximate_digit_width());
m_xSpinButton->set_width_chars(chars);
}
diff --git a/vcl/unx/gtk3/gtk3gtkinst.cxx b/vcl/unx/gtk3/gtk3gtkinst.cxx
index 3b54fbbb3415..e249a21dc5aa 100644
--- a/vcl/unx/gtk3/gtk3gtkinst.cxx
+++ b/vcl/unx/gtk3/gtk3gtkinst.cxx
@@ -1238,17 +1238,16 @@ public:
return Size(size.width, size.height);
}
- virtual float get_approximate_char_width() const override
+ virtual float get_approximate_digit_width() const override
{
PangoContext* pContext = gtk_widget_get_pango_context(m_pWidget);
PangoFontMetrics* pMetrics = pango_context_get_metrics(pContext,
pango_context_get_font_description(pContext),
pango_context_get_language(pContext));
- float nCharWidth = pango_font_metrics_get_approximate_char_width(pMetrics);
float nDigitWidth = pango_font_metrics_get_approximate_digit_width(pMetrics);
pango_font_metrics_unref(pMetrics);
- return std::max(nCharWidth, nDigitWidth) / PANGO_SCALE;
+ return nDigitWidth / PANGO_SCALE;
}
virtual int get_text_height() const override
More information about the Libreoffice-commits
mailing list