[Libreoffice-commits] .: Branch 'feature/cmclayout' - 4 commits - accessibility/source vcl/inc vcl/source
Caolán McNamara
caolan at kemper.freedesktop.org
Mon Apr 30 02:28:07 PDT 2012
accessibility/source/standard/vclxaccessibleradiobutton.cxx | 5
vcl/inc/vcl/builder.hxx | 16 +
vcl/inc/vcl/button.hxx | 22 +-
vcl/source/control/button.cxx | 118 ++++++------
vcl/source/window/builder.cxx | 46 +++-
vcl/source/window/layout.cxx | 2
6 files changed, 129 insertions(+), 80 deletions(-)
New commits:
commit a707b39833c1b57a043ef99620dd479bc8a8a523
Author: Caolán McNamara <caolanm at redhat.com>
Date: Mon Apr 30 10:25:34 2012 +0100
just return a vector rather than pass one in by ref to be cleared
diff --git a/accessibility/source/standard/vclxaccessibleradiobutton.cxx b/accessibility/source/standard/vclxaccessibleradiobutton.cxx
index 73eefb6..003b9df 100644
--- a/accessibility/source/standard/vclxaccessibleradiobutton.cxx
+++ b/accessibility/source/standard/vclxaccessibleradiobutton.cxx
@@ -104,9 +104,8 @@ void VCLXAccessibleRadioButton::FillAccessibleRelationSet( utl::AccessibleRelati
RadioButton* pRadioButton = dynamic_cast< RadioButton* >( GetWindow() );
if ( pRadioButton )
{
- ::std::vector< RadioButton* > aGroup;
- pRadioButton->GetRadioButtonGroup( aGroup, true );
- if ( !aGroup.empty() )
+ ::std::vector< RadioButton* > aGroup(pRadioButton->GetRadioButtonGroup(true));
+ if (!aGroup.empty())
{
sal_Int32 i = 0;
Sequence< Reference< XInterface > > aSequence( static_cast< sal_Int32 >( aGroup.size() ) );
diff --git a/vcl/inc/vcl/button.hxx b/vcl/inc/vcl/button.hxx
index 76b1408..3fc5dc7 100644
--- a/vcl/inc/vcl/button.hxx
+++ b/vcl/inc/vcl/button.hxx
@@ -388,14 +388,14 @@ public:
or giving up the SolarMutex may mean events get executed that lead to the pointers getting
invalid.
- @param io_rGroup
- gets cleared on entering the function. on return contains the <code>RadioButton</code>s
- in the same group as this <code>RadioButton</code>.
-
@param bIncludeThis
defines whether <code>this</code> is contained in the returned list
+
+ @return
+ on return contains the <code>RadioButton</code>s
+ in the same group as this <code>RadioButton</code>.
*/
- void GetRadioButtonGroup( std::vector<RadioButton*>& io_rGroup, bool bIncludeThis ) const;
+ std::vector<RadioButton*> GetRadioButtonGroup(bool bIncludeThis = true) const;
virtual bool set_property(const rtl::OString &rKey, const rtl::OString &rValue);
void group(RadioButton &rOther);
diff --git a/vcl/source/control/button.cxx b/vcl/source/control/button.cxx
index fc2248c..b070115 100644
--- a/vcl/source/control/button.cxx
+++ b/vcl/source/control/button.cxx
@@ -2316,25 +2316,24 @@ void RadioButton::group(RadioButton &rOther)
// .-----------------------------------------------------------------------
-void RadioButton::GetRadioButtonGroup( std::vector< RadioButton* >& io_rGroup, bool bIncludeThis ) const
+std::vector< RadioButton* > RadioButton::GetRadioButtonGroup(bool bIncludeThis) const
{
- // empty the list
- io_rGroup.clear();
+ std::vector< RadioButton* > aGroup;
if (m_xGroup)
{
for (std::set<RadioButton*>::iterator aI = m_xGroup->begin(), aEnd = m_xGroup->end(); aI != aEnd; ++aI)
{
RadioButton *pRadioButton = *aI;
- if (pRadioButton == this)
+ if (!bIncludeThis && pRadioButton == this)
continue;
- io_rGroup.push_back(pRadioButton);
+ aGroup.push_back(pRadioButton);
}
- return;
+ return aGroup;
}
//old-school
- SAL_WARN("vcl", "No group set on radiobutton");
+ SAL_WARN("vcl", "No new-style group set on radiobutton, using old-style digging around");
// go back to first in group;
Window* pFirst = const_cast<RadioButton*>(this);
@@ -2352,10 +2351,12 @@ void RadioButton::GetRadioButtonGroup( std::vector< RadioButton* >& io_rGroup, b
if( pFirst->GetType() == WINDOW_RADIOBUTTON )
{
if( pFirst != this || bIncludeThis )
- io_rGroup.push_back( static_cast<RadioButton*>(pFirst) );
+ aGroup.push_back( static_cast<RadioButton*>(pFirst) );
}
pFirst = pFirst->GetWindow( WINDOW_NEXT );
} while( pFirst && ( ( pFirst->GetStyle() & WB_GROUP ) == 0 ) );
+
+ return aGroup;
}
// -----------------------------------------------------------------------
@@ -2364,8 +2365,7 @@ void RadioButton::ImplUncheckAllOther()
{
mpWindowImpl->mnStyle |= WB_TABSTOP;
- std::vector<RadioButton*> aGroup;
- GetRadioButtonGroup(aGroup, false);
+ std::vector<RadioButton*> aGroup(GetRadioButtonGroup(false));
// Gruppe mit RadioButtons durchgehen und die gecheckten Buttons
for (std::vector<RadioButton*>::iterator aI = aGroup.begin(), aEnd = aGroup.end(); aI != aEnd; ++aI)
{
commit 09593c5366945e55d9e8bce982591d76b4eae8ac
Author: Caolán McNamara <caolanm at redhat.com>
Date: Mon Apr 30 10:19:19 2012 +0100
implement RadioButton groups
diff --git a/vcl/inc/vcl/builder.hxx b/vcl/inc/vcl/builder.hxx
index ffb2e54..730fd34 100644
--- a/vcl/inc/vcl/builder.hxx
+++ b/vcl/inc/vcl/builder.hxx
@@ -49,6 +49,19 @@ private:
}
};
std::vector<WinAndId> m_aChildren;
+
+ struct RadioButtonGroupMap
+ {
+ rtl::OString m_sID;
+ rtl::OString m_sGroup;
+ RadioButtonGroupMap(const rtl::OString &rId, const rtl::OString &rGroup)
+ : m_sID(rId)
+ , m_sGroup(rGroup)
+ {
+ }
+ };
+ std::vector<RadioButtonGroupMap> m_aGroups;
+
rtl::OString m_sID;
Window *m_pParent;
public:
@@ -60,7 +73,8 @@ public:
typedef std::map<rtl::OString, rtl::OString> stringmap;
private:
Window *insertObject(Window *pParent, const rtl::OString &rClass, const rtl::OString &rID, stringmap &rVec);
- Window *makeObject(Window *pParent, const rtl::OString &rClass, stringmap &rVec);
+ Window *makeObject(Window *pParent, const rtl::OString &rClass, const rtl::OString &rID, stringmap &rVec);
+ bool extractGroup(const rtl::OString &id, stringmap &rVec);
void handleChild(Window *pParent, xmlreader::XmlReader &reader);
Window* handleObject(Window *pParent, xmlreader::XmlReader &reader);
diff --git a/vcl/inc/vcl/button.hxx b/vcl/inc/vcl/button.hxx
index c5bc274..76b1408 100644
--- a/vcl/inc/vcl/button.hxx
+++ b/vcl/inc/vcl/button.hxx
@@ -37,6 +37,7 @@
#include <vcl/bitmap.hxx>
#include <vcl/salnativewidgets.hxx>
+#include <set>
#include <vector>
class UserDrawEvent;
@@ -286,10 +287,10 @@ private:
Rectangle maStateRect;
Rectangle maMouseRect;
Image maImage;
- sal_Bool mbChecked;
- sal_Bool mbSaveValue;
- sal_Bool mbRadioCheck;
- sal_Bool mbStateChanged;
+ sal_Bool mbChecked;
+ sal_Bool mbSaveValue;
+ sal_Bool mbRadioCheck;
+ sal_Bool mbStateChanged;
Link maToggleHdl;
SAL_DLLPRIVATE void ImplInitRadioButtonData();
@@ -311,6 +312,8 @@ private:
SAL_DLLPRIVATE RadioButton& operator= (const RadioButton &);
protected:
+ boost::shared_ptr< std::set<RadioButton*> > m_xGroup;
+
using Control::ImplInitSettings;
using Window::ImplInit;
SAL_DLLPRIVATE void ImplInit( Window* pParent, WinBits nStyle );
@@ -395,6 +398,7 @@ public:
void GetRadioButtonGroup( std::vector<RadioButton*>& io_rGroup, bool bIncludeThis ) const;
virtual bool set_property(const rtl::OString &rKey, const rtl::OString &rValue);
+ void group(RadioButton &rOther);
};
// ------------
diff --git a/vcl/source/control/button.cxx b/vcl/source/control/button.cxx
index d6c1e83..fc2248c 100644
--- a/vcl/source/control/button.cxx
+++ b/vcl/source/control/button.cxx
@@ -2291,13 +2291,51 @@ void RadioButton::ImplDrawRadioButton( bool bLayout )
}
}
-// -----------------------------------------------------------------------
+void RadioButton::group(RadioButton &rOther)
+{
+ if (!m_xGroup)
+ {
+ m_xGroup.reset(new std::set<RadioButton*>);
+ m_xGroup->insert(this);
+ }
+
+ if (rOther.m_xGroup)
+ {
+ for (std::set<RadioButton*>::iterator aI = rOther.m_xGroup->begin(), aEnd = rOther.m_xGroup->end(); aI != aEnd; ++aI)
+ m_xGroup->insert(*aI);
+ }
+
+ m_xGroup->insert(&rOther);
+
+ rOther.m_xGroup = m_xGroup;
+
+ //if this one is checked, uncheck all the others
+ if (mbChecked)
+ ImplUncheckAllOther();
+}
+
+// .-----------------------------------------------------------------------
void RadioButton::GetRadioButtonGroup( std::vector< RadioButton* >& io_rGroup, bool bIncludeThis ) const
{
// empty the list
io_rGroup.clear();
+ if (m_xGroup)
+ {
+ for (std::set<RadioButton*>::iterator aI = m_xGroup->begin(), aEnd = m_xGroup->end(); aI != aEnd; ++aI)
+ {
+ RadioButton *pRadioButton = *aI;
+ if (pRadioButton == this)
+ continue;
+ io_rGroup.push_back(pRadioButton);
+ }
+ return;
+ }
+
+ //old-school
+ SAL_WARN("vcl", "No group set on radiobutton");
+
// go back to first in group;
Window* pFirst = const_cast<RadioButton*>(this);
while( ( pFirst->GetStyle() & WB_GROUP ) == 0 )
@@ -2416,6 +2454,8 @@ void RadioButton::ImplLoadRes( const ResId& rResId )
RadioButton::~RadioButton()
{
+ if (m_xGroup)
+ m_xGroup->erase(this);
}
// -----------------------------------------------------------------------
diff --git a/vcl/source/window/builder.cxx b/vcl/source/window/builder.cxx
index 2a1edca..183b718 100644
--- a/vcl/source/window/builder.cxx
+++ b/vcl/source/window/builder.cxx
@@ -39,11 +39,24 @@ VclBuilder::VclBuilder(Window *pParent, rtl::OUString sUri, rtl::OString sID)
: m_sID(sID)
, m_pParent(pParent)
{
- fprintf(stderr, "now trying %s\n", rtl::OUStringToOString(sUri, RTL_TEXTENCODING_UTF8).getStr());
xmlreader::XmlReader reader(sUri);
handleChild(pParent, reader);
+ //Set radiobutton groups when everything has been imported
+ for (std::vector<RadioButtonGroupMap>::iterator aI = m_aGroups.begin(),
+ aEnd = m_aGroups.end(); aI != aEnd; ++aI)
+ {
+ RadioButton *pOne = static_cast<RadioButton*>(get_by_name(aI->m_sID));
+ RadioButton *pOther = static_cast<RadioButton*>(get_by_name(aI->m_sGroup));
+ SAL_WARN_IF(!pOne || !pOther, "vcl", "missing member of radiobutton group");
+ if (pOne && pOther)
+ pOne->group(*pOther);
+ }
+ //drop maps now
+ std::vector<RadioButtonGroupMap>().swap(m_aGroups);
+
+ //auto-show (really necessary ?, maybe drop it when complete)
for (std::vector<WinAndId>::iterator aI = m_aChildren.begin(),
aEnd = m_aChildren.end(); aI != aEnd; ++aI)
{
@@ -119,7 +132,19 @@ namespace
}
}
-Window *VclBuilder::makeObject(Window *pParent, const rtl::OString &name, stringmap &rMap)
+bool VclBuilder::extractGroup(const rtl::OString &id, stringmap &rMap)
+{
+ VclBuilder::stringmap::iterator aFind = rMap.find(rtl::OString(RTL_CONSTASCII_STRINGPARAM("group")));
+ if (aFind != rMap.end())
+ {
+ m_aGroups.push_back(RadioButtonGroupMap(id, aFind->second));
+ rMap.erase(aFind);
+ return true;
+ }
+ return false;
+}
+
+Window *VclBuilder::makeObject(Window *pParent, const rtl::OString &name, const rtl::OString &id, stringmap &rMap)
{
Window *pWindow = NULL;
if (name.equalsL(RTL_CONSTASCII_STRINGPARAM("GtkDialog")))
@@ -147,7 +172,10 @@ Window *VclBuilder::makeObject(Window *pParent, const rtl::OString &name, string
else if (name.equalsL(RTL_CONSTASCII_STRINGPARAM("GtkButton")))
pWindow = extractStockAndBuildButton(pParent, rMap);
else if (name.equalsL(RTL_CONSTASCII_STRINGPARAM("GtkRadioButton")))
+ {
+ extractGroup(id, rMap);
pWindow = new RadioButton(pParent, WB_CENTER|WB_VCENTER|WB_3DLOOK);
+ }
else if (name.equalsL(RTL_CONSTASCII_STRINGPARAM("GtkCheckButton")))
pWindow = new CheckBox(pParent, WB_CENTER|WB_VCENTER|WB_3DLOOK);
else if (name.equalsL(RTL_CONSTASCII_STRINGPARAM("GtkSpinButton")))
@@ -171,17 +199,13 @@ Window *VclBuilder::insertObject(Window *pParent, const rtl::OString &rClass, co
if (!m_sID.isEmpty() && rID.equals(m_sID))
{
pCurrentChild = m_pParent;
- fprintf(stderr, "inserting into parent dialog\n");
//toplevels default to resizable
if (pCurrentChild->IsDialog())
- {
- fprintf(stderr, "forcing resizable\n");
pCurrentChild->SetStyle(pCurrentChild->GetStyle() | WB_SIZEMOVE);
- }
}
else
{
- pCurrentChild = makeObject(pParent, rClass, rMap);
+ pCurrentChild = makeObject(pParent, rClass, rID, rMap);
if (!pCurrentChild)
fprintf(stderr, "missing object!\n");
else
@@ -429,7 +453,13 @@ void VclBuilder::collectProperty(xmlreader::XmlReader &reader, stringmap &rMap)
reader.nextItem(
xmlreader::XmlReader::TEXT_NORMALIZED, &name, &nsId);
rtl::OString sValue(name.begin, name.length);
- rMap[sProperty] = sValue.replace('_', '-');
+ //replace '_' with '-' except for property values that
+ //refer to widget ids themselves. TO-DO, drop conversion
+ //and just use foo_bar properties throughout
+ if (sProperty.equalsL(RTL_CONSTASCII_STRINGPARAM("group")))
+ rMap[sProperty] = sValue;
+ else
+ rMap[sProperty] = sValue.replace('_', '-');
}
}
}
commit fe933b188c3fdb89691abc82dee410905ab0ffb0
Author: Caolán McNamara <caolanm at redhat.com>
Date: Mon Apr 30 09:53:09 2012 +0100
n-rows doesn't matter, auto sizes depending on children
diff --git a/vcl/source/window/layout.cxx b/vcl/source/window/layout.cxx
index 5d6b587..b3789a5 100644
--- a/vcl/source/window/layout.cxx
+++ b/vcl/source/window/layout.cxx
@@ -509,6 +509,8 @@ bool VclGrid::set_property(const rtl::OString &rKey, const rtl::OString &rValue)
set_row_homogeneous(toBool(rValue));
else if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("column-homogeneous")))
set_column_homogeneous(toBool(rValue));
+ else if (rKey.equalsL(RTL_CONSTASCII_STRINGPARAM("n-rows")))
+ /*nothing to do*/;
else
return Window::set_property(rKey, rValue);
return true;
commit 8a2edf4728e0c1eb34dc0a163e706a56a480729d
Author: Caolán McNamara <caolanm at redhat.com>
Date: Mon Apr 30 08:59:54 2012 +0100
use GetRadioButtonGroup to get other members of the radiobutton group
diff --git a/vcl/source/control/button.cxx b/vcl/source/control/button.cxx
index 5060bd1..d6c1e83 100644
--- a/vcl/source/control/button.cxx
+++ b/vcl/source/control/button.cxx
@@ -2326,64 +2326,24 @@ void RadioButton::ImplUncheckAllOther()
{
mpWindowImpl->mnStyle |= WB_TABSTOP;
+ std::vector<RadioButton*> aGroup;
+ GetRadioButtonGroup(aGroup, false);
// Gruppe mit RadioButtons durchgehen und die gecheckten Buttons
- Window* pWindow;
- WinBits nStyle;
- if ( !(GetStyle() & WB_GROUP) )
+ for (std::vector<RadioButton*>::iterator aI = aGroup.begin(), aEnd = aGroup.end(); aI != aEnd; ++aI)
{
- pWindow = GetWindow( WINDOW_PREV );
- while ( pWindow )
+ RadioButton *pWindow = *aI;
+ if ( pWindow->IsChecked() )
{
- nStyle = pWindow->GetStyle();
-
- if ( pWindow->GetType() == WINDOW_RADIOBUTTON )
- {
- if ( ((RadioButton*)pWindow)->IsChecked() )
- {
- ImplDelData aDelData;
- pWindow->ImplAddDel( &aDelData );
- ((RadioButton*)pWindow)->SetState( sal_False );
- if ( aDelData.IsDelete() )
- return;
- pWindow->ImplRemoveDel( &aDelData );
- }
- // Um falsch gesetzt WB_TABSTOPS immer zu entfernen, nicht
- // innerhalb der if-Abfrage
- pWindow->mpWindowImpl->mnStyle &= ~WB_TABSTOP;
- }
-
- if ( nStyle & WB_GROUP )
- break;
-
- pWindow = pWindow->GetWindow( WINDOW_PREV );
- }
- }
-
- pWindow = GetWindow( WINDOW_NEXT );
- while ( pWindow )
- {
- nStyle = pWindow->GetStyle();
-
- if ( nStyle & WB_GROUP )
- break;
-
- if ( pWindow->GetType() == WINDOW_RADIOBUTTON )
- {
- if ( ((RadioButton*)pWindow)->IsChecked() )
- {
- ImplDelData aDelData;
- pWindow->ImplAddDel( &aDelData );
- ((RadioButton*)pWindow)->SetState( sal_False );
- if ( aDelData.IsDelete() )
- return;
- pWindow->ImplRemoveDel( &aDelData );
- }
- // Um falsch gesetzt WB_TABSTOPS immer zu entfernen, nicht
- // innerhalb der if-Abfrage
- pWindow->mpWindowImpl->mnStyle &= ~WB_TABSTOP;
+ ImplDelData aDelData;
+ pWindow->ImplAddDel( &aDelData );
+ pWindow->SetState( sal_False );
+ if ( aDelData.IsDelete() )
+ return;
+ pWindow->ImplRemoveDel( &aDelData );
}
-
- pWindow = pWindow->GetWindow( WINDOW_NEXT );
+ // Um falsch gesetzt WB_TABSTOPS immer zu entfernen, nicht
+ // innerhalb der if-Abfrage
+ pWindow->mpWindowImpl->mnStyle &= ~WB_TABSTOP;
}
}
More information about the Libreoffice-commits
mailing list