summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2013-02-25 12:41:29 +0000
committerCaolán McNamara <caolanm@redhat.com>2013-02-25 12:57:52 +0000
commitc1d3315e8d1e4d8be4bcabcf343ef5dd76d63691 (patch)
treedaf0f19ef428af9f1089df2e17146f32dc5a5c99
parent423932fe1849a2c9e2f4c1730a93435f39657e95 (diff)
Related: fdo#60764 APPFONT is 1/8 avg char *height* & 1/4 avg char *width*
but *sob*, it's not really that, because there's a dialog scale factor which is per-language which adds a bit to it depending on the language, MAP_REALAPPFONT is the unscaled variant. but *head in hands*, it's not really that either because if the font was considered "too narrow" then the average char width is recalculated in terms of the average char height. *clenches teeth*, add a approximate_char_width and use it directly. It can be considered the rough equivalent of pango_font_metrics_get_approximate_char_width albeit that it retains the same crude 1/8 of the width of "aemnnxEM" Change-Id: I4c135ca03467447dddf279ac0c187b13371acadb
-rw-r--r--sc/uiconfig/scalc/ui/sortoptionspage.ui2
-rw-r--r--vcl/inc/vcl/outdev.hxx1
-rw-r--r--vcl/source/control/combobox.cxx4
-rw-r--r--vcl/source/control/lstbox.cxx4
-rw-r--r--vcl/source/gdi/outdev3.cxx5
-rw-r--r--vcl/source/window/window.cxx2
6 files changed, 10 insertions, 8 deletions
diff --git a/sc/uiconfig/scalc/ui/sortoptionspage.ui b/sc/uiconfig/scalc/ui/sortoptionspage.ui
index 0fc7eebe601d..f6815af78bb7 100644
--- a/sc/uiconfig/scalc/ui/sortoptionspage.ui
+++ b/sc/uiconfig/scalc/ui/sortoptionspage.ui
@@ -168,7 +168,7 @@
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="margin_left">20</property>
- <property name="max_width_chars">72</property>
+ <property name="max_width_chars">65</property>
<accessibility>
<relation type="labelled-by" target="sortuser"/>
</accessibility>
diff --git a/vcl/inc/vcl/outdev.hxx b/vcl/inc/vcl/outdev.hxx
index 0eba3a120262..1fb5f2546880 100644
--- a/vcl/inc/vcl/outdev.hxx
+++ b/vcl/inc/vcl/outdev.hxx
@@ -580,6 +580,7 @@ public:
xub_StrLen nLen = STRING_LEN ) const;
/// Height where any character of the current font fits; in logic coordinates.
long GetTextHeight() const;
+ float approximate_char_width() const;
void DrawTextArray( const Point& rStartPt, const XubString& rStr,
const sal_Int32* pDXAry = NULL,
xub_StrLen nIndex = 0,
diff --git a/vcl/source/control/combobox.cxx b/vcl/source/control/combobox.cxx
index 5f9de77ad49b..8356a525efb9 100644
--- a/vcl/source/control/combobox.cxx
+++ b/vcl/source/control/combobox.cxx
@@ -1066,9 +1066,7 @@ Size ComboBox::CalcMinimumSize() const
aSz.Width() = mpImplLB->GetMaxEntryWidth();
if (m_nMaxWidthChars != -1)
{
- //MAP_APPFONT == 1/8th avg char
- long nMaxWidth = LogicToPixel(Size(m_nMaxWidthChars * 8, 0),
- MapMode(MAP_APPFONT)).Width();
+ long nMaxWidth = m_nMaxWidthChars * approximate_char_width();
aSz.Width() = std::min(aSz.Width(), nMaxWidth);
}
aSz.Width() += getMaxWidthScrollBarAndDownButton();
diff --git a/vcl/source/control/lstbox.cxx b/vcl/source/control/lstbox.cxx
index d87c1b3e4729..888081810614 100644
--- a/vcl/source/control/lstbox.cxx
+++ b/vcl/source/control/lstbox.cxx
@@ -1348,9 +1348,7 @@ Size ListBox::CalcSubEditSize() const
if (m_nMaxWidthChars != -1)
{
- //MAP_APPFONT == 1/8th avg char
- long nMaxWidth = LogicToPixel(Size(m_nMaxWidthChars * 8, 0),
- MapMode(MAP_APPFONT)).Width();
+ long nMaxWidth = m_nMaxWidthChars * approximate_char_width();
aSz.Width() = std::min(aSz.Width(), nMaxWidth);
}
diff --git a/vcl/source/gdi/outdev3.cxx b/vcl/source/gdi/outdev3.cxx
index 741ddbb03a46..44a4e964af1b 100644
--- a/vcl/source/gdi/outdev3.cxx
+++ b/vcl/source/gdi/outdev3.cxx
@@ -5759,6 +5759,11 @@ long OutputDevice::GetTextHeight() const
return nHeight;
}
+float OutputDevice::approximate_char_width() const
+{
+ return GetTextWidth(rtl::OUString("aemnnxEM")) / 8.0;
+}
+
// -----------------------------------------------------------------------
void OutputDevice::DrawTextArray( const Point& rStartPt, const String& rStr,
diff --git a/vcl/source/window/window.cxx b/vcl/source/window/window.cxx
index 309c8a37355b..8c6ac824e0cd 100644
--- a/vcl/source/window/window.cxx
+++ b/vcl/source/window/window.cxx
@@ -211,7 +211,7 @@ void Window::ImplInitAppFontData( Window* pWindow )
{
ImplSVData* pSVData = ImplGetSVData();
long nTextHeight = pWindow->GetTextHeight();
- long nTextWidth = pWindow->GetTextWidth(rtl::OUString("aemnnxEM"));
+ long nTextWidth = pWindow->approximate_char_width() * 8;
long nSymHeight = nTextHeight*4;
// Make the basis wider if the font is too narrow
// such that the dialog looks symmetrical and does not become too narrow.