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
This commit is contained in:
Caolán McNamara 2013-07-03 11:39:16 +01:00
parent f19cc39658
commit 30db63e8a3
4 changed files with 129 additions and 49 deletions

View File

@ -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"

View File

@ -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);

View File

@ -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;

View File

@ -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")
{