[Libreoffice-commits] core.git: 3 commits - extras/source include/vcl svtools/source vcl/source
Caolán McNamara
caolanm at redhat.com
Wed Jul 3 04:46:53 PDT 2013
extras/source/glade/libreoffice-catalog.xml.in | 89 ++++++++++++++++++-------
include/vcl/builder.hxx | 2
include/vcl/field.hxx | 4 +
svtools/source/control/ctrlbox.cxx | 25 +------
vcl/source/control/combobox.cxx | 27 ++++---
vcl/source/control/field.cxx | 12 +++
vcl/source/window/builder.cxx | 62 +++++++++++++++--
7 files changed, 159 insertions(+), 62 deletions(-)
New commits:
commit 30db63e8a3f8806a1b00e14cd70bc75f3e66211e
Author: Caolán McNamara <caolanm at redhat.com>
Date: Wed Jul 3 11:39:16 2013 +0100
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
diff --git a/extras/source/glade/libreoffice-catalog.xml.in b/extras/source/glade/libreoffice-catalog.xml.in
index f717ee0..ad045c5 100644
--- a/extras/source/glade/libreoffice-catalog.xml.in
+++ b/extras/source/glade/libreoffice-catalog.xml.in
@@ -30,30 +30,92 @@
<glade-widget-class title="Hyphen Edit" name="cuilo-HyphenEdit"
generic-name="ReplaceEdit" parent="GtkEntry"
icon-name="widget-gtk-textentry"/>
+
+ <glade-widget-class title="VclComboBoxText" name="VclComboBoxText"
+ generic-name="ComboBoxText" parent="GtkComboBoxText"
+ icon-name="widget-gtk-comboboxtext">
+ <properties>
+ <property save="True" query="False" id="dropdown" default="True" name="Use DropDown">
+ <parameter-spec>
+ <type>GParamBoolean</type>
+ </parameter-spec>
+ </property>
+ <property save="True" query="False" id="max-width-chars" default="-1" name="Maximum Width in Characters">
+ <parameter-spec>
+ <type>GParamInt</type>
+ <min>-1</min>
+ </parameter-spec>
+ <tooltip>The desired maximum width of the ComboBox, in characters</tooltip>
+ </property>
+ </properties>
+ </glade-widget-class>
+
+ <glade-widget-class title="VclComboBoxNumeric" name="VclComboBoxNumeric"
+ generic-name="ComboBoxNumeric" parent="VclComboBoxText"
+ icon-name="widget-gtk-comboboxtext">
+ <properties>
+ <property save="True" query="False" id="adjustment" name="Adjustment">
+ <parameter-spec>
+ <type>GParamObject</type>
+ <value-type>GtkAdjustment</value-type>
+ </parameter-spec>
+ <tooltip>List of widgets in this group</tooltip>
+ </property>
+ </properties>
+ </glade-widget-class>
+
<glade-widget-class title="Color ListBox" name="svtlo-ColorListBox"
generic-name="Color ListBox" parent="GtkComboBox"
- icon-name="widget-gtk-combobox"/>
+ icon-name="widget-gtk-combobox">
+ <properties>
+ <property id="dropdown" default="True" common="True"/>
+ </properties>
+ </glade-widget-class>
+
<glade-widget-class title="Other Color ListBox" name="svxlo-ColorLB"
generic-name="Other Color ListBox" parent="GtkComboBox"
icon-name="widget-gtk-combobox"/>
+
<glade-widget-class title="Font Name ListBox" name="svtlo-FontNameBox"
generic-name="Font name ListBox" parent="GtkComboBox"
- icon-name="widget-gtk-combobox"/>
+ icon-name="widget-gtk-combobox">
+ <properties>
+ <property id="dropdown" default="True" common="True"/>
+ </properties>
+ </glade-widget-class>
+
<glade-widget-class title="Sidebar Font Name ListBox" name="svxlo-SvxSBFontNameBox"
generic-name="Sidebar Font name ListBox" parent="GtkComboBox"
icon-name="widget-gtk-combobox"/>
+
<glade-widget-class title="Font Size ListBox" name="svtlo-FontSizeBox"
generic-name="Font Size ListBox" parent="GtkComboBox"
- icon-name="widget-gtk-combobox"/>
+ icon-name="widget-gtk-combobox">
+ <properties>
+ <property id="dropdown" default="True" common="True"/>
+ </properties>
+ </glade-widget-class>
+
<glade-widget-class title="Line ListBox" name="svtlo-LineListBox"
generic-name="Line ListBox" parent="GtkComboBox"
- icon-name="widget-gtk-combobox"/>
+ icon-name="widget-gtk-combobox">
+ <properties>
+ <property id="dropdown" default="True" common="True"/>
+ </properties>
+ </glade-widget-class>
+
<glade-widget-class title="Language ListBox" name="svxcorelo-SvxLanguageBox"
generic-name="LanguageBox" parent="GtkComboBox"
icon-name="widget-gtk-combobox"/>
+
<glade-widget-class title="Font ListBox" name="svtlo-FontStyleBox"
generic-name="FontStyleBox" parent="GtkComboBox"
- icon-name="widget-gtk-combobox"/>
+ icon-name="widget-gtk-combobox">
+ <properties>
+ <property id="dropdown" default="True" common="True"/>
+ </properties>
+ </glade-widget-class>
+
<glade-widget-class title="Text Encoding ListBox" name="svxlo-SvxTextEncodingBox"
generic-name="TextEncodingBox" parent="GtkComboBox"
icon-name="widget-gtk-combobox"/>
@@ -198,23 +260,6 @@
<glade-widget-class title="Relative Numeric Field" name="svxlo-SvxRelativeField"
generic-name="Relative Numeric Field" parent="GtkSpinButton"
icon-name="widget-gtk-spinbutton"/>
- <glade-widget-class title="VclComboBoxText" name="VclComboBoxText"
- generic-name="ComboBoxText" parent="GtkComboBoxText"
- icon-name="widget-gtk-comboboxtext">
- <properties>
- <property save="True" query="False" id="max-width-chars" default="-1" name="Maximum Width in Characters">
- <parameter-spec>
- <type>GParamInt</type>
- <min>-1</min>
- </parameter-spec>
- <tooltip>The desired maximum width of the ComboBox, in characters</tooltip>
- </property>
- </properties>
- </glade-widget-class>
-
- <glade-widget-class title="VclComboBoxNumeric" name="VclComboBoxNumeric"
- generic-name="ComboBoxNumeric" parent="VclComboBoxText"
- icon-name="widget-gtk-comboboxtext"/>
<glade-widget-class title="SvtURLBox" name="svtlo-SvtURLBox"
generic-name="URLBox" parent="VclComboBoxText"
diff --git a/include/vcl/builder.hxx b/include/vcl/builder.hxx
index 13aba58..3708a34 100644
--- a/include/vcl/builder.hxx
+++ b/include/vcl/builder.hxx
@@ -290,6 +290,8 @@ public:
static OString extractCustomProperty(stringmap &rMap);
+ static bool extractDropdown(stringmap &rMap);
+
//add a default value of 25 width-chars to a map if width-chars not set
static void ensureDefaultWidthChars(VclBuilder::stringmap &rMap);
diff --git a/svtools/source/control/ctrlbox.cxx b/svtools/source/control/ctrlbox.cxx
index 4d28a77..d1599fa 100644
--- a/svtools/source/control/ctrlbox.cxx
+++ b/svtools/source/control/ctrlbox.cxx
@@ -114,24 +114,9 @@ ColorListBox::ColorListBox( Window* pParent, const ResId& rResId ) :
SetEdgeBlending(true);
}
-namespace
-{
- bool extractDropdown(VclBuilder::stringmap &rMap)
- {
- bool bDropdown = true;
- VclBuilder::stringmap::iterator aFind = rMap.find(OString(RTL_CONSTASCII_STRINGPARAM("dropdown")));
- if (aFind != rMap.end())
- {
- bDropdown = toBool(aFind->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 4cea57f..5d02b3b 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")
{
commit f19cc396580726f9fa1c75a2b6346e2a4827acc2
Author: Caolán McNamara <caolanm at redhat.com>
Date: Wed Jul 3 11:36:51 2013 +0100
metric and numeric boxes should calc optimal size based on legal input range
Change-Id: I8515f71a562caf8332a4eea20dab5636a9343ec6
diff --git a/include/vcl/field.hxx b/include/vcl/field.hxx
index 67bf9a2..13cec22 100644
--- a/include/vcl/field.hxx
+++ b/include/vcl/field.hxx
@@ -722,6 +722,8 @@ public:
explicit NumericBox( Window* pParent, const ResId& );
virtual ~NumericBox();
+ virtual Size CalcMinimumSize() const;
+
virtual long PreNotify( NotifyEvent& rNEvt );
virtual long Notify( NotifyEvent& rNEvt );
virtual void DataChanged( const DataChangedEvent& rDCEvt );
@@ -749,6 +751,8 @@ public:
virtual long Notify( NotifyEvent& rNEvt );
virtual void DataChanged( const DataChangedEvent& rDCEvt );
+ virtual Size CalcMinimumSize() const;
+
virtual void Modify();
virtual void CustomConvert();
diff --git a/vcl/source/control/field.cxx b/vcl/source/control/field.cxx
index b491ba5..7ed2a71 100644
--- a/vcl/source/control/field.cxx
+++ b/vcl/source/control/field.cxx
@@ -940,7 +940,7 @@ void NumericField::Last()
namespace
{
- Size calcMinimumSize(const SpinField &rSpinField, const NumericFormatter &rFormatter)
+ Size calcMinimumSize(const Edit &rSpinField, const NumericFormatter &rFormatter)
{
OUStringBuffer aBuf;
sal_Int32 nTextLen;
@@ -1003,6 +1003,11 @@ NumericBox::NumericBox( Window* pParent, const ResId& rResId ) :
Show();
}
+Size NumericBox::CalcMinimumSize() const
+{
+ return calcMinimumSize(*this, *this);
+}
+
// -----------------------------------------------------------------------
NumericBox::~NumericBox()
@@ -1935,6 +1940,11 @@ MetricBox::MetricBox( Window* pParent, const ResId& rResId ) :
Show();
}
+Size MetricBox::CalcMinimumSize() const
+{
+ return calcMinimumSize(*this, *this);
+}
+
// -----------------------------------------------------------------------
MetricBox::~MetricBox()
commit e8f34963459c973d681055d708166d43079b7eb7
Author: Caolán McNamara <caolanm at redhat.com>
Date: Wed Jul 3 11:34:56 2013 +0100
adjust ComboBox optimal size for non-dropdown case
Change-Id: Iedcd27e1e40e4d69a9776ba23ec88981fe031710
diff --git a/vcl/source/control/combobox.cxx b/vcl/source/control/combobox.cxx
index e89bc53..35f2e6f 100644
--- a/vcl/source/control/combobox.cxx
+++ b/vcl/source/control/combobox.cxx
@@ -1069,27 +1069,30 @@ Size ComboBox::CalcMinimumSize() const
if (!mpImplLB)
return aSz;
- if ( !IsDropDownBox() )
+ if (!IsDropDownBox())
{
aSz = mpImplLB->CalcSize( mpImplLB->GetEntryList()->GetEntryCount() );
aSz.Height() += mnDDHeight;
+ aSz.Width() = std::max(aSz.Width(), Edit::CalcMinimumSizeForText(GetText()).Width());
}
else
{
- aSz.Height() = Edit::CalcMinimumSizeForText(GetText()).Height();
+ aSz = Edit::CalcMinimumSizeForText(GetText());
+ }
- aSz.Width() = mpImplLB->GetMaxEntryWidth();
- if (m_nMaxWidthChars != -1)
- {
- long nMaxWidth = m_nMaxWidthChars * approximate_char_width();
- aSz.Width() = std::min(aSz.Width(), nMaxWidth);
- }
- aSz.Width() += getMaxWidthScrollBarAndDownButton();
- ComboBoxBounds aBounds(calcComboBoxDropDownComponentBounds(
- Size(0xFFFF, 0xFFFF), Size(0xFFFF, 0xFFFF)));
- aSz.Width() += aBounds.aSubEditPos.X()*2;
+ if (m_nMaxWidthChars != -1)
+ {
+ long nMaxWidth = m_nMaxWidthChars * approximate_char_width();
+ aSz.Width() = std::min(aSz.Width(), nMaxWidth);
}
+ if (IsDropDownBox())
+ aSz.Width() += getMaxWidthScrollBarAndDownButton();
+
+ ComboBoxBounds aBounds(calcComboBoxDropDownComponentBounds(
+ Size(0xFFFF, 0xFFFF), Size(0xFFFF, 0xFFFF)));
+ aSz.Width() += aBounds.aSubEditPos.X()*2;
+
aSz.Width() += ImplGetExtraOffset() * 2;
aSz = CalcWindowSize( aSz );
More information about the Libreoffice-commits
mailing list