From 30db63e8a3f8806a1b00e14cd70bc75f3e66211e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= Date: Wed, 3 Jul 2013 11:39:16 +0100 Subject: [PATCH] arrange a way to describe non-dropdown MetricBoxes i.e. use a VclComboBoxNumeric which now has an adjustment option and a dropdown option (defaulting to true). Rework existing glade widget placeholders to be children of that widget placeholder. Centralize the dropdown bit tweaking logic. Change-Id: Ib6dc4d19b367986e9d6a2fc2bead51e198892893 --- .../source/glade/libreoffice-catalog.xml.in | 89 ++++++++++++++----- include/vcl/builder.hxx | 2 + svtools/source/control/ctrlbox.cxx | 25 ++---- vcl/source/window/builder.cxx | 62 +++++++++++-- 4 files changed, 129 insertions(+), 49 deletions(-) diff --git a/extras/source/glade/libreoffice-catalog.xml.in b/extras/source/glade/libreoffice-catalog.xml.in index f717ee06a96e..ad045c5f0714 100644 --- a/extras/source/glade/libreoffice-catalog.xml.in +++ b/extras/source/glade/libreoffice-catalog.xml.in @@ -30,30 +30,92 @@ + + + + + + GParamBoolean + + + + + GParamInt + -1 + + The desired maximum width of the ComboBox, in characters + + + + + + + + + GParamObject + GtkAdjustment + + List of widgets in this group + + + + + icon-name="widget-gtk-combobox"> + + + + + + + icon-name="widget-gtk-combobox"> + + + + + + + icon-name="widget-gtk-combobox"> + + + + + + icon-name="widget-gtk-combobox"> + + + + + + + icon-name="widget-gtk-combobox"> + + + + + @@ -198,23 +260,6 @@ - - - - - GParamInt - -1 - - The desired maximum width of the ComboBox, in characters - - - - - second); - rMap.erase(aFind); - } - return bDropdown; - } -} - extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeColorListBox(Window *pParent, VclBuilder::stringmap &rMap) { - bool bDropdown = extractDropdown(rMap); + bool bDropdown = VclBuilder::extractDropdown(rMap); WinBits nWinBits = WB_LEFT|WB_VCENTER|WB_3DLOOK|WB_TABSTOP; if (bDropdown) nWinBits |= WB_DROPDOWN; @@ -797,7 +782,7 @@ LineListBox::LineListBox( Window* pParent, WinBits nWinStyle ) : extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeLineListBox(Window *pParent, VclBuilder::stringmap &rMap) { - bool bDropdown = extractDropdown(rMap); + bool bDropdown = VclBuilder::extractDropdown(rMap); WinBits nWinBits = WB_LEFT|WB_VCENTER|WB_3DLOOK|WB_TABSTOP; if (bDropdown) nWinBits |= WB_DROPDOWN; @@ -1073,7 +1058,7 @@ FontNameBox::FontNameBox( Window* pParent, const ResId& rResId ) : extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeFontNameBox(Window *pParent, VclBuilder::stringmap &rMap) { - bool bDropdown = extractDropdown(rMap); + bool bDropdown = VclBuilder::extractDropdown(rMap); WinBits nWinBits = WB_LEFT|WB_VCENTER|WB_3DLOOK|WB_TABSTOP; if (bDropdown) nWinBits |= WB_DROPDOWN; @@ -1461,7 +1446,7 @@ FontStyleBox::FontStyleBox( Window* pParent, WinBits nBits ) : extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeFontStyleBox(Window *pParent, VclBuilder::stringmap &rMap) { - bool bDropdown = extractDropdown(rMap); + bool bDropdown = VclBuilder::extractDropdown(rMap); WinBits nWinBits = WB_LEFT|WB_VCENTER|WB_3DLOOK|WB_TABSTOP; if (bDropdown) nWinBits |= WB_DROPDOWN; @@ -1681,7 +1666,7 @@ FontSizeBox::FontSizeBox( Window* pParent, const ResId& rResId ) : extern "C" SAL_DLLPUBLIC_EXPORT Window* SAL_CALL makeFontSizeBox(Window *pParent, VclBuilder::stringmap &rMap) { - bool bDropdown = extractDropdown(rMap); + bool bDropdown = VclBuilder::extractDropdown(rMap); WinBits nWinBits = WB_LEFT|WB_VCENTER|WB_3DLOOK|WB_TABSTOP; if (bDropdown) nWinBits |= WB_DROPDOWN; diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx index 4cea57f7afe0..5d02b3b5c703 100644 --- a/vcl/source/window/builder.cxx +++ b/vcl/source/window/builder.cxx @@ -877,6 +877,18 @@ bool VclBuilder::extractModel(const OString &id, stringmap &rMap) return false; } +bool VclBuilder::extractDropdown(VclBuilder::stringmap &rMap) +{ + bool bDropdown = true; + VclBuilder::stringmap::iterator aFind = rMap.find(OString("dropdown")); + if (aFind != rMap.end()) + { + bDropdown = toBool(aFind->second); + rMap.erase(aFind); + } + return bDropdown; +} + bool VclBuilder::extractBuffer(const OString &id, stringmap &rMap) { VclBuilder::stringmap::iterator aFind = rMap.find(OString("buffer")); @@ -1146,12 +1158,17 @@ Window *VclBuilder::makeObject(Window *pParent, const OString &name, const OStri OString sPattern = extractCustomProperty(rMap); extractModel(id, rMap); + WinBits nBits = WB_LEFT|WB_VCENTER|WB_3DLOOK|WB_DROPDOWN; + if (!sPattern.isEmpty()) { + OString sAdjustment = extractAdjustment(rMap); OString sUnit = extractUnit(sPattern); FieldUnit eUnit = detectMetricUnit(sUnit); - SAL_INFO("vcl.layout", "making metric box for " << name.getStr() << " " << sUnit.getStr()); - MetricBox *pBox = new MetricBox(pParent, WB_LEFT|WB_DROPDOWN|WB_VCENTER|WB_3DLOOK); + SAL_WARN("vcl.layout", "making metric box for " << name.getStr() << " " << sUnit.getStr() + << " use a VclComboBoxNumeric instead"); + MetricBox *pBox = new MetricBox(pParent, nBits); + pBox->EnableAutoSize(true); pBox->SetUnit(eUnit); if (eUnit == FUNIT_CUSTOM) pBox->SetCustomUnitText(OStringToOUString(sUnit, RTL_TEXTENCODING_UTF8)); @@ -1159,7 +1176,7 @@ Window *VclBuilder::makeObject(Window *pParent, const OString &name, const OStri } else if (extractEntry(rMap)) { - ComboBox* pComboBox = new ComboBox(pParent, WB_LEFT|WB_DROPDOWN|WB_VCENTER|WB_3DLOOK); + ComboBox* pComboBox = new ComboBox(pParent, nBits); pComboBox->EnableAutoSize(true); if (!rItems.empty()) { @@ -1173,7 +1190,7 @@ Window *VclBuilder::makeObject(Window *pParent, const OString &name, const OStri } else { - ListBox *pListBox = new ListBox(pParent, WB_LEFT|WB_DROPDOWN|WB_VCENTER|WB_3DLOOK|WB_SIMPLEMODE); + ListBox *pListBox = new ListBox(pParent, nBits|WB_SIMPLEMODE); pListBox->EnableAutoSize(true); if (!rItems.empty()) { @@ -1188,9 +1205,40 @@ Window *VclBuilder::makeObject(Window *pParent, const OString &name, const OStri } else if (name == "VclComboBoxNumeric") { - NumericBox* pComboBox = new NumericBox(pParent, WB_LEFT|WB_DROPDOWN|WB_VCENTER|WB_3DLOOK); - pComboBox->EnableAutoSize(true); - pWindow = pComboBox; + OString sPattern = extractCustomProperty(rMap); + OString sAdjustment = extractAdjustment(rMap); + extractModel(id, rMap); + + WinBits nBits = WB_LEFT|WB_VCENTER|WB_3DLOOK; + + bool bDropdown = VclBuilder::extractDropdown(rMap); + + if (bDropdown) + nBits |= WB_DROPDOWN; + + if (!sPattern.isEmpty()) + { + OString sUnit = extractUnit(sPattern); + FieldUnit eUnit = detectMetricUnit(sUnit); + SAL_INFO("vcl.layout", "making metric box for " << name.getStr() << " " << sUnit.getStr()); + connectNumericFormatterAdjustment(id, sAdjustment); + MetricBox *pBox = new MetricBox(pParent, nBits|WB_BORDER); + if (bDropdown) + pBox->EnableAutoSize(true); + pBox->SetUnit(eUnit); + if (eUnit == FUNIT_CUSTOM) + pBox->SetCustomUnitText(OStringToOUString(sUnit, RTL_TEXTENCODING_UTF8)); + pWindow = pBox; + } + else + { + SAL_INFO("vcl.layout", "making numeric box for " << name.getStr()); + connectNumericFormatterAdjustment(id, sAdjustment); + NumericBox* pBox = new NumericBox(pParent, nBits); + if (bDropdown) + pBox->EnableAutoSize(true); + pWindow = pBox; + } } else if (name == "GtkTreeView") {